3 ms·
Is (* (f (+ 2 x)) 5) more difficult to parse than: 5 * f(x+2) Considering that we're familiar with the latter syntax (more or less) since kindergarten,
by eMSF 6y ago
Is
(* (f (+ 2 x)) 5)
more difficult to parse than:
5 * f(x+2)
Considering that we're familiar with the latter syntax (more or less) since kindergarten, I'd say... yes. And the idea that you'd somehow start to consider something you've been doing all your life as “irregular” after 2–4 weeks of Lisp cure is just hilarious.
- coldtea 6y ago>And the idea that you'd somehow start to consider something you've been doing all your life as “irregular” after 2–4 weeks of Lisp cure is just hilarious. And yet we learn all kinds of syntax that we haven't been familiar at all (zero indexing, x=x+1, etc which we used to the exact inverse: math assignments being immutable or denoting an equation not increment, etc), -- not to mention advanced stuff like generics, futures, closures, etc -- and we seem to manage just fine...
- Viliam1234 6y agoDepending on how frequent are complex equations in your code, you could make a macro for it, and write it e.g. like this: (math 5 * f (x + 2)) I might be tempted to do so if I frequently encountered math expressions of depth 3 or more, which in my short Lisp career I didn't. Also, I would probably rewrite the expression as: (* 5 (f (+ x 2))) to make it easier to read by putting the simple operand first; or in case of two difficult operands I would use formatting: (* (f (+ x 2)) (g (+ x 3))) Note that a good editor would check that the parentheses match the formatting, so I wouldn't really count that 3 closing parentheses are needed in the last line; they would be inserted automatically.