If you replace call-next-method() with invoke(bar,(Fu,),f) then it does what you want. The situation in Julia is a bit more complicated since you don't know which argument(s) you want to push further up the type lattice. The invoke function works by letting you specify exactly which less specific type signature you would like to invoke the function with.
On Wed, Jul 16, 2014 at 9:03 PM, Markus Roberts <[email protected]> wrote: > Most multimethod systems seem to have a way to call the next-most-general > method of a function, but I'm not seeing a good way to do that in Julia. > This is complicated by the fact that my sense of what's idiomatically > clean in Julia isn't very well honed yet. If Julia had CLOS's > call-next-method I could get the results I'm looking for by writing > something like: > abstract Fu > > function bar(f::Fu) > print("Bar\n") > end > > type Foo <: Fu > end > > function bar(f::Foo) > print("Oooo...\n") > call-next-method() # <-- CLOS, not Julia > end > > bar(Foo()) > > ....(which I would expect to emit "Oooo...Bar\n"). Similar results can be > obtained in other languages with "super", "inherited", etc. or by casting > the appropriate argument to the (in Julia, abstract) parent type. > > My question: what's the "right" way to do this in Julia? > > -- MarkusQ > > P.S. An around-method analogue would work too, though it doesn't feel as > semantically appropriate. > >
