Skip to content

Commit

Permalink
Add adverb and colon pair to glossary
Browse files Browse the repository at this point in the history
  • Loading branch information
skids committed Apr 4, 2015
1 parent 26335b6 commit ae713fe
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/Language/glossary.pod
Expand Up @@ -21,6 +21,25 @@ Note that it is still allowed to have a name
my $s = anon sub triple($x) { 3 * $x }
say $s.name; # triple
=head1 Adverb
Generically, an adverb is a named argument to a function. There are also
some specific syntax forms that allow adverbs to be tucked into some
convenient places:
q:w"foo bar" # ":w" is a Quotelike form modifier adverb
m:g/a|b|c/ # ":g" is also
4 +> 5 :rotate # ":rotate" is an operator adverb
@h{3}:exists # ":exists" is also, but is known as a subscript adverb
Adverbs are usually expressed with colon pair notation, and for this
reason colon pair notation is also known as the adverbial pair form:
:a(4) # Same as "a" => 4
Some other forms that use a colon in ways that have adverb-like semantics
are called adverbial forms.
=head1 Autothreading
Autothreading is what happens if you pass a junction to a sub that expects a
Expand All @@ -40,6 +59,28 @@ C<f(1|2|3)> call to be internally executed as C<f(1)|f(2)|f(3)>, and the
resulting junction is C<2|4|6>. This process of separating junction
arguments into multiple calls to a function is called I<autothreading>.
=head1 Colon Pair and Colon List
A colon pair is a shorthand syntax used to create or visually present
a Pair object. The two most common forms are:
:a(4) # Same as "a" => 4, same as Pair.new(:key<a>,:value(5))
:a<4> # Same as "a" => "4", same as Pair.new(:key<a>,:value<5>)
This is also known as the adverbial pair form. Note: when the part after
the colon and before the brackets is not a legal identifier, other
semantics apply, not all of which produce Pair objects.
Two other common forms are:
:a # Same as :a(True)
:!a # Same as :a(False)
A colon list just means that a list that contains only colon pairs,
does not need commas, or even spaces:
:a(4):c:!d:c # Same as a => 4, c => True, d => False, c => True
=head1 Constraint
Constraints are a restriction placed on acceptable types for a parameter
Expand Down

0 comments on commit ae713fe

Please sign in to comment.