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"))
Evaluating this with a correct (per CL) lexically scoped BLOCK
operator will yield "ok". Your implementation above, /if/ there is
only one exception type, will yield "broken" since b2's catch is the
nearest exception handler.
--
Kevin Reid <http://homepage.mac.com/kpreid/>
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev