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
Language improvements (?)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1996-07-24 (08:44)
From: christo@n...
Subject: Language improvements (?)

  Since we are griping about language features, allow me to put in my two
cents about a few (admittedly even more) trivial matters.

  First, it would be nice to be able to hide pervasives so that, in order to
use a pervasive, you would need to qualify it explicitly, e.g.,
"Pervasives.char".  I know that you can redefine a pervasive if you want to
(at least in the interpreter), but unless you can hide the Pervasives module,
you run into problems in recursive scopes like class definitions.  I ran into
this problem defining a unicode module where I wanted to reuse the names
"char" and "string" so I could refer to them as "Unicode.char" and

  Second, if you are going to put objects in the language, it would be useful
to make some of the primitives objects as well.  For example, it would have
been nice to be able to coerce a "c:char" to a unicode character via the
coercion operator, "c:char :> Unicode.char".  Of course you can define your
own character class, but that introduces a new type so you can't use it with
all the library functions that operate on chars.  In fact, the same could be
said for most of the library as well.  I realize most of it was taken from
Caml Light and hasn't been fully converted yet, but many library modules are
well-suited to the object paradigm, for example, hash tables.

  Third, since the trend in O'Caml is toward curried function types, it would
be useful to be able to section binary operators as in Haskell, e.g., "(1+)"
would mean "(function x -> 1 + x)".  Also, and perhaps more importantly, it
would be useful to be able to refer to methods independently of a particular
object.  For example, if "f" is a method of class "t", and "x" is a "t list",
I would like to be able to write #f x

or perhaps even f x

instead of (function obj -> obj#f) x.

Either way, this lets you separate overloading somewhat from the OO paradigm,
potentially making it more useful, IMHO.

  And, at the risk of instigating a syntax war, I would prefer a more
Haskell-like syntax overall; for example, offside scoping, uppercase types so
there is no need for quotes in front of type variables, and user-definable
symbolic binary operators... <sigh> Then again, I guess there's no point in
turning O'Caml into an eager Haskell.  Anyway, I suppose there is a
philosophical reason why there are no user-defined symbolic identifiers in
Caml although SML allows them.

Frank Christoph                 Next Solution Co.      Tel: 0424-98-1811                             Fax: 0424-98-1500