-
Notifications
You must be signed in to change notification settings - Fork 4
load
This operator imports a module into the current lexical scope.
The first argument must be a text or a symbol. A text can be a local filename, an http url, or an https url. A symbol path must correspond to a function defined in ~/.sexy/symbols.sxy. This file is defined for the user if it does not exist; the default symbols.sxy file contains symbols for sexy and github.
Each load symbol is read up to the nearest /. Sexy searches for a function of this name in symbols.sxy and, if found, calls the function with the rest of the symbol (after the /) as a string.
(load sexy/test/sexy-lib/0)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/0.2.0")
(load sexy/test/sexy-lib/0.1)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/0.1.2")
(load sexy/test/sexy-lib/0.1.0)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/0.1.0")
(load sexy/test/sexy-lib/1)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/1.6.4")
(load sexy/test/sexy-lib/1.2.4)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/1.2.4")
(load sexy/test/sexy-lib/1.5)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/1.5.9")
(load sexy/test/sexy-lib/1.5.7)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/1.5.7")
(load github/TurtleKitty/sexy-lib/test/sexy-lib/0)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/0.2.0")
(load github/TurtleKitty/sexy-lib/test/sexy-lib/1)
-> (load "https://raw.githubusercontent.com/TurtleKitty/sexy-lib/master/test/sexy-lib/1.6.4")
Subsequent arguments and options are passed to the lib function of the module. The return value of this function is the return value for load. In most cases, the Sexy programmer will want to assign the result of load to a name. The use operator is syntactic sugar for load.
(use name path ...) -> (def name (load path ...))
At compile time, the syntax operator determines what operators will be imported into the local scope.
Modules can be mutually recursive. A module can even import itself, but one had better have a termination condition in the lib form.