Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Clarification and reflow
  • Loading branch information
JJ committed Mar 2, 2019
1 parent 2ce0f43 commit 2b8a006
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
12 changes: 6 additions & 6 deletions doc/Type/Proxy.pod6
Expand Up @@ -6,13 +6,13 @@
class Proxy {}
A Proxy is an object that allows you to execute whenever a value is retrieved
from a container (C<FETCH>) or when it is set (C<STORE>). Please note that
C<Proxy> can introduce mutability at places where it would break behavior,
e.g. in C<Hash> keys.
A Proxy is an object that allows you to set a hook that executes whenever a
value is retrieved from a container (C<FETCH>) or when it is set (C<STORE>).
Please note that C<Proxy> can introduce mutability at places where it would
break behavior, e.g. in C<Hash> keys.
To create a container that returns twice of what was stored in it, you do
something like this:
To create a container that returns twice what was stored in it, you do something
like this:
sub double() is rw {
my $storage = 0;
Expand Down
19 changes: 10 additions & 9 deletions doc/Type/Signature.pod6
Expand Up @@ -315,8 +315,9 @@ say can-turn-into("a string", 123);
# OUTPUT: «Parameter '$type' of routine 'can-turn-into' must be a type object
# of type 'Any', not an object instance of type 'Int'...»
For explicitly indicating the normal behavior, C<:_> can be used, but this is
unnecessary. C<:(Num:_ $)> is the same as C<:(Num $)>.
For explicitly indicating the normal behavior, that is, not constraining whether
the argument will be an instance or a type object, C<:_> can be used, but this
is unnecessary. C<:(Num:_ $)> is the same as C<:(Num $)>.
To recap, here is a quick illustration of these type constraints, also
known collectively as I<type smileys>:
Expand Down Expand Up @@ -348,13 +349,13 @@ document further elaborates on the concepts of instances and type
objects and discovering them with the C<.DEFINITE> method.
Keep in mind all parameters have values; even optional ones have default
defaults that are the type object of the constrained type for explicit
type constraints. If no explicit type constraint exists, the default
default is an L<Any|/type/Any> type object for methods, submethods, and
subroutines, and a L<Mu|/type/Mu> type object for blocks. This means that if you
use the C<:D> type smiley, you'd need to provide a default value or
make the parameter required. Otherwise, the default default would be a
type object, which would fail the definiteness constraint.
defaults that are the type object of the constrained type for explicit type
constraints. If no explicit type constraint exists, the default default is an
L<Any|/type/Any> type object for methods, submethods, and subroutines, and a
L<Mu|/type/Mu> type object for blocks. This means that if you use the C<:D>
type smiley, you'd need to provide a default value or make the parameter
required. Otherwise, the default default would be a type object, which would
fail the definiteness constraint.
sub divide (Int:D :$a = 2, Int:D :$b!) { say $a/$b }
divide :1a, :2b; # OUTPUT: «0.5␤»
Expand Down

0 comments on commit 2b8a006

Please sign in to comment.