Skip to content

Commit e459ac8

Browse files
committed
Document .VAR
1 parent 1fa6313 commit e459ac8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/Language/mop.pod

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@
22
33
=TITLE Meta-Object Protocol
44
5+
=SUBTITLE Introspection and the Perl 6 Object System
6+
57
TODO
68
79
=head1 Metamethods
810
9-
TODO
11+
These are introspective macros that resemble method calls.
12+
13+
Note that if you want to call a method by the same name of an object, use
14+
quotes around the method name to call it indirectly:
15+
16+
class MY-CLASSES-ARE-ALL-CAPS {
17+
method WHY { "I DON'T KNOW" }
18+
}
19+
my $c = MY-CLASSES-ARE-ALL-CAPS.new;
20+
say $c.WHY # "(MY-CLASSES-ARE-ALL-CAPS)"
21+
say $c."WHY"() # "I DON'T KNOW"
1022
1123
=head2 X<WHAT|syntax,WHAT>
1224
@@ -40,4 +52,11 @@ The object has a valid concrete representation.
4052
4153
Returns the underlying C<Scalar> object, if there is one.
4254
55+
The presence of a C<Scalar> object indicates that the object is "itemized".
56+
57+
.say for (1, 2, 3); # not itemized, so "1\n2\n3\n"
58+
.say for [1, 2, 3]; # itemized, so "1 2 3\n"
59+
say (1, 2, 3).VAR ~~ Scalar; # False
60+
say [1, 2, 3].VAR ~~ Scalar; # True
61+
4362
=end pod

0 commit comments

Comments
 (0)