5 ms·
I might add kebab-case to my current language project. From all the code I've written, I only found a handful of - operators not surrounded by spaces, so that a
by tlb 4y ago
I might add kebab-case to my current language project. From all the code I've written, I only found a handful of - operators not surrounded by spaces, so that ambiguity wouldn't bite me often.
Also, I wish the unary negation operator was more visually salient. `foo * -bar` is very different from `foo * bar`, but it's only a handful of pixels on the screen. I've thought about trying to render it as an em-dash or something. Didn't NASA lose a rocket over a spurious - sign?
- harrisi 4y agoNASA reference: https://nssdc.gsfc.nasa.gov/nmc/spacecraft/display.action?id=MARIN1 https://nssdc.gsfc.nasa.gov/nmc/spacecraft/display.action?id...
- chewxy 4y agoAPL uses ¯ for negative numbers. - is a ambivalent function (it can work as a monadic or dyadic function)
- gdwatson 4y agoThere are coding fonts that make the "-" look more like a minus than a hyphen. I know that Iosevka and its variants do.
- int_19h 4y agoSome languages use ~ for negation; wasting it (and other common chars) on bitwise ops is a waste in most languages that don't specifically target bit twiddling. That said, have you considered making this outright illegal without explicit parentheses? I actually wish that more languages would require that any sequence of operators has the same precedence throughout; i.e. a+b*c would also be illegal. It's always a pain to remember the exact precedence rules, especially since they're not consistent across PLs, so I'd prefer any expression that is ambiguous to be explicitly disambiguated.
- NeoTar 4y agoI have a similar opinion on using the exclamation point for the NOT operator. It can be very hard to spot sometimes, especially after an opening bracket - if(!something()) Of course its generally better to try and rename functions or refactor to avoid the negative if possible.
- still_grokking 4y agoCode is symbolic and not like a (western) written language. Kebab-case and snake_case may seem to read better when looked at code like it would be written text, but they read worse than camelCase when looked at it in a symbolic way. https://news.mit.edu/2020/brain-reading-computer-code-1215 https://news.mit.edu/2020/brain-reading-computer-code-1215