Darwin Help

Back to Index

ReadLibrary

Function ReadLibrary


Calling Sequence  ReadLibrary(filename)
ReadLibrary(filename,funcname)
Parameters
NameTypeDescription

filename stringprocedure name or library filename
funcname symbolprocedure name
Return Type  procedure
Synopsis If only filename is supplied as a parameter, this function loads the contents of filename located in the user's local Darwin library. The ReadLibrary returns the function with the supplied name. If there is a second parameter, the first one is used to load the file from the library and the second should be a procedure name which is loaded in that file. ReadLibrary returns the procedure named in the second argument. With two arguments, if the filename starts with a slash ("/"), the it is assumed to be an absolute path name and the library name (stored in libname) will not be prepended to it. The location of the Darwin library is set with the -l flag when initiating your Darwin session and is kept in the global variable "libname".

One of the main uses of ReadLibrary is to provide a mechanism for automatic loading of functions from the library. By assigning a name with an unevaluated call to ReadLibrary (with the appropriate parameters), when the function is used (and its name is evaluated), it will produce the actual reading of the library. Since reading the library is likely to assign the function name with a proc (or something else), the unevaluated ReadLibrary will be obliterated and the reading of the library happens only once. This mechanism allows efficient reading of library functions from many points; the first read will be the only one executed. The file "darwinit" in the Darwin library provides the definitions of all system-defined functions and many different examples of its use.

Examples
> ReadLibrary(MultiAlign);

> ReadLibrary(MultiAlign, AnchorAlign);

See also libname,   ReadProgram,   ReadRawFile