> On 7 Jul 2015, at 13:13, Milan Bouchet-Valat <[email protected]> wrote:
> I think another solution could work, but I'm not sure it's really
> better. Instead of checking whether
> method_defined(f,(Vararg{SEXPREC},))
> you could always define a fallback wrapper function like this:
> function f(x::AbstractSEXPREC...)
>     y = rcopy(x...) # do default conversions
>     f(y...)
> end
> 
> AbstractSEXPREC would just be an abstract type from which SEXPREC would
> inherit, so that the fallback would not be called when a more specific
> f(x::SEXPREC...) method exists.
> 
> Then, you would call f() on the VarArgs{SEXPREC}, and Julia would take
> care of calling either the user-defined function or your fallback,
> based on the standard dispatching rules.

Sorry, I should have said: SEXPREC is the abstract type (the subtypes are 
VecSxp, RealSxp, IntSxp, etc.), so this is essentially what I’m doing. However 
I wanted it so that the fallback wrapper is defined automatically the first 
time the method is used in this manner.

Reply via email to