Implement PPC0030: undef aware equality#24304
Conversation
I think they would need their own amg values, and I guess should fallback to the original op after the definedness comparison, if the fallback is enabled and the original op has an overload. If fallback isn't enabled (edit) and the overload isn't defined (/edit) the overload should throw an exception like it does for any other op. If fallback is enabled by neither the undef-aware nor the base op is overloaded the normal path should be taken (try_amagic_bin() numifies the result for the numeric comparisons and the normal op implementation does the right thing. |
52495ee to
8e8d3b2
Compare
8e8d3b2 to
e27f610
Compare
|
@tonycoz : Right then. This new approach defines a whole new set of op codes and pp funcs for the undef-aware versions. I'm undecided about the names of them - The newly-added numerical comparison codes are annoyingly no longer in ordered sequence with the other ones, so it breaks the operation of There is however one big snag that I haven't thought of a good solution to, and that's the intended operation of the
Aside from those I don't have any other ideas, nor do I have a good feel for which one would be preferrable. Something to think on perhaps... (Oh and also, yes I know the branch fails sanity currently; this is due to the amagic tests I mention above) |
|
Another thing to consider is |
I don't think the code in amagic_call() would be recursively calling the pp funcs. I don't see a way to avoid messing with amagic_call() and it doesn't seem too bad: First is the switch statement that handles finding fallbacks: https://github.com/leonerd/perl5/blob/e27f6109f8a3cde7a6f67866f7c88b0aaf7ab0ee/gv.c#L3967-L3970 This checks for fallback ops, so we might add: Maybe put the undef checks in a macro. Another switch further down. https://github.com/leonerd/perl5/blob/e27f6109f8a3cde7a6f67866f7c88b0aaf7ab0ee/gv.c#L4271-L4275 again, add a case: Thankfully the |
e27f610 to
ff2c120
Compare
|
Rightthen. A new round of updates. Having followed those notes and read over the way This latest update now implements most of the While I was there I did realise that the logic could use an overloaded I haven't looked into the |
ff2c120 to
03fb011
Compare
|
And now with |
78b1b43 to
ababe66
Compare
ababe66 to
daac33e
Compare
d36c014 to
2a01134
Compare
|
Based on Perl/PPCs#87 I've shuffled the implementation here so it doesn't add entire new I added the |
2a01134 to
bee478b
Compare
|
I've now also added some basic docs in I won't add a perldelta yet because it will just keep conflicting along rebases around release time. I'll instead add something in a comment here to copy out at the time we get around to thinking about merging this. |
|
Proposed perldelta: |
|
The overload.pm docs could probably use a mention of the way overloading works for the new ops, possibly an extra |
bee478b to
6069dcd
Compare
Added. I also wonder, while we're there, if we should add specific mention about |
6069dcd to
a8ae640
Compare
|
I think if we're agreed we don't need a One of the smoker tests is unhappy currently but that's only because at present, blead's |
I don't think it needs a feature flag, it may need an experimental warning. |
a8ae640 to
e6fb1b3
Compare
|
Looks fine except for: |
1e7ec64 to
d85e9b8
Compare
912f978 to
4bd35af
Compare
4bd35af to
2e72670
Compare
|
There's been a few updates, but porting tests are still failing. |
2e72670 to
068404c
Compare
068404c to
723a9d4
Compare
tonycoz
left a comment
There was a problem hiding this comment.
Now I just need to add this to sv_numeq()/sv_numne().
…passthrough to bison
* `use VERSION` of v5.42 * 5.14-style `package NAME VERSION` syntax * No need for `no warnings "experimental::builtin"` now that refaddr is stable
As per PPC0030. Intentionally ignores the comment at the top of `regen/opcodes` to add new ops at the end, because the ops need to be grouped together with the other ones. Currently lacks any attempt at documentation or perldelta.
723a9d4 to
8fd7ef8
Compare
Now we're in the change freeze ahead of 5.44's release, this is an excellent time to start thinking about and reviewing changes for the 5.45.x cycle. With that in mind, this PR is currently still in draft, as I have a number of things to finish off first.
This adds a set of new operators for comparing values for equality, which consider
undefto be a distinct value and not equal to either the empty string, or zero. These are specified in PPC0030.Still TODO: