caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Syntax of types
@ 2013-02-07  6:21 Christophe Papazian
  2013-02-07  6:48 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Papazian @ 2013-02-07  6:21 UTC (permalink / raw)
  To: Caml List

Hi

I'm not sure to understand the difference between :

let f (type s) : s t -> s = ...
let f : type s . s t -> s = ...

except it seems I can use the second one in place of the first one, but sometimes I can't use the first one and need the second one.
So I feel I only need the second one.

Thank you for your answers

	Christophe



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

* Re: [Caml-list] Syntax of types
  2013-02-07  6:21 [Caml-list] Syntax of types Christophe Papazian
@ 2013-02-07  6:48 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2013-02-07  6:48 UTC (permalink / raw)
  To: Christophe Papazian; +Cc: Caml List

[-- Attachment #1: Type: text/plain, Size: 803 bytes --]

On Thu, Feb 7, 2013 at 3:21 PM, Christophe Papazian <
christophe.papazian@gmail.com> wrote:

> Hi
>
> I'm not sure to understand the difference between :
>
> let f (type s) : s t -> s = ...
> let f : type s . s t -> s = ...
>
> except it seems I can use the second one in place of the first one, but
> sometimes I can't use the first one and need the second one.
> So I feel I only need the second one.
>

As explained in the manual, they are not strictly equivalent.

http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual021.html#toc80

In particular the second syntax guarantees that the type is polymorphic,
and syntactically it can only used just after the defined identifier.

This said, in practice the second one mostly subsumes the first one (but it
is just syntactic sugar).

Jacques Garrigue

[-- Attachment #2: Type: text/html, Size: 1295 bytes --]

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

end of thread, other threads:[~2013-02-07  6:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07  6:21 [Caml-list] Syntax of types Christophe Papazian
2013-02-07  6:48 ` Jacques Garrigue

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