1
votes

Julia has a number of internal variables such as WORD_SIZE (indicates whether target system is 32- or 64-bit) and CPU_CORES (number of cpu cores presently available).

In the Julia REPL, is there some way to list all of these internal variables?

AFAIK, whos and names(Main) does not show them...

EDIT: From this previous question on listing exported function names, I see that names(Base) does show these internal variables, along with every other exported item in the Base module.

1
those variables are in a submodule of the Base, whos(Base.Sys) shows them.Gnimuc
Thanks! Put that as an answer, and I will mark that down as correct, @GnimucK.buruzaemon
That does not list all the variables for me, just a few of them. Not, say, JULIA_HOME, STDIN, ENV, etc.DNF
@DNF hm, yes, I see that now... so that means my question is still unanswered...buruzaemon

1 Answers

1
votes

as @DNF pointed in the comment above, whos(Base.Sys) won't print all the internal(constant) variables in Base. but we can search those variables directly from whos(Base) via:

julia> whos(Base, r"^\s*[A-Z_]+$")
                          ARGS      0 bytes  0-element Array{UTF8String,1}
                          BLAS    214 KB     Module
                     CPU_CORES      8 bytes  Int64
                        C_NULL      8 bytes  Ptr{Void}
                    ENDIAN_BOM      4 bytes  UInt32
                           ENV      0 bytes  Base.EnvHash with 29 entries
                          FFTW    149 KB     Module
                          HTML    168 bytes  DataType
                             I      8 bytes  UniformScaling{Int64}
                            IO     92 bytes  DataType
                    JULIA_HOME     66 bytes  ASCIIString
                        LAPACK    933 KB     Module
                     LOAD_PATH    190 bytes  2-element Array{ByteString,1}
                          MIME    148 bytes  DataType
                       OS_NAME      0 bytes  Symbol
                        STDERR    217 bytes  Base.TTY
                         STDIN     64 KB     Base.TTY
                        STDOUT    217 bytes  Base.TTY
                       VERSION     40 bytes  VersionNumber
                     WORD_SIZE      8 bytes  Int64

this lies in the fact that Julia's constants are UPPERCASE. you may find that some Modules are also in the list, but it's easy to identify. indeed, one can use a more complex regex to expel them.

note that, those variables which are not exported into Base will not shown out. e.g.

whos(Base.Libdl)