What will the new syntax be like? (O'Caml + O'Labl)

From: John Prevost (prevost@maya.com)
Date: Mon Dec 06 1999 - 04:05:20 MET


To: caml-list@inria.fr
Subject: What will the new syntax be like? (O'Caml + O'Labl)
From: John Prevost <prevost@maya.com>
Date: 05 Dec 1999 22:05:20 -0500

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

Things which freak me out:

  a) the ident1:ident2 syntax for labels is maybe convenient, but the
     fact that : is already used for types and that this requires : to not
     have whitespace around it is pretty nasty.

  b) the ?... syntax for optional stuff is pretty abominable.
     Combined with the : syntax, the definition of a function starts
     to look like gibberish.

  c) the ?... [< ... >] syntax for providing a default value for an
     optional argument adds to the pain, since [< ... >] is already
     used by parsers, and its heaviness combined with the ?s lightness
     makes it really obscure what a line like the above means.

  d) not illustrated above, the use of ` for polymorphic variants is
     also pretty ferociously confusing--mainly because ` and ' are
     sometimes difficult to tell apart, and because I could now say
     something like:

     let foo = parser [< '`foo 'a' >] -> ...

     which is parsable, but nasty.

  e) The type expressions that come out are sometimes nasty looking as
     well:

     'a[> 'int int | 'float float]

     which is actually not that bad, except for the 'a part which is
     quite unlike other self-referential types in O'Caml. (Why not
     something like objects: [> 'int int | 'float float ] as 'a?)

I just sucked down the O'Caml CVS version and have played with it a
bit trying to figure out what syntax is in the works. As far as I can
tell, the : is still being overloaded as above, and ? is being used
too, but [< ... >] has been changed (to something like {= ...} ? I
can't entirely tell, because if I try to use it I always get a "This
optional argument cannot be erased" warning.

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.

John



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:29 MET