You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 7358 Reporter:@nojb Status: closed (set by @mshinwell on 2016-12-08T16:02:28Z) Resolution: won't fix Priority: normal Severity: minor Target version: later Category: ~DO NOT USE (was: OCaml general) Monitored by:@gasche@hcarty
Bug description
I just found out that the precedence level of user-defined operators (||) and (&&) is the same, and that they associate to the left. On the other hand, (||) and (&&) have different precedences and associate to the right (see http://caml.inria.fr/pub/docs/manual-ocaml/expr.html).
I understand the need to have user defined operators |... and &... associate to the left given the ubiquity of composition operators such as (|>). But I wonder what is the rationale of them having the same precedence, which is confusing in the case of (||) and (&&) (as it does not coincide with that of || and &&).
The text was updated successfully, but these errors were encountered:
IMO this is a historical error that we have to live with: we cannot change the precedences now without breaking unknown amounts of code in a way that cannot be detected by the type-checker.
It may be nice to detect the non-parenthesized use and warn for people to add parenthesis (I think C implementations have related-ish warnings), but I don't know how to implement that effectively.
I am unconvinced a patch for this would be worth the time spent. Obtuse infix operators such as ||~ are, in my experience, generally best avoided anyway as the potential for obfuscation is high. Other opinions?
Original bug ID: 7358
Reporter: @nojb
Status: closed (set by @mshinwell on 2016-12-08T16:02:28Z)
Resolution: won't fix
Priority: normal
Severity: minor
Target version: later
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @gasche @hcarty
Bug description
I just found out that the precedence level of user-defined operators (||
) and (&&) is the same, and that they associate to the left. On the other hand, (||) and (&&) have different precedences and associate to the right (seehttp://caml.inria.fr/pub/docs/manual-ocaml/expr.html).
I understand the need to have user defined operators |... and &... associate to the left given the ubiquity of composition operators such as (|>). But I wonder what is the rationale of them having the same precedence, which is confusing in the case of (||
) and (&&) (as it does not coincide with that of || and &&).The text was updated successfully, but these errors were encountered: