Delegate Literals + Immutability, pure and closures

Don nospam at nospam.com
Thu Sep 29 23:06:06 PDT 2011


On 30.09.2011 02:32, dsimcha wrote:
> On 9/29/2011 5:06 PM, David Nadlinger wrote:
>> Yes, this pattern is very useful indeed, I also often use a similar
>> solution for generating code for string mixins on the fly. Do we already
>> have a name for it, by the way? I like to call it »IEDL for »Immediately
>> Executed/Evaluated Delegate Literal«, but that's probably just me.
>
> No previously chosen name that I know of, but I like your name. Anyhow,
> I'm impressed/pleasantly surprised. I didn't realize an IEDL could be
> executed at compile time to produce a mixin string. If IEDLs are that
> universally useful, then they definitely deserve some special case
> performance optimizations, i.e. inlining and avoiding heap allocations.
> Does anyone else have any interesting use cases for them?

I use them everywhere in the test suite. They behave a lot like comma 
expressions (in that they allow you to put multiple expressions in a 
place where you'd normally only be able to have one) but they allow 
statements and declarations as well as expressions. This makes them 
extremely useful in metaprogramming.


More information about the Digitalmars-d mailing list