Skip to content

Commit

Permalink
Changes slightly the object invocation example
Browse files Browse the repository at this point in the history
To introduce in a natural way the indirect invocant syntax, closing #2131.

As usual, please reopen and/or edit subject if it is not addressed
satisfactorily.
  • Loading branch information
JJ committed Jun 29, 2018
1 parent 0086826 commit db0f520
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions doc/Language/objects.pod6
Expand Up @@ -18,7 +18,8 @@ types do not have the same capabilities as objects, if you call methods on them,
they are automatically I<boxed> into normal objects.
Everything that is not a I<native> value is an <object>.
Objects do allow for both L<inheritance|https://en.wikipedia.org/wiki/Object-oriented_programming#Inheritance_and_behavioral_subtyping> and L<encapsulation|https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation>.
Objects do allow for both L<inheritance|https://en.wikipedia.org/wiki/Object-oriented_programming#Inheritance_and_behavioral_subtyping> and
L<encapsulation|https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation>.
=head1 Using Objects
Expand Down Expand Up @@ -278,7 +279,7 @@ You may write your own accessors to override any or all of the autogenerated one
travelers => <þor Freya> );
$trip.notes("First steps");
$trip.notes("Almost there");
notes $trip: "Almost there";
print $trip;
# OUTPUT:
Expand All @@ -292,6 +293,13 @@ The declared multi method C<notes> overrides the auto-generated
methods implicit in the declaration of C<$.notes>, using a different
signature for reading and writing.
Please note that in C<notes $trip: "Almost there"> we are using X<indirect
invocant syntax>, which puts first the method name, then the object, and then,
separated by a colon, the arguments: C<method invocant: arguments>. We can use
this syntax whenever it feels more natural than the classical
period-and-parentheses one. It works exactly in the same way.
Method names can be resolved at runtime with the C<.""> operator.
class A { has $.b };
Expand Down

0 comments on commit db0f520

Please sign in to comment.