Hacker News new | ask | show | jobs
by agentultra 5515 days ago
You can just build your tree data structure and develop operators to work with them in Lisp. There's nothing that restricts you to using lists.

So what's the point of "replacing" them (even if such a thing were possible without "replacing" Lisp)?

1 comments

Cons cells give you binary trees. It is possible to encode any arbitrary tree as a binary tree. However, this does not mean that the expression of algorithms over such left child right sibling encoded trees is identical to one over trees with some higher branching factor. So the cons/binary situation will at the least require some additional layers of abstraction to simulate various traversal patterns of the n way tree on the encoding binary tree.

There also physical/efficiency concerns. There's a reason databases use highly branching trees.

And you can create the abstractions necessary to work with such a data structure and add them straight to the regular grammar of the language.

Lisp also has all of the other low-level primitives we're used to when working closer to the machine. Structs, indexed arrays, hashes, etc. If efficiency is a concern, just pick an implementation that compiles to machine code. SBCL is pretty good for this depending on your target platform.

Replacing conses seems like a waste of time.