Arc Forumnew | comments | leaders | submitlogin
4 points by kennytilton 6134 days ago | link | parent

LOOP. I know Paul thinks it was a mistake and I hated it (for its un-Lispyness) until I learned it, but now I will not use anything else for iteration. The funny thing is that loop gives us both shorter code and fewer parentheses, the goal of Arc! In a list processing language, what comes up more often iteration? OK, Arc is closer to Scheme in spirit so the answer to that is probably "Recursion!", but us CLers think using recursion to iterate just means your language is weak on iteration so recursion gets forced into an inappropriate role.


1 point by bOR_ 6134 days ago | link

what do you need loop for that map (iterating over a list) doesn't give you?

The only place I use loops is just the infinite loop that represent single timesteps in which my models run. Arc has

(repeat 5 (pr "la "))

-----

3 points by kennytilton 6133 days ago | link

loop (in CL, this is) is a full-blown iteration DSL with its own tricky syntax to remember and everything, all in the name of making such code terser. The only time I use MAPCAR, CL's map, is in the rare case where I can just say:

  (mapcar 'length my-strings)
That is shorter than:

  (loop for s in my-strings collecting (length s))
loop has an initially clause, a finally clause, several kinds of ways to iterate and step, and has special keywords for different kinds of value accumulation. Like I said, it really is its own little iteration language that cuts waaay down on parentheses and otherwise makes for more terse and more efficient iteration.

-----