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 MAA00580; Fri, 3 Aug 2001 12:00:20 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 MAA00536 for ; Fri, 3 Aug 2001 12:00:19 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f73A0ID19125; Fri, 3 Aug 2001 12:00:18 +0200 (MET DST) Received: from kastanie.ai.univie.ac.at (root@kastanie.ai.univie.ac.at [131.130.174.141]) by fichte.ai.univie.ac.at (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id MAA23126; Fri, 3 Aug 2001 12:00:18 +0200 Received: (from markus@localhost) by kastanie.ai.univie.ac.at (8.9.3/8.9.3/Debian 8.9.3-21) id MAA31510; Fri, 3 Aug 2001 12:00:17 +0200 Date: Fri, 3 Aug 2001 12:00:17 +0200 From: Markus Mottl To: Xavier Leroy Cc: OCAML Subject: Re: [Caml-list] Why can't I use constructors as functions? Message-ID: <20010803120017.A31361@kastanie.ai.univie.ac.at> References: <20010803101651.C29703@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010803101651.C29703@pauillac.inria.fr>; from Xavier.Leroy@inria.fr on Fri, Aug 03, 2001 at 10:16:51 +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 03 Aug 2001, Xavier Leroy wrote: > - Constructors in Caml Light and OCaml really have an arity, e.g. > C of int * int is really a constructor with two integer arguments, > not a constructor taking one argument that is a pair. Hence, there > would be two ways to map the constructor C to a function: > fun (x,y) -> C(x,y) > or > fun x y -> C(x,y) Why? To me only the latter seems to be consistent with the constructor. I'd expect the first form in the case of "C of (int * int)", which is indeed represented differently to "C of int * int". Actually, this proves that we already have ambiguity, e.g.: C (1, 2) How does the definition of this variant look like? C of int * int or C of (int * int) ? Nobody can tell... Therefore, I'd rather propose that it be required to write: C 1 2 if the definition is "C of int * int". I know, this would break a lot (maybe almost all) code, but could be automatically transformed if required. Maybe the choice of the type constructor for pairs "*" wasn't so good: people really confuse this with tuples. Another symbol would seem more approriate ("&", "^", ...?). The language would seem much more regular to me if functions and constructors were treated in a similar way. Would this be too big a change to the core language? Regards, Markus Mottl -- Markus Mottl markus@oefai.at Austrian Research Institute for Artificial Intelligence http://www.oefai.at/~markus ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr