Groovy

Andrey Khropov andkhropov_nosp at m_mtu-net.ru
Mon Jan 1 10:07:35 PST 2007


Jarrett Billingsley wrote:

>The closest thing we have now is:
> 
> for_each(list, (x)
> {
>    writefln(x);
> });

Unfortunately type inference for delegate parameters isn't supported yet :(. So
we have to specify its type:

for_each(list, (int x)
{
    writefln(x);
});


> This is basically what Suneido is doing for you behind the scenes.  It seems
> like a relatively simple feature to implement, but there are many issues to
> consider.  One, when do you allocate the context for the delegate?  When it
> leaves the function?  How do you know that it isn't assigned to somewhere
> else and not returned?  So you allocate it when it's declared, but then you
> lose the ability to access the outer function's copy of the locals, and you
> also lose performance if the delegate never needs to be returned, so you're
> allocating an unnecessary context with every call to the outer function. Then
> there's the problem of nested functions in nested functions accessing local
> variables from more than one level of nesting... etc. etc. etc.

There are a plenty of functional programming language compilers that
successfully deal with these problems.

-- 
AKhropov



More information about the Digitalmars-d mailing list