On Friday, 28 June 2013 at 13:20:47 UTC, monarch_dodra wrote:

What is a "string lambda" ? Do you mean "a string alias latter parsed as an expression", or "an actual lambda function".

The former. I didn't think it was *that* obscure of a term (https://www.google.com/search?q=%22string+lambda%22+site:forum.dlang.org).

There were talks about this recently in learn: If you *type* the same lambda function twice, it *will* generate two different templates.
http://forum.dlang.org/thread/[email protected]

I'm not sure if that's due to this bug or not: http://forum.dlang.org/thread/[email protected]?page=2#post-jdcn98:241mg9:244:40digitalmars.com

However,

--------
enum PRED = () => 1;

struct S(alias pred){}

void main()
{
    auto a = S!PRED();
    auto b = S!PRED();
    a = b;
}
--------
This is fine.

If that's all it takes to avoid copies, then maybe it's not so big of a problem for lambdas.

From testing, *string* preds don't have this "feature"/"bug" (?), even if you compile time build them, the compiler will "see" that it is the same string (probably true for integrals and whatnot). But for lambdas, only their *name* counts (eg __lambda1__). So if you plan to re-use a lambda, it *must* be stored in a way the compiler can "see" its unicity, and not typed more than once.

Ditto.

Reply via email to