summaryrefslogtreecommitdiff
path: root/lib/overload.pm
Commit message (Collapse)AuthorAgeFilesLines
* Speed up compilation of overload.pm a smidge.James Raspass2016-09-281-5/+3
| | | | | | | | | | | | | | | | | | 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.
* document that we may add more overloaded ops over timeRicardo Signes2015-05-081-1/+2
|
* overload.pm: Document fifth arg for &|^~Father Chrysostomos2015-01-311-2/+11
|
* overload.pm: TypoFather Chrysostomos2015-01-311-1/+1
|
* overload.pm: Document &. etc.Father Chrysostomos2015-01-311-6/+6
|
* Increase $overload::VERSION to 1.25Father Chrysostomos2015-01-311-1/+1
|
* overload.pm: Add string-specific bitopsFather Chrysostomos2015-01-311-4/+4
|
* overload.pm: Removed an unused variableBrian Fraser2014-10-311-2/+2
|
* Increase $overload::VERSION to 1.23Father Chrysostomos2014-09-091-1/+1
|
* Remove redundant check from overload.pmFather Chrysostomos2014-09-091-1/+1
| | | | | I added this in ca6102577e. It is silly to check ref $sub a few lines after $sub = \&....
* Document that range operator '..' can not be overloaded.Moritz Lenz2013-04-141-1/+5
| | | | | Also document that this means that ranges and bigint.pm do not mix perfectly. Bump version numbers.
* Fix various minor pod issuesKarl Williamson2013-01-241-2/+2
| | | | | These were all uncovered by the new Pod::Checker, not yet in core. Fixing these will speed up debugging the new Checker.
* propagate context into overloads [perl #47119]Jesse Luehrs2012-06-281-4/+1
| | | | | | | | | | | | | | | | | 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.
* [perl #113050] Put fallback back under "()"Father Chrysostomos2012-05-231-4/+5
| | | | | | | | | | | | | | 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.
* overload.pm: Allow :: in method namesFather Chrysostomos2012-05-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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);
* overload.pm: This warning exists nowFather Chrysostomos2012-05-211-10/+0
|
* Update overload docsFather Chrysostomos2012-05-211-24/+7
|
* Make ‘no overload’ also warn about invalid argsFather Chrysostomos2012-05-211-0/+2
|
* overload.pm: Don’t touch %OVERLOAD’s dummy entryFather Chrysostomos2012-05-211-2/+0
| | | | | | | | | | | 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.
* Make overloaded classes inherit fallbackFather Chrysostomos2012-05-211-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Increase $overload::VERSION to 1.19Father Chrysostomos2012-05-211-1/+1
|
* Increase $overload::VERSION to 1.18Father Chrysostomos2012-01-241-1/+1
|
* In overload::AddrRef, use ‘no overloading’Father Chrysostomos2012-01-241-11/+2
| | | | This speeds this up by about 13 times.
* overload.pm: Smaller indents for long linesFather Chrysostomos2012-01-181-6/+6
|
* overload.pm: spaces after dots; wording tweakFather Chrysostomos2012-01-181-16/+17
|
* Document new overload warning in overload.pmFather Chrysostomos2012-01-181-0/+5
| | | | as well as perldiag.
* overload.pm: Doc tweaksFather Chrysostomos2012-01-181-1/+1
| | | | This sentence got mangled somehow, somewhen.
* In overload::ov_method, use ‘no overloading’Father Chrysostomos2012-01-181-3/+2
| | | | Using this instead of Scalar::Util makes things marginally faster.
* Lower $overload::VERSION to 1.17Father Chrysostomos2012-01-161-1/+1
| | | | It doesn’t need to be increased twice between releases.
* overload.pm: Combine two loopsFather Chrysostomos2012-01-161-3/+2
| | | | It should go faster if we only iterate through %arg once.
* overload.pm: Put invalid arg warning in "overload" categoryFather Chrysostomos2012-01-161-1/+1
| | | | Existing overload warnings work that way.
* Suppress ‘useless’ warning in overload.pmFather Chrysostomos2012-01-161-1/+1
|
* Emit a warning if an attempt is made to overload an invalid (e.g., ↵jkeenan2012-01-161-17/+30
| | | | misspelled) operator. For RT #74098.
* [perl #40333] Stop overload::Overloaded from calling ->canFather Chrysostomos2012-01-091-1/+1
| | | | | | | | | | | | | | 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.
* Increase $overload::VERSION to 1.17Father Chrysostomos2012-01-051-1/+1
|
* Correct links to perlsyn and perlopFather Chrysostomos2012-01-051-2/+2
|
* Version bumpsif-0.0602Father Chrysostomos2011-11-221-1/+1
|
* [RT #36079] Convert ` to '.jkeenan2011-11-221-11/+11
|
* overload.pm: Fix broken linkKarl Williamson2011-07-031-2/+3
| | | | | | 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
* overload.pm: Fix broken linkKarl Williamson2011-05-181-2/+2
|
* Relation between overloading and ties: second tryFather Chrysostomos2011-02-101-8/+10
| | | | The current text is confusing as it refers to tied values. Variables, not values, are tied (don’t bring up handles, please!).
* Revert "The relation between overloading and ties has been fixed."Father Chrysostomos2011-02-101-0/+13
| | | | | | | This reverts commit c378af320498199f011ee6aca32cef036936dd36. Other parts of the document still refer to this. More edits are fifthcoming.
* The relation between overloading and ties has been fixed.Father Chrysostomos2011-02-101-13/+0
|
* perl #82278: Overload documentation: many changes This is a partial rewrite ↵Michael Breen2011-02-101-480/+643
| | | | 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.
* Increase overload.pm’s versionFather Chrysostomos2010-11-271-1/+1
|
* [perl #79680] overload 1.10 sprintf fails taint checkingMichael Fig2010-11-271-1/+1
| | | | | | | [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.]
* [perl #71998] overload::Method can die with blessed methodsFather Chrysostomos2010-09-281-2/+4
| | | | | | | | | | | | | | | | | | 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.
* Bump overload.pm's VERSION (plus some spelling nits)Rafael Garcia-Suarez2009-11-011-3/+3
|
* Documentation for the 'qr' overload.Ben Morrow2009-11-011-11/+16
|
* Bump overload.pm's version since it differs from the version in 5.11.0Jesse Vincent2009-10-201-1/+1
|