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

block/tagbody and catch/throw



    Date: Tue, 15 Apr 86 15:22  EST
    From: David C. Plummer <DCP at SCRC-QUABBIN.ARPA>
    To:   SANDRA <LOOSEMORE at UTAH-20.ARPA>, Rob MacLachlan <RAM>,
          common-lisp at SU-AI.ARPA
    Re:   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?

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

    	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.

I think that the two examples referred to create more confusion than
they eliminate.  It is a feature of the language that GO or RETURN can
change the dynamic environment.  It is obvious from the scope rules
that the block or tag is not within the catch, therefore when control
is transferred to the block or tag, the catch is no longer in the
dynamic environment.  How the catch disappears is an implementation
detail.  It does make some sense to say that these code fragments are
legal, but discussion about the implementation is inappropriate in the
main text; it only confuses people.

I have a feeling that these features are much more surprising to
implementors than to users.  It may not be obvious that a particular
combination is legal, but it should be fairly obvious what it does as
long as you haven't been damaged too much by Lisps with bizzare scope
rules.

  Rob