Hum, OK. Thanks Mauro.

On Thu, Sep 3, 2015 at 10:43 AM Mauro <[email protected]> wrote:

> The short answer is: no.  There is an issue on github, I think.  Or at
> least an issue in which this was discussed.  If I remember correctly it
> is a desired feature but with no time plan for an implementation.
>
> On Thu, 2015-09-03 at 11:38, Cristóvão Duarte Sousa <[email protected]>
> wrote:
> > (This was already asked in Julia Gitter, but I'm switching to the mailing
> > list as this may better fit here than in a chat.)
> >
> > """
> > Is it possible to constraint the type of a bits type parameter? Something
> > like f{N::Int}(x::SomeParamType{N}) where for N::Int I want to mean that
> N
> > is an instance of Int, i.e., 1, 2, -10, 0, etc., and not that it is the
> > DataType Int.
> > """
> >
> > Let me put it in another words:
> >
> > To have parametric types to be restricted on the parameters they accept
> is
> > just a matter of defining constructors in the right way. For example,
> > although Array{Any, 1.5} is a valid type per se, one cannot create an
> > instance of it.
> >
> > Now imagine I have a type X{T} where it is possible that T is anything
> >  (there are constructors), a DataType or as bits type instance.
> > I can create methods which dispatch when T is an Integer subtype:
> > f{T<:Integer}(x::X{T}) = "Integer subtype"
> > I can create methods which dispatch when T is a specific Integer subtype:
> > f(x::X{Int}) = "Int"
> > I can create methods which dispatch when T is a specific Int instance:
> > f(x::X{4}) = "4"
> >
> > I wonder if it is possible to define a method which will dispatch on any
> > Int instance (be it 1, 2, 0, -10), something like:
> > f{N::Int}(x::X{N}) = "N"
> > so that
> > f(X{Int8}()) returns "Integer subtype",
> > f(X{Int}()) returns "Int",
> > f(X{4}()) returns "4", and
> > f(X{3}()) returns "N" ...
> >
> > This was probably asked and replied somewhere else, but I couldn't find
> it.
> >
> > Thanks,
> > Cheers,
> > Cristóvão
>
>

Reply via email to