Skip to main content
10 votes

How can ambiguity with unary and binary operators be resolved?

Who says you have to? Never mind that APL has a separate "high minus" for negative literal numbers, the APL unary/binary operators (called monadic/dyadic functions in APL lingo) scheme is ...
Adám's user avatar
  • 3,236
9 votes

How can ambiguity with unary and binary operators be resolved?

This is called maximal munch, and is usually handled during lexing. It means that the lexer will make the tokens as large as possible. This is obvious with identifiers, ...
a coder's user avatar
  • 685
9 votes

How can ambiguity with unary and binary operators be resolved?

Require parentheses whenever different operators are mixed Whenever different operators appear in the same expression, whether infix, prefix, or postfix, they must be fully parenthesised. No ...
Michael Homer's user avatar
  • 13.6k
7 votes

How can ambiguity with unary and binary operators be resolved?

In Haskell and ML, which don't use parenthesis for function calls, their solution to the problem is that they require parenthesis around unary operators: f x (-1)
hugomg's user avatar
  • 1,365
7 votes

How can ambiguity with unary and binary operators be resolved?

Spacing Swift allows a * b and a*b for infix operators, but a *b is interpreted as a prefix ...
Bbrk24's user avatar
  • 9,407
7 votes

How can single-item tuples be disambiguated from the grouping operator?

Rust-style: Trailing comma Since Rust allows and even encourages trailing commas in arrays, structs, and so on, it also allows them in tuples, giving you a simple, unambiguous single-item tuple syntax:...
rydwolf's user avatar
  • 4,582
4 votes

Prior art on precedence rules on template instantiation for inner entity clashes

In C#, it's not an error. If E is Exception, then the first catch gets executed: ...
Eldritch Conundrum's user avatar
3 votes

How can ambiguity with unary and binary operators be resolved?

If you do come across any conflicts that may arise from a clash between unary and binary operators, I'd recommend checking out a language with a similar set of operators to see how they handle them. ...
just Paul's user avatar
3 votes

How can single-item tuples be disambiguated from the grouping operator?

Labels Some languages, such as Swift and C#, let you label the items in tuple types: ...
Bbrk24's user avatar
  • 9,407
1 vote

How can single-item tuples be disambiguated from the grouping operator?

Compiler inference Another, more complex option would be compiler inference. In a statically and strongly typed language, and one where few operators can be used on a tuple, it may be relatively ...
rydwolf's user avatar
  • 4,582

Only top scored, non community-wiki answers of a minimum length are eligible