[Nickle] Hash keys not copied?

Keith Packard keithp at keithp.com
Mon Dec 31 13:57:51 PST 2007


On Mon, 2007-12-31 at 10:19 -0800, Bart Massey wrote:

> If you restrict keys to being immutable values you avoid the
> problem; there's a strong argument that keys should be
> values, not data structures.

Immutable keys are never a problem -- 'copying' is free too.

> If you want the semantics that mutable data structures are
> allowed and you always look up based on the current
> contents, then you can play complicated games with the mark
> bit on boxes to get what you want. 

I don't think I want this -- I think I want the 'key' to be the value of
the data structure when the key is used.

> I vote for immutable.  My second choice would be key-copying
> and my third would be probabilistic, but it's close.  I
> think current-value is confusing and ugly.

I'll just copy keys when mutable then. Current value is crazy.

The use case here was in adding memoization to a game solver; I just use
the current state of the game as the hash key. My perfect tic-tac-toe
player is now about 10 times faster.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : /pipermail/nickle/attachments/20071231/6536b5cd/attachment.pgp 


More information about the Nickle mailing list