2 ms·
This looks impressive on the first sight (kudos!). But on the other hand it's still a pretty fragile and unreadable macro, no? And it supports only a very limit
by jstimpfle 9y ago
This looks impressive on the first sight (kudos!). But on the other hand it's still a pretty fragile and unreadable macro, no? And it supports only a very limited form of list comprehensions. Can "destructuring-bind" support them fully?
- vzcx 9y agoYes, it is fragile (less than five minutes, man!) but hardly unreadable to the macro-accustomed eye. A "real" implementation would do more processing of the forms in the list read by read-delimited-list and perform appropriate checks. This is more to just give you a sense of how trivial it is to extend the language. I don't actually know python well enough (I had to look up "list comprehension") to say, but I would estimate that it would only take a page or so of code to give you something fully-featured and robust. In practice, I would never abuse the reader like this when typical "loop" expressions are enough to do these kind of things (and more).
- martinflack 9y agoAnyone who would like to use list comprehension forms, or read about how Lisp enables them, might find these papers interesting: Implementation of a "Lisp comprehension" macro by Guy Lapalme http://rali.iro.umontreal.ca/rali/sites/default/files/publis/LapalmeLispComp.pdf http://rali.iro.umontreal.ca/rali/sites/default/files/publis... Simple and Efficient Compilation of List Comprehension in Common Lisp by Mario Latendresse http://www.ai.sri.com/~latendre/listCompFinal.pdf http://www.ai.sri.com/~latendre/listCompFinal.pdf