From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 51876BC68 for ; Sat, 28 Oct 2006 17:49:29 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k9SFnS5b029672 for ; Sat, 28 Oct 2006 17:49:29 +0200 Received: by ug-out-1314.google.com with SMTP id 78so860714ugn for ; Sat, 28 Oct 2006 08:49:28 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:subject:from:to:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; b=CQLHQEwd3mImglsMrUNlOw5vsREH1phSF6f41gLNMBp0lr3zUxobBXU4n7sYoMAfwsr8kSGptP4JI/XNGUZz+H2hCdqMVAEUjFtiI5bOt+DRzf6CpvbJoAGFxd2M3m/LrBUzRUcPWfbRksZR1Y8Gk9jjhmA0UUuZjbFGu+WiFp8= Received: by 10.66.222.9 with SMTP id u9mr1394382ugg; Sat, 28 Oct 2006 08:49:28 -0700 (PDT) Received: from ?10.0.0.41? ( [88.154.194.131]) by mx.google.com with ESMTP id j3sm771166ugd.2006.10.28.08.49.27; Sat, 28 Oct 2006 08:49:28 -0700 (PDT) Subject: weird type behavior From: Kirill To: caml-list@yquem.inria.fr Content-Type: text/plain Date: Sat, 28 Oct 2006 17:49:08 +0200 Message-Id: <1162050549.23148.26.camel@nfnl> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 7bit X-j-chkmail-Score: MSGID : 45437C08.002 on discorde : j-chkmail score : X : 0/20 1 X-Miltered: at discorde with ID 45437C08.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 foo:01 foo:01 val:01 val:01 polymorphic:01 ints:01 functions:01 int:01 int:01 define:01 functional:02 parameters:02 parameters:02 languages:03 Hi everyone, I'm a novice user of OCaml and functional languages in general. While playing with the interpreter, writing all kinds of functions, I've run into a behavior that doesn't look quite right to me. Please excuse me, if it is explained somewhere and I simply haven't gotten there yet. In the following example, I define a simple function foo that returns function bar, which, in turn, accepts 2 parameters. The weird part is that after bar is being called for the first time, its signature changes from polymorphic types to ints. Right after (foo 3) call it's '_a -> '_b -> '_b = But after being called, it becomes (int -> int) -> int -> int = # let foo n = let bar f x = x in bar;; val foo : 'a -> 'b -> 'c -> 'c = # let inc x = x + 1;; val inc : int -> int = # let z = foo 3;; val z : '_a -> '_b -> '_b = # z inc 0;; - : int = 0 # z;; - : (int -> int) -> int -> int = I have also noticed that if foo doesn't accept parameters, everything works as expected: # let foo = let bar f x = x in bar;; val foo : 'a -> 'b -> 'b = # let inc x = x + 1;; val inc : int -> int = # let z = foo;; val z : 'a -> 'b -> 'b = # z inc 0;; - : int = 0 # z;; - : 'a -> 'b -> 'b = I have tried this with 3.09.2 and 3.09.3 on X64 Ubuntu. I have also noticed other things I don't see explanation for, but they may be connected to this one. Will be grateful for any explanation. Thanks, -Kirill