Yes, it's definitely a special case of such a trait system. I had heard some mentions of bringing in traits but was not aware of the details at all.
Looking at Mauro's code, it seems it would be somewhat unwieldy to use in this case, since if I'm not mistaken, one would have to specify manually that 'ASCIIString' satisfies the 'ASCIIString trait'. It also didn't appear that you can automatically base traits on type parameters. On Thursday, September 17, 2015 at 2:27:50 PM UTC-4, Tom Breloff wrote: > > I think what you're looking for are traits. There's discussion about > making them part of the core language eventually, but in the meantime, > check out https://github.com/mauro3/Traits.jl > > On Thu, Sep 17, 2015 at 2:16 PM, Josh Langsfeld <[email protected] > <javascript:>> wrote: > >> Essentially, it would really cool to be able to do something like 'type >> SubString{T<: AbstractString} <:T ...' for dispatch purposes. >> 'SubString{ASCIIString} <: ASCIIString' would still return false in general. >> >> On Thursday, September 17, 2015 at 1:47:24 PM UTC-4, Josh Langsfeld wrote: >>> >>> I recently was stumped when I wanted to write a function that dispatched >>> on 'ASCIIString' versus 'UTF8String' but then had to deal with a >>> 'SubString{ASCIIString}'. It made me think that given Julia's prolific use >>> of wrapper types, it would be very nice to be able to dispatch on a type T >>> and also any wrapper with a single type parameter of T that acts just like >>> a regular T. >>> >>> As far as I'm aware, that's only possible with a UnionType, but that's >>> quite cumbersome to code, especially if you don't know the names of all the >>> wrappers you might see beforehand. Any thoughts on the feasibility of >>> something like this? >>> >> >
