Version française
Home     About     Download     Resources     Contact us    
Browse thread
How do I ..
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <Jacques.Garrigue@i...>
Subject: Re: How do I ..
From: Brian Rogoff <bpr@best.com>

> > I'm confused:
> > 
> >        Objective Caml version 2.99 (99/12/08)
> > 
> > # let f (lx:x : int) = x + 1;;
> > Syntax error
> 
> Try "#modern true;;" at the top level, or compile with the -modern switch. 
> 
> I hope this modern/classic mode distinction is just a temporary thing. 

For this specific point of syntax, prohibiting it in classic mode is
just temporary. This is intended to avoid bad behaviour on legacy
programs, like "let f (x:int) = x + 1;;", where x: would interpreted
as a label. Better to have a syntax error at once, rather than a
"unbound value int" later on. Note that we cannot avoid all such
cases, but this does not seem a good idea to have lots of them.

As to the existence of two modes, I expect it to stay around for a bit
longer.

Clearly, there are supporters for both styles. Those who may like to
put some labels in their interfaces, but do not want to have to put
labels in every line of code, and those who value the extra expressive
power of doing so.

One solution would have been no classic mode, but two standard
libaries, with or without labels. This might have worked ok, but this
meant that the programming style was choosen by the author of the
library, rather than by its user.

With two modes, libraries can be written in any style, and
they can be used (more or less) comfortably in both styles.

Jacques
------------------------------------------------------
Jacques Garrigue, visiting INRIA from Kyoto University
		          Jacques.Garrigue at inria.fr