Darren Duncan wrote:
> Hello,
>
> I'm wondering how to write anonymous value literals of some Perl 6 basic
> types,
> and I didn't see mention of this in synopsis 2.
>
> Now, with some basic types, I know how to do it, examples:
>
> Bool # Bool::True
> Int # 42 or 0x17 or :12<AB9>
> Rat|Num # 18.2 or :8<53.07> or 4/3
Num 1/2
Rat 1 div 2
> Seq # (5,6,7)
I'm not sure if that's a Seq or a List.
> Array # [8,9,10]
> Hash # { :a<b>, :c<d> } or { a => 'b', c => 'd' }
>
> Correct me if I'm wrong with the above.
>
> But some significant ones I don't know and really want to know:
>
> Bit
> Blob
> Set
> Bag
> Mapping
I guess that Mapping is analog to the List/Seq case:
:a(2), :a<b>;
> How does one write anonymous value literals of those types? And I mean
> directly, not by writing a literal of some other type and using a conversion
> function to derive the above?
Type.new(...)
> The above is my main question, but also I wonder about how to make an
> anonymous
> literal of a KeyHash|KeySet|KeyBag.
I think that's (from a language user's point) the "wrong" question.
These types are not designed to be very much visible for the user, but
more like helpers. (Please correct me if I'm wrong here).
> And also how does one specify a Rat vs a
> Num or what does "18.2" or "4/3" actually get you?
I think that S03 elaborates on that. See also my example above.
Cheers,
Moritz