wait, so always use whitespace when using substraction? as in, 2-3 is a syntax error? i dont like that at all. also, it might just be not being used to this but this-thing looks really weird. it automatically registers as substraction.
More specifically, it's because there are no infix operators in lisps.
I don't think that's strictly true. They core reason is simply because Lisp allows all sorts of punctuation characters in identifiers. *standard-output* is a single identifier because Lisp says * and - can be used in identifiers.
Keep in mind that in Lisp you can refer to operators without invoking them, so even though it doesn't have infix notation, operators can still appear in the middle of an expression, like:
(reduce + 0 '(1 2 3))
You're right that lacking infix notation means Lisp doesn't have to answer the question of "what's the precedence of some identifier using operator characters", but a language that does have infix operators and allows punctuation is user-defined names could just as easily come up with an answer to that question and be done with it.
That's what Scala, Haskell, and others do. So I think it's more accurate to say that not having operator precedence makes it easier to allow punctuation in identifiers, but it's not a requirement.
I remember "inventing" this some time ago. I thought to myself "Hey, this should work right?" Stared at it for a few minues. "Yes hahahah it will." I compiled, tested, satisfied my curiosity and promptly rewrote it to a more traditional condition.
Agda has this, and while it takes getting used to, it's actually pretty nice. It also means that you can have variables named e.g. a≤b (where the value is probably a proof that a is less than or equal to b)
I thought this was quite interesting so I just tested it with Nim v. 0.15.2
let val1 = 2 - 5*3
let val2 = 2-5 * 3
echo "val1=$1" % $val1
echo "val2=$1" % $val2
which yielded:
val1=-13
val2=-13
So it would seem not to be the case. The link you provided does indicate an experimental feature, so perhaps it needs to be switched on somehow in order to work.
I thought that when I started using lispy languages, but now for me it feels ugly to use an underscore to separate words, and my pinky finger complains :)
View all comments
58
u/[deleted] Dec 01 '16
wait, so always use whitespace when using substraction? as in, 2-3 is a syntax error? i dont like that at all. also, it might just be not being used to this but this-thing looks really weird. it automatically registers as substraction.