Browse thread
Efficency of varient types
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-11-28 (07:49) |
From: | Jacques Garrigue <garrigue@m...> |
Subject: | Re: [Caml-list] Efficency of varient types |
From: David Baelde <david.baelde@gmail.com> > First, I'd like to point that you're talking about sum types and not > variants. For short, variants are the backquoted labels `Int of int, > and I think they cost more at runtime, for they cannot be encoded as > integers. Unfortunately there is no such clear distinction: sum types are also often called variant types (inside the compiler too), and polymorphic variants can be abbreviated as "variants". Some people even call the latter "open sum types", to make things even muddier. More importantly, polymorphic variants are internally encoded as integers, so there is no representation cost for constant tags. Polymorphic variants with value arguments take extra space, as they put the variant tag in an extra field, and cannot be optimized for the multi-argument case, but we are then talking of cases where allocation is required anyway. Jacques Garrigue