($bound-fn & fn-tail)
Returns a function defined by the given fn-tail that, when called, will activate the same dynamic environment active in the thread at the time $bound-fn was called.
This is basically an "enhanced" version of clojure.core/bound-fn.
Returns a function defined by the given fn-tail that, when called, will activate the same dynamic environment active in the thread at the time $bound-fn was called. This is basically an "enhanced" version of clojure.core/bound-fn.
Returns a function which, when called, will install the same dynamic environment active in the thread at the time $bound-fn* was called and then call f with any given arguments.
This is basically an "enhanced" version of clojure.core/bound-fn*.
Returns a function which, when called, will install the same dynamic environment active in the thread at the time $bound-fn* was called and then call f with any given arguments. This is basically an "enhanced" version of clojure.core/bound-fn*.
Are we allowed to start another trampoline if there's already one on the stack?
Default: true
Are we allowed to start another trampoline if there's already one on the stack? Default: true
Set to true when the CPS compiler expands a macro
Set to true when the CPS compiler expands a macro
Contains a map specifying how special forms are handled.
We need to treat certain forms as "special". Often, these are Clojure "special forms", but there are other forms we need to treat specially as well — such as 'binding' forms (which Clojure implements as a macro).
This var provides a unified way of detecting these cases and dispatching to an appropriate handler function. It is also dynamic, allowing compilers built on top of the cps compiler to implement their own special forms.
Clojure special forms are handled by mapping its "special symbol" to a handler function. Other forms are handled by mapping the var object representing the operator of the form (i.e., #'binding) to a handler function. The handler function must accept the following parameters (in order)
Contains a map specifying how special forms are handled. We need to treat certain forms as "special". Often, these are Clojure "special forms", but there are other forms we need to treat specially as well — such as 'binding' forms (which Clojure implements as a macro). This var provides a unified way of detecting these cases and dispatching to an appropriate handler function. It is also dynamic, allowing compilers built on top of the cps compiler to implement their own special forms. Clojure special forms are handled by mapping its "special symbol" to a handler function. Other forms are handled by mapping the var object representing the operator of the form (i.e., #'binding) to a handler function. The handler function must accept the following parameters (in order) * form - the form to be expanded * macro-env - the macro environment * continuation - a form representing the current continuation of the form being expanded * dynamic-env - a symbol representing the dynamic environment that will be available when the form is executed (i.e., a map containing the var->value bindings for dynamic vars)
If true, we are not allowed to make calls to CPS functions. Otherwise, we can mix functions any way we like.
Default: false
If true, we are not allowed to make calls to CPS functions. Otherwise, we can mix functions any way we like. Default: false
Records the number of trampolines active on the current stack.
Records the number of trampolines active on the current stack.
(auto-override-fn name)
Attempts to automatically generate a CPS override for a function from its native definition. This requires that the source code be for the function is discoverable. Currently, this is done via clojure.repl/source-fn. If the source for the function can not be located, a compile-time exception is thrown.
name is the name (symbol) of the function to override.
This macro is useful to cases where a) the source code for a function is discoverable, and b) that code can be transformed as-is by the CPS compiler (i.e., it does not contain unsupported forms) If those conditions are satisfied, this macro is a great way to provide a CPS implementation of a function without the need to duplicate the code.
Attempts to automatically generate a CPS override for a function from its native definition. This requires that the source code be for the function is discoverable. Currently, this is done via clojure.repl/source-fn. If the source for the function can not be located, a compile-time exception is thrown. name is the name (symbol) of the function to override. This macro is useful to cases where a) the source code for a function is discoverable, and b) that code can be transformed as-is by the CPS compiler (i.e., it does not contain unsupported forms) If those conditions are satisfied, this macro is a great way to provide a CPS implementation of a function without the need to duplicate the code.
(call f cont env & args)
(cps & body)
(cps-apply cont env f evaled unevaled)
Helper macro used by cps-call for transforming function calls.
Parameters: cont - this form's continuation form f - a symbol representing the function to be called evaled - a vector of symbols representing values for function argument expressions that have been transformed so far unevaled - a vector containing forms for function arguments that still need to be transformed
Helper macro used by cps-call for transforming function calls. Parameters: cont - this form's continuation form f - a symbol representing the function to be called evaled - a vector of symbols representing values for function argument expressions that have been transformed so far unevaled - a vector containing forms for function arguments that still need to be transformed
(cps-binding cont env bindings & body)
(cps-call cont env)
(cps-call cont env f & args)
Macro that transforms a function call.
Parameters: cont - this form's continuation form f - the form of the function to be called args - the forms of the function arguments
Macro that transforms a function call. Parameters: cont - this form's continuation form f - the form of the function to be called args - the forms of the function arguments
(cps-coll cont env coll)
(cps-def cont env name)
(cps-def cont env name expr)
(cps-def cont env name doc expr)
(cps-do cont env)
(cps-do cont env expr & body)
(cps-dot cont env & body)
(cps-expr cont env expr)
(cps-exprs env exprs callback)
Low-level macro for transforming a sequence of expressions and binding their values to variables.
After all expressions have been processed, callback is called with a collection of symbols which will be bound to the values of the expressions. callback should return a form, which will be executed in a scope with all these variables. Note that callback must be an actual function, callable at macro-expansion time, not a form representing a function.
Low-level macro for transforming a sequence of expressions and binding their values to variables. After all expressions have been processed, callback is called with a collection of symbols which will be bound to the values of the expressions. callback should return a form, which will be executed in a scope with all these variables. Note that callback must be an actual function, callable at macro-expansion time, not a form representing a function.
(cps-fn & body)
Generates a CPS-transformed function from the given body(ies). Simply specify the function the same way you would use fn.
Generates a CPS-transformed function from the given body(ies). Simply specify the function the same way you would use fn.
(cps-fn* cont env name & bodies)
Constructs a CPS-transformed function
If cont is not nil, it will be called with the resulting function. Otherwise, the resulting form will evaluate direcly to the function.
Constructs a CPS-transformed function If cont is not nil, it will be called with the resulting function. Otherwise, the resulting form will evaluate direcly to the function.
(cps-form cont env form)
(cps-if cont env test then)
(cps-if cont env test then else)
(cps-let* cont env bindings & body)
(cps-let-cc cont env [cc] & body)
CPS-aware macro for expanding a let-cc form
CPS-aware macro for expanding a let-cc form
(cps-letfn* cont env bindings & body)
(cps-new cont env class & params)
(cps-quote cont env & body)
(cps-set! cont env place expr)
(cps-special-form cont env form)
(cps-symbol cont env name)
(cps-try cont env & exprs)
(cps-var cont env symbol)
(default-exception-handler ex)
(dynamic? resolved-var)
(fn->callable f)
Reifies f to implement both ICallable and IFn. The result is an object that can be called with call -- e.g., within CPS-transformed code -- or directly as an IFn (e.g., in "normal" code). If invoked as an IFn, it will automatically start a trampoline.
f must implement IFn, and must accept a continuation as its first argument. Ideally, it will be CPS-transformed.
Reifies f to implement both ICallable and IFn. The result is an object that can be called with call -- e.g., within CPS-transformed code -- or directly as an IFn (e.g., in "normal" code). If invoked as an IFn, it will automatically start a trampoline. f must implement IFn, and must accept a continuation as its first argument. Ideally, it will be CPS-transformed.
(forbid-fn! f)
(forbid-fn! f msg)
Provides a "CPS Override" for a fn that throws an IllegalStateException, thus effectively preventing the function from being called from a CPS context.
Provides a "CPS Override" for a fn that throws an IllegalStateException, thus effectively preventing the function from being called from a CPS context.
(get-dynamic-env)
Returns an opaque representation of the current thread's dynamic bindings
Returns an opaque representation of the current thread's dynamic bindings
(handler-case protected & exception-handlers)
Executes protected in an environment with the specified exception-handlers installed as exception handlers. If protected exits normally, handler-case returns its value. Otherwise (if protected throws an exception), the first exception-handler that matches the thrown exception type will be invoked. If no matching handler is found, the exception is re-thrown.
exception-handlers => exception-handler*
exception-handler => (exception-type [name] & handler-body)
Executes protected in an environment with the specified exception-handlers installed as exception handlers. If protected exits normally, handler-case returns its value. Otherwise (if protected throws an exception), the first exception-handler that matches the thrown exception type will be invoked. If no matching handler is found, the exception is re-thrown. exception-handlers => exception-handler* exception-handler => (exception-type [name] & handler-body) * exception-type - Type of exception to be handled by this case. An exception will match this case if it is of this type or a sub-type of this type. * name - Name (variable) to which the thrown exception will be bound. * handler-body - sequence of expressions to be evaluated when a matching exception is thrown.
(with-continuation callable cont env)
(invoke-thunk thunk)
(let-cc [cc] & body)
Executes body with <cc> bound to the current continuation.
Usage:
(let-cc [<cc>]
<body...>
Executes body with <cc> bound to the current continuation. Usage: (let-cc [<cc>] <body...>
(override-fn name & fn-tails)
Used to provide a CPS-transformed version of an existing native function.
This macro generates a CPS override for the specified function from the provided implementation code (in fn-tails). The provided implementation code is CPS-transformed and will be called (as a CPS routine) when the specified function is called from within another CPS routine. This effectively replaces the native implementation with a CPS implementation in such cases.
name is the function to override.
fn-tails are function parameter list(s) and body(ies), as would be used in a fn or cps-fn form. These are enclosed in a cps-fn form and sent through the CPS compiler.
Used to provide a CPS-transformed version of an existing native function. This macro generates a CPS override for the specified function from the provided implementation code (in fn-tails). The provided implementation code is CPS-transformed and will be called (as a CPS routine) when the specified function is called from within another CPS routine. This effectively replaces the native implementation with a CPS implementation in such cases. name is the function to override. fn-tails are function parameter list(s) and body(ies), as would be used in a fn or cps-fn form. These are enclosed in a cps-fn form and sent through the CPS compiler.
(override-fn* name callable)
Version of override-fn that accepts an ICallable object, rather than a function form.
Version of override-fn that accepts an ICallable object, rather than a function form.
(override-macro! name & fn-spec)
(thunk & body)
(trampoline f & args)
Runs f on a trampoline, and returns the resulting value.
Runs f on a trampoline, and returns the resulting value.
(translate-to symbol)
Helper for constructing handler functions for translating forms from one language to another. Basically, the operator of the input form is replaced with the symbol parameter.
Helper for constructing handler functions for translating forms from one language to another. Basically, the operator of the input form is replaced with the symbol parameter.
(unwind-protect protected & cleanup)
(with-dynamic-env env & body)
Takes an opague dynamic environment (á la get-dynamic-env). The body is then executed with that environment activated.
Takes an opague dynamic environment (á la get-dynamic-env). The body is then executed with that environment activated.
(with-dynamic-env* env f & args)
Takes an opaque dynamic environment (á la get-dynamic-env) and a function of no arguments. The function is then called with that environment activated.
Takes an opaque dynamic environment (á la get-dynamic-env) and a function of no arguments. The function is then called with that environment activated.
(with-exception-handler f & body)
Executes body in a context with f effectively installed as an exception handler function.
Executes body in a context with f effectively installed as an exception handler function.
(with-strict-cps & body)
(with-thread-binding-frame frame & body)
(without-recursive-trampolines & body)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close