4 ms·
I like Common Lisp's LOOP, personally.
by pnathan 16y ago
I like Common Lisp's LOOP, personally.
- ohyes 16y agoIt is an abomination until you learn how to use it, then it is completely awesome.
- eschulte 16y agosame with `format', they're easy to bad-mouth until you've used them a couple of times, then you don't want to contemplate programming without them
- G_Morgan 16y agoEverything is an abomination until you learn how to use it. The difficulty with loop is it takes something trivial and makes it more complex than it needs to be. Simple things are not simple. Complex things are rare and loop doesn't simplify them enough.
- ohyes 16y agoThat might be true. It is indeed complex if you look at the BNF in the hyper-spec. (http://www.lispworks.com/documentation/HyperSpec/Body/m_loop.htm http://www.lispworks.com/documentation/HyperSpec/Body/m_loop...) If you ignore the hyperspec, however, and get a feel for it by looking at examples and writing code using it, it becomes quite simple. It is very useful when you are translating C or Java code. (http://www.unixuser.org/~euske/doc/cl/loop.html http://www.unixuser.org/~euske/doc/cl/loop.html) I find it quite readable in comparison to many of common lisp alternatives for iteration. And I kind of disagree that simple things aren't simple. For example: (loop for i from 0 below 10 do ...) Is pretty much the simplest construct that you normally need. Granted, I would likely just use dotimes in that case... but lets say you are iterating between 5 and 15, dotimes becomes unwieldy, where the for loop is pretty much the same code with the numbers changed. (loop for i from 5 below 15 do ....) Now try incrementing by 2 (loop for i from 5 below 15 by 2 do ....) compare to the similar do* code (do* ((i 5 (+ i 2))) ((>= i 15)) ....) kind of a toss up to me. Not that I don't understand your point... in fact, as little as a year ago, I felt that way too... but I have since changed my mind. My current preference is to use do* if writing a macro that needs iteration, and to use loop when I am doing something similar to a list comprehension or array traversal.
- kroger 16y agoI love Common Lisp's LOOP, it's very handy. For those who prefer something lispier, there's always ITERATE http://common-lisp.net/project/iterate/ http://common-lisp.net/project/iterate/ (common-lisp.net seems to be down)
- aerique 16y agoITERATE is an excellent gateway-drug to LOOP. I sometimes joke my programming language is LOOP instead of CL: http://www.reddit.com/r/science/comments/bc91w/on_the_8th_day_god_made_pi_monte_carlo_simulation/c0m23gz http://www.reddit.com/r/science/comments/bc91w/on_the_8th_da...
- mahmud 16y agoLoop and Format are only useful for getting work done, but they fall flat for waxing poetic on LISP beauty.