[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hash-tables containing references to hash-tables
From: |
tomas |
Subject: |
Re: Hash-tables containing references to hash-tables |
Date: |
Mon, 23 Nov 2009 13:41:00 +0100 |
User-agent: |
Mutt/1.5.15+20070412 (2007-04-11) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, Nov 23, 2009 at 03:12:22AM -0800, Nordlöw wrote:
> Is it possible for a hash-table to contain a *reference* to another
> hash-table, similar to how we can build arbitrary graphs using conses/
> lists and setf?
Yes, it is -- in a way.
> If so how? If not, is there reason for being so or is it just an emacs
> todo?
>
> If we have
> (puthash parent-key (make-hash-table : size CHILD-SIZE) parent-hash)
> then I want
> (gethash parent-key parent-hash)
> to return a *reference* to hash-table contained in parent-hash.
It already does. In Lisp, you _always_ get a reference for anything
beyond simple data types (as integers and friends).
> I already have a working code for this but I am uncertain how this
> will perform when CHILD-SIZE is really large.
Ah, it's performance you are worried about. No -- gethash isn't
returning a copy of the child table, but "the child table itself".
Change it and you'll see...
Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLCoLcBcgs9XrR2kYRAtlJAJ9t4UrnbsYeZTFatyV4qykL5zJ9bwCdGwGq
P2MC1udxN7bCG3zGScDgmJI=
=kXCM
-----END PGP SIGNATURE-----