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
It would be nice that -. and ** behave like in math. Specifically,
let x = 3. in
-. x**2.
sould return -9. (i.e. be parsed as -. (x**2.)) rather than the current 9.
(because it is seen as (-. x)**2.). The same therefore should also hold for
-.3.**2. and -3.**2. (while it is more debatable for the latter as -3. can be
seen as a constant...).
A general remark: we are very weary of changing the grammar because it's hard to tell how many programs this will break. In this particular case, the typechecker will not help at all in tracking the change, so programs will just start returning the wrong result without any hint of what is wrong.
I think it's pretty unlikely that we will ever dare to make this change.
Since you are wary of making such a change #2 (comment), how about issuing a warning when the construction -. xy is encountered without parentheses (i.e. not -. (xy)) — possibly telling the author to make their voice heard on this issue.
I think it is pretty bad that OCaml is a language that does not respect the universally adopted mathematical priorities.
Original bug ID: 3414
Reporter: administrator
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2016-12-07T10:37:11Z)
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Monitored by: @hcarty @Chris00
Bug description
Full_Name: Christophe TROESTLER
Version: 3.08.2
OS: GNU/Linux
Submission from: ppp-62-235-157-155.tiscali.be (62.235.157.155)
It would be nice that -. and ** behave like in math. Specifically,
let x = 3. in
-. x**2.
sould return -9. (i.e. be parsed as -. (x**2.)) rather than the current 9.
(because it is seen as (-. x)**2.). The same therefore should also hold for
-.3.**2. and -3.**2. (while it is more debatable for the latter as -3. can be
seen as a constant...).
Best regards,
Christophe
File attachments
The text was updated successfully, but these errors were encountered: