space efficiency question
Frank Dellaert
frank@cc.gatech.edu
Mon, 17 Dec 2001 00:40:21 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_001F_01C18693.68D2E250
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I'm not a compiler/interpreter implementer, just a Haskell user :-)
My question is: if I have two datatypes, say
newtype Attributes =3D Att [String]
data Instance =3D 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 =3D Attributes ["a","bc"]
i0000 =3D Instance a [1,2]
i0001 =3D Instance a [1,1]
...
i7896 =3D 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
------=_NextPart_000_001F_01C18693.68D2E250
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I'm not a compiler/interpreter =
implementer, just a=20
Haskell user :-)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>My question is: if I have two =
datatypes,=20
say</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>newtype Attributes =3D Att =
[String]</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>data Instance =3D Instance Attributes=20
[Int]</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>where an Attributes value describes the =
discrete=20
attributes that are stored (as Int) in an Instance.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Now: if I have a couple of thousand of =
these=20
Instances, created with the same Attributes value, as in:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>a =3D Attributes =
["a","bc"]</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i0000 =3D Instance a [1,2]</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i0001 =3D Instance a [1,1]</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i7896 =3D Instance a [2,1]</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>can I be assured that there are not =
thousands of=20
actual copies of a but that they simply have a pointer to a ? I'm =
interested in=20
the answer for both ghc (compiled/interpreted) as interpreted =
Hugs.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I would hope, so, right ? Is there an =
actual=20
guarantee or is that an optimization that the implementation might or =
might not=20
implement ?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Cheers<BR>Frank =
Dellaert</FONT></DIV></BODY></HTML>
------=_NextPart_000_001F_01C18693.68D2E250--