Hacker News new | ask | show | jobs
by thisrod 1684 days ago
This is an interesting point. Julia might well benefit from

    Base.not_understood(f, x::Apple_Count, y::Apple_Count) =
        f(int(x), int(y)) |> AppleCount
with semantics borrowed from Smalltalk. I'm a bit rusty with Julia, please forgive any syntax errors.

I wonder how hard it would be to hack the compiler, catch method not found exceptions, and do that? It wouldn't be fast, but it would work as a proof of concept.

Edit: the semantics I have in mind go like this. If you call f(x, y), where x and y are Apple_Count, but there is no method defined for f(::Apple_Count, ::Apple_Count), then the compiler tries not_understood(f, x, y).