Subject: Re: Road to Special Enlightenment Survey
From: (Rob Warnock)
Date: Mon, 23 Feb 2009 22:02:21 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Kenneth Tilton  <> wrote:
| Raise your hand if you learned how specials work when some other Lisper 
| straightened you out after seeing this code of yours:
|    (let ((save *grafport*))
|        (setf *grafport* myport)
|        (..some grafporting code..)
|        (setf *grafport* save))
| ...with this:
|    (let ((*grafport* myport))
|       (..some grafporting code..))
| If so, how much Lisp had you written by then?
| Raise your other hand if you just found out.

For even more extra credit(?!?), raise your third hand if you
already knew about the second form above but just now found out
that you can do the same thing this way:

    (defun do-some-grafporting-thingy (&optional (*grafport* *grafport*))
      ...some grafporting code...)

    (do-some-grafporting-thingy)	; Uses current value of *GRAFPORT*
    (do-some-grafporting-thingy myport)	; Temp binds *GRAFPORT* to MYPORT


p.s. A very common usage of that is this idiom:

    (defun format-val (val &key ((stream *standard-output*) *standard-output*))
      (format t "...{magic format for a VAL}..." val))

followed by:

    (format-val some-val)	; goes to *standard-output*
    (format-val some-val :stream some-other-stream-entirely)

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607