-
Notifications
You must be signed in to change notification settings - Fork 594
Add feature "noindirect" that disables indirect method calls #17186
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
Conversation
lib/feature.pm
Outdated
"5.23" => [qw(current_sub evalbytes fc postderef_qq say state switch unicode_eval unicode_strings)], | ||
"5.27" => [qw(bitwise current_sub evalbytes fc postderef_qq say state switch unicode_eval unicode_strings)], | ||
"all" => [qw(bitwise current_sub declared_refs evalbytes fc postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)], | ||
"all" => [qw(bitwise current_sub declared_refs evalbytes fc noindirect postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought while reading this is the double negation, which becomes even worst when using no noindirect
.
Maybe we are just talking about use feature 'direct'
instead of use feature noindirect
:-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that it's supposed to stop you from using indirect method calls, it's not a feature you need in order to use direct ones, so calling the feature simply 'direct' seems wrong to me on that basis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no feature 'indirect'
feels more logical to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Leont that would imply the conceptual model that some "feature"s are on by default that you start by disabling. That changes the current idea that there are no "feature"s enabled to begin with but you can turn some of them on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leonerd there's the default
bundle just below here. it used to include array_base
(which some of the versioned bundles didn't include) until we removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, what @ilmari said. While I do think it's a valid discussion if this is a good idea, we have done this before.
@tonycoz can you force re-push your branch so we can test travis? |
Oops, think I broke it |
6ece5e8
to
b114690
Compare
I too was thinking about quite a few "no"-style pragmata to add:
It starts to suggest a general idea that actually we want an
|
This is mostly a PoC, the intent of putting it in feature is so it's trivially addable to a feature bundle, so it could be enabled with use 5.xx (though we seem to be out of bits for that, which is an issue for more than this.) |
This heavily penalizes sub calls for everyone not opting in and using 'my $obj = new Foo' form, which is half CPAN (grep.cpan.me shows 1 to 25 of more than 1000 distributions). Should we have a more efficient way for feature detection, instead of memcpy + a hash lookup? |
On Sun, 20 Oct 2019 at 20:48, Sergey Aleynikov ***@***.***> wrote:
This heavily penalizes sub calls for everyone not opting in and using 'my
$obj = new Foo' form, which is half CPAN (grep.cpan.me shows 1 to 25 of
more than 1000 distributions). Should we have a more efficient way for
feature detection, instead of memcpy + a hash lookup?
Wow, I'm surprised, I didn't think feature checks are this expensive.
FWIW, the lookup isnt into a true hash, but something with hash like
semantics. But we *are* hashing the feature strings every time we check if
a feature is enabled. AFAICT that is unnecessary, we could precompute them
all at start up and store their hash values.
cheers,
Yves
…--
perl -Mre=debug -e "/just|another|perl|hacker/"
|
I am very surprised as well. I had a priori imagined that feature flags were a bitmask of similar style to the warnings and hints bits, such that a runtime check is just bitwise & test. Knowing they are this expensive suddenly makes me more hesitant to add others. :/ Is it something we could look at? |
On Mon, 21 Oct 2019 at 11:37, Paul Evans ***@***.***> wrote:
I am very surprised as well. I had a priori imagined that feature flags
were a bitmask of similar style to the warnings and hints bits, such that a
runtime check is just bitwise & test. Knowing they are this expensive
suddenly makes me more hesitant to add others. :/
Is it something we could look at?
Personally I think we could.
Yves
…--
perl -Mre=debug -e "/just|another|perl|hacker/"
|
I'll take a look once I get back and recover from the flights. |
Does this affect fake indirect syntax like print and exec? |
Not for print at least, the test code (briefly) checks that it still works. I'll add a check for exec (it doesn't need to run, just compile) once I get back to this after re-working feature checks. |
may want to add those checks for |
b114690
to
bcc65d4
Compare
The main hold on this form me right now is discussion on where we're going and how we're getting there (similarly for #17212), I think this is part of where we're going, but (reasonably) the p5h discussions were pretty high level. |
bcc65d4
to
212c84f
Compare
212c84f
to
24250a8
Compare
Is the current negative here acceptable? Ideas for alternatives? There was a thumbs down for the Whether this is managed in perl code using feature.pm or not, I do believe it should still use the feature mechanism (which is now much faster.) |
I think it makes more sense to have it as an I've pushed this to the branch |
I more like 'use feature "noindirect"' for consistency (it should be, at least somewhere). |
Consistency with what? We have no other features with "no" in the name (e.g. we didn't have |
One question is whether we should leave it like it is currently, with
or if it would be better to give an error explicitly saying that the indirect method calls are disabled. |
This is superseded by #17477, closing. |
A first go at optionally disabling indirect notation in core