Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add few minor fixes.
Remove I<> that wasn't being rendered inside C<>, fix a typo, etc.
  • Loading branch information
uzluisf committed Oct 7, 2018
1 parent 651d20b commit ef85fe0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions doc/Type/Signature.pod6
Expand Up @@ -126,7 +126,7 @@ Please note that in the code above type constraints are enforced at two
different levels: the first level checks if it belongs to the type in which the
subset is based, in this case C<Int>. If it fails, a C<Type check> error is
produced. Once that filter is cleared, the constraint that defined the subset is
checked, producing a C<I<Constraint> type check> error if it fails.
checked, producing a C<Constraint type check> error if it fails.
X<|anonymous arguments>
Anonymous arguments are fine too, if you don't actually need to refer to a
Expand Down Expand Up @@ -200,7 +200,7 @@ too. Any C<where> clause on any parameter will be executed, even if it's
optional and not provided by the caller. In that case you may have to guard
against undefined values within the C<where> clause.
sub f(Int $a, UInt $i? where { !$i.defined or $i > 5 } ) { ... }
sub f(Int $a, UInt $i? where { !$i.defined or $i > 5 }) { ... }
=head3 Constraining slurpy arguments
Expand Down Expand Up @@ -255,7 +255,7 @@ and type objects (C<Int>). Consider the following code:
# (Str:D $: :$count!, *%_)
# (Str:D $: $limit, *%_)
# (Str:D $: *%_)»
say limit-lines "a \n b", Int # Always returns the max number of lines
say limit-lines "a \n b", Int; # Always returns the max number of lines
Here we really only want to deal with string instances, not type objects. To do
this, we can use the C<:D> type constraint. This constraint checks that the
Expand Down Expand Up @@ -297,11 +297,10 @@ Here's a more practical example:
sub can-turn-into(Str $string, Any:U $type) {
return so $string.$type;
}
say can-turn-into("3", Int);
say can-turn-into("6.5", Int);
say can-turn-into("6.5", Num);
say can-turn-into("a string", Num);
# OUTPUT: True True True False
say can-turn-into("3", Int); # OUTPUT: «True␤»
say can-turn-into("6.5", Int); # OUTPUT: «True␤»
say can-turn-into("6.5", Num); # OUTPUT: «True␤»
say can-turn-into("a string", Num); # OUTPUT: «False␤»
Calling C<can-turn-into> with an object instance as its second parameter
will yield a constraint violation as intended:
Expand Down Expand Up @@ -331,6 +330,8 @@ known collectively as I<type smileys>:
say Foo ~~ Any:D; # OUTPUT: «False␤»
say Foo ~~ Any:U; # OUTPUT: «True␤»
say Foo ~~ Any:_; # OUTPUT: «True␤»
# Checking an instance of a class
my $f = Foo.new;
say $f ~~ Any:D; # OUTPUT: «True␤»
say $f ~~ Any:U; # OUTPUT: «False␤»
Expand Down Expand Up @@ -399,7 +400,7 @@ object instance is always definite. Whether an object is a type
object/indefinite or an object instance/definite can be verified using the
L<DEFINITE|/language/mop#DEFINITE> (meta)method.
I<Definiteness> should be distinghuished from I<definedness>, which is concerned
I<Definiteness> should be distinguished from I<definedness>, which is concerned
with the difference between defined and undefined objects. Whether an object is
defined or undefined can be verified using the C<defined>-method, which is
implemented in class L<Mu|/type/Mu>. By default a type object is considered
Expand Down

0 comments on commit ef85fe0

Please sign in to comment.