From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA06778 for caml-redistribution@pauillac.inria.fr; Wed, 15 Mar 2000 15:07:06 +0100 (MET) Resent-Message-Id: <200003151407.PAA06778@pauillac.inria.fr> 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 JAA05241 for ; Wed, 15 Mar 2000 09:22:37 +0100 (MET) Received: from lorraine.loria.fr (lorraine.loria.fr [152.81.1.17]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id JAA03602 for ; Wed, 15 Mar 2000 09:22:36 +0100 (MET) Received: from bar.loria.fr (bar.loria.fr [152.81.2.13]) by lorraine.loria.fr (8.9.3/8.9.3/8.9.3/JCG-DG) with ESMTP id JAA26406 for ; Wed, 15 Mar 2000 09:22:35 +0100 (MET) Date: Wed, 15 Mar 2000 09:22:34 +0100 (MET) From: Jean-Yves Moyen Reply-To: Jym To: Caml mailing list Subject: Re: let ... in layout In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Resent-From: weis@pauillac.inria.fr Resent-Date: Wed, 15 Mar 2000 15:07:06 +0100 Resent-To: caml-redistribution@pauillac.inria.fr On 15 Mar 2000, Julian Assange wrote: > > let .. in > let .. in ... > > seems such a common construct in caml that it could do with some > syntatic sugar. I often see let..in run to 5-20 clauses. This appears > incredibly ugly compared to the equivalent haskell code, is harder to > read and takes longer to write due to the clutter of the surrounding > token magic. Has anyone thought about applying layout in general to > ocaml, or otherwise sugaring let...in? Is there any reason why the BNF > > let {name = expr}+ in > > would be ambiguous? I guess one can write: let silly f= let x=List.map f z=3 in ... which can be read either: let silly f= let x=List.map f in let z=3 in ... or: let silly f= let x=List.map in let f z=3 in ... Of course, if your definition aren't mutually recursive, you can use 'and' to separate two deifferent definitons: let x=t and y=u and ... and z=v in ... which is not so long to write, unambigous and readable (I find). > The only other haskell features I frequently miss, are list > comprehensions and multiple argument pattern matching. I don't understand exactly what you mean by 'multiple argument pattern matching', but I guess you could just use a tuple-pattern matching: let f a b c= match a,b,c with ... which allows you to match several arguments at once. Hypocoristiquement, Jym.