Home > Raku > Defeating definedness

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 :Ds 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
  1. No comments yet.
  1. August 22, 2022 at 16:58

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: