Appendix A: Keywords
Zuri reserves thirty-one words. None of them can be used as a variable, function, class or parameter name.
| Keyword | What it does | Covered in |
|---|---|---|
and | logical conjunction, short-circuiting | Operators |
as | binds an error in catch, or renames an import | Errors, Modules |
assert | raises AssertError when its condition is falsy | Control Flow |
break | leaves the innermost loop | Control Flow |
catch | runs a block, intercepting anything it raises | Errors |
class | declares a class, or with > an extension to one | Classes, Extensions |
const | declares a name that cannot be reassigned | Variables |
continue | skips to the next iteration | Control Flow |
def | declares a function, named or anonymous | Functions |
default | the fall-through branch of a using | Control Flow |
do | begins a do/while loop | Control Flow |
echo | prints a value and a newline | Hello, World! |
else | the alternative branch of an if | Control Flow |
false | the boolean false | Data Types |
for | iterates over anything iterable | Control Flow |
if | conditional branch | Control Flow |
import | loads a module | Modules |
in | separates a for loop’s variables from its iterable | Control Flow |
iter | the counting loop | Control Flow |
nil | the absence of a value | Data Types |
or | logical disjunction, short-circuiting | Operators |
parent | the superclass constructor, or a superclass method | Inheritance |
raise | raises an error | Errors |
return | leaves the current function | Control Flow |
self | the current instance, inside a method | Classes |
static | puts a field or method on the class, not the instance | Classes |
true | the boolean true | Data Types |
using | multi-way branch on one subject | Control Flow |
var | declares a variable | Variables |
when | one branch of a using | Control Flow |
while | the conditional loop | Control Flow |
Names That Are Not Keywords
These are ordinary globals, not reserved words, so nothing stops you from shadowing one. Doing so is a good way to confuse the next reader:
time sum bytes file instance_of typeof
delprop getprop hasprop setprop id print
rand is_bigint is_bool is_bytes is_callable is_class
is_dict is_file is_function is_instance is_int is_iterable
is_list is_number is_object is_string
The built-in error classes are also globals: Error, TypeError,
ValueError, NumericError, ArgumentError, NotImplementedError,
RangeError, AccessError, AssertError, PropertyError,
UndefinedError and ModuleNotFoundError.
Reserved by Convention
Two module-level names are provided by the runtime rather than declared by
you: __file__ and __root__. See Modules.
Names beginning with $ are never produced by the lexer, which is how the
compiler synthesises loop variables that cannot collide with yours.
A leading underscore marks something private, both for class members and for module members. The compiler enforces it in both cases.