Fail to import



all you of good will, will you help a newbie in the throes of early learning?

I have a little script

importall adiff
v0 = variate(1.)
v1 = variate([1.,2.,3.])

and a module file

module    adiff
importall Base,StaticArrays
export    Adiff,variate
immutable Adiff{nd}<: Real
    value     ::Float64
function variate(a::Vector{Float64})
    s = size(a)
    b = Addif{s}
    for i = 1:s
        b.value(i)        = a(i)
        b.derivative(:,i) = 0.
        b.derivative(i,i) = 1.
    return b
variate(a::Float64)  = Adiff{1}(a,Float64[1.])
function show(io::IO,a::Adiff)
  x  = a.value
  dx = a.derivative
end # module adiff

Executing the script, I get “variate not defined”, which puzzles me no end. I get similar things to work on other modules, what am I doing wrong here?

Thanks for your help


(JuliaPro 5.1.1 on Windows 7)

LoadError: UndefVarError: variate not defined
while loading C:\Users\philippem\home\GIT\julia\tests\test_adiff.jl, in expression starting on line 5
 in include_string(::String, ::String) at loading.jl:441
 in include_string(::Module, ::String, ::String) at eval.jl:32
 in (::Atom.##59#62{String,String})() at eval.jl:81
 in withpath(::Atom.##59#62{String,String}, ::String) at utils.jl:30
 in withpath(::Function, ::String) at eval.jl:46
 in macro expansion at eval.jl:79 [inlined]
 in (::Atom.##58#61{Dict{String,Any}})() at task.jl:60


Try using adiff instead of importall.



Thank you. But neither

using adiff
v0 = adiff.variate(...)


using adiff
v0 = variate(...)

work, same error message. The later option should not work if I have understood something.

I think what happens is: I have an error in my module, it fails to compile, and I get this “uninformative” error message…

I’ll keep rummaging in the code.


Addif instead of adiff in the second line of variate?

What happens if you run from the repl instead of atom? This should have thrown an error.

Modules should have initial capitals, eg call the module Adiffs.

If you use import instead of using, you must qualify names as Adiffs.Adiff.

Are you aware of the ForwardDiff.jl package?


OK progress.

So I had multiple bugs in adiff.jl, so that it did not compile, resulting in a failure to import. So yes, Julia error methods can be cryptic…

I am aware of the ForwardDiff package. I was actually active 1-2 years ago in developing some code for automatic differentiation and was on the Google group. I went back to Fortran (don’t tell me, I know), and my brain rebooted.

I come from oo programming, and I have a little pattern of “one type, one module” (some would say a class). That forces me to lowercase my module names to keep my types uppercase…