[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reference implementation

This page is part of the web mail archives of SRFI 90 from before July 7th, 2015. The new archives for SRFI 90 contain all messages, not just those from before July 7th, 2015.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11-Nov-06, at 11:29 PM, Chongkai Zhu wrote:

Hi,

I think the idea of this srfi is good. But the current reference implementation is poor. Would the author provide an implementation that is a rewrite of srfi-69's reference implementation but do apply all the parameters?

The size parameter is easy to implement (it is already supported by the SRFI 69 implementation). The min-load and max-load parameters are not too difficult to implement, you have to store the min-load and max-load parameters in the <srfi-hash-table> record and resize the hash-table on an insertion when the load exceeds the max-load, and on a deletion when the load is less than the min-load.

It is impossible to write a portable and complete implementation of the weak-keys and weak-values parameters because weak references are not standard. In implementations of Scheme which do not support weak references the garbage collector has to be modified to implement them. The situation is similar to the implementation of the eq? test parameter (i.e. eq?-hash-tables) which requires modifications to the garbage collector for an efficient implementation (by hashing on the object address).

If you are interested in implementing all the features fully (and more) I suggest you look at their implementation in the Gambit system. The garbage collector is in the file lib/mem.c and the hash table procedures are defined in the file lib/_system.scm .

Marc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFFVyd8//V9Zc2T/v4RAhJFAJ98RS7ZdamJluR9X+pO0Kt2FJIS6gCgnq29
Ld1d9aPf+rK9n7ZPQJSg//4=
=VTHe
-----END PGP SIGNATURE-----