This appendix lists the words that have a fixed meaning in Teascript. The lexical rules for them are given in Lexical Structure; here every word is listed with its role and the chapter that defines it.

Reserved Words

Teascript has 32 reserved words. They are written in lower case, are case-sensitive (While is an ordinary identifier), and cannot be used as identifiers. Not as the name of a variable, constant, function, class, parameter or imported name, nor as an attribute name that is written after a dot with one exception (see Reserved words after a dot).

WordRoleDefined in
andlogical AND, short-circuitLogical
asalias an imported module or valueImport Semantics
breakends innermost loopbreak
caseclause of switchswitch
classclass declarationClass Definition and Instantiation
constdeclare constantsConstants
continueproceed to the next iteration of the innermost loopcontinue
defaultfallback clause of switchswitch
dobegins do { ... } while loopwhile / do
elsealternative branch of ifif / else
exportmakes a module-level declaration or variable available to importersExports
falseboolean value falseBoolean
forloopsGeneric for, Iterative for
fromfrom module import ...Import Semantics
functionfunction declaration, expression, methodFunctions
ifconditional statementif / else
importload a moduleImport Semantics
inmembership operator, used in iterative forComparison, Generic for
isclass membership testIdentity
newclass constructorInstantiation
nilabsent valueNil
notlogical negation; not in, is notLogical
operatoroperator methodOperator Overload Dispatch Table
orlogical OR, short-circuitLogical
returnend enclosing functionreturn
selfmethod receiverSelf and Super
staticstatic methodClass Definition and Instantiation
superrefer to superclassSelf and Super
switchmulti-way selection by equalityswitch
trueboolean value trueBoolean
vardeclare variableVariable Declaration
whileloopswhile / do

Groups

GroupWords
Valuesnil true false
Declarationsvar const function class static operator new
Conditionalsif else switch case default
Loops & Jumpsfor while do in break continue return
Operatorsand or not is in
Objectsself super new
Modulesimport from as export

Multi-role Words

WordRoles
inthe membership operator (x in list) and the separator of a generic for (for var x in list)
notthe prefix operator, and the first word of not in
isthe class test, and the first word of is not
newthe constructor declaration in a class body, and the member name in Class.new(...)
functiona declaration, an expression, and a method declaration in a class body

Context-sensitive Words

Every reserved word is reserved everywhere; the following are, in addition, meaningful only in some places, and are rejected elsewhere:

WordValid in
static, operatorthe body of a class
selfmethods, constructors, accessors, and the [] and []= operators of a class
superthe body of a class declared with a superclass
newfollows a dot; Point.new(1, 2)
case, defaulta switch statement
break, continuethe body of a loop
returnthe body of a function
exportthe main body of a module

Not Reserved Words

The following words may look like keywords but are ordinary identifiers.

Special Method Names

getattr, setattr, call, iter, contains, tostring and gc are recognized by the runtime only because a class defines a method with that name (see Special Methods). They can be used as variable names, parameter names and attribute names like any other identifier.

Predefined Globals

The base library defines a set of names that are available in every module. They are not reserved: they are ordinary variables of the global environment that can be read but not assigned, and any scope can shadow one by declaring a variable of the same name (see Declarations).

KindNames
Functionsprint input assert error typeof tonumber tostring gc eval dump loadfile loadstring pcall rawequal hasattr getattr setattr delattr
ClassesObject Number Bool Function, and the classes of the other built-in types

The names of the standard modules (math, os, io and others) are not variables and are not reserved either: they are logical module names used by import (see Search Path Resolution).

Symbols

Some character sequences used in other languages are not tokens of Teascript and are scanned as separate tokens or rejected: ++, --, &&, ||, ===, !==, ??, ->, :: and @. In particular, logical operators are the words and, or and not (and ! as a spelling of not), and in a slice x[a::c] the two colons are two separate : tokens.