Skip to content

Commit

Permalink
more julia 1.0 updates and fix for dep-warn (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro3 authored Sep 4, 2018
1 parent 631464c commit b25fa15
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/src/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion examples/ex1.jl
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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

Expand Down
21 changes: 4 additions & 17 deletions src/Parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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...)
Expand All @@ -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


Expand Down

0 comments on commit b25fa15

Please sign in to comment.