From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA10037; Mon, 19 Feb 2001 01:02:17 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA09964 for ; Mon, 19 Feb 2001 01:02:15 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f1J02DT02135 for ; Mon, 19 Feb 2001 01:02:14 +0100 (MET) Received: from localhost (mikan.kurims.kyoto-u.ac.jp [130.54.16.202]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id JAA29259; Mon, 19 Feb 2001 09:01:46 +0900 (JST) To: patrick@watson.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] Typing of default arguments In-Reply-To: References: <200102170715.IAA11563@pauillac.inria.fr> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010219090146V.garrigue@kurims.kyoto-u.ac.jp> Date: Mon, 19 Feb 2001 09:01:46 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Patrick M Doane > Any thoughts about the restriction of polymorphism that can happen when > using default arguments? It is still annoying that d' fails to type-check. > > I would assume that the function could be type-checked as if the default > argument did not exist, and then type-check the default value against the > signature of the function for consistency. > > This strategy would then give f and f' these types: > > val f : g:('a -> 'b) -> 'a -> 'b > val f' : ?g:('a -> 'b) -> 'a -> 'b Since the default value for g is (fun x -> x), when g is omitted 'a = 'b should be enforced. Otherwise, (fun x -> f' x) would be of the magic type ('a -> 'b), which is certainly not what you are asking for. Enforcing such a conditional equation is possible, but this would means yet another extension to the type system: val f' : ?g:('a -> 'b ?= 'c -> 'c) -> 'a -> 'b meaning that the default value for g has type 'c -> 'c. Two problems: is it really worth it (you are not the first one to ask for that, but would this improve a lot programming style?), and what are the consequences. In particular it would probably mean more polymorphic types at places where you do not really need them, requiring more type annotations to make them readable. Jacques ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr