On Thu, 17 May 2012 23:20:01 +0200, John Maschmeyer wrote:

> On Thursday, 17 May 2012 at 10:30:26 UTC, Jacob Carlborg wrote:
>> Does it work if the lambda is passed to a function:
>>
>> void foo (int delegate (int x) dg)
>> {
>>     wirteln(__traits(codeof, dg);
>> }
>>
>> foo(x => x + 1);
> 
> Unforutnately, no.  As written the lambda is a runtime parameter,
> so there is no way the trait can get the actual function code. Instead,
> all that will print is the signature of the delegate.
> 
> If that were a template parameter, it would theoretically be possible to
> print the lambda expression, but as currently implemented it doesn't.

An alias parameter to a template would actually be the ideal use-case for 
what I have in mind. Essentially, it would work just like map/reduce/
filter (function passed by alias), but translate the lambda to SQL/XPath/
etc.

Reply via email to