This section describes the statements.
statement assign_statement call_statement def_statement if_statement jump_statement log_statement return_statement send_statement use_statement var_statement
statements statement more_statements
more_statements
""
linebreak statement more_statements
assign statement
assign_statement
"assign" space name optional_assign_suffix optional_box ':' space expression optional_box
optional_assign_suffix
""
assign_suffix
assign_suffix
'.' name optional_assign_suffix
'[' expression ']' optional_assign_suffix
invocation assign_suffix
optional_box
""
"[]"
The assign statement is the instrument of mutation. It can replace the value of a variable that was
created by the var statement.
The assign statement can also act on values that are mutable.
null.assign array[]: valueassign variable: array[]Attempting any of those changes on a stone object halts the actor.
call statement
call_statement
"call" space callee
callee name activate
activate selection activate subscript activate invocation activate invocation
The call statement invokes a function and ignores the return value.
def statement
def_statement
"def" space name def_value
def_value
':' space expression
parameter_list space body
The def statement defines a read-only variable within
the current function. The variable is read-only, but the value it contains
may be mutable. Names that are defined with the def statement
can not be changed with the assign statement. If the value is mutable,
then the value's members or elements may be changed with the assign statement.
The def statement can not appear in an if or a do statement.
If the def is followed by a function literal, then a read only variable having the same name as the function is created and given the value of the function object. So these two statements do the same thing:
def double: function double (number) {
return number + number
}
def double(number) {
return number + number
}
Variables must be defined before they are used. The name may not be used on the right side of the :colon.
def sqrt_2: 1.4142135623730950
jump statement
jump_statement
"jump" space callee
The jump statement is parameterized jump to a function.
It is similar to return except that control ultimately goes to the caller's caller, not the caller.
In some languages, this is called tail call optimization.
It can significantly reduce the rate at which memory is consumed, making looping by recusion and continuation passintg style feasible.
The jump statement is not allowed in functions that make inner functions.
function factorial(n, progress | 1) {
if n > 1
jump factorial(n - 1, n * progress)
else
return progress
fi
}
if statementif_statement then_clause "fi"
then_clause
"if" space expression indent statements outdent else_clause
else_clause
""
"else" else_consequence
else_consequence space then_clause indent statements outdent
The if statement creates forks in the control flow of a function.
The else if
form makes it possible to have alternatives without deep indentation.
The if statement can be nested.
if first_name = "Curly" \/ first_name = "Moe" \/ first_name = "Shemp"
assign last_name: "Howard"
else if first_name = "Larry"
assign last_name: "Fine"
else
assign last_name: "(unknown)"
fi
if fee
if fie
assign ok: fee
fi
else
assign ok: fie
fi
if character(list[at].op) = "j"
assign list[at].yz: list[at].yz - 1
else if list[at].op = "opx"
assign list[at].yz: list[at].yz + 1
fi
assign at: at + 1
An if statement may contain def and use
statements only if the name being defined appears in both the then branch and the else branch.
The name ia visible to the rest of the function.
if allowed!
use retricted: "hard to get stuff"()
else
def restricted: null
fi
log statement
log_statement
"log" channel ':' space expression
channel name
The log statement sends the value of an expression to a channel (or log actor).
It is used to capture information about the execution of the program for analysis and administration.
Logs can provide insight into the operation of a system.
A channel has a status for each program or subprogram according to policy:
forbidden: The program or subprogram will not build as long as the source mentions this channel.allowed. Log messages are sent immediately to the channel actor.ignored: The log statement is ignored. It is treated as a comment. It might be allowed on a later build.conditional. The log statement is ignored at first, but can be allowed at any tine. The debug channel is an example. If the debugger is running, the debug channel is enabled.
abort abuse account alert alpha analysis anomaly authorization beta billing breech budget bug catastrophic cause checklist compliance console contract crash dashboard data dayfile debug
delay demo development disaster disconnect disruption down emergency epic error event evidence example exception exhausted experimental
expired failure fatal feature finished format fraud guest hallucination halt hello host hygiene idle illegal inconsistent info intervention key kyc legal local
major maintenance memory migration minor mishap money monitor motivation network normal null offline online operations page panic partition partner permission policy portal
practice privacy probe protocol prototype public quality quantum range recover region regulation reject remote risk sample security
serious service situation spam sponsor start state statistics stop storage store stress summary super support suspicious syntax system test time trace training
transition trend trial trivial type unknown unneeded up usage verbose violation warning world
Logging does not change the behavior of a program. There will be no response.
If a log channel is allowed, then messages are sent to a log actor that is monitoring that channel. It might tabulate, summarize, record, or pass on the event. Unlike send messages, log messages are sent immediately, not waiting for the successful completion of the turn. However, if log is abused, the actor halts.
log debug: "index" && index
return statement
return_statement
"return" return_value
return_value
""
space expression
The return statement provides for the normal exit of a function
and the specification of its return value.
If a return value is not provided, then null is assumed. A function may return null implicitly by falling
thru the bottom.
def double(number) {
return number * 2
}
def abort() {
assign defcon: 1
call launch_all_missiles()
}
send statement
send_statement
"send" space expression ':' space expression callback
callback
""
':' space expression
The send statement sends a message to another actor.
The left expression must resolve to an actor address object or a message object that is expecting a reply because it was sent with a callback. The right expression is a record containing the outgoing message. The outgoing message record must not contain functions or patterns or cyclic structures.
If a callback function is included, then the callback function receives the reply, not the receiver function. See callback.
send server: message: reply_callback
use statement
use
"use" space name optional_locator invocation
optional_locator
""
':' space locator
locator text_literal name
The use statement makes a subprogram available to a program or another subprogram. The return value of the subprogram is bound to the name. An optional locator can be provided for finding the subprogram file in the program shop. Standard subprograms do not require a locator. The name may not be used as an argument on the right side of the :colon.
The subprograms are stored in the program shop, which contains the standard subprograms that are located with the name form, and the extra subprograms that are located with the text_literal form.
In the text_literal form, it is recommended that the text contain a prefix to indicate the source or usage of the subprogram. Guest code (programs from third parties that are not fully trusted) may be restricted from use of the use statement, or may have restrictions on which subprograms they can employ.
A system may provide powerful subprograms that act as interfaces to powerful endowments such as communication devices, data storage devices, input devices (like keyboards, camera, and microphones), output devices (like printers, displays, and speakers), and operating system services. Typically, access to powerful subprograms is limited to subprograms that attenuate the power, presenting limited capabilities to other subprograms and programs.
The use statement can not appear in a function or in an if statement.
use lang: language_library("en")
var statement
var_statement
"var" space name ':' space expression
The var statement creates a variable in the current function scope.
The value of a variable can be replaced by the assign statement. The var statement can not appear in an if or do statement. The name is the name of a new variable in this scope. The expression on the right side of the :colon gives the initial value of the variable. The name may not be used in the expression on the right side of the :colon.
Variables must be declared before they are used or assigned values. Note that : expression is not optional.
var first_name: "" var last_name: "" var node_nr: 0