[e-lang] scoping rules of when-catch

Mark S. Miller markm at cs.jhu.edu
Sun Jul 23 01:26:25 EDT 2006


This is in reply to old e-lang message
http://www.eros-os.org/pipermail/e-lang/2006-May/011314.html
Quoted in its entirety.

Kevin Reid wrote:
> On May 31, 2006, at 20:41, Mark Miller wrote:
>> On 5/31/06, Kevin Reid <kpreid at mac.com> wrote:
>>> On May 31, 2006, at 17:26, Mark Miller wrote:
>>>
>>>> <funcHeader> ::= <ident> ( <pattern>* ) <optGuard>
>>> What was the original reason for its inclusion?
>> The main one was FQN-based upgrade. The other was that I was
>> uncomfortable reasoning about the type of p in
>>
>>     when (p) -> { ... p ... }
>>
>> as being resolved within the when-closure, but unresolved outside the
>> when-closure. By contrast, in
>>
>>     when (p) -> done(i) { ... i .... }
>>
>> we can think of i as having the type that p resolves to. My intuition
>> was that separate types should be associated with separate variables.
> 
> Two thoughts:
> 
> - This is something the E programmer will need to know about  
> independently of whether 'when' is involved.

In what way?


> - Nontrivial patterns are a good reason to not kill the <pattern> in  
> 'when':
> 
>      when (foo) -> _([bar :int, baz]) { ... bar ... baz ... }

when (foo) -> {
     def [bar :int, baz] := foo
     ... bar ... baz ...
}

Seems at least as clear.

I continue to want to get rid of the explicit done function declaration. If we 
do, and if we also accept pragma.enable("lambda-args") (described at 
<http://www.eros-os.org/pipermail/e-lang/2005-August/010996.html> into 
official E, then "when" can stop being built in syntax, and can instead be a 
control abstraction defined in E. I find this appealing.

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

     Cheers,
     --MarkM



More information about the e-lang mailing list