3 ms·
That is completely subjective, and your example is bad. What's more readable here... > (+ 1 2 3 4 5) or > 1 + 2 + 3 + 4 + 5 In my (subjective) opinion, the
by CodyReichert 11y ago
That is completely subjective, and your example is bad. What's more readable here...
> (+ 1 2 3 4 5)
or
> 1 + 2 + 3 + 4 + 5
In my (subjective) opinion, the first one is. The extra +'s are redundant and noisy, and sacrifice a meaningful syntax for "trying to read as plain english". The syntax of any language takes practice and lots of reading - that's not unique to Lisp.
- hacker_9 11y agoMany languages do follow a similar syntax though, that do relate to how plain english is written. I personally started with C#, and when I look at other languages I don't find them very hard to follow because they also follow the same basic 'read left to right' rule. Even coming across data formats such as html/xml for the first time are easy to follow because of the left to right reading. In your example, the 2nd one is actually what I'd prefer to read as I know that it will be compiled down to 5 ADD assembly instructions, whereas the first looks like it will be turned into a function call that will then initiate a loop. I'm guessing/hoping Lisp optimises the (+) function though so probably a null argument from me. See my reply to nnq for a better example.
- Retra 11y agoThis is what I see when I look at lisp code: (doof-boof "1 3" f1 3 "f1 3" 'f "f3 " f") I love lisp, but I love commas too.
- renox 11y agoThe first one is still flawed: +(1 2 3 4 5) or even better +[1 2 3 4 5] would be better IMHO as it visually separates the function from the arguments.