typed.clj.lang

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

(default-eval form)
Roughly equivalent to clojure.core/eval.

default-load1

(default-load1 base-resource-path)
Roughly equivalent to clojure.core/load.

extensible-eval

(extensible-eval form)
Evaluates the form data structure (not text!) and returns the result.

extensible-load

added in 1.0

(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.

file-lang

(file-lang res)
Returns the :lang entry in ns form in the given namespace.

install

(install)(install features)
A no-argument function that installs extensible `eval` and `load`
alternatives that respect :lang ns metadata

lang-dispatch

A map from :lang entries to their corresponding `load` and `eval` alternatives.

monkey-patch-extensible-eval

A no-argument function that installs the extensible `eval` function
over clojure.core/eval.

monkey-patch-extensible-load

A no-argument function that installs the extensible `load` function
over clojure.core/load.

ns-lang

(ns-lang ns)
Returns the :lang value in the give Namespace's metadata.