Re: Boxing wrt. unary constructors

From: Xavier Leroy (Xavier.Leroy@inria.fr)
Date: Thu Oct 15 1998 - 19:25:27 MET DST


Date: Thu, 15 Oct 1998 19:25:27 +0200
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Don Syme <dsyme@microsoft.com>, caml-list@inria.fr
Subject: Re: Boxing wrt. unary constructors
In-Reply-To: <39ADCF833E74D111A2D700805F1951EF0B2EF53D@RED-MSG-06>; from Don Syme on Wed, Oct 14, 1998 at 02:43:31AM -0700

> This is probably a FAQ, but if I have a type
> type abc = ABC of int
> then does Ocaml 2.00 use a boxed or unboxed repr. of values of this
> type?

Boxed. While it would not be hard to make a special case for
one-constructor datatypes, this is not currently done in the OCaml
compiler. However, you can use type abstraction to obtain much of the
same effects while keeping an unboxed representation:

        (struct type abc = int let abc x = x let proj_abs x = x end :
         sig type abc val abc: int->abc val proj_abc: abc->int end)

Regards,

- Xavier Leroy



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:16 MET