Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed links in 3
  • Loading branch information
lichtkind committed Mar 25, 2013
1 parent d39ed47 commit 317fa2d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 50 deletions.
7 changes: 0 additions & 7 deletions docs/appendix-a-index.txt
Expand Up @@ -4032,13 +4032,6 @@ deletes a directory with given name

# [Rn](#nav-top)

<a id="required"/>
**required** &mdash;
[*trait*](appendix-g-glossary.html#trait) to create
[*attributes*](appendix-g-glossary.html#attribute) that you have to give data
while [*object*](appendix-g-glossary.html#object) creation &mdash;
`class rocket { has $.speed is required }`

<a id="role"/>
**role**
*«block modifier»* &mdash;
Expand Down
82 changes: 39 additions & 43 deletions docs/tablet-3-variables.txt
Expand Up @@ -9,12 +9,12 @@ Variable Types
==============

Perl 6 (as Perl 5) knows 3 basic types of variables:
[Scalars](variables.html#scalars) (single values),
[Arrays](variables.html#array) (ordered and indexed lists of several
values) and [Hashes](variables.html#hash) (2 column table, with ID and
[Scalars](#scalars) (single values),
[Arrays](#array) (ordered and indexed lists of several
values) and [Hashes](#hash) (2 column table, with ID and
associated value pairs). They can be easily distinguished, because in
front of their name is a special character called
[sigil](ap-b-lookup.html#sigils) (latin for sign). Its the $
[sigil](appendix-b-grouped#sigils) (latin for sign). Its the $
(similar to S) for Scalars, @ (like an a) for Arrays and a % (kv pair
icon) for a Hash. They are now invariant (not changing), which means
for instance, an array vaiable starts always with an @, even if you
Expand All @@ -29,26 +29,25 @@ just want a slice of the content.
%hash{'ba','da','bim'} ### @hash{'ba','da','bim'} in Perl 5

The sigils also mark distinct namespaces, meaning: in one [lexical
scope](variables.html#scoping) you can have 3 different variables
scope](#scoping) you can have 3 different variables
named $stuff, @stuff and %stuff. These sigils [can also be used as an
operator](ap-b-lookup.html#contextualizers) to enforce a
operator](appendix-b-grouped#contextualizers) to enforce a
context in which the following data will be seen.

The fourth namespace is for [subroutines and
similar](variables.html#callable), even if you don't usually think of them
similar](#callable), even if you don't usually think of them
as variables. It's sigil & is used to refer to subroutines without calling them.

All special namespaces from Perl 5 (often marked with special syntax), like
tokens (`__PACKAGE__`), formats, file or dir handles, or builtins are
now regular variables or routines.

Because all variables contain [objects](objects.html), they have methods.
In fact, [all operators](operators.html), including square or curly bracket
Because all variables contain [objects](tablet-8-objects.html), they have methods.
In fact, [all operators](tablet-4-operators.html), including square or curly bracket
subscripts, are just methods of an object with a fancy name.

The primary sigil can be followed by a secondary sigil, called a
[twigil, which indicates a special scope](variables.html#twigils)
for that variable.
[twigil](#twigils), which indicates a special scope for that variable.



Expand All @@ -58,11 +57,11 @@ Scalar
This type stores one value, usually
a reference to something: a value of a data type,
a code object, an object or a compound of values like a
[pair](variables.html#pair), [junction](operators.html#junctions),
[array](variables.html#array), [hash](variables.html#hash) or
[capture](variables.html#capture). The scalar context is now called
[pair](#pair), [junction](tablet-4-operators.html#junctions),
[array](#array), [hash](#hash) or
[capture](#capture). The scalar context is now called
item context, hence the `scalar` instruction from Perl 5 was renamed to
[item](ap-b-lookup.html#contextualizers).
[item](appendix-b-grouped#contextualizers).

$CHAPTER = 3; # first comment!
$bin = 0b11; # same value in binary format
Expand Down Expand Up @@ -90,16 +89,15 @@ item context, hence the `scalar` instruction from Perl 5 was renamed to
$coderef = sub { do_something_completely_diffenent(@_) };

(For info on some of those terms:
[comment](basic-syntax.html#single-line), [binary
format](basic-syntax.html#radix-prefixes), [the underscores ease
reading](basic-syntax.html#number-literals), [scientific
notation](basic-syntax.html#scientific-notation), [single-quoted
string](basic-syntax.html#single-quotes), [double-quoted
string](basic-syntax.html#double-quotes), [heredoc
string](basic-syntax.html#heredocs), [file handle](io.html#files),
[class](objects.html), [junction](variables.html#junction), [list of
values](variables.html#array), [hash](variables.html#hash),
[callable](variables.html#callable).)
[comment](tablet-2-basic-syntax.html#single-line),
[binary format](tablet-2-basic-syntax.html#radix-prefixes),
[the underscores ease reading](tablet-2-basic-syntax.html#number-literals),
[scientific notation](tablet-2-basic-syntax.html#scientific-notation),
[single-quoted string](tablet-2-basic-syntax.html#single-quotes),
[double-quoted string](tablet-2-basic-syntax.html#double-quotes),
[heredoc string](tablet-2-basic-syntax.html#heredocs),
[file handle](io.html#files), [class](tablet-2-basic-syntax.html), [junction](#junction), [list of
values](#array), [hash](#hash), [callable](#callable).)

Unlike Perl 5, references are automatically dereferenced to a fitting
context. So you could use these `$arrayref`s and `$hashref`s similarly to
Expand All @@ -125,7 +123,7 @@ Array
-----

An array is an ordered and indexed list of
[variables](variables.html). If not specified otherwise, they
[scalar](#Scalar)s. If not specified otherwise, they
can be changed, expanded and shortened anytime and used as a list,
stack, queue and much more. As in Haskell, lists are processed lazily,
which means: the compiler looks only at the part it currently
Expand All @@ -134,10 +132,10 @@ lists that have not been computed yet. The `lazy` command enforces this
and the `eager` command forces all values to be computed.

The list context is forced with a [@ operator or `list()`
command](ap-b-lookup.html#contextualizers). That's not
command](appendix-b-grouped.html#contextualizers). That's not
autoflattening like in Perl 5 (automatically convert a List of Lists
into one List). If you still want that, [say flat(). Or say
lol()](ap-b-lookup.html#contextualizers) to explicitly
lol()](appendix-b-grouped.html#contextualizers) to explicitly
prevent autoflattening.

@primes = (2,3,5,7,11,13,17,19,23); # an array gets filled like in Perl 5
Expand Down Expand Up @@ -217,9 +215,9 @@ There is even a whole class of metaoperators that work upon lists.
Hash
----

is in Perl 6 an unordered list of Pairs. [A Pair](variables.html#pair)
is in Perl 6 an unordered list of Pairs. [A Pair](#pair)
is a single key `=>` value association and [appears in many
places](language-design.html#maximum_reusage) of the language syntax.
places](tablet-1-language-design.html#maximum_reusage) of the language syntax.
A hash allows lookup of values by key value using `{}` or `<>` syntax.

%dev = 'pugs'=>'audreyt', 'pct'=>'pm', "STD"=>'larry';
Expand Down Expand Up @@ -268,11 +266,11 @@ A hash allows lookup of values by key value using `{}` or `<>` syntax.
Callable
--------

Internally [subroutines](subroutines.html), [methods](objects.html)
and [alike](ap-b-lookup.html#routine-types) are variables
Internally [subroutines](tablet-7-subroutines.html), [methods](tablet-8-objects.html)
and [alike](appendix-b-grouped.html#routine-types) are variables
with the sigil & and stored in a fourth namespace. Unlike Perl 5, all
subroutines can be overwritten or augmented with user defined routines.
Of course [scalars](variables.html#scalars) can
Of course [scalars](#scalar)s can
also contain routines.

&function = sub { ... }; # store subroutine in callable namespace
Expand All @@ -286,9 +284,9 @@ also contain routines.
Data Types
==========

In contrast to [variable types](variables.html#variable-types)
In contrast to [variable types](#Variable-Types)
(container types) every [value has a
type](ap-b-lookup.html#value-types) too. These are
type](appendix-b-grouped.html#value-types) too. These are
organized internally as classes or roles and can be categorized into 3
piles: the undefined, immutable and the mutable types.

Expand Down Expand Up @@ -334,7 +332,7 @@ parameters, it is a mixture of a list and array.


One important difference between a compound structure of lists and
hashes and a capture: while [assignments](variables.html#assignment)
hashes and a capture: while [assignments](#assignment)
with = the complete content of the named variables will be copied. But
not so in the case of a capture. When I change $s in the last example,
the content of $cap changes too, because when parameters to a routine
Expand Down Expand Up @@ -365,8 +363,8 @@ xxx
Scoping
=======

[scope declarator](ap-b-lookup.html#scope-declarator),
[scopes](ap-b-lookup.html#scopes)
[scope declarator](appendix-b-grouped.html#scope-declarator),
[scopes](appendix-b-grouped.html#scopes)

my $var;
state
Expand Down Expand Up @@ -396,7 +394,7 @@ As rightfully expected, assignments are done with the equal sign. But
unlike Perl 5 you always get a copy of the right side data assigned to
the left, no matter how nested the data structure was (lists of lists
eg). You never get in Perl 6 a reference with =. As the only exception
may be seen [captures](variables.html#capture).
may be seen [captures](#capture).

my @original = [1,2],[3,4];
my $copy = @original[0]; # $copy points to [1,2]
Expand All @@ -423,9 +421,7 @@ binding to get 2 variables that point to the same memory location.
Special Variables
=================

[are listed their
table](ap-b-lookup.html#special-variables). To understand
their secondary sigil [go to the twigil chapter of this
tablet](variables.html#twigils).
are listed in [Index B](appendix-b-grouped.html#special-variables).
To understand their secondary sigil [click here](#twigils).

***

0 comments on commit 317fa2d

Please sign in to comment.