Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Change MemoWise public API #247

Closed
wants to merge 30 commits into from

Conversation

paracycle
Copy link

Re-attempt at #213 with @jemmaissroff, still a WIP...

Before merging:

  • Copy the table printed at the end of the latest benchmark results into the README.md and update this PR
  • If this change merits an update to CHANGELOG.md, add an entry following Keep a Changelog guidelines with semantic versioning

@PikachuEXE
Copy link
Contributor

Should I wait for this to be finished before migrating to this gem?

@paracycle
Copy link
Author

Should I wait for this to be finished before migrating to this gem?

I am not a maintainer of the gem, so I am not sure if this will ever get merged and released. But, my aim is to keep the public API surface change to only the change from prepend MemoWise to extend MemoWise. So, if you adopt now, it shouldn't be hard to upgrade later.

@ms-ati
Copy link
Contributor

ms-ati commented Dec 10, 2021

Hi @PikachuEXE, my understanding is that this is intended to be a proposal to be discussed -- which is awesome! -- but at this time, there's no current understanding nor expectation that this proposed API change will be accepted, is there?

UPDATE @paracycle I see your response first, and 👍🏻 to how you expressed it!

@PikachuEXE
Copy link
Contributor

OK I get this is a proposal now

I would ask

  1. Is there anything would be taken away (including the potential benefits) by moving away from prepend?
  2. How this gem's compatibility with other gems (which also use meta programming, e.g. contracts.ruby) would be comparing prepend and extend?
  3. Is there any other not so obvious potential issues that we can think of?
  4. What are the original intents by picking prepend over extend/include?

@paracycle
Copy link
Author

@PikachuEXE all of those points will be addressed in the PR description in detail once the build gets green on this branch.

@PikachuEXE
Copy link
Contributor

This branch has conflicts that must be resolved

@paracycle
Copy link
Author

This branch has conflicts that must be resolved

Yes! That's why the PR is marked [WIP] and is set as Draft.

JacobEvelyn and others added 23 commits December 13, 2021 12:55
Previous versions of `MemoWise` used an array as the
internal cache data structure, where each memoized method
uses a unique array index. However, complex inheritance
structures make it easy to have multiple methods accidentally
share the same array index on the same object, resulting
in nondeterministic and incorrect behavior.

While we may explore that optimization again in the future,
for the time being we are switching to a hash data structure
keyed on method name, which is safer because two methods
cannot share the same name in Ruby.
This should allow to do chaining like:
```ruby
private memo_wise def foo
  42
end
```
@codecov
Copy link

codecov bot commented Dec 14, 2021

Codecov Report

Merging #247 (ea14b66) into main (5581c30) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #247   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          206       151   -55     
=========================================
- Hits           206       151   -55     
Impacted Files Coverage Δ
lib/memo_wise.rb 100.00% <100.00%> (ø)
lib/memo_wise/internal_api.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5581c30...ea14b66. Read the comment docs.

@jemmaissroff
Copy link
Contributor

Closed and replaced by #253

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.

5 participants