tags:

views:

57

answers:

2

Is it possible to specify parameter names for delegate types in F#? When I create a delegate of this type in F#:

type DataValidationEventHandler = delegate of obj * DataValidationEventArgs -> unit

...it auto-generates this signature for the handler in C#:

static void loader_ValidationEvent(object __p1, DataValidationEventArgs __p2)

Ideally it would generate the usual 'sender' and 'e' parameter names.

+3  A: 

Yes:

type DataValidationEventHandler = delegate of sender:obj * e:DataValidationEventArgs -> unit
kvb
Bleh. I tried that, but I put parens around 'sender:obj' (as you would in a function signature). Good to know that doesn't work. Thanks.
Daniel
how do you do this for c#?
Bless Yahu
@Bless Yahu - in C# delegate types always have parameter names - there is no way to omit them. For example the equivalent C# delegate would be `delegate void DataValidationEventHanlder(object sender, DataValidationEventArgs e)`.`
kvb
My mistake, I was mistook this on how to provide the xml comments for parameters of delegates.
Bless Yahu
+1  A: 

Yes:

type MyDel = delegate of o:obj * ea:System.EventArgs -> unit

names them o and ea.

Brian