[bitc-dev] Error in specification of DO
Swaroop Sridhar
swaroop at cs.jhu.edu
Thu Jul 10 20:47:18 CDT 2008
Kevin Reid wrote:
> On Jul 10, 2008, at 14:57, Jonathan S. Shapiro wrote:
>
>> Unfortunately, it seems to me that the labeled BLOCK escape, which is
>> the generalization of these constructs, can't be handled by any
>> stateless implementation if it is possible for the label to be
>> captured.
>> The problem is that we need to disarm the label when its associated
>> block exits. What we need here is dynamic scope rather than dynamic
>> extent, which seems to require something like:
>>
>> (define (f x)
>> (block myBlock expr)) =>
>>
>> (define (f x)
>> (let ((myBlock-armed #t)))
>> (defexception myBlock '#a)
>> (try
>> ...body...
>> (catch id
>> ((myBlock exitValue)
>> (if myBlock-armed
>> exitValue
>> (throw DynamicLabelExtentViolation))))))
>> (set! myBlock-armed #f)))
>
> It seems to me that one of these is the case:
>
> 1. myBlock-armed will never be seen to be false, in that if the throw
> occurs outside after myBlock-armed is set to #f, it is outside the
> catch as well.
>
> 2. You meant (defexception myBlock '#a) as a "static" (as in the C
> storage class) definition rather than a lexical one; in which case
> your implementation is incorrect anyway, as this example demonstrates:
>
> (define (call-with-return f)
> (block myBlock
> (f (lambda (x) (return-from myBlock x)))))
>
> (call-with-return (lambda (b1)
> (call-with-return (lambda (b2)
> (b1 "ok")))
> "broken"))
I think that the interpretation of the local defexception is lexical.
However, the check for armed-ness is done at the wrong place.
It must be checked within the `expr' before throwing/invoking the
return-via (similar to array bounds check) and not at the enclosing
catch block.
Swaroop.
More information about the bitc-dev
mailing list