New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OCaml not well defined? #7171
Comments
Comment author: @lpw25 See section 4.1.1 of the manual. |
Comment author: @gasche More precisely, the "Function Applciation" documentation See Jacques Garrigue' research work with Jun Furuse on optional parameters for a formalization of the labels as found in OCaml: http://www.math.nagoya-u.ac.jp/~garrigue/research.html#sel A label-selective lambda-calculus with optional arguments and its compilation method |
Comment author: bay2@illinois.edu Gasche, Thank you for your answer. I understand the application form as f arglist. However, the example seems to give lie to the statement from the manual: The expressions ( expr ) and begin expr end have the same value as expr. |
Comment author: @gasche I see what you mean: he fact that "(expr)" and "expr" evaluate in the same way is not compositional: it does not mean that "(expr) foo" and "expr foo" evaluate in the same way. But this is true in most languages, for example "(1+2)3" and "1+23" are distinct, yet explaining that parentheses do not affect the value seems reasonable even of arithmetical expressions. |
Original bug ID: 7171
Reporter: bay2@illinois.edu
Assigned to: @lpw25
Status: closed (set by @xavierleroy on 2017-09-24T15:32:03Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.02.3
Category: back end (clambda to assembly)
Bug description
Dear Sir or Madam,
Running the following code on OCaml version 4.02.3 yields the following output:
let f ?x y = match x with None -> y | Some z -> z +y ;;
val f : ?x:int -> int -> int =
f 2 ?x:(Some 3);;
(f 2) ?x:(Some 3);;
Error: This expression has type int
This is not a function; it cannot be applied.
This seems to indicate that in an application, OCaml evaluates the argument list to a function before applying one argument after the other to the function. Is OCaml not well defined? Do you have a semantics for OCaml to share?
Best,
Michael
Steps to reproduce
let f ?x y = match x with None -> y | Some z -> z +y ;;
val f : ?x:int -> int -> int =
f 2 ?x:(Some 3);;
(f 2) ?x:(Some 3);;
Error: This expression has type int
This is not a function; it cannot be applied.
The text was updated successfully, but these errors were encountered: