caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: How do I ..
@ 1999-12-18 17:41 Juergen Pfitzenmaier
  0 siblings, 0 replies; 7+ messages in thread
From: Juergen Pfitzenmaier @ 1999-12-18 17:41 UTC (permalink / raw)
  To: caml-list


John Skaller was asking about:
> # let f (lx:x : int) = x + 1;;
> Syntax error

maybe   let f lx: (x : int) = x + 1;;
is what you want.

pfitzen




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

* Re: How do I ..
  1999-12-20 20:16     ` Brian Rogoff
@ 1999-12-21 17:39       ` Jacques Garrigue
  0 siblings, 0 replies; 7+ messages in thread
From: Jacques Garrigue @ 1999-12-21 17:39 UTC (permalink / raw)
  To: bpr; +Cc: caml-list

From: Brian Rogoff <bpr@best.com>

> > 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.
> 
> I understand that people will have different preferences, but supporting
> two syntaxes has severe disadvantages. As an interim approach it is OK but 
> it will be harder for beginners and may split the users development
> efforts. I understand the arguments for both styles, so I haven't yet
> decided what I'll do. Since I'm pretty tolerant of verbosity (Ada user:-) 
> I'll probably try to exclusively use the modern mode.

While I agree with you that the current situation may be a bit
disturbing for beginners (they will probably choose the style they are
taught), it is not true that efforts are splitted. This was the point
in merging. The two styles are completely compatible, and in a same
project the two styles may be combined freely, on a file unit
(directory, with makefiles). This last approach is not encouraged, but
this is possible. 

If you are not yet fixed on the style you will choose, then I can only
encourage your choosing modern mode.  My personal point of view, as I
proposed it with olabl, is that writing more labels costs nothing, and
that commutation (or rather the irrelevance of the order) of arguments
is a real plus.

Concerning future, if at some point there appears a consensus that the
modern mode is better, then it would be possible to switch things the
other way round, modern mode being the default, and classic mode being
left for legacy software and irreducibles. But currently compatibility
seems to matter more.

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




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

* Re: How do I ..
  1999-12-20 11:06   ` Jacques Garrigue
@ 1999-12-20 20:16     ` Brian Rogoff
  1999-12-21 17:39       ` Jacques Garrigue
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Rogoff @ 1999-12-20 20:16 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: caml-list

On Mon, 20 Dec 1999, Jacques Garrigue wrote:
> From: Brian Rogoff <bpr@best.com>
> > 
> > I hope this modern/classic mode distinction is just a temporary thing. 
> 
> 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.

I understand that people will have different preferences, but supporting
two syntaxes has severe disadvantages. As an interim approach it is OK but 
it will be harder for beginners and may split the users development
efforts. I understand the arguments for both styles, so I haven't yet
decided what I'll do. Since I'm pretty tolerant of verbosity (Ada user:-) 
I'll probably try to exclusively use the modern mode.

-- Brian




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

* Re: How do I ..
  1999-12-18 17:59 ` Brian Rogoff
@ 1999-12-20 11:06   ` Jacques Garrigue
  1999-12-20 20:16     ` Brian Rogoff
  0 siblings, 1 reply; 7+ messages in thread
From: Jacques Garrigue @ 1999-12-20 11:06 UTC (permalink / raw)
  To: bpr; +Cc: caml-list

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




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

* How do I ..
  1999-12-18  7:02 skaller
  1999-12-18 17:59 ` Brian Rogoff
@ 1999-12-18 18:09 ` David Brown
  1 sibling, 0 replies; 7+ messages in thread
From: David Brown @ 1999-12-18 18:09 UTC (permalink / raw)
  To: CAML Mailing

skaller writes:
 > I'm confused:
 > 
 >        Objective Caml version 2.99 (99/12/08)
 > 
 > # let f (lx:x : int) = x + 1;;
 > Syntax error

The labels have to be at the "top".

# let f lx:(x : int) = x + 1;
val f : lx:int -> int = (fun)

Dave Brown




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

* Re: How do I ..
  1999-12-18  7:02 skaller
@ 1999-12-18 17:59 ` Brian Rogoff
  1999-12-20 11:06   ` Jacques Garrigue
  1999-12-18 18:09 ` David Brown
  1 sibling, 1 reply; 7+ messages in thread
From: Brian Rogoff @ 1999-12-18 17:59 UTC (permalink / raw)
  To: skaller; +Cc: caml-list

On Sat, 18 Dec 1999, skaller wrote:

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

> Here, I have an argument x, a label lx, and a type declaration int.
> What's the error? Can't I both label an argument, and also type it?

Modern mode handles it. I would have thought classic mode would too, since
you're not reordering arguments, but I see that's not the case. Explanation
anyone?

> The whitespace rule is a bit weird .. but it makes some sense,
> when compared with 'a for a type variable: the ' must come
> right in front of the a, with no white space, so I guess
> I can live with lablx:x as a labelled argument .. :-)
> 
> At first, I got really confused by the difference between
> a label, and the name of the argument. Until I realised,
> you can't use the name of the argument as a label, because
> it would imply all arguments were labelled. In the tutorial,
> it would be nice to replace ambiguous examples like:
> 
> 	let f x:x ... 

I think that the label is "x:" and the argument name is "x", with the 
sugar that :x is equivalent to x:x. At least that's how I interpreted 
the rules.

-- Brian




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

* How do I ..
@ 1999-12-18  7:02 skaller
  1999-12-18 17:59 ` Brian Rogoff
  1999-12-18 18:09 ` David Brown
  0 siblings, 2 replies; 7+ messages in thread
From: skaller @ 1999-12-18  7:02 UTC (permalink / raw)
  To: caml-list

I'm confused:

       Objective Caml version 2.99 (99/12/08)

# let f (lx:x : int) = x + 1;;
Syntax error


Here, I have an argument x, a label lx, and a type declaration int.
What's the error? Can't I both label an argument, and also type it?

The whitespace rule is a bit weird .. but it makes some sense,
when compared with 'a for a type variable: the ' must come
right in front of the a, with no white space, so I guess
I can live with lablx:x as a labelled argument .. :-)

At first, I got really confused by the difference between
a label, and the name of the argument. Until I realised,
you can't use the name of the argument as a label, because
it would imply all arguments were labelled. In the tutorial,
it would be nice to replace ambiguous examples like:

	let f x:x ... 

where I can't tell which x is which, with

	let f xlabl:xparam ..

where the names clearly suggest what is what.

--
John Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850




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

end of thread, other threads:[~1999-12-21 21:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-18 17:41 How do I Juergen Pfitzenmaier
  -- strict thread matches above, loose matches on Subject: below --
1999-12-18  7:02 skaller
1999-12-18 17:59 ` Brian Rogoff
1999-12-20 11:06   ` Jacques Garrigue
1999-12-20 20:16     ` Brian Rogoff
1999-12-21 17:39       ` Jacques Garrigue
1999-12-18 18:09 ` David Brown

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