| > The lack of maybe or nullable types in perl6 P6 supports something more powerful and uses that instead: https://en.wikipedia.org/wiki/Tagged_union In P6 the symbol Int, when treated as a type by the compiler, denotes Int:_, which is a sum type, with two subtypes, namely a generically existentially quantified Int (Int:D) and a generically universally quantified Int (Int:U). Thus Int can be used in the role of a nullable type, but is an improvement in the sense that the equivalent to None (Int:U) encodes its type. In P6 all constructable types are automatically sum types with :U and :D subtypes. > need to check for definedness There is relatively little need for users to check definedness. The language and compiler ensure basic type/memory safety and the user can just write code and it'll automatically be type safe at this basic level. When the need arises, the user only need type one or two characters in almost all cases (either `:D` if writing a type constraint or `if foo` or `?foo` if writing an explicit check). > at run-time In P6 definedness refers to the notion that something actually exists and this is deliberately aligned with the notion that something exists at run-time. Users seldom need to concern themselves with this but when they do the P6 approach is simple and convenient. > one of its major design blunders. Also this syntax! I see the Int, Int:D, Int:U semantics and syntax as a design triumph. See another comment in this thread for an introduction to my view: https://news.ycombinator.com/item?id=18647590 > I rather use proper maybe types as in every other language. When I read things like "proper" and "as in every other language" in this manner I experience them as appeals to authority. Perl 6 is not a typical language. Just as Perl 5 isn't either. For example, a P6 compiler is allowed to statically check that types match at compile time: sub foo (Str $bar) {}
foo 42
yields the compile time error: Error while compiling .code.tio
Calling foo(Int) will never work...
but it doesn't view static type checking as a panacea any more than it considers dynamic type checking as a panacea.P6, like Perl, is designed around the notion of a this and that view of things rather than an either/or view. |