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.
I already have a working code for this but I am uncertain how this
will perform when CHILD-SIZE is really large.
/Nordlöw
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-----
> 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.
There is not automatic copy ever done in lisp. You have to
explicitely copy the structures (such as cons, copy-list,
copy-hash-table, copy-my-struct, etc) you use if you want copies (or
use a function that explicitely copies the input data like append does
for all lists but the last). And for some types, there are even no
predefined copier function!
--
__Pascal Bourguignon__