Is "Data" a reserved keyword in Julia?


#1

I traced a problem of my project down to the keyword “Data”. I did not see any declaration in the documents that “Data” is reserved. Here is an example:

# it works for "Data2" 
abstract type Data2 end;
typeof(Data2) 

# but it does not work for "Data
abstract type Data end;
typeof(Data) 

Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)

Error message is here:

MethodError: no method matching include_string(::Type{Data}, ::String, ::String, ::Int64)e[0m
Closest candidates are:
include_string(e[91m::Modulee[39m, ::Any...) at /Applications/JuliaPro-0.6.2.2.app/Contents/Resources/pkgs-0.6.2.2/v0.6/CodeTools/src/eval.jl:34
include_string(e[91m::Modulee[39m, ::String, ::String) at /Applications/JuliaPro-0.6.2.2.app/Contents/Resources/pkgs-0.6.2.2/v0.6/Compat/src/Compat.jl:71
include_string(e[91m::Modulee[39m, ::AbstractString, ::AbstractString) at /Applications/JuliaPro-0.6.2.2.app/Contents/Resources/pkgs-0.6.2.2/v0.6/Compat/src/Compat.jl:73
...

#2

No, Data is not a reserved or special word. Your minimal example works for me. There’s something else going on here.


#3

Thank you. You are right. It works in my Julia REPL, but not in JuliaPro. It might be caused by the JuliaPro. I should have tried it out in REPL first before positing. Thanks.


#4

It might be nice to setup a website at some point where people can post name collisions like this. I see a reserved word post once every couple months.

Rails has a pretty nice one here:


#5

It’s likely that you are seeing a conflict with DataStreams.jl which exports a module called Data.

Maybe this wasn’t the best move, as admittedly Data does seem like too general a name to use for much of anything, except possibly sentient androids, but it’s a core part of the Julia data ecosystem so I think that name is here to stay.


#6

Even still, the posted error is confusing — if that were the case it should show a

ERROR: cannot assign variable Data from module Main

or some such when trying to create the type.