Skip to content

Commit b25fa15

Browse files
authored
more julia 1.0 updates and fix for dep-warn (#78)
1 parent 631464c commit b25fa15

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

docs/src/manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function fn(var, pa::Para)
262262
# and called @unpack_*
263263
out = var + a + b
264264
b = 77
265-
@pack!_Para pa # only works with mutables
265+
@pack_Para! pa # only works with mutables
266266
return out, pa
267267
end
268268

examples/ex1.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This is the example used in the manual.
2+
# (Consider using Literate.jl)
13
using Parameters
24

35
## Create a type which has default values:
@@ -94,7 +96,7 @@ function fn1(var, pa::Para)
9496
# and called @unpack_*
9597
out = var + a + b
9698
b = 77
97-
@pack_Para pa # now pa.b==77
99+
pa = reconstruct(pa, b=b) # now pa.b==77
98100
return out, pa
99101
end
100102

src/Parameters.jl

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function _pack_mutable(binding, fields)
253253
e
254254
end
255255
function _pack_immutable(binding, fields)
256-
error("Cannot pack an immutable. Consider using `reconstruct` (or file a feature request).")
256+
error("Cannot pack an immutable. Consider using `reconstruct` (or make a pull request).")
257257
end
258258

259259
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)
556556
esc($Parameters.$(_pack)(ex, $unpack_vars))
557557
end
558558
macro $pack_name_depr(ex)
559-
Base.depwarn("The macro `@pack_A` is deprecated, use `@$(string($pack_name))`", $(QuoteNode(pack_name_depr)) )
559+
Base.depwarn("The macro `@$($(Meta.quot(pack_name)))` is deprecated, use `@$($(Meta.quot(pack_name_depr)))`", $(QuoteNode(pack_name_depr)) )
560560
esc($Parameters.$(_pack)(ex, $unpack_vars))
561561
end
562562
$tn
563563
end
564564
end
565-
@static if isdefined(Base, Symbol("@__MODULE__"))
566-
@deprecate with_kw(typedef, withshow=true) with_kw(typedef, @__MODULE__, withshow=true)
567-
else
568-
@deprecate with_kw(typedef, withshow=true) with_kw(typedef, current_module(), withshow=true)
569-
end
570565

571566
"""
572567
Do the with-kw stuff for named tuples.
@@ -616,11 +611,7 @@ end
616611
For more details see manual.
617612
"""
618613
macro with_kw(typedef)
619-
@static if isdefined(Base, Symbol("@__MODULE__"))
620-
return esc(with_kw(typedef, __module__, true))
621-
else
622-
return esc(with_kw(typedef, current_module(), true))
623-
end
614+
return esc(with_kw(typedef, __module__, true))
624615
end
625616

626617
macro with_kw(args...)
@@ -644,11 +635,7 @@ end
644635
For more details see manual.
645636
"""
646637
macro with_kw_noshow(typedef)
647-
@static if isdefined(Base, Symbol("@__MODULE__"))
648-
return esc(with_kw(typedef, __module__, false))
649-
else
650-
return esc(with_kw(typedef, current_module(), false))
651-
end
638+
return esc(with_kw(typedef, __module__, false))
652639
end
653640

654641

0 commit comments

Comments
 (0)