Hi,

On Thu, Oct 9, 2008 at 06:15, Conglun Yao <[EMAIL PROTECTED]> wrote:
> Sorry, I can't fully understand the source code, but it seems we can
> only define a polymorphic variant with only one additional type
> declaration, like
>               `A of int   or `A of (int * int)
>  rather than `A of int * int

That's correct.

> It looks wired, as we can directly define
> type t = [ `A of int * int | `B of string ]  in toploop or a *.ml file.

yes, that's because ocaml handle the "of int * int" a bit differently
in regular and
polymorphic variant declarations:
  - in the regular variant the * is a separator between constructor
arguments (thus two arguments)
  - polymorphic variants only have one argument, so int * int is
treated as a whole type expression and * is the "tupling" operator

So yes, this looks wired in the ocaml parser.

-- 
  Olivier

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to