Why does Julia restrict dependent types to integers (or tuples thereof)?

julia> type Foo{a} end

julia> Foo{3}()
Foo{3}()                                                                   
     
                                                                            
    
julia> Foo{"hello"}()                                                       
   
ERROR: type: apply_type: in Foo, expected Type{T<:Top}, got ASCIIString  

julia> Foo{(1,2)}()
Foo{(1,2)}()

When I write code for rings over the integers, modulo N, I can stick N in 
the type.  It's great, because you don't want to mix your fields, so the 
type keeps things separate, and you don't need extra storage space, 
repeating N for each instance.

But when I want to do the equivalent for factor rings of polynomials (where 
a polynomial is the equivalent of N above) then, suddenly, I cannot.  I 
cannot replace N above with a polynomial, because the type system won't 
allow it (afaict).  Yet the same arguments apply - I don't want to mix 
factor rings (different polynomials give different types) and I don't want 
to repeat the factor in each instance - it's just wasting storage space.

What is the reason for this (apparently arbitrary) restriction?  I think I 
can work round it by encoding the polynomial as a tuple of integers, but 
it's going to be painful, and likely inefficient.

And sorry I am asking multiple questions today.  I feel like I am sitting 
here complaining about everything just because I am ignorant...

Andrew

PS How does the logic of the error above work?  How are integers types?  Is 
it special cased in the compiler?

Reply via email to