> Here's a question, though: If your language did not support list comprehensions, what would it take to add them? For a language like Ruby, you may have to dig into the language implementation itself.
No, not really:
http://stackoverflow.com/questions/310426/list-comprehension...
Gosh, if you had an extensible reader, you could do so much more... Oh wait, why don't we try it: http://lisp-univ-etc.blogspot.com/2013/01/real-list-comprehe... ;)
Someone's very happy to have authored Clojure's for special form.
I nice and somewhat related paper is "Simple and Efficient Compilation of List Comprehension in Common Lisp" by Mario Latendresse:
http://www.iro.umontreal.ca/~latendre/publications/listCompF...
Given that clojure is a dialect of lisp (the list processing language), it seems that list comprehensions should not be a remarkable achievement. Am i missing something?
This is very telling example of how differently Java people think.
First of all - ''this'' is NOT list comprehensions. Lisp has list comprehension, the sub-set of features that makes macros possible. Quote, back-quote, comma and grouping with parenthesis are parts of Lisp syntax to do it.
This is a meaningless generalization from a lisp programmer's perspective, just another macro.
Look at it carefully. This is the how confusion looks like. Thinking in terms of classes and methods prompts them to create artificial, unnecessary complications.
This is not hacking, this is exactly opposite.)
We don't address this in the post, but adding :while conditions is quite a fun challenge.
This is the best I could come up with (in Emacs Lisp): https://gist.github.com/4356261 . It's rather hacky :D
Darius Bacon (abecedarius) came up with a beautiful alternative formulation that handles :while conditions seamlessly. Here's my port of his idea into Emacs Lisp: https://gist.github.com/4380866
I'd be very happy to see other versions :)