Characters in Quirl

This page explains all printable characters with a special meaning in Quirl. Note that their special meaning applies only outside text and outside comments.

!
The exclamation mark prefixes values of types that use floating-point arithmetic and are hence not guaranteed to be perfectly precise. Here are two examples: !5.6655388976/10^16 and !0.5t.
"
The quotation mark occurs both at the start and at the end of text, e.g. "Hello world!".
#
The number sign, also called hash, marks the start of a comment. The comment runs until the end of the line.
$
The dollar sign marks a placeholder which corresponds to a parameter in the definition of a function or structure. It always comes before a single small letter as in $a.
%
Commonly known as percent sign, this sign is actually Quirl's modulo sign. It occurs between two integers. For example, 1%7 represents the residue class of integers whose remainder is 1 when divided by 7.
&
The ampersand represents a value that is greater than any number in a set such as the integers. There is also -& which is smaller than any number of the set. & and -& are the two possible values of Quirl's Beyond type.
'
The apostrophe marks the start of the repetend in an infinitely repeating decimal number. For example, 0.8'3 represents the number 0.833333333… and so forth, which is exactly 5/6.
( )
Parentheses enclose the arguments passed to a callable type. For example, add(3 1) would apply the function add to the two arguments 3 and 1 to compute their sum, four.
*
The asterisk serves as a multiplication sign in certain numbers, e.g. !5*10^3. It also marks the second binary operation on types: Ring*Scalable represents an intersection type.
+
The plus sign serves as an optional positive unary sign as in +5 and marks addition in the usual sense as in x+1 or 3+7\2. It also marks the first binary operation on types: Set+Tuple is a union type. U+ marks the start of a Unicode code point.
,
The comma is equivalent to whitespace in Quirl. You can use it instead of or additionally to actual whitespace characters to delimit operands from each other.
-
The hyphen-minus marks negative numbers like -8 and subtraction as in 2-i.
.
The full stop or dot is used as decimal point in numbers such as 3.141592. It may also be used as namespace separator outside numbers in the future.
..
Two consecutive dots mark a range from what precedes the dots to what comes after them. Currently, the only supported range is that of Unicode code points as in U+0041..U+005A.
...
Three consecutive dots make a type or wildcard parameter of a function variadic. For example: ...Int and ...?. A variadic parameter accepts any number of arguments when the function is called.
/
The solidus or slash is used as a fraction sign as in the rational number 3/4 or in !1.380649/10^23.
:
The colon marks the start of a condition in the definition of a function or structure. When a function is called with certain arguments, only the mapping whose parameters match the arguments and whose condition is true is applied.
;
The semicolon separates two statements, so comes between them. Many other programming languages use the semicolon as statement terminator instead, requiring a semicolon after each statement. That is not the case in Quirl.
< >
reserved
=
The equals sign marks a definition in Quirl. What's left of the equals sign determines the kind of definition.
?
The question mark acts as a wildcard. It represents any type in parameter lists. In argument lists, it represents an unbound argument, which enables partial application of functions, e.g. next = add(? 1).
@
The commercial at stands for function composition as in not@eq($a $b). Function composition is evaluated from right to left. So the example is equivalent to not(eq($a $b)).
F
A single capital letter F represents the truth value false.
T
A single capital letter T represents the truth value true.
U
A single capital letter U followed by + and an uppercase hexadecimal number is a Unicode code point. It encodes a character. For example, U+1F436 is the codepoint for a dog face 🐶.
[ ]
Square brackets start and end a tuple, for example [1 4]. Tuples can be nested as in [[3 5] [2 1]].
\
The reverse solidus, also known as backslash, serves as radical symbol. It is always followed by an unsigned integer, the radicand. That is, \2 is the positive square root of two.
^
The circumflex accent is used as power sign so that x^3 is x to the power of three. The base before the power sign must be either x or the number ten as in !4*10^12.
_
The low line does not have a special effect. But it is notable for being allowed in names like snake_case.
`
reserved
i
The small letter i in numbers represents the imaginary unit. That is a square root of negative one, the other square root of negative one being -i.
t
The small letter t stands for the angular unit turn. One turn is equivalent to τ radians or 360 degrees. There must be a rational or floating-point real number before the unit as in 1/2t or !0.5t.
x
The small letter x is the indeterminate in polynomials such as x^2-2x-1. Each x can have a rational or integer coefficient and a non-negative integer power.
{ }
Curly brackets mark the start and end of a set of items, for example {1 2 "be kind"}. An empty set is represented by curly brackets with nothing except optionally space in between: {}.
|
The vertical line seperates alternatives on the right side of a grammar production rule, for example the alternatives "0" and "1" in BIT ~ "0" | "1".
~
The tilde separates left and right side in a grammar's production rule. It substitutes for the arrow usually found in literature in its place.
°
The degree sign stands for the angular unit degree. is the same as 1/360t, so 90° is the same as a quarter turn, 1/4t. Quirl recognizes degrees as input, but never uses degrees in its output.

Whitespace characters

The unicode characters U+0009 character tabulation, U+000A line feed, U+000D carriage return, U+0020 space and U+00A0 no-break space are recognized as space characters. Space characters separate operands. For instance, 1 2 is a list of two integers one and two. On the other hand, 12 without space in between is the single integer twelve.

The character U+000A line feed is notable for terminating a comment.

Normalization

Quirl's lexer also recognizes some more characters as equivalent to those above and replaces them accordingly. This is to make copying and pasting expressions from other sources for quick computations with Quirl more convenient. Please use the above special characters in your own code though.

⁰¹²³⁴⁵⁶⁷⁸⁹
A superscript integer is converted to a circumflex accent followed by a regular integer. For example, x⁴² would be replaced by x^42.
×
U+00D7 multiplication sign is converted to asterisk.
U+2026 horizontal ellipsis is converted to three consecutive dots.
U+2044 fraction slash is converted to solidus.
U+2212 minus sign is converted to hyphen-minus.
U+2215 division slash is converted to solidus.
U+221A square root is converted to reverse solidus.
U+22C5 dot operator is converted to asterisk.
U+23B7 radical symbol bottom is converted to reverse solidus.