Re: delete command weirdness
- From: usenet2.3.CalRobert@xxxxxxxxxxxxxxx (Robert Maas, http://tinyurl.com/uh3t)
- Date: Tue, 13 May 2008 19:42:57 -0700
From: Nathaniel Calloway <n...@xxxxxxxxxxx>
delete exists exclusively for its side effects because there is
another function *with the exact same behavior* and no side effects.
No, you are completely wrong. DELETE exists exclusively for its
*SPEED*, because there is another function *with the exact same
return value* and no side effects, but which is much slower because
it does a lot more CONSing while building that return value. The
side effects are a *COST* of the speed. You can have it fast, or
you can avoid side effects, but you can't have both. You get to
choose which is more important for a given application.
It's the same with REVERSE (non-destructive, but slow because it
does lots of CONSing), and NREVERSE (fast, no CONSING at all, but
destructive).
CL has quite its fair share of imperative commands.
No, you're completely wrong. CL doesn't have any commands at all.
It has only functions, macro operators, and a very few special
operators. Tell me three examples of something in CL that you
believe is a command.
wait, no...operations, that's it.
You're getting closer. Functions perform data-processing
operations, such as modifying a place to have a new value,
allocating a new object and initializing its slots/places,
reading/writing I/O stuff, ...
I mean methods.
In a generic way (as in ordinary English usage), method and
procedure and algorithm all mean the same thing. In Java, there are
three kinds of English.methods, namely primitive operations,
*static*methods* (which are really the same as functions), and
*instance*methods* (which really truly are OOP methods).
oh ***...FUNCTIONS.
That's only part of the truth. CL also has special operators which
in the CAR position of a form cause Lisp to do low-level things or
set up unusual control structures, and macro operators which in the
CAR position of a form cause the form to be replaced by another
form containing special forms and/or function calls.
Remember that evaluating a form which expresses a function call can
*only* evaluate each element (except the first), and then pass the
resultant values as parameters to the function described by the
first element of the form.
By comparison, a form that expresses a special form (i.e. the first
element of the form is a special operator) can do any confangled
thing the special operator wants to do with the form. For example:
(SETQ sym ...) can modify the place defined by sym in both the case
of a lexical variable (a magic place accessible only to the
compiler, including the JIT compiler used by EVAL) and the case of
a special variable (the value cell of the symbol sym). In the case
of a special variable, it's pretty simple: There's some internal
function like SETVALUECELL which takes the symbol and the new value
as parameters, rather analagous to RPLACA which takes a CONS cell
and a new value. But in the case of a lexical variable, it's deep
innerds of the way Lisp is implemeted as to where the lexical
"value cell" really is located. It's not the value cell of the
symbol. Maybe it's on the stack. Maybe it's in a lexical-closure
object. You don't need to know or care how it's implemented.
.
- Follow-Ups:
- Re: delete command weirdness
- From: Kent M Pitman
- Re: delete command weirdness
- References:
- delete command weirdness
- From: Nathaniel Calloway
- Re: delete command weirdness
- From: Steven M. Haflich
- Re: delete command weirdness
- From: Nathaniel Calloway
- delete command weirdness
- Prev by Date: Re: delete command weirdness
- Next by Date: Re: lisp website monitoring tool?
- Previous by thread: Re: delete command weirdness
- Next by thread: Re: delete command weirdness
- Index(es):