The home resource is the resource to which Fabl adds new globals and functions. The function
void setHome(Resource x)
sets the home to x. Here's an example:
allocate("ex:home1");
setHome(ex:home1);
var abc = 234;
This adds the global abc to the resource ex:home1. (As will be explained in the next section, the underlying RDF action involves setting the value of the property regarding('abc') on the resource ex:home1 to 234.)
Continuing the example:
allocate("ex:home2");
setHome(ex:home2);
var abc = "hello from home2";
adds abc to the namespace ex:home2 with a different value and type.
Then,
setHome(ex:home1); abc; --> 234 setHome(ex:home2); abc; --> hello from home2
setHome may be passed a namespace prefix, as in
setHome('ex');
with an effect identical to
setHome(namespace('ex'));
The function
sets the home resource to the resource that was home prior to execution of the last setHome. Example:
setHome(ex:home1);// now ex:home1 is home setHome(ex:home2);// and now ex:home2 lastHome(); // back to ex:home1
returns an anonymous resource (ie an object with no URI) that is suitable for use as a home resource. (Home resources require initialization of the path and namespaces properties; this initialization is performed by newHome.)
The special namespace home: is allocated to the home resource. For example,
allocate("home:myprop",Property);
allocates myprop under the home resource, whatever that happens to be.
Also, the global variable home evaluates to the home resource.