Language improvements (?)

Frank Christoph (christo@nextsolution.co.jp)
Wed, 24 Jul 1996 15:30:32 +0900

Date: Wed, 24 Jul 1996 15:30:32 +0900
From: christo@nextsolution.co.jp (Frank Christoph)
Message-Id: <9607240630.AA00506@sparc3.nextsolution.co.jp>
To: caml-list@pauillac.inria.fr
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
"Unicode.string".

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

List.map #f x

or perhaps even

List.map f x

instead of

List.map (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
christo@nextsolution.co.jp Fax: 0424-98-1500