Browse thread
[Caml-list] Calling a function with a self-defined type as argument
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Dimitri Ara <dimitri@n...> |
| Subject: | Re: [Caml-list] Calling a function with a self-defined type as argument |
Oliver Bandel <oliver@first.in-berlin.de> a écrit :
> (*
> let _ = x Line "h0oifdaji oi" ;;
> This last one does not work: => "This function is applied to too many arguments"
>
> let _ = x Line( "reuruhjf" ) ;;
> This last one does not work: => "This function is applied to too many arguments"
>
> But it works in this way:
> let _ = x (Line "reuruhjf") ;;
>
> WHY? (why *only* that?)
>
> At least the second example (with parantheses around the
> Line's arguments) should work...?!
> *)
Because :
(1) application is left associative.
Thus `f x y' means `(f x) y' and
`x Line ""' means `(x Line) ""'.
(2) parentheses don't delimit the arguments of a function or a
constructor but only fix the precedence of an expression.
Thus f x (y) means f x y and
`x Line ("")' means `x Line ""'.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners