Re:Lisp and Haskell (2015)
by guenthert on Thursday October 08, 2020 @03:07PM
(#24722588)
Is that truly a stumbling block? I ask because English is not my native language. Around the time I learned English in high school I also became interested in computers, which to me then meant programming in BASIC. It took an embarrassingly long time for me to realize that e.g. GOTO was actually formed from 'go to' -- to me, "GOTO <n>" just meant that program flow would continue at line <n>, nothing more, nothing less. "IF" was just a mnemonic introducing a conditional branch, etc. . I didn't perceive my poor grasp on English as a hindrance in learning to program (as thankfully introductory text were available in my native language). Of course, you need a good handle on the language, when communicating with co-workers (and all code is communication), but that came much later.
[ Parent
| on HN ]
The problem with the Loop macro isn’t the English, it’s that it doesn’t look anything like the rest of the language. It’s like finding some embedded Python in your Java; even if you’re fine with using Python, it’s going to be pretty hard to work with when you’re in Java mode.
Also, macros are much harder to debug, especially when the macro expansion code itself crashes. The loop macro does a lot of work, which makes it a particularly annoying macro to fix when things go wrong.
I wasn't defending the LOOP macro, but I think your critique comes 30 years too late ;-}
LOOP is just a little bit more complex than BASIC:
(LOOP FOR I FROM 0 BELOW (LENGTH S) THEREIS FOR
CH = (CHAR S I) WHEN (< I 0) ALWAYS DO (RETURN CH))
*** - loop: illegal syntax near for in
(loop for i from 0 below (length s) thereis
for ch =
(char s i) when (< i 0) always do (return ch))That might be the case, the same approach would work here though I think. There is even less a pretention of proper English grammar and why should there be? I can't remember the exact syntax of all the LOOP terms for the life of me and generally try to keep it simple.
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node240.html#... states that "The thereis construct takes one form" so that will be your error. Not quite sure, as I don't know what you intend to express. when (< i 0) makes no sense as i is always positive.
http://www.gigamonkeys.com/book/loop-for-black-belts.html might be of help.
The 'go to' thing probably took me 30 years to realize. I was puzzled when I read the 'go to considered harmful'and the 'structured programming with go to' article until I realized.... It is probably the same as in your case, I learned programming before learning English.