[e-lang] scoping rules of when-catch

Kevin Reid kpreid at mac.com
Sun Jul 23 10:58:26 EDT 2006


On Jul 23, 2006, at 1:26, Mark S. Miller wrote:
> Kevin Reid wrote:
>> On May 31, 2006, at 20:41, Mark Miller wrote:
>>>  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.
>> - This is something the E programmer will need to know about   
>> independently of whether 'when' is involved.
> In what way?

I do not remember what I meant by this.

>> - 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 found this ugly at first glance, but it seems OK now, since the  
removal of the function header will simplify the language.

> 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.

I agree, though I have not yet thought about lambda-args itself.


Another thing about 'when':

Given the sealed-throw rules, the expansion of when needs to be changed.

? e`pragma.enable("easy-when"); pragma.disable("explicit-result- 
guard"); when (a) -> { b } catch c { c }`
# value: e`null
#        null
#        {
#            Ref.whenResolved(a, /** when-catch 'done' function */
#            def _ {
#
#                /** Invoke as a function */
#                method run(resolution__1) :void {
#                    escape __return {
#                        try {
#                            def _ := Ref.fulfillment(resolution__1)
#                            b
#                        } catch c {
#                            c
#                        }
#                    }
#                }
#            })
#        }`

If a resolves to a broken reference, the result will be that  
reference's problem, *sealed*, which is unnecessarily uninformative.

I don't have any specific ideas yet about how to fix the expansion  
nicely.

Also, it seems to me that a user program likely might want to  
distinguish between exceptions resulting from the reference breaking  
and those resulting from failure of the when body; but again I don't  
know what the right solution is.

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list