From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p65EJ1dX014435 for ; Tue, 5 Jul 2011 16:19:01 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsDAI0cE07RVaC2kGdsb2JhbAAyCxaYV4cNAYgSCBQBAQEBCQkNBxQEIYh6pTiOcgGNRQWDNIMCgk6PbIwjPINY X-IronPort-AV: E=Sophos;i="4.65,479,1304287200"; d="scan'208";a="98018316" Received: from mail-gy0-f182.google.com ([209.85.160.182]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Jul 2011 16:18:55 +0200 Received: by gyf3 with SMTP id 3so3592838gyf.27 for ; Tue, 05 Jul 2011 07:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=u8lLvFlCICiXTbPj35ZMEGhsrjXNUUQ19C9bNmlqgnk=; b=ib9kViYLH9IgH2YLV+SQyylVbfnXmOR75ECpDrNs+xxLlH4G0N9JGBdIsvXAls1mDB A9J/VP6fwCIR+ylm3QFHT1q5xsBU7kEGexuQRsVStSnSiscMJ6QlV8rn5IzHQlDd+nPK cp5EplZGMLX/M/67IxSwnmNCSvUO+gxpSQnvE= MIME-Version: 1.0 Received: by 10.151.133.9 with SMTP id k9mr1958226ybn.149.1309875532970; Tue, 05 Jul 2011 07:18:52 -0700 (PDT) Received: by 10.151.43.6 with HTTP; Tue, 5 Jul 2011 07:18:52 -0700 (PDT) In-Reply-To: References: Date: Tue, 5 Jul 2011 15:18:52 +0100 Message-ID: From: Wojciech Meyer To: malc Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001485f8d174d7bc0604a7532958 X-Validation-by: wojciech.meyer@googlemail.com Subject: Re: [Caml-list] Type inference and marshalling --001485f8d174d7bc0604a7532958 Content-Type: text/plain; charset=ISO-8859-1 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 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 = > # 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 > > --001485f8d174d7bc0604a7532958 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I think that's because i is being unified with int64 type in the seek_i= n call. So the type of i will be int64, and input_value polymorphic type va= riable will be int64.
The unused binding j is not taken account and thro= wn 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 w= hy 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
=A0 =A0 =A0 =A0Objective Caml version 3.11.2

# let f ic =3D let i =3D input_value ic in let j =3D i + 1 in LargeFile.see= k_in ic i;;
Warning Y: unused variable j.
val f : in_channel -> unit =3D <fun>
# let f ic =3D let i =3D input_value ic in let j =3D i + 1 in LargeFile.see= k_in ic j;;
Error: This expression has type int but an expression was expected of type<= br> =A0 =A0 =A0 =A0 int64

--
mailto:av1474@comtv.ru

--
Caml-list mailing list. =A0Subscription 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


--001485f8d174d7bc0604a7532958--