home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / lisp / mcl / 2107 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.8 KB

  1. Path: 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
  2. From: Espen J. Vestre <espen@coli.uni-sb.de>
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: shiftf
  5. Date: 27 Jan 1993 09:34:10 GMT
  6. Organization: Computerlinguistik, Universitaet des Saarlandes
  7. Lines: 33
  8. Distribution: world
  9. Message-ID: <1k5kuiINNld0@coli-gate.coli.uni-sb.de>
  10. NNTP-Posting-Host: mp-mac10.coli.uni-sb.de
  11. X-UserAgent: Nuntius v1.1.1d12
  12. X-XXMessage-ID: <A78C0D20C6014453@mp-mac10.coli.uni-sb.de>
  13. X-XXDate: Wed, 27 Jan 93 08:57:52 GMT
  14.  
  15. MCL's shiftf macro produces unneccesary complicated form in the simple
  16. cases.  The most frequent use of shift, is probably for simple pointer
  17. switching in list structures: Replacing a value while saving the old
  18. value.  (The two-argument (place, newvalue) special case of shiftf used
  19. to have its own name, swapf)
  20.  
  21. Here's what MCL's shiftf produces:
  22. ? (macroexpand '(shiftf (cddr liste) nil))
  23. (LET* ((#:G91 LISTE) 
  24.        (#:G89 (MULTIPLE-VALUE-LIST (CDDR #:G91)))) 
  25.   (DECLARE (DYNAMIC-EXTENT #:G89)) 
  26.   (MULTIPLE-VALUE-BIND (#:G90) NIL 
  27.     (PROGN (CCL::SET-CDDR #:G91 #:G90))) 
  28.   (VALUES-LIST #:G89))
  29.  
  30. Here's a simpler expansion suggestion (Allegro 4.1 produces something
  31. similar to this):
  32. (LET* ((#:G91 LISTE) 
  33.        (#:G89 (CDDR #:G91))
  34.        (#:G90 NIL))
  35.   (CCL::SET-CDDR #:G91 #:G90)
  36.   #:G89)
  37.  
  38. The second form has an execution time of appr. 1/3 of the first form,
  39. which may be quite significant for pointer-manipulating programs.
  40.  
  41. --------------------------------------------------------------
  42. Espen J. Vestre,                          espen@coli.uni-sb.de
  43. Universitaet des Saarlandes,        
  44. Computerlinguistik, Gebaeude 17.2 
  45. Im Stadtwald,                          tel. +49 (681) 302 4501
  46. D-6600 SAARBRUECKEN, Germany           fax. +49 (681) 302 4351
  47. --------------------------------------------------------------
  48.