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
What is a "list"? #1344
Comments
|
I'd expect |
No. |
|
Thanks. I'll go over and fix any .list's that don't return a Positional. |
Per #1344 , a Seq is not a "list", because it does not do a Positional role.
Per rakudo/rakudo#1344 , a Seq is not a "list", because it does not do a Positional role. Looks like the original tests[^2] did start off testing for List and because they were added alongside `cache` listop, they tested for whether caching did not occur. Then, they were changed[^2] to test for a Seq return value. My guess that was semi-accidental and the proper course was meant to be to fix &list(Seq:D) to give a List. [1] a046d7448847d327e09bc542dd [2] 5463a12cbe6dacaaef898d28d3
Per rakudo/rakudo#1344 , a Seq is not a "list", because it does not do a Positional role. Looks like the original tests[^2] did start off testing for List and because they were added alongside `cache` listop, they tested for whether caching did not occur. Then, they were changed[^2] to test for a Seq return value. My guess that was semi-accidental and the proper course was meant to be to fix &list(Seq:D) to give a List. [1] a046d7448847d327e09bc542dd [2] 5463a12cbe6dacaaef898d28d3
|
Started writing tests and below is what I got so far... but there are several inconsistencies in I opened that issue as #1355 and will wait for its resolution before proceeding here. subtest 'list makes Positionals' => {
plan 3 + my @stuff :=
(1, (2, 3)), $(1, (2, 3)),
%(:42foo, :70bar), $%(:42foo, :70bar), Map.new((:42foo, :70bar)),
$(Map.new((:42foo, :70bar))),
set(1, 2, 3), SetHash.new(1, 2, 3),
bag(1, 2, 3), BagHash.new(1, 2, 3),
mix(1, 2, 3), MixHash(1, 2, 3),
1, <1>, 2e0, <2e0>, 3.1, <3.1>, <3+3i>, <3+3i >,
Date.today, DateTime.now, now;
subtest 'Seq' => {
# Seqs are a bit of a strange animal when it comes to &list/.list:
# https://irclog.perlgeek.de/perl6-dev/2017-12-31#i_15636448
# Since they have the PositionalFailOver stuff, they can be considered
# a "list" if you squint hard enough, so &list(Seq:D) is a no-op,
# because it just passes through a `+@ is raw` slurpy, whereas `.list`
# involves no such squinting and returns a real-er list
plan 4;
(my \V = (1, 2, 3).Seq).cache;
isa-ok list(V), Seq, '&list returns a listy thing';
is-deeply list(V), Seq, '&list gives right list';
isa-ok V.list, List, '.list returns a listy thing';
is-deeply V.list, V.List, '.list gives right list';
}
subtest 'Array' => {
plan 4;
my \V = [1, 2, 3];
isa-ok list(V), Array, '&list returns a listy thing';
is-deeply list(V), V, '&list gives right list';
isa-ok V.list, Array, '.list returns a listy thing';
is-deeply V.list, V, '.list gives right list';
}
subtest 'Slip' => {
plan 4;
my \V = (1, 2, 3);
isa-ok list(V), Slip, '&list returns a listy thing';
is-deeply list(V), V, '&list gives right list';
isa-ok V.list, Slip, '.list returns a listy thing';
is-deeply V.list, V, '.list gives right list';
}
for @stuff -> \V {
subtest V.^name => {
plan 4;
my \s-exp = (V ~~ Iterable and V.VAR !~~ Scalar) ?? (V,) !! V.List;
isa-ok list(V), (V,), '&list returns a listy thing';
is-deeply list(V), (V,), '&list gives right list';
isa-ok V.list, List, '.list returns a listy thing';
is-deeply V.list, V.List, '.list gives right list';
}
}
} |
Buf.list returns a Seq, which explodes when we rake its guts for List stuff inside &nodemap. Fix by making it return a List. Part of addressing #1344 Bug find: https://irclog.perlgeek.de/perl6/2018-01-07#i_15660359
|
Related issue. there's a difference that a scalarized List doesn't get deconted by &list, but does by .list: And the same problem (or not problem?) exists with |
Partially fixes R#1344 #1344 Since (per discussion on the Issue) a Seq is not a "list", the .list/.cache methods need to return a Positional. This commit is required for the grant to have proper coersion+typecheck on `@`-sigilled constants. The rest of the Issue still requires filling in the gaps in positional slurpy semantics ( R#1355 #1355 )
The link doesn't load anymore and R#1344 [^1] is still open. [1] rakudo/rakudo#1344
The link doesn't load anymore and R#1344 [^1] is still open. [1] rakudo/rakudo#1344
I'd assume it to be something that does
Positionalrole. For example,@()coercer calls.cache, which onSeqs returns aListand onAnys calls.list.I'd assume anything that is
@()-coerced can be bound to a@-variable. However, that is not currently the case:The reason is
Hash.listreturns aSeqobject. So the question is: isSeqa "list"?Along with the above inconsistency, I see that
Seq:D.listreturns aList, whilelist Seq:Dstill returns aSeq. I went to fix that (currently inlist-Seqbranch in rakudo and roast), but that's blocked by a6.ctest oflistthat looks like it might've been changed to check forSeqreturn value by accident.To summarize: what's a "list" and is Seq a "list"?
The text was updated successfully, but these errors were encountered: