PC Review


Reply
Thread Tools Rate Thread

delegate syntax

 
 
Rick Lones
Guest
Posts: n/a
 
      24th Mar 2011
When I declare a delegate signature thusly . . .

private delegate void eventHandler(EventWaitHandle ewh);

. . . can someone explain why the "ewh" identifier is required? It appears
completely superfluous to me - the parameter type(s) and position(s) seem like
all that should be needed. This is .Net 2.0 BTW, dunno what changes in later
incarnations.

-rick-
 
Reply With Quote
 
 
 
 
kndg
Guest
Posts: n/a
 
      25th Mar 2011
On 3/25/2011 4:48 AM, Rick Lones wrote:
> When I declare a delegate signature thusly . . .
>
> private delegate void eventHandler(EventWaitHandle ewh);
>
> . . . can someone explain why the "ewh" identifier is required? It
> appears completely superfluous to me - the parameter type(s) and
> position(s) seem like all that should be needed. This is .Net 2.0 BTW,
> dunno what changes in later incarnations.
>
> -rick-


I think it is also the same with interface declaration where the method
identifier is superfluos, but actualy I prefer that way because I know
what that parameter supposed to means (which improve readability).
 
Reply With Quote
 
Rick Lones
Guest
Posts: n/a
 
      25th Mar 2011
Peter Duniho wrote:
> On 3/24/11 1:48 PM, Rick Lones wrote:
>> When I declare a delegate signature thusly . . .
>>
>> private delegate void eventHandler(EventWaitHandle ewh);
>>
>> . . . can someone explain why the "ewh" identifier is required? It
>> appears completely superfluous to me - the parameter type(s) and
>> position(s) seem like all that should be needed. This is .Net 2.0 BTW,
>> dunno what changes in later incarnations.

>
> It's the same in all versions of the language. And yes, the parameter
> name is theoretically superfluous. However, note that delegate types
> use the same data structure to define the signature as for methods, the
> MethodInfo type (which you can retrieve from the delegate type by
> getting the MethodInfo for the Invoke() method on the type), and the
> MethodInfo type has to include parameter names.
>
> I suppose the compiler could have just put in some placeholders, but it
> seems to me that for those moments when one is in fact looking at the
> parameter names (either in the type declaration or via reflection),
> having meaningful parameter names is very useful. The type alone is
> often insufficient to explain how a parameter should be used (e.g.
> "sender" in the EventHandler delegate type).


It's been so long I had to peek at an old C header file to be sure that the
parameter was not required in, e.g., an extern declaration. It seems basically
an artifact then but one of "intelligent design". I do see some advantages,
especially as regards your point re MethodInfo. Thanks.

-rick-
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delegate issue - meetings only show up after delegate opened the request nils.pommerien@gmail.com Microsoft Outlook Calendar 0 21st Jul 2006 06:16 PM
Outlook 2002 - Delegate updates in delegate calendar? =?Utf-8?B?V2F6emE=?= Microsoft Outlook Calendar 0 1st Feb 2006 11:20 AM
Newby delegate problem - syntax problems I guess Cosmin Prund Microsoft C# .NET 5 16th Nov 2005 07:23 AM
Delegate Gurus: Can I create a delegate for a property (as opposed to a method)? Bill Davidson Microsoft C# .NET 6 3rd Aug 2005 04:19 PM
delegate handling, or incorrect syntax... either way how can i do this? Eric Newton Microsoft VB .NET 1 5th Jan 2004 04:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:07 AM.