Skip to content

Conversation

@bdonlan
Copy link
Collaborator

@bdonlan bdonlan commented Mar 13, 2016

Currently, wrapped maps use the passed-in Map as-is. This produces intuitive
results when the Map is mutated, but as soon as you try to modify the
DynamicObject, you get cryptic errors due to attempts to use this Map as an
IPersistentMap or IObj (in the case of metadata operations).

This change introduces a wrapper which proxies non-mutating calls through to
the underlying map directly, but which creates a copy of the map (as a
PersistentHashMap) if mutating operations are performed.

I considered simply having wrap() copy the map directly, but I felt that the
name 'wrap' would be seen to imply that mutations on the underlying map would
be reflected in the wrapped DynamicObject, so I chose this route instead.

Currently, wrapped maps use the passed-in Map as-is. This produces intuitive
results when the Map is mutated, but as soon as you try to modify the
DynamicObject, you get cryptic errors due to attempts to use this Map as an
IPersistentMap or IObj (in the case of metadata operations).

This change introduces a wrapper which proxies non-mutating calls through to
the underlying map directly, but which creates a copy of the map (as a
PersistentHashMap) if mutating operations are performed.

I considered simply having wrap() copy the map directly, but I felt that the
name 'wrap' would be seen to imply that mutations on the underlying map would
be reflected in the wrapped DynamicObject, so I chose this route instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant