Skip to content

Commit de32476

Browse files
committed
Reflow and adjust links
Refs #2568
1 parent a7c21ad commit de32476

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

doc/Language/nativecall.pod6

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ my $result = clock_gettime( 0, $this-time);
125125
say "$result, $this-time"; # OUTPUT: «0, timespec<65385480>␤»
126126
=end code
127127
128-
The L<original function we are calling,
128+
The original function we are calling,
129129
L<clock_gettime|https://linux.die.net/man/3/clock_gettime>, uses a pointer to
130-
the C<timespec> struct as second argument. We declare it as a L<class|/syntax/class> here, but
131-
specify its representation as C<is repr('CStruct')>, to indicate it corresponds
132-
to a C data structure. When we create an object of that class, we are creating
133-
exactly the kind of pointer C<clock_gettime> expects. This way, data can be
134-
transferred seamlessly to and from the native interface.
130+
the C<timespec> struct as second argument. We declare it as a
131+
L<class|/syntax/class> here, but specify its representation as C<is
132+
repr('CStruct')>, to indicate it corresponds to a C data structure. When we
133+
create an object of that class, we are creating exactly the kind of pointer
134+
C<clock_gettime> expects. This way, data can be transferred seamlessly to and
135+
from the native interface.
135136
136137
137138
=head1 Basic use of pointers

doc/Language/nativetypes.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ used instead of the types C<int> or C<num> listed above.
3131
3232
In general, these variables will behave in the same way as regular
3333
scalar variables, in a behavior that is called
34-
L<I<auto-boxing>|/language/numerics#Auto-Boxing>; however, there are
34+
L<I<auto-boxing>|/language/numerics#Auto-boxing>; however, there are
3535
some differences, since what you are actually declaring is how they will
3636
be represented, not their actual type. The first one is that their type
3737
will be actually their equivalent type, not their native type.
@@ -201,4 +201,4 @@ Which would print the five elements of the array, as it should be expected.
201201
202202
=end pod
203203

204-
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
204+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

doc/Language/numerics.pod6

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ say Buf.new(1000, 2000, 3000).List; # OUTPUT: «(232 208 184)␤»
567567
say my uint8 @a = 1000, 2000, 3000; # OUTPUT: «232 208 184␤»
568568
=end code
569569
570-
=head2 Auto-Boxing
570+
=head2 Auto-boxing
571571
572572
While they can be referred to as "native I<types>", native numerics are not
573573
actually classes that have any sort of methods available. However, you I<can>
@@ -595,9 +595,9 @@ my int $a-native = -42;
595595
{ for ^1000_000 { $a-native.abs }; say now - ENTER now } # OUTPUT: «0.938720␤»
596596
=end code
597597
598-
As you can see above, the native variant is more than twice slower. The reason is the method
599-
call requires the native type to be boxed, while no such thing is needed in the non-native
600-
variant, hence the performance loss.
598+
As you can see above, the native variant is more than twice slower. The reason
599+
is the method call requires the native type to be boxed, while no such thing is
600+
needed in the non-native variant, hence the performance loss.
601601
602602
In this particular case, we can simply switch to a subroutine form of L<abs|/routine/abs>, which can work
603603
with native types without boxing them. In other cases, you may need to seek out other solutions
@@ -621,13 +621,13 @@ pragma).
621621
622622
=head2 Native dispatch
623623
624-
It is possible to have native candidates alongside non-native candidates to, for example,
625-
offer faster algorithms with native candidates when sizes are predictable, but to fallback
626-
to slower non-native alternatives otherwise. The following are the rules concerning multi-dispatch
627-
involving native candidates.
624+
It is possible to have native candidates alongside non-native candidates to, for
625+
example, offer faster algorithms with native candidates when sizes are
626+
predictable, but to fallback to slower non-native alternatives otherwise. The
627+
following are the rules concerning multi-dispatch involving native candidates.
628628
629-
First, the size of the native type does not play a role in dispatch and an C<int8> is considered
630-
to be the same as C<int16> or C<int>:
629+
First, the size of the native type does not play a role in dispatch and an
630+
C<int8> is considered to be the same as C<int16> or C<int>:
631631
632632
=begin code
633633
multi foo(int $x) { say "int" }
@@ -640,10 +640,10 @@ foo my int $x = 42;
640640
=end code
641641
642642
Second, if a routine is an C<only>—i.e. it is not a
643-
L«C<multi>|/language/functions#Multi-dispatch»—that
644-
takes a non-native type but a native one was given during the call, or vice-versa, then the argument
645-
will be auto-boxed or auto-unboxed to make the call possible. If the given
646-
argument is too large to fit into the native parameter, an exception will be thrown:
643+
L«C<multi>|/language/functions#Multi-dispatch»—that takes a non-native type but
644+
a native one was given during the call, or vice-versa, then the argument will be
645+
auto-boxed or auto-unboxed to make the call possible. If the given argument is
646+
too large to fit into the native parameter, an exception will be thrown:
647647
648648
=begin code
649649
-> int {}( 42 ); # OK; auto-unboxing
@@ -652,18 +652,20 @@ argument is too large to fit into the native parameter, an exception will be thr
652652
-> Int {}( my int $ = 42 ); # OK; auto-boxing
653653
=end code
654654
655-
When it comes to L«C<multi>|/language/functions#Multi-dispatch» routines, native arguments
656-
will always be auto-boxed if no native candidates are available to take them:
655+
When it comes to L«C<multi>|/language/functions#Multi-dispatch» routines, native
656+
arguments will always be auto-boxed if no native candidates are available to
657+
take them:
657658
658659
=begin code
659660
multi foo (Int $x) { $x }
660661
say foo my int $ = 42; # OUTPUT: «42␤»
661662
=end code
662663
663-
The same luxury is not afforded when going the other way. If only a native candidate is
664-
available, a non-native argument will I<not> be auto-unboxed and instead an exception indicating
665-
no candidates matched will be thrown (the reason for this asymmetry is a native type can always
666-
be boxed, but a non-native may be too large to fit into a native):
664+
The same luxury is not afforded when going the other way. If only a native
665+
candidate is available, a non-native argument will I<not> be auto-unboxed and
666+
instead an exception indicating no candidates matched will be thrown (the reason
667+
for this asymmetry is a native type can always be boxed, but a non-native may be
668+
too large to fit into a native):
667669
668670
=begin code
669671
multi f(int $x) { $x }

doc/Type/Variable.pod6

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ introspect and manipulate variables.
1515
1616
=head1 Traits
1717
18-
X<|is default (Variable)>
19-
=head2 X<Trait is default>
18+
=head2 X<Trait is default|is default (Variable)>
2019
2120
Sets the default value with which a variable is initialized, and to which it is
2221
reset when L<Nil|/type/Nil> is assigned to it. Trait arguments are evaluated at
@@ -98,4 +97,4 @@ Returns the name of the variable, including the sigil.
9897
9998
=end pod
10099

101-
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
100+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)