# Fail to import

**URL:** https://discourse.julialang.org/t/fail-to-import/4538
**Category:** New to Julia
**Created:** [June 29, 2017, 9:19am UTC](https://discourse.julialang.org/t/fail-to-import/4538 "2017-06-29T09:19:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Philippe\_Maincon](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@Philippe\_Maincon](https://discourse.julialang.org/u/Philippe_Maincon)
#### Post date: [June 29, 2017, 9:19am UTC](https://discourse.julialang.org/t/fail-to-import/4538/1 "2017-06-29T09:19:31Z")

</div>

Hi,

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

I have a little script

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

```

and a module file

```julia
module adiff
importall Base,StaticArrays
export Adiff,variate
immutable Adiff{nd}<: Real
    value ::Float64
    derivative::Svector{nd}
end
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.
    end
    return b
end
variate(a::Float64) = Adiff{1}(a,Float64[1.])
function show(io::IO,a::Adiff)
  x = a.value
  dx = a.derivative
  print(io,"Adiff(x=$x,dx=$dx)")
end
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

Philippe

(JuliaPro 5.1.1 on Windows 7)

```julia
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

```

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [June 29, 2017, 9:48am UTC](https://discourse.julialang.org/t/fail-to-import/4538/2 "2017-06-29T09:48:48Z")

</div>

Try using adiff instead of importall.

---

<div class="post-metadata">

### Author: ![Philippe\_Maincon](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@Philippe\_Maincon](https://discourse.julialang.org/u/Philippe_Maincon)
#### Post date: [June 29, 2017, 10:14am UTC](https://discourse.julialang.org/t/fail-to-import/4538/3 "2017-06-29T10:14:49Z")

</div>

Hi,

Thank you. But neither

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

```

nor

```julia
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.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [June 29, 2017, 10:29am UTC](https://discourse.julialang.org/t/fail-to-import/4538/4 "2017-06-29T10:29:19Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Philippe\_Maincon](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@Philippe\_Maincon](https://discourse.julialang.org/u/Philippe_Maincon)
#### Post date: [June 29, 2017, 11:14am UTC](https://discourse.julialang.org/t/fail-to-import/4538/5 "2017-06-29T11:14:13Z")

</div>

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…

Thanks!
