Fabl commands which introduce global variables have appeared in earlier sections, for example:
var abc = 23;
It is now time to explain how this relates to the RDF data model. URIs provide the basic mechanism for identifying resources in the Semantic Web, but it is not easy, nor necessary, to agree on URIs for all entities. Another approach, called reference by description, was introduced as part of the the Stanford TAP Project. The idea is simple: a description that is true of exactly one resource serves as an identifier for that resource. For example, the time that a photograph was taken together with the identity of its photographer uniquely identifies the photograph (except in unusual circumstances). Such a description is called discriminant in the terminology TAP.
The Fabl implementation draws on this idea for identifying global variables, functions, and parametric types. URIs are not fabricated to denote these. Instead, each is endowed with a description that uniquely identifies it. Here are the details:
The class fabl:Regarding is a subclass of rdf:Property that allows us to associate
a unique property with any resource R. The function
Property regarding(Resource R)
constructs elements of this class. An element of Regarding does not have a URI, but is uniquely characterized by the resource which it regards. That is,
regarding(R) == regarding(Q) implies R==Q
So, elements of Regarding are referenced by description. This construct allows us to build associative arrays in Fabl. Example:
var aa = new(Resource);
set(aa,regarding('left'),23);
set(aa,regarding('right'),24);
fget(aa,regarding('left'));
-->23
The syntax:
aa['left'];
is equivalent to fget(aa,regarding('left'))
Fabl globals are implemented using this mechanism. The command
var x = 23;
is implemented by
set(home,regarding('x'),23);
There is an additional aspect to globals: their types. Each resource R with associated globals is assigned its own OWL class - a singleton class containing only R itself. When a new global is introduced, a new restriction is placed on the class asserting that the values of the global belong to the the given type. (If this seems abstruse, there is no need to worry; detailed understanding of this mechanism is not relevant to Fabl programming practice).
Parametric types and functions receive similar treatment. A parametric type is uniquely identified by its variety (SeqOf or Function), and by its parameters (the base type of a sequence, or the input and output types of a function). A function is uniquely identified by the home in which it is defined, its name, and the types of its inputs. Thus many functions function named f can exist under the same home, as long as their input types differ.