how would one describe Perl 6 type system?
Is it dynamically typed, optionally typed, statically typed?
Is it dynamically typed, optionally typed, statically typed?
> sub f(Int $x) { $x + 1 }
sub f (Int $x) { #`(Sub|140221097113944) ... }
> sub g(Str $x) { f($x) }
===SORRY!=== Error while compiling:
Calling f(Str) will never work with declared signature (Int $x)If the compiler can prove the outcome of a type check at compile time, it can throw a type error or optimize out the runtime check, depending on the outcome.