Re: novice: mapcan use?



Kent M Pitman <pitman@xxxxxxxxxxx> writes:

> Pascal Costanza <pc@xxxxxxxxx> writes:
>
>> Furthermore, the majority of the destructive functions are defined on
>> conses/lists. It's better to get the whole picture that Lisp isn't
>> "just" about list processing, but also has other data structures that
>> are probably more important for creating efficient programs than
>> destructive functions.
>
> I'm not clear on what observation you're making here.
>
> Do you mean "the majority of functions that are ever called destructive
> are among this set" or do you actually mean there are more ways to (sigh)
> "destroy" (i.e., "modify") a cons/list than there are other data structures.

I'm not Pascal but my observation is that many people use
"destructive" to describe operations that may leave one or more of the
arguments in an unusable state, i.e. destroyed. And using this meaning
of "destructive" indeed most functions that are so called operate on
conses.

> Certainly there are many destructive operations on other data structures,
> and they are quite important. How many people seriously expect array
> operations to be non-destructive, yet we do not call AREF by some goofy
> name like AREF! nor even NAREF.

So I think it's a misuse of the term "destructive" to use it to
describe (SETF AREF) (what I assume you meant) because it doesn't
"destroy" it's argument--it merely changes it's state. Of course, as
you know, that does "destroy" it as far as being a functional data
type but, as you also of course know, Common Lisp is not a purely
functional language so we don't get all worked up about it. (Also the
SETF is a pretty good clue that state is being mutated.)

I do recognize that there are folks (Schemers often) who use
"destructive" as a synonym for "has side effects". Which is a sign of
their functional bias. In an attempt to avoid this confusion I
introduced a new (as far as I know) term in my book, "recycling" to
refer to what *I* would mean by "destructive" if I used the
term--operations that may leave their arguments in an unusable
state. I picked this term because most of the "recylcing" ops are the
ones that recycle the cons cells in their argument or arguments in
order to avoid creating excessive garbage. (Of course nothing is that
simple because some "recycling" operations, such as NCONC, while
recycling their arguments also have reliable side effects and can be
used purely for those side effects.

> (The history of "N" for destruction is a pretty silly story itself. At
> least Interlisp had the good sense to use "D".)

Didn't it stand for "Non-consing". That at least gets at the
distinction that seems to me to be the key one.

-Peter

--
Peter Seibel * peter@xxxxxxxxxxxxxxx
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp * http://www.gigamonkeys.com/book/
.



Relevant Pages

  • Re: novice: mapcan use?
    ... the majority of the destructive functions are defined on ... Do you mean "the majority of functions that are ever called destructive ... name like AREF! ... (The history of "N" for destruction is a pretty silly story itself. ...
    (comp.lang.lisp)
  • Re: destruction of an old unicycle
    ... The unicycle could still do with some more destruction though. ... recycling center. ... smashed it up but chose to dismantle and recycle instead. ...
    (rec.sport.unicycling)
  • Re: Another Lonely Suicide...
    ... majority should not lead to laws, and when it does, should not lead to ... pointless death and destruction; thus, we work to change it, like ...
    (uk.legal)
  • Re: novice: mapcan use?
    ... > Certainly there are many destructive operations on other data structures, ... > name like AREF! ... destructive list operators destroy the structure of the list, ... > (The history of "N" for destruction is a pretty silly story itself. ...
    (comp.lang.lisp)
  • Re: US action against Iran
    ... >> While the two men lead the most powerful nations in the world, ... Chaos and destruction for the majority on this benighted ...
    (uk.politics.misc)