[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shiftf
- To: info-mcl
- Subject: shiftf
- From: espen@coli.uni-sb.de (Espen J. Vestre)
- Date: 27 Jan 93 09:34:10 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: Computerlinguistik, Universitaet des Saarlandes
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
--------------------------------------------------------------