[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

block/tagbody and catch/throw



    Date: Tue 15 Apr 86 11:28:18-MST
    From: SANDRA <LOOSEMORE@UTAH-20.ARPA>

    Am I the only person who finds the descriptions of the interaction between
    block/tagbody and catch/throw in CLtL confusing?  On both pages 120 and 131,
    it's mentioned that the lexical scoping of the block/tag names "has
    consequences that may be suprising to users".  What are these consequences?
    After being told that my intuitions about their behavior may be wrong, it's
    confusing to be told in the very next sentence that the examples work "as
    one might expect"; at this point, I don't really know *what* to expect!  It
    would be helpful to describe the behavior of the examples in more detail
    instead of resorting to hand-waving.  The reference to "breaking up catchers"
    in the following paragraph should also be explained in more detail.

block/tagbody have lexical scope and dynamic extent.  catch/throw have
dynamic scope and dynamic extent.  Things work 'as one might expect' if
you fully understand that.  If you don't fully understand that, it may
have "consequences that may be surprising."  Granted the manual could
probably use improving.


    Date: Tue, 15 Apr 1986  14:03 EST
    From: Rob MacLachlan <RAM@C.CS.CMU.EDU>

	There is no language-level interaction between catch and throw and
    the lexical control mechanisms.  To someone who understands lexical
    scoping, RETURN and GO do "what one might expect."  The tag or block
    referred to is the one lexically apparent at the point of the GO or
    RETURN.

	People more familiar with dynamic scoping "may be surprised",
    since the lexically apparent tag or block is not necessarly the
    dynamically innermost one.

	GO and RETURN sometimes need to remove crap from the stack in most
    implementations.  This may involve undoing special bindings and
    "breaking up catchers."  This is a feature of the implementation, not
    the language.

No, "breaking up catchers" is a feature of the language, because a
lexical GO has to get back to the lexical environment of the target tag,
which may be outside the dynamic extent of some CATCH form.