Generally, you would define an abstract type that the user would
inherit. Inheriting from an abstract type is essentially a declaration
that the child class will provide definitions for some
functions/behavior

You would also define prototypes for any functions the user code is
expected to implement (c.f. Base.Graphics)

You can use a type union over abstract and concrete types to include
limit the applicable types of the function you are defining (zero!, in
your example), or just leave it completely up to duck-typing (as you
currently are doing in your example)

(switching to julia-users since this is mainly a question on how to
use the language, not a design proposal for consideration, and
julia-dev is basically a subset of julia-users anyways)


On Mon, Apr 7, 2014 at 8:30 PM, Mason McGill <[email protected]> wrote:
> To clarify, this is in julia-dev rather than julia-users because it doesn't
> seem there's a Julia analogue to features in other languages like
> interfaces, concepts, or duck typing that allow user code and library code
> to collaborate.  Was this a conscious design decision?  Is anything in the
> works to improve the state of generic library writing in Julia?  Is there a
> solution I don't know about?

Reply via email to