develooper Front page | perl.perl6.language | Postings from December 2008

how to write literals of some Perl 6 types?

Thread Previous | Thread Next
From:
Darren Duncan
Date:
December 1, 2008 18:21
Subject:
how to write literals of some Perl 6 types?
Message ID:
49349BB3.5070702@darrenduncan.net
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
   Str      # 'Hello world'
   Pair     # :key<val> or key=>val
   Range    # 1..10
   Junction # 'a'|'b'|'c' or 'e'&'f' or any(5,20) or none(60,87)
   Seq      # (5,6,7)
   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

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?

The above is my main question, but also I wonder about how to make an anonymous 
literal of a KeyHash|KeySet|KeyBag.  And also how does one specify a Rat vs a 
Num or what does "18.2" or "4/3" actually get you?  And also is there such a 
thing as a Buf literal and if so how do you write one?

Thank you. -- Darren Duncan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About