(alter-bodies fn-def expression)
Allows specification of code that should wrap each body of the defn
form. Provides:
defn
macro.
NOTA BENE: &body is an ordered collection of valid expressions.
Example:
(alter-bodies fn-def
`(binding [scope ~[(ns-name &ns) &name ¶ms]]
~@&body))Allows specification of code that should wrap each body of the `defn` form. Provides: * ¶ms - The paramaters corresponding to this arity. * &body - The collection of expressions in the body of this arity. * &ns - The namespace in which this fn is being interned * &name - The symbol used to name this defn. * &meta - The metadata attached to the fn name. * &env-keys - The keys of the &env map known to the `defn` macro. NOTA BENE: &body is an *ordered collection* of valid expressions. Example: (alter-bodies fn-def `(binding [*scope* ~[(ns-name &ns) &name ¶ms]] ~@&body))
(alter-bodies* fn-def f)
Takes a fn-def and a function of args [params body] and replaces each body in the fn-def with the result of applying the function to the params and the body! body should be assumed to be a collection of valid expressions.
Takes a fn-def and a function of args [params body] and replaces each body in the fn-def with the result of applying the function to the params and the body! body should be assumed to be a collection of valid expressions.
(alter-form fn-def expression)
Allows specification of code that would wrap the entire defn
form.
Useful mainly for providing a lexical scope (e.g., evaluating the defn
within the body of a let
). Provides:
defn
macro.Allows specification of code that would wrap the entire `defn` form. Useful mainly for providing a lexical scope (e.g., evaluating the `defn` within the body of a `let`). Provides: * &ns - The namespace in which this fn is being interned * &name - The symbol used to name this defn. * &meta - The metadata attached to the fn name. * &env-keys - The keys of the &env map known to the `defn` macro. * &form - A placeholder for the actual form -- not the form itself. NOTA BENE: &form should always be assumed to represent a *single* expression. Example: (alter-form fn-def `(binding [*my-var* 3 ~&form)))
(defn name doc-string? attr-map? [params*] prepost-map? body)
(defn name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?)
Should behave exactly like clojure.core/defn, except:
You can tag the fn name with aspects:
^{:morphe.core/aspects [aspects ...]}
The aspects must be functions of one argument that know how to manipulate a
morphe.core/ParsedFnDef record.
In implementation, it basically uses the guts of clojure.core/defn to parse the definition, representing the parsed form with a ParsedFnDef record, which then gets operated on by composable modification fns (aspects).
The ParsedFnDef record has the following fields:
:env - the &env
var inside the defn
call.
:wrapper - A single expression not equal to, but representing any code that
should wrap the defn
call.
:namespace - The namespace in which the fn is being interned.
:fn-name - The symbolic name of the function being defined.
:metadata - The metadata that was attached to the fn-name.
:arglists - A sequence of arglists, one for each arity.
:bodies - A sequence of arity bodies, where each body is a collection of expressions.
Should behave exactly like clojure.core/defn, except: You can tag the fn name with aspects: `^{:morphe.core/aspects [aspects ...]}` The aspects must be functions of one argument that know how to manipulate a morphe.core/ParsedFnDef record. In implementation, it basically uses the guts of clojure.core/defn to parse the definition, representing the parsed form with a ParsedFnDef record, which then gets operated on by composable modification fns (aspects). The ParsedFnDef record has the following fields: :env - the `&env` var inside the `defn` call. :wrapper - A single expression not equal to, but representing any code that should wrap the `defn` call. :namespace - The namespace in which the fn is being interned. :fn-name - The symbolic name of the function being defined. :metadata - The metadata that was attached to the fn-name. :arglists - A sequence of arglists, one for each arity. :bodies - A sequence of arity bodies, where each body is a collection of expressions.
(prefix-bodies fn-def expression)
Allows the specification of an expression that will be added to the beginning of each fn arity (presumably for side-effects). Provides:
defn
macro.
Example: (prefix-bodies fn-def `(assert (even? 4) "Math still works."))Allows the specification of an expression that will be added to the beginning of each fn arity (presumably for side-effects). Provides: * ¶ms - The paramaters corresponding to this arity. * &ns - The namespace in which this fn is being interned * &name - The symbol used to name this defn. * &meta - The metadata attached to the fn name. * &env-keys - The keys of the &env map known to the `defn` macro. Example: (prefix-bodies fn-def `(assert (even? 4) "Math still works."))
(prefix-bodies* fn-def f)
Takes a fn-def and a function of args [params] and prefixes each body in the fn-def with the result of applying the function to the params!
Takes a fn-def and a function of args [params] and prefixes each body in the fn-def with the result of applying the function to the params!
(prefix-form fn-def expression)
Allows the specification of an expression that will be evaluated before
the defn
form (presumably for side-effects). Provides:
defn
macro.
Example:
(prefix-form fn-def
`(println (format "Compiling %s/%s now."
(ns-name &ns)
&name)))Allows the specification of an expression that will be evaluated before the `defn` form (presumably for side-effects). Provides: * &ns - The namespace in which this fn is being interned * &name - The symbol used to name this defn. * &meta - The metadata attached to the fn name. * &env-keys - The keys of the &env map known to the `defn` macro. Example: (prefix-form fn-def `(println (format "Compiling %s/%s now." (ns-name &ns) &name)))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close