Skip to content

Conversation

@ericherman
Copy link
Contributor

Returns the CV pointer to the overloaded method, which will be needed by join to detect concat magic.

Co-authored-by: @book

@ericherman
Copy link
Contributor Author

ericherman commented Dec 11, 2022

@demerphq : @book mentioned that this function would be useful to some of your work independent of #20503 . In this patch, the function is currently stand-alone and without tests; do you have thoughts about how it should be tested in isolation?

There are perhaps opportunities to reduce some duplication, as there are similar uses in Perl_amagic_call, however to make that sort of refactoring readable, I think we'd want to introduce a struct to hold the pointers to the mg, stash, cvp, etc. ... this patch does not attempt that.

@ericherman ericherman force-pushed the ericherman/amagic_find branch 3 times, most recently from aced732 to 319e4f8 Compare December 11, 2022 11:16
@ericherman ericherman changed the title Added function amagic_find(sv, method, flags) Add function amagic_find(sv, method, flags) Dec 11, 2022
@ericherman ericherman force-pushed the ericherman/amagic_find branch 3 times, most recently from 2c89e29 to 27e2960 Compare December 11, 2022 11:29
@demerphq
Copy link
Collaborator

demerphq commented Dec 11, 2022 via email

@leonerd
Copy link
Contributor

leonerd commented Dec 11, 2022

A thought on testing: Would it be possible to adjust the code in amagic_call() to use this function to find the magic first..? That way you wouldn't need to test this function specifically, as it would already be implicitly tested by anything that tests amagic_call(), for which there's already quite a lot of test code.

@ericherman
Copy link
Contributor Author

A thought on testing: Would it be possible to adjust the code in amagic_call() to use this function to find the magic first..?

As I mentioned, there is an opportunity to do a bigger refactoring, however the callers stash a lot of intermediate pointers (mg, stash, cvp, etc), thus it is not a straight-forward refactoring.

We could change amagic_find to receive pointers-to-pointers as parameters, or introduce a parameter struct to hold the pointers, however it is not clear to me that either of these would be a great improvement.

I think it is possible, yes, however I do not have a good vision of what a true improvement of extracting the duplication of amagic_call would look like.

Returns the CV pointer to the overloaded method,
which will be needed by join to detect concat magic.

Co-authored-by: Philippe Bruhat (BooK) <book@cpan.org>
@ericherman ericherman force-pushed the ericherman/amagic_find branch from 27e2960 to 37a1830 Compare December 16, 2022 13:12
@demerphq
Copy link
Collaborator

@ericherman is there any reason this is still marked draft? Id be fine with applying it as is.

@leonerd
Copy link
Contributor

leonerd commented Dec 16, 2022

@ericherman is there any reason this is still marked draft? Id be fine with applying it as is.

+1. It looks fine to me.

@demerphq
Copy link
Collaborator

Once its merged we can add tests after. Probably faster. :-)

@book book marked this pull request as ready for review December 16, 2022 17:13
@ericherman
Copy link
Contributor Author

Only that we didn't have tests in place yet. However, I'm happy to see it tested indirectly, as will happen with RFC0013 and your work @demerphq

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.

4 participants