The Do Block
Transform the language with features from the context of an object.
Introduction
The do
statement is one of the most versatile and powerful syntax elements in the language. It is also one of the most complex.
In essence, it transforms the language by giving the user access to the properties of an object as new syntax keywords.
However, since the object is defined and exists only during runtime, the parse-time information and errors available are very limited, making it a trickier construct to use.
The computed object result of the statement is the target of the do
block. All of that object's properties are unwrapped into syntax keywords.
These keywords either reference the value of their linked property or, if the property is a function, they directly invoke that function, removing the need for the run
statement in some contexts.
At face value this can be used as a syntax-simplifier, removing the need to write out x[y]
property references.
However, it also allows an advanced user to alter the language with the functional properties that are available.
The statements in the turtle's do
block would be completely unintelligible in regular context, but are valid syntax because they are local keywords made from the properties of the turtle object.
Last updated