3 ms·
White space is required around operators. This allows the names of bindings (variables, methods or whatever) to be very flexible. Things that represent a boolea
by BruceM 13y ago
White space is required around operators. This allows the names of bindings (variables, methods or whatever) to be very flexible. Things that represent a boolean can end in '?'. Operations that mutate can end in '!'. In the Objective C bridge that I'm working on, I make use of '/' like: 'objc/class-responds-to-selector'.
Type names are typically enclosed in '<...>' like '<integer>' (but that's just a convention used everywhere).
- krautsourced 13y agoAh, ok, I had not seen the part about the mandatory whitespaces. I still think it has the potential to confuse, so if I were to write in languages that allow dashes, I'd probably still avoid them where possible (can't see the advantage over using underscores instead). Anyway, thanks for the info.
- gecko 13y agoHaving plenty of experience both with languages that do and do not allow "operators" in variable names, it's not actually confusing in practice. You quickly learn that whitespace is very significant in those languages, and then you read them differently. This isn't any different than indentation in Python, line breaks in Ruby, or sigils in C++.
- Someone 13y agoI haven't really programmed in Lisp or Dylan, but the code I read certainly seemed the better because of the punctuation in function names. It gets denser, but stays readable. A question mark signals 'returns boolean' just as strong as a "Is" or "Has" prefix, and there AFAIK is nothing in other languages that signals "modifies its arguments" as strong as a ! suffix. I also find that Dylan's convention of using brackets in class names rapidly grows on you. But maybe that requires working in Forth as a warming up. And of course, hyphens not only look better than underscores, they are easier to type, too :-)