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

Backports v4 #139

Open
marcandre opened this issue Feb 6, 2020 · 3 comments
Open

Backports v4 #139

marcandre opened this issue Feb 6, 2020 · 3 comments

Comments

@marcandre
Copy link
Owner

marcandre commented Feb 6, 2020

Backports v4 roadmap:

  • Drop backports for Ruby < 2.1
  • Make require 'backports' a noop (or an error?)
  • Remove stdlib support
  • Remove rails

ETA: Xmas '20

@marcandre
Copy link
Owner Author

  • Use prepend or keep using alias_method_chain?

This was referenced Feb 6, 2020
@marcandre
Copy link
Owner Author

I wouldn't mind having a nicer API too. E.g.:

Backports.update :to_h, :transform_values, up_to: 2.7

That would still be susceptible to forward incompatiblities if the up_to argument is optional.

/cc @zverok

@zverok
Copy link
Contributor

zverok commented Feb 28, 2020

Thinking about it a bit, I'd say this:

  1. There is a completely different level of "threat" for methods that are new (like Enumerable#tally) and methods whose behavior is redefined (Enumerable#to_h)
  2. I believe that drawbacks of the methods of the first kind in most cases could be neglected (e.g. delegated to backports user's responsibility), while drawbacks of the seconds are various (performance penalty, possible incompatibilities)
  3. A lot of times, nobody thinks "oh, I want a method(s) from that Ruby version", rather "oh, I used to that method/I read about that method in some tutorial, can I have it please?"

So, I think along this lines:

  1. Somehow define what methods are new, and what are redefinitions
  2. Then, provide this API:
Backports.require! # requires all new methods, no redefinitions
Backports.require!(redefinitions: true) # all new and redefinitions

Backports.require!(redefinitions: true, except: %w[Enumerable#to_h]) # but not that one
Backports.require!(only: %w[Enumerator.produce]) # I am picky today!

Backports.require!(upto: 2.6) # don't take nothing from 2.7

(For some cases, it will also require some reconciliation of "what means what", for example, if somebody asks for Enumerable#to_h, does that mean they want Array#to_h too? Most probably... But does that mean they also might want to opt-out of "just Array#to_h"?)

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

No branches or pull requests

2 participants