Defeating definedness
In his latest blogpost, p6steve went through a lot of trouble to enforce definedness. I managed to shorten it a bit.
None: Nil;
subset Option of Any where Any:D | None;
my Option $defined = 42;
my Option $nothing = None;
my Option $undefined = Mu;
.&dd for $defined, $nothing, $undefined;
# OUTPUT: Type check failed in assignment to $undefined; expected Option but got Mu (Mu)
I would really like to see the content of $nothing
, and while I’m on it show why Steve’s hard labour was in vain.
try {
my Option $defined = 42;
my Option $nothing = None;
my Option $undefined = Mu;
.&dd for $defined, $nothing, $undefined;
CATCH { default { note .message; .resume } }
}
# OUTPUT: Type check failed in assignment to $undefined; expected Option but got Mu (Mu)
# Int $defined = 42
# Label $nothing = Label.new(name => "None", file => "tmp/2021-03-08.raku", line => 1880)
# Any $undefined = Any
Raku is a dynamic, late bound language. There are language constructs, like resumable exceptions and NativeCall, that can defeat any type-check. Trying to use Raku like Rust, Haskell or any other strictly typed language will eventually fail. No amount of :D
s will substitute testing, testing and even more testing.
I hope not to have tested p6steve’s patience and try to calm the waves with a new repo.
Categories: Raku
Comments (0)
Trackbacks (1)
Leave a comment
Trackback
-
August 22, 2022 at 16:582022.34 R(aku&ust) – Rakudo Weekly News