4 ms·
For me, the point worth arguing is not whether infix vs prefix arithmetic is hard, but that "actual programs" get harder. They don't: Math, logical operations,
by lmkg 17y ago
For me, the point worth arguing is not whether infix vs prefix arithmetic is hard, but that "actual programs" get harder. They don't: Math, logical operations, and variable assignment are the hardest to switch over to thinking Lisply, because those are the operations normally represented as binary operators in other languages[1]. Lisp and other languages share the same prefix notation for standard function calls. When you start moving into "actual" programs from toy examples, functions become a bigger chunk of the program, and the lack of infix operators becomes a smaller deal.
I wonder if intro-to-lisp books should shy away from arithmetic in the first few chapters to avoid this stumbling block. It seems odd to introduce the nature of lisp syntax by focusing on its weakest point. Shuffling lists of symbols around gives an introduction to the syntax and the more fundamental data types, and makes for an easier segue into macros.
[1] Variable assignment is the easiest to overcome, because you simply doesn't use variable assignment as much in Lisp, and in this sense the aversion is a good thing as working to avoid it helps produce more idiomatic code. Logical operators are also easier to overcome because in practice it's not common to have thorny expressions with high nesting levels like you can in arithmetic.
I wonder if it would be worthwhile to have a MATH special form in common lisp that that allows for special evaluation in its body, like how the LOOP form parses its arguments.
- ced 17y agoI find that logical expressions are easier to parse. (OR (AND ...) (AND ...) ...) is cleaner (and shorter) than the corresponding one-liner in Python.