| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Multiple forms of syntax can be used to obtain a package name from
`caller`, which emits this as its first return value, and assign
that name to a lexical scalar.
The following each achieve the same result, but with varying efficiency:
* `sub callme { my $package = caller(2); ...}`
* `sub callme { my ($package) = caller(2); ...}`
* `sub callme { my $package = (caller(2))[0]; ...}`
In the first example, `pp_caller` determines only the package name
and pushes it to the stack. In the other two examples, the other 10 of
`caller`'s return values are calculated and pushed onto the stack,
before being discarded.
This commit changes non-CPAN-first instances of the latter two forms
in core to the first form.
Note: There is a special exception to the equivalence described above,
when caller is use in list context within the DB package. Such a
usage instance in regen/warnings.pl therefore remains unchanged.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Until recently, overload did not enable or disable any warnings.
Instead, it would rely on the value of $^W, or the -w flag. When
switching to use the builtin::blessed function, the code was changed to
disable 'experimental::builtin' warnings. Since no other warnings are
changed, the current active warning set is combined with this one
disabled category, and baked in for the entire module. The currently
active warning set is determined by $^W, so whatever its value was when
overload was compiled would get baked in, and any runtime changes to $^W
would no longer have any impact.
The particular warning that would most commonly be emitted by overload
is the sub redefinition warning, in case an overload was being
overwritten. Various modules, such as JSON::PP and Cpanel::JSON::XS,
were expecting to be able to overwrite overloads without any warnings.
They would set $^W to false to prevent them. After the "no warnings
'experimental::builtin';" line was added, it became impossible to
disable these warnings at runtime.
Move the disabling of the experimental warnings to a smaller scope. This
means that the rest of the module is restored to its previous state of
having warnings controlled by $^W.
|
|
|
|
|
|
| |
Localizing $@ and $! was added when the code was loading Scalar::Util at
runtime. We're no longer loading any modules in this part of the code,
so we don't need to localize anything.
|
|
|
|
|
| |
The file was partly using 2 space indents, partly using 4 space indents,
and occasionally tabs. Standardize on 4 space indents using spaces.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
This change fixes enough code that it's possible to run make test_prep when perl is compiled with -Dusedefaultstrict.
There are 2 caveats to this:
- Does not address XSLoader/DynaLoader already submitted in another PR.
- Does not address cpan/Pod-Usage or cpan/Text-Tabs which continue to be outstanding upstream.
|
|
|
|
| |
C<L</foo>> renders better in places than L</C<foo>>
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The pumpking has determined that the CPAN breakage caused by changing
smartmatch [perl #132594] is too great for the smartmatch changes to
stay in for 5.28.
This reverts most of the merge in commit
da4e040f42421764ef069371d77c008e6b801f45. All core behaviour and
documentation is reverted. The removal of use of smartmatch from a couple
of tests (that aren't testing smartmatch) remains. Customisation of
a couple of CPAN modules to make them portable across smartmatch types
remains. A small bugfix in scope.c also remains.
|
| |
|
|
|
|
|
|
|
|
| |
607ee4356 changed the hash of permitted ops from having '1' as a value
to having undef as a value. This also changed one of the warning points
from checking for truthiness to existence. However, a second warning
was accidentally left checking for truthiness. This commit fixes that
oversight, and adds a regression test for warnings in this case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Measured with the following crude perl script calling perf. Perl
is in there to get a rough baseline cost of starting perl:
print 'PERL', (`perf stat -r100 perl -e 1 2>&1`)[10];
print 'OLD ', (`perf stat -r100 perl lib/overload.pm 2>&1`)[10];
print 'NEW ', (`perf stat -r100 perl lib/overload2.pm 2>&1`)[10];
Produced the following results on my machine:
PERL 5,800,051 instructions # 1.05 insns per cycle ( +- 0.06% )
OLD 14,818,995 instructions # 1.16 insns per cycle ( +- 0.03% )
NEW 14,696,974 instructions # 1.16 insns per cycle ( +- 0.03% )
While the numbers did fluctuate between runs, the new code was
consistently faster.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
I added this in ca6102577e. It is silly to check ref $sub a few
lines after $sub = \&....
|
|
|
|
|
| |
Also document that this means that ranges and bigint.pm do not mix perfectly.
Bump version numbers.
|
|
|
|
|
| |
These were all uncovered by the new Pod::Checker, not yet in core.
Fixing these will speed up debugging the new Checker.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
amagic_call now does its best to propagate the operator's context into
the overload callback. It's not always possible - for instance,
dereferencing and stringify/boolify/numify always have to return a
value, even if it's not used, due to the way the overload callback works
in those cases - but the majority of cases should now work. In
particular, overloading <> to handle list context properly is now
possible.
For backcompat reasons (amagic_call and friends are technically public
api functions), list context will not be propagated unless specifically
requested via the AMGf_want_list flag. If this is passed, and the
operator is called in list context, amagic_call returns an AV* holding
all of the returned values instead of an SV*. Void context always
results in amagic_call returning &PL_sv_undef.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Unfortunately, there is code all over CPAN that assumes fallback is
stored under the "()" stash entry. And that code also assumes that
the overloadedness flag (the existence of the CV) is in the same spot.
So much for encapsulation.
This commit changes overloading itself to use a different key, "((",
while having it search for "()" first, and then "((" only if "()" is
not found, to preserve compatibility with encapsulation-breaking code.
So the "((" key will only be used by gv.c if there is no fallback
value specified at all.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
According to overload’s documentation, ‘[v]alues specified as strings
are interpreted as method names.’
But it behaves differently if the string contains a double colon:
use overload q\""\=>"bar::baz";
@bar::ISA = foo;
sub foo::baz{a}
warn bless[]
__END__
Undefined subroutine &bar::baz called at - line 4.
But apostrophes work as documented:
use overload q\""\=>"bar'baz";
@bar::ISA = foo;
sub foo::baz{a}
warn bless[]
__END__
a at - line 4.
I can’t see how the treatment of ::, introduced in a60067777, is not a
bug, though the method logic looks intentional:
+ if (not ref $sub and $sub !~ /::/) {
I suspect it was one of those things that was just not thought
through. The pre-a60067777 logic was in gv.c, and treated strings
containing package separators just like any other strings:
switch (SvTYPE(sv)) {
default:
if (!SvROK(sv)) {
if (!SvOK(sv)) break;
gv = gv_fetchmethod(stash, SvPV(sv, na));
if (gv) cv = GvCV(gv);
break;
}
cv = (CV*)SvRV(sv);
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Now that mro_method_changed_in (triggered by the
‘*{$package . "::()"} = \&nil;’ assignment) causes overloadedness to
be checked the next time a overloaded operation occurs, it is not nec-
essary to trigger %OVERLOAD’s magic explicitly.
This also means that PL_amagic_generation is not incremented any more.
Unfortunately, we cannot eliminate it, as there are XS modules that
expect to increment it themselves to mark their caches as stale.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before this commit, only classes that had no overloading defined could
inherit the fallback from other classes. If a subclass wanted to
override a single overload setting, it would have to specify the fall-
back value explicitly, to avoid implying fallback=>undef.
We do this by separating the fallback value from overloadedness
itself, so it is possible to have a class that is overloaded, but with
no fallback value.
Previously, the ‘()’ stash entry was used for two purposes. It had a
sub in it so it could be found using usual method lookup mechanims.
The failure to find any such method would be taken for efficiency’s
sake to mean that there was no overloaded, and the search for methods
could end early. The scalar slot contained the fallback entry itself.
To preserve the effiency, we still use &{"()"} to indicate that there
is overloadedness.
Fallback now uses its own entry, named ‘(fallback’. Since it
has to be special-cased anyway, there is no need to add it to
regen/overload.pl.
|
| |
|
| |
|
|
|
|
| |
This speeds this up by about 13 times.
|
| |
|
| |
|
|
|
|
| |
as well as perldiag.
|
|
|
|
| |
This sentence got mangled somehow, somewhen.
|
|
|
|
| |
Using this instead of Scalar::Util makes things marginally faster.
|
|
|
|
| |
It doesn’t need to be increased twice between releases.
|
|
|
|
| |
It should go faster if we only iterate through %arg once.
|
|
|
|
| |
Existing overload warnings work that way.
|
| |
|
|
|
|
| |
misspelled) operator. For RT #74098.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It’s possible, and too easy, for classes to define a can method to
deal with AUTOLOAD, without taking overloading into account. Since
AUTOLOAD is the main reason for overriding can, and since overloading
does not respect autoloading, can overrides should not be expected to
deal with it.
Since overload.pm already has a mycan function that fits this purpose,
this commit changes Overloaded to use that.
The test includes an example of a class structure that the previous
Overloaded implementation could not handle.
|
| |
|