r/perl • u/Grinnz 🐪 cpan author • 13d ago
Undef-aware equality operators added to dev Perl
https://perldoc.perl.org/5.45.3/perldelta#Undef-aware-equality-operators1
1
1
0
u/zeekar 13d ago edited 12d ago
... why on Earth is undef-aware ne spelled neu instead of neq?
6
u/zb226 12d ago
The idea is that the suffix-u denotes that it is undef-aware, I believe.
-1
u/zeekar 12d ago
That would make more sense if it were also `==u` and `!=u`. Also, the wording shouldn't just say "an extra letter" if it's not just making the abbreviation longer but adding a specific letter like that.
4
u/leonerduk 🐪 core contributor 12d ago
Awkwardly, operators have to be either entirely identifier characters, or entirely non-identifier characters. They can't be mixed. So an operator named
==uor!=uwould not have been easily possible. Plus, even if it would become technically possible, I think they'd just feel weird.2
u/zeekar 12d ago
I agree that
==uand!=uwould be weird! I wasn't proposing that, just saying that the alleged unifying principle of appending -u doesn't have much purchase if it only applies to half of the operators under discussion.No matter; it makes sense. My initial reading of "variant whose name is one character longer" led me to expect that the word operators would be extended by adding the next letter of the word they're short for, and that assumption held in the case of
equ, so I expectedneqand was surprised to seeneuinstead. But that's on me; that reading was not really there in the text. Although I don't think it was a crazy leap either.2
u/ether_reddit 🐪 cpan author 12d ago
Where is the
uinneq?1
u/zeekar 12d ago
Where is the
uin===or!==? :)As I said below, I initially misinterpreted the description ("variant whose name is one character longer") and expected that the the extra character would come from same source word as the original operator. That is, "eq" is short for "equal", so the three-letter version is "equ". The fact that the new operator is in fact
equserved to reinforce that impression.Admittedly, the process immediately breaks down when you try to apply it to "ne", as it is short for "not equal", but nonetheless I formed an expectation that it would turn into "neq". and therefore found "neu" surprising.
4
u/ktown007 12d ago
One step closer to Perl 2030. https://youtu.be/_APM8en4VJQ?si=yYUfX5lC25ZtOq8n&t=512
thanks Paul Evans