On Tuesday, 25 June 2013 at 04:26:00 UTC, Timothee Cour wrote:
I think it's because each lambda litteral is treated unique.
can dmd be changed to recognize identical lambda litterals as identical? Is
there any particular issue making that difficult?
it already recognizes identical string literals as identical

I could be wrong, but the difference might be that it *can* recognize string literals as idential, but it doesn't actually guarantee it as spec. This is not an issue for strings, but...

Imagine I have a module, where I declare "alias T = R!some_labda".

Then in another module, I declare "alias U = R!some_labda".

Then in a third module, would I be able to declare a T, and store it inside a U ? Would the compiler be able to see that both lambdas are actually the same? I honestly don't know.

But it seems dangerous to me: Lambdas specifically don't have names, and are unique. If you type two of them that have the same body, that shouldn't mean they are actually the same.

Also, doing this would create symbol collisions, where a user has defined two different lambdas, that have the same body, but expected different definitions. EG:

alias T = R!some_lambda;
alias U = R!some_same_lambda"
void foo(T t);
void foo(U u); //Nope, foo(U) already declared; What?

Reply via email to