InterfaceFunctions

Documentation for InterfaceFunctions.

InterfaceFunctions.@interfaceMacro
@interface fn_expr

Define an interface function for the abstract type in the first argument of the function signature in fn_expr.

It is common to define empty functions for interfaces

function fn(a::A, b::B) end

This macro creates the function and adds an informative error message to the user so that he knows what went wrong and how to fix it.

@inteface fn(a::A, b::B)

roughly translates to

function fn(a::A, b::B)
    throw(UnimplementedInterface{A}(#=signature=#))
end

An interface on an abstract type is a way to indicate that every subtype has to provide a custom method for this function. Interfaces are useful for code re-usability in higher order methods. Higher order methods of abstract types can use the interfaces defined on these types to provide implementations for their subtypes.

source