Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Oct 20, 2019

A first go at optionally disabling indirect notation in core

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)],
Copy link
Member

@atoomic atoomic Oct 20, 2019

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 :-)

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.

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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.

@toddr
Copy link
Member

toddr commented Oct 20, 2019

@tonycoz can you force re-push your branch so we can test travis?

@tonycoz tonycoz closed this Oct 20, 2019
@tonycoz tonycoz deleted the feature-no-indirect branch October 20, 2019 12:44
@tonycoz tonycoz restored the feature-no-indirect branch October 20, 2019 12:44
@tonycoz
Copy link
Contributor Author

tonycoz commented Oct 20, 2019

Oops, think I broke it

@toddr toddr reopened this Oct 20, 2019
@tonycoz tonycoz force-pushed the feature-no-indirect branch from 6ece5e8 to b114690 Compare October 20, 2019 13:00
@leonerd
Copy link
Contributor

leonerd commented Oct 20, 2019

I too was thinking about quite a few "no"-style pragmata to add:

no indirect;
no parser::prototypes;  # bans first { ... } @items, requires  first(sub { ... }, @items)
no constsub::invocants  # bans PF_UNIX->foo; requires  PF_UNIX()->foo

It starts to suggest a general idea that actually we want an antifeature to mirror `feature:

no antifeature qw( direct parser_protos constsub_invocants ... );

@tonycoz
Copy link
Contributor Author

tonycoz commented Oct 20, 2019

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.)

@toddr toddr added this to the 5.32.0 milestone Oct 20, 2019
@dur-randir
Copy link
Member

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?

@demerphq
Copy link
Collaborator

demerphq commented Oct 20, 2019 via email

@leonerd
Copy link
Contributor

leonerd commented Oct 21, 2019

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?

@demerphq
Copy link
Collaborator

demerphq commented Oct 21, 2019 via email

@tonycoz
Copy link
Contributor Author

tonycoz commented Oct 21, 2019

I'll take a look once I get back and recover from the flights.

@tonycoz tonycoz added the do not merge Don't merge this PR, at least for now label Oct 24, 2019
@Grinnz
Copy link
Contributor

Grinnz commented Oct 24, 2019

Does this affect fake indirect syntax like print and exec?

@tonycoz
Copy link
Contributor Author

tonycoz commented Oct 24, 2019

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.

@pink-mist
Copy link

may want to add those checks for say and system too then - not sure how many more examples there are

@tonycoz tonycoz force-pushed the feature-no-indirect branch from b114690 to bcc65d4 Compare October 30, 2019 23:51
@tonycoz
Copy link
Contributor Author

tonycoz commented Nov 12, 2019

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.

@tonycoz tonycoz force-pushed the feature-no-indirect branch from bcc65d4 to 212c84f Compare December 16, 2019 23:28
@tonycoz tonycoz force-pushed the feature-no-indirect branch from 212c84f to 24250a8 Compare January 6, 2020 04:37
@tonycoz tonycoz removed the do not merge Don't merge this PR, at least for now label Jan 9, 2020
@tonycoz
Copy link
Contributor Author

tonycoz commented Jan 9, 2020

Is the current negative here acceptable? Ideas for alternatives?

There was a thumbs down for the antifeature idea without discussion.

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.)

@ilmari
Copy link
Member

ilmari commented Jan 9, 2020

I think it makes more sense to have it as an indirect feature that's enabled by default, and can be turned off by no feature 'indirect'; and possibly removed from a future version bundle, like we did with array_base.

I've pushed this to the branch ilmari/feature-indirect (1be847c).

@dur-randir
Copy link
Member

I more like 'use feature "noindirect"' for consistency (it should be, at least somewhere).

@ilmari
Copy link
Member

ilmari commented Jan 9, 2020

Consistency with what? We have no other features with "no" in the name (e.g. we didn't have no_array_base when we removed support for setting $[). The CPAN pragma this is modelled on is no indirect, not use noindirect.

@ilmari
Copy link
Member

ilmari commented Jan 9, 2020

One question is whether we should leave it like it is currently, with intuit_method just returning false for indirect method calls, which leads to unintuitive errors like

Bareword found where operator expected at - line 19, near "new Foo"
       (Do you need to predeclare new?)
syntax error at - line 19, near "new Foo"

or if it would be better to give an error explicitly saying that the indirect method calls are disabled.

@ilmari
Copy link
Member

ilmari commented Feb 13, 2020

This is superseded by #17477, closing.

@ilmari ilmari closed this Feb 13, 2020
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.

10 participants