Reference
Contents
Index
Core.TypeModuleMixins.Procedural.CompositeModuleMixins.Procedural.RoleMapModuleMixins.Common.eval_to_expressionModuleMixins.Common.eval_to_expressionModuleMixins.Common.nameModuleMixins.Common.strip_syntax_versionModuleMixins.Common.to_expressionModuleMixins.Passes.passModuleMixins.Passes.passModuleMixins.Passes.walkModuleMixins.Procedural.closureModuleMixins.Procedural.componentModuleMixins.Procedural.default_implementationModuleMixins.Procedural.implementsModuleMixins.Procedural.map_componentsModuleMixins.Procedural.record_partModuleMixins.Procedural.record_typeModuleMixins.Procedural.requiresModuleMixins.Procedural.resolveModuleMixins.Procedural.type_parameter_namesModuleMixins.Syntactic.check_declarationModuleMixins.Syntactic.declarationModuleMixins.Syntactic.field_typesModuleMixins.Syntactic.map_structModuleMixins.Syntactic.mentionedModuleMixins.Syntactic.parameterizeModuleMixins.Syntactic.struct_nameModuleMixins.substitute_top_levelModuleMixins.@composeModuleMixins.@for_eachModuleMixins.Spec.@specModuleMixins.Syntactic.@componentModuleMixins.Syntactic.@implementsModuleMixins.Syntactic.@mixinModuleMixins.Syntactic.@requires
ModuleMixins.substitute_top_level — Method
substitute_top_level(var, val, mod, expr)Takes a syntax object expr and substitutes every occurence of module var for val, only if the resulting object is actually present in module mod. The mod module should correspond with a lookup of val in the caller's namespace.
ModuleMixins.@compose — Macro
@compose module Name
[@mixin Parents, ...]
...
endCreates a new composable module Name. Structs inside this module are merged with those of the same name in Parents.
ModuleMixins.@for_each — Macro
@for_each(M -> M.method(), lst::Vector{Symbol})Calls method() for each module in lst that actually implements that method. Here lst should be a vector of symbols that are all in the current module's namespace.
ModuleMixins.Passes.pass — Method
pass(x::CompositePass, expr)Tries all passes in a composite pass in order, and returns with the first that succeeds (i.e. doesn't return no_match). You may create a CompositePass by adding passes with the + operator.
ModuleMixins.Passes.pass — Method
pass(x::Pass, expr)Interface. An implementation of the pass function should take a Pass object and an expression (or symbol), and return no_match if the expression did not match the pattern.
You can use the given Pass object to store information about this pass, return syntax that should replace the current expression, or nothing if it should be removed.
ModuleMixins.Passes.walk — Method
walk(x::Pass, expr_list)Calls MacroTools.prewalk with the given Pass. If no_match is returned, the expression stays untouched.
ModuleMixins.Spec.@spec — Macro
@spec module *name*
*body*...
endCreate a spec. The @spec macro itself doesn't perform any operations other than creating a module and storing its own AST as const *name*.AST.
This macro is only here for teaching purposes.
ModuleMixins.Common.eval_to_expression — Method
eval_to_expression(mod::Module, obj)Generic function for converting syntax data objects to expressions, where parts of expressions need to be evaluated in a given module.
Defaults to calling to_expression, dropping the mod argument.
ModuleMixins.Common.eval_to_expression — Method
eval_to_expression(mod::Module)Currying version of eval_to_expression.
ModuleMixins.Common.name — Method
Get name attribute from syntax data object.
ModuleMixins.Common.strip_syntax_version — Method
strip_syntax_version(expr)From Julia 1.14, a module expression may carry the syntax version of the code it was parsed from as its first argument: Expr(:module, v"1.14.0", true, name, body). Whether it does depends on the project the code lives in, not on the Julia version alone. Remove the version, so that @capture patterns of the form module name_ body__ end match either way.
ModuleMixins.Common.to_expression — Function
Generic function for converting syntax data objects to expressions.
ModuleMixins.Procedural.Composite — Type
Composite{T <: Tuple, R <: Tuple}A value composed of parts, one per component. Properties are forwarded to the part that has a field of that name, so c.x works for any field x of any part. R is a tuple of RoleMap markers, recording which part fills each role.
ModuleMixins.Procedural.RoleMap — Type
RoleMap{R, i}Marker type: role R is filled by part i of a composite.
ModuleMixins.Procedural.closure — Method
closure(roots::Module...)Compute all components needed by roots, in dependency order (dependencies first), each component appearing once. Roles are resolved to a component implementing them: one of the roots if any, otherwise default_implementation.
ModuleMixins.Procedural.component — Method
component(c::Composite, ::Val{M})
component(c::Composite, M::Module)
component(c::Composite, T::Type)The part of c contributed by component M, the part of type T, or, if T is a role (an abstract type), the part contributed by the component that implements T. Pass a module as Val(M) for a type-stable lookup.
ModuleMixins.Procedural.default_implementation — Method
default_implementation(R::Type)The component (module) used to fill role R if no component implementing R is selected explicitly.
ModuleMixins.Procedural.implements — Method
implements(::Val{M}, R::Type)Whether component M fills role R. Defaults to false.
ModuleMixins.Procedural.map_components — Method
map_components(f, c::Composite)Apply f to every part of c and compose the results that aren't nothing.
ModuleMixins.Procedural.record_part — Method
record_part(M::Module, name::Symbol)The part that component M contributes to record name: the type M.name if M defines it, otherwise nothing.
ModuleMixins.Procedural.record_type — Method
record_type(name::Symbol, roots::Module...)The Composite type of record name, for the closure of roots. It has one part for every component that defines a type name, in dependency order.
ModuleMixins.Procedural.requires — Method
requires(::Val{M})The components (modules) or roles (abstract types) that component M depends on. Extend this for every component that has dependencies.
ModuleMixins.Procedural.resolve — Method
resolve(R, roots)The component that fills requirement R. A module is a component and resolves to itself. A role resolves to the one component in roots that implements it, or else to its default_implementation.
ModuleMixins.Procedural.type_parameter_names — Method
type_parameter_names(T)The names of the type parameters of a UnionAll type, in order.
ModuleMixins.Syntactic.check_declaration — Method
check_declaration(x, valid, declaration, name)Check that x, named name in declaration, is an instance of valid.
ModuleMixins.Syntactic.declaration — Method
declaration(expr)If expr is one of the declarations @mixin, @requires or @implements, return the declaration name and its arguments. Otherwise return nothing. Arguments may be separated by spaces or by commas.
ModuleMixins.Syntactic.field_types — Method
field_types(struct_expr)The declared types of the fields of a struct.
ModuleMixins.Syntactic.map_struct — Method
map_struct(f, expr)Apply f to the struct definition in expr, looking through macro calls like @kwdef and docstrings. Returns expr unchanged if it doesn't define a struct.
ModuleMixins.Syntactic.mentioned — Method
mentioned(names, expr)The elements of names that occur as a symbol anywhere in expr, in the order of names.
ModuleMixins.Syntactic.parameterize — Method
parameterize(expr, struct_names)Rewrite the struct defined in expr (if any), so that every other struct in struct_names that is mentioned in a field type becomes a type parameter.
ModuleMixins.Syntactic.struct_name — Method
struct_name(expr)The name of the struct defined by expr, or nothing.
ModuleMixins.Syntactic.@component — Macro
@component module Name
[@mixin Components...]
[@requires Requirements...]
[@implements Roles...]
...
endDefine a component module. The declarations expand into methods of ModuleMixins.Procedural:
@mixin A, B: importAandBfrom the parent module (if they are plain names), and require them as components.@requires R: require role or componentR.@implements R: the component implements roleR.
If a field type of a struct mentions another struct S of the same module, the struct gets a type parameter S, which record_type fills with the composite of all parts of record S.
ModuleMixins.Syntactic.@implements — Macro
@implements Roles...Declaration inside a @component module. See @component.
ModuleMixins.Syntactic.@mixin — Macro
@mixin Components...Declaration inside a @component module. See @component.
ModuleMixins.Syntactic.@requires — Macro
@requires Requirements...Declaration inside a @component module. See @component.