4 ms·
I'd say we should have a proper looping facility that allows for building lists without the fuzz of having special syntax. Common lisp has one. The ITER macro i
by bjoli 7y ago
I'd say we should have a proper looping facility that allows for building lists without the fuzz of having special syntax. Common lisp has one. The ITER macro in CL has is user-extensible, as are racket's for-loops.
For non-lazy languages, you either need some sort of loop fusion or a construct like transducers to get similar functionality.
- lispm 7y agoSome LOOP implementations are user-extensible, too.
- omaranto 7y agoCommon Lisp's iter or loop macros are special syntax for, among other things, building lists. I think maybe you should have said instead that it's nice when a language let's you add such special syntax in libraries. :)
- bjoli 7y agoThat is not quite what I want to get across. I think python's list comprehensions are great, but I think they are a shit replacement for a proper looping facility that does everything python's list comprehensions do and more. Racket's for loops are also macros that expand to tail recursive procedures within a letrec, but they are "standard syntax" (in the sense that they are included in the base library) just as loop is.
- omaranto 7y agoWell, Python does have a looping facility that can do everything it's comprehensions can do and more. It's just more special syntax and looks somewhat different from the comprehensions (though they do share keywords where appropriate). I mean, I too prefer loop or iter but Python isn't looping-poor.
- bjoli 7y agoIt can't return a list :) It is as if someone said "wow! Returning something from a loop is useful", but instead of going all the way they added special syntax for it.