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 SAA15575; Wed, 4 Apr 2001 18:39:25 +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 SAA15765 for ; Wed, 4 Apr 2001 18:39:24 +0200 (MET DST) Received: from mrwall.kal.com (mrwall.kal.com [194.193.14.236]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id f34GdNr25516 for ; Wed, 4 Apr 2001 18:39:23 +0200 (MET DST) Received: from mrwall.kal.com [194.193.14.236] (HELO localhost) by mrwall.kal.com (AltaVista Mail V2.0J/2.0J BL25J listener) id 0000_0045_3acb_4ee6_107f; Wed, 04 Apr 2001 17:42:14 +0100 Subject: RE: [Caml-list] Future of labels, and ideas for library labelling MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Wed, 4 Apr 2001 17:37:49 +0100 content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.4417.0 Message-ID: Thread-Topic: [Caml-list] Future of labels, and ideas for library labelling Thread-Index: AcC78bNzMwx5uGyLSK2cb0JQNJ3eQwBMXk0A From: "Dave Berry" To: "Jacques Garrigue" , Cc: Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > -----Original Message----- > From: Jacques Garrigue [mailto:garrigue@kurims.kyoto-u.ac.jp] > ... > SML for instance has structural > records, and uses them in its basis library. You can look at=20 > the result for yourself. For me it's only half the way. > * You cannot mix labeled and unlabeled arguments, whereas you often > want to keep one unlabeled argument in your function. As you say, this is a matter of taste, but I don't agree with your sentiment here. I would prefer all labels or none, rather than having to remember which arguments have labels and which don't. Better still is the suggestion of Arturo Borquez and Dave Mason, where labels can be given or not, as the caller pleases. My only reservation is that I don't know how easy this would be to extend to optional arguments. > * I believe labels + currying give a nicer syntax. It's a matter of taste again, but I think the OCaml label syntax is awful. I also don't like curried syntax: with f{x=3D0, y=3D1} or f(0, = 1), the brackets clearly delineate the arguments. Curried syntax makes this much less clear (particularly when mixed with infix operators). I find most Haskell programs unreadable for this reason. (To be fair, I think much of SML's syntax is also awful). > * You would of course have to extends records with optional fields, > with creates new problems of overloading. This is certainly true. Possibly we could simplify the problem by only allowing optional arguments in records used as parameter lists. > > 1. List.fold_right (List.fold_right IntSet.add) lists IntSet.empty > Now let's write it with labels > List.fold_left lists ~init:IntSet.empty > ~f:(fun set l -> > List.fold_left l ~init:set ~f:(fun set x ->=20 > IntSet.add x set)) or: > List.fold_left lists ~acc:IntSet.empty > ~f:(List.fold_left ~f:(fun ~acc item -> IntSet.add acc ~item)) > Now, which is the more readable program, this one or yours. This is taste again, but I'm tempted to ask "Are you serious"??? Patrick's version is clearly more readable. Better still would be to get rid of some qualified names and use more concise names: foldr (foldr IntSet.add) lists IntSet.empty Brevity can make programs easier to read. > For me it was really revealing to hear > from program transformation researchers in Haskell (who use fold for > their transformations) that they didn't use it directly in actual > programs. That's potentially interesting, but did you ask what they used instead? Maybe they used list comprehensions or monad syntax. Dave. ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr