From paul@inet.co.za  Wed May 17 10:57:16 2000
Received: from exchange_rbk02.inet.co.za (exchange-rbk02.inet.co.za [196.38.91.22])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id KAA29043
	for <prolog@swi.psy.uva.nl>; Wed, 17 May 2000 10:57:09 +0200 (MET DST)
Received: from pdev.inet.co.za ([196.14.60.35]) by exchange_rbk02.inet.co.za with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21)
	id K81Z3VSS; Wed, 17 May 2000 10:58:39 +0200
Date: Wed, 17 May 2000 12:47:18 +0200 (GMT+0200)
From: Paul Sephton <paul@inet.co.za>
To: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
cc: ok@atlas.otago.ac.nz, ino-waiting@gmx.net, prolog@swi.psy.uva.nl
Subject: Re: String Representation
In-Reply-To: <200005170256.OAA27684@atlas.otago.ac.nz>
Message-ID: <Pine.LNX.3.91.1000517123108.20641B-100000@pdev.inet.co.za>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

On Wed, 17 May 2000, Richard A. O'Keefe wrote:

> I wrote:
> > Using a *single* atom to hold a string has the advantage that if there
> > are several occurrences of exactly the same string, they will share the
> > representation, so you can get less than 1 byte per character.
> 	
> Paul Sephton <paul@inet.co.za> wrote:
> 	Unless, of course, you are talking about single character atoms...
> 	
> Not even then.  Suppose for argument's sake that the space cost of
> an entry in the atom table is 16 + 4*ceiling(length/4) bytes, so that
> a single character atom costs 20 bytes.
> 
> If there are more than 20 references to that atom, the average cost
> of the representation is less than 1 byte per character.
> 
> With that space cost, a four-character string would only need 5 references
> to go below one byte per character.

Assuming that an atom is represented internally as a reference to a hash 
table entry, then a list of atoms would be represented internally as a 
variable size array of these references?  My point is, that the smallest 
size allocated per atom would be the size of the reference, which would 
be proscribed by the table size.  For a reference size of a byte, the 
hash table size would be 256.  For a two byte word, 65536.  For four 
bytes 0xffffffff (four billion or so) etc.   

Now, if I have a list of single character atoms, and assuming four byte 
hash keys, I am talking about four bytes per character in my list, 
regardless of the overheads for hash table management.

So, the size to represent an atom would be the size of the reference (for 
however many times the atom is referenced) + the hash table storage 
overhead.  This regardless of the actual size of the atom.

Regards
Paul
_____________________________________________________________________________
Paul Sephton (paul@inet.co.za)                               INET Development
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ever wondered if jumping out of the frying pan might actually be refreshing?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

