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
"splice" and "shift" aren't strictly equivalent #17104
Comments
From choroba@matfyz.czCreated by choroba@matfyz.cz"perldoc -f splice" says: The following equivalences hold (assuming "$#a >= $i" ) push(@a,$x,$y) splice(@a,@a,0,$x,$y) They are equivalent in the sense of what happens to array @a. They even return #!/usr/bin/perl use Test::More tests => 4; my @y = my @x = qw( a b ); is_deeply [scalar splice @x, 0, 1], [scalar shift @y]; @x = @y = (); is_deeply [scalar splice @x, 0, 1], [scalar shift @y]; This behaviour is documented under "splice" and "shift", but the word Ch. Perl Info
|
From @jkeenanOn Tue, 23 Jul 2019 15:53:47 GMT, choroba@matfyz.cz wrote:
I concur that this discussion of "equivalences" is highly misleading. The fact that 'splice' has 3 different cases for return value means that those return values are not at all comparable to those of the other 4 built-in functions. When the original list is empty, calls to 'pop' need to anticipate an exception. See the 4 scripts attached. In principle, we could modify the documentation to say that the original list must (sometimes) be non-empty and that the "equivalence" applies only to the result list and not to the return values -- but that's so complicated that I think we're better off just removing all the discussion of "equivalence". Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#134304 (status was 'open')
Searchable as RT134304$
The text was updated successfully, but these errors were encountered: