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
.map gets confused by IterationEnd sentinel #4582
Comments
From zefram@fysh.orgThe .map method iterates through its input in a way that will be $ ./perl6 -e 'my @a = 2,3,4; @a[1] := IterationEnd; say @a.elems; say @a.map({ "wibble" }).elems; say @a.perl; say @a.reverse.elems; say @a.reverse.perl' Similar confusion also arises if the sentinel is ever generated in $ ./perl6 -e 'my @a = 2,3,4; say @a.elems; say @a.map({ $_ == 3 ?? IterationEnd !! "wibble" }).elems' -zefram |
From @lizmat
I think this is really a case of DIHWIDT. The IterationEnd sentinel needs to be public, because module makers will need to be able to make their own Iterators.
This is really equivalent to the use of last in: $ ./perl6 -e 'my @a = 2,3,4; say @a.elems; say @a.map({ $_ == 3 ?? (last) !! "wibble" }).elems' which is both in perl 5 and perl 6 very acceptable usage. IMHO, this ticket can be rejected. |
The RT System itself - Status changed from 'new' to 'open' |
From zefram@fysh.orgElizabeth Mattijsen via RT wrote:
What, don't put the IterationEnd sentinel in an array? But it's such
One is returning a value (which it could have got from anywhere); Perl 5 doesn't have last exit a map per se: the map itself doesn't count -zefram |
From @jnthnOn Wed Sep 23 14:14:07 2015, elizabeth wrote:
Indeed. If people use it for anything aside from the intended purpose (compare it with =:= to what comes back from an Iterator method) then on their own head be it. And there's no reasonable use for it other than that.
True, but let's not encourage people to write that.
Yup. /jnthn |
@jnthn - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#126147 (status was 'rejected')
Searchable as RT126147$
The text was updated successfully, but these errors were encountered: