Skip to content

Conversation

@briandfoy
Copy link
Member

@briandfoy briandfoy commented Sep 2, 2025

The ^^ operator can't return the last evaluated expression since it could either be true or false, and would not indicate the success of the XOR. You can see this by using ^^:

$ perl -E 'say q(A) ^^ q(B)'

$ perl -E 'say q(0) ^^ q(B)'
1
  • This set of changes does not require a perldelta entry.

The docs may need further revisions to distinguish ^^ from the other logical operators. I think the re-organization of the separate sections for ||, //, and ^^ was a mistake that will cause more confusion for people since these three are dissimilar enough to need sections that distinguish them sufficiently.

The ^^ operator can't return the last evaluated expression since it could either be true or false, and would not indicate the success of the XOR. You can see this by using ^^:

    $ perl -E 'say q(A) ^^ q(B)'

    $ perl -E 'say q(0) ^^ q(B)'
    1
@Grinnz
Copy link
Contributor

Grinnz commented Sep 2, 2025

There are several examples of that with operators that are the same precedence. Redesigning perlop may be useful but would be a larger task. Selfishly, I would like a redesign that makes it easier to give them searchable operator-pages on perldoc.perl.org. But I think that would be better served as a new document or section, or a module similar to Pod::Functions.

@Grinnz
Copy link
Contributor

Grinnz commented Sep 2, 2025

Ref #23224

@khwilliamson khwilliamson merged commit 44254e7 into blead Sep 2, 2025
68 checks passed
@book
Copy link
Contributor

book commented Sep 2, 2025

^^ is also the only one that can't short-circuit.

Which made me think (and double-check) that && does return the last evaluated expression:

$ perl -E 'say $_ && 2 for 0, "", 3'
0

2

@karenetheridge karenetheridge deleted the xor-logical-result branch September 2, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants