Reference

FunctionImplementations.AbstractArrayImplementationStyleType

FunctionImplementations.AbstractArrayImplementationStyle <: ImplementationStyle is the abstract supertype for any style associated with an AbstractArray type.

Note that if two or more AbstractArrayImplementationStyle subtypes conflict, the resulting style will fall back to that of Arrays. If this is undesirable, you may need to define binary ImplementationStyle rules to control the output type.

See also FunctionImplementations.DefaultArrayImplementationStyle.

source
FunctionImplementations.ImplementationType

FunctionImplementations.Implementation(f, s) wraps a function f with a style s. This can be used to create function implementations that behave differently based on the style of their arguments.

source
FunctionImplementations.ImplementationStyleType

ImplementationStyle is an abstract type and trait-function used to determine behavior of objects. ImplementationStyle(typeof(x)) returns the style associated with x. To customize the behavior of a type, one can declare a style by defining a type/method pair

struct MyContainerImplementationStyle <: ImplementationStyle end
FunctionImplementations.ImplementationStyle(::Type{<:MyContainer}) = MyContainerImplementationStyle()
source
FunctionImplementations.ImplementationStyleMethod
ImplementationStyle(::ImplementationStyle1, ::ImplementationStyle2) = ImplementationStyle3()

Indicate how to resolve different ImplementationStyles. For example,

ImplementationStyle(::Primary, ::Secondary) = Primary()

would indicate that style Primary has precedence over Secondary. You do not have to (and generally should not) define both argument orders. The result does not have to be one of the input arguments, it could be a third type.

source
FunctionImplementations.permuteddimsMethod
permuteddims(a::AbstractArray, perm)

Lazy version of permutedims. Defaults to constructing a Base.PermutedDimsArray but can be customized to output a different type of array.

source
FunctionImplementations.result_styleFunction
result_style(s1::ImplementationStyle[, s2::ImplementationStyle])::ImplementationStyle

Takes one or two ImplementationStyles and combines them using ImplementationStyle to determine a common ImplementationStyle.

Examples

julia> FunctionImplementations.result_style(
           FunctionImplementations.DefaultArrayImplementationStyle(),
           FunctionImplementations.DefaultArrayImplementationStyle()
       )
FunctionImplementations.DefaultArrayImplementationStyle()

julia> FunctionImplementations.result_style(
           FunctionImplementations.UnknownImplementationStyle(),
           FunctionImplementations.DefaultArrayImplementationStyle()
       )
FunctionImplementations.DefaultArrayImplementationStyle()
source
FunctionImplementations.styleFunction
style(cs...)::ImplementationStyle

Decides which ImplementationStyle to use for any number of value arguments. Uses ImplementationStyle to get the style for each argument, and uses result_style to combine styles.

Examples

julia> FunctionImplementations.style([1], [1 2; 3 4])
FunctionImplementations.DefaultArrayImplementationStyle()
source
FunctionImplementations.ConcatenateModule
module Concatenate

Alternative implementation for Base.cat through Concatenate.cat(!).

This is mostly a copy of the Base implementation, with the main difference being that the destination is chosen based on all inputs instead of just the first.

Additionally, we have an intermediate representation in terms of a Concatenated object, reminiscent of how Broadcast works.

The various entry points for specializing behavior are:

  • Destination selection can be achieved through:
Base.similar(concat::Concatenated{Style}, ::Type{T}, axes) where {Style}
  • Custom implementations:
Base.copy(concat::Concatenated{Style}) # custom implementation of cat
Base.copyto!(dest, concat::Concatenated{Style}) # custom implementation of cat! based on style
Base.copyto!(dest, concat::Concatenated{Nothing}) # custom implementation of cat! based on typeof(dest)
source