How to handle deprecations of new broadcast functions?

I’m starting to see lots of warnings like this:

WARNING: deprecated syntax "function .*(...)".
Use "function Base.broadcast(::typeof(*), ...)" instead.

WARNING: deprecated syntax "function .*(...)".
Use "function Base.broadcast(::typeof(*), ...)" instead.

WARNING: deprecated syntax "function .*(...)".
Use "function Base.broadcast(::typeof(*), ...)" instead.

WARNING: deprecated syntax "function .*(...)".
Use "function Base.broadcast(::typeof(*), ...)" instead.

WARNING: deprecated syntax "function ./(...)".
Use "function Base.broadcast(::typeof(/), ...)" instead.

WARNING: deprecated syntax "function ./(...)".
Use "function Base.broadcast(::typeof(/), ...)" instead.

How do I edit the code so that it will work in versions 0.4, 0.5, and 0.6?

3 Likes

We probably need to add support to the @compat macro in Compat.jl.

For the most part, you shouldn’t need to define operators like .* at all in 0.6: just defining * for your type will automatically give you x .* y as a synonym for broadcast(*, x, y).

But because this is a syntax deprecation, you will get a warning even if your definitions are protected by if VERSION < v"0.6". So, we should define the @compat macro to make @compat function Base.broadcast(::typeof(*), ...) turn into a .*(...) definition in 0.5 and 0.4.

4 Likes

It doesn’t look like this has been done yet, so I’ve added an issue:

https://github.com/JuliaLang/Compat.jl/issues/308

3 Likes