5. Core Module

The core module provides the language primitives and the standard library.

5.1. Literals

Macro-Node: '(x)

Interprets x as a literal symbol rather than a node declaration. See Literal Symbols.

The same symbol object is always returned for a given symbol name.

x

An atom node expression.

Pattern Matching

Matches the literal symbol x. See Pattern Matching.

Macro-Node: c(x)

Returns x interpreted as a literal character.

  • If x is a symbol of one character, the character is returned.
  • If x is a string, the first character in the string is returned.
  • If x is an integer in the range 0 — 9, the character corresponding to the digit is returned.

x

The value to convert to a character.

Pattern Matching

Matches the character literal produced by the given argument. See Pattern Matching.

Macro-Node: &(node)

Returns the raw node object corresponding to the node with identifier node. See Node References.

node

The node identifier, which can be any valid node expression. The expression is processed in the module in which the macro node instance occurs.

5.2. Bindings

Macro-Node: ->(source, target)

Establishes a binding between node source and node target.

source

The source node.

target

The target node.

[Note]

Registered as an infix operator with precedence 10 and right associativity.

Macro-Node: <-(target, source)

Establishes a binding between node source and node target.

Same as -> however the argument order is reversed with the first argument being the target node and the second argument being the source node.

target

The target node.

source

The source node.

[Note]

Registered as an infix operator with precedence 10 and left associativity.

