| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
The list this link tries to refer to is a bullet list, and so
doesn't get anchors generated for it, so clicking on the link
fails
|
| |
|
|
|
|
| |
The current text is confusing as it refers to tied values. Variables, not values, are tied (don’t bring up handles, please!).
|
|
|
|
|
|
|
| |
This reverts commit c378af320498199f011ee6aca32cef036936dd36.
Other parts of the document still refer to this. More edits are
fifthcoming.
|
| |
|
|
|
|
| |
to address long standing issues and comments that this document is confusing, in addition to accurately documenting the behaviour of fallback and nomethod in the context of overloaded operands of different types, as implemented in the fix for bug #71286. Fixes many mistakes, ambiguities, and omissions. Most of the early part of the document has been restructured and revised. For the full list of changes, see bug #82278.
|
| |
|
|
|
|
|
|
|
| |
[Note from the committer: I cannot reproduce the bug this is intended
to fix. I suspect the author has a botched Scalar::Util installation.
But it *does* make the code go faster, as it uses fewer ops. That’s my
reason for appling it.]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If an overload method is itself blessed into a class that has
overloaded operators but does not have fallback enabled, then an error
is produced:
$ perl5.10.0
use overload '+' => sub{};
bless overload::Method main => '+';
overload::Method main => '+';
^D
Operation "ne": no method found,
left argument in overloaded package main,
right argument has no overloaded magic at /usr/local/lib/perl5/5.10.0/
overload.pm line 59.
The attached patch fixes this.
|
| |
|
| |
|
| |
|