3 ms·
how would one describe Perl 6 type system? Is it dynamically typed, optionally typed, statically typed?
by systems 9y ago
how would one describe Perl 6 type system?
Is it dynamically typed, optionally typed, statically typed?
- kbp 9y agoIt has optional static typing: > 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)
- jerf 9y agoThe Perl 6 answer to almost all such questions is simply "Yes". It is an incredible mess. Whether it is a glorious mess is something that we are finally coming up on the ability to determine.
- perlgeek 9y agoIt's gradually typed. Which means there are dynamic type checks, and optional static type declarations as well. 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.