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

Rakudo doesn't treat several whatever stars in a row correctly in a list smartmatch #500

Closed
p6rt opened this issue Dec 17, 2008 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Dec 17, 2008

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

Searchable as RT61452$

@p6rt
Copy link
Author

p6rt commented Dec 17, 2008

From @masak

<masak> rakudo​: say (1,2,3) ~~ (1,*,*,3)
<p6eval> rakudo 34053​: OUTPUT[0␤]
<jnthn> Hmm.
<masak> jnthn​: what do you think of that first one?
<jnthn> The first one looks like a bug.
<masak> jnthn​: :)
* masak submits

@p6rt
Copy link
Author

p6rt commented Jan 31, 2009

From jswitzer@gmail.com

On Wed Dec 17 15​:38​:07 2008, masak wrote​:

<masak> rakudo​: say (1,2,3) ~~ (1,*,*,3)
<p6eval> rakudo 34053​: OUTPUT[0␤]

If my understanding of how whatever-star works is right, this test isn't
entirely correct. What you probably meant to test was this​:

(22​:16​:24) s1n​: rakudo​: (1,2,3) ~~ (1,*,*,3)
(22​:16​:28) p6eval​: rakudo 36183​: RESULT«Bool​::False»
(22​:16​:59) s1n​: rakudo​: (1,2,3) ~~ (*,*,3)
(22​:17​:03) p6eval​: rakudo 36183​: RESULT«Bool​::False»
(22​:17​:25) s1n​: rakudo​: (1,2) ~~ (1,*)
(22​:17​:28) p6eval​: rakudo 36183​: RESULT«Bool​::True»

Notice the 1 test is checking if a 3 element list against a 4 element
list. The second test shows that the multiple whatever-stars still don't
work. The last test is just gravy showing that at least 1 whatever-star
works correctly.

@p6rt
Copy link
Author

p6rt commented Jan 31, 2009

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

@p6rt
Copy link
Author

p6rt commented Jan 31, 2009

From @masak

On Fri Jan 30 20​:20​:04 2009, s1n wrote​:

On Wed Dec 17 15​:38​:07 2008, masak wrote​:

<masak> rakudo​: say (1,2,3) ~~ (1,*,*,3)
<p6eval> rakudo 34053​: OUTPUT[0␤]

If my understanding of how whatever-star works is right, this test isn't
entirely correct. What you probably meant to test was this​:

(22​:16​:24) s1n​: rakudo​: (1,2,3) ~~ (1,*,*,3)
(22​:16​:28) p6eval​: rakudo 36183​: RESULT«Bool​::False»
(22​:16​:59) s1n​: rakudo​: (1,2,3) ~~ (*,*,3)
(22​:17​:03) p6eval​: rakudo 36183​: RESULT«Bool​::False»
(22​:17​:25) s1n​: rakudo​: (1,2) ~~ (1,*)
(22​:17​:28) p6eval​: rakudo 36183​: RESULT«Bool​::True»

Notice the 1 test is checking if a 3 element list against a 4 element
list. The second test shows that the multiple whatever-stars still don't
work. The last test is just gravy showing that at least 1 whatever-star
works correctly.

I've had similar thoughts when trying to grok the whatever star, and my
conclusion contradicts your above comment. Here's why​:

Currently, one of the established uses of the whatever star in
smartmatching is checking whether an item is an element of an array.
S03​:3323 gives this example​:

  Array Num array contains number *,X,*

To me, this establishes that the whatever star also matches zero-width
subsequences of the array. Because if it didn't, the above wouldn't
match an array containing the element in the beginning or in the end.

With this logic (that the whatever star matches zero elements), all
three of your smartmatches should evaluate to true.

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

From @jnthn

On Wed Dec 17 15​:38​:07 2008, masak wrote​:

<masak> rakudo​: say (1,2,3) ~~ (1,*,*,3)
<p6eval> rakudo 34053​: OUTPUT[0␤]
<jnthn> Hmm.
<masak> jnthn​: what do you think of that first one?
<jnthn> The first one looks like a bug.
<masak> jnthn​: :)
* masak submits

And as of git daa2eea it looks like an ex-bug. Plus added a bunch of tests.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

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

@p6rt p6rt closed this as completed Feb 13, 2009
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