Macros and macro helpers used in schema.core.
Macros and macro helpers used in schema.core.
(apply-prepost-conditions body)
Replicate pre/postcondition logic from clojure.core/fn.
Replicate pre/postcondition logic from clojure.core/fn.
(assert! form & format-args)
Like assert, but throws a RuntimeException (in Clojure) and takes args to format.
Like assert, but throws a RuntimeException (in Clojure) and takes args to format.
(cljs-env? env)
Take the &env from a macro, and tell whether we are expanding into cljs.
Take the &env from a macro, and tell whether we are expanding into cljs.
(compile-fn-validation? env fn-name)
Returns true if validation should be included at compile time, otherwise false. Validation is elided for any of the following cases:
Returns true if validation should be included at compile time, otherwise false. Validation is elided for any of the following cases: * function has :never-validate metadata * *compile-fn-validation* is false * *assert* is false AND function is not :always-validate
(defrecord-schema n & args)
Like defrecord for schema primitives, and also registers cross-platform print methods.
Like defrecord for schema primitives, and also registers cross-platform print methods.
(error! s)
(error! s m)
Generate a cross-platform exception appropriate to the macroexpansion context
Generate a cross-platform exception appropriate to the macroexpansion context
(extract-arrow-schematized-element env s)
Take a nonempty seq, which may start like [a ...] or [a :- schema ...], and return a list of [first-element-with-schema-attached rest-elements]
Take a nonempty seq, which may start like [a ...] or [a :- schema ...], and return a list of [first-element-with-schema-attached rest-elements]
(extract-schema-form symbol)
Pull out the schema stored on a thing. Public only because of its use in a public macro.
Pull out the schema stored on a thing. Public only because of its use in a public macro.
(if-cljs then else)
Return then if we are generating cljs code and else for Clojure code. https://groups.google.com/d/msg/clojurescript/iBY5HaQda4A/w1lAQi9_AwsJ
Return then if we are generating cljs code and else for Clojure code. https://groups.google.com/d/msg/clojurescript/iBY5HaQda4A/w1lAQi9_AwsJ
(normalized-defn-args env macro-args)
Helper for defining defn-like macros with schemas. Env is &env from the macro body. Reads optional docstring, return type and attribute-map and normalizes them into the metadata of the name, returning the normalized arglist. Based on clojure.tools.macro/name-with-attributes.
Helper for defining defn-like macros with schemas. Env is &env from the macro body. Reads optional docstring, return type and attribute-map and normalizes them into the metadata of the name, returning the normalized arglist. Based on clojure.tools.macro/name-with-attributes.
(normalized-metadata env imeta explicit-schema)
Take an object with optional metadata, which may include a :tag, plus an optional explicit schema, and normalize the object to have a valid Clojure :tag plus a :schema field.
Take an object with optional metadata, which may include a :tag, plus an optional explicit schema, and normalize the object to have a valid Clojure :tag plus a :schema field.
(parse-arity-spec spec)
Helper for schema.core/=>*.
Helper for schema.core/=>*.
(process-arrow-schematized-args env args)
Take an arg vector, in which each argument is followed by an optional :- schema, and transform into an ordinary arg vector where the schemas are metadata on the args.
Take an arg vector, in which each argument is followed by an optional :- schema, and transform into an ordinary arg vector where the schemas are metadata on the args.
(process-fn- env name fn-body)
Process the fn args into a final tag proposal, schema form, schema bindings, and fn form
Process the fn args into a final tag proposal, schema form, schema bindings, and fn form
(process-fn-arity {[bind & body] :arity-form
:keys [env fn-name output-schema-sym bind-meta ufv-sym]})
(process-fn-arity env fn-name output-schema-sym bind-meta arity-form)
Process a single (bind & body) form, producing an output tag, schema-form, and arity-form which has asserts for validation purposes added that are executed when turned on, and have very low overhead otherwise. tag? is a prospective tag for the fn symbol based on the output schema. schema-bindings are bindings to lift eval outwards, so we don't build the schema every time we do the validation.
:ufv-sym should name a local binding bound to schema.utils/use-fn-validation
.
5-args arity is deprecated.
Process a single (bind & body) form, producing an output tag, schema-form, and arity-form which has asserts for validation purposes added that are executed when turned on, and have very low overhead otherwise. tag? is a prospective tag for the fn symbol based on the output schema. schema-bindings are bindings to lift eval outwards, so we don't build the schema every time we do the validation. :ufv-sym should name a local binding bound to `schema.utils/use-fn-validation`. 5-args arity is deprecated.
(safe-get m k)
Like get but throw an exception if not found. A macro for historical reasons (to work around cljx function placement restrictions).
Like get but throw an exception if not found. A macro for historical reasons (to work around cljx function placement restrictions).
(set-compile-fn-validation! on?)
Globally turn on or off function validation from being compiled into s/fn and s/defn. Enabled by default. See (doc compile-fn-validation?) for all conditions which control fn validation compilation
Globally turn on or off function validation from being compiled into s/fn and s/defn. Enabled by default. See (doc compile-fn-validation?) for all conditions which control fn validation compilation
(try-catchall & body)
A cross-platform variant of try-catch that catches all* exceptions. Does not (yet) support finally, and does not need or want an exception class.
*On the JVM certain fatal exceptions are not caught.
A cross-platform variant of try-catch that catches all* exceptions. Does not (yet) support finally, and does not need or want an exception class. *On the JVM certain fatal exceptions are not caught.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close