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 PAA31395; Fri, 5 Sep 2003 15:23:38 +0200 (MET DST) 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 PAA18504 for ; Fri, 5 Sep 2003 15:23:37 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h85DNbT12744 for ; Fri, 5 Sep 2003 15:23:37 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.12.9/1.01.28121999) with ESMTP id h8388RHd045331 for ; Wed, 3 Sep 2003 10:08:27 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id h838871I015715 for ; Wed, 3 Sep 2003 10:08:09 +0200 (MET DST) X-Authentication-Warning: clipper.ens.fr: frisch owned process doing -bs Date: Wed, 3 Sep 2003 10:08:06 +0200 (MET DST) From: Alain.Frisch@ens.fr X-X-Sender: frisch@clipper.ens.fr Reply-To: Alain.Frisch@ens.fr To: Caml list Subject: Re: [Caml-list] Type inference + optional parameters In-Reply-To: <20030903110813O.garrigue@kurims.kyoto-u.ac.jp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; alain:01 frisch:01 caml-list:01 inference:01 jacques:01 bauer:01 bauer:01 ocamls:01 inference:01 type-safe:01 multimatch:01 unification:01 alain:01 compiler:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 3 Sep 2003, Jacques Garrigue wrote: > From: Christoph Bauer > > > ocamls type inference uses information of optionl arguments. This > > results in a strange behaviour. > > Brian Rogoff already answered this one. Do you seriously expect a > type-safe compiler to simply ignore the type of the default value :-) I guess the original question is not that naive. It would be possible to have a type system with an extension like your multimatch, to make the type of the result of a function depend on the presence/absence of optional argument. With a crazy syntax to express conditional unification constraints, you could write for instance: do_with_opt_conv: ?conv:('a -> 'b orelse 'b = 'a) -> 'a -> 'b meaning that in the absence of the optional argument, the result type must be unified with the argument type (there are more constraints when the optional argument is not provided). Does it make sense ? -- Alain ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners