Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds Attribute.gist refs #2632
  • Loading branch information
JJ committed Mar 2, 2019
1 parent 9d85ba6 commit 52132a7
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions doc/Type/Attribute.pod6
Expand Up @@ -7,10 +7,10 @@
class Attribute { }
In Perl 6 lingo, an I<attribute> refers to a per-instance/object storage slot.
An C<Attribute> is used to talk about classes' and roles' attributes on the
An C<Attribute> is used to talk about classes' and roles' attributes at the
meta level.
Normal usage of attributes does not require the user to use class Attribute
Normal usage of attributes does not require the user to use this class
explicitly.
The usual way to obtain an object of type C<Attribute> is by introspection:
Expand Down Expand Up @@ -245,6 +245,8 @@ using L<bless|/routine/bless>.
=head2 trait is rw
Defined as:
multi sub trait_mod:<is> (Attribute:D $attr, :$rw!)
Marks an attribute as read/write as opposed to the default
Expand All @@ -262,6 +264,27 @@ writable value.
CATCH { default { put .^name, ': ', .Str } };
# OUTPUT: «X::Assignment::RO: Cannot modify an immutable Any␤»
=head2 method gist
Defined as
multi method gist(Attribute:D:)
Returns the name of the type followed by the name of the attribute.
=for code
class Hero {
has @!inventory;
has Str $.name;
submethod BUILD( :$name, :@inventory ) {
$!name = $name;
@!inventory = @inventory
}
}
say Hero.^attributes(:local)[0]; # OUTPUT: «Positional @!inventory»
Since say implicitly calls C<.gist>, that is what produces the output here.
=end pod

# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 comments on commit 52132a7

Please sign in to comment.