Values
Numeric quantities with units, multiple-choice responses, and tablets
Every step has a result, and that result carries a value.
A value can be in the output of another procedure, the return from a function call, or a literal from the input document itself.
The descriptions of a procedure or the content of a step are of course predominantly textual, but they themselves are not values.
Literati
Textual values can be formed either as literals in expressions or by capturing the input from a user and binding it to a variable.
String Literals
Text strings in an expression, are, as you would expect, written
-
a quote
"to open the string; then -
zero or more characters be they ASCII
[A-Za-z0-9,.*]or any other valid Unicode you can write in your editor; followed by -
a quote
"to close the string.
Thus
{ "President of the Imperial Galactic Government" }
is a valid value.
Newlines can be included in a string literal by writing \n as can quote characters, so long as
they too are escaped with a backslash.
Multi-line Literals
A textual value spanning multiple lines can also be included in a Technique document:
{ ```
Boy who is not able to explain what a Hrung is,
nor why it chose to collapse on Betelgeuse VII.
``` }
in which case newlines are preserved as written.
The multi-line literal capability is specifically in Technique so that small fragments of other languages such as shell scripts can be included in expressions. As such, when written a tag can be included to indicate what that embedded language is. For example, an ancient dusty computer system might have this in its data banks:
{ ```asm
* RELIEVE MONOTONY
ORG $2000
MISSLE LDAA #$FF ; ARM WARHEAD
STAA ARMFLG
LDAB #$01 ; SELECT TARGET: ENTHUSIASTIC CLIENT
STAB TARGET
JSR TRACK ; ACQUIRE FIRING SOLUTION
LDAA TARGET
CMPA #$01
BNE ABORT
STAA LAUNCH ; FIRE
WAI
``` }
When included in an expression in a code block there will often be considerable whitespace padding to the left of the string. When parsed and evaluated this indentation is removed from the value, as is the newline after the tag before the first line of the text.
Quanticle
Numeric values are either Integrals or Quantities.
Integrals
Numbers are valid values in Technique, be they from the natural numbers, ℕ,
{ 1 },
{ 2 },
{ 3 }, ...
or from the integers, ℤ,
..., { -3 },
{ -2 },
{ -1 },
{ 0 },
{ 1 },
{ 2 },
{ 3 }, ...
and can be written as literals or returned by procedures and functions. Formally,
-
an optional
-for a negative number; then -
one or more digits
[0-9].
Other than { 0 } it is convention
that integrals are not written with leading zeros.
Quantities
Technique also supports quantities, which are measurements. For example, the mass of the Earth mₑ is
{ 5.9722 ± 0.0006 × 10²⁴ kg }
because everyone who studied physics knows numbers come with uncertainty and units.
Not everyone knows how to enter ± and × or wants to dig out the Unicode
superscript characters, so the Technique parser also accepts a more liberal
form,
{ 5.9722 +/- 0.0006 x 10^24 kg }
which is a little easier to type. The format for a quantity is:
-
the mantissa; optionally followed by
-
an uncertainty; optionally followed by
-
a magnitude; then, regardless, followed by
-
a symbol for the units,
all whitespace separated.
The mantissa is the amount that has been measured, which is:
-
an optional
-for a negative number; then -
one or more digits
[0-9]; optionally followed by -
a
.as decimal point; and then -
one or more digits
[0-9]for a fractional amount.
It is convention, though not enforced, that the mantissa is written without leading zeros.
The uncertainty is written with:
-
the
±character or the string+/-; followed by -
one or more digits
[0-9]; optionally followed by -
a
.as decimal point; and then -
one or more digits
[0-9]for a fractional amount.
There is no language requirement that the uncertainty has the same precision as the mantissa, but conventionally this will always be the case.
The magnitude is written as:
-
a
×orxcharacter; followed by -
the string
10; followed by
either
-
a
^character; -
an optional
-for a negative number; then -
one or two digits
[0-9];
or
-
an optional Unicode superscript
⁻for a negative number; then -
one or more Unicode superscript digits.
Then finally we have the symbol:
-
one character from
[A-Za-z°μ]; followed by -
zero or more characters from the same
[A-Za-z°μ]range or[0-9/^_]or the Unicode superscript digits.
This allows symbols like
kg,
°C,
km/h, and
m².
Units do not have to be SI abbreviations;
Joule,
petabyte, and
seconds
are acceptable too. Terms indicating an amount, like tsp,
cups,
pallets, and
trucks
are also all valid. Whether or not the units are written as a plural is left
to the author.
Enumerati
Response Enums
Steps in Technique can have pre-defined responses. The purpose of these responses is to guide users in the appropriate results for a step, and to provide for consistency. For example:
before_concert :
Prepare for a performance by Disaster Area.
1. Audience bunker (safe distance, thirty-seven miles)
'OCCUPIED' | 'EVACUATED'
2. Sound level
'MERELY_DEAFENING' | 'PAINFUL' | 'STRUCTURALLY_DAMAGING'
3. Stunt ship, trajectory into local sun
'LOCKED'
Each of these individual possible responses is a response literal, formed thus:
-
an opening
'single-quote character; followed by -
a starting character
[A-Za-z0-9]; followed by -
interior characters
[A-Za-z0-9_ ]*; followed by -
a final character
[A-Za-z0-9]?; followed by -
a closing
'single-quote character.
The single response literal chosen is an Enumerati value.
We often observe the convention that responses are all-capital letters, as
shown here, making them appropriate for domains where the responses are
reminiscent of the enumerations or constants from a conventional programming
language, but this is not required. Other domains use proper case, for example
'Occupied' and 'Evacuated'.
The space character , while unusual, is permitted. The point, as noted
above, is to create known fixed strings representing choices, so 'Merely Deafening', 'Painful' and
'Structurally Damaging' would also be acceptable
Enumerati values. Spaces, however, are not allowed as padding before or
after the string, so ' Yes ' would be invalid.
Tabularum
Key/Value Tables
The composite data structure in Technique is the tablet, which allows key/value pairs to be accumulated thusly:
-
an opening bracket
[character; followed by -
pairs; followed by
-
a closing bracket
]character.
The pairs are
-
an opening quote
"character; followed by -
a string as the label; followed by
-
a closing quote
"character; followed by -
an equals
=character; followed by -
a value.
For example,
{ [
"problem" = "Life, the Universe, and Everything"
"answer" = 42
"question" = ?
] }
While appropriate in many domains, labels do not need to be constrained to looking like identifiers. A more verbose string is also a valid label:
{ [
"Our problem" = "Life, the Universe, and Everything"
"The Answer" = 42
"But what is The Question" = ?
] }
An empty tablet, written as { [=] }
in an expression, is a valid Tabularum value.
Arraeum
Lists
A list is formed in the same manner as a tablet but without the label:
-
an opening bracket
[character; followed by -
values; followed by
-
a closing bracket
]character,
where values are:
-
a value; optionally followed by one or more additional values:
-
either a
,separator or a newline separator; followed by -
another value;
-
and so on.
The type of the elements in a list must be the same.
List literals are often written on a single line with , separators { [1, 2, 3, 4, 5] } but lists with
longer or more complex values can be written in block form with newline as the
separator,
{ [
(3, "humans")
(2, "dolphins")
(1, "mice")
] }
The empty list, signified by { [] }, is a valid Arraeum value.
Parametriq
Tuples
Multiple values of potentially disjoint type can be listed in a single structure called a tuple. A tuple is formed by writing:
-
an opening parenthesis
(character; followed by -
values; followed by
-
a closing parenthesis
)character,
where values are:
-
an expression; followed by one or more additional values:
-
a comma
,as separator; followed by -
another expression;
-
and so on.
A tuple must have at least two values to parse and evaluate as a valid
Parametriq, so
{ ("Arthur Dent", "Mostly Harmless", "Bathrobe") }
would be a valid tuple inhabiting a type such as
a : (Name, OriginPlanet, Attire) -> ()
.
The type of the values in the tuple do not have to be the same,
so
{ (2, "Norway", 'FJORD') }
would also be a valid tuple, in this case an inhabitant of the
a : (Iteration, Place, Geography) -> ()
type.
Note that the arguments to a procedure or function are a set of parameters, not a tuple. A tuple can be passed as one of those parameters if the signature so requires it.
Intratempse
Cost Literals
Cost literals are intended to describe an amount of time, a monetary amount, or an amount of some resource that is what will consumed or expended by step. A cost is formed wrapping a quantity literal in a constructor:
-
a
$character; followed by -
an opening parenthesis
(character; followed by -
a resource
-
a closing parenthesis
)character.
The resource here has the same components as an abbreviated quantity, being:
-
a mantissa as the amount; followed by
-
a whitespace character
; followed by -
a symbol for the units.
Examples would be { $(2 minutes) },
{ $(5 GBP) } for a currency, or { $(6 pints) } for an amount.
Conventionally the units for a number greater than 1 are written as a plural.
A cost literal at the end of a step is an annotation, not result value. If a cost value is required is can be written in an expression.
Unitus
The Unit Value
The unit type a : () -> ()
has a single
inhabitant, the unit value, written
- the string
().
Note that this is not an empty tuple. A value
of { () } is used to represent a
successful result but one with no particular value.