space efficiency question
I'm not a compiler/interpreter implementer, just a Haskell user :-) My question is: if I have two datatypes, say newtype Attributes = Att [String] data Instance = Instance Attributes [Int] where an Attributes value describes the discrete attributes that are stored (as Int) in an Instance. Now: if I have a couple of thousand of these Instances, created with the same Attributes value, as in: a = Attributes ["a","bc"] i0000 = Instance a [1,2] i0001 = Instance a [1,1] ... i7896 = Instance a [2,1] can I be assured that there are not thousands of actual copies of a but that they simply have a pointer to a ? I'm interested in the answer for both ghc (compiled/interpreted) as interpreted Hugs. I would hope, so, right ? Is there an actual guarantee or is that an optimization that the implementation might or might not implement ? Cheers Frank Dellaert
participants (1)
-
Frank Dellaert