Vassil Nikolov <vnikolov@poboxes.com> wrote:
+---------------
| rpw3@rigden.engr.sgi.com (Rob Warnock) wrote:
| > +---------------
| > | ...idiom for a half-cons (i.e. a singleton reference)?
| > +---------------
| >
| > Several Scheme implementations have such a notion for a half-cons,
| > conventially called a "box":
...
| Are boxes as efficient as cons cells in terms of speed of access and
| memory use? (By the latter I mean, does a box take up half the space
| for a cons?)
+---------------
It all depends on the implementation, I'd guess. In MzScheme a box is an
instance of "Scheme_Small_Object", which is a type field [a short, but
most compilers will force that to a PSV] and a pointer-sized value (PSV).
A cons is an instance of "Scheme_Object", which is a type field and
two PSVs. So for MzScheme, a box is 2/3 (or maybe 3/5) the size of a cons.
In an implementation I've been working on [play project], the same is true:
a box is 2/3 the size of a cons.
Chez Scheme (see http://www.cs.indiana.edu/eip/workshop1/lab7/lab73.html)
also has boxes, but I don't know if they're 1/2, 2/3, or 1 times a cons...
-Rob
-----
Rob Warnock, 8L-855 rpw3@sgi.com
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
2011 N. Shoreline Blvd. FAX: 650-964-0811
Mountain View, CA 94043 PP-ASEL-IA