Rationale of return types from subroutines always being nullable?

[email protected] (Quanrong via perl6-users) Mon, 20 Oct 2025 16:59:11 +0200
Newsgroups perl.perl6.users
Message-ID <[email protected]>
Hi all, I'm learning Raku and enjoying it tremendously, it's a beautiful 
and well thought language.

I was very surprised to find that, even if you declare the return type 
of a subroutine with the `:D` smiley, subroutines are still allowed to 
return `Nil`.

What is the reason for this? It would be very useful to be able to state 
that a subroutine must not return `Nil`. And, if this is not possible, 
shouldn't the `:D` smiley be disallowed for the return type in a signature?

I suppose there has to be a good reason for this.

Thank you!