33051

Arrays break string types in Julia

Is the following by design?

ASCIIString <: String returns true, but Array{ASCIIString,1} <: Array{String,1} returns false.

Perhaps this is a bug, and I should make a pull request on github. (I'm running v0.4.0-dev+6210)

Answer1:

just convert my comment into an answer:

the answer to your question is YES. As julia's document says:

in the parlance of type theory, Julia’s type parameters are invariant, rather than being covariant (or even contravariant).

in the misleading case below, one may find that

julia> Int64 <: Int true julia> Array{Int64,1} <: Array{Int,1} true

this is because Int and Int64 are the same type.

julia> xdump(Int) Int64::DataType <: Signed julia> xdump(Int64) Int64::DataType <: Signed julia> xdump(Array{Int,1}) Array{Int64,1}::DataType <: DenseArray{Int64,1} julia> xdump(Array{Int64,1}) Array{Int64,1}::DataType <: DenseArray{Int64,1}

we can use typejoin to checkout the relationship between type A and type B and their corresponding "arrays".

julia> typejoin(Int64,Int) Int64 julia> typejoin(Array{Int64,1},Array{Int,1}) Array{Int64,1}

but

julia> typejoin(ASCIIString,String) String julia> typejoin(Array{String,1},Array{ASCIIString,1}) Array{T,N} (constructor with 9 methods)

Recommend

  • Including .cpp at end of template header file
  • Office 365 Mail API: Admin access token to access everyone's emails
  • What is an instance of an NSObject
  • Backup of Data Lake Store
  • Julia v0.6 macro inside function
  • How to customise JIDE grids in Matlab
  • IJulia install - WARNING: Module BinDeps uuid did not match cache file
  • JavaFX apllication does not run with Selenium WebDriver
  • Gatttool non-interactive mode --char-write
  • how to build game playing neural network in Python?
  • npm thinks node is out of date, but it isn't
  • Are there algorithms for putting a digest into the file being digested?
  • How can I determine which routines MATLAB uses to solve a sparse matrix?
  • using html data-attributes as css-variable (i.e. text-shadow)
  • JSON encode and decode on PHP
  • Using Laravel 5.4 pusher
  • Enabling DTD support in Sql Server
  • perl, mysql - fasting way to upload a csv file into mysql?
  • Convert SQLite database to XML
  • converting text file into xml using php?
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • Conversion from string “a” to type 'Boolean' is not valid
  • Oledb connection string for excel files
  • Installing iPhone App to iPhone
  • Content-Length header not returned from Pylons response
  • Custom Tabgroup Appcelerator
  • $wpdb not working in file of WordPress plugin
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Counter field in MS Access, how to generate?
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Jquery - Jquery Wysiwyg return html as a string
  • WPF Applying a trigger on binding failure
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do I configure my settings file to work with unit tests?
  • Java static initializers and reflection
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Binding checkboxes to object values in AngularJs