Dynamic Closure + Lazy Arguments = Performance Killer?

Jarrett Billingsley jarrett.billingsley at gmail.com
Sat Oct 25 11:38:36 PDT 2008


On Sat, Oct 25, 2008 at 1:17 PM, Frits van Bommel
<fvbommel at remwovexcapss.nl> wrote:
>> Fantastic.  That also neatly solves the "returning a delegate"
>> problem; it simply becomes illegal to return a scope delegate.
>
> Even if "scope delegate" becomes a different type, sometimes such a "scope
> delegate"s is perfectly safe to return:
> -----
> alias scope void delegate() dg;
> Dg foo(Dg dg) {
>    return dg;  // Why would this be illegal?
> }
> -----
>

Clarification - it would be an error to return a scope delegate from
the scope in which it was declared.

Currently the behavior you mention (passing a scope delegate into a
function then returning it) doesn't even exist for scope classes -
parameters cannot be "scope".  I would imagine, though, that if a
parameter were scope, a function would be able to return that
parameter, and in fact that would be the only way to return a scope
reference (delegate or class) from a function.



More information about the Digitalmars-d mailing list