4 ms·
Cons, car, cdr are fine for putting things together and breaking them apart. The problem is everything is boxed, and the indirection mechanism is conflated wit
by alphazard 1y ago
Cons, car, cdr are fine for putting things together and breaking them apart.
The problem is everything is boxed, and the indirection mechanism is conflated with the concatenation mechanism. What you really want is the ability to compose a value (concatenate 2 things together), but store it contiguously in memory. If cons did that then you could create true products of values, without any indirection.
Then you need a different method for creating indirection. A function for each of C's malloc and '*' respectively. That would give you the control needed to create trees with arbitrary branching factors.
- Jtsummers 1y agoIf you don't want cons, you can use vectors and arrays in Lisp. Cons isn't the only data structure available.
- johnisgood 1y agoAnd often you want to avoid heavy cons-ing, too.