Subject: Re: A list of integers...
From: Erik Naggum <erik@naggum.no>
Date: 1997/07/21
Newsgroups: comp.lang.lisp
Message-ID: <3078494830334034@naggum.no>
[comp.org.lisp-users removed from newsgroups]
* David Thornley -> Travish Robinson
| An integer isn't a list, but an atom. Append is for lists, cons for
| putting atoms onto lists.
|
| (defun add-int-to-list (intvar)
| (setf *int-list* (cons intvar *int-list*)))
is it useful to teach `setf', but not adjuncts like `push', `incf', etc?
also, is it useful to teach novices to define new functions with individual
side effects instead of idiomatic expressions for them?
I'm concerned because I see a lot of novice Lisp users here who ask the
oddest questions and are only given directions further along an obviously
harder trail than if they were asked to go back to camp and look more
closely at the map. I think this can contribute to needless frustration.
instead of writing a function to be called as (add-int-to-list 42), I think
a better way is to write (push 42 *int-list*) in place of the call, and
then ask the novice to macroexpand the form to see what it really does. I
don't know about others, but I found macroexpand to be a useful teacher,
especially when it came to not writing manually expanded macros when I
could use a supported macro or even think "there ought to be a macro way".
#\Erik"
--
there was some junk mail in my mailbox. somebody wanted to sell me some
useless gizmo, and kindly supplied an ASCII drawing of it. "actual size",
the caption read. I selected smaller and smaller fonts until it vanished.