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 |
…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. TODO: Currently only parsed and tested for the stringy version, not the numerical version, even though numerical is implemented internally. TODO: Currently lacks any attempt at documentation or perldelta. TODO: Also lacks any consideration on how an `equ` operator would interact with `use overload`. Further thought is required here.
Support 'use integer' with ===/!== operators
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: |
| use 5.006; | ||
| sub usage { die "usage: $0 [ -b bison_executable ] [ file.y ]\n" } | ||
|
|
||
| use v5.10; |
There was a problem hiding this comment.
it's 5.12 that adds implicit strict (assuming that's the reason for removing the explicit strict).
tony@venus:~$ perl -e 'use v5.10; print $x'
tony@venus:~$ perl -e 'use v5.12; print $x'
Global symbol "$x" requires explicit package name (did you forget to declare "my $x"?) at -e line 1.
Execution of -e aborted due to compilation errors.
| its arguments is C<undef>. These operators, called the I<undef-aware equality | ||
| operators>, consider that C<undef> is equal to another C<undef> but not equal | ||
| to any defined value - even the number zero or the empty string. Furtheremore, | ||
| these operators will not invoke warnings of undefined values, even when their |
There was a problem hiding this comment.
The warning complains about Use of uninitialized value rather than undefined.
I only bring this up because you say "warnings of undefined values" (warning about "undefined values") rather than "warnings on undefined values" (some warning when an undefined value is seen.)
Feel free to ignore this.
|
The overload.pm docs could probably use a mention of the way overloading works for the new ops, possibly an extra |
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: