Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!EU.net!julienas!news.fnet.fr!ilog!news
From: davis@ilog.fr (Harley Davis)
Subject: Re: with-preserved-values macro
In-Reply-To: Dave@Yost.COM's message of Wed, 12 Oct 1994 00:59:26 GMT
Message-ID: <DAVIS.94Oct12132552@passy.ilog.fr>
Lines: 35
Sender: news@ilog.fr
Nntp-Posting-Host: passy
Organization: Ilog SA, Gentilly, France
References: <yostCxJC32.4C5@netcom.com>
Date: 12 Oct 1994 12:25:52 GMT


In article <yostCxJC32.4C5@netcom.com> Dave@Yost.COM (Dave Yost) writes:

   Not having been around for 10 years, I was wondering why there wasn't
   a macro like this (did I get it right?):

   (defmacro with-preserved-values (thing-spec-list &body body)
     "Each thing-spec is a list consisting of a thing
   and an optional temporary value to be stored there.
   Executes body inside an unwind-protect context which preserves
   the original values of the things listed in thing-spec-list.
   Example:
     (setf height 1)
     (setf (width foo) 2)
     (with-preserved-values ((height)
			     ((width foo) 9))
       (print height) ; -> 1
       (print (width foo)) ; -> 9
       (setf height 22))
     (print height) ; -> 1
     (print (width foo)) ; -> 2"

Ilog Talk has just this macro.  We call it "withf".

-- Harley Davis
-- 

------------------------------------------------------------------------------
motto: Use an integrated object-oriented dynamic language today.
       Write to info@ilog.com and ask about Ilog Talk.
------------------------------------------------------------------------------
Harley Davis                            net: davis@ilog.fr
ILOG S.A.                               tel: +33 1 46 63 66 66
2 Avenue Gallini, BP 85                fax: +33 1 46 63 15 82
94253 Gentilly Cedex, France            url: http://www.ilog.fr/
