Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Indexing on a Str throws generic “out of range” message which is less than awesome (“hello”) #5740
Actually thrown at:
IRC discussion starting here:
On Mon, 10 Oct 2016 06:05:10 -0700, email@example.com wrote:
I don't get why we throw in this case at all. We don't do it with any of the Positionals:
<Zoffix_> m: say $_ for 1..1, (1,), [1,], (1,).Seq
Other than Blob and Uni, which I'd say also break the consistency:
<Zoffix_> m: say "".NFD
The throwage breaks the "everything is a 1-item list" idiom, as I can't safely do $x, because
And regardless of that, I'm -1 on this ticket. Right now $x throws X::OutOfRange on non-Positionals (even though it shouldn't), but the proposed fix for this ticket would see the possibility of yet another exception in another special case being thrown, all for the sake that *someone new to the language* *assumes* Perl 6 can index strings. IMO such special casing will be a hassle to more normal Perl 6 users than a helpful tip to new Perl 6 users. Just recall how often the Perl-5-ism exceptions get thrown when writing normal Perl 6 code.
I agree with you, but we can do better.
Usually I'm against all perl5 error messages, but I believe that this case is different. I am sure that this is what most people attempt to do at some point. I also know for sure that this is what I did a couple of times when I was starting with Perl 6. I also remember many times people were asking this on the channel.
So here's what I think:
On 2017-05-08 09:26:53, firstname.lastname@example.org wrote: