Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Wojciech Meyer <wojciech.meyer@googlemail.com>
To: malc <av1474@comtv.ru>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Type inference and marshalling
Date: Tue, 5 Jul 2011 15:18:52 +0100	[thread overview]
Message-ID: <CAOg1smDRVEhk7BUqNOpetb_-P4LND=+Ad9hwYGHstK4OF4tqsA@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1107051757280.9196@linmac>

[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]

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 <av1474@comtv.ru> 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:av1474@comtv.ru
>
> --
> 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
>
>

[-- Attachment #2: Type: text/html, Size: 1956 bytes --]

  reply	other threads:[~2011-07-05 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 13:59 malc
2011-07-05 14:18 ` Wojciech Meyer [this message]
2011-07-05 14:54   ` Mathias Kende
2011-07-05 23:24 ` Jacques Garrigue
2011-07-06  5:11   ` malc
2011-07-06  7:44     ` Jacques Garrigue
2011-07-06  8:31       ` malc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOg1smDRVEhk7BUqNOpetb_-P4LND=+Ad9hwYGHstK4OF4tqsA@mail.gmail.com' \
    --to=wojciech.meyer@googlemail.com \
    --cc=av1474@comtv.ru \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox