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
Boxing wrt. unary constructors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Boxing wrt. unary constructors
> 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)


- Xavier Leroy