@global dynlib_defined; /* Prototype implementation of a library system for l1. To define a library create a new file and start with the following: @dynlib(name, //must be the file's name minus its .cqct extension [ (import1, lib1.f1), (import2, lib1.f2), (import3, lib2.f1), ... ], [ export1, export2, ... ] { //in this scope, import1 will be bound as a local variable to the export //named f1 of the library named lib1 (the system will search the load path //for lib1.cqct). lib1.cqct must contain an @library(lib1 ... ) { ... }. //We must define export1, export2, etc in this scope. } All library bindings are resolved lazily at run time. Recursive dependencies are allowed. */ if (dynlib_defined == nil) { @global __dynlib_exports,pathto; dynlib_defined = 1; //__dynlib_exports is a map from library identifies (cids) to a map from //function identifies (also cids) to generation functions. //The generation function keyed by a given library cid and function cid will //will return the function with that name from that library when called. //This is not meant for general use. __dynlib_exports = [:]; //pathto returns the first full path to a file with the provided name //found while searching the load path. The below macros depend upon //the existence of such a function. @define pathto(f) { @local i,paths,len; paths = loadpath(); len = length(paths); for(i=0;i