Introduction
An 'expression' is a piece of code that evaluates to a result. Basically, Scythe expressions are a basic programming language. Not a specially well designed programming language mind, it sort of evolved with the program.
Expressions are constructed from the following constituents: literal, list, variable, function and operation.
Literal
A literal is an explicit value such as a number or string. Strings are usually surrounded by double-quotes. The quotes can be omitted if the string only consists of a-z, 0-9 and underscore. The following are valid literals:
- 42
- 3.14
- "Hello world"
- Scythe
List
The list type is your basic array, a data type that holds multiple values. Lists are explictly defined with square brackets with a comma separating each value. Any valid expression can be a value in a list, there is no requirement for a list to only hold values of a certain type.
The following are all valid lists:
- [1,2,3,4]
- [1,2,"Brown",Cow]
- [1,3.14,[99,bob],hello,($x > 10)]
All expressions return a list to their caller. In many cases it's a list with one entry, but a list nonetheless.
Function
A function returns a value based on arguments supplied. Function names may consist of a-z, 0-9 and underscore. Function names are followed by a set of round brackets containing the function arguments. The brackets are always present even if the function takes no arguments. Any valid expression can be used as an argument.
Functions are defined within Scythe and cannot be created by the user. Current available functions are:
| Name | Description |
|---|---|
| folders() | Returns all folder names. |
| minus(base, ext) | Returns values in base that do not appear in ext. |
| unseen() | Returns if the current message is unseen. |
Operation
An operation takes the general form of (left operator right).
left and right are both expressions. Valid values of operator are shown in the following sections. Note that comparison operators return true if any combination of left and right result in true. For example the expression ([1,2] == [3,4]) would make the following comparisons:
- 1 == 3
- 1 == 4
- 2 == 3
- 2 == 4
Scythe treats any non-zero number as true and any string is true apart from "0" and "".
Logic comparisons
| Operator | Returns true when |
|---|---|
| and | left and right are true. |
| or | Either left or right are true. |
Numeric comparisons
| Operator | Returns true when |
|---|---|
| == | left is equal to right |
| != | left is not equal to right |
| < | left is less than right |
| <= | left is less than or equal to right |
| > | left is greater than right |
| >= | left is greater than or equal to right |
String comparisons
The names of the operators below are the case-sensitive version of the operator. For the case-insensitive version add i to the end of the name, e.g. contains is case-sensitive whilst containsi is case-insensitive.
| Operator | Returns true when |
|---|---|
| contains | left contains right |
| notcontains | left does not contain right |
| equals | left equals right |
| notcontains | left does not equal right |
