caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Private type syntax and error message
@ 2008-09-12 13:43 Colonna Francois
  2008-09-12 15:01 ` [Caml-list] " Colonna Francois
  2008-09-12 15:04 ` Jon Harrop
  0 siblings, 2 replies; 5+ messages in thread
From: Colonna Francois @ 2008-09-12 13:43 UTC (permalink / raw)
  To: caml-list

Hello,

if, as I found in the documentation, I write :
 
# 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 ?

Best,

François Colonna



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

* Re: [Caml-list] Private type syntax and error message
  2008-09-12 15:04 ` Jon Harrop
@ 2008-09-12 14:19   ` Dario Teixeira
  2008-09-12 14:37     ` Virgile Prevosto
  0 siblings, 1 reply; 5+ messages in thread
From: Dario Teixeira @ 2008-09-12 14:19 UTC (permalink / raw)
  To: caml-list, Jon Harrop

> What do you expect it to do that might work? If it created
> an abstract type 
> the type would be useless, having no way to construct or
> destructure values 
> of that type...

Hi,

I think the idea is that the type would be declared inside
a module that would provide constructor functions.  Moreover,
because private is not abstract, it would allow the outside
world to pattern-match on values of that type.  This is actually
a very useful feature.

Btw, the code works on 3.11 CVS!

Cheers,
Dario Teixeira






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

* Re: [Caml-list] Private type syntax and error message
  2008-09-12 14:19   ` Dario Teixeira
@ 2008-09-12 14:37     ` Virgile Prevosto
  0 siblings, 0 replies; 5+ messages in thread
From: Virgile Prevosto @ 2008-09-12 14:37 UTC (permalink / raw)
  To: caml-list

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


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

* Re: [Caml-list] Private type syntax and error message
  2008-09-12 13:43 Private type syntax and error message Colonna Francois
@ 2008-09-12 15:01 ` Colonna Francois
  2008-09-12 15:04 ` Jon Harrop
  1 sibling, 0 replies; 5+ messages in thread
From: Colonna Francois @ 2008-09-12 15:01 UTC (permalink / raw)
  To: caml-list

Le vendredi 12 septembre 2008 à 15:43 +0200, Colonna Francois a écrit :
> Hello,
> 
> if, as I found in the documentation, I write :
>  
> # 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 ?
> 

Sorry,

I found in http://caml.inria.fr/mantis/view.php?id=4584 the answer to my
question. X. Leroy said there :

The "private type abbreviations" feature of 3.11 ....

  type t = private float
 

So, I shall wait a few monthes. No problem.
Thanks any ways to thoses who answered.

Best,
François Colonna


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

* Re: [Caml-list] Private type syntax and error message
  2008-09-12 13:43 Private type syntax and error message Colonna Francois
  2008-09-12 15:01 ` [Caml-list] " Colonna Francois
@ 2008-09-12 15:04 ` Jon Harrop
  2008-09-12 14:19   ` Dario Teixeira
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Harrop @ 2008-09-12 15:04 UTC (permalink / raw)
  To: caml-list

On Friday 12 September 2008 14:43:19 Colonna Francois wrote:
> Hello,
>
> if, as I found in the documentation, I write :
>
> # type my_int = private int;;

Where does that appear in the documentation? Google returns zero hits...

> I get the message : "This fixed type is not an object or variant"
>
> 1. The message is very obscure

How would you write it more clearly?

> 2. why this syntax is not implemented as it should be ?

What do you expect it to do that might work? If it created an abstract type 
the type would be useless, having no way to construct or destructure values 
of that type...

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


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

end of thread, other threads:[~2008-09-12 15:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-12 13:43 Private type syntax and error message Colonna Francois
2008-09-12 15:01 ` [Caml-list] " Colonna Francois
2008-09-12 15:04 ` Jon Harrop
2008-09-12 14:19   ` Dario Teixeira
2008-09-12 14:37     ` Virgile Prevosto

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