Ashley Winters skribis 2005-10-06 19:30 (-0700): > > my Array $a = 97; # dies eventually, but when? > Runtime -- cannot coerce Int value to Array
It is fully determinable at compile time. 97 will never be compatible with Array, so I see no reason to wait. Do remember that some programs run for weeks or months, rather than a few seconds. It's nice to get all the certain failures during compile time. > > sub foo (Int $arg) {...} > > foo("hello"); # should die at the latest when foo() is called > $arg should be undef but Exception::InvalidInteger("Str value 'hello' > cannot be coerced to an Int at $?LINE") That'd be a problem with sub foo (Int $arg //= 5) { ... } because the "hello" is then silently ignored eventually. But, these unthrown exceptions should be emitted as warnings anyway, so it is not really a problem, because everyone has warnings enabled all the time. I wouldn't mind this to fail. If it fails, it can die or be undef, depending on the user's wishes. In my case: die. > If bar returns a Str ~~ /<Perl6::Grammar::Int>/, it gets coerced; > otherwise, undef but Exception "hello 5 worlds"? /^<...>/ perhaps? And I think we should match against Num, not Int, as it's very hard to have a rule that matches just integers. 0.5e3 is an integer, but 0.5e-3 is not. As stated in my previous message, I think that all numbers should be parsed the same way, and interpreted as Nums. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html