☰

clojerl

0.7.0+build.2033.refc431a40

  • Home
  • API Reference

Modules

  • clj_analyzer
  • clj_behaviour
  • clj_cache
  • clj_compiler
  • clj_edn
  • clj_emitter
  • clj_emitter_pattern
  • clj_env
  • clj_hash_collision
  • clj_module
  • clj_multimethod
  • clj_murmur3
  • clj_protocol
  • clj_reader
  • clj_rt
  • clj_scope
  • clj_utils
  • clj_vector
  • clojerl
  • core_eval
  • Basic Types

  • clojerl.BitString
  • clojerl.Boolean
  • clojerl.Float
  • clojerl.Fn
  • clojerl.Integer
  • clojerl.Keyword
  • clojerl.Nil
  • clojerl.String
  • clojerl.Symbol
  • erlang.Fn
  • erlang.Port
  • erlang.Process
  • erlang.Reference
  • erlang.Type
  • erlang.util.Date
  • erlang.util.Regex
  • erlang.util.UUID
  • Namespaces & Vars

  • clojerl.Namespace
  • clojerl.Var
  • Collections & Data Structures

  • clojerl.Cons
  • clojerl.Cycle
  • clojerl.Iterate
  • clojerl.LazySeq
  • clojerl.List
  • clojerl.Map
  • clojerl.Range
  • clojerl.Repeat
  • clojerl.Set
  • clojerl.SortedMap
  • clojerl.SortedSet
  • clojerl.TupleMap
  • clojerl.Vector
  • erlang.List
  • erlang.Map
  • erlang.Tuple
  • Concurrency

  • clojerl.Agent
  • clojerl.Atom
  • clojerl.Delay
  • clojerl.Future
  • clojerl.ProcessVal
  • clojerl.Promise
  • I/O

  • erlang.io.File
  • erlang.io.PushbackReader
  • erlang.io.StringReader
  • erlang.io.StringWriter
  • Errors

  • clojerl.ArityError
  • clojerl.AssertionError
  • clojerl.BadArgumentError
  • clojerl.Error
  • clojerl.ExceptionInfo
  • clojerl.IllegalAccessError
  • Protocols

  • clojerl.IAssociative
  • clojerl.IBlockingDeref
  • clojerl.IChunk
  • clojerl.IChunkedSeq
  • clojerl.IColl
  • clojerl.ICounted
  • clojerl.IDeref
  • clojerl.IEncodeClojure
  • clojerl.IEncodeErlang
  • clojerl.IEquiv
  • clojerl.IError
  • clojerl.IExceptionInfo
  • clojerl.IFn
  • clojerl.IHash
  • clojerl.IIndexed
  • clojerl.IKVReduce
  • clojerl.ILookup
  • clojerl.IMap
  • clojerl.IMeta
  • clojerl.INamed
  • clojerl.IOError
  • clojerl.IPending
  • clojerl.IRecord
  • clojerl.IReduce
  • clojerl.IReference
  • clojerl.IReversible
  • clojerl.ISeq
  • clojerl.ISeqable
  • clojerl.ISequential
  • clojerl.ISet
  • clojerl.ISorted
  • clojerl.IStack
  • clojerl.IStringable
  • clojerl.IType
  • clojerl.IVector
  • erlang.io.ICloseable
  • erlang.io.IPushbackReader
  • erlang.io.IReader
  • erlang.io.IWriter

clj_module

Clojerl compilation module.

Keeps the Core Erlang representation for the modules being compiled.

It is mainly used by clj_emitter to register new modules and then add or update function as each form in the compiler is processed.

Summary

Types

  • clj_module()
  • function_id()

