This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

[Caml-list] Calling a function with a self-defined type as argument
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2002-08-22 (12:55) From: Oliver Bandel Subject: Re: [Caml-list] Calling a function with a self-defined type as argument
```
On 22 Aug 2002, Dimitri Ara wrote:

> 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 ""'.

OK.
But why has the Line()-argument not a higher pruiority than the
function-call?
The Line()-argument is only complete, if it get's it's
args. And the type-declaration says in detail, how to
handle the Line().

But it seems to me that it is handled like an "ordinary"
function call. I thought, that the compiler would put
this together: *one* argument to the function, and the
argument means using the type `Line "text"'.

Ciao,
Oliver

-------------------
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

```