Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
let ... in layout
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-03-15 (14:07)
From: Jean-Yves Moyen <Jean-Yves.Moyen@l...>
Subject: Re: let ... in layout
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 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 Is there any reason why the BNF
>         let {name = expr}+ in
> would be ambiguous?

I guess one can write:
let silly f=
  let f z=3 in

which can be read either:
let silly f=
  let f in 
  let z=3 in

let silly f=
  let 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.