:D is a type constraint requiring an instantiated (or defined) object of the given type (or a subtype of it).
:U is a type constraint saying you have a container specified for the given type that hasn't been instantiated. So if you have my Int $a; you have said this should hold and Int but it's currently valueless (undefined). It would match Int:U in a signature. Assign 5 to it and it's now defined and matches Int:D in a signature. On Fri, 14 Sep 2018, 11:44 Todd Chester, <toddandma...@zoho.com> wrote: > >> On Fri, 14 Sep 2018, 11:22 Todd Chester, <toddandma...@zoho.com > >> <mailto:toddandma...@zoho.com>> wrote: > >> > >> Hi All, > >> > >> I adore the "kv" method: > >> > >> $ p6 'for "abc\n23\n4.56".lines.kv -> $i, $j { say "$i $j" };' > >> 0 abc > >> 1 23 > >> 2 4.56 > >> > >> So, I decided to go and look at: > >> https://docs.perl6.org/routine/kv > >> > >> multi method kv(Any:U: -->List) > >> multi method kv(Any:D: -->List) > >> > >> > >> Okay, here is what I see: > >> > >> "method" is .foo style of a routine > >> > >> "Any:U:" and "Any:D:" are what goes in front of .foo > >> and it can be of type "Any". > >> > >> https://docs.perl6.org/type/Any > >> > >> ":D" mean constrained, meaning it much have something > >> > >> What is ":U"? > >> > >> Whatever ":U", how can it be both? > >> > >> The second ":" is the delimiter for what goes in front of the .foo, > >> meaning it has finished its declaration of what that in front is. > >> Kind of like a comma. > >> > >> "-->List" mean something is returned of type "List" > >> https://docs.perl6.org/type/List > >> > >> 0 abc > >> 1 23 > >> 2 4.56 > >> > >> > >> How have I done so far? > >> > >> > >> And is there a list somewhere of the meanings of ":U" and ":D" > >> and such so the next time I see one that I do not recognize, > >> I can look it up? > >> > >> Many thanks, > >> -T > >> > > > On 09/14/2018 03:28 AM, Simon Proctor wrote: > > :D means a defined value. So it's when you have an instance. :U is > > undefined so it's when you call kv as a classethod. > > > > Pair.kv would be :U. > > (A => "b").kv would be :D > > > > > > Hi Simion, > > I am not following. What do you mean by "undefined"? > > I can't make head or tails out of "Pair" > https://docs.perl6.org/type/Pair > > I thought ":D" meant "constrained"? > > Yours in confusion , > -T >