Let's create a hash table where the keys are tables. arc> (= tab (table))
#hash()
arc> (= key (table))
#hash()
arc> (= (tab key) 3)
3
arc> tab
#hash((#hash() . 3))
arc> (tab key)
3
Quick: is the key a table value or reference? arc> (tab (table))
3
Ok, so it's by value. But wait: arc> (= (key 5) 6)
6
arc> tab
#hash((#hash((5 . 6)) . 3))
arc> (keys tab)
(#hash((5 . 6)))
So it's a reference, right? arc> (tab key)
nil
Weird. So is it accessible by value? arc> (tab (obj 5 6))
nil
arc> (tab (table))
nil
Finally: arc> (= (key 5) nil)
nil
arc> (tab key)
3
arc> (tab (table))
3
Curiouser and curiouser.How the #$%# heck does the table remember what the state of its key was at the
time of binding? Bug found while playing with palsecam's transparent persistence idea
(http://arclanguage.org/item?id=10696). Update: confirmed with original arc3/v372 and arc3.1/v4.2.2 under Snow Leopard, and with arc3.1/v4.1.3 under Ubuntu Jaunty. |