Hacker News new | ask | show | jobs
by sesm 737 days ago
In Clojure '-' is not a special symbol, so it's used as a word separator in function names, like 'get-in'. That's possible because '-' is not an operator, but is a function with a 1-symbol name.
2 comments

Also Raku, the Perl spin-off, is allowing this.

Clojure I guess is taking that from its LISP legacy, where it’s not an issue as you don’t have infix notation.

Raku on the other hand, took the decision on the road starting from Perl. If I recall correctly, Raku does let you use infixed dashes as minus into agglutinated numeric literals and operators sequences, like `2-5-7`, but your need spaces to use it as a substraction operator when an identifier is involved like `bare-price - gift-voucher`.

That said I never used Raku nor Clojure (or any Lisp), there is just no job opportunity that ever reached me with these kind of non-mainstream programming language.

The current definition:

An ordinary identifier is composed of a leading alphabetic character which may be followed by one or more alphanumeric characters. It may also contain isolated, embedded apostrophes ' and/or hyphens -, provided that the next character is each time alphabetic.

https://docs.raku.org/language/syntax#Ordinary_identifiers

This means that '2-5-7' is NOT an identifier but the numerical value -10.

Thanks for the link and the excerpt. Just out of curiosity, did the capitalized "NOT" was there because my above message was interpreted as a guess that `2-5-7` could serve as an identifier in Raku? That was not my belief nor what I tried to expose, to be clear on that point.

Thank you again for your reply.

Yeah, it was. Sorry, misread :-)
No worry, we all do that here and there. ;)
The best part of setting things up like that (especially with `-` having any arity) is that there's no ambiguity in the grammar between -/1 (negation) and -/2 (subtraction).