[e-lang] Announcing Release Candidate 0.8.33g: User Defined Control Flow

Mark Miller markm at cs.jhu.edu
Sat Dec 25 18:11:11 EST 2004


Mark Miller wrote:
> [...] Other possible ways to preserve the sepWord info:
> 
> * mangle them into the name of the message name, as Smalltalk does.
> * mangle them into the name of the function being invoked.
> * treat each pair as a keyword argument, where the sepWord is the
>   keyword and the function is its value.

I think the second proposal is disqualified on security grounds. The object
you're invoking is the one you're relying on. It's important for the code to
be clear about which object this is.

The third proposal and the current interim expansion create a performance
problem, at least for naive implementations -- the need for double dispatch.
We might wish to do different things in response to the use of different
sepWords. For example, we might wish to extend of __for to respond to
"collect", "fold", "select", etc. For control abstractions, performance is
especially important. So I think the Smalltalk-like mangling scheme is the way
to go. It leverages the dispatch we're already paying for.


Speaking of __for, ...

>     ? def __for(collection,
>     >           `do`, assocFunc) {
>     >     def noReturnFunc(k,v) {
>     >         assocFunc(k,v)
>     >     }
>     >     __dynamicExtent (noReturnFunc) as func {
>     >         collection.iterate(func)
>     >     }
>     > }

the use of __dynamicExtent above is quite silly. __for can do this job as
easily for itself as it can contract it out.

     ? def __for(collection,
     >           `do`, var assocFunc) {
     >     try {
     >         def noResultFunc(k,v) {
     >             assocFunc(k,v)
     >         }
     >         collection.iterate(noResultFunc)
     >     } finally {
     >         assocFunc := Ref.broken("loop body disabled")
     >     }
     > }

This also avoids an extra layer of wrapping.

-- 
Text by me above is hereby placed in the public domain

     Cheers,
     --MarkM



More information about the e-lang mailing list