From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id BB1ABBBAF for ; Tue, 11 Jul 2006 09:55:44 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6B7thAm006467 for ; Tue, 11 Jul 2006 09:55:44 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA05711 for ; Tue, 11 Jul 2006 09:55:42 +0200 (MET DST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6B7tdAJ006437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 11 Jul 2006 09:55:42 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 7E6D953D27 for ; Tue, 11 Jul 2006 17:55:30 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16107-10 for ; Tue, 11 Jul 2006 17:55:30 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 5D53753D1D for ; Tue, 11 Jul 2006 17:55:17 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id 20680A0AFCA; Tue, 11 Jul 2006 17:55:19 +1000 (EST) Date: Tue, 11 Jul 2006 17:55:19 +1000 From: Pietro Abate To: ocaml ml Subject: evaluation order ... Message-ID: <20060711075519.GA14285@pulp.rsise.anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.11+cvs20060403 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at nez-perce with ID 44B3597F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44B3597B.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 val:01 val:01 anu:01 blog:98 blog:98 invert:01 expression:01 expression:01 int:01 int:01 constraint:01 unit:03 unit:03 let:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hi all, #type ('a,'w) mt = ('a -> 'w) -> 'w #let return a = fun k -> k a ;; #let a = return 4 ;; type ('a, 'b) mt = ('a -> 'b) -> 'b val return : 'a -> ('a -> 'b) -> 'b = val a : (int -> '_a) -> '_a = # # let b = a print_int;; 4val b : unit = () as expected ... but # let c = a id;; This expression has type int -> int but is here used with type int -> unit if I invert the order ... #let a = return 4 ;; val a : (int -> '_a) -> '_a = #let c = a id;;;; val c : int = 4 #let b = a print_int;; This expression has type int -> unit but is here used with type int -> int # why does the order matter ? if "val a" is of type (int -> '_a) -> '_a = why '_a is fixed as soon as I use it once ? Do I have to add a type constraint ? :) p -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html