Extensible languages in Clojure, a la Racket's #lang.
This is a simple library that monkey patches clojure.core/load to be extensible to different backends.
monkey-patch-extensible-load does the actual monkey-patching and
must be called explicitly.
lang-dispatch is a map from keywords to alternative load functions
(of type [String -> nil]). The corresponding function will be used to
load a file according its :lang metadata entry in the ns form.
To add a new implementation, use (alter-var-root lang-dispatch assoc :new-impl my-load)
eg. A file with a ns form
(ns fancy-ns-form
{:lang :new-impl})
will use my-load to load the file.
Extensible languages in Clojure, a la Racket's #lang.
This is a simple library that monkey patches clojure.core/load
to be extensible to different backends.
`monkey-patch-extensible-load` does the actual monkey-patching and
must be called explicitly.
`lang-dispatch` is a map from keywords to alternative `load` functions
(of type [String -> nil]). The corresponding function will be used to
load a file according its :lang metadata entry in the `ns` form.
To add a new implementation, use
(alter-var-root lang-dispatch assoc :new-impl my-load)
eg. A file with a `ns` form
(ns fancy-ns-form
{:lang :new-impl})
will use `my-load` to load the file.
(default-eval form)Roughly equivalent to clojure.core/eval.
Roughly equivalent to clojure.core/eval.
(default-load1 base-resource-path)Roughly equivalent to clojure.core/load.
Roughly equivalent to clojure.core/load.
(extensible-eval form)Evaluates the form data structure (not text!) and returns the result.
Evaluates the form data structure (not text!) and returns the result.
(extensible-load & paths)Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise.
Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise.
(file-lang res)Returns the :lang entry in ns form in the given namespace.
Returns the :lang entry in ns form in the given namespace.
(install)(install features)A no-argument function that installs extensible eval and load
alternatives that respect :lang ns metadata
A no-argument function that installs extensible `eval` and `load` alternatives that respect :lang ns metadata
A map from :lang entries to their corresponding load and eval alternatives.
A map from :lang entries to their corresponding `load` and `eval` alternatives.
A no-argument function that installs the extensible eval function
over clojure.core/eval.
A no-argument function that installs the extensible `eval` function over clojure.core/eval.
A no-argument function that installs the extensible load function
over clojure.core/load.
A no-argument function that installs the extensible `load` function over clojure.core/load.
(ns-lang ns)Returns the :lang value in the give Namespace's metadata.
Returns the :lang value in the give Namespace's metadata.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |