Can I please have an ArrayOutOfBoundsException?
<p>In Python, if you index a collection structure with a out-of-bounds key/index, you get a slap in the face:</p>

<pre><code>&gt;&gt;&gt; [1, 2, 3][9]
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
IndexError: list index out of range
</code></pre>

<p>That's an Exception; it derives from BaseException, and failing to handle one will <strong>crash my program, which is almost always what I want</strong>.</p>

<hr>

<p>Perl 5 and 6's list indexing seems to not care about out-of-bounds indexing:</p>

<pre><code>$ perl6
&gt; my @l = (1..4);
[1 2 3 4]
&gt; say @l[2];
3
&gt; say @l[9];
(Any)
&gt; print @l[9];                                                                                                          
Use of uninitialized value @l of type Any in string context
&lt;snip&gt;    
True
&gt; my $x = @l[9]; # even assignment doesn't error! who decided this was okay!?
&gt; say $x; print $x;
(Any)
Use of uninitialized value $x of type Any in string context
&lt;snip&gt;    
</code></pre>

<p><sup>it's basically the same thing in Perl 5, except you don't get a value returned, but execution continues as normal.</sup></p>

<p>I don't understand why out-of-bounds accessing should ever be <strong>silent</strong>. The only warnings you get that value may be "uninitialised" (but we all know it really means <strong>non-existent</strong>) are when you give it to certain functions.</p>

<p>Can I fix this somehow? I could implement my own post-circumfix indexing operator to override the default one that dies on junk index, but there's no way to tell the difference between an uninitialised value and the type <code>Any</code>. The only way to do that <em>I</em> can see is to check if the requested index is in the range <code>List.elems()</code>.</p>

<p>What (preferably minimal, simple, clean, readable, etc) solution can I use to remedy this?</p>

<hr>

<p>Before anyone says "yes, but the variable is uninitialised, like <code>my $x;</code>!": in C you get a segfault if you access memory you didn't allocate; why can't I have that sort of safety?</p>

<hr>

<p>I've tagged this as both Perl and Perl 6 because, while I'm learning Perl 6 and the particulars of this question apply mostly to 6, the main idea seems to be a shared aspect of both 5 and 6.</p>