[E-Lang] the return of `return'

Dean Tribble tribble@e-dean.com
Tue, 19 Jun 2001 00:49:29 -0700


>That's an excellent point!  This renaming is the `uglier expansion' I
>had in mind, instead of Zooko's special kind of function def that
>doesn't rebind `return', since the renaming doesn't need new syntax.
>I just had a queer blind spot, thinking of it as hygienic only when
>there's an explicit binding occurrence of the name.  I feel better
>about this now.

Your theory of hygienic is actually correct; the above binding of return is 
non-hygienic; i.e., the renamed return captures use occurrences that do not 
syntactically designate it.  The capture is well structured, however, so it 
is at least elegant or clean, but that's definitely not the same as the 
formal hygienic property.  In particular, the transformation will need to 
explicitly say which syntactic scope the "return" is bound (and hence how 
it gets renamed), even if the transformation mechanism is not conceived in 
terms of syntactic environments (e.g., even if the compiler is implemented 
as ad hoc AST tree transformations, it will need to figure out which 
"return" it is binding).

>[...]
> > >    def fooMaker(x) {
> > >        return(def foo {
> > >            to blat() { ... }
> > >        })
> > >    }
> >
> > With special syntax, the above would be:
> >
> >     def fooMaker(x) {
> >         return def foo {
> >             to blat() { ... }
> >         }
> >     }
>
>The `return' there still annoys me but it's not nearly as bad as with
>the parens...
>
> > or perhaps even
> >
> >     def fooMaker(x) {
> >         return foo {
> >             to blat() { ... }
> >         }
> >     }
>
>If this were the first code I saw then I'd be scratching my head
>wondering what it means.

A good reason to consider it too clever.  Perhaps the more verbose, but 
simpler, example below?

     def fooMaker(x) {
         def foo {
             to blat() { ... }
         }
         return foo
     }


>[...]
> > Which immediately and trivially optimizes to
> >
> >     def fooMaker(x) {
> >         def foo {
> >             to blat() { ... }
> >         }
> >     }
>If this code is still valid Kernel E but full E requires `return',
>then Kernel E is no longer an E subset.  One fix: require all Kernel E
>object definitions to look like ``to foo() { return ... }'' and
>translate any nonlocal returns to explicit escape expressions.

Oops.  Good point.