'import @with_kw from Parameters inside my own package
I have created my own Julia package and I am new to such practices.
I previously had this code:
using Parameters
@with_kw mutable struct MWE @deftype String
mwe1 = "default" ; @assert mwe1 in ["default", "1", "2"]
mwe2 = "test"
end
Which worked well. Now that I put it into my package, replacing using with import, I have the following error:
julia> import MyPackageMWE
[ Info: Precompiling RobustRSP [33e6bdf6-6d3e-458b-9f4e-8cd6eb784281]
[ Info: Loading JuMP
[ Info: Loading Gurobi
[ Info: Loading Combinatorics, DelimitedFiles, Dates and Random
[ Info: Loading Distributions, Graphs and Plots
[ Info: Loading Parameters and Formatting
[ Info: Loading Compose, Cairo and Fontconfig
[ Info: Loading .jl files 0%
ERROR: LoadError: UndefVarError: @with_kw not defined
Any ideas what went wrong? Maybe it is related to @macros?
Solution 1:[1]
I don't know the package Parameters but it may be that if @with_kw is exported in Parameters then if you replace
using Parameters
with
import Parameters
then you should change
@with_kw with Parameters.@with_kw
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Giovanni |