Macro-Node: @(node, context : '(default))

Indicates an explicit context to which bindings, involving node as the target, should be established.

When the @ expression appears as the target of a binding, the binding to node is established in the context with identifier context, see Section 2.5, “Contexts”. The context identifier may be omitted in which case the identifier default is assumed.

context may also be a functor of the form when(context-id, type), where context-id is the context identifier and type is a node, of which the value is interpreted as a failure type. In this case the binding will only be activated if the failure type, of the previous binding in the context, is equal to type by =. See Conditionally Active Bindings based on Failure Type. If context-id is omitted, that is context is of the form when(type), the identifier default is assumed.

node

The node.

context

The context identifier, or when expression, see above.

[Note]

Registered as an infix operator with precedence 800 and left associativity. The when symbol is also registered as an infix operator with precedence 850 and left associativity.

Macro-Node: ::(node, state)

When appearing as the target of a binding, a binding is established to node which is only active when node is in the state with identifier state.

state may also be a functor of the form from => state, in which case the binding is only active when the state of node changes from the state with identifier from to the state with identifier to.

See Section 2.10, “Node States” for more information.

node

The node.

state

The state identifier or => expression, see above.

[Note]

Registered as an infix operator with precedence 700 and left associativity. The => symbol is also registered as an infix operator with precedence 750 and left associativity.

5.3. Meta-Node Definitions

Macro-Node: :(id(args...), body)

Defines a meta-node with identifier id, argument list args and definition body. See Section 3, “Meta-Nodes”.

id

Meta-node identifier.

args

Comma-separated list of node identifiers, to which the meta-node arguments are bound.

body

Node expression making up the definition of the meta-node. If the definition consists of more than a single expression, it should be enclosed in braces, see Node Lists.

[Note]

Registered as an infix operator with precedence 5 and right associativity.

Macro-Node: ..(node)

Explicitly references a node defined in the enclosing scope of the meta-node. See Section 3.3, “Outer Node References”.

node

The node identifier, which can be any valid node expression.

5.4. Failures

Meta-Node: fail(:(type))

Returns a failure with a given failure type.

type (Optional)
The failure type. If not provided the failure returned has no type.

Meta-Node: fail-type(x)

Returns the failure type of x.

Returns a failure if x does not evaluate to a failure or evaluates to a failure with no type.

x

The value of which to return the failure type.

Meta-Node: fails?(x)

Returns true if x fails to evaluate to a value.

x

The value to test for failure.

Pattern Matching

Matches if the source node evaluates to a failure. If the argument x is provided matches only failures of type x otherwise matches any failure. See Pattern Matching.

Meta-Node: ?(x)

Returns true if x evaluates to a value, false if x fails to evaluate to a value.

x

The value to test for failure.

Meta-Node: fail-type?(x, type)

Tests for failure with a given type.

Returns true if x fails with failure type equal to type, by =. Returns false if the failure type of x is not equal to type or x does not fail.

x

The value to check.

type

The failure type.

Meta-Node: !!(x)

Evaluates to true if x evaluates to a value. If x evaluates to a failure, evaluates to the failure value.

x

The value to test for failure.

Meta-Node: !-(test, value)

Returns value if test does not fail. If test fails, the failure is returned.

test

The value which is checked for failure.

value

The value which should be returned if test does not fail.

Macro-Node: !(functor)

Tests that each argument of a functor expression does not fail, before evaluating the expression.

If at least one argument fails, then the entire functor node fails.

functor

The functor expression.

Meta-Node: catch(try, catch, :(test))

Returns the value of try if it does not evaluate to a failure. If try evaluates to a failure returns the value of catch.

try
The value, which is returned if it does not evaluate to a failure.
catch
The value, which is returned when try evaluates to a failure.
test
An optional function, which is applied on the failure type of try. If the function returns true, the value of catch is returned otherwise the value of try is returned.

5.5. Builtin Failure Types

Failure Type Node: No-Value

Failure type representing the absense of a value.

Optional meta-nodes arguments, for which no value is provided, are bound to a failure of this type.

Node No-Value! is bound to a failure of this type.

Failure Type Node: Type-Error

A failure of this type is returned when an argument to a meta-node is not of the expected type.

Node Type-Error! is bound to a failure of this type.

Failure Type Node: Index-Out-Bounds

A failure of this type is returned when attempting to access an element at an index that is outside the bounds of the list or string.

Node Index-Out-Bounds! is bound to a failure of this type.

Failure Type Node: Invalid-Integer

A failure of this type is returned by int when a string, from which an integer cannot be parsed, is provided as an argument.

Node Invalid-Integer! is bound to a failure of this type.

Failure Type Node: Invalid-Real

A failure of this type is returned by real when a string, from which a real number cannot be parsed, is provided as an argument.

Node Invalid-Real! is bound to a failure of this type.

Failure Type Node: Arity-Error

A failure of this type is returned when a meta-node is invoked indirectly, by a meta-node reference see Section 3.5, “Higher-Order Meta-Nodes”, with an incorrect number of arguments.

Node Arity-Error! is bound to a failure of this type.

5.6. Arithmetic

Meta-Node: +(x, y)

Computes the sum of x and y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 100 and left associativity.

Meta-Node: -(x, :(y))

Computes the difference of x and y.

If y is not provided, returns the negation of x, i.e. x multiplied by -1.

x
A number.
y (Optional)
A number.
[Note]

Registered as an infix operator with precedence 100 and left associativity.

Meta-Node: *(x, y)

Computes the product of x and y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 200 and left associativity.

Meta-Node: /(x, y)

Computes the quotient of x and y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 200 and left associativity.

Meta-Node: %(x, y)

Computes the remainder of the division of x by y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 200 and left associativity.

5.7. Comparison

Meta-Node: <(x, y)

Returns true if x is less than y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 50 and left associativity.

Meta-Node: <=(x, y)

Returns true if x is less than or equal to y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 50 and left associativity.

Meta-Node: >(x, y)

Returns true if x is greater than y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 50 and left associativity.

Meta-Node: >=(x, y)

Returns true if x is greater than or equal to y.

x

A number.

y

A number.

[Note]

Registered as an infix operator with precedence 50 and left associativity.

Meta-Node: =(a, b)

Returns true if a is equal to b.

  • Numbers are equal if they represent the same numeric value.
  • Characters are equal if they represent the same character.
  • Strings are equal if they have the same contents.
  • Otherwise a and b are equal if they evaluate to the same object.

x

A value.

y

A value.

[Note]

Registered as an infix operator with precedence 50 and left associativity.

Meta-Node: !=(a, b)

Returns true if a is not equal to b.

See = for the rules of equality.

x

A value.

y

A value.

[Note]

Registered as an infix operator with precedence 50 and left associativity.

5.8. Logical Operators

Meta-Node: and(x, y)

Logical AND.

Returns True if x and y evaluate to True. Returns False otherwise.

x

A Boolean value

y

A Boolean value

[Note]

Registered as an infix operator with precedence 25 and left associativity.

Pattern Matching

Matches if both the nested patterns in x and y match the source node. See Pattern Matching.

Meta-Node: or(x, y)

Logical OR.

Returns True if either x or y evaluate to True. Returns False if both x and y evaluate to False.

x

A Boolean value

y

A Boolean value

[Note]

Registered as an infix operator with precedence 20 and left associativity.

Pattern Matching

Matches if at least one of the nested patterns in x and y match the source node. Both the bindings generated by the patterns x and y are established if the corresponding pattern condition matches. See Pattern Matching.

[Note]

This pattern matches even if not all its nested patterns have matched.

Meta-Node: not(x)

Logical NOT.

Returns True if x evaluates to False.

x

A Boolean value

Pattern Matching

Matches if the nested pattern x does not match. The bindings generated by x are not established by this pattern. See Pattern Matching.

[Note]

Since this binding does not establish any bindings, it is treated as a constant pattern and may only appear nested inside other patterns.

5.9. Selection Operators

Meta-Node: if(condition, true-value, :(false-value))

Returns true-value if condition is True otherwise returns false-value.

If false-value is not provided, a failure is returned if condition evaluates to False.

condition
The condition.
true-value
Value to return if condition is true.
false-value (Optional)
Value to return if condition is false. If not provided defaults to a failure of type No-Value.

Macro-Node: case(..(clauses))

<clause> = <condition> : <value>

Expands to nested if expressions.

Each argument is a clause is of the form condition : value. The case expression evaluates to the value corresponding to the first clause of which the condition node evaluates to True. The final clause may also be of the form value, in which case it becomes the default value, to which the case expression evaluates if the conditions of all the other clauses evaluate to False.

clauses

The clauses.

Example. 

case(
    a < b : a,
    b >= a : b
)

# Is equivalent to:

if(a < b, a, if(b >= a, b))

Example with default value. 

case(
    a < b : -1,
    b > a : 1,
    0
)

# Is equivalent to:

if(a < b, -1, if(b > a, 1, 0))

Node True

The value of this node represents Boolean True.

Node False

The value of this node represents Boolean False.

5.10. Types

Meta-Node: int(x)

Converts x to an integer value.

  • If x is an integer returns x.
  • If x is a real returns x with the fractional part truncated.
  • If x is a string, attempts to parse an integer from x. Returns the parsed value if successful otherwise returns a failure of type Invalid-Integer.

If x is neither of the above returns a failure of type Type-Error.

x

The value to convert to an integer.

Pattern Matching

Matches if the source node is an integer, in which case x is matched to the integer value. See Pattern Matching.

Meta-Node: real(x)

Converts x to a real number value.

  • If x is an integer or real returns x.
  • If x is a string, attempts to parse a real number from x. Returns the parsed value if successful otherwise returns a failure of type Invalid-Real.

If x is neither of the above returns a failure of type Type-Error.

x

The value to convert to a real.

Pattern Matching

Matches if the source node is a real, in which case x is matched to the real value. See Pattern Matching.

Meta-Node: string(x)

Converts x to a string.

x

The value to convert to a string.

Pattern Matching

Matches if the source node is a string, in which case x is matched to the string value. See Pattern Matching.

Meta-Node: to-int(x)

Converts x to an integer value.

Same as int however with the target-node attribute set to int. As such, in the following:

a -> to-int(b)

Node b is set to the value of a converted to an integer.

x

The value to convert.

Meta-Node: to-real(x)

Converts x to an real number value.

Same as real however with the target-node attribute set to real. As such, in the following:

a -> to-real(b)

Node b is set to the value of a converted to a real number.

x

The value to convert.

Meta-Node: to-string(x)

Converts x to an integer value.

Same as string however with the target-node attribute set to string. As such, in the following:

a -> to-string(b)

Node b is set to the value of a converted to a string.

x

The value to convert.

Meta-Node: int?(x)

Returns true if x is an integer.

x

The value to test.

Meta-Node: real?(x)

Returns true if x is a real valued number.

x

The value to test.

Meta-Node: string?(x)

Returns true if x is a string.

x

The value to test.

Meta-Node: symbol?

Returns true if x is a symbol.

x

The value to test.

Meta-Node: char?

Returns true if x is a character.

x

The value to test.

Meta-Node: inf?(x)

Returns true if x is either positive or negative infinity.

x

The value to test.

Meta-Node: NaN?(x)

Returns true if x is a NaN (Not a Number) value.

x

The value to test.

5.11. Lists

Lists are represented by a special cons type, in which the head stores the first element of the list and the tail stores the list of remaining elements. Neither the head nor the tail are evaluated until they are actually referenced and used.

The empty list is represented by the value of the node Empty.

Meta-Node: cons(head, tail)

Creates a list with the head as the first element and tail as the list of remaining elements.

head

The first element of the list.

tail

The list containing the remaining elements after the first.

Pattern Matching

Matches if the source node is a non-empty list, in which case head is matched to the head of the list and tail is matched to the tail of the list. See Pattern Matching.

Meta-Node: head(list)

Returns the head (first element) of a list.

If list is the empty list, returns a failure of type Empty.

If list is not a list returns a failure value of type Type-Error.

list

The list.

Meta-Node: tail(list)

Returns the tail, the list containing the elements after the first element, of a list.

If list is the empty list, returns a failure of type Empty.

If list is not a list returns a failure value of type Type-Error.

list

The list.

Meta-Node: cons?(thing)

Returns true if thing is a list of at least one element, false otherwise.

[Note]

Does not return true if thing is the empty list.

list

The list.

Node: Empty

The value of this node represents the empty list.

Node: Empty!

The value of this node is a failure of type Empty. This failure is returned when attempting to access the head or tail of an empty list.

Meta-Node: list(..(xs))

Creates a list with elements xs.

xs

The list elements.

Pattern Matching

Matches if the source node is a list of the same size as xs, in which case each argument in xs is matched to the corresponding list element. See Pattern Matching.

Meta-Node: list*(..(xs))

Creates a list containing, as elements, all the arguments in xs excluding the last. The last argument in xs is treated as a list containing the remaining elements.

xs

The list elements, with the last argument being the list containing the remaining elements.

Pattern Matching

Matches if the source node is a list of at least one less elements that the number of elements in xs. The arguments, excluding the last, are matched to the corresponding elements in the list with the last argument being matched to the remaining list elements. See Pattern Matching.

Meta-Node: list!(..(xs))

Creates a list containing, as elements, all the arguments in xs.

Unlike list, if at least one of xs fails to evaluate to a value, the failure is returned.

xs

The list elements.

Meta-Node: nth(list, n)

Retrieves the element of a list at a particular index.

Returns a failure of type Index-Out-Bounds if n is greater than the number of elements in list.

list

The list.

n

The index of the element to retrieved.

Meta-Node: append(list1, list2)

Returns a list containing the elements of list2 appended to list1.

list1

The initial list.

list2

The list which is appended onto list1.

Meta-Node: foldl'(x, f, list)

Folds a list to a single value, starting from the first element.

The function f is first applied on x and the head of list. Subsequently, f is applied on the result of the previous application and the next element of list, until the end of list is reached.

x

Initial first argument to f.

f

Function of two arguments.

list

List to fold.

Meta-Node: foldl(f, list)

Folds a list to a single value, starting from the first element.

Same as foldl' except the head of list is used as the initial first argument to the fold function f.

f

Function of two arguments.

list

List to fold.

Meta-Node: foldr(f, list, :(x))

Folds a list to a single value, starting from the last element.

f is first applied on the last element of list and the value of x. If the x argument is not provided or x evaluates to a failure of type No-Value, f is first applied on the last two elements of list. Subsequently f is applied on the previous element of list and the result of the previous application, until the head of list list is reached.

If list only has a single element and x is not provided, the element is returned as is. If l is empty and x is provided, x is returned as is.

f
Function of two arguments.
list
List to fold.
x (Optional)
Second argument to the application of f on the last element of list.

Meta-Node: map(f, list)

Applies a function on each element of a list.

Returns a list containing the result of applying f on each element of list in turn.

f

Function of one argument.

list

The list.

Meta-Node: filter(f, list)

Filters elements from a list.

Returns a list containing only the elements of list for which the function f returns true.

f

Function of one argument, which should return true if the argument should be retained in the list or false if it should be removed.

list

The list to filter.

Meta-Node: every?(f, list)

Returns true if f returns true for every element of list.

f

Function of one argument.

list

The list.

Meta-Node: some?(f, list)

Returns true if f returns true for at least one element of list.

f

Function of one argument.

list

The list.

Meta-Node: not-any?(f, list)

Returns true if f returns false for every element of list.

f

Function of one argument.

list

The list.

Meta-Node: not-every?(f, list)

Returns true if f returns false for at least one element of list.

f

Function of one argument.

list

The list.

5.12. Strings

Meta-Node: string-at(string, index)

Returns the character at a given index in the string.

If the index is greater than the number of characters in this string, returns a failure of type Index-Out-Bounds.

string

The string.

index

The index of the character.

Meta-Node: string-concat(string, str1, str2)

Concatenates str2 to the end of str1.

str1

The first string.

str2

The string which is concatenated to str1.

Meta-Node: string->list(string)

Returns a list containing the characters in a string.

string

The string.

Meta-Node: list->string(list)

Returns a string containing the concatenation of the elements in a list.

Each element of list is converted to a string and concatenated to the result string.

list

List of elements to concatenate.

Meta-Node: format(string, ..(args))

Creates a formatted string, in which placeholders are replaced by the arguments in args.

The sequence %s designates a placeholder which is to be replaced by an argument. The first placeholder is replaced by the first argument, the second with the second argument and so on. Each argument is converted to a string prior to being substituted into the result string.

The sequence %% designates a literal % character and is thus replaced with a %.

string

The format string.

args

The arguments to substitute into the string.

5.13. Dictionaries

Meta-Node: member(dict, key)

Retrieves the value of an entry in a dictionary.

If dict does not have an entry for key a failure, of type No-Value is returned.

dict

The dictionary.

key

The entry key.

5.14. Functions

Meta-Node: apply(f, ..(xs))

Applies a function on an argument list.

The argument list, on which f is applied consist of each argument of xs, excluding the last, followed by each element of the last argument of xs.

f

The function to apply.

xs

The arguments to apply f on.

[Caution]

If f is not a function or the last argument of xs is not a list, a failure of type Type-Error, is returned.

5.15. Introspection

The core/introspection module provides utility meta-nodes for introspecting the nodes comprising a program. These meta-nodes may only be used within macro nodes, during macro expansion, as runtime definitions are not available.

Meta-Node: node?(thing)

Returns true if thing is a node object.

thing

The thing to check whether it is a node.

Meta-Node: find-node(node, :(module))

Looks-up a node in a module.

Returns the node object or a failure if no node is found.

node
The node to lookup, which can be any node expression.
module (Optional)
The module in which to look-up the node. Defaults to the current module, set by the last /module declaration that is processed.
[Note]

Currently there is no way to retrieve a module object, thus the module argument is not used. This functionality will be added in a future release.

Meta-Node: get-attribute(node, attribute)

Retrieves the value of an attribute of a node.

Returns a failure if the attribute is not set.

node

The node object.

attribute

The attribute identifier.

5.16. Pattern Matching

Pattern matching is provided by the core module in the form of bindings involving the meta-node instance, which is to be matched, as the target. The binding succeeds if the pattern matches, otherwise it fails.

A meta-node which supports pattern matching, has a target-node or target-transform, see Section 3.7, “Instances as Targets”, such that when an instance of the meta-node appears as the target of a binding, the argument nodes are bound to the values, required in order for the meta-node to return a value that is equivalent to the value of the source node. When there are such values, the pattern is said to have matched. If there is no possible value for at least one argument node, all argument nodes should evaluate to failures of type Match-Fail. In this case the pattern has not matched

Example. 

x -> int(y)

In the example, above, y is bound to the value of x if it is an integer, otherwise y evaluates to a failure. There is no argument which will result in int returning a non-integer value thus if the source node, x, is not an integer the argument node, y, is bound to a failure. Since int returns the value of its argument directly, when it is an integer, the argument node is simply bound to the source node.

Example. 

x -> list(y, z)

In the example, above, y is bound to the first element of x and z is bound to the second element of x if x is a list of two elements. These bindings will result in a list, equivalent to x, being produced when y and z are passed as arguments to the list meta-node.

Nested Patterns

Patterns may be nested, that is an argument to a meta-node instance is itself a meta-node instance of which the operator meta-node supports pattern matching. When the arguments contain one or more nested patterns, the bindings to the argument nodes should only succeed if all nested patterns match.

Example. 

x -> list(int(y), z)

The example, above, is similar to the previous example except with the additional condition that the first element of x should also be an integer. That is y is bound to the first element of x and z to the second element of x if x is a list of two elements of which the first element is an integer.

When _ appears nested inside a pattern it matches anything and does not establish any bindings. This is used to indicate that the value for a particular argument is unimportant.

Example. 

x -> list(_, y)

In the example, above, y is bound to the second element of x if it is a list of two elements. The value of the first element of x is ignored completely.

Constant Patterns

Constant patterns comprise a constant value as opposed to a node. These patterns match when the source node is equal, by =, to the constant value. Constant patterns do not result in any bindings being established however they do affect the condition of the pattern in which they are nested.

[Important]

Constant patterns may only be used when nested inside a non-constant pattern.

Constant values include any literal constants, such as numbers, strings as well as character literals, produced by the c macro, and literal symbols, produced by the ' macro.

Example. 

x -> list(1, y, z)

In the example, above, y is bound to the second element of x and z to the third element of x if x is a list of three elements of which the first element is equal to 1.

The following are examples of invalid uses of constant patterns:

Examples: Invalid use of Constant Patterns. 

# Invalid as the pattern is not nested
x -> 1

# Invalid as at least one argument should not be a constant.
x -> list(1, 2)

[Caution]

Functor nodes, of which the arguments are all constants, such as 1 + 1, are only treated as constant patterns if the meta-node supports pattern matching. In this case the + meta-node does not support pattern matching, thus 1 + 1 is currently not treated as a constant pattern.

Matchers

The matcher node attribute stores a meta-node which is called to construct the pattern for a given list of arguments. The matcher meta-node is called with two arguments: the place to be matched, which should become the source node of any bindings established by the pattern, and the pattern functor expression itself (including the operator). The meta-node should return a Pattern object, which is a dictionary containing the following entries:

condition
The node expression which evaluates to true if the pattern matches. This should include the conditions of the argument nodes if they are patterns themselves.
bindings

List of bindings established by the pattern. If there are no bindings established by the pattern, then this entry should be set to the empty list, see Empty.

[Important]

The bindings should not be conditioned on condition as they will be conditioned later when the node declarations for the entire pattern (including the parent patterns) is constructed. See Conditional Bindings.

[Tip]

Pattern objects may be created with the Pattern meta-node.

All bindings, established by a pattern, should be established in an explicit context with identifier match, which is activated only on failures with type Match-Fail. This allows multiple patterns to be specified on a single node, with the node being set to the value corresponding to the binding of the first pattern that matches.

Example: Multiple Patterns. 

x -> int(y)
x -> list(int(y))
x -> list("x", int(y))

The example above contains multiple patterns involving a single node y.

y is bound to:

  1. the value of x if it is an integer, or
  2. the first element of x if it is a list of one element, which is an integer, or
  3. the second element of x if it is a list of two elements, with the first element being the string value "x" and the second element being an integer.

The following meta-nodes in the core module all have a matcher and may thus appear within patterns.

5.17. Module: core/patterns

This module contains utilities for creating and processing patterns.

Meta-Node: Pattern(condition, :(binding))

Creates a Pattern object. See Matchers

condition
The node expression which evaluates to true if the pattern matches.
binding (Optional)
List of binding expressions of the bindings established by the pattern. Defaults to the empty list if not provided.

Meta-Node: get-matcher(node)

Returns the matcher function, stored in the matcher attribute of a node.

Returns a failure if the node’s matcher attribute is not set.

node

The node object of which to retrieve the matcher.

Meta-Node: make-pattern(place, pattern)

Creates the Pattern object for a pattern expression.

[Note]

Can be used for any pattern, including constant patterns.

place
The place which should be matched to the pattern, i.e. the source node of the bindings established by the pattern.
pattern
The pattern expression.
[Note]

If pattern is a functor expression of which the operator is not a meta-node with a matcher, a Pattern with a single binding place -> pattern, and no condition is returned.

Meta-Node: combine-conditions(c1, c2)

Returns an expression which is the conjunction of two expressions, by and.

c1
The first condition, on the left hand side of the and.
c2
The second condition, on the right hand side of the and.

If c1 evaluates to a failure, returns c2. If c2 evaluates to a failure, returns c1.

[Tip]

This is useful for creating a condition which combines the conditions of multiple argument nodes.

Meta-Node: conditionalize-bindings(condition, bindings)

Returns a list where each binding in bindings is conditioned on condition. See Conditional Bindings.

If condition evaluates to a failure, a condition of True is assumed, thus the bindings are not conditioned.

condition
The condition on which to condition the bindings.
bindings
List of bindings to condition.

Failure Type Node: Match-Fail

Failure type indicating that a pattern failed to match.

Node Match-Fail! is bound to a failure of this type.

Meta-Node: fail-match(condition)

If condition evaluates to false or to a failure, returns a failure of type Match-Fail, otherwise returns true.

condition
The pattern condition.

Meta-Node: make-match-bind(src, target)

Generates a binding src -> target, with target in the match context which is activated on failures of type Match-Fail.

src
The source of the binding.
target
The target of the binding.

Meta-Node: make-pattern-declarations(pattern)

Creates the node declarations implementing a pattern.

Returns a single node declaration.

pattern
The Pattern object for which to create the declarations.
[Tip]

The declaration returned by this meta-node is a suitable return value for a target-transform function. See Section 3.7, “Instances as Targets”.

5.18. Operator Table

Operator Precedence Associativity

.

1000

left

when

850

left

@

800

left

=>

750

left

::

700

left

*

200

left

/

200

left

+

100

left

-

100

left

<

50

left

<=

50

left

>

50

left

>=

50

left

=

50

left

!=

50

left

and

25

left

or

20

left

!-

15

right

->

10

right

<-

10

left

:

5

right