Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
(int * int) <> int*int ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-02-24 (02:17)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] (int * int) <> int*int ?
From: "Lukasz Stafiniak" <>
> > This unfortunate syntax has consequences down to polymorphic variants,
> > which otherwise could be represented more efficiently.
> >
> This is interesting, could you explain it shortly?

The tuple based syntax for constructors is ambiguous: there is no way
to know syntactically whether a constructor takes as argument a tuple
or separate arguments. This is the reason for this whole discussion.

For datatypes, the ambiguity is solved by looking-up the definition.

With polymorphic variants, there is no definition, so one is forced to
use a uniform representation, namely all constructors have either 0 or
1 argument. This means that `A(arg1,arg2) has to be represented
internally as [|`A; [|arg1; arg2|] |].
With a non-ambiguous syntax, like (`A arg1 arg2), it would be possible
to use a more compact internal representation: [|`A; arg1; arg2|].

This is not a big problem, just an historical hiccup.