DIP6: Attributes

Daniel Keep daniel.keep.lists at gmail.com
Tue Aug 4 05:46:22 PDT 2009



Sergey Gromov wrote:
> Tue, 04 Aug 2009 17:22:50 +1000, Daniel Keep wrote:
> 
>> Don wrote:
>>> ...
>>>
>>> A question: in C#/Java, can you have annotations on function pointer and
>>> delegate declarations?
>>>
>>> void foo( int delegate(int) pure dg) {
>>>   ...
>>> }
>>> What would this look like with annotations?
>> Well, Java doesn't HAVE delegates and C# doesn't (AFAIK) allow you to
>> define them inline; they have a special declaration syntax that can't be
>> used in an expression.
> 
> C#:
> 
> List<int> ls;
> ls.Sort((x, y) => y - x);
> 
> or
> 
> ls.Sort((x, y) => { int a; a = y; a -= x; return a; });

That's not a delegate type, that's a delegate literal.



More information about the Digitalmars-d mailing list