Hi Rory,
good to see that you're looking into this too!
If I understand correctly, your implementation is semantically
equivalent to single-parameter traits, right? Single-parameter traits
(i.e. only dependent on one type) probably cover about 90% of the use
cases but not all, for instance comparison or binary mathematical
operations are multi-parameter. I think, if interfaces/traits make it
into Base, they should be multi-parameter as single-parameter would be
at odds with multiple dispatch.
If I remember our conversation correctly, one of your main qualms with
Traits.jl are the trait-functions and their confusing syntax. Currently
they look like:
@traitfn f{X; Iterable{X}}(x::X) = ...
@traitfn g{X, Y; Eq{X,Y}}(x::X, y::Y) = ...
If traits make in into Base and *if* subtyping is removed, then (I
think) above could use the following syntax:
f(x::Iterable) = ...
g{Eq{X,Y}}(x::X, y::Y) = ...
So, the simpler syntax, as used in Interfaces.jl, could probably be used
for single-parameter traits. The `;` in the `{}` (separating types and
traits) could probably be removed. Although I haven't thought this
through yet, in particular how this meshes with diagonal and triangular
dispatch syntax.
A few more comments:
- You use some kind of mutable Unions. However, Unions in Julia are
immutable, I suspect for a reason. I don't know whether that could
lead to problems, maybe someone more knowledgeable can comment on
this?
- With your syntax, it is not clear from the the function signature
whether it's a type assertion or an interface assertion. But maybe it
doesn't need to be clear. Also a naming-convention could help, I
thought that traits could all start with Is* or Has*, like IsCallable
or HasLength.
- I think there is potential to share code between Interfaces.jl and
Traits.jl. In particular for the interface verification, where
methods signatures are compared. If you're interested I could try and
factor this out.
Mauro
On Tue, 2015-07-07 at 22:23, Rory Finnegan <
rory.f...@gmail.com> wrote:
> I'll just mention Interfaces.jl
> <
https://github.com/Rory-Finnegan/Interfaces.jl> as an alternative to