How to run Julia 0.4 Code with an ASCIIString substitute?

I'm testing out the Remez library in Julia and have hit a couple of snags. I would like to build the original ARM reference code written in Julia 0.4 whilst making as few changes as possible to it. But the user interface has totally defeated me since it uses ASCIIString in a way that I cannot seem to replicate or resolve by any sensible method.

I have looked at the threads on here and most (pre 2015) talk about ASCIIString as still existing. Then it went into LegacyStrings and now it is nowhere. I haven't found description of a suitable workaround and my knowledge of Julia is still very poor so I need some help please. The closest I could find here was this thread which is old enough that ARGS was of type ASCIIStrings. I found a suggestion elsewhere to try LegacyStrings but that didn't work either (same error message) :(

All I really want is some way to declare an array of empty strings so that the rest of the original ARM code can see its parameters from the command line how it expects. Annoyingly the Julia editor I'm using still thinks ASCIIString is a valid keyword :(

I tried declaring it String, AbstractString, Array, AbstractArray and various others but no joy. The compiler's helpful suggestion is clearly nonsensical. I am not seeing the wood for the trees here. I am a complete novice at Julia (about 2 weeks experience) so it may well be blindingly obvious what I should be doing here but I just can't see it!

argwords = Array(ASCIIString, 0)  ## this line fails to compile
for arg = ARGS
  if doing_opts && beginswith(arg, "-")
    if arg == "--"
        doing_opts = false
           error("unrecognised option: ", arg)
        push!(argwords, arg)   ## saves them for later access by main code
# compiler output Julia v1.9.3
# ERROR: LoadError: MethodError: no method matching Array(::Type{ASCIIString}, ::Int64)
# Closest candidates are:
# Array(::LinearAlgebra.UniformScaling, ::Integer, ::Integer)

It was ASCIIString originally. Then I tried LegacyStrings but that no longer offers a compatible way of using this type of declaration. Please can I have suggestions for a minimal changes work around to get this code to compile in v1.9.3 without errors?


  • It's the Array creation syntax that's changed here - looking up ?Array in the REPL, you can see:

    Array{T}(undef, dims)
    Array{T,N}(undef, dims)

    Construct an uninitialized N-dimensional Array containing elements of type T. [...] dims may be a tuple or a series of integer arguments corresponding to the lengths in each dimension.

    In your case, we want the type T to be String, and just one dimension of length (initially) 0, so we can write it as Array{String}(undef, 0).

    julia> Array{String}(undef, 0)

    That output shows you an easier way to write it though: just argwords = String[] creates the empty Array of Strings you want.