Function literals and lambda functions

Peter Alexander peter.alexander.au at gmail.com
Sun Mar 6 12:24:12 PST 2011


On 6/03/11 2:03 PM, Russel Winder wrote:
> PS  If you ask why not:
>
>          reduce ! ( "a+b" ) ( 0.0 , outputData )
>
> I find this somehow unacceptable.  It's the string, its not a function.
> Fine, my problem, but that still leaves the above.

You probably know this already, but just in case...

The string is converted into a function at compile time, so if you were 
scared of the possible performance hit of having to parse the string at 
runtime, then you can rest assured that it is as fast as supplying a 
normal function.

On the other hand, if you just don't like the appearance of a string as 
a function in source code then, yah, I agree. It does seem a little 
wrong, although you get used to it.


More information about the Digitalmars-d mailing list