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 LAA32174; Fri, 3 Aug 2001 11:19:09 +0200 (MET DST) 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 LAA32172 for ; Fri, 3 Aug 2001 11:19:08 +0200 (MET DST) Received: from uni-sb.de (uni-sb.de [134.96.252.33]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f739J7D17705; Fri, 3 Aug 2001 11:19:07 +0200 (MET DST) Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.252.31]) by uni-sb.de (8.11.5/2001080100) with ESMTP id f739J6301557; Fri, 3 Aug 2001 11:19:06 +0200 (CEST) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.11.5/2001080100) with ESMTP id f739J5R10212; Fri, 3 Aug 2001 11:19:06 +0200 (CEST) Received: from ps.uni-sb.de (grizzly.ps.uni-sb.de [134.96.186.68]) by mail.cs.uni-sb.de (8.11.5/2001080100) with ESMTP id f739J4420885; Fri, 3 Aug 2001 11:19:05 +0200 (CEST) X-Authentication-Warning: email: Host grizzly.ps.uni-sb.de [134.96.186.68] claimed to be ps.uni-sb.de Received: from ps.uni-sb.de (zoidberg.ps.uni-sb.de [134.96.186.121]) by ps.uni-sb.de (8.11.2/8.11.0) with ESMTP id f739J4016261; Fri, 3 Aug 2001 11:19:04 +0200 Message-ID: <3B6A6C88.EFBDB7E2@ps.uni-sb.de> Date: Fri, 03 Aug 2001 11:19:04 +0200 From: Andreas Rossberg Organization: =?iso-8859-1?Q?Universit=E4t?= des Saarlandes X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: de, en MIME-Version: 1.0 To: "'caml-list@inria.fr'" CC: Xavier Leroy Subject: Re: [Caml-list] Why can't I use constructors as functions? References: <20010803101651.C29703@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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) > The former is more natural if you come from an SML background > (where constructors have 0 or 1 argument), but the latter fits better > the Caml Light / OCaml execution model, which favors curried > functions. By not treating constructors like functions, we avoid > having to choose... It seems to me that the former is the only choice that can be consistently typed. > - Code clarity. While using a constructor as a function is sometimes > convenient, I would argue it is often hard to read. Writing > "fun x -> Succ x" is more verbose, but easier to read, I think. But aren't you basically saying here that currying and partial application is bad practice? I can think of a person on this list who will love to hear that but it seems somewhat inconsistent with some of the basic Caml design decisions... ;-) Best regards, - Andreas -- Andreas Rossberg, rossberg@ps.uni-sb.de "Computer games don't affect kids. If Pac Man affected us as kids, we would all be running around in darkened rooms, munching pills, and listening to repetitive music." ------------------- 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