I have been debugging some code using OSCdef and discovered what seems to be a bug in IdentityDict.
The context: I have a class for which I am creating some OSCdefs for each instance. I have some func called makeOSCDef which which generates the OSCdefs required by concatenating 2 symbols.
However, while these register in the OSCDef IdentityDict fine and work as expected, calling the function again results in duplicate keys in the OSCDef IdentityDict, meaning the function will be get duplicate calls. Moreover, searching for that key will return nil, even though it is listed in the IdentityDict.
Exploring this further:
//Creates duplicates
a= IdentityDictionary.new
~foo = \foo
a.put(~foo++\bar, 5)
//no duplicates
~foo = \foo++"bar".asSymbol
a.put(~foo, 5)
//duplicates
~func = {|symbol|
var sym = symbol ++ \bar;
a.put(sym, 1);
}
~func.(\foo).value
// no duplicates
~func = {|symbol|
// var sym = (symbol ++ \bar).asSymbol;
a.put((symbol ++ \bar).asSymbol, 1);
}
~func.(\foo).value
// yet...
(\foo++\bar) == (\foo++\bar) // evaluates to true
Frustrating! Any thoughts?