The Fabl Manual
Function Index
Class Index
Globals Index
Libraries
Contents

Title Page
Introduction
Sample Code
Architecture
Syntax
Strong Typing
Polymorphism
Operators
Help
Errors
Configuration
RDF
Namespaces
Owl
Datatypes
Resources
Dot ops
Coercion
Type Casting
nil

Types
string
id
int
double
boolean
Literal
Containers
Functions
void

Home
Regarding
The Path
Classes
Delegation
Functional Values
Read/Write
Load/Store
Libraries
Imports
CGI
Libraries

The Fabl load and store primitives can support a variety of schemes for code management. This section describes one such scheme.

The basic idea is to partition code and other content into libraries; each library is assigned a URI. For example, we have assigned the URI http://fabl.net/vocabularies/libgeom2d/1.1 to a library of code related to two-dimensional geometry. Use of this URI provides the basis for unique naming of functions and constants; the code itself (in binary fb form) resides in the file http://fabl.net/lib/libgeom2d/1.1/revision4.fb. The fact that http://fabl.net/lib/libgeom2d/1.1/revision4.fb implements the functions named under http://fabl.net/vocabularies/libgeom2d/1.1 is expressed by the RDF triple:

<http://fabl.net/vocabularies/libgeom2d/1.1> 
   rdfs:isDefinedBy 
   <http://fabl.net/lib/libgeom2d/1.1/revision4.fb>

Note: modification in an RDF vocabulary is called a revision rather than a new version if it adds to the vocabulary without changing the meaning of preexisting terms. Revisions do not require use of a new URI for the vocabulary.

Similarly, the location of a Fabl implementation of the Dublin Core vocabulary is asserted by

<http://purl.org/dc/elements/1.1>
   rdfs:isDefinedBy 
   <http://fabl.net/lib/dublin_core-1.1.fb>

For efficiency and convenience, it is often useful to maintain a local copy of code files. The following triple asserts the availability of such a local copy:

<http://purl.org/dc/elements/1.1>
   rdfs:isDefinedBy 
   <file://../dublin_core-1.1.fb>

(recall that the file URL is interpreted relative to the location of the Fabl executable, in the <fablRoot>/bin directory). The Fabl source code can be found at:

http://fabl.net/lib/dublin_core-1.1-1.fbl
and
file://../lib/dublin_core-1.1-1.fbl

Thus, the following Fabl command performs compilation:

compile("file://../lib/dublin_core-1.1.fb","file://../lib/dublin_core-1.1-1.fbl");

The discovery files

The URIs http://fabl.net/vocabularies/discovery0 ,http://fabl.net/vocabularies/discovery1, and http://fabl.net/vocabularies/discovery2 are allocated to functions that define namespaces and tell where to find the content of the namespaces. discovery0 and discovery1 contain discovery information for libraries that are shipped with Fabl, while discovery2 is for use in Fabl development beyond the core libraries. The distinction between discovery0 and discovery1 is the degree of stability. discovery0 pertains to vocabularies such as Dublin Core and RSS 1.0 that are widely used by the semantic web community, and have been stable for a period of years. discovery1 covers libraries of more recent vintage, that can be expected to evolve further in the near future.

The implementation of the discovery0 namespace, like the other discovery implementations, defines a function namespaces() for defining namespace prefixes, and another function isDefinedBy() for specifying where to find the content of the namespaces. The function discovery() can be invoked to perform both jobs.

The following code sequence sets up the namespace prefixes and the isDefinedBy data as specified in discovery0 and discovery1:

stdlibPrefix = "file://../lib/";

load("file://../lib/discovery0.fb");
discovery0:discovery();
install('discovery1');
discovery1:discovery();

stdlibPrefix is used to designate a standard place to retrieve libraries from; in this case it set to the local lib directory. An install can be used for discovery1 because discovery0 includes the relevant information about discovery1.

The above code sequence is included in <installDir>/bin/init.fbl, and as a result, Fabl starts up with prefixes and isDefinedBy information for about a dozen namespaces. These are in addition to the core namespaces, such as rdf,rdfs,owl and xsd that are built into Fabl, and need no installation (as noted in the namespaces section).

So, at startup time, libraries implementing the namespaces defined in discovery0 and discovery1 are ready for installation by commands such as:

install('foaf');

for the popular foaf vocabulary (see http://xmlns.com/foaf/0.1/).

The discovery implementations make make use of the utility function:

void isDefinedBy(string u0,string u1)

whose implementation is simply:


void function isDefinedBy(string u0,u1)
{
  resource(u0).rdfs:isDefinedBy = resource(u1);
}