On Fri, 2014-02-07 at 17:48,
jeff.b...@gmail.com wrote:
> With all the magical things julia does, you have to pay the piper at
> some point :) Hence some things are difficult.
Well, you have to pay the piper by having to answer all these questions
of newbies coming up with "clever" ideas ;-)
> I believe the best we could do here is automatically copy all methods
> naming Array, replacing Array with MyArr. There are two separate
> issues: (1) type behavior: is MyArr a subtype of Array? (2) available
> methods: what methods exist for MyArr?
>
> For part (2) we can do absolutely anything. Part (1) is impossible; if
> isa(x,Array) is true then x must behave like an Array and nothing
> else.
I see, if the second argument to `isa` is a concrete type then x must be
exactly of that type. If that is a hard requirement then there is
indeed no way around.
As I wrote, I was only aware of one argument against allowing subtypes
of concrete types, which had to do with memory layout. (Which would
be fine in this case) But it looks like there are other reasons too.
> convert(super(ma), ma) is always a no-op. Anything of type X is
> already of type super(X). Instead for this we use `invoke`, which
> performs dispatch differently, which is what you really want here
> AFAICT.
Yes, I didn't know of `invoke`.
Cheers!