Version française
Home     About     Download     Resources     Contact us    
Browse thread
If OCaml were a car
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] If OCaml were a car
On Sun, Aug 19, 2007 at 10:43:14AM -0400, John Carr wrote:
> > Maybe I ride this car too often to realize (or I'm dumb) but I don't  
> > get the joke about controls.
> 
> OCaml has a badly designed syntax processed by a badly implemented
> parser feeding into a backend that generates poor error messages.
> All this makes the language hard to use.

I think this is a little bit of an exaggeration, but there is some
truth to it.

It's not likely that the syntax can be changed (how is the revised
syntax doing lately?) but there is one error message which could be
fixed.  When I worked at Merjis a colleague got frustrated to the
point of virtually giving up the language at the error message "Foo
makes inconsistent assumptions over Bar"[1].  It is literally useless:
it does not describe what it means, what files are involved which are
inconsistent, what their MD5 sums are or should be, and lastly it
doesn't say how to fix the problem (which generally involves
recompiling libraries).

On the up side, OCaml does show you the range of characters within the
line where the error happens.  This is something I now really miss
when using gcc / C code.

> Anybody else learn C using pcc on Unix?

Using the traditional K&R compiler for OS-9/68k and later using pcc on
Unix.  The OS-9 compiler only had about 10 different error messages
that it could print (I remember they were listed on a short page in
the manual).  ocamlopt really is miles better :-)

> Unfortunately, I didn't think to start cataloging compiler error
> messages and their causes when I started learning the language.
> I did send one anomaly to the list about parsing of semicolons.

I tell beginners that most code they write should be within a toplevel
statement:

  let _ =
    ...

or (better):

  let () =
    ...

That basically gets rid of any ; vs ;; issues.

On the subject of cataloging error messages see:
http://www.ocaml-tutorial.org/common_error_messages

Rich.

[1] I forget the precise message because hopefully my terribly
complicated dependency rules for OCaml on Fedora make it impossible
to happen, so I can't recreate it here!
http://fedoraproject.org/wiki/Packaging/OCaml#head-0c27c921de0c32d391ea39fffcbbacbd28ad10ca

-- 
Richard Jones
Red Hat