Skip to content

Commit

Permalink
Adds @jnthn's rules in #1092
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jun 7, 2018
1 parent 237285a commit 3044b0e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
15 changes: 9 additions & 6 deletions doc/Language/nativetypes.pod6
Expand Up @@ -69,17 +69,20 @@ characteristic of being usable in L<NativeCall> functions.
=end table
These types have a fixed size representation which is independent of the
platform, and thus can be used safely for those calls. Nothing prevents us from
using it in any other environment, if we so wish. In the same way as the types
above, this size will have to be taken into account when assigning values to
variables of this type:
platform, and thus can be used safely for those native calls. Nothing prevents
us from using them in any other environment, if we so wish. In the same way as
the types above, this size will have to be taken into account when assigning
values to variables of this type:
my byte $intillo = 257;
say $intillo; # OUTPUT: «1␤»
Since C<byte> is able to hold only 8 bits, it will I<wrap over> and assign the result of the original value modulo 256, which is what is shown.
Since C<byte> is able to hold only 8 bits, it will I<wrap over> and assign the
result of the original value modulo 256, which is what is shown.
The main difference between types with declared native size and those without is the use of X<is nativesize> in their declaration. For instance, C<int8> is declared in this way:
The main difference between types with declared native size and those without is
the use of X<is nativesize> in their declaration. For instance, C<int8> is
declared in this way:
my native int8 is repr('P6int') is Int is nativesize( 8) { }
Expand Down
38 changes: 38 additions & 0 deletions doc/Language/newline.pod6
@@ -0,0 +1,38 @@
=begin pod :tag<perl6>
=TITLE Newline handling in Perl 6.
=SUBTITLE How the different newline characters are handled, and how to change the behavior.
Different operating systems use different characters, or combinations of them,
to represent the transition to a new line. Every language has its own set of
rules to handle this. Perl 6 has the following ones:
=item C<\n> in a string literal means Unicode codepoint 10.
=item The default L<nl-out|/routine/nl-out> that is appended to a string by say
is also C<\n>
=item On output, when on Windows, the encoder will by default transform a C<\n>
into a C<\r\n> when it's going to a file, process, or terminal (it won't do this
on a socket, however).
=item On input, on any platform, the decoder will by default normalize C<\r\n>
into C<\n> for input from a file, process, or terminal (again, not socket).
=item These above two points together mean that you can - socket programming
aside - expect to never see a C<\r\n> inside of your program (this is how things
work in numerous other languages too).
X<|:translate-nl>
=item The L<C<:$translate-nl>|/type/Encoding#method_decoder> named parameter
exists in various places to control this transformation, for instance, in
L<C<Proc::Async.new>|/type/Proc::Async#method_new> and
L<C<Proc::Async.Supply>|/type/Proc::Async#method_Supply>.
=item A C<\n> in the C<regex|/language/regexes> language is logical, and will match a C<\r\n>.
=end pod

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

0 comments on commit 3044b0e

Please sign in to comment.