Pointers in Haskell??
Jeff Dalton
jeff@aiai.ed.ac.uk
Fri, 7 Dec 2001 18:11:57 GMT
> All Haskell compilers use pointers internally. The
> idea is that because Haskell is referentially
> transparent and side effect free, you can overwrite
> a function application with its result. For example,
>
> let
> x = [1..1000]
> in
> foo (A x) (B x)
>
> Will internally have "x" pointing to the function
> application [1..1000], when this function application
> is evaluated it will overwrite the memory cell "x"
> points to with the result. So eventually it will
> look like this:
>
> +---+---+ +---+---+
> | A | x | | B | x |
> +---+---+ +---+---+
> | |
> +---+-------+
> |
> V
> +---+---+------+
> | : | 1 | tail |---> The list 2..1000
> +---+---+------+
>
> Where each block is a memory cell and each arrow is a
> pointer.
What does it mean to have a letter ("A", "x", or a number or "tail",
etc) inside a box?
> A book that describes this a lot better is:
>
> Simon Peyton-Jones. The implementation of functional
> programming languages. Prentice-Hall, 1987
Are they always implemented that way these days?
-- J