[cap-talk] Last Call for ref_send API 1.0

Dean Tribble tribble at e-dean.com
Thu Apr 5 11:31:35 CDT 2007


On 4/4/07, Sandro Magi <smagi at higherlogics.com> wrote:
>
> Dean Tribble wrote:
> >     > Closure is a very common concept that is only loosely reflected it
> the
> >     > decalred interface.
> >     Errr.. "only loosely". Please explain.
> > Closures are not generally restricted to a one argument, and generally
> > contain a pair of a function and an environment.
>
> SML functions are single-argument with multiple arguments supported via
> tuples; this is more or less what ref_send does. You could define
> explict tuples (Pair, Triple, ..., Nuple), but an array as in ref_send
> works as well.


I don't dispute that a one argument function could be considered a closure.
I merely observe the lots of things that are not one arg functions could
equally be considered functions.  Runnable, for example, is a "closure" type
that is very integral to Java libraries.  Java does not follow the SML
pattern of having ginle-argument functions and metods everywhere; if one
were to extend Java with general closure support, it would likely support
closures different numbers of arguments. Since it's only a name, it's cheap
at this point to not introduce the confusion.

...
> Yes, C# delegates are closures, but they're only "closer" because
> there's more direct compiler support/syntactic sugar:


I generally agree  The two features I woul want from a "closures
implementation" in a Java-style language are support for multiple arguments
and support for closing over arguments.

return delegate(int a) {return a+b;}
>
> I don't see how this is conceptually different to:
>
> final int b=1;
> return new Closure<int,int>() {
> int post(int arg) { return b + arg; } };


The difference is 'that "return delegate(int a, int c) {return a+b-c;}"
can't be expressed by Closure:)

Adding first-class functions to an OO language generally involves
> defining a distinguished interface with a single 'apply' method, which
> is exactly this.


Hence my suggestions of Fn1, Fn2, etc.

I don't see why Microsoft didn't take this approach
> with .NET in fact; would have simplified the concepts and the VM.


I don't either :)  And don't ask me about multidelegates :)

I think we've now exceeded the effort this topic deserves,since while
potentially confusing, it's not a very big issue.  Tyler can of course use
any names he pleases, but I thought I'd point out the potential confusions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eros-os.org/pipermail/cap-talk/attachments/20070405/2e1515c1/attachment.html 


More information about the cap-talk mailing list