ark@research.att.com (Andrew Koenig) wrote:
>
>If you do not references, values are all you have. So, for example
>
> val p = [3, 4, 5];
>
> val q = [3, 4, 5];
>
>Now p = q because p and q have the same value, and there is no way to
>determine whether p and q are the same list because even the question
>is meaningless in ML. (The implementation might store p and q as
>pointers to the same memory, or it might not. There is no way to
>tell.)
Why do you need to know where things are stored in memory? It is
irrelevant if the things are immutable. Worrying about the fine
details of implementation is the disease of the C programmer. ML is a
higher level language, so the sordid practicalities of whether
comparing two lists will traverse the whole structure or not is left
entirely to the compiler.
In the tree example that you started with, what is wrong with just
passing round the whole subtree so that it can be compared with as
necessary? Any reasonable implementation will only be passing round a
pointer so you lose nothing.
Tony.
--
o
o o o [[Question: What is special about 1681?]]
o o o o
|