https://common-lisp.net/project/iterate/
Even the ITA/Google style guide says to avoid loop if possible:
Almost every macro in Lisp provides syntax.
It's one of the strengths of Lisp imo; that you don't need to think much about how the parser is going to interpret your code (ie. missing semi-colons, whitespace, use curly brace here, square bracket there, etc.), just stick to (func arg1 arg2) and all you're left with is your own logic errors.
(func arg1 arg2 (func arg3))
That's the syntax of function calls.But Lisp has a few special forms and zillions of macros. Most of them are syntax.
Lisp has IF. What is the syntax of IF?
IF form then-form else-form+
Lisp has COND. What is the syntax of COND? cond {clause}*
clause::= (test-form form*)
List has DEFUN. What is the syntax of DEFUN? defun function-name lambda-list [[declaration* | documentation]] form*
Now what is the syntax for LAMBDA-LIST? lambda-list::= (var*
[&optional {var | (var [init-form [supplied-p-parameter]])}*]
[&rest var]
[&key {var | ({var | (keyword-name var)} [init-form [supplied-p-parameter]])}* [&allow-other-keys]]
[&aux {var | (var [init-form])}*])
and so on...> It's one of the strengths of Lisp imo; that you don't need to think much about how the parser is going to interpret your code (ie. missing semi-colons, whitespace, use curly brace here, square bracket there, etc.), just stick to (func arg1 arg2) and all you're left with is your own logic errors.
What you describe is just the data syntax for s-expressions. Not the syntax of the programming language Lisp.
Exactly. The data syntax if what most people worry about. The names of the verbs (funcs/methods/etc.) may change from language to language, but the data syntax is what trips people up. I think Lisp has one of the simplest and clearest. There are very few cases of "oh you can't write that there, only nouns are allowed in that position".
I agree with your point, but I think we're arguing slightly different points here ;)
(lambda x (+ x x))
(cond (> x 2) (+ x x))
(if (> x 2)
(do-this when-true)
(also-do-this when-true))
They are syntactically correct (technically), but they are probably not what you meant. So you still have to pause and ask yourself how cond works... except the parser will not help you.That is to say, a problem with s-expressions is that they are so regular that everything looks the same, and when everything looks the same, it can become an obstacle to learning. Mainstream languages are not very regular, but they are more mnemonic. I think Lisp works best for a very particular kind of mind, but that for most programmers its strengths are basically weaknesses.
(if (> x 2)
(do-this when-true)
(also-do-this when-true))
In some other language: x > 2 ? doThis(whenTrue) : alsoDoThisWhenTrue();
Same problem. Maybe even slightly worse. For example it could be: x > 2 ? doThis(whenTrue) ; alsoDoThisWhenTrue();
To spot the difference between a colon and the semicolon: tough.If not, how is the macro different other than implicitly changing the evaluation?
for a more simple example, why is the idiom CALL-WITH-FOO (implemented as a function) not syntax while WITH-FOO (implemented as a macro) is? What precisely is syntax is somewhat nebulous (if I use a regex library in C, have I added syntax to the language? Regexes certainly are syntax, despite being wrapped in a C string).