From b25fa15a0f05b79817714a31ed52c35b62c61766 Mon Sep 17 00:00:00 2001 From: Mauro Date: Tue, 4 Sep 2018 07:29:03 +0000 Subject: [PATCH] more julia 1.0 updates and fix for dep-warn (#78) --- docs/src/manual.md | 2 +- examples/ex1.jl | 4 +++- src/Parameters.jl | 21 ++++----------------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/docs/src/manual.md b/docs/src/manual.md index 659cc06..9c3e012 100644 --- a/docs/src/manual.md +++ b/docs/src/manual.md @@ -262,7 +262,7 @@ function fn(var, pa::Para) # and called @unpack_* out = var + a + b b = 77 - @pack!_Para pa # only works with mutables + @pack_Para! pa # only works with mutables return out, pa end diff --git a/examples/ex1.jl b/examples/ex1.jl index bab366b..44e8cf3 100644 --- a/examples/ex1.jl +++ b/examples/ex1.jl @@ -1,3 +1,5 @@ +# This is the example used in the manual. +# (Consider using Literate.jl) using Parameters ## Create a type which has default values: @@ -94,7 +96,7 @@ function fn1(var, pa::Para) # and called @unpack_* out = var + a + b b = 77 - @pack_Para pa # now pa.b==77 + pa = reconstruct(pa, b=b) # now pa.b==77 return out, pa end diff --git a/src/Parameters.jl b/src/Parameters.jl index dc9cdfc..9f51ca2 100644 --- a/src/Parameters.jl +++ b/src/Parameters.jl @@ -253,7 +253,7 @@ function _pack_mutable(binding, fields) e end function _pack_immutable(binding, fields) - error("Cannot pack an immutable. Consider using `reconstruct` (or file a feature request).") + error("Cannot pack an immutable. Consider using `reconstruct` (or make a pull request).") end const macro_hidden_nargs = length(:(@m).args) - 1 # ==1 on Julia 0.6, ==2 on Julia 0.7 @@ -556,17 +556,12 @@ function with_kw(typedef, mod::Module, withshow=true) esc($Parameters.$(_pack)(ex, $unpack_vars)) end macro $pack_name_depr(ex) - Base.depwarn("The macro `@pack_A` is deprecated, use `@$(string($pack_name))`", $(QuoteNode(pack_name_depr)) ) + Base.depwarn("The macro `@$($(Meta.quot(pack_name)))` is deprecated, use `@$($(Meta.quot(pack_name_depr)))`", $(QuoteNode(pack_name_depr)) ) esc($Parameters.$(_pack)(ex, $unpack_vars)) end $tn end end -@static if isdefined(Base, Symbol("@__MODULE__")) - @deprecate with_kw(typedef, withshow=true) with_kw(typedef, @__MODULE__, withshow=true) -else - @deprecate with_kw(typedef, withshow=true) with_kw(typedef, current_module(), withshow=true) -end """ Do the with-kw stuff for named tuples. @@ -616,11 +611,7 @@ end For more details see manual. """ macro with_kw(typedef) - @static if isdefined(Base, Symbol("@__MODULE__")) - return esc(with_kw(typedef, __module__, true)) - else - return esc(with_kw(typedef, current_module(), true)) - end + return esc(with_kw(typedef, __module__, true)) end macro with_kw(args...) @@ -644,11 +635,7 @@ end For more details see manual. """ macro with_kw_noshow(typedef) - @static if isdefined(Base, Symbol("@__MODULE__")) - return esc(with_kw(typedef, __module__, false)) - else - return esc(with_kw(typedef, current_module(), false)) - end + return esc(with_kw(typedef, __module__, false)) end