With the latest master I still get "ERROR: syntax: malformed type parameter 
list".

Possibly I was not clear (I was actually going to clarify, but I 
accidentally hit 'post' prematurely...). Note that the second type 
parameter is `n::Integer` rather than `n<:Integer`, in other words, I want 
specify that the `n` parameter must be a value rather than a type, so that 
`FixedArray{Int,3}` allowed, but not `FixedArray{Int,Int}`

An application of this might be to allow dispatch on the contents of a 
Val{T}. A trivial example to illustrate the idea:

function f{T::Int}(::Type{Val{T}})
    -T
end


function f{T::Bool}(::Type{Val{T}})
    !T
end

So that f(Val{1}) and f(Val{true}) call different methods. Currently you 
can use a @generated function to check the type T, but then you could not 
later add methods to f that handle values of T with types other than Int 
and Bool.

Tom

On Wednesday, 30 September 2015 11:48:58 UTC+10, Tim Holy wrote:
>
> Yes, the syntax you proposed already works. Try it out. 
>
> --Tim 
>
> On Tuesday, September 29, 2015 06:42:36 PM Tom Lee wrote: 
> > Is there any way to restrict a type parameter to a particular bitstype, 
> or 
> > is this planned in the next type design iteration? eg: 
> > 
> > type FixedVector{T<:Number, n::Integer} 
> > data::NTuple{n,T} 
> > end 
> > 
> > 
> > You can achieve this by adding checks in the constructor, but doing so 
> > always makes things so untidy. 
>
>

Reply via email to