Revise.jl 可以处理`ERROR: LoadError: invalid redefinition of Constant`吗?

问题描述 投票:0回答:1

我尝试使用 Revise.jl

 解决
这篇文章中描述的问题。我的初始代码是(存储为
tmp_SE.jl
):

struct Person
    name::String
    male::Bool
    age::Float64
    children::Int
    # eyes::String
  end

function describe(p::Person)
    println("Name: ", p.name, "Male: ", p.male)
    println("Age: ", p.age, "Children: ", p.children)
end

我启动 Julia REPL 并执行以下序列:

using Revise
include("tmp_SE.jl")
ted=Person("Ted", 1, 55, 0)
describe(ted)

工作正常。

然后我输入

edit("tmp_SE.jl")

这将打开编辑器,在其中我取消注释结构中的最后一行。如果我接着尝试

include("tmp_SE.jl")

我明白了

ERROR: LoadError: invalid redefinition of constant Person
, 而尝试简单直接

ted=Person("Ted", 1, 55, 0, "brown")

结果

ERROR: MethodError: no method matching Person(::String, ::Int64, ::Int64, ::Int64, ::String)

换句话说,行为是一样的,就好像我没有使用

Revise.jl

如果您能在这个问题上得到帮助,我将不胜感激。也许,我缺少一个步骤......

error-handling julia
1个回答
0
投票

遗憾的是,这不受支持。

修订文档内容如下:

Revise(或者通常是 Julia 本身)无法将某些类型的更改合并到正在运行的 Julia 会话中:

  • 类型定义或常量的更改
  • 同名变量和函数之间的冲突
  • 取消出口

此类更改需要您重新启动 Julia 会话。

© www.soinside.com 2019 - 2024. All rights reserved.