4 ms·
I groan every time I see someone advocating building data structures out of cons cells. I use Lisp at my day job, and I can tell you that some of the hardest c
by metageek 16y ago
I groan every time I see someone advocating building data structures out of cons cells. I use Lisp at my day job, and I can tell you that some of the hardest code to maintain is the code that uses lists instead of defstruct. Once you need to add a field to that structure, you have to manually trace down every spot that uses it, and make sure it can cope with your longer list. Last time it turned out to be easier to just replace the list with a defstruct.
- RodgerTheGreat 16y agoBuilding data structures out of pairs is one of the features of Lisp that introductions to the language tend to focus on, (particularly in academia) as it feels very simple and elegant. This kind of disconnect between theory and practice is part of why I often find it hard to take writing about Lisp programming at face value.
- pavelludiq 16y agoI agree in general, it is better to inform your readers, your type system and yourself in a few weeks of your intentions. But in simple cases, if your testing out something, it might be better to use lists and cons cells, at least initially(for example plists or alists instead of hash tables). But like a lot of things in common lisp, this requires good judgment.