You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On 2023-06-02 13:27, Branislav Zahradník wrote:
Example:
|my @list : (Array[ max_length (7), Int ]; if ($list[8]) { # should
this fail? } |
Would IMO be great if <$list[7]> then is a "compile-time" error.
So yes, IMO it should "throw an exception",
if not at "compile-time" then
at least at "run-time".
But then what about:
my $t :UInt8;
$t |= 256;
In Perl, our data isn't just the "type" of the data (SV, IV, PV), but also the "shape" of the data (scalar, array, hash). I think any checks would have to consider both. Thus, we need array out-of-bounds errors.
Also, the MVP will not have compile-time errors because we're trying to constrain the scope as much as possible. I do see room for compile-time errors later.
It's a non-issue because the my $f :UInt8; would throw an exception because undef doesn't meet the constraint.
But if we have var:
var $t :of(UInt8);
$t |= 256;
The error would appear on the second line because you can coerce an undefined value, but not an uninitialized one. However, that would like leak out of the existing scope and cause grief elsewhere in unsuspecting code (which it should do, to be fair), but people would scream, so I'm pretty sure that var is not just out of scope for this MVP, but also impossible to get P5P to accept (what would happen with $array[$i] where $i is an uninitialized var? I should throw an exception).
As an aside, if we do attributes for the checks, we can't do :UInt8 because there are so many checks that we'd have massive pollution of the attribute "namespace" and would be much more like to cause conflicts with existing code.
Example:
The text was updated successfully, but these errors were encountered: