Article View: comp.lang.lisp.mcl
Article #675shiftf
From: Espen J. Vestre
Date: Wed, 27 Jan 1993 09:34
Date: Wed, 27 Jan 1993 09:34
33 lines
1924 bytes
1924 bytes
MCL's shiftf macro produces unneccesary complicated form in the simple
cases. The most frequent use of shift, is probably for simple pointer
switching in list structures: Replacing a value while saving the old
value. (The two-argument (place, newvalue) special case of shiftf used
to have its own name, swapf)
Here's what MCL's shiftf produces:
? (macroexpand '(shiftf (cddr liste) nil))
(LET* ((#:G91 LISTE)
(#:G89 (MULTIPLE-VALUE-LIST (CDDR #:G91))))
(DECLARE (DYNAMIC-EXTENT #:G89))
(MULTIPLE-VALUE-BIND (#:G90) NIL
(PROGN (CCL::SET-CDDR #:G91 #:G90)))
(VALUES-LIST #:G89))
Here's a simpler expansion suggestion (Allegro 4.1 produces something
similar to this):
(LET* ((#:G91 LISTE)
(#:G89 (CDDR #:G91))
(#:G90 NIL))
(CCL::SET-CDDR #:G91 #:G90)
#:G89)
The second form has an execution time of appr. 1/3 of the first form,
which may be quite significant for pointer-manipulating programs.
--------------------------------------------------------------
Espen J. Vestre, espen@coli.uni-sb.de
Universitaet des Saarlandes,
Computerlinguistik, Gebaeude 17.2
Im Stadtwald, tel. +49 (681) 302 4501
D-6600 SAARBRUECKEN, Germany fax. +49 (681) 302 4351
--------------------------------------------------------------
Technical Details
Message-ID:
<1k5kuiINNld0@coli-gate.coli.uni-sb.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!ira.uka.de!sbusol.rz.uni-sb.de!coli.uni-sb.de!mp-mac10.coli.uni-sb.de!espenShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!ira.uka.de!sbusol.rz.uni-sb.de!coli.uni-sb.de!mp-mac10.coli.uni-sb.de!espen From: Espen J. Vestre <espen@coli.uni-sb.de> Newsgroups: comp.lang.lisp.mcl Subject: shiftf Date: 27 Jan 1993 09:34:10 GMT Organization: Computerlinguistik, Universitaet des Saarlandes Lines: 33 Distribution: world Message-ID: <1k5kuiINNld0@coli-gate.coli.uni-sb.de> NNTP-Posting-Host: mp-mac10.coli.uni-sb.de X-UserAgent: Nuntius v1.1.1d12 X-XXMessage-ID: <A78C0D20C6014453@mp-mac10.coli.uni-sb.de> X-XXDate: Wed, 27 Jan 93 08:57:52 GMT