(foo: 2).next((foo: 1, bar: 2))
// -> ( 'foo': 2, 'bar': 2 )
// in contrast
(foo: 2).next(IdentityDictionary [\foo->1, \bar->2])
// (foo: 2)
That happens because Event.next is done as the reverse of composeEvents
, i.e.
e1.next(e2) == e2.composeEvents(e1) // for e1 an Event
composeEvents
is defined in Object as a no-op that returns the e1
, so an e1.next(X)
will give back e1
unchanged “for most X”.
(foo: 1).next(42) //-> (foo: 1)
The only class that redefines composeEvents
is Environment
as this.copy.putAll(arg)
.
My question is basically: why is Environment treated differently from IdentityDictionary and below in terms of composeEvents
, even though those also have a putAll
? There’s probably also a “typing” issue involved because
(foo: 2).next(Environment [\foo->1, \bar->2])
// -> Environment[ (foo -> 2), (bar -> 2) ]
So that’s not Exactly and event you get back there which may also be a little surprising. I thought that Environment (unlike IdentityDictionary) might have know = true
(like Event) but I see that’s not actually the case…
e = (foo: 2)
e.foo // -> 2
e = (foo: 2).next((Environment [\foo->1, \bar->2]))
// -> Environment[ (foo -> 2), (bar -> 2) ]
e.foo // err
So that couldn’t have been the deciding factor where to redefine composeEvents
in the hierarchy…
Also IdentityDictionary has .parent
capability too (it’s defined there), just like Event and Environment. So that seems to be another non-factor.