Skip to content

Commit 10ba037

Browse files
authored
Merge pull request #2 from perl6/master
update
2 parents d8c2b04 + 909627c commit 10ba037

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

doc/Language/experimental.pod6

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,53 @@ not yet rendered properly.
2222
2323
=item X<B<cache>|cache> [TBD]
2424
25-
=item X<B<macros>|macros> [TBD]
26-
2725
=item X<B<pack>|pack> [TBD]
2826
27+
=head2 X<B<macros>|macros>
28+
29+
L<Macros|https://en.wikipedia.org/wiki/Macro_(computer_science)> are
30+
code-generating routines, that generate code in compile time, before the program
31+
is executed. In Perl 6 its use is still experimental and it needs to be turned
32+
on via the pragma
33+
34+
use experimental :macros;
35+
36+
Macro processing happens during parsing time. A macro generates an abstract
37+
syntax tree, which is grafted into the program syntax tree. C<quasi> is the
38+
routine that performs this task.
39+
40+
=begin code :skip-test<need use experimental>
41+
macro does-nothing() {
42+
quasi {}
43+
};
44+
does-nothing; # OUTPUT: «»
45+
=end code
46+
47+
X<|quasi (macros)>
48+
Macros are a kind of routine, so they can take arguments in exactly the same
49+
way, and act also in almost the same way.
50+
51+
=begin code :skip-test<need use experimental>
52+
macro is-mighty( $who ) {
53+
quasi { "$who is mighty!"}
54+
};
55+
say is-mighty "Freija"; # OUTPUT: « "Freija" is mighty!␤»
56+
=end code
57+
58+
X<|unquoting (macros)>
59+
X<|{{{}}} (macros)>
60+
"Almost" accounts for the fact that the argument is inserted as a literal,
61+
including the quotes. Please note that we can also eliminate the parentheses for
62+
a macro call, following the same rules as a routine. You can use the unquoting
63+
construct C<{{{}}}> to get rid of this kind of thing:
64+
65+
=begin code :skip-test<need use experimental>
66+
macro is-mighty( $who ) {
67+
quasi { {{{$who}}} ~ " is mighty!"}
68+
};
69+
say is-mighty "Freija";# OUTPUT: «Freija is mighty!␤»
70+
=end code
71+
2972
3073
=end pod
3174

doc/Type/Distribution.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Interface for objects that provide API access mapping META6 data to the files its represents.
1010
Objects that fulfill the C<Distribution> role can be read by e.g. L<CompUnit::Repository::Installation>.
1111
Generally a C<Distribution> provides read access to a set of modules and meta data. These
12-
may be backed by the file system (L<Distribution::Path>, L<Distribution::Hash>) but could
12+
may be backed by the filesystem (L<Distribution::Path>, L<Distribution::Hash>) but could
1313
also read from a e.g. tar file or socket.
1414
1515
=head1 Required Methods

doc/Type/Distribution/Hash.pod6

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
77
class Distribution::Hash does Distribution::Locally { }
88
9-
A L<Distribution|/type/Distribution> implementation backed by the file system. It does not require a
10-
a C<META6.json> file, essentially providing a lower level C<Distribution::Path>.
9+
A L<Distribution|/type/Distribution> implementation backed by the filesystem. It does not require a
10+
C<META6.json> file, essentially providing a lower level C<Distribution::Path>.
1111
1212
=head1 Methods
1313
@@ -33,4 +33,4 @@ path as it would be found in the meta data such as C<lib/Foo.pm6> or C<resources
3333
3434
=end pod
3535

36-
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
36+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

doc/Type/Distribution/Path.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
class Distribution::Path does Distribution::Locally { }
88
9-
A L<Distribution|/type/Distribution> implementation backed by the file system. It requires a
9+
A L<Distribution|/type/Distribution> implementation backed by the filesystem. It requires a
1010
C<META6.json> file at its root.
1111
1212
=head1 Methods
@@ -34,4 +34,4 @@ path as it would be found in the meta data such as C<lib/Foo.pm6> or C<resources
3434
3535
=end pod
3636

37-
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
37+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)