I think that's because i is being unified with int64 type in the seek_in
call. So the type of i will be int64, and input_value polymorphic type
variable will be int64.
The unused binding j is not taken account and thrown away, so the type
system will not take into account + operator that will cause i to be int.
Why the unused binding is being thrown away before type checker, I don't
know, maybe somebody could explain possibly.
So from this is obvious why the second statement fails to type check.

Cheers;
Wojciech

On Tue, Jul 5, 2011 at 2:59 PM, malc <[email protected]> wrote:

> Perhaps someone could explain why following behaves the way it does:
>
> ~$ ocaml
>        Objective Caml version 3.11.2
>
> # let f ic = let i = input_value ic in let j = i + 1 in LargeFile.seek_in
> ic i;;
> Warning Y: unused variable j.
> val f : in_channel -> unit = <fun>
> # let f ic = let i = input_value ic in let j = i + 1 in LargeFile.seek_in
> ic j;;
> Error: This expression has type int but an expression was expected of type
>         int64
>
> --
> mailto:[email protected]
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to