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

Symmetric set difference (^) doesn't right-associate or chain in Rakudo #3536

Closed
p6rt opened this issue Oct 2, 2014 · 8 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Oct 2, 2014

Migrated from rt.perl.org#122882 (status was 'resolved')

Searchable as RT122882$

@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

From @masak

<masak> m​: say (<jet plane> (^) <network lag>) (^) <plane network>
<camelia> rakudo-moar d60a8f​: OUTPUT«set(jet, lag)␤»
<masak> m​: say <jet plane> (^) <network lag> (^) <plane network>
<camelia> rakudo-moar d60a8f​: OUTPUT«Too many positionals passed;
expected 2 arguments but got 3 [...]
<masak> surely I should be able to do the latter too?
<masak> (a) because if nothing else, infix​:<(^)> should left-associate
<masak> (b) because maybe it even chains? I dunno.
* masak submits rakudobug

It's an interesting question in itself where the error message "Too
many positionals passed; expected 2 arguments but got 3" comes from.
Does the (^) operator somehow declare itself as chaining, but then has
no capability to handle a longer chain of operands? Just guessing
here.

@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

From @pmichaud

On Wed, Oct 01, 2014 at 09​:00​:08PM -0700, Carl Mäsak wrote​:

<masak> m​: say <jet plane> (^) <network lag> (^) <plane network>

It's an interesting question in itself where the error message "Too
many positionals passed; expected 2 arguments but got 3" comes from.
Does the (^) operator somehow declare itself as chaining, but then has
no capability to handle a longer chain of operands? Just guessing
here.

I noticed this a few weeks ago when playing with the set operators. The problem is that infix​:<(^)> is correctly declared as having list associativity (it's at "junctive_or" precedence), but is defined as a binary operator in src/core/set_operators.pm. This is the reason for the "expected 2 arguments but got 3" message.

For comparison, note that infix​:<(|)> is defined in src/core/set_operators.pm as

  sub infix​:<(|)>(**@​p)

infix​:<(^)> needs to have a similar declaration instead of the 2-argument form that is there now.

Pm

@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

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

@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

From @masak

<pmichaud> see my response to RT #​122882 :)
<pmichaud> mainly, infix​:<(^)> should list associate
<pmichaud> imo, <jet plane> (^) <network lag> (^) <plane network> should result in <jet lag>
<pmichaud> more to the point, <a network> (^) <b network> (^) <a network> should result in <b> and not <b network>, which is hard to do if (^) is left-assoc
<masak> pmichaud​: I agree. that rhymes with infix​:<^^> semantics, too.
<pmichaud> exactly.
<masak> pmichaud++
<pmichaud> anyway, the problem is the way infix​:<(^)> is implemented in src/core/set_operators.pm

@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

From @masak

<lizmat> $ 6 'say <a network> (^) <b network> (^) <a network>'
<lizmat> set(b)
<lizmat> #​122882 can be marked as TEST NEEDED :-)

Marked as testneeded.

@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

From @pmichaud

Added tests in roast/S03-operators/set.t, marking ticket resolved.

Pm

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

From @pmichaud

Added tests in roast/S03-operators/set.t, marking ticket resolved.

Pm

@p6rt p6rt closed this as completed Oct 2, 2014
@p6rt
Copy link
Author

p6rt commented Oct 2, 2014

@pmichaud - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant