Skip to content

Commit 462336d

Browse files
committed
Adds example of dynamic calls closes #115
1 parent 8d4f609 commit 462336d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/Language/packages.pod6

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,33 @@ C<CORE>). The current package is searched last.
132132
Use the C<MY> pseudopackage to limit the lookup to the current lexical scope,
133133
and C<OUR> to limit the scopes to the current package scope.
134134
135+
In the same vein, class and method names can be interpolated too.
136+
137+
role with-method {
138+
method a-method { return "in-a-method of " ~ $?CLASS.^name };
139+
}
140+
141+
class a-class does with-method {
142+
method another-method { return 'in-another-method' };
143+
}
144+
145+
class b-class does with-method {};
146+
147+
my $what-class='a-class';
148+
149+
say ::($what-class).a-method;
150+
$what-class = 'b-class';
151+
say ::($what-class).a-method;
152+
153+
my $what-method='a-method';
154+
say a-class."$what-method"();
155+
$what-method='another-method';
156+
say a-class."$what-method"();
157+
158+
X<|::($c).m>
159+
X<|A."$m"()>
160+
161+
135162
=head2 Direct lookup
136163
137164
To do direct lookup in a package's symbol table without scanning, treat the

0 commit comments

Comments
 (0)