🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #46

Re: return-from GF with :after methods?

#46
From: Barry Margolin
Date: Tue, 28 Jul 1992 23:05
39 lines
2507 bytes
In article <1992Jul28.185423.22804@jpl-devvax.jpl.nasa.gov> charest@aig.jpl.nasa.gov writes:
>I have a generic function with a primary method and at least one :after
>method. The GF uses standard method combination. In the body of the
>primary method I have a conditional RETURN-FROM statement which I had
>assumed would throw out of the *GF* altogether and skip execution of the
>:after method (essentially overriding the semantics of standard method
>combination). However, in Lucid 4.0.2 the :after method is executed
>anyway--the net effect of RETURN-FROM being immediate exit from the
>primary method only.

>Is this correct behavior? If so, how do I exit from a primary method such
>that :after method are skipped? I'd like to avoid use of THROW and
>non-standard method combination. Is it possible?

This is correct.  RETURN-FROM is a lexical operator, and returns from the
lexically-enclosing block with the given name.  Since the generic function
definition doesn't lexically enclose the RETURN-FROM, there's no way it
could do what you expected.

If you don't want to use another method combination, then the most obvious
solution is to put a CATCH in an :AROUND method and a THROW in the primary
method.  This won't necessarily throw out of the entire generic function,
though; if a subclass defines an :AROUND method of its own, it will enclose
your :AROUND method, and the CATCH will return to it.

To better ensure what you want, you could break your GF into two functions,
e.g. GF1 and GF2.  GF1 would contain the CATCH and a call to GF2, and the
primary method for GF2 would contain the THROW.  You might make GF1
non-generic, so that subclass authors wouldn't be tempted to add :AROUND
methods to it.

P.S. Please hit Return every 70-80 characters when posting to the net.
Each of your paragraphs was on one long line; don't assume that everyone is
using a mail/news reader that wraps nicely (since most of us aren't).
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Technical Details
Message-ID: <154js5INN5g8@early-bird.think.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!barmar
References: <1992Jul28.185423.22804@jpl-devvax.jpl.nasa.gov>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!barmar
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.clos
Subject: Re: return-from GF with :after methods?
Date: 28 Jul 1992 23:05:41 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
Lines: 39
Message-ID: <154js5INN5g8@early-bird.think.com>
References: <1992Jul28.185423.22804@jpl-devvax.jpl.nasa.gov>
NNTP-Posting-Host: telecaster.think.com