｢Man is amazing, but he is not a masterpiece｣

Is different than the other two, it can be thought of as short for

Q ｢Man is amazing, but he is not a masterpiece｣

While the others are short for

qq “Man is amazing, but he is not a masterpiece”

Which is short for

Q :qq “Man is amazing, but he is not a masterpiece”
Q :double “Man is amazing, but he is not a masterpiece”

Which is also short for

Q :s :a :h :f :b :c “Man is amazing, but he is not a masterpiece”
Q :scalar :array :hash :function :backslash :closure “Man is amazing, but he is not a masterpiece”

For more information see the [Quoting Constructs](https://docs.perl6.org/language/quoting) documentation.

---

There are modules for [debugging and tracing](https://github.com/jnthn/grammar-debugger) Grammars.

A regex is just a special kind of method by the way.

say Regex.^mro;
# ((Regex) (Method) (Routine) (Block) (Code) (Any) (Mu))

Which is part of the reason it doesn't have some of the niceties of parser generators built-in yet. The main reason is it got to a working state, then other features needed more designing at that point.

---

# Perl 5
/(Male|Female) (?:[Cc][Aa][Tt]|[Dd][Oo][Gg])/
# is better written as
/(Male|Female) (?i:cat|dog)/

In Perl 6 you can turn on and off sigspace mode

/:s (:!s Male | Female ) [:!s:i cat | dog ]/
# or fully spelled out
/:sigspace (:!sigspace Male | Female ) [:!sigspace :ignorecase cat | dog ]/

# or just use spaces more sparingly
/:s ( Male| Female) [:i cat| dog]/

Note that in this case it is more like

/( Male | Female ) \s+ [:i cat | dog ]/

In other contexts it could be slightly different. Basically it ignores insignificant whitespace.

Note that `( a || b )` is more like the Perl 5 behaviour, but `( a | b )` tries both in parallel with longest literal match.

Regular expressions are also the reason `:35minutes` is in the language by the way

say 'a ab abc' ~~ m:3rd/ \S+ /;
# ｢abc｣

Rather than make it a special syntax, it was generalized so it can be used everywhere.

---

The asterix in a Term position turns into a Whatever, when that is part of an expression it turns into a positional parameter of a WhateverCode.

$deck.pick(*); # randomized deck of cards
$deck.pick(Whatever.new); # ditto

$dice.roll(*); # infinite list of random rolls of a die
$dice.roll(Whatever.new); # ditto

%a.sort( *.value ); # sort the Pairs by value (rather than key then value)
%a.sort( -> $_ { .value } ); # ditto

Note that the last asterix was part of an expression, while the others weren't.

my &shuffle = *.pick(*); # only the first * represents a parameter to the lambda
# the other is an argument to the pick method

The main reason I think for its addition to the language is for indexing in an array

@a[ * - 1 ];

Rather than make it a special syntax exclusively for index operations, it was made a general lambda creation syntax.

I will agree that it takes some getting used to, but it is not intractable. WhateverCode lambdas should also only be used for very short code, as it can get difficult to understand in a hurry.

---

A `$_` inside of `{ }` creates a bare block lambda, basically this removes the specialness of Perl 5's `grep` and `map` keywords.

There is a similar feature of placeholder parameters `{ $^a <=> $^b }` to remove the specialness of Perl 5's `sort` keyword.

Another feature is pointy block, which removes the specialness of a `for` loop iterator value syntax.

# Perl 5 (this is the only place where this is valid)
for my $line (<>) { say $line }

# Perl 6
for lines() -> $line { say $line }

# not special
lines().map( -> $line { say $line } );

# really not special
if $a.method-call -> $result { say $result }

---

There is more to NativeCall that you haven't discovered yet.

For example, you can directly declare an external C function as a method in a class, and expose it with a different name. (if the first parameter is the instance)

Also it doesn't matter what you put in the code block for a NativeCall sub, as long as it parses. That is why it doesn't matter if you put a Whatever star (asterix) there or a stub-code ellipsis `...` in it. (you can also leave it empty)

use NativeCall;
sub double ( --> size_t ) is native() is symbol<fork> { say 'Hello World' }

say double;
say '$*PID == ',$*PID;
# 1555
# 0
# $*PID == 1552
# $*PID == 1555

---

Supplies can be pattern matched, just use `grep` on them as if they were a list. It in turn returns a Supply. You can also call `map`, `first`, `head`, and `tail` on them. Basically every List method is also on a Supply, along with special methods like `delayed`.

---

A lot about what you talked about with lists, and itemization is something that does take some time to get used to. It does get easier, but is always something you have to be cognizant of. Sort of like returning lists from subroutines are from Perl 5. It allows control over flattening that isn't available in Perl 5.