caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Language improvements (?)
@ 1996-07-24  6:30 Frank Christoph
  1996-07-24  8:44 ` Pierre Weis
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Christoph @ 1996-07-24  6:30 UTC (permalink / raw)
  To: caml-list


  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





^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Language improvements (?)
@ 1996-07-25 17:14 Pierre Weis
  0 siblings, 0 replies; 7+ messages in thread
From: Pierre Weis @ 1996-07-25 17:14 UTC (permalink / raw)
  To: caml-list


Date: Thu, 25 Jul 1996 20:14:18 +0900
From: christo@nextsolution.co.jp (Frank Christoph)
Message-Id: <9607251114.AA00849@sparc3.nextsolution.co.jp>
To: caml-list@pauillac.inria.fr
In-Reply-To: <199607250212.TAA04865@kronstadt.rahul.net> (message from Ian T Zimmerman on Wed, 24 Jul 1996 19:12:38 -0700)
Subject: Re: Language improvements (?)

[ Mode'rator's Note:

   Hi,

   Please note that from today to August the 26th, no messages from
   the Caml mailing list will be sent (vacations).

   Sorry for the inconvenience,

   Pierre Weis
]

>>>>> "Ian" == Ian T Zimmerman <itz@rahul.net> writes:

> Hmm, I sincerely hope the Caml team will _not_ follow this suggestion, or at
> the very least leaves an escape in the form of a compiler switch for those
> of us who dislike it.

> It is a religious issue, and I see little point in repating the arguments
> made many times before in comp.compilers, among other places.  I recognize
> the points of the other side, but this would be a fundamental change in how
> the language `looks and feels' and so I think prudence should prevail and
> scoping by keywords should be preserved.

  I agree 100%.  It's far too late for such a fundamental change; implementing
it in O'Caml would be rash and injudicious, and would probably take it
completely out of the realm of ML itself.

  So, uh, let's change the name of the language.  Yeah, that's it. How about,
oh, I dunno, "The-Language-Formerly-Known-As-Objective ML"?  :)

  No, seriously though, I don't expect such a drastic change at this point.  I
was just, shall we say, daydreaming?  Besides, I have a hundred *other*
syntactical improvements to suggest.  Now where was that list ... ?

  OK, OK -- I can see everyone starting to moan already.

  But I do have one humble little question concerning syntax and conventional
practice in the Caml world.  O'Caml seems to lack a succinct way of defining
functions that pattern-match multiple arguments.  For example, suppose I
wanted to define a function to exclusive-OR the integers 1 and 0 without using
the wildcard "_".  In Haskell, I could write

xor 1 1 = 0
xor 0 1 = 1
xor 1 0 = 1
xor 0 0 = 0

and apparently in SML it is possible to write

fun xor 1 1 = 0
  | xor 0 1 = 1
  | xor 1 0 = 1
  | xor 0 0 = 0

but, as far as I can tell, there is no simple way to do this in O'Caml.  If I
write

let xor 1 1 = 0
and xor 1 0 = 1
and xor 0 1 = 1
and xor 0 0 = 0

I get a duplicate binding error.  If I try

let xor = fun ...

or

let xor = function ...

then I need to nest pattern-matching constructs.

  Is there a pattern-matching construct like the Haskell and SML examples I
gave in O'Caml?  (Did I miss it?)  Or is there some reason why it has been
left out?

  I know that compiling pattern-matches perfectly isn't possible because it
requires parallel evaluation of arguments.  Is this why there is no such
construct, to force users to choose an evaluation order?  But then, "fun x y
..." is parallel.  (Granted, there is an O'Caml convention for its
evaluation.)

------------------------------------------------------------------------
Frank Christoph                 Next Solution Co.      Tel: 0424-98-1811
christo@nextsolution.co.jp                             Fax: 0424-98-1500





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1996-07-25 17:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-24  6:30 Language improvements (?) Frank Christoph
1996-07-24  8:44 ` Pierre Weis
1996-07-24  9:53   ` Frank Christoph
1996-07-24 17:04     ` Georg Bauer
1996-07-25  2:12     ` Ian T Zimmerman
1996-07-25 12:26   ` Michel Mauny
1996-07-25 17:14 Pierre Weis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).