Le mercredi 18 novembre 2015 à 00:40 -0800, NotSoRecentConvert a écrit
:
> I have a simple function which takes a directory string and returns a
> list of files and directories which fit some other parameters. My
> problem is that I can't find a function definition which accepts both
> ASCIIString and UTF8String types. Previous to Julia 0.4 I just used
> String and everything worked well but the new AbstractString does not
> work. What can I do?
I think the problem is not with AbstractString, but with type
invariance. Basically, don't write
f(x::AbstractArray{AbstractString)) = ...
but
f{T<:AbstractString}(x::AbstractArray{T)) = ...
See
http://docs.julialang.org/en/release-0.4/manual/types/#parametric-compo
site-types
(you can also look for covariance and invariance in the archives)
Regards
> subtypes(AbstractString)
> Base.SubstitutionString{T<:AbstractString}
> DirectIndexString
> LaTeXStrings.LaTeXString
> RepString
> RevString{T<:AbstractString}
> RopeString
> SubString{T<:AbstractString}
> UTF16String
> UTF8String
>
> subtypes(DirectIndexString)
> ASCIIString
> UTF32String
>
> I probably would have never run into this problem if
> joinpath(ASCIIString,ASCIIString) didn't return UTF8String.
>
> Julia Version 0.4.1
> Commit cbe1bee (2015-11-08 10:33 UTC)
> Platform Info:
> System: Linux (x86_64-linux-gnu)
> CPU: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
> WORD_SIZE: 64
> BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY
> Haswell)
> LAPACK: liblapack.so.3
> LIBM: libopenlibm
> LLVM: libLLVM-3.3