Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Grammatical corrections and a couple of extra defs
  • Loading branch information
Hayden Stainsby committed May 12, 2012
1 parent 0c0d226 commit 0936234
Showing 1 changed file with 49 additions and 35 deletions.
84 changes: 49 additions & 35 deletions docs/tablet-2-basic-syntax.txt
Expand Up @@ -20,13 +20,12 @@ or [**class**](appendix-a-index.html#class). That marks your code as Perl 6
Perl 5 and 6 in one source file.

To even that little obstacle, you can leave out the usual `use strict;` and
`use warnings;` in front of every script, because thats now default.
`use warnings;` in front of every script, because that is now the default.
Also `use utf8;` is obsolete since any Perl 6 source code is always treated
as UTF-8 and any [*unicode*](appendix-g-glossary.html#unicode) character can
be used anywhere in the code. Even the features of the pragmas `constant` and
`vars` are now part of the core language.

Also the functionality of many useful and famous modules like Moose
Also the functionality of many useful and famous modules like Moose
(object system), Parse::RecDescent++, exception handling,
List::\[More\]Utils, Export, English an advanced pretty printer and
Expand Down Expand Up @@ -72,8 +71,8 @@ compiler to ignore the rest of the line.
Multi Line
----------

If many lines has to be commented,
use "**[\#\`](appendix-a-index.html#pound-apostrophe)**"
Many lines can be commented by using
"**[\#\`](appendix-a-index.html#pound-apostrophe)**"
followed by any pair of braces that surround the comment.

$things = #`( I wonder how many of these
Expand All @@ -84,10 +83,10 @@ Documenting Comments
--------------------

When adding an equal sign after the pound like
**[#=](appendix-a-index.html#pound-equal)**, it can be used to comment
a subroutine or method that has this description stored.
It's accessible via the *[WHY](#WHY-introspection)* introspection method
of the routine object.
**[#=](appendix-a-index.html#pound-equal)**, a comment about the following
a subroutine or method is stored.
This comment is accessible via the *[WHY](#WHY-introspection)* introspection
method of the routine object.

#= ...
sub {
Expand Down Expand Up @@ -117,7 +116,7 @@ Quoting

Quoting, like [regular expression](tablet-9-regexes.html), is a sublanguage
inside the main language with its own syntactical rules. It is parsed
by a special grammar as to be found in the [special
by a special grammar which can be found in the [special
variable](appendix-b-grouped.html#special-variables) `$~Quote`. The
operator with the same name (the generic quoting operator `Q`) does
almost nothing, just provides a mechanism to mark the beginning and
Expand All @@ -128,9 +127,9 @@ end of text sequence.
Delimiter
---------

The examples in this chapter use almost every time slashes for that
purpose, but any not alphanumerical character or pair of matching
(bracing) character can be used as well.
The examples in this chapter use slashes as the delimier in almost
all cases, however any non-alphanumeric character or pair of matching
(bracing) characters can be used as well.

Q /.../ or Q |...| or Q *...* or Q "..." or Q[...] ...

Expand Down Expand Up @@ -201,10 +200,10 @@ following are synonyms:
'...'


The backslash (\\) liberates here just itself and the single quote
from its special meaning. Or to put it simple \\\\ translates (or
interpolates) to \\ and \\' to '. For anything more you need
additional adverbs.
The backslash (\\) here is only required to delimite itself and
the single quote from its special meaning. Or to put it simply \\\\
translates (or interpolates) to \\ and \\' to '. For anything more
you need additional adverbs.

'Welcome in Larry\'s madhouse'
'\'\\'; # string contains: '\
Expand All @@ -215,8 +214,8 @@ additional adverbs.
Double Quotes
-------------

Double quoting combines all the previous mentioned adverbs for
interpolation (also **:q** - implied by **:b**), thatswhy all the
Double quoting combines all the previously mentioned adverbs for
interpolation (also **:q** - implied by **:b**), so all the
following are synonymous.

Q :s, :a, :h, :f, :c, :b /.../;
Expand All @@ -243,19 +242,19 @@ any whitespace (\\s aka <ws>).

Q :quotewords /.../; # qw/.../ with quote protextion
Q :ww /.../; # :qq implied
<<>> # have also a unicode alias (chevron)
<<>> # also have a unicode alias (chevron)

The second group of aliases mark a modified version, where single and
double quoted strings (inside the quote) are treated as one
word. Thats called *quote* protection.
word. This is called *quote* protection.

my @steps = <one "two three">; # 3 steps to success: ["one", "\"two", "three\""]
my @steps = <<one "two three">>; # now only 2 steps: ["one", "two three"]


Please note also that **:quotewords** (double pointy braces) implies
**:double** (double quotes), which means all [interpolation rules](#interpolation)
apply here also.
**:double** (double quotes), which means all
[interpolation rules](#interpolation) apply here as well.

<$pi> eq '$pi' # True
<<$pi>> == pi # True (hopefully)
Expand All @@ -279,7 +278,7 @@ by the adverbs **to** and heredoc. Heredocs can be nested.

To make templates in which variables and closures are evaluated, take
the normal double quote and just add the adverb for the heredoc
delimiter or define with other adverbs what exactly you want to have
delimiter or define with other adverbs exactly what you want to have
evaluated.

qq:heredoc 'EOT';
Expand All @@ -302,7 +301,7 @@ warnings early if there is something incompatible with convention.
Regex
-----

Even being a completely different language then quoting on its own (as
Even being a completely different language than quoting on its own (as
to be defined in *\$\~Regex* and *\$\~P5Regex*), [regular
expressions](tablet-9-regexes.html) can be built using the general quoting
operator with the right adverb.
Expand Down Expand Up @@ -345,12 +344,13 @@ Number Literals
Unlike strings, numbers don't need
[quoting](#quoting). But if there is a non number
character in it, there will be an error. Chars of a number definition
are: (0-9,.,+,-,e,E,i,_) including the [radix
are: (0-9,.,+,-,e,E,i,\_) including the [radix
prefixes](#radix-prefixes): (0b,0o,0d,0x) and the
prefix for [version numbering](#version-number)
(v). The + and can act also as operator that convert into the
numerical context, which still means: take from left to right all
digits and stop with the first none number character.
(v). The + can also act as an operator that converts a string
to numerical context, which means: take form left to right all digits
and interprate as a numeric literal. This will fail if the string
contains any number numeric digits.

A single underscore is allowed only between any two digits, delimiter
helping readability.
Expand All @@ -360,11 +360,15 @@ helping readability.
$int = 2;
$real = 2.2;


$num = +'123';
$num = +'123foo'; # fails, 'foo' is not numeric

Radix Prefixes
--------------

Prefixes may be use to enter numbers in the most commonly used
radices.

0b binary - base 2, digits 0..1
0o ocatal - base 8, digits 0..7
0d decimal - base 10, digits 0..9
Expand All @@ -375,13 +379,23 @@ Radix Prefixes
General Radix Form
------------------

Numbers may be entered in any radix using the general radix form, digits
are represented by `0-9` and then `a-z` (case insensitive), so up to base
36 can be represented as a string of digits.

:10<42> # same as 0d42 or 42
:36<3z> # 3*(36**1) + 35*(36**0) = 143

Larger radices can be entered as lists of decimal numbers.

:60[12,34,56]; # 12*(60**2) + 34*(60**1) + 56*(60**0) = 45296

Scientific Notation
-------------------

Scientific notation may be entered using `e` (case insensitive) and
works the way you would expect.

$float = 60.2e23 # becomes automatically 6.02e24
$float = 6.02E-23 # capital E works too

Expand All @@ -390,7 +404,7 @@ Scientific Notation
Rational Number
---------------

To distinguish them from a division operation, you have to groupe them
To distinguish them from a division operation, you have to group them
with braces.

(3/7)
Expand All @@ -404,7 +418,7 @@ get (3/7), the nude source code. There are 2 different [immutable
value types](appendix-b-grouped.html#immutable-types) representing
both rational number. FatRat has unlimited precision and Rat has just
enough to be evaled into a Real type. When you explicitly [type a
variable](tablet-3-variables.html#data-types) to one o them, the braces become
variable](tablet-3-variables.html#data-types) to one of them, the braces become
optional.

my Rat $pi_approx = 22/7;
Expand All @@ -415,8 +429,8 @@ optional.
Complex Number
--------------

have also there own [immutable value
type](ap-b-lookup.html#immutable-types).
There is also an [immutable value
type](ap-b-lookup.html#immutable-types) for complex numbers.

1+2i
my $c = 5.2+1e42i;
Expand Down Expand Up @@ -444,7 +458,7 @@ perl
----

The `.perl` method returns a string that arranges any set of values in
almost the same format, as the would be defined it source code. It's a
almost the same format, as it would be defined in source code. It's a
built in Data::Dumper (pretty printer).

@a.perl # evals to: [1, 2, 3, 4, 5]
Expand Down Expand Up @@ -501,7 +515,7 @@ xxx
Formats
-------

moved from core language to a module.
Moved from core language to a module.



Expand Down

0 comments on commit 0936234

Please sign in to comment.