
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've been reading on this list about boxed/unboxed structures. I'm not quite clear what this terminology means. Is there a good paper that covers this topic in detail, or a book reference? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iEYEARECAAYFAj2a8OEACgkQDtpPjAQxZ6DUSgCeIRgAl3dpOPavJhrmwFxal5O1 Y8IAnRDzmdag9lyljlacKtE4aZMujfiG =h2Zn -----END PGP SIGNATURE-----

We can think of it like this: When we have a value x :: Int, then 'x' is a computation which when evaluated will return either an Int or will be bottom (undefined). When the program runs and x is evaluated, suppose it evalutes to an actual Int (not bottom). Then in the future any time x is evaluated, instead of redoing the entire computation, we only want to get the value out which we previously calculated. What we do to accomplish this is to replace to thunk (computation) which calculates x with a thunk which simply returns the value which was computed before. The problem is that every time you need to get x in the future, you have to follow this pointer to the (trivial) code which returns a value. THis gets expensive if you need these values frequently. Enter unboxed values. An unboxed value is just that low-level value, not wrapped inside a thunk. This means that it is strict in the sense that it cannot be undefined without your program necessarily dying. In GHC, the type of an unboxed integer is Int#. In fact, the Int type is defined in terms of this: data Int = Int Int# You can get more information that you really want from SPJ's paper "Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine" which talks about this issue. -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Wed, 2 Oct 2002, Shawn P. Garbett wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I've been reading on this list about boxed/unboxed structures. I'm not quite clear what this terminology means. Is there a good paper that covers this topic in detail, or a book reference? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux)
iEYEARECAAYFAj2a8OEACgkQDtpPjAQxZ6DUSgCeIRgAl3dpOPavJhrmwFxal5O1 Y8IAnRDzmdag9lyljlacKtE4aZMujfiG =h2Zn -----END PGP SIGNATURE-----
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hal Daume III writes:
data Int = Int Int#
You can get more information that you really want from SPJ's paper "Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine" which talks about this issue.
SPJ's paper "unboxed values as first class citizens" is more specifically about this subject, see http://research.microsoft.com/users/simonpj/Papers/papers.html#compiler . -- Thomas
participants (3)
-
Hal Daume III
-
Shawn P. Garbett
-
Thomas Johnsson