develooper Front page | perl.perl6.users | Postings from September 2018

Re: .kv ?

Thread Previous | Thread Next
Brandon Allbery
September 14, 2018 22:11
Re: .kv ?
Message ID:
On Fri, Sep 14, 2018 at 5:56 PM ToddAndMargo <> wrote:

>       'To opt into a non-nullable version of a type add the :D
>       "smiley" to it."
> This is confusing.  And I don't think correct, but I could be wrong.
> Curt stated it a lot better:
>        If I say "my Int $x",
>        $x is now an Int, but an undefined Int.
>        If I say "my Int $x = 42",
>        $x is an Int, but set to a defined value, 42.
> ":D" means that the variable is "defined".  "non-nullable" is
> a confusing way to state it.

Not exactly. "Defined" is a "now" thing; "non-nullable", via type smileys,
is an "always" thing. It is defined now, and it can never be undefined.

> To me ":D" means that the variable has something assigned to
> and ":U" means that the variable has yet to have anything
> assigned to it.
> If I were to rewrite this, I'd reverse D and U as that
> is the way they evolve.  All variables start out as :U.

This is the same misunderstanding: what is now, is not guaranteed to be so
in the future. :U and :D provide such guarantees. Merely being defined or
undefined right now says nothing about the future.

brandon s allbery kf8nh

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About