Skip to content

Commit 0e60c9a

Browse files
committed
Pair and Blob literals
1 parent b7d5b91 commit 0e60c9a

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

lib/Language/syntax.pod

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ of comment
128128
say 'code again';
129129
=end code
130130
131+
=comment TODO: identifiers
132+
131133
=head1 Statements and Expressions
132134
133135
Perl 6 programs are made of lists of statements. A special case of a statement
@@ -212,6 +214,12 @@ String literals are surrounded by quotes:
212214
213215
See L<quoting|/language/quoting> for many more options.
214216
217+
=head3 Blob literals
218+
219+
Binary data of L<type Blob|/type/Blob> can be written as C<:base{data}>, so
220+
221+
:16<DE AD BE EF>
222+
215223
=head3 Number literals
216224
217225
Number literals are generally specified in base ten, unless a prefix like
@@ -266,11 +274,40 @@ a real and an imaginary number:
266274
1+2i
267275
6.123e5i
268276
269-
=begin comment
270277
271278
=head3 Pair literals
272279
273-
TODO
280+
Pairs are made of a key and a value, and there are two basic forms for
281+
constructing them: C<< key => 'value' >> and C<:key('value')>.
282+
283+
=head4 Arrow pairs
284+
285+
Arrow pairs can have an expression or an identifier on the left-hand side:
286+
287+
identifer => 42
288+
"identifier" => 42
289+
('a' ~ 'b') => 1
290+
291+
=head4 Adverbial pairs (colon pairs)
292+
293+
Short forms without explicit values:
294+
295+
my $thing = 42;
296+
:$thing # same as thing => $thing
297+
:thing # same as thing => True
298+
:!thing # same as thing => False
299+
300+
The variable form also works with other sigils, like C<:&callback> or
301+
C<:@elements>.
302+
303+
Long forms with explicit values:
304+
305+
:thing($value) # same as thing => $value
306+
:thing<quoted list> # same as thing => <quoted list>
307+
:thing['some', 'values'] # same as thing => ['some', 'values']
308+
:thing{a => 'b'} # same as thing => { a => 'b' }
309+
310+
=begin comment
274311
275312
=head3 Array literals
276313

0 commit comments

Comments
 (0)