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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <weis@p...>
Subject: Re: Language improvements (?)

Date: Thu, 25 Jul 1996 20:14:18 +0900
From: (Frank Christoph)
Message-Id: <>
In-Reply-To: <> (message from Ian T Zimmerman on Wed, 24 Jul 1996 19:12:38 -0700)
Subject: Re: Language improvements (?)

[ Mode'rator's Note:


   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 <> 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

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 ...


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

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