Hacker News new | ask | show | jobs
by cglouch 3474 days ago
Well as dumb as it sounds, one reason to allow hyphens instead of requiring underscores is that the former takes one keystroke to type, whereas the latter takes two. This is kind of nice when dealing with longer function names.

It's also worth noting that pyret requires spaces between all math operators, not just subtraction. In other words, 3+4 is not valid; you would need to type 3 + 4. So at least it's internally consistent in that sense.

2 comments

Not dumb at all...it's just that assuming that we spend more time re-reading code than we do in the initial writing of it, saving the keystroke from hyphen-to-understroke seems like premature optimization :).

Good to know that Pyret requires spacing between the other operators. That does help a lot, and an argument could be made that it forces folks to not do `a-b` when they mean `a - b`.

Personally I find that hyphen-separated identifiers are more readable than when they have underscores. When dabbling in perl6 I got accustomed to then very quickly. And forcing people to put spaces around binary operators is definitely a plus.
It's not dumb at all. It's one of the things we had in mind when we designed the syntax!