Skip to content

Commit

Permalink
Fix vectorization deprecation macros for Julia 0.7 (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored Aug 9, 2017
1 parent 4f24102 commit 5883a74
Showing 1 changed file with 43 additions and 27 deletions.
70 changes: 43 additions & 27 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,49 @@ end
# These macros should raise a depwarn when the `0.5` support is dropped from
# `Compat` and be dropped when the support for `0.6` is dropped from `Compat`.
# Modified based on the version copied from 0.6 Base.
macro dep_vectorize_1arg(S, f)
S = esc(S)
f = esc(f)
T = esc(:T)
x = esc(:x)
AbsArr = esc(:AbstractArray)
## Depwarn to be enabled when 0.5 support is dropped.
# depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
# Symbol("@dep_vectorize_1arg"))
:(@deprecate $f{$T<:$S}($x::$AbsArr{$T}) @compat($f.($x)))
end

macro dep_vectorize_2arg(S, f)
S = esc(S)
f = esc(f)
T1 = esc(:T1)
T2 = esc(:T2)
x = esc(:x)
y = esc(:y)
AbsArr = esc(:AbstractArray)
## Depwarn to be enabled when 0.5 support is dropped.
# depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
# Symbol("@dep_vectorize_2arg"))
quote
@deprecate $f{$T1<:$S}($x::$S, $y::$AbsArr{$T1}) @compat($f.($x,$y))
@deprecate $f{$T1<:$S}($x::$AbsArr{$T1}, $y::$S) @compat($f.($x,$y))
@deprecate $f{$T1<:$S,$T2<:$S}($x::$AbsArr{$T1}, $y::$AbsArr{$T2}) @compat($f.($x,$y))
if VERSION < v"0.7.0-DEV.1211"
macro dep_vectorize_1arg(S, f)
S = esc(S)
f = esc(f)
T = esc(:T)
x = esc(:x)
AbsArr = esc(:AbstractArray)
## Depwarn to be enabled when 0.5 support is dropped.
# depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
# Symbol("@dep_vectorize_1arg"))
:(@deprecate $f{$T<:$S}($x::$AbsArr{$T}) @compat($f.($x)))
end

macro dep_vectorize_2arg(S, f)
S = esc(S)
f = esc(f)
T1 = esc(:T1)
T2 = esc(:T2)
x = esc(:x)
y = esc(:y)
AbsArr = esc(:AbstractArray)
## Depwarn to be enabled when 0.5 support is dropped.
# depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
# Symbol("@dep_vectorize_2arg"))
quote
@deprecate $f{$T1<:$S}($x::$S, $y::$AbsArr{$T1}) @compat($f.($x,$y))
@deprecate $f{$T1<:$S}($x::$AbsArr{$T1}, $y::$S) @compat($f.($x,$y))
@deprecate $f{$T1<:$S,$T2<:$S}($x::$AbsArr{$T1}, $y::$AbsArr{$T2}) @compat($f.($x,$y))
end
end
else
macro dep_vectorize_1arg(S, f)
AbstractArray = GlobalRef(Base, :AbstractArray)
return esc(:(@deprecate $f(x::$AbstractArray{T}) where {T<:$S} $f.(x)))
end

macro dep_vectorize_2arg(S, f)
AbstractArray = GlobalRef(Base, :AbstractArray)
return esc(quote
@deprecate $f(x::$S, y::$AbstractArray{T1}) where {T1<:$S} $f.(x, y)
@deprecate $f(x::$AbstractArray{T1}, y::$S) where {T1<:$S} $f.(x, y)
@deprecate $f(x::$AbstractArray{T1}, y::$AbstractArray{T2}) where {T1<:$S, T2<:$S} $f.(x, y)
end)
end
end

Expand Down

0 comments on commit 5883a74

Please sign in to comment.