Philosophy and "for" loops — more from Go and Rust
Philosophy and "for" loops — more from Go and Rust
Posted Jul 8, 2013 6:10 UTC (Mon) by foom (subscriber, #14868)In reply to: Philosophy and "for" loops — more from Go and Rust by fuhchee
Parent article: Philosophy and "for" loops — more from Go and Rust
Sure, CL LOOP has a bunch of useful, baked-in features, but that does not make it very impressive.
To start with, on the surface level, it's very pascal-ish, using english phrases with extra noise words and many random synonyms -- not at all in keeping with the "look and feel" of the rest of common lisp.
Also, it has no sequence-genericity, even to the limited extent that the rest of CL has (e.g. in "make-seequence", "elt" supporting both lists and vectors). Rather, you have to tell it in obtuse syntax ("for x in y" vs "for x across y" whether you want to iterate on a list or a vector.) But those are fairly unimportant criticisms.
But, most importantly, it has the same problem that the loop in Go has -- no ability to iterate over used-defined types. The availability of a looping syntax which can loop over arbitrary iterable objects -- or, more fundamentally -- the *concept* of an "iterable object" at all -- is a terribly useful feature for a language to have, and, I think, one of the defining feature of modern languages.
Python, C++11, and apparently (though I have no experience there), Rust all now have such a concept and syntax. (Also Dylan and Racket, for those who use lispy languages)
In Python and Rust, they've taken the obvious step of *only* having syntax for iteration over a iterable type -- no special C-like "multi-part" loop syntax is available at all. Everything else can be easily expressed as a type which generates the proper sequence of values.
Add to the mix the ability to trivially write a generator function with "yield" sprinkled through, which returns an iterator, and you've got a very very powerful abstraction that makes languages lacking that ability pale in comparison. *That* functionality is mind-blowing.
