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

Fall back to normal constructor if hash style arguments are provided #1348

Merged
merged 1 commit into from
Jun 5, 2019

Conversation

marcusramberg
Copy link
Member

Summary

Fall back to old behavior if more than one argument or hashref is given as argument

Motivation

Maintain old behavior

References

As discussed on IRC.

@marcusramberg
Copy link
Member Author

As discussed on IRC we should probably either add a deprecation notice to this or change clone and the test back to use the constructor arguments instead of the setter. I prefer the latter.

@kraih
Copy link
Member

kraih commented May 2, 2019

What are the use cases for this feature? (Can't check right now, but i'm fairly sure we have no constructors yet that extend the Mojo::Base argument variations, so use cases need to be strong)

@marcusramberg
Copy link
Member Author

@kraih We do have a lot of constructors with special behavior for single argument. Like

lib/Mojo/URL.pm:55:1:sub new { @_ > 1 ? shift->SUPER::new->parse(@_) : shift->SUPER::new }

@marcusramberg
Copy link
Member Author

My main concern is maintaining backwards compat, so I'm fine with adding this with a deprecation notice as well to avoid breakage until upstreams have had time to adjust.

@kraih
Copy link
Member

kraih commented May 2, 2019

@marcusramberg That's not the same at all. There is no attribute handling in Mojo::URL::new, which is very special.

@Grinnz
Copy link
Contributor

Grinnz commented May 12, 2019

What's the status of this? Downstream modules are still broken in the meantime :(

@jhthorsen
Copy link
Member

I'm 👍 on merging this, but maybe we should probably also add a deprecation warning at the same time if the if kicks in.

@Grinnz
Copy link
Contributor

Grinnz commented Jun 5, 2019

@marcusramberg Could you add a deprecation notice to the PR?

@marcusramberg marcusramberg force-pushed the promise_constructor_fallback branch 2 times, most recently from 237c593 to 03c7422 Compare June 5, 2019 17:42
@marcusramberg
Copy link
Member Author

@Grinnz done. @mojolicious/core can we have a couple of more votes?

lib/Mojo/Promise.pm Show resolved Hide resolved
lib/Mojo/Promise.pm Outdated Show resolved Hide resolved
@marcusramberg marcusramberg merged commit cba31e3 into master Jun 5, 2019
@marcusramberg marcusramberg deleted the promise_constructor_fallback branch June 5, 2019 20:30
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.

None yet

4 participants