Yazoo takes the libertarian view that a function should be allowed to do whatever it wants to itself, although it can only alter a variable outside of by naming that variable and its lineage. In general these rules are automatic with a C-style syntax for naming variables. Suppose we have a multilayered set of definitions like
functions :: {
f1 :: { str :: string ; ... }
g1 :: { ... }
...
}
...
f2 :: functions.f1
Both g1 and g2 will be able access their respective members str without interfering with one another, though they cannot access members outside of itself with confidence because their code does not know its path. (The statement x = g1() may work inside of f1() but it will cause f2() to crash.) This is all consistent with the libertarian rule. But there is one significant way in which the naming convention does not live up to the rule: functions have no way to reliably name themselves. f1() can print itself---as it should be allowed to do---by writing print(f1), but that won't work inside f2() because its own name was changed. What a function needs is a way of naming one's own variable without having to find out the name of some member that points to it.
Enter `this'. this (with a lower-case `t') usually refers to whatever object encloses the code that is currently running. Be warned, there are two major cases where this may not point where we expect, because Yazoo is very literal about the enclosing-object rule. The first problem case arises when we try to use this inside any other curly braces, as in
a :: { b :: { f :: {... } } }
f_search_path :: { b, a, this }
The problem here is that code within braces always belongs to the definition of some other object, and inside those braces this refers to that object, not the current function. In this case this refers to the set f_search_path, not the enclosing function.
Caveat no. 2 is that this will not work inside of the arguments to another function call. The reason is a bit more complicated and will be explained later, but it precludes things like
print(top(this)) | won't work
We can get around the problem by printing from an alias, which obeys all the normal rules.
self := @this | workspace or function space
print(top(self))
Within a function, this refers to the function itself. At the outermost level or at the command-line, this refers to the `workspace' variable that encompasses all of the user's activities. (Technically, when Yazoo is run interactively at the command line, start.zoo runs all of the user's commands inside of an illusory workspace that is really one of its own variables.) The cosmos of Yazoo is arranged with the true workspace living side-by-side with a register variable (whose members include R_slong, R_composite, etc.) all within the universal variable called Zero. The members of Zero have no names, so there is no way to access anything outside the workspace except by using the built-in register commands.
A second miscellaneous name floating around Yazoo is `that'. that only exists to the right of an equate statement, where it refers to whatever was on the left. It can be used to abbreviate cumbersome expressions such as
facts.num.N = facts.num.N * log(facts.num.N) + facts.num.N
with
facts.num.N = that * log(that) + that
Outside of equations, or to the left of the equals sign, that is void.
Both this and that seem to be funny sorts of members, since their targets depend on the contexts in which they are used. Of course they are not really members at all. They are basic operators, just like `+' and `=' except that they happen not to take any arguments. In total, four operators masquerading as members inhabit Yazoo: this, that; args whom we will meet presently; and the void.
Last update: July 28, 2013