Subject: Re: Iteration in lisp
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 03 May 2008 22:11:06 -0500
Newsgroups: comp.lang.lisp
Message-ID: <bJmdncYiDN3XtIDVnZ2dnUVZ_vednZ2d@speakeasy.net>
John Thingstad <jpthing@online.no> replied [to Kent]:
+---------------
| > I actually don't know which implementations do this.  I just know people
| > complain that some do and seem not to like writing SETQ at toplevel.
| 
| Usually I would want defparameter at the toplevel REPL.
| I use the history to retrieve it to re-test.
| defvar is only for things you want to survive through the session.
| As such it is almost as dangerous as declaring something defconstant.
+---------------

Agreed, which is why when I defined my version of DEFLEX[1]
to use DEFPARAMETER semantics (similar in that way to Scheme's
top-level DEFINE) instead of DEFVAR semantics. [From time to
time I've thought of adding a DEFLEX/ONCE with DEFVAR semantics,
but sufficient motivation has never arisen. ;-} ]

Typing (DEFLEX FOO 13) is almost as short as typing (SETQ FOO 13),
but is a *lot* less dangerous if later code should rebind FOO!  ;-}
And it's also more portable[2]...
 


-Rob

[1] http://rpw3.org/hacks/lisp/deflex.lisp

[2] The semantics, that is, assuming you load
    the DEFLEX macro in your CL's init file.

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