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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3F8ACBB9C for ; Tue, 13 Sep 2005 14:41:18 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8DCfH96028556 for ; Tue, 13 Sep 2005 14:41:17 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA16773 for ; Tue, 13 Sep 2005 14:41:17 +0200 (MET DST) Received: from efil.de (efil.de [81.3.25.37]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8DCfGVQ028545 for ; Tue, 13 Sep 2005 14:41:16 +0200 Received: by efil.de (Postfix, from userid 1000) id 114D199719F; Tue, 13 Sep 2005 14:41:41 +0200 (CEST) Date: Tue, 13 Sep 2005 14:38:43 +0200 From: Ingo Bormuth To: caml-list@inria.fr Subject: Reference to polymorphic function ? Message-ID: <20050913123843.GA9640@kruemel> Reply-To: Ingo Bormuth Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Attribution: Ingo Bormuth X-Url: http://ibormuth.efil.de/contact User-Agent: Mutt/1.5.8i Cc: ingo@bormuth.org X-Miltered: at concorde with ID 4326C8ED.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4326C8EC.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; val:01 val:01 resolving:01 ingo:98 efil:98 ingo:98 efil:98 polymorphic:01 polymorphic:01 marshal:01 expression:01 behaviour:01 explicitly:01 int:01 closure:02 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 list, the following declaration of put_to_screen nicely accepts all kinds of values as v. This is the expected behaviour. # let put_to_screen v = print_string ( Marshal.to_string v [] ) ;; val put_to_screen : 'a -> unit = # put_to_screen "test" ;; %%%%%test- : unit = () # put_to_screen 5 ;; %%%%%E- : unit = () Nevertheless, if I store the polymorphic function in a reference to create a closure for all kinds of output methodeis, any attemps to use that function are thwarted by the type interferer. # let put = ref put_to_screen ;; val put : ('_a -> unit) ref = {contents = } # !put "test" ;; %%%%%%test- : unit = () # !put 5 ;; This expression has type int but is here used with type string How can I keep the interferer from explicitly resolving the type of v ? # put;; - : (string -> unit) ref = {contents = } Thanks ! -- +--------------------------------------------------------+ | Ingo Bormuth, voicebox & telefax: +49-12125-10226517 | | GnuPG key 86326EC9 at http://ibormuth.efil.de/contact | +--------------------------------------------------------+