Interactive development

question

#1

When redefining a subfunction I always have to go back and redefine the top level function since otherwise it continues to use the old definition of the subfunction. Is there a way around this? I have played with @noinline and starting julia with --optimise=0 but it doesn’t seem to help. The REPL session below illustrates what I am talking about.

julia> a()=b()
a (generic function with 1 method)

julia> b()=1
b (generic function with 1 method)

julia> a()
1

julia> b()=2
WARNING: Method definition b() in module Main at REPL[2]:1 overwritten at REPL[4]:1.
b (generic function with 1 method)

julia> a()
1

FAQ subcategory
#2

What you are seeing is #265 in action. From what I now this is slated to be fixed in Julia v0.6, but until then there is no good workaround.


#3

Ah thanks. Do you know if the idea of an interpreted mode (rather than JIT) has ever been explored?


#4

There is an interpreter already, but it is relatively slow, and doesn’t yet support all intrinsics (see https://github.com/JuliaLang/julia/pull/18754).


#5

Note that interpreting code is not related to fixing #265 at all.


#6

Relevant FAQ entry here (mostly second half).


#7

In IJulia, I use this macro:

macro autorun(expr)
    esc(:(begin
        $IJulia.push_preexecute_hook(()->@eval($expr))
        $expr
        nothing
        end))
end

@autorun a()=b()
@autorun b()=1

a()    # 1

@autorun b()=2

a()    # 2

It’s a hack, but it works.