4 ms·
As a Clojure programmer, I learned to love hyphens, so much more readable. But since Clojure is a Lisp, is does not suffer this whitespace problem/confusion.
by cygned 10y ago
As a Clojure programmer, I learned to love hyphens, so much more readable. But since Clojure is a Lisp, is does not suffer this whitespace problem/confusion.
(- a b)
- kpil 10y agoI'd say there is some room for confusion, even if it's not in the grammar. I have spent quite some time chasing bugs of the type (- a -1) where the second minus ended up there because of either a copy/paste-error or a brain fart due to the original expression was a - 1...
- wolfgang42 10y agoI'm not sure how (- a - 1) would work, unless you've named something "-"?
- Grue3 10y ago- is a function. Because Closure is a Lisp1, substraction function being passed as an argument like that is very probable. In Common Lisp you'd pass #'-, so it's clear that it's a function being passed.
- kazinator 10y agoAn infix language could also require whitespace around operators, so that a-b could be a an identifier. Like in a Lisp infix macro: (infix (a + b * c) / d). This kind of thing is quite habitable: we hardly lose sleep over (3.4) the list of one float versus (3 . 4) the dotted pair of integers.
- brudgers 10y agoI'd say that white space requirements around operators even seems implicitly consistent with the Pythonic idiom of semantic white space and the Pythonic dictum of only one way to do things.
- skrishnamurthi 10y agoPython has many ways to do just about everything (e.g., list comprehensions are completely redundant). It's a nice marketing slogan, though.
- brudgers 10y agoYes, there's even two Pythons.
- skrishnamurthi 10y agoWe're discussing an infix language that does exactly that. In Pyret, binary operators must be surrounded by spaces. Therefore, `a-b` is not ambiguous.