Warning: deprecated syntax .+?



Recently, I noticed this warning on my Travis builds Julia v0.6:

WARNING: deprecated syntax “function .+(…)”.
Use “function Base.broadcast(::typeof(+), …)” instead.

Can you please confirm the dot notation is not deprecated?


Yes. .+ no longer exists, neither do any of the . operators. Instead, all . operators are now just calls to broadcast(!)


You mean we have to write broadcast everywhere?


No? Just use .+. You can’t extend "the operator .+" because it doesn’t actually exist though: .+ means broadcast(+,...)


My question is because of these warnings:



I am just using .+ everywhere and the deprecation warnings are showing up. I am probably doing something wrong somewhere else.


Either you or a package you are using has an overload of .+.


If you read the depwarn carefully, it’s telling you that the function definition have been deprecated, not the use of it.


wild guess: https://github.com/SimonDanisch/FixedSizeArrays.jl/blob/master/src/ops.jl#L42


Thank you all, makes sense, probably one of my dependencies is redefining .+


On the spot @Evizero :slight_smile:


By the way, StaticArrays.jl now provides StaticArrays.FixedSizeArrays which is (mostly) compatible with the old FixedSizeArrays and designed for Julia v0.6. It’s also much nicer since it plays well with the regular StaticArrays types. You might be able to switch over to it without much hassle and get Julia v0.6 compatibility for free.


Btw. I first saw this deprecation warning when I ran some older code where I defined the + function for other types:

v0.6.0> import Base

v0.6.0> Base.+(x::Foo, y::Foo) = ...
WARNING: deprecated syntax "function .+(...)".
Use "function Base.broadcast(::typeof(+), ...)" instead.

Which I fixed with direct import:

v0.6.0> import Base.+

v0.6.0> +(x::Foo, y::Foo) = ...


To extend + without an explicit import, you can do

Base.:+(x, y) = ...

You can also avoid the . in the import statement by using

import Base: +

if you so choose, though of course as you saw, what you have works.