I don't really understand how this could work. If the type of a function is 'a * 'b -> 'c then the function expects 2 tuple members, right? It has no idea what their size is, because it can be called on any tuple. Now let's say the tuple is float * int. If we unbox the tuple,  we get 3 words, with the int comprising the 3rd word, and no metadata. How does the function know how big each member is, or where to find each member? Are you assuming we monomorphize the function?

Yotam


On Thu, Jan 30, 2014 at 4:31 PM, Jon Harrop <jon@ffconsultancy.com> wrote:
Yotam wrote:
> I don't think so. Without metadata, how do you know where one tuple member
ends and another begins?

Use static type information. When the type is known to be 'a * 'b you use
the unboxed representation. Otherwise you default to the boxed
representation.

OCaml already does this to some extent because functions that accept a tuple
are compiled to multi-argument functions (IIRC). So this would just be an
extension to handle the return value too. The same idea could be used with
many other types, e.g. unboxed optional arguments.

Cheers,
Jon.