-% Inform in four minutes
+o% Inform in four minutes
% Roger Firth <roger@firthworks.com>
A quick reference to the Inform programming language.
can include special values including:
------------- ------------------------------------
- \^ newline
- \~ quote (")
+ ^ newline
+ ~ quote (")
@@64 at sign "@"
@@92 backslash ""
- @@94 circumflex "\^"
- @@126 tilde "\~"
- @\`a a with a grave accent "`à`", et al
+ @@94 circumflex "^"
+ @@126 tilde "~"
+ @`a a with a grave accent "`à`", et al
@LL pound sign "£", et al
@00 ... @31 low string 0..31
------------- ------------------------------------
---------- ---------------------------------------------
*p + q* addition
*p - q* subtraction
- *p * q\* multiplication
+ *p * q* multiplication
*p / q* integer division
*p % q* remainder
*p++* increments *p*, evaluates to original value
*--p* decrements *p*, evaluates to new value
*p & q* bitwise AND
*p | q* bitwise OR
- *\~p* bitwise NOT (inversion)
+ *~p* bitwise NOT (inversion)
---------- ---------------------------------------------
Conditional expressions return `true` (1) or `false` (0); *q* may be a
---------------- ----------------------------------------
*p == q* *p* is equal to *q*
- *p \~= q* *p* isn't equal to *q*
+ *p ~= q* *p* isn't equal to *q*
*p* > *q* *p* is greater than *q*
*p < q* *p* is less than *q*
*p >= q* *p* is greater than or equal to *q*
-------- ----------------------------------
p && q both p and q are true (non-zero)
p || q either p or q is true (non-zero)
- \~\~p p is false (zero)
+ ~~p p is false (zero)
-------- ----------------------------------
To return -1, 0 or 1 based on unsigned comparison:
Objects (for **property** variables) and Routines (for **local**
variables).
-## Classes and Objects
+Classes and Objects
+-------------------
To declare a *class* - a template for a family of objects -
where the optional (*N*) limits instances created at run-time:
A property variable inherited from an object's class is
addressed by *object.class::property*; this gives the
-original value prior to any changes within the object.
\ No newline at end of file
+original value prior to any changes within the object.
+
+Manipulating the object tree
+----------------------------
+
+To change object relationships at run-time:
+
+ move object to parent_object ;
+ remove object ;
+
+To return the parent of an object (or nothing):
+
+ parent(object)
+
+To return the first child of an object (or nothing):
+
+ child(object)
+
+To return the adjacent child of an object's parent (or nothing):
+
+ sibling(object)
+
+To return the number of child objects directly below an object:
+
+ children(object)
+
+Message passing
+---------------
+
+To a class:
+
+ class.remaining()
+ class.create()
+ class.destroy(object)
+ class.recreate(object)
+ class.copy(to_object,from_object)
+
+To an object:
+
+ object.property(a1,a2, ... a7)
+
+To a routine:
+
+ routine.call(a1,a2, ... a7)
+
+To a string:
+
+ string.print()
+ string.print_to_array(array)
+
+Statements
+----------
+
+Each *statement* is terminated by a semi-colon ";".
+
+A *statement_block* is a single *statement* or a series of
+*statements* enclosed in braces {...}.
+
+An exclamation "!" starts a comment - rest of line ignored.
+
+A common statement is the assignment:
+
+ variable = expr ;
+
+There are two forms of multiple assignment:
+
+ variable = variable = ... = expr ;
+ variable = expr, variable = expr, ... ;
+
+Routines
+--------
+
+A routine can have up to 15 local variables: word values which are
+private to the routine and which by default are set to zero on each
+call. Recursion is permitted.
+
+A **standalone** routine:
+
+- has a name, by which it is called using `routine();` can also be
+ called indirectly using
+
+ indirect(routine,a1,a2, ... a7)
+
+- can take arguments, using `routine(a1,a2, ... a7)`, whose values
+ initialise the equivalent local variables
+
+- returns true at the final "]"
+
+ [ routine
+ local_var local_var ... local_var ;
+ statement;
+ statement;
+ ...
+ statement;
+ ]
+
+A routine **embedded** as the value of an object property:
+
+- has no name, and is called when the property is invoked; can also
+ be called explicitly using object.property()
+
+- accepts arguments only when called explicitly
+
+- returns false at the final "]"
+
+ property [
+ local_var local_var ... local_var;
+ statement;
+ statement;
+ ...
+ statement;
+ ]
+
+Routines return a single value, when execution reaches the final "\]"
+or an explicit return statement:
+
+ return expr;
+ return;
+ rtrue;
+ rfalse;
+
+To define a dummy standalone routine with N local variables (unless it
+already exists):
+
+ Stub routine N;
\ No newline at end of file