Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency: &infix:<^^> evaluates Callables, but regular ^^ doesn't #6457

Open
p6rt opened this issue Aug 20, 2017 · 3 comments
Open

Inconsistency: &infix:<^^> evaluates Callables, but regular ^^ doesn't #6457

p6rt opened this issue Aug 20, 2017 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Aug 20, 2017

Migrated from rt.perl.org#131932 (status was 'open')

Searchable as RT131932$

@p6rt
Copy link
Author

p6rt commented Aug 20, 2017

From @zoffixznet

The first example below evaluates the code block, while the two examples after it never do and return the block raw.

Is this by design?

<Zoffix_> m​: &infix​:<^^>(1, -> {say 2})
<camelia> rakudo-moar 2545e6​: OUTPUT​: «2␤»

<Zoffix_> m​: 1 ^^ -> {say 2}
<camelia> rakudo-moar 2545e6​: ( no output )
<Zoffix_> m​: 0 ^^ -> {say 2}
<camelia> rakudo-moar 2545e6​: ( no output )
Zoffix_> m​: say (0 ^^ -> {say 2})
<camelia> rakudo-moar 2545e6​: OUTPUT​: «-> { #`(Block|72040712) ... }␤»

@p6rt
Copy link
Author

p6rt commented Aug 20, 2017

From @smls

It's the same with && and ||​:

  ➜ &infix​:<&&>(1, -> {say 2}); # 2
  ➜ say 1 && -> {say 2}; # -> { #`(Block|169403552312) ... }

  ➜ &infix​:<||>(0, -> {say 2}); # 2
  ➜ say 0 || -> {say 2}; # -> { #`(Block|786414142008) ... }

And also with the loose-precedence versions `and`, `or`, `xor`.

And also with `xx`​:

  ➜ &infix​:<xx>(-> {say 2}, 2)
  2
  2

  ➜ say -> {say 2} xx 2
  (-> { #`(Block|315591575136) ... } -> { #`(Block|315591575208) ... })

I.e., it's apparently a general rule for "thunky" operators.

Whether it's intentional, I don't know.

The design docs don't mention it​: https://design.perl6.org/S03#Tight_and_precedence

@p6rt
Copy link
Author

p6rt commented Aug 20, 2017

The RT System itself - Status changed from 'new' to 'open'

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

No branches or pull requests

1 participant