Re: [julia-users] Multiple levels of parametric

2014-02-16 Thread Stefan Karpinski
On Sun, Feb 16, 2014 at 5:56 PM, Fil Mackay wrote: > Out of interest is there a dispatch beyond triangular, or does this cover > all meta-triangle structures? There are always more levels of dispatch. With meta object protocols (which CLOS supports), you can use arbitrary, predicates for dispatc

Re: [julia-users] Multiple levels of parametric

2014-02-16 Thread Fil Mackay
On Monday, February 17, 2014 10:10:14 AM UTC+11, Jameson wrote: > > In general, you don't want to dispatch Enums on their type -- that's > what abstract types are for -- see my enum pull request for more > Yep - from earlier post Enum{} is abstract: abstract Enum{INT<:Integer} > discussion.

Re: [julia-users] Multiple levels of parametric

2014-02-16 Thread Fil Mackay
> > abstract Enum{INT<:Integer} > convert{T<:Enum{INT},INT<:Integer}(::Type{INT}, x::T) # INT not defined > Answering my nooby question, this can be done as: Base.convert{INT<:Integer}(::Type{INT}, x::Enum{INT}) # works fine But this one still presents an issue with no such solution: Base.<{IN

Re: [julia-users] Multiple levels of parametric

2014-02-16 Thread Jameson Nash
In general, you don't want to dispatch Enums on their type -- that's what abstract types are for -- see my enum pull request for more discussion. So, I'm not sure why you want this, but I'll give it a shot. abstract Enum{INT<:Integer} convert{T<:Enum, I<:Integer}(::Type{I}, x::T) = eltype(x) === I

Re: [julia-users] Multiple levels of parametric

2014-02-16 Thread Fil Mackay
On Sunday, February 16, 2014 3:59:36 AM UTC+11, Stefan Karpinski wrote: > > On Feb 15, 2014, at 7:10 AM, Fil Mackay > > > wrote: > > @Stefan I found > thiswhich > was really helpful. Never heard of diagonal dispatch before.

Re: [julia-users] Multiple levels of parametric

2014-02-15 Thread Stefan Karpinski
On Feb 15, 2014, at 7:10 AM, Fil Mackay wrote: > > @Stefan I found this which was really helpful. Never heard of diagonal > dispatch before. You wouldn't have since we made it up. This is new territory in dispatch here. > Or triangular dispatch. Out of interest is that something on the horizon

Re: [julia-users] Multiple levels of parametric

2014-02-15 Thread Fil Mackay
@Stefan I found thiswhich was really helpful. Never heard of diagonal dispatch before. Or triangular dispatch. Out of interest is that something on the horizon or more immediate consideration? Conclusion: yes I'm too greedy

Re: [julia-users] Multiple levels of parametric

2014-02-15 Thread Fil Mackay
On Saturday, February 15, 2014 3:35:19 PM UTC+11, Keno Fischer wrote: > > Is dictionary an abstract type in that example though? > No, but it could be by using "IDictionary", and would work.. > test{TI<:Integer}(a::TI, x::Dict{String, TI}) > > would work just fine. > Yes true I had simplifie

Re: [julia-users] Multiple levels of parametric

2014-02-14 Thread Keno Fischer
Is dictionary an abstract type in that example though? test{TI<:Integer}(a::TI, x::Dict{String, TI}) would work just fine. On Fri, Feb 14, 2014 at 11:30 PM, Fil Mackay wrote: > On Sat, Feb 15, 2014 at 4:13 AM, Stefan Karpinski wrote: > >> On Fri, Feb 14, 2014 at 7:58 AM, Fil Mackay >> wrote:

Re: [julia-users] Multiple levels of parametric

2014-02-14 Thread Fil Mackay
On Sat, Feb 15, 2014 at 4:13 AM, Stefan Karpinski wrote: > On Fri, Feb 14, 2014 at 7:58 AM, Fil Mackay wrote: > >> How can I do this? Surely parametric parameters can build on one >> another..? > > > Not in method dispatch, at least not yet. I'm not sure how you can be > shocked by this. There's a

Re: [julia-users] Multiple levels of parametric

2014-02-14 Thread Stefan Karpinski
On Fri, Feb 14, 2014 at 7:58 AM, Fil Mackay wrote: > How can I do this? Surely parametric parameters can build on one another..? Not in method dispatch, at least not yet. I'm not sure how you can be shocked by this. There's a tower of dispatch power: (a) single dispatch (b) multiple dis

Re: [julia-users] Multiple levels of parametric

2014-02-14 Thread Tim Holy
Treated in the last part of this section of the FAQ: http://docs.julialang.org/en/latest/manual/faq/#how-should-i-declare-abstract- container-type-fields See also https://github.com/JuliaLang/julia/issues/3766 --Tim On Friday, February 14, 2014 04:58:34 AM Fil Mackay wrote: > I'm trying to use 2

Re: [julia-users] Multiple levels of parametric

2014-02-14 Thread Milan Bouchet-Valat
Le vendredi 14 février 2014 à 04:58 -0800, Fil Mackay a écrit : > I'm trying to use 2 levels of parametric: one on an abstract type and > another in a function. This is to ensure that a parameter 'x' passed > is consistent with an Dict passed in as well: > > > > abstract Test{TI<:Integer} > >

[julia-users] Multiple levels of parametric

2014-02-14 Thread Fil Mackay
I'm trying to use 2 levels of parametric: one on an abstract type and another in a function. This is to ensure that a parameter 'x' passed is consistent with an Dict passed in as well: abstract Test{TI<:Integer} function test{TI<:Integer,T<:Associative{Symbol,TI}}(a::T, x::TI) end # ERROR: TI n