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

Zip operator when an element is a Whatever #5538

Open
alabamenhu opened this issue Mar 24, 2024 · 1 comment
Open

Zip operator when an element is a Whatever #5538

alabamenhu opened this issue Mar 24, 2024 · 1 comment
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@alabamenhu
Copy link
Contributor

alabamenhu commented Mar 24, 2024

The Problem

If using the zip operator on a list with an interior Whatever, the Whatever will be replaced with the previous element.

Expected Behavior

The expected behavior should preserve the interior Whatever object, as only when it's a final element does it repeat the previous element (per docs).

my @a = ['a', *, 'c']; 
my @b = [1,2,3]; 
say (@a Z @b); 
# ((a 1) (* 2) (c 3))

Actual Behavior

say (@a Z @b); 
# ((a 1) (a 2) (c 3))

Steps to Reproduce

See above code. Note that the cross operator X does not have the same error:

say (@a X @b); 
((a 1) (a 2) (a 3) (* 1) (* 2) (* 3) (c 1) (c 2) (c 3))

Environment

  • Compiler version (rakudo -v or raku -v): v2024.02.110.g.18.abe.8.c.32
@lizmat
Copy link
Contributor

lizmat commented Mar 24, 2024

It appears to be meant this way: the zip iterators appear to apply the Rakudo::Iterator.Whatever to the given iterables, and the internal documentation states:

    # Returns an iterator from a given iterator where the occurrence of
    # a Whatever value indicates that last value seen from the source
    # iterator should be repeated indefinitely until either another
    # non-Whatever value is seen from the source iterator, or the source
    # iterator is exhausted.

This behaviour does not appear to be documented. However, the spectests do have tests for it: removing the special Whatever handling, results in t/spec/S03-metaops/zip.t tests failing.

I propose we at least add a documentation issue. And maybe a problem-solving issue whether this behaviour is wanted or not. Or to have a way to disable it.

@ab5tract ab5tract added the LTA Less Than Awesome; typically an error message that could be better label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

3 participants