[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Destructuring considered harmful

I think the use of destructuring as it currently exists represents
a step backwards in making Lisp a serious language for programming
non-toy systems, because it is actively hostile to abstracting
away from representational decisions. In 90% of all cases, complicated
list structures are REALLY being used to implement some sort of abstract
type, or just to package up a bunch of related information that you
want to pass around. The use of LET-style destructuring emphasizes
the position of the data in particular structures, and de-emphasizes
the meaning of the data.

This is precisely the opposite of what really should happen. It binds
programmers to using a particular representation ("I wish a could
change the order of these two things, or put them in a vector, but I
can't because every routine in the system KNOWS exactly what the guts
of the structure look like"), and it makes it difficult to understand
what is happening in terms of the abstraction being implemented (e.g.,
sub-trees of a binary tree are extracted by saying ((a . b)
random-tree) instead of having the extractors "left-son" and
"right-son" right there).

Furthermore, because of its brevity and "convenience", this language
feature will actively encourage programmers to do it the wrong way.
I think that RMS-style destructuring will at least allow structures
to be shredded according to their abstract structure.

	-David Dill