Hacker News new | comments | show | ask | jobs | submit login

I like Common Lisp's LOOP, personally.

It is an abomination until you learn how to use it, then it is completely awesome.

same 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

Everything 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.

That 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...)

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.


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.

I love Common Lisp's LOOP, it's very handy. For those who prefer something lispier, there's always ITERATE


(common-lisp.net seems to be down)

ITERATE 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_da...

Loop and Format are only useful for getting work done, but they fall flat for waxing poetic on LISP beauty.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact