From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p65NP3ev030745 for ; Wed, 6 Jul 2011 01:25:03 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmYDAAKcE05KfVO2kGdsb2JhbAA9AQMSnF+LJwgUAQEBAQkJDQcUBCGIeqcljnKES4khAgMGhjAEhz2KeYYVhg48gT2CKQ X-IronPort-AV: E=Sophos;i="4.65,481,1304287200"; d="scan'208";a="102587242" Received: from mail-pv0-f182.google.com ([74.125.83.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 06 Jul 2011 01:24:57 +0200 Received: by pvg11 with SMTP id 11so9484395pvg.27 for ; Tue, 05 Jul 2011 16:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=skSKYMOrBkJbfF7hkf+sA5H6mkcXcxBd5yhG39H/uv8=; b=gUmAv8K8lAokiN2fJ3AVW4JHpjRB7nQj/DglFR4nRxca3ES5CgZn4o5/GB5g53pgvL Qfod8PuyQEYl+xiVw9cjGHAtnJoOJPMjKXokZ/HZ5Fx1DBkOwEZ/hPARreKCNu9KvUpp 3kLwxxVjBx10X74I4IL481Z28jGj7Pns1R0Vw= Received: by 10.68.34.228 with SMTP id c4mr9513589pbj.463.1309908295520; Tue, 05 Jul 2011 16:24:55 -0700 (PDT) Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) by mx.google.com with ESMTPS id d3sm1310903pbh.69.2011.07.05.16.24.53 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jul 2011 16:24:54 -0700 (PDT) Sender: Jacques Garrigue Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Jacques Garrigue In-Reply-To: Date: Wed, 6 Jul 2011 08:24:51 +0900 Cc: caml-list@inria.fr Message-Id: <098226D8-77AA-4F80-97A5-F72F47C6A98E@math.nagoya-u.ac.jp> References: To: malc X-Mailer: Apple Mail (2.1084) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p65NP3ev030745 Subject: Re: [Caml-list] Type inference and marshalling On 2011/07/05, at 22:59, 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 = The return type of input_value being 'a, which gets generalized by the relaxed value restriction, i gets the polymorphic type "forall 'a. 'a". So you can use it both as an int and an int64. ==> input_value is an unsafe function, you should always write a type annotation on its return type. > # 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 j being the result of an integer addition, it has type int, and cannot be used as int64. Jacques