Suggestion: "new delegate" - delegates useable outside of the nesting function scope

Burton Radons burton-radons at smocky.com
Fri Jun 2 17:18:42 PDT 2006


I use delegates a lot but the fact that they can only live until the end 
of the nesting function scope means I need to use classes in many cases, 
which is a lot more typing (and fluff telling the autodoc that it's not 
part of the public API, and other problems) when it could be easily 
fixed. The syntax change would be very simple:

	dispatcher.add (new delegate void (Event event) { ... });

And the effect would be simple as well: duplicate the calling context's 
stack to the extent that the delegate can see it and use the duplicated 
pointer as the "this" pointer; otherwise it's a regular nested delegate. 
Five minutes work max, very topical changes, explicit allocation, big 
benefits. Is good!



More information about the Digitalmars-d mailing list