Hi,
On 06.06.2007, at 07:00, Phlex wrote:
So here is one more question :
Let's say I want unique System names across the Universe ... that
would mean i need to have a Data.Map in the Universe, with Name
keys and System values. Since all data are values instead of
references, would i end up with two copies of each System (in
Universe's Data.Map and in its Galaxy), or would these be shared
somehow ? In other words, should i go for integer (or maybe access
key/tuple) identified objects or just put the System in both
Data.Maps it belongs to ?
That depends. In an OO world everything has its own implicit
identity. The new operator in Java provides you with an object with a
new and unique key which is not easy to observe. But most formal
semantics have it. One can think of it as the address of the
allocated object.
In FP there are no objects, there are only terms. Whether two terms
are identically is answered by a structural traversal over the values
and subvalues.
Now, I return to your question. What makes your "objects" galaxies,
planets, stars, etc. unique? Is it their coordinate in space, their
name, their structural position in your tree? What is it? Let's
assume you say their names are unique. Then you only have to store a
set of all names used in your universe.
If you want a planet which orbits around star "a" to be different
form another planet that is in orbit of star "b", although both
planets are the same in every other aspect. Then you might think
about introducing arbitrary unique integer keys.
This is similar to database design. There are those normal form laws
[1] which guide you to improve your db schema. In database design
there are people who introduce artificial primary keys almost always.
Although there are natural primary keys most of the time.
I hope these random thoughts help a bit to change the perspective.
Regards,
Jean-Marie
[1] http://en.wikipedia.org/wiki/Database_normalization
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe