Is there a canonical form of Perl6?

The standard Perl6 grammar is relatively large. Although this facilitates expression when mastered, it creates a barrier to mastery. For example, basic constructs often have several forms that support different programming paradigms. A prime example is the variety of syntaxes for creating Pairs :

Pair.new('key', 'value'); # The canonical way 
'key' => 'value';         # this... 
:key<value>;              # ...means the same as this 
:key<value1 value2>;      # But this is  key => <value1 value2> 
:foo(127);                # short for  foo => 127 
:127foo;                  # the same   foo => 127

Pay particular attention to the comment on the first form: "The canonical path."

Another example is the documentation formethod make :

This is just a little sugar for $/.made = $ast which is a very common operation in actions.

Is there a canonical form that can be deduced for a Perl6 program so that, having mastered canonical literacy, you can check any Perl6 program in this form to understand it?

+4
1

, Perl6 ( roast) , "". , , - /. .new() Pair Pair. , , , , . - .

.perl() . Perl:

> Pair.new('key', 'value').perl
:key("value")
> ('key' => 'value').perl
:key("value")
> (:key<value>).perl
:key("value")
+7

Source: https://habr.com/ru/post/1678039/


All Articles