(no subject)
2026-05-05 02:30разработчики #pony не очень высокого мнения о программистах. И это правильно.
---
When using infix operators in complex expressions a key question is the precedence, i.e. which operator is evaluated first. Given this expression:
1 + 2 * 3 // Compilation failed.
We will get a value of 9 if we evaluate the addition first and 7 if we evaluate the multiplication first. In mathematics, there are rules about the order in which to evaluate operators and most programming languages follow this approach.
The problem with this is that the programmer has to remember the order and people aren’t very good at things like that. Most people will remember to do multiplication before addition, but what about left bit shifting versus bitwise and? Sometimes people misremember (or guess wrong) and that leads to bugs. Worse, those bugs are often very hard to spot.
Pony takes a different approach and outlaws infix precedence. Any expression where more than one infix operator is used must use parentheses to remove the ambiguity. If you fail to do this the compiler will complain.
This means that the example above is illegal in Pony and should be rewritten as:
1 + (2 * 3) // 7
Repeated use of a single operator, however, is fine:
1 + 2 + 3 // 6
---
When using infix operators in complex expressions a key question is the precedence, i.e. which operator is evaluated first. Given this expression:
1 + 2 * 3 // Compilation failed.
We will get a value of 9 if we evaluate the addition first and 7 if we evaluate the multiplication first. In mathematics, there are rules about the order in which to evaluate operators and most programming languages follow this approach.
The problem with this is that the programmer has to remember the order and people aren’t very good at things like that. Most people will remember to do multiplication before addition, but what about left bit shifting versus bitwise and? Sometimes people misremember (or guess wrong) and that leads to bugs. Worse, those bugs are often very hard to spot.
Pony takes a different approach and outlaws infix precedence. Any expression where more than one infix operator is used must use parentheses to remove the ambiguity. If you fail to do this the compiler will complain.
This means that the example above is illegal in Pony and should be rewritten as:
1 + (2 * 3) // 7
Repeated use of a single operator, however, is fine:
1 + 2 + 3 // 6
(no subject)
Date: 2026-05-04 23:36 (UTC)(no subject)
Date: 2026-05-04 23:47 (UTC)Сказано-же - думать не надо. :)
(no subject)
Date: 2026-05-05 00:07 (UTC)(no subject)
Date: 2026-05-05 00:31 (UTC)