[Haskell-cafe] What is a Boxed Array?

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Fri Dec 9 17:16:48 EST 2005

Tomasz Zielonka: 

> there are other reasons to box values besides implementing laziness,
> like for simplifying the memory model (which can simplify GC
> implementation), allowing to intermix values of different types
> (different kinds of polymorphism) or allow variable sized values (think
> strings, arrays and arbitrary size integers).

> Some concrete examples: Arrays in many scripting languages, like Python,
> are often boxed. There are some languages, like R, where there are many
> types of unboxed arrays, for efficiency reasons.

There are nice unboxed arrays in Clean as well. The gain of efficiency is


Hmmm.... I thought that arrays in Python have no reason to be boxed. Lists,
yes, since they are untyped, so they are arrays of pointers, but arrays are

I don't know why boxing may simplify the *memory model*. 

The most dramatic effect of implicit boxing is the possibility -
available in Smalltalk - to change the *identity* of an object. You
write (x become y), and all references to the object assigned to x, point
now to something completely different. A terrible weapon. 

Jerzy Karczmarczuk 

More information about the Haskell-Cafe mailing list