Subject: Re: I would like for a list to evaluate some terms but not others
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 17 Mar 2008 21:38:54 -0500
Newsgroups: comp.lang.scheme
Message-ID: <1bKdnepdjdijtkLanZ2dnUVZ_tajnZ2d@speakeasy.net>
Abdulaziz Ghuloum  <aghuloum@cee.ess.indiana.edu> wrote:
+---------------
| Pascal J. Bourguignon wrote:
| > If I wanted an optimized version of list* I would just have used
| > Common Lisp. 
| 
| What's that supposed to mean?
+---------------

Probably nothing sinister, just that LIST* is a standard builtin in
Common Lisp, and thus is likely to be optimized by the implementation:

    > (describe 'list*)

    LIST* is an external symbol in the COMMON-LISP package.
    Function: #<Function LIST* {1021E149}>
    Function arguments:
      (arg &rest others)
    Function documentation:
      Returns a list of the arguments with last cons a dotted pair
    Its declared argument types are:
      (T &REST T)
    Its result type is:
      T
    > 

E.g., its implementation in CMUCL is suitably low-level & grubby  ;-}
[from "cmucl-19c/src/code/list.lisp"]:

    ;;; List* is done the same as list, except that the last cons
    ;;; is made a dotted pair

    (defun list* (arg &rest others)
      "Returns a list of the arguments with last cons a dotted pair"
      (cond ((atom others) arg)
	    ((atom (cdr others)) (cons arg (car others)))
	    (t (do ((x others (cdr x)))
		   ((null (cddr x)) (rplacd x (cadr x))))
	       (cons arg others))))


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607