Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!EU.net!julienas!news.fnet.fr!ilog!news
From: davis@ilog.fr (Harley Davis)
Subject: Re: Lisp->C compilers
In-Reply-To: barmar@nic.near.net's message of 8 Nov 1994 19:29:31 -0500
Message-ID: <DAVIS.94Nov9093658@passy.ilog.fr>
Lines: 39
Sender: news@ilog.fr
Nntp-Posting-Host: passy
Organization: Ilog SA, Gentilly, France
References: <Cyx236.7nD@cogsci.ed.ac.uk> <1NcgVc1w165w@sytex.com>
	<39ouhd$7eh@daisy.informatik.uni-kiel.de> <39p55b$jfv@tools.near.net>
Date: 09 Nov 1994 08:36:58 GMT


In article <39p55b$jfv@tools.near.net> barmar@nic.near.net (Barry Margolin) writes:

   In article <39ouhd$7eh@daisy.informatik.uni-kiel.de> wg@informatik.uni-kiel.d400.de (Wolfgang Goerigk) writes:
   >You might call this restriction needless. But, if you just want to
   >(funcall 'list-all-packages), why don't you simply write (funcall
   >#'list-all-packages).

   The reason (funcall <symbol> ...) was left in the language even though
   (funcall '(lambda ...)) was removed is because it interacts well with
   function redefinition.  For instance, suppose you have code that looks
   like:

   (funcall (slot-accessor object) ...)

   If you fill in the slot with (setf (slot-accessor object) #'foo) this will
   put FOO's current definition in the slot.  If you later redefine FOO, the
   slot will still have the old definition (unless you remember to update the
   slot).  On the other hand, if you fill in the slot with (setf
   (slot-accessor object) 'foo) then the above FUNCALL expression will always
   use the latest definition of FOO.

If you're worried about this, you should just do:

  (setf (slot-accessor object) (lambda (x) (foo x)))

The symbol hack is not necessary, and clutters up the language.

-- 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/
