top | item 27630996

(no title)

earl_gray | 4 years ago

I feel like I may have misunderstood the point of the article because this seems like an obvious explanation to me. A pair of parentheses in Scheme tells the interpreter that it needs to open a new environment, evaluate the expression inside, and return the value. If there aren't parentheses, the evaluator will look up the value of the symbol in the current environment. These are very different things and, it seems to me, mixing them would make it unnecessarily difficult to pass named functions as arguments.

For example, (map car '((a b) (c d) (e f))) evaluates to '(a c e), while (map (car '((a b) (c d) (e f)))) yields an error.

In this case, I don't want my interpreter to 'helpfully' add the parentheses in around car when it see it's a one-argument function that expects a list and the following expression is a list. And even if the interpreter is able to disambiguate it and thus avoid introducing errors, a huge benefit of the parentheses in Scheme is how easy is (as a human) to see the structure of your code at a glance. In my mind, introducing ambiguity here would only serve to undermine this while bring minimal benefit.

discuss

order

No comments yet.