Functions

  • add_alias(AliasSym, AliasedNsSym, ModuleName)
    Adds an alias symbol for a Clojerl namespace.
  • add_attributes(Attrs, ModuleName)
    Adds arbitrary attributes to the module.
  • add_exports(Exports, ModuleName)
    Adds exports of functions to the module.
  • add_functions(Funs, ModuleName)
    Adds functions to the module.
  • add_mappings(Mappings, ModuleName)
    Adds mappings from a symbol to a value.
  • add_on_load(Expr, ModuleName)
    Adds an on_load expression to the module.
  • all_modules()
    Returns a list where each element is Core Erlang module.
  • ensure_loaded(Source, Name)
    Makes sure the clj_module is loaded.
  • fake_fun(ModuleName, Function, Arity)
    Gets the named fake fun that corresponds to the mfa provided.
  • get_functions(ModuleName)
    Returns all functions in the module.
  • get_module(ModuleName)
    Returns the Core Erlang module named ModuleName.
  • in_context()
    Checks whether we are in a clj_module context.
  • is_clojure(Name)
    Checks if the Name module is a Clojerl module.
  • is_loaded(Name)
    Checks if the Clojelr module Name is loaded.
  • is_protocol(Name)
    Checks if the Name module is a Clojerl protocol.
  • maybe_ensure_loaded(Name)
    Ensures a module is loaded when in a compiling context.
  • remove_all_functions(ModuleName)
    Remove all functions in the module.
  • with_context(Fun)
    Runs the function in a clj_module context.

Types

clj_module()
-type clj_module() :: #module{}.

function_id()
-type function_id() :: {atom(), integer()}.

Functions

add_alias(AliasSym, AliasedNsSym, ModuleName)
-spec add_alias('clojerl.Symbol':type(),
                'clojerl.Symbol':type(),
                module() | clj_module()) ->
                   clj_module().

Adds an alias symbol for a Clojerl namespace.

add_attributes(Attrs, ModuleName)
-spec add_attributes([{cerl:cerl(), cerl:cerl()}],
                     clj_module() | module()) ->
                        clj_module().

Adds arbitrary attributes to the module.

add_exports(Exports, ModuleName)
-spec add_exports([{atom(), non_neg_integer()}],
                  clj_module() | module()) ->
                     clj_module().

Adds exports of functions to the module.

add_functions(Funs, ModuleName)
-spec add_functions([{cerl:cerl(), cerl:cerl()}],
                    module() | clj_module()) ->
                       clj_module().

Adds functions to the module.

add_mappings(Mappings, ModuleName)
-spec add_mappings(['clojerl.Var':type()], module() | clj_module()) ->
                      clj_module().

Adds mappings from a symbol to a value.

add_on_load(Expr, ModuleName)
-spec add_on_load(cerl:cerl(), module() | clj_module()) -> clj_module().

Adds an on_load expression to the module.

all_modules()
-spec all_modules() -> [cerl:c_module()].

Returns a list where each element is Core Erlang module.

ensure_loaded(Source, Name)
-spec ensure_loaded(binary(), module()) -> ok.

Makes sure the clj_module is loaded.

fake_fun(ModuleName, Function, Arity)
-spec fake_fun(module(), atom(), integer()) -> function().

Gets the named fake fun that corresponds to the mfa provided.

A fake fun is generated during compile-time and it provides the same functionality as its original. The only difference is that all calls to functions in the same module are replaced by a call to clj_module:fake_fun/3.

This is necessary so that macro functions can be used without having to generate, compile and load the binary for the partial module each time a macro is found.

A fake module is generated for each fake fun because a previous attempt that used erl_eval to generate and execute the fake_fun was too slow.

get_functions(ModuleName)
-spec get_functions(module() | clj_module()) ->
                       [{function_id(), {cerl:c_fname(), cerl:c_fun()}}].

Returns all functions in the module.

get_module(ModuleName)
-spec get_module(atom()) -> cerl:c_module().

Returns the Core Erlang module named ModuleName.

in_context()
-spec in_context() -> boolean().

Checks whether we are in a clj_module context.

is_clojure(Name)
-spec is_clojure(module()) -> boolean().

Checks if the Name module is a Clojerl module.

is_loaded(Name)
-spec is_loaded(module()) -> boolean().

Checks if the Clojelr module Name is loaded.

is_protocol(Name)
-spec is_protocol(module() | cerl:c_module()) -> boolean().

Checks if the Name module is a Clojerl protocol.

maybe_ensure_loaded(Name)
-spec maybe_ensure_loaded(module()) -> ok.

Ensures a module is loaded when in a compiling context

This is used from in-ns so that namespaces without any vars definition still get registered when compiling.

remove_all_functions(ModuleName)
-spec remove_all_functions(module() | clj_module()) -> clj_module().

Remove all functions in the module.

with_context(Fun)
-spec with_context(fun()) -> ok.

Runs the function in a clj_module context.

This is used by clj_compiler when evaluating or compiling an expression. It should be used in conjuntion with in_context/0 when you need to find out if there is a clj_module being processed.