Index
All corners
Every corner in the book, by chapter. Filter by kind or search the titles.
1. Who Takes the Operand
- 1.1 The ladder, from tightest to loosest
- 1.2
**binds tighter than unary minus, and groups from the right - 1.3 A method call binds tighter than everything, including prefix minus
- 1.4 A space before the dot turns a method call into a different operator
- 1.5 Junctions bind looser than arithmetic and concatenation
- 1.6 Different junction operators do not mix without parentheses
- 1.7 Comparisons chain, and the middle operand is evaluated once
- 1.8
== Trueat the end of a chain compares the last operand, not the result - 1.9
!negates a comparison and keeps the chain, but only a comparison - 1.10 Structural operators refuse to chain
- 1.11
&&binds tighter than||and//, and^^wants exactly one true operand - 1.12
minandmaxare looser than all arithmetic, and do not mix - 1.13 The ternary nests from the right, and an assignment inside it needs parentheses
- 1.14
say 0 or …prints 0: the word operators are looser than a list call - 1.15
andthenandorelsetest definedness and hand the value on as$_ - 1.16 The sigil of the target decides between item and list assignment
- 1.17 List assignment is looser than
ZandX; item assignment is tighter - 1.18 The comma binds tighter than
Z,Xand... - 1.19
=>sits on the assignment level and nests to the right - 1.20 A reduction takes everything to its right
- 1.21 A reduction folds by the operator's associativity
- 1.22 An empty reduction answers the operator's identity
- 1.23 Only associative and chaining operators reduce
- 1.24 The pointed side of a hyper operator sets the length
- 1.25
>>.^nameasks the list, not its elements - 1.26
Rswaps the operands and keeps the precedence - 1.27 Autoincrement reads its operand at the moment it runs
- 1.28 Symbolic prefixes bind tight;
soandnotbind loose - 1.29 A flip-flop counts the elements of its run
- 1.30 Feeds are the loosest operators of all
2. Quotes and Interpolation
- 2.1
Q,qandqqdiffer only in which features are on - 2.2
Qhas no escapes at all - 2.3 Single quotes know two escapes: the backslash and the delimiter
- 2.4
\qq[…]interpolates inside single quotes - 2.5 Double quotes know the C escapes, and three ways to write a code point
- 2.6
\x,\oand\ctake every digit that follows - 2.7
\c[…]takes names, aliases and sequences - 2.8 A backslash before a letter is an error; before anything else it is that character
- 2.9 Perl's spellings are refused, with the Raku one in the message
- 2.10 A variable interpolates; a method call on it needs parentheses
- 2.11 Arrays, hashes and subs interpolate only with a subscript or a call
- 2.12 A bracket right after a variable belongs to the variable
- 2.13 A
{in double quotes opens a block of code - 2.14 An apostrophe or a hyphen followed by a letter continues the name
- 2.15 Every kind of scalar interpolates, including match variables
- 2.16 An undefined value interpolates as an empty string, with a warning
- 2.17
< >splits on whitespace and on nothing else - 2.18 A single word in angle brackets is a Str, not a list
- 2.19 Numbers in a word list become allomorphs
- 2.20 A lone fraction in angle brackets is a number literal
- 2.21
<< >>interpolates and keeps quoted words together - 2.22 In
<< >>, every interpolation starts a new word - 2.23 Adverbs switch features one at a time, and the last one wins
- 2.24
:w,:vand:xwork on the result, in the order written - 2.25 Inside brace delimiters, a
{is not a block - 2.26 Brackets nest, and a doubled bracket is one delimiter
- 2.27 Any other character closes itself, but not every character can open
- 2.28 Curly quotes are quotes too
- 2.29 A heredoc removes the terminator's indentation from every line
- 2.30 A tab in a heredoc's indentation reaches the next multiple of eight
- 2.31 Interpolated text keeps its own indentation
- 2.32 The rest of a heredoc's line is ordinary code
- 2.33 The terminator must match exactly and stand alone
- 2.34 Adverbs apply to a heredoc as to any quote
- 2.35
qxreturns what the command printed, and never fails - 2.36 Only
qqxinterpolates;qxhands$whoto the shell - 2.37 Braces inside
qx{…}run a command of their own
3. Whitespace, Terms and Blocks
- 3.1
{ … }is a Hash only when it looks like one - 3.2 A block that only returns a pair is a Hash, so
maprefuses it - 3.3 A brace that touches a term is a subscript
- 3.4 A
}that ends a line ends the statement - 3.5 Inside brackets, a line-ending
}separates elements like; - 3.6 A keyword touching
(is a function call - 3.7 A space after a sub's name moves the parentheses into the argument
- 3.8 Parentheses touching the name end the call
- 3.9 A sub called without parentheses takes the whole comma list
- 3.10 A postfix must touch its term
- 3.11 A backslash unspace lets a postfix stand apart
- 3.12 A line that starts with a dot continues at dotty-infix precedence
- 3.13
.&calls any sub as if it were a method - 3.14
++needs a container, and a method call returns a value - 3.15 Spacing does not group operands
- 3.16 A hyphen or apostrophe joins an identifier only before a letter
- 3.17 A
<touching a term opens a subscript - 3.18 A sub named after a type, even
X, needs its& - 3.19
=>quotes the word on its left only on the same line - 3.20 A colonpair's number must be a plain integer
- 3.21 A colonpair's value must touch its name
- 3.22
#starts a comment outside quotes;#`and a bracket embed one - 3.23
#|and#=attach documentation to a declaration - 3.24 Pod directives must start a line
- 3.25 A line starting
=wordthen a space is Pod, even mid-statement - 3.26 Every Unicode space is whitespace, but some do not split words
- 3.27 Numeric literals allow
_between digits, andemakes a Num - 3.28 A decimal point needs a digit after it
4. Values Nobody Uses
- 4.1 A value nobody uses has its
sinkmethod called - 4.2 A block whose value is unused sinks its last statement
- 4.3 A call that stands alone sinks the value it returns
- 4.4 A sunk operator sinks its result, not its condition
- 4.5
//never sinks its left side - 4.6 A sunk list sinks every element; a sunk
xxsinks none - 4.7 The compiler reports sunk values that cannot matter
- 4.8 Calls, method calls and assignments are never reported
- 4.9 Each unused branch is reported, except the right side of
// - 4.10
no worriesdoes not silence a "Useless use" - 4.11 Only a bare block runs where it stands
- 4.12 Everything after an item assignment's comma is sunk
- 4.13 A sunk Failure throws its exception
- 4.14 Testing a Failure marks it handled, and then it sinks quietly
- 4.15 A handled Failure is
NaNas a number and "(HANDLED)" as a string - 4.16 Inside
try, a Failure throws as soon as a call returns it - 4.17 A failed process throws when its
Procis sunk - 4.18
.out.closesinks theProc;.slurp(:close)does not - 4.19 A
Procstays armed however often it is tested - 4.20
try { run … }does not catch a failed process - 4.21 The last value of a
forbody is not always sunk - 4.22 A sunk
Seqruns to the end, even a lazy one - 4.23 A routine's value is its last statement's, and a loop's is
Nil - 4.24 A
givenwithout a matchingwhengivesFalse, notNil - 4.25
return $xkeeps the container that a last statement drops - 4.26 The
sinkprefix runs a statement and givesNil
5. Containers and Binding
- 5.1 A
$variable keeps its value in a Scalar container - 5.2
:=gives a container a second name;=copies the value - 5.3 A name bound to a value cannot be assigned to
- 5.4 A sigilless name is a binding
- 5.5 A
$name bound to a list is not an item - 5.6 Assignment returns the container it assigned to
- 5.7 An assignment metaoperator takes a whole expression on its right
- 5.8 An assignment metaoperator is an item assignment, even on an array
- 5.9
.=assigns a method's result, on the method-call level - 5.10
//=,||=and&&=evaluate their right side only when needed - 5.11 A List holds bare values, unless it was given containers
- 5.12 Iterating an Array hands out its containers
- 5.13 Iterating a Hash hands out its containers too
- 5.14
:=between elements makes two slots one - 5.15
my (…) :=binds read-only, andis rwmakes an alias - 5.16
my (…) :=checks the count;my (…) =does not - 5.17 A bound
@or%name takes the object's own type - 5.18
=gives an array new containers but shares what they hold - 5.19
@a = @a, 3puts the array inside itself - 5.20
$(…)and.itemmake a value one item - 5.21
foriterates an item once - 5.22
<>takes a value out of its container - 5.23
.rakumarks an item with$, except inside an Array - 5.24
flatstops at a Scalar container - 5.25
($a, $b) = …reads the whole right side first - 5.26 A nested group in
my (…) =does not destructure - 5.27 A routine strips the container unless declared
is rworis raw - 5.28 A Pair keeps the container of its value
- 5.29 Pairs that hold the same variable are not identical
- 5.30 A Map is immutable, but the containers inside it are not
- 5.31
temprestores a variable when its block is left - 5.32
temptakes one term, and it must be a container - 5.33 A
doblock returns atempvariable already restored - 5.34
letkeeps its change only if the block succeeds
6. Nil, Any and the Undefined
- 6.1 Nil answers every method it does not have with Nil
- 6.2 A type name followed by
[is a parameterization, not a subscript - 6.3 Nil is undefined, false, and its own only instance
- 6.4
for Nilruns once: Nil fills one slot in a list - 6.5 List methods on Nil see the one-element list
(Nil,) - 6.6 Nil takes the type-object answer of the list methods
- 6.7 An Array or a Hash slot turns Nil into its default
- 6.8
%h = Nil,Int:Dand native variables refuse Nil - 6.9 Nil refuses every change
- 6.10 String methods on Nil return an empty string, even
.chars - 6.11 Nil is 0 in arithmetic and empty in a string, with a warning
- 6.12 A Failure is a Nil, so it smartmatches
Nil - 6.13 A default value does not replace a Nil argument
- 6.14 Nil is what code returns when it has nothing to return
- 6.15 A return type, even
:D, lets Nil and Failures through - 6.16 A single value is a list of one element
- 6.17 A type object is a list of one element too
- 6.18
42.keysis(0,), andInt.keysis empty - 6.19
.keyson an enum value lists the whole enumeration - 6.20
.hashand.pairupwant pairs, and a single value is odd - 6.21
mapcalls its block once for a single value - 6.22
grepsmartmatches a single value, and a type object is one - 6.23
firstanswers Nil when nothing matches - 6.24 Without a count,
head,tailandpickreturn the value itself - 6.25
reduceon one element calls the reducer with one argument - 6.26
sum,min,batchandrotorrefuse a type object - 6.27
minandmaxlet an undefined operand lose - 6.28 The sub forms take a list or separate values,
sortexcepted - 6.29 The other list methods treat a value as a list of one
- 6.30 A classified Nil keeps its key and loses its value
- 6.31
arenames the type of one value, or of a type object - 6.32 Index 0 of a single value is the value itself
- 6.33 An index that is not a number dies, and
42[Int]also warns - 6.34 Assigning through a subscript builds the missing Array or Hash
- 6.35
<key>on a value that is not a hash is a Failure - 6.36
pushon an undefined variable creates an Array - 6.37
++on an undefined variable counts from 0 - 6.38 A Set or junction of one value holds it, even Nil
- 6.39
.matchstringifies its invocant and sets the caller's$/ - 6.40
joinof one value is its string; undefined joins as empty - 6.41 Smartmatching against a plain object tests identity
- 6.42
===compares value types by value and other objects by identity
7. Numbers
- 7.1 The wider type wins: Int, Rat, FatRat, Num, Complex
- 7.2
1,1.0and1e0are equal but not the same value - 7.3
NaNis identical to itself, and-0e0is not identical to0e0 - 7.4 Smartmatching against a number compares numerically
- 7.5 Zero is false in every numeric type, and NaN is true
- 7.6 A whole Num prints like an Int
- 7.7 A Rat prints at most six decimals, but
.rakuis exact - 7.8
1/0is a Rat, and it fails only when printed - 7.9 Rat arithmetic is exact until the denominator needs 64 bits
- 7.10
$*RAT-OVERFLOWdecides what an overflowing Rat becomes - 7.11
$*RAT-OVERFLOWdoes not reach a division of literals - 7.12 A FatRat never degrades, and beats a Rat
- 7.13
Rat.newreduces, moves the sign up and takes only Ints - 7.14
.Inttruncates a Num exactly;.Ratonly approximates it - 7.15 An undefined number dies in arithmetic, but only warns under
+ - 7.16 A string that is not a number makes arithmetic return a Failure
- 7.17
trycatches the Failure from+, but not the one from== - 7.18
divrounds down and%takes the sign of the divisor - 7.19 Dividing by zero gives a Rat, a Failure or an exception
- 7.20
7 mod 2.5is -0.5 - 7.21
gcdandlcmtruncate to Int, and zero is special - 7.22
**stays exact with an Int exponent - 7.23 A power too large or too small is a Failure, except
** 2 - 7.24
Inf ** -1is an underflow, not zero - 7.25 A negative base to a negative power puts the sign on the denominator
- 7.26 Superscript digits are the
**operator - 7.27
roundsends halves towards positive infinity - 7.28
floorand friends return an Int;roundwith a scale may not - 7.29
signis an Int, andsuccadds one in the value's own type - 7.30 An Int compared with a Num is compared as a Num
- 7.31 NaN is unequal to everything, and
<=>with it is Nil - 7.32
cmpcompares a number with a string as two strings - 7.33
=~=is relative to the larger operand, and absolute at zero - 7.34 An Order is a number, and
.Orderlooks only at the integer part - 7.35 A reduction over one operand returns it unchanged
- 7.36
[lcm] ()dies of an ambiguous call - 7.37 Of two equal values,
maxkeeps the second; of more, the first - 7.38 Bitwise operators see an Int as endless two's complement
- 7.39 A left shift by a negative count past -63 wraps around
- 7.40
Inf - Infis NaN, and the negative zero keeps its sign - 7.41
narrowmakes an Int of any Num close to one, however small - 7.42
baserounds its last digit, and*asks for every digit - 7.43
basealso counts in camels - 7.44
is-primeandexpmodaccept whole numbers of any type - 7.45
polymodstops at a divisor of 1 or less - 7.46 An Int's
polymodby a fraction gives negative remainders - 7.47 A Rat unpacks into numerator and denominator
- 7.48
.fmtrounds halves up, and%fgoes through a double - 7.49
log10,log2and a logarithm with a base divide two logarithms - 7.50
$x.exp($base)raises the base to$x - 7.51
sqrtof a negative Real is NaN, not a Complex - 7.52
randtakes no argument - 7.53
srandrepeats a sequence only from its second run - 7.54 A literal of the wrong numeric type is a compile-time error
- 7.55 Native integers wrap around, and a 64-bit one refuses a big Int
8. Strings
- 8.1 Two strings with the same text are the same value
- 8.2 A subclass of Str keeps its type through its own methods
- 8.3
"0"is true, but<0>is false - 8.4 A string cannot be unpacked by a signature
- 8.5 Smartmatching against a string compares the topic's text
- 8.6
+"…"skips surrounding whitespace, and an empty string is 0 - 8.7 A string can hold any number literal, even a fraction
- 8.8 A string that is not a number gives a Failure
- 8.9
.Inttruncates, and.Numkeeps a negative zero - 8.10
valmakes an allomorph and keeps the exact text - 8.11 An allomorph compares by both halves
- 8.12 Smartmatch reads one half of an allomorph; sets want both
- 8.13 An allomorph is Int and Str, so a multi cannot choose
- 8.14 String methods on an allomorph return a plain Str
- 8.15
<42>.linesreturns an allomorph whose number is 0 - 8.16
~calls.Str, which shortens a Rat and tab-joins a Hash - 8.17 The count of
xgoes through.Int, and Inf is refused - 8.18
ltandcmpcompare code points, so capitals sort first - 8.19
~|,~&and~^combine strings code point by code point - 8.20
succincrements the last run of letters or digits - 8.21
predfails wheresuccwould have carried - 8.22 Case mapping follows Unicode, and can change the length
- 8.23
wordcasecapitalises a letter after a digit or a dot - 8.24
samecaseandsamemarkcopy a pattern position by position - 8.25
samespacecopies the whitespace between words - 8.26
chompremoves one line ending of any kind;chopone grapheme - 8.27
trimremoves Unicode whitespace, but not zero-width characters - 8.28
indexreturns Nil, not -1, and 0 is a find - 8.29 A negative position fails; one past the end finds nothing
- 8.30
rindexdies on a position at the end - 8.31 A needle list with a position is searched as one string
- 8.32
rindexwith a needle list and a position never returns - 8.33
rindexsearches backwards and ignores:i - 8.34
indicesdoes not overlap unless asked - 8.35
contains(/…/, $pos)cannot match at the end - 8.36
:ifolds case fully, except inends-with - 8.37
starts-with,ends-withandsubstr-eqcompare at one place - 8.38
substrtakes a range or code, but not*-3..* - 8.39
substrout of range returns a Failure with advice - 8.40
substr-rwsplices into the variable - 8.41 A bound
substr-rwwrites into the text it first saw - 8.42
charscounts graphemes,codescode points after composition - 8.43
combwith a number cuts chunks; with a fraction it searches - 8.44
combwith a string and a limit finds overlapping matches - 8.45
combwith a regex returns every match, empty ones included - 8.46
linessplits at any line ending; a final one adds nothing - 8.47
lines(:!count)dies - 8.48
wordssplits at a no-break space; a word list does not - 8.49
split("")adds an empty string at each end - 8.50
splitcan return the separators, but in one form only - 8.51 The limit of
splitcounts pieces;:endcounts from the right - 8.52
splitwith a string needle dies on a fractional limit - 8.53
splitwith a regex splits at empty matches too - 8.54 A list of needles splits at the earliest match, then the longest
- 8.55
:vgives a string for a regex in a list of needles - 8.56 A zero-width regex in a list of needles never returns
- 8.57
substwith a string needle replaces it literally, once - 8.58 An empty needle with
:gmisses both ends - 8.59
substpasses:nthand:xon, and refuses:ovand:ex - 8.60
substwith:as(Str)dies under:g,:nthor:x - 8.61 A replacement block receives the Match
- 8.62 With a string needle,
substleaves$/alone - 8.63
:ii,:ssand:mmshape the replacement, not the match - 8.64
subst-mutatereturns the Match, not the new string - 8.65
subst-mutateaccepts:ovand:ex, whichsubstrefuses - 8.66
.matchwith a negative:cmatches before the start - 8.67
transmaps characters, and a short target string starts over - 8.68 When
transkeys repeat, the last wins, or the first - 8.69
transreplaces a regex key's whole match, or calls code - 8.70
transwants Pairs, andStr => "x"is not one - 8.71
indentadds to every line that has a character - 8.72
indent(*)removes the common indentation, counting tabs as columns - 8.73
parse-basereads a string in any base from 2 to 36 - 8.74
:16("…")understands prefixes, unless the letter is a digit - 8.75
.rakuescapes sigils and control characters, but not invisible ones - 8.76
encodecomposes first, and refuses what it cannot encode - 8.77
encodewith an undefined encoding never returns - 8.78
fmtcounts graphemes, and its errors have no type - 8.79
.Version,.Dateand.IOparse strings; one string has aWHY - 8.80
containson a list searches the list's text - 8.81 The Str type object warns, answers empty, or refuses
9. Lists, Arrays, Seqs and Slips
- 9.1 The comma makes a list, and a one-element list keeps it
- 9.2 One list argument is the list; several are its elements
- 9.3 A Hash spreads into its Pairs; a Seq in
$sdoes not - 9.4 A list numifies to its length and stringifies with spaces
- 9.5 A Slip dissolves into the list around it
- 9.6 A Slip slips even out of a Scalar container
- 9.7
Emptyis a Slip, and it is not defined - 9.8
.Arraycopies, and.eagerreturns the list itself - 9.9 Slipping a list passes its Pairs as positionals;
.Capturemakes them named - 9.10
.giststops at 100 elements, and a lazy list prints(...) - 9.11 A literal negative index does not compile
- 9.12 A computed negative index is a Failure; past the end is
Any - 9.13 An index is truncated to an integer; a type object is refused
- 9.14 An endless range stops at the end of the array; a finite one does not
- 9.15
:deleteleaves a hole, except at the end - 9.16
:kv,:p,:kand:vskip positions that do not exist - 9.17 A slice assignment gives one value to each slot
- 9.18
@a[*] = …keeps the length;@a[] = …replaces the array - 9.19 A semicolon subscript goes one level deeper per dimension
- 9.20 A shaped array has a fixed size in every dimension
- 9.21
my @a[Int]is an ordinary array, with a warning - 9.22 A typed array shows its type in
.rakubut not in.gist - 9.23
pushadds each argument whole;appendspreads a single list - 9.24
popandshifton an empty array return a Failure - 9.25
spliceaccepts*and code for its offset and size - 9.26 A lazy array takes
shiftandunshift, but notpushorpop - 9.27
splicewithout a size removes only what a lazy array has computed - 9.28
grabremoves random elements and returns them - 9.29
cloneis shallow, and a lazy clone shares its source - 9.30 A lazy list can be indexed, but not counted
- 9.31
is-lazyis False for agather, even an endless one - 9.32 A Seq can be iterated only once
- 9.33 Some methods keep a Seq's values; most use them up
- 9.34
.head(-1)is empty;.head(*-1)drops the last element - 9.35 A
mapblock takes as many elements as it has parameters - 9.36
deepmapitemizes what it builds for an inner list - 9.37
deepmapon a hash unwraps a one-element array - 9.38
grepjudges what its code returns - 9.39
:k,:kv,:pand:vchoose whatgrepandfirstreturn - 9.40
first(:end)searches from the end, and refuses a lazy list - 9.41 A one-parameter block sorts by key; two parameters compare
- 9.42
sort(:k)returns positions, andreversekeeps inner lists whole - 9.43
uniquecompares with what it kept;squishwith the previous element - 9.44
pickstops at the size of the list;rollcan go on for ever - 9.45
combinationsleaves out sizes that cannot be made - 9.46
pairupkeeps Pairs and pairs up everything else - 9.47
toggleswitches between conditions, and stays put after the last - 9.48
rotorcuts a list into pieces and drops a short last one - 9.49
classifybuilds a hash of arrays whose keys keep their type - 9.50
treeturns nested lists into nested items - 9.51
.joinseparates only the top-level elements - 9.52
.fmtformats each element on its own - 9.53
.sumcounts a nested list instead of adding it - 9.54
xxevaluates its left side again for every repetition - 9.55
xxtruncates its count, and*repeats without end - 9.56
xrepeats a string, andx *makes a WhateverCode - 9.57
Zstops at the shortest list;Xis lazy if any operand is - 9.58 A list pattern matches element by element, with
*and**as wildcards - 9.59 A Range on the right of
~~checks a list's length - 9.60 Arrays and lists are identical only to themselves
10. Hashes, Maps and Pairs
- 10.1 Hash assignment takes pairs, keys and values, or a mix
- 10.2 A nested array or list becomes one key
- 10.3 An odd number of items dies
- 10.4
%h = %h, …adds to the hash - 10.5
my %h = { … }works, with a warning - 10.6
Hash.newandMap.newdrop named arguments beside positional ones - 10.7 Iteration order is random, but printing sorts
- 10.8
saysorts keys as strings and stops after 100 pairs - 10.9 A key is a string, so
%h{1}and%h<1>are one slot - 10.10 Numbers become keys through their printed form
- 10.11 An undefined key becomes the empty string, with a warning
- 10.12 A bareword before
=>is a string, even a type name - 10.13 A list inside the braces is a slice, not one key
- 10.14
my %h{Any}keeps keys as objects - 10.15 An object hash finds a key by identity
- 10.16
my %h{Int}checks every key - 10.17
%h<1>is a third key in an object hash - 10.18
my Int %hchecks values; Nil restores the type object - 10.19 A missing key reads as Any and is not created
- 10.20
:existsasks about a key,:deleteremoves it - 10.21 Assigning Nil to a key does not remove it
- 10.22
:k,:v,:kvand:pskip missing keys unless negated - 10.23
:existsand:deletecombine with:kvand:p, not:k - 10.24 An adverb after an operator belongs to the operator
- 10.25
%h{*}is every value, and%h{}is the hash itself - 10.26
%h{'a';'b'}reaches into nested hashes and returns a list - 10.27
%h.push(a => 1)pushes nothing - 10.28
pushstacks the values of a repeated key into an Array - 10.29 Assignment merges hashes by replacing,
pushby stacking - 10.30
|%hpasses the pairs as named arguments - 10.31
.invertspreads list values;.antipairsdoes not - 10.32 List methods see pairs, and pairs compare by key
- 10.33
.fmtformats each pair, and.rolland.pickreturn Pairs - 10.34 A hash in numeric context is its size
- 10.35 Smartmatching against a hash asks about its keys
- 10.36
.Set,.Bagand.Mixread the values as weights - 10.37 A Map prints as
Map.new, and converts to and from a Hash - 10.38 A Map refuses new keys and deletions; missing keys are Nil
- 10.39 A Pair's
.rakuuses the colon form only for identifier keys - 10.40 A Pair is a hash of one pair, and always true
- 10.41
cmporders pairs by key, then by value - 10.42
$x ~~ :methodcalls the method and compares truthiness - 10.43 A Pair on both sides smartmatches key and value
11. Ranges
- 11.1 Four operators and a prefix build a range
- 11.2
.Strlists the elements, whilesayshows the endpoints - 11.3 A Range, a Seq or a Complex cannot be an endpoint
- 11.4
1 .. * + 1is code that makes a range, not a range - 11.5 A numeric start converts the end; a string start converts nothing
- 11.6
minandmaxare the endpoints as written, exclusions ignored - 11.7
is-intandinfinitejudge the endpoints, not the elements - 11.8 Every range is true, even an empty one
- 11.9 Two ranges are the same value when their endpoints are
- 11.10
xxand~bind tighter than.., and a prefix|warns - 11.11
elemscounts without iterating, and an endless range fails - 11.12 An endless range is Inf as a number, though
elemsfails - 11.13 A numeric range steps by one from its start
- 11.14 A range of single characters walks the code points
- 11.15 A range of longer strings counts each position separately
- 11.16
*..1yields minus infinity forever - 11.17
reverseof a fractional range counts down from its end - 11.18
first(:end, :kv)counts its index from the end - 11.19 A loop over a range gets values, not containers
- 11.20 A range in a list is one element
- 11.21 Indexing a range computes the element
- 11.22 A range subscript selects its elements, and cannot go below zero
- 11.23 A Range is immutable
- 11.24 A number matches a numeric range by value, strings included
- 11.25
'raku' ~~ -∞..∞is False - 11.26 A string range compares in string order, not by its elements
- 11.27 One range is inside another when its endpoints are
- 11.28 Anything comparable can be a topic, and a Date range walks days
- 11.29
in-rangereturns True or throws - 11.30 Arithmetic with a number moves the endpoints, not the elements
- 11.31 A string range plus a number gets Failure endpoints
- 11.32 Ranges sort by start, then by end
- 11.33
sumuses a formula, and answers an Int for a Num range - 11.34
int-boundsandminmaxrefuse what they cannot state - 11.35
max(:k)of an open range names an element that is not there - 11.36
pickandrollchoose without building the list - 11.37 After
srand, the firstpickfrom a range differs - 11.38
randreturns a real number, and refuses an empty span - 11.39 A Range converts to lists and hashes; its Capture has six names
- 11.40 String methods see the range's text
- 11.41 Each numeric type has a Range, and a native type its exact bounds
- 11.42 The Range type object is a list of one undefined element
12. The Sequence Operator
- 12.1
...has four spellings, and…is the same operator - 12.2 Only
*andInfmake a sequence lazy - 12.3 The first element on the right is the endpoint; the rest is appended
- 12.4 An empty right side fails at once; an empty left side fails later
- 12.5 The seeds are checked against the endpoint before anything else
- 12.6 A numeric endpoint is a limit, not a target
- 12.7 Any other endpoint is smartmatched, and the walk goes upwards
- 12.8 A
nonejunction as the endpoint makes the sequence endless - 12.9 One or two seeds make an arithmetic sequence
- 12.10 Three seeds make an arithmetic or a geometric sequence
- 12.11 Only the first seed is emitted as written
- 12.12 Only the last three seeds decide the step
- 12.13 A failed deduction throws when the sequence is read, not when it is built
- 12.14 Seeds already beyond the endpoint produce nothing at all
- 12.15 A geometric sequence stops by size only for a negative ratio
- 12.16 A geometric sequence of negative numbers misses its endpoint
- 12.17 A code object among the seeds is the generator, and ends them
- 12.18 A generator receives as many previous values as it has parameters
- 12.19 A generator dies if the seeds are fewer than its parameters
- 12.20 With a generator, a numeric endpoint must be hit exactly
- 12.21 A code endpoint receives as many values as it has parameters
- 12.22
lastinside a generator or an endpoint ends the sequence - 12.23 A Slip from the generator adds several elements
- 12.24 The endpoint is tested once per call of the generator
- 12.25 A sequence fails where it is read, which may be outside the
try - 12.26 Single characters walk the code points
- 12.27 Strings of the same length vary each position separately
- 12.28
...^keeps the end of a string sequence of equal lengths - 12.29 Strings of different lengths walk in string order
- 12.30 Two string seeds never make a step
- 12.31 Any type with
succandpredcan be walked - 12.32 A chain of sequences starts each segment afresh
- 12.33 A chain always ends with its last endpoint
- 12.34
...^cannot be chained - 12.35 The left side takes the elements of any list
13. Sets, Bags and Mixes
- 13.1 A Set holds an element once; a Bag and a Mix weigh it
- 13.2 Elements are the same only when they are identical
- 13.3 Arrays and Lists are elements by identity; Pairs, Ranges and Sets by value
- 13.4 Every empty Set is the same object
- 13.5
setflattens one level;.newkeeps several arguments whole - 13.6 A Pair given to
setis an element, not a weight - 13.7 The coercers flatten all the way down and read Pairs as weights
- 13.8 Set, Bag and Mix read a Pair's value in three ways
- 13.9 A negative weight is skipped by a Bag and subtracted by a Mix
- 13.10 A weight that is not a finite real number throws
- 13.11 The string
"Inf"slips into a Mix - 13.12 A lazy list cannot become a Set, and an infinite Range is lazy
- 13.13
⊆,≡and⊂call a lazy operand ambiguous - 13.14 Converting to a narrower type drops weights that do not fit
- 13.15 A conversion from a hash form is a snapshot
- 13.16
.Bagof a Mix truncates the Mix itself - 13.17
Set[Str]checks its elements and keeps its name - 13.18
is Setmakes the variable a Set;is SetHashmakes it assignable - 13.19
my %h is Set;without a value is unusable - 13.20 A Set's values are all True, and its total is its size
- 13.21 A Bag's total is the sum of its weights, and
.kxxvrepeats each key - 13.22 A Mix's total is exact, may be negative, and has no
.kxxv - 13.23
saysorts the elements;.Strand.rakudo not - 13.24
.hashkeeps the elements as objects;.Mapmakes them strings - 13.25 Set, Bag and Mix are values; the hash forms are objects
- 13.26
eqvwants the same type,==compares sizes andcmpthe sorted pairs - 13.27 Smartmatching against a Set converts the left side to a Set
- 13.28 A Bag in a
$variable is one item; a bare Bag gives its Pairs - 13.29 In numeric context a QuantHash is its total, and it is not Cool
- 13.30 The type object
Setcounts as one element of itself - 13.31 A subscript on a Set answers a Bool, and assigning to it dies
- 13.32 Assigning to a SetHash key stores its truth
- 13.33
.setof a Set adds its Pairs, not its elements - 13.34 A BagHash truncates weights, and zero or less removes the key
- 13.35 A MixHash keeps negative weights, and accepts Inf and NaN
- 13.36 An undefined SetHash variable comes to life when used
- 13.37 The values of a hash form are live
- 13.38
>>maps the weights, and truncates them on a Mix - 13.39
pickdraws without replacement,rollwith - 13.40
grabneeds a hash form, and a Mix cannotpick - 13.41
classify-listcounts into a BagHash - 13.42
grab(*)removes each element only as it is read - 13.43 A Mix rolls by its positive weights only
- 13.44
∈sees a string as one element and a Hash by its values - 13.45
∪takes the larger weight; the left operand decides mutability - 13.46
∩takes the smaller weight - 13.47
∩of two Hashes ignores false values - 13.48
∖subtracts weights, and a Mix keeps what goes negative - 13.49 A Hash on the right of a Mix difference counts as a Set
- 13.50
⊖keeps the difference of the weights - 13.51
⊖of three operands is not two⊖in a row - 13.52
⊎adds weights and⊍multiplies them; neither makes a Set - 13.53 A reduction with no operands gives an empty Set or Bag
- 13.54
⊆compares weights, and a negative weight is less than none - 13.55
(<+)and≼were removed in 6.d - 13.56
≡compares in the richer type of its two operands - 13.57 Two Hashes compare their sizes before their truth
- 13.58 Set operators sit on the junction levels, and different ones do not mix
- 13.59 The Boolean set operators chain like comparisons
- 13.60
∪=builds a new collection instead of changing the old one - 13.61 A Junction operand makes four operators hang
- 13.62 A Failure operand throws, even one already handled
14. Blobs and Bufs
- 14.1
blob8andbuf16are short names for parameterised roles - 14.2 A plain
Blobis not ablob8 - 14.3 A buffer is Positional and Stringy, but not a list
- 14.4 Only native integers can be elements
- 14.5
.newflattens lists and ranges, and accepts only integers - 14.6 A value too wide for the element wraps around
- 14.7
.bytesof aBlob[int]counts one byte per element - 14.8
allocatefills with a value or repeats a pattern - 14.9
allocatewith an empty pattern never returns - 14.10
sayprints a buffer in hex, and~refuses it - 14.11 The hex dump stops after 200 digits
- 14.12 Two equal Blobs are one value; two equal Bufs are not
- 14.13
eqvwants the same type,eqcompares values,==counts - 14.14
cmpcompares lengths before contents - 14.15 A buffer is its number of elements in numeric context
- 14.16 Smartmatching a buffer compares its elements, across types
- 14.17 A regex against a buffer matches one element's digits
- 14.18 A Blob refuses every change, each with its own exception
- 14.19 A Blob index past the end is a Failure; a slice past the end throws
- 14.20 A Buf reads zeros past its end, and grows when written there
- 14.21 Every element view of a Buf writes back into it
- 14.22
pushtakes values;appendalso spreads a list - 14.23 A bad value among several grows the Buf, then throws
- 14.24
spliceremoves, inserts, and pads past the end - 14.25 A failed
splicestill changes the Buf - 14.26
is buf8makes an array variable a Buf - 14.27
subbuftakes a start and a length, a range, or code - 14.28
subbufwith a string start and a length never returns - 14.29
subbuf-rwreplaces a stretch of a Buf, and reads back the old one - 14.30
reallocatesets the length, padding with zeros - 14.31
~keeps the type only when both sides share it - 14.32
Xtakes a buffer as one item;Zwalks through it - 14.33
~&,~|and~^combine buffers element by element - 14.34
~&and~|die on signed buffers of unequal length - 14.35 List methods see the elements;
reducesees one buffer - 14.36
encodereturns autf8, autf16or aBlob[uint8] - 14.37 Encoding names ignore case; an unknown name throws
- 14.38
encodewith a number as the encoding never returns - 14.39 Without
:strict, a code point below 256 is written as its byte - 14.40
:replacementalso applies under:strict, and takes any value - 14.41
decodeuses the buffer's own encoding, or UTF-8 - 14.42 Malformed bytes die, and
:replacementdoes not rescue UTF-8 - 14.43 UTF-16 follows a byte-order mark; UTF-8 drops one
- 14.44
utf8-c8keeps every byte, in synthetic characters - 14.45 A 16-bit buffer decodes its bytes, not its elements
- 14.46 A
utf8becomes its text wherever a string is wanted - 14.47 An
Encodingobject makes encoders and incremental decoders - 14.48
Encoding::Registry.registerteachesencodea new name - 14.49
read-uint16and its kin read bytes at an offset, in a chosen order - 14.50 On a wide buffer,
read-*andwrite-*count the offset in elements - 14.51
read-num32andread-num64decode IEEE floats - 14.52
read-ubitscounts bits from the top of the first byte - 14.53
read-bitsof zero bits is -1 - 14.54
write-*grows the buffer and cuts the value to size - 14.55
write-ubitswrites the low bits of a value at a bit position - 14.56
write-ubitsclears the bits after the run in its last byte - 14.57
packandunpackneeduse experimental :pack - 14.58 The type object
Blobis a list of one element - 14.59
Blob(…)coerces through.new;.Bufand.Blobcopy
15. Signatures and Introspection
- 15.1
.aritycounts required positionals;.countcounts all of them - 15.2 A call with the wrong arguments dies with
X::AdHoc - 15.3 A call that can never bind is refused before the program runs
- 15.4 A method takes any named argument; a sub refuses it
- 15.5 A Pair written in a call is a named argument
- 15.6 Named parameters are optional unless marked with
! - 15.7 A default is computed at each call, and may use earlier parameters
- 15.8 A parameter is read-only;
is copymakes a private copy - 15.9
is rwneeds a variable, and a typed one checks its type - 15.10
\xandis rawpass the argument as it is - 15.11
:Dand:Ucheck definedness, with their own exception - 15.12 A failed type check names the parameter, the value and the type
- 15.13
wheresmartmatches the argument against anything - 15.14 An optional parameter's
whereruns when the argument is left out - 15.15 A
subsetis a named type with awhere - 15.16
Int()calls.Inton whatever arrives - 15.17 A coercion that fails binds a Failure
- 15.18 A coercion from an undefined value warns; other bad sources throw
- 15.19 A coerced parameter has no container, and its elements are not coerced
- 15.20
*@flattens,**@keeps each argument,+@decides by the count - 15.21 A slurpy array is an Array, but
+aandis rawgive a List - 15.22 A
*@slurpy of literals has read-only elements - 15.23 A slurpy hash takes the named arguments; a capture takes everything
- 15.24
is itemonly chooses between candidates - 15.25
::Tcaptures the type of an argument - 15.26 A sub-signature unpacks an argument
- 15.27 Placeholders become parameters in alphabetical order
- 15.28 A block without a signature takes one optional argument
- 15.29 The topic parameter's default is the
Codetype object - 15.30
&?ROUTINEand&?BLOCKname the running code - 15.31
-->,returnsandofdeclare one return constraint - 15.32 A value that fails the return constraint throws
X::TypeCheck::Return - 15.33
--> 42and--> Nilreturn a constant whatever the body does - 15.34 A return constraint makes a routine a
Callable[T] - 15.35
returnleaves the innermost routine, through any blocks - 15.36 A
returnwith no routine to leave throws - 15.37
returnhands back a read-only container;return-rwa writable one - 15.38
failin a block fails the routine around it, or throws - 15.39 Blocks, routines and WhateverCodes share one type tree
- 15.40 A code object knows its name; an anonymous one's is empty
- 15.41
.file,.lineand.packagesay where code was declared - 15.42 Smartmatching against code calls it and takes the truth of the result
- 15.43
.candotells whether a Capture would bind; a routine's ignores extra nameds - 15.44 A block lists its phasers, and they can be called by hand
- 15.45
KEEPandUNDOlook at the result;PREandPOSTguard a call - 15.46 A stub body dies when it runs;
???only warns - 15.47 A multi's name is its proto, which lists the candidates
- 15.48
.multiis 0 on a proto, and a plain sub's.dispatcheris anNQPMu - 15.49 The narrowest candidate wins
- 15.50 A tie dies as ambiguous, unless one candidate
is default - 15.51
Int:DandInttie for a defined Int - 15.52 No matching candidate throws
X::Multi::NoMatch - 15.53 A proto can run code around
{*}; a bare{*}checks nothing - 15.54
callsameandnextsamego on to the next candidate - 15.55
samewithdispatches again from the top - 15.56
.wrapputs a new layer around a routine - 15.57
nextsamein a pointy-block wrapper throws - 15.58 A wrapper sees every call, recursive ones included
- 15.59
.assumingfixes some arguments and leaves the rest - 15.60 A primed sub is named
assumed.f, and holds on to variables - 15.61 A routine trait mixes a role into the routine
- 15.62
is DEPRECATEDkeeps a routine working and reports it at exit - 15.63
is exportfiles a symbol under tags - 15.64
is tighter,is looserandis equivplace a new operator - 15.65 An operator reports its precedence, and
.prec("prec")dies - 15.66 A method's signature starts with its invocant and ends with
*%_ - 15.67 A parameter can set an attribute directly
- 15.68 A method's signature prints
$::, which does not parse back - 15.69 A printed signature leaves out the default type and computed values
- 15.70
Int:D()prints asInt:D(Any):D, which does not compile - 15.71 A computed default prints as
Code.new, which does not rebuild it - 15.72 The compiler refuses a malformed signature
- 15.73 A Capture smartmatches a signature it would bind to
- 15.74 Signature against signature:
~~asks for compatibility,eqvfor sameness - 15.75 A
whereclause is equal to nothing, not even to itself - 15.76 A signature built with
Signature.newcannot bind anything - 15.77
Signature.newtakes the count as given - 15.78
Parameter.newdies on+@aand doubles a bare name - 15.79 A Parameter answers questions about itself
- 15.80 An Attribute answers questions about itself
- 15.81
is required,is builtandis defaulton attributes - 15.82 A role's attribute belongs to
$?CLASSuntil it is composed - 15.83
set_valuewrites an attribute without a type check - 15.84 A WhateverCode has one parameter per star
- 15.85 A method call on a
*expression becomes part of it - 15.86 A
*on the right of~~takes the whole smartmatch - 15.87 A WhateverCode's
.fileis a null string - 15.88 Code in an array subscript receives the length once per parameter
- 15.89 A ForeignCode's gist is not its name
16. Exceptions and Failures
- 16.1 An uncaught exception prints a backtrace and exits with status 1
- 16.2
say $!prints the backtrace along with the message - 16.3
trygives its block's value, or Nil with the exception in$! - 16.4 A successful
tryresets$!toAny - 16.5 Each routine has its own
$!, shared by its blocks - 16.6 A nested
tryhands its exception to the rest of the outer block - 16.7 CATCH handles what a
whenordefaultmatches, then leaves the block - 16.8 An exception that no
whenmatches goes on outward - 16.9 A
trywith its own CATCH catches nothing else - 16.10 Inside CATCH the exception is
$_, and it never becomes$! - 16.11 A CATCH in a loop body ends one iteration, and
$_is the exception - 16.12 A trailing CATCH makes the block's value Nil
- 16.13
.resumecontinues after the statement that threw - 16.14
.resumerefuses a finishedtryand a missing method - 16.15
.rethrowkeeps the original backtrace;.throwstarts a new one - 16.16 An exception class supplies its own
message - 16.17 An exception object has no backtrace until it is thrown
- 16.18
diewith anything but an Exception throws an X::AdHoc - 16.19
diewithout an argument rethrows$!, or says "Died" - 16.20
diethrows an exception object as it is, and a Failure's exception - 16.21 A trailing newline does not hide the backtrace;
:without-backtracedoes - 16.22
warnprints to standard error, goes on, and returns 0 - 16.23
warnjoins its arguments, and an empty warning gets a stock message - 16.24 CONTROL catches warnings; without
.resumeit leaves the block - 16.25
quietlyswallows warnings before any CONTROL sees them - 16.26 A
lastcaught by CONTROL does not end the loop - 16.27 Rethrowing a caught
return,takeoremitloses its value - 16.28 Loop control outside a loop throws X::ControlFlow
- 16.29 An uncaught stray
lastis reported like a compile-time error - 16.30
nextandlastin a called sub act on the caller's loop - 16.31 A class that does X::Control reaches CONTROL and never CATCH
- 16.32 A bare
succeedyields an internal null that cannot be printed - 16.33
failreturns a Failure from the routine;diethrows - 16.34
failaccepts whatdieaccepts - 16.35 Outside a routine,
failthrows likedie - 16.36 A bare
failandFailure.newlook for$!in different places - 16.37
failwith a handled Failure re-arms it - 16.38 A Failure that throws far from its
failreports both places - 16.39 An unhandled Failure can warn when the garbage collector frees it
- 16.40 An unhandled Failure passes through subscripts, lists and
for - 16.41 A Failure owns the backtrace of its
fail - 16.42
use fatalmakes a returned Failure throw at once - 16.43 A Failure assigned to a typed variable reports two errors
- 16.44 A backtrace holds every frame; its string shows the interesting ones
- 16.45
.nice(:oneline)shows the second frame, not the first - 16.46
Backtrace.newrecords where it is created - 16.47
is hidden-from-backtraceleaves a routine out of the report - 16.48
awaitrethrows a thread's exception with a role mixed in - 16.49 A
diein amapblock fires when that element is computed - 16.50 LEAVE runs on every exit; KEEP and UNDO split success from failure
- 16.51 A dying ENTER stops the queue; a dying LEAVE does not
- 16.52 A LEAVE sees the exception in
$!only inside thetry - 16.53 In a loop, LEAVE runs before NEXT
- 16.54 PRE and POST throw X::Phaser::PrePost with the condition's source
- 16.55 Compile-time errors are exceptions, and EVAL makes them catchable
- 16.56 A call that can never match its signature fails at compile time
- 16.57 A compile-time exception carries the details of the complaint
- 16.58 Dispatch and type-check errors name what they got and expected
- 16.59 Each misuse of a value has its own exception type
17. Regexes and Grammars
- 17.1
|takes the longest alternative,||the first that matches - 17.2 A code block ends the part of a branch that
|measures - 17.3 A code block runs every time the engine reaches it
- 17.4
tokenandrulenever backtrack;regexdoes - 17.5
:stops backtracking into one atom,!allows it under a ratchet - 17.6
ruleputs<.ws>after every atom, the last one included - 17.7
<ws>cannot match between two word characters - 17.8
%puts a separator between repetitions of one atom - 17.9
<(and)>choose the part of the match that counts - 17.10 After
)>,.posis not.to - 17.11 A capture can be matched again later in the same regex
- 17.12
&wants both sides to match the same stretch of text - 17.13 A lexical regex hides a built-in rule, but not from
<.name> - 17.14
$varmatches its text;<$var>compiles it - 17.15 An interpolated regex keeps its captures to itself
- 17.16
<%h>compiles and never matches - 17.17 Nothing captured inside a lookaround survives
- 17.18 Any quantifier makes a capture an Array, except
? - 17.19 An absent capture prints as Mu in
.list, but reads Nil - 17.20 Alternatives number their captures from the same index
- 17.21 A named group is not numbered, and a repeated name collects an Array
- 17.22
.capsand.chunkskeep the order of the text;.keysdoes not - 17.23 Two matches of the same text are
eqv, never=== - 17.24 A Match computes with its text
- 17.25 A zero-width match is true; a Match that ends before it starts is false
- 17.26
~~and.matchset the caller's$/, to Nil on failure - 17.27 Each routine has its own
$/; its blocks share it - 17.28 Inside a code block,
$/is the match so far - 17.29
makeneeds a Match, and the lastmakewins - 17.30 A list on the left of
~~is matched element by element - 17.31 An undefined topic is matched as the empty string, with a warning
- 17.32 A Match on the right of
~~answers itself - 17.33 A regex in Boolean context matches
$_, and in string context warns - 17.34 A regex called with a Match matches only at that position
- 17.35
m//matches at once, with the adverbs of.match - 17.36
.matchwith a string searches for the text, and ignores:i - 17.37
:greturns a List, empty when nothing matches - 17.38
:ovfinds one match per start position,:exevery match - 17.39
:xwants an exact count, and ignores a Range's excluded ends - 17.40 An invalid
:xis a Failure, and:x(Nil)dies - 17.41
:nthcounts from 1, from the end, or down a list - 17.42
:nthrefuses 0 and a list that does not increase - 17.43
:nth(2), :x(1)answers an empty list - 17.44
:cscans from a position,:panchors there, and Nil swaps them - 17.45
:as(Str)returns the text, but not with:cor:p - 17.46 A replacement string is built before
substruns - 17.47
s///returns the Match, or False when nothing matched - 17.48
S///works on$_, and~~ S///is never useful - 17.49 The replacement of
s///is code, and some adverbs are refused - 17.50
indexand its relatives refuse a regex;substrdies trying - 17.51
transpairs a list of regexes, and skips the Regex type object - 17.52
parsemust reach the end, and returns the grammar's own type - 17.53 A grammar without
TOPcannot parse, and neither canGrammar - 17.54 A failed
subparseis a Match whose.tois -3 - 17.55
:rule,:argsand:poschoose where a parse starts - 17.56 A grammar parses any object, and
.origkeeps it - 17.57
parsefilereads the file and hands the rest toparse - 17.58
parseretriesTOPonly ifTOPcan backtrack - 17.59 Named arguments to
parseset attributes the result forgets - 17.60 A rule is a method that runs on a Match
- 17.61 A subgrammar overrides rules by name, and
<ws>captures - 17.62 An actions object is called after each named rule succeeds
- 17.63
.actionsof a parse without actions is not a Raku object - 17.64 An action's
makereplaces the one in the rule's body - 17.65 The action is named after the rule, not the alias
- 17.66 A proto token takes the longest candidate, whose action fires
- 17.67 Actions fire for branches that are later abandoned
18. Dates and Times
- 18.1
nowis an Instant,timean Int, and they are 37 seconds apart - 18.2
from-posixadds 10 seconds, and one more per leap second so far - 18.3 A POSIX time names two seconds when a leap second falls on it
- 18.4 Adding to an Instant gives an Instant; subtracting two gives a Duration
- 18.5 An Instant equals its count of atomic seconds, not its POSIX time
- 18.6 Equal Instants and equal Durations are not
=== - 18.7 A Duration prints as a plain number and stores whole nanoseconds
- 18.8
Duration.new(Inf)is not a Duration - 18.9 Only
+,-and%keep a Duration - 18.10
Date.newtakes three parts, named parts, a string or an Instant - 18.11 The day may be
*, or code that receives the month's length - 18.12
Date.newignores names it does not know,:timezoneincluded - 18.13 A formatter changes
.Strand.gist, never.raku - 18.14 A Date made from a DateTime takes over its formatter
- 18.15 A date string is exactly
YYYY-MM-DD - 18.16 A bad month or day throws
X::Temporal::OutOfRange, with the valid range - 18.17
day-of-weekcounts from Monday, andweekis the ISO week - 18.18 A Date as a number is its Modified Julian Day
- 18.19
yyyy-mm-ddand its relatives take a separator - 18.20 Years outside 1000 to 9999 are padded or signed
- 18.21 The calendar is Gregorian all the way back, and year 0 exists
- 18.22 A Date plus an Int moves by days; a Date minus a Date counts them
- 18.23 Any other arithmetic on a Date quietly uses its day count
- 18.24 The sum of some Dates is a Date or an Int, depending on the count
- 18.25 Dates compare by day, but
cmpandsortcompare their text - 18.26 A Date's identity is its day: a formatter does not count, a subclass does
- 18.27 A DateTime matches the Date of its own clock; a Date matches no DateTime
- 18.28 A range of Dates walks one day at a time
- 18.29 A Date range compares by text, so a formatter cuts it short
- 18.30
laterandearliermove by one unit; a month clips the day - 18.31 An unknown unit dies on a Date and does nothing on a DateTime
- 18.32
truncated-toaccepts any word that begins with a unit - 18.33 A DateTime truncates in its own zone
- 18.34
clonereplaces fields and checks them again - 18.35 A Date becomes a DateTime at midnight UTC, without its formatter
- 18.36
:yearbeside:datethrows the date away - 18.37
DateTime.newreads ISO 8601, with a zone or without - 18.38 Near misses of ISO 8601 are refused
- 18.39 A
Zgives way to:timezone, but an offset clashes with it - 18.40 A date-only string with a bad month dies with an internal error
- 18.41 A number is a POSIX time, and the second takes its type
- 18.42 The six-part form keeps the second exactly as given, even a string
- 18.43 Hour and minute throw
X::Temporal::OutOfRange; the second does not - 18.44 A second of 60 is accepted only at 23:59 UTC on a leap-second day
- 18.45
.posixdrops the fraction,.Instantkeeps it, and.Intis refused - 18.46 The calendar methods follow the local date; the Julian dates follow UTC
- 18.47 The default text shows the zone to the minute, and six decimals when needed
- 18.48 Rounding the second can print one that does not exist, or die
- 18.49 A DateTime's identity is its printed text
- 18.50 DateTimes compare by moment, except with
cmp,legandsort - 18.51
in-timezonemoves the clock and keeps the moment - 18.52
clone(:timezone)keeps the clock and moves the moment - 18.53
.localfollowsmy $*TZ, butDateTime.nowdoes not - 18.54
DateTime.nowis local with a Num second;now.DateTimeis UTC with a Rat - 18.55 A leap second and the second after it share one POSIX time
- 18.56 The Date of a leap-second Instant is the next day
- 18.57 A leap second keeps its
:60in every zone - 18.58
lateron a DateTime carries into days and keeps the zone - 18.59 Moving by seconds counts leap seconds; moving by days clips
:60to:59 - 18.60 DateTime minus DateTime is a Duration that counts leap seconds
- 18.61 A DateTime plus a plain number is an Instant, and a Duration drops the formatter
- 18.62 Instants and Durations are Cool; Dates and DateTimes are not
- 18.63 The fields are read-only, and the type objects refuse them
19. Files and Paths
- 19.1
.IOkeeps the path exactly as written - 19.2 An empty path throws at once
- 19.3
dirnameandbasenamesplit the text at the last slash - 19.4
.cleanuptidies the text and keeps every.. - 19.5
.absoluteis canonical:./aanda/are the same path - 19.6
.resolveremoves..only where the directory exists - 19.7 A relative path remembers the directory it was made in
- 19.8
.parentis textual, soa/..has the parenta - 19.9
.child,.addand.siblingjoin text with one slash - 19.10
.extensioncounts dot-parts from the right - 19.11
.extensionwith a value makes a path with a new extension - 19.12 An explicit
:parts(1)does not add a missing extension - 19.13
.succon a path increments the text before its first dot - 19.14 A smartmatch with a path compares paths; with a string, text
- 19.15 Two paths with the same text are two values
- 19.16
.eis a Bool; the other tests of a missing file fail - 19.17
.sis a size,.modean IntStr, and the times are Instants - 19.18 The standard handles' paths are IO::Special values
- 19.19
mkdircreates the parents and passes over an existing directory - 19.20
unlinkof a missing file is True - 19.21 The sub forms of
unlink,rmdirandchmodreturn what worked - 19.22
copy,renameandmovegive the reason in.os-error - 19.23 A second
symlinkfails; a dangling one does not - 19.24
symlinkstores an absolute target unless told otherwise - 19.25
dirlists paths that start with the directory as written - 19.26
dir's test sees the bare name, and can let.and..in - 19.27
spurtwrites, replaces or appends, and returns True - 19.28
slurpof a missing file throws, whileopenfails - 19.29 Reading turns
\r\ninto\n - 19.30
.linessplits onnl-in, and:!chompkeeps the separators - 19.31
.words,.comband.spliton a path read the file - 19.32 The
linessub reads a file only when given a path - 19.33 A UTF-16 file begins with a byte-order mark
- 19.34 Every output method returns True, and
.tellcounts bytes - 19.35 A closed handle refuses with two kinds of exception
- 19.36
.eofis True beforegetreturns Nil - 19.37
lines($n)stops after n lines and leaves the handle open - 19.38 On a handle,
.lines(:!chomp)keeps every line end but the first - 19.39 A handle's
:nl-in("\r\n")never sees a\r\n - 19.40
read,readcharsandslurpgo on from the current position - 19.41 A
:binhandle reads bytes and refuses lines - 19.42
openfails when the system refuses, and throws on a bad argument - 19.43
:rwcreates without emptying;:updatedoes not create - 19.44 Encoding names are normalised, and
.encodingswitches in mid-file - 19.45
promptreturns an allomorph, and Nil at the end of input - 19.46
$*IN.lines($n)leaves the rest of the input unread - 19.47
indirruns a block in another directory, or fails - 19.48
chdirchanges$*CWD, not the process's directory - 19.49
IO::Path.chdironly computes a path - 19.50 IO::Spec::Unix does the text work, and its
:parentremovesx/.. - 19.51
sayprints a Junction;putandprintprint each value - 19.52
nl-outis whatsay,putandprint-nladd - 19.53
IO::Handle.newmakes a closed handle - 19.54
lockandflushreturn a Failure when they cannot - 19.55 A command's output is an IO::Pipe whose
closereturns the Proc - 19.56 IO::CatHandle reads several files as one
- 19.57 A CatHandle's on-switch runs per file, and once more with Nil
20. Processes
- 20.1
runpasses arguments as they are;shellhands one string to/bin/sh - 20.2 Arguments are turned into strings, and lists are flattened
- 20.3 A
Procis true only when the exit code and the signal are both 0 - 20.4 A program that cannot start gives exit code -1, signal 254 and no pid
- 20.5
:outgives a read-onlyIO::Pipe, and closing it returns theProc - 20.6
.exitcodewaits for the program, and so does reading to the end - 20.7 Reading
.outfirst can deadlock when.erris captured too - 20.8
:mergeputs both streams in.out, but not in the order they were written - 20.9
:ingives a write-only pipe; without it, the program reads the parent's input - 20.10 An open handle or another program's pipe can stand in for a stream
- 20.11 A binary pipe refuses text with
X::IO::Closed - 20.12
read($n)on a binary pipe returns a whole chunk, whatever$nis - 20.13
:nlsets the line separator both ways, and:!chompkeeps it - 20.14 A text pipe turns
\r\ninto\nbefore:nlsees it - 20.15
:envreplaces the whole environment, but the program is found through the parent'sPATH - 20.16
Proc.newbuilds a finishedProc, or one that spawns later - 20.17 Asking a new
Procfor its status fixes the status at 1 - 20.18
Proc::Async.newignores the named arguments it does not know - 20.19
.startreturns a promise of a bareProc, andawaitas a statement checks it - 20.20 A program that cannot start breaks the promise with
X::OS - 20.21
.starttakes:ENV, not:env, and ignores the wrong one - 20.22 An untapped
.stdoutholds back the start promise - 20.23 Output nobody captures can overtake the parent's buffered output
- 20.24 A Supply must be chosen before
.start, and some choices exclude others - 20.25 A tap added after the output has ended receives nothing, not even
done - 20.26 Every chunk and every
donecome before the start promise is kept - 20.27 A chunk is not a line, and its last character waits for the next
- 20.28
\r\nbecomes\n, and:enccan be set for each stream - 20.29 Malformed input quits the Supply, and the text before it is lost
- 20.30 The merged Supply is read from the start, and
whenever $proctaps it - 20.31
bind-stdoutandbind-stderrsend a stream into an open handle - 20.32
bind-stdinfeeds a program from a file or another program - 20.33 Writing needs
:w, and the program sees the end only afterclose-stdin - 20.34
.killsends SIGHUP unless told otherwise, and returns the number it sent
21. Promises, Locks and Awaiting
- 21.1 A Promise is false until it is kept or broken
- 21.2
sayon a Promise shows its status, not its value - 21.3
keepstores exactly its argument, andTruewhen there is none - 21.4
breakwithout a cause breaks with "Died", not False - 21.5
.causerefuses a promise that is not broken - 21.6
.resultwaits, then rethrows a copy of the cause - 21.7 A promise is resolved once, and the refusal names a vow
- 21.8
keepholds on to the variable, not its value - 21.9
eqvcompares results, so it waits for them - 21.10 A
thenblock receives the promise, not its result - 21.11 Each
thenmakes a new promise, and one promise can have many - 21.12
then(:synchronous)runs insidekeep, and may return a plain value - 21.13 A dying synchronous
thenmakeskeepthrow an unrelated error - 21.14
andthenandorelsepick the outcome they handle - 21.15 A
startblock sees the outer$_, but fresh$/and$! - 21.16
startandthensee the dynamic variables of their creator - 21.17
starttakes an expression, and a dying block breaks its promise - 21.18 A dying
startwhose promise is sunk ends the program - 21.19
Promise.inkeeps with True after a delay;Infnever does - 21.20
anyofandallofcount a broken promise as done - 21.21
awaitand.resultrethrow with different roles - 21.22
awaiton several promises returns their results in argument order - 21.23
await ()is an empty list;await()is an error - 21.24
awaiton the thread pool does not hold on to its thread - 21.25
awaitrefuses a Junction, andbreakautothreads over one - 21.26 A Channel queues values until they are received
- 21.27 A Channel's
closedpromise waits until the queue is empty - 21.28 A Channel passes values between threads, and
awaitreceives one - 21.29
awaiton a Channel takes a Nil value for no value - 21.30
sleepreturns Nil, and some arguments mean never - 21.31
sleep-timerreturns what it did not sleep;sleep-untila Bool - 21.32
sleep-timer NaNfails its own return type check - 21.33
Lock.protectreturns what its block returns, container and all - 21.34 A Lock is re-entrant, and only its holder may unlock it
- 21.35 Every call of
.conditionmakes a new condition variable - 21.36
Lock::Softis a Lock whose misuse has typed exceptions - 21.37
Lock::Async.lockreturns a promise, and the lock is not re-entrant - 21.38
protect-or-queue-on-recursiondefers the inner call instead of waiting - 21.39 A Semaphore hands out permits, and
releasehas no ceiling - 21.40 A Semaphore's permit count wraps at 32 bits
- 21.41
cuereturns Nil, and a Cancellation only with a timer - 21.42 A CurrentThreadScheduler runs everything at once, in the caller
- 21.43
hyperkeeps the order of the elements,racedoes not - 21.44 An exception in a
hyperworker surfaces where the values are read - 21.45 A Promise becomes a Supply of its one value
22. Supplies
- 22.1 A Supply comes from a factory, a Supplier or a supply block
- 22.2
from-listdelivers every value before.tapreturns - 22.3
from-listflattens a single Iterable argument only - 22.4 A tap with no quit handler rethrows the quit at the emitter
- 22.5 A Supplier reaches only the taps present when it emits
- 22.6 After done, a tap receives nothing more
- 22.7 An emit from inside a handler waits until that handler returns
- 22.8 A tap's handler never runs on two threads at once
- 22.9 Supplier::Preserving keeps events until the first tap
- 22.10 Only a Supplier's supply is live
- 22.11 Closing a tap twice runs an
on-closehook twice - 22.12
on-demandruns its producer once per tap, on the tapping thread - 22.13 A supply block runs again for every tap
- 22.14 The body runs to its end before any whenever event
- 22.15 Closing the Tap of a whenever does not finish the supply
- 22.16 whenever accepts anything that coerces to a Supply
- 22.17 A whenever over a Promise delivers its value later, from another thread
- 22.18 A whenever over a Channel drains it until it closes
- 22.19 react waits until it is done and then returns Nil
- 22.20 A quit ends react with the exception
- 22.21
emitinside react only warns - 22.22
doneends the supply at once - 22.23
lastfinishes one whenever,nextskips one value - 22.24 A LAST run by
lastcannot emit - 22.25 A supply block is done when its body and every whenever are done
- 22.26 An exception in a supply block becomes its quit
- 22.27 One whenever's quit ends the whole supply
- 22.28 QUIT belongs to the whenever and handles a quit like CATCH
- 22.29 A QUIT that matches nothing lets the quit through
- 22.30 QUIT sees only its own source
- 22.31 LAST runs when a source finishes, not on
done - 22.32 CLOSE phasers run in reverse, before or after the done handler
- 22.33 Closing the tap of a supply block closes everything inside it
- 22.34
wheneveroutside a supply or react does not compile - 22.35
donein a tap handler can end a supply block without its done handler - 22.36 An exception in
.mapbecomes a quit, and later values still arrive - 22.37 After a leaking quit,
.listandawaitlose the exception - 22.38
grepsmartmatches, andfirstisgrepthenhead - 22.39
headcloses its source;tailwaits for done - 22.40
tailof an empty supply emits Any - 22.41
uniquecompares by identity;squish's:withsees the previous value - 22.42
rotoremits Arrays and repeats its cycle - 22.43
batchwithout a size makes batches of one - 22.44
batch(:emit-timed)never emits - 22.45
elems($seconds)never reports the final count - 22.46
elemswith an interval below one second divides by zero - 22.47
minandmaxemit each new record - 22.48
reduceof an empty supply emits Nil - 22.49
sortandreversewait for done;rotateholds back only its count - 22.50
classifyemits a Pair per new key, with a supply that replays - 22.51
linesandwordsjoin text across chunks - 22.52
splitwith a limit drops the rest - 22.53
combwith a regex never joins a match across chunks - 22.54
decodeholds back the last character of every chunk - 22.55
flatfollows every inner supply;migrateonly the newest - 22.56
mergeinterleaves, and wants defined supplies - 22.57
zippairs values in step;zip-latestpairs the latest ones - 22.58
sanitizeenforces the order of events, andacttaps through it - 22.59
sharesubscribes once, and at once - 22.60
.listsubscribes at once and reads lazily - 22.61 A supply as a Promise holds its last value
- 22.62
.Channelcloses on done and fails on quit - 22.63
intervalticks from 0, and its delay comes first - 22.64
delayedshifts every event, done included - 22.65
stableemits a waiting value after the done - 22.66
throttlelets a number of values through per interval - 22.67
Supply.startemits a supply per value
A. Possible Bugs
- A.1 Braces inside
qx{…}run a command of their own - A.2
7 mod 2.5is -0.5, and an Int'spolymodfollows it - A.3
Inf ** -1is an underflow, not zero - A.4 A negative base to a negative power puts the sign on the denominator
- A.5
[lcm] ()dies of an ambiguous call - A.6 A left shift by a negative count past -63 wraps around
- A.7
1e-300.narrowis 0 - A.8
<42>.linesreturns an allomorph whose number is 0 - A.9
rindexdies on a position at the end - A.10
rindexwith a needle list and a position never returns - A.11
combwith a string and a limit finds overlapping matches - A.12
lines(:!count)dies - A.13
splitwith a string needle dies on a fractional limit - A.14
split(:v)gives a string for a regex in a list of needles - A.15 A zero-width regex in a list of needles never returns
- A.16 An empty needle with
:gmisses both ends - A.17
substwith:as(Str)dies under:g,:nthor:x - A.18
subst-mutateaccepts:ovand:ex, whichsubstrefuses - A.19
.matchwith a negative:cmatches before the start - A.20
encodewith an undefined or numeric encoding never returns - A.21
splicewithout a size removes only what a lazy array has computed - A.22
reverseof a fractional range counts down from its end - A.23
first(:end, :kv)on a Range counts its index from the end - A.24 A
nonejunction as the endpoint makes the sequence endless - A.25 A geometric sequence of negative numbers misses its endpoint
- A.26 The endpoint is tested once per call of the generator
- A.27
...^keeps the end of a string sequence of equal lengths - A.28 A chain always ends with its last endpoint
- A.29
.Bagof a Mix truncates the Mix itself - A.30
my %h is Set;without a value is unusable - A.31
∩of two Hashes ignores false values - A.32 A Junction operand makes four set operators hang
- A.33
.bytesof aBlob[int]counts one byte per element - A.34
allocatewith an empty pattern never returns - A.35 A bad value among several grows the Buf, then throws
- A.36 A failed
splicestill changes the Buf - A.37
subbufwith a string start and a length never returns - A.38
~&and~|die on signed buffers of unequal length - A.39
write-ubitsclears the bits after the run in its last byte - A.40
.multiis 0 on a proto, and a plain sub's.dispatcheris anNQPMu - A.41
.prec("prec")fails its own return type - A.42 A method's signature prints
$::, which does not parse back - A.43
Int:D()prints asInt:D(Any):D, which does not compile - A.44 A signature built with
Signature.newcannot bind anything - A.45
Parameter.newdies on+@aand doubles a bare name - A.46 A WhateverCode's
.fileis a null string - A.47 A ForeignCode's gist is not its name
- A.48 Rethrowing a caught
return,takeoremitloses its value - A.49 A bare
succeedyields an internal null that cannot be printed - A.50 In a loop, LEAVE runs before NEXT
- A.51
.matchwith:x(Nil)dies of an arity error - A.52
:nth(2), :x(1)answers an empty list - A.53
.actionsof a parse without actions is not a Raku object - A.54 A Date range compares by text, so a formatter cuts it short
- A.55 A date-only string with a bad month dies with an internal error
- A.56 Rounding the second can print one that does not exist, or die
- A.57 A DateTime's identity is its printed text
- A.58 DateTimes compare by moment, except with
cmp,legandsort - A.59
read($n)on a binary pipe returns a whole chunk, whatever$nis - A.60 Asking a new
Procfor its status fixes the status at 1 - A.61 A dying synchronous
thenmakeskeepthrow an unrelated error - A.62
awaiton a Channel takes a Nil value for no value - A.63
sleep-timer NaNfails its own return type check - A.64 A Semaphore's permit count wraps at 32 bits
- A.65 A LAST run by
lastcannot emit - A.66 After a quit from
.map, later values and a done still arrive - A.67
batch(:emit-timed)never emits - A.68
elemswith an interval below one second divides by zero - A.69
stableemits a waiting value after the done
B. Writing a Probe
- B.1 A
tryaround a lazy Seq catches nothing - B.2 Through
try, a Failure looks like adie, or like success - B.3
$!belongs to the latesttryin the routine - B.4 A
trywith a CATCH of its own lets the rest escape - B.5 Rakudo computes an operation on literals while it compiles
- B.6 A literal mistake keeps the whole probe from compiling
- B.7 Braces in a double-quoted EVAL string run before the EVAL
- B.8 A list operator inside
saytakes every argument after it - B.9 Precedence can build a different expression from the one intended
- B.10 A sub's
$_,(* + 1).arityandtry { $^a }mislead - B.11 A Pair in a call is a named argument, not data
- B.12
sayprints nothing if one argument cannot be printed - B.13 Plain printing hides what a value is
- B.14 Hash and set order changes with every run
- B.15 Several "Useless use" warnings come out in a random order
- B.16 After
srand, a first pass draws other numbers - B.17 A dropped Failure warns at an unpredictable moment
- B.18 A probe that prints a path prints where it ran
- B.19 An endless list hangs a probe that has no timer
- B.20 An output that changes between runs cannot be verified