Re: Cons cell archaic!?



On Oct 10, 9:16 am, J Kenneth King <ja...@xxxxxxxxxxxxxx> wrote:
Anticomuna <ts.concei...@xxxxxxxxxx> writes:
How? Is there anything wrong with the concept? I thought it was so
easy to parse the S-expressions because of it. Is this really a
problem for Lisp or this is more of a non-Lisper automatic reaction to
something he is not used to?

How would the implementation of a Lisp without a using cons look like?
Would it have any advantage over the "archaic" one?

I used the word "archaic" in the same sentence as "cons cells" in another
topic myself... just to expand on what I meant:

"At the dawn of time, these names were mnemonic, at least to the folks
implementing the first Lisp on an IBM 704. But even then they were
just lifted from the assembly mnemonics used to implement the
operations."

http://gigamonkeys.com/book/they-called-it-lisp-for-a-reason-list-pro...

The section on List Manipulation Functions is a little too verbose to
quote, but does suggest that the list has in a way already been
abstracted from its cons-cell roots, which were basically a very
low-level implementation if I read it all right. So when I mentioned
the terrible sounding word, "archaic," I meant it in the sense that
we're not all running Lisp on IBM 704's and most of us don't write
much assembly these days.

Exactly.

The lisp's cons forces programer to think in implementation detail
level, pretty much in the same way when lispers sneer at C or Java.

I don't really know how often cons is used these days, but Clojure
doesn't think we need them at all and Peter Siebel suggests all we
really need are FIRST/REST and NTH functions for *most* applications
we'd start writing from scratch.

Yes. Many lisp experts has acknowledged the problem.

Note that First, Rest, Nth is not enough. There needs to be also Last,
at least. In general, when you think of lists as sequence of things as
a language primitive, and you think of general ways to manipulate such
a item, you will also have functions that extract arbitrary contiguous
sequence of the item (what many lang, such as Python, calls “slice”),
and functions that extract multiple elements in arbitrary positions in
the list (what Mathematica calls Parts, Extract, almost non-existent
in any other lang), and you must also have functions that do delete
versions of the above (i.e. instead of specifying which part you want,
the function returns the parts not specified. Basically a inverse
boolean. In many lang, there's no such function), and functions that
do the extraction/deletion based on a pattern (which is part of the
functionality of what's called Pattern Matching in many functional
langs such as Haskell, and in limited way called grep in e.g. Perl),
or the extraction spec can be based on a predicate function, and you
also need functions that extract arbitrary levels of the sublist or
arbitrary leafs, or arbitrary, multiple, nodes in the tree.

So, all things considered, you have aspect of:

• whether to extract, or its opposite of specificying of parts you
don't want. e.g. First, or NotFirst (i.e. Rest). Perl's grep, or grep
with reverse boolean !=.

• the syntax and spec used to indicate parts of the expression, i.e..
index based, pattern based, predicate based.

• extracting a slice. (i.e. a sequence of neighboring elements in the
same level of nesting. e.g. get me 3rd to 7th elemets of the 4th
element of the list.)

• extracting particular level. (e.g. give me all nodes in the list
that are 3rd level nesting)

• extracting arbitrary elements. e.g. a general function that accept
argument that can extract, say, 1st and last elements, or 3rd, 5th,
1th elemnts in that order.

All these, are well done in Mathematica. Some so-called array-
languages such as Matlab, APL/J, offers some of these. Some other
functional lang, such as Haskell, OCaml, afaik offers parts of these
too. In generality, consistency, simplicity, nothing comes close to
Mathematica.

Lisp with its cons is completely fucked up. Even Perl, Python, PHP,
provide far more easier manipulation of lists than lisp.

Further readings:

• Fundamental Problems of Lisp
Xah Lee, 2008
http://xahlee.org/UnixResource_dir/writ/lisp_problems.html

• The Concepts and Confusions of Prefix, Infix, Postfix and Fully
Nested Notations
Xah Lee, 2006
http://xahlee.org/UnixResource_dir/writ/notations.html

Xah
http://xahlee.org/


.