Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] (int * int) <> int*int ?
From: "Lukasz Stafiniak" <lukstafi@gmail.com>
> > 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.

Jacques