Skip to content

Alternate cfg pattern#63

Open
alephzero wants to merge 2 commits into
masterfrom
lshamis/cfg2
Open

Alternate cfg pattern#63
alephzero wants to merge 2 commits into
masterfrom
lshamis/cfg2

Conversation

@alephzero

Copy link
Copy Markdown
Owner

Alternate cfg implementation with much less magic.

Previously, cfg was an object wrapper that would masquerade as the requested type in almost every way. The two major exceptions was 1) type(obj) would not match the underlying type, and 2) C-bindings were not fooled.
The masquerading objects were hooked and updates when the user calls a0.update_configs()

New cfg2 has the same signature, but returns a non-masquerading object that has an explicit get() method. get() returns a true object of the requested type, not one that updates under the hood.
get() always returns the most recent version. No need for an update call.

Example usage here:

bar = a0.cfg2("topic", "/bar", int)
assert bar.get() == 3

Ideal transition plan:

  • This new pattern is called cfg2
  • Once this lands, we can update users from cfg to cfg2
  • When no users of the old cfg exists, alias cfg==cfg2
  • Update users from cfg2 to cfg
  • Remove cfg2
    We'll see how well that turns out.

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.

2 participants