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

infix:<!eq> shouldn't differ from infix:<ne> when applied to junctions in Rakudo #1787

Closed
p6rt opened this issue May 26, 2010 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented May 26, 2010

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

Searchable as RT75368$

@p6rt
Copy link
Author

p6rt commented May 26, 2010

From @masak

<pmichaud> actually, $i !~~ any(|$nth) should be the same as
!($i ~~ any(|$nth)) iiuc
<moritz_> the negation comes at the end
<pmichaud> negations and junctions are problematic
<pmichaud> (in general)
<masak> apparently so.
<masak> I accept what you're saying, but I can't see how it works out that way.
<jnthn> To the point that the spec in one place suggests a warning.
<masak> how does the ! end up outermost?
<pmichaud> it's a metaop
<pmichaud> it always ends up "outermost"
<jnthn> masak​: All ! meta-ops are like that.
<masak> the ! metaop ends up outside of junctions? cool!
<jnthn> $a !== $b is !($a == $b) really
<masak> jnthn​: oh, indeed.
<masak> so this doesn't go for the infix​:<ne> operator?
<moritz_> nope
<moritz_> that's not meta-y
<moritz_> so !eq is not quite the same as ne, when junctions are involved
<moritz_> masak​: that's a good item for our best practise list
<jnthn> btw, Rakudo's ne is implemented in terms of !eq
<jnthn> If you want to avoid the inconsistency, then change infix​:<ne>
to take two Mus.
<masak> jnthn​: so maybe that's a potential bug in Rakudo? :)
<jnthn> masak​: Only if we can decide what the spec is. ;-)
<masak> didn't we just do that?
* jnthn would kinda feel more comfortable if they were the same.
<moritz_> rakudo​: say 1 ne 1|2
<p6eval> rakudo 240400​: OUTPUT«any(Bool​::False, Bool​::True)␤»
<moritz_> rakudo​: say 1 !eq 1|2
<p6eval> rakudo 240400​: OUTPUT«0␤»
<moritz_> that's correct as I understand the current spec
<masak> so it's actually correct? hooray!
<jnthn> masak​: Or if we should mark ne and != as having Mu parameters.
<jnthn> So they work out the same as !eq and !==
<masak> jnthn​: I don't see why we should.
<mathw> I'm wondering how often it's going to bite people
<mathw> And if we want to allow the distinction
<mathw> Is it potentially useful?
<pmichaud> as I read the spec, infix​:<ne> is supposed to be the same as !eq
<pmichaud> i.e., it's just a shortcut.
<masak> so it is a bug?
<moritz_> masak​: only by pmichaud++'s interpretation
* masak submits rakudobug
<masak> that's enough for me. :)
<mathw> I'm not convinced
<pmichaud> S03​:1189
<pmichaud> As in Perl 5, converts to C<Str> before comparison. C<ne>
is short for C<!eq>.
<moritz_> ok
<moritz_> that's enough for me :-)
<pmichaud> also later at S03​:3915

@p6rt
Copy link
Author

p6rt commented May 28, 2010

From @jnthn

On Wed May 26 05​:53​:47 2010, masak wrote​:

<moritz_> rakudo​: say 1 ne 1|2
<p6eval> rakudo 240400​: OUTPUT«any(Bool​::False, Bool​::True)␤»
<moritz_> rakudo​: say 1 !eq 1|2
<p6eval> rakudo 240400​: OUTPUT«0␤»

Now it's all nicely consistent...

say 1 !eq 1|2
0
say 1 ne 1|2
0
say 1 !== 1|2
0
say 1 != 1|2
0

Given to moritz++ for spectests.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented May 28, 2010

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

@p6rt
Copy link
Author

p6rt commented May 30, 2010

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

@p6rt p6rt closed this as completed May 30, 2010
@p6rt
Copy link
Author

p6rt commented May 30, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S03-junctions/autothreading.t

commit 95286058005835b101d98e9f2d55549f5fe2aa64
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun May 30 12​:55​:14 2010 +0000

  [t/spec] tests for RT #​75368 and new spec wrt autothreading over negated operators
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;30992 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S03-junctions/autothreading.t b/t/spec/S03-junctions/autothreading.t
index ec61ecb..2e32c6b 100644
--- a/t/spec/S03-junctions/autothreading.t
+++ b/t/spec/S03-junctions/autothreading.t
@@ -1,7 +1,7 @@
 use v6;
 use Test;
 
-plan 77;
+plan 83;
 
 {
     # Solves the equation A + B = A * C for integers
@@ -285,4 +285,18 @@ plan 77;
     is $c, 6, 'do autothread over blocks with explicit Any';
 }
 
+# used to be RT #75368
+# L<S03/Junctive operators/Use of negative operators with junctions>
+{
+    my Mu $x = 'a' ne ('a'|'b'|'c');
+    ok $x ~~ Bool, 'infix:<ne> collapses the junction (1)';
+    ok $x !~~ Junction, 'infix:<ne> collapses the junction (2)';
+    nok $x, '... and the result is False';
+
+    my Mu $y = 'a' !eq ('a'|'b'|'c');
+    ok $y ~~ Bool, 'infix:<!eq> collapses the junction (1)';
+    ok $y !~~ Junction, 'infix:<!eq> collapses the junction (2)';
+    nok $y, '... and the result is False';
+}
+
 # vim: ft=perl6

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

No branches or pull requests

1 participant