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
Assigning multiple values to an array does not work with infinite ranges (@a[^∞] = 42) #5199
Comments
From @AlexDanielLet's start with an example that works: Code: Result: That's fine. But let's try an infinite range now: Code: Result: That's definitely not what I meant. <timotimo> i'd expect the latter to have 5, 6 in it and no Mu afterwards Yes, that's what I expected too. But I can also accept an error that says �I can't do it�. |
From @jnthnOn Fri Mar 25 11:53:59 2016, alex.jakimenko@gmail.com wrote:
We've been around the block a few times on this one, and the current semantics that you observe here are the ones we've settled on, so this is not a bug. But to explain why things are this way... Note also that: $ perl6-m -e "my @a; @a[lazy ^8] = 5, 6; say @a;" The iterator of ^� considers itself wanting lazy evaluation, and this lazy marking is what we use to decide between truncating at the current length of the array (lazy) or taking the range at face value and indexing all the elements (non-lazy). For a while, we always trimmed ranges at the length of the array, meaning: @a[0,1] = <a b>; Would assign, and: @a[^1] = <a b>; Would do nothing. We fixed that to make the above two equivalent, which is a lot less surprising, and by hanging it off the laziness peg we still let @a[2..*] (or @a[2..Inf]) truncate as expected when slicing. Note that since l-values are first class in Perl 6, we can't in general know whether a given indexing is going to be used as an l-value or not, so making: @a[^�] = ... Do something different to: ... = @a[^�] Is also not an option. And I think we can agree that r-value auto-truncating is highly useful. Also note that slicing in and of itself is an eager operation. Thanks, /jnthn |
The RT System itself - Status changed from 'new' to 'open' |
@jnthn - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#127784 (status was 'rejected')
Searchable as RT127784$
The text was updated successfully, but these errors were encountered: