summaryrefslogtreecommitdiff
path: root/lib/overload.pm
Commit message (Collapse)AuthorAgeFilesLines
* Fix enough code to get make test_prep working with -dDusedefaultstrictTodd Rinaldo2020-10-131-6/+9
| | | | | | | | | 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.
* Change some link pod for better renderingKarl Williamson2020-08-311-2/+2
| | | | C<L</foo>> renders better in places than L</C<foo>>
* lib/overload.pm: Use L</Foo Bar>, not L<Foo Bar>Karl Williamson2019-05-251-15/+15
|
* Update docs wrt bitwise opsFather Chrysostomos2017-12-311-2/+2
|
* revert smartmatch to 5.27.6 behaviourZefram2017-12-291-3/+28
| | | | | | | | | | | | | 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.
* update doc in lib/ about smartmatchZefram2017-11-221-28/+3
|
* overload.pm: add a missing 'exists'Dan Collins2016-12-261-2/+2
| | | | | | | | 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.
* 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
|