Version française
Home     About     Download     Resources     Contact us    
Browse thread
Private type syntax and error message
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Virgile Prevosto <virgile.prevosto@m...>
Subject: Re: [Caml-list] Private type syntax and error message
Hello,

Le ven 12 sep 2008 07:19:54 CEST,
Dario Teixeira <darioteixeira@yahoo.com> a écrit :

> 
> Btw, the code works on 3.11 CVS!
> 
Yes, this is a feature scheduled to be added in 3.11. in 3.10.x, only
variant and records can be made private. 

Le ven 12 sep 2008 15:43:19 CEST,
Colonna Francois <f.colonnacesari@free.fr> a écrit :

> # type my_int = private int;;
> 
> I get the message : "This fixed type is not an object or variant"
> 
> 1. The message is very obscure
> 2. why this syntax is not implemented as it should be ?
The syntax seems to be implemented as what the documentation says.
See http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#htoc99: 
"Private types

type-representation	::=	...  
 	∣	 = private constr-decl  { | constr-decl }  
 	∣	 = private { field-decl  { ; field-decl } }
"
i.e. at the moment you can write 'type foo = private A of int'
or 'type bar = private { a of int }'
but not directly 'type my_int = private int'
(IIRC, there are some technical reasons linked to the internal
representation of ocaml syntax tree for that) 
As said above, you have to wait (or try the cvs version) for ocaml 3.11
to be able to declare any type definition as private.
-- 
E tutto per oggi, a la prossima volta.
Virgile