You can define an abstract type CC that is a super type of C, and define a
fallback + operator for it that converts C to A. If an operator + for C is
defined, it will be used instead of the CC operator +.

-erik

On Saturday, February 27, 2016, Julia Tylors <[email protected]> wrote:
> Hi, I have a problem i need an implicit call, I wonder whether there is a
way to do what i have in mind.
>
> +(x::A,y::A) = C(x,y)
> implicit_match(c::C) = #returns type A,
> function foo(x::A,Y::A)
>    (x+y) + (x+y)
> end
>
>
> As you may see in the function foo, once (x+y) is executed, it returns an
instance of type C.
> now second operation becomes in type C+C , but there is no function like
+(c1::C, c2::C),  but i have a match function (implicit_match) which can
return an instance of A by looking at the input instance of type C
> I want this implicit function to be executed once +(::C,::C) is not
found.
> Can we do something like this?
> I don't like to define +(::C,::C) or generate +(::C,::C) using a macro.
> Thanks

-- 
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/

Reply via email to