Version française
Home     About     Download     Resources     Contact us    
Browse thread
What will the new syntax be like? (O'Caml + O'Labl)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <Jacques.Garrigue@i...>
Subject: Re: What will the new syntax be like? (O'Caml + O'Labl)
From: John Prevost <prevost@maya.com>

> Can we get any hints on what the syntax of the O'Labl features in the
> new O'Caml will be like?  I do like the polymorphic variants and
> tagged/optional argument features of O'Labl, but I'm not too keen on
> their syntax:
> 
> let foo bar:a zub:b ?qux:c [< 10 >] ?woz:d =
>   match d with
>     | None -> a + b + c
>     | Some x -> a + b + c + d

Changes are rather small:

let foo bar:a zub:b ?qux:c{=10} ?woz:d () =
  match d with
  | None -> a + b + c
  | Some x -> a + b + c + d

Notice that you need a non-labeled argument after optional ones, due
to a change in semantics. Optional arguments are now only discarded if
the function is applied to a non-labeled argument appearing after them
the function type.
This change was necessary to resolve some ambiguities, and provide an
untyped semantics for the language.

> Things which freak me out:
> [...]

You may like or not the above notation for labels. We had discussions
here, and the conclusion was that putting spaces around type
annotations was a good thing anyway...

I will not answer in detail your other comments, but yes, the change
in notation for default arguments is to avoid the similarity with
stream parsers.

Variant types have also a cleaned-up syntax, where recursion works
like with objects.

> Anyway, what's in store for us in the next version of O'Caml?  I've
> thought Caml's syntax the cleanest of the ML family for some time, but
> warts like the above could make me change my mind.

It's hard to put that many new features in the language, keeping the
compatibility with all, and obtain a clean syntax. I must admit.
However I think that ocaml3 syntax is reasonable enough, at least
better than olabl's. A second attempt has its advantages.

By the way, the new version is not yet released, so if you have a
coherent syntax to propose for the new features, you can propose.

        Jacques
------------------------------------------------------
Jacques Garrigue, visiting INRIA from Kyoto University
		          Jacques.Garrigue at inria.fr