space efficiency question

Frank Dellaert frank@cc.gatech.edu
Tue, 18 Dec 2001 12:48:18 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_000C_01C187C2.4477ED80
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

MessageThanks !

Now, a small follow-up question: if I subsequently test 2 Instances =
whether they were instantiated with the same Attributes value, as in

test (Instance a1 _) (Instance a2 _) =3D (a1=3D=3Da2)

will this be implemented efficiently ? I.e. will it check first whether =
the pointers happen to be the same, and only then do a full Eq =
comparison ?

Cheers
Frank
  ----- Original Message -----=20
  From: Simon Peyton-Jones=20
  To: Frank Dellaert ; Haskell@haskell.org=20
  Sent: Monday, December 17, 2001 10:24 AM
  Subject: RE: space efficiency question


  Now: if I have a couple of thousand of these Instances, created with =
the same Attributes value, as in:
    =20
    a =3D Attributes ["a","bc"]
    i0000 =3D Instance a [1,2]
    i0001 =3D Instance a [1,1]
    ...
    i7896 =3D Instance a [2,1]
    =20
    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.=20
  Yes for GHC: you'll only get one copy of 'a'.
  =20
  Simon
  =20

------=_NextPart_000_000C_01C187C2.4477ED80
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><TITLE>Message</TITLE>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks !</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now, a small follow-up question: if I =
subsequently=20
test 2 Instances whether they were instantiated with the same Attributes =
value,=20
as in</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>test (Instance a1 _) (Instance a2 _) =
=3D=20
(a1=3D=3Da2)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>will this be implemented efficiently ? =
I.e. will it=20
check first whether the pointers happen to be the same, and only then do =
a full=20
Eq comparison ?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Cheers</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Frank</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A href=3D"mailto:simonpj@microsoft.com" =
title=3Dsimonpj@microsoft.com>Simon=20
  Peyton-Jones</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:frank@cc.gatech.edu"=20
  title=3Dfrank@cc.gatech.edu>Frank Dellaert</A> ; <A=20
  href=3D"mailto:Haskell@haskell.org"=20
  title=3DHaskell@haskell.org>Haskell@haskell.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, December 17, 2001 =
10:24=20
  AM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> RE: space efficiency=20
  question</DIV>
  <DIV><BR></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>
  <BLOCKQUOTE dir=3Dltr=20
  style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; =
MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</DIV>
    <DIV><FONT face=3DArial><FONT size=3D2>can I be assured that there =
are not=20
    thousands of actual copies of a but that they simply have a pointer =
to a ?=20
    I'm interested in the answer for both ghc (compiled/interpreted) as=20
    interpreted Hugs.<SPAN class=3D268132109-17122001><FONT=20
    =
color=3D#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></DIV></BLOCKQUOTE>
  <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
  class=3D268132109-17122001><FONT color=3D#0000ff>Yes for GHC: you'll =
only get one=20
  copy of 'a'.</FONT></SPAN></FONT></FONT></DIV>
  <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
  class=3D268132109-17122001></SPAN></FONT></FONT>&nbsp;</DIV>
  <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
  class=3D268132109-17122001><FONT=20
  color=3D#0000ff>Simon</FONT></SPAN></FONT></FONT></DIV>
  <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
  =
class=3D268132109-17122001>&nbsp;</SPAN></FONT></FONT></DIV></BLOCKQUOTE>=
</BODY></HTML>

------=_NextPart_000_000C_01C187C2.4477ED80--