Hacker News new | ask | show | jobs
by nescioquid 757 days ago
I shared the urge to avoid loop until I read Pascal Costanza's Highly Opinionated Guide to Lisp[1]

>> Seemingly, the intended way to use the LOOP facility is to just "guess" a way to express an iteration and see if it works. If it doesn't you can either look up the specifics ...

Since then, I do just guess at the syntax and it strangely does what I want most of the time.

It seems that a library like this has a lot to prove because a) it doesn't provide a new capability, b) it adds a project dependency, and c) creates yet another way to do a standard task. If you really don't like the loop macro, you probably don't need much persuading, but I would have liked to have seen more discussion on the these trade-offs.

[1] http://www.p-cos.net/lisp/guide-v1.html

2 comments

Huh, this is such an unusual design goal in programming languages "just try something and it'll probably work"

Only css is done this way... but not even intentionally

That's not the design goal, it's more a "haha but kind a true" thing.

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node235.html

The grammar for what's accepted by Loop is well specified, but the results also read very clearly. Once you learn a few of them, you start to understand how the rest would be written and can guess, but the design is not that you would guess.

> Huh, this is such an unusual design goal in programming languages "just try something and it'll probably work"

Perl was famously that way. It's great for the initial write but not so good for maintenance.

Very very handy for people just learning (what's often referred to as "baby perl" in an affectionate rather than derogatory way).

Learning to use perl -properly- is a whole other barrel of monkeys though.

(it does have the advantage that it's very easy to spot code written by a confused perl programmer, whereas I've experienced a number of unfortunate events where python code initially looked fine but turn out to be logically utterly confused; this is not a complaint about python, though it does darkly amuse me)

Haskell works like this: if you can manage to make it compile, it'll work the first time. Might leak gigs of space too, but it'll work.
Funny. I'm pretty sure I failed a technical interview many years ago due to the whiteboard exercise in which I used LOOP pseudocode to solve the problem. They weren't Lispers and assumed the code wouldn't work, but I was sure it did (I couldn't explain why though, at the time, as they made me doubt my solution).

Either way I think they were looking for a recursive solution. Oh well, they still invited me to lunch, though.