Dot syntax in .7


#1

I was looking at the most recent version of .7 and noticed a lot of the dot syntax was not working. Is this feature broken or being deprecated?

Here are some examples:

function f(x)
    if rand() < .5
        return x + 1
    else 
        return x - 1
    end 
end

f.(rand(10))
ERROR: MethodError: no method matching getproperty(::typeof(f), ::Tuple{Array{Float64,1}})
Closest candidates are:
  getproperty(::Any, ::Symbol) at sysimg.jl:18

x = [rand(2) for i in 1:10]
x .+ [1 2]
β”Œ Warning: `a::AbstractArray + b::Number` is deprecated, use `broadcast(+, a, b)` instead.
β”‚   caller = macro expansion at broadcast.jl:341 [inlined]
β”” @ Core broadcast.jl:341

a = rand(3,3)
a .= .1
β”Œ Warning: Deprecated syntax `using the value of `.=``.
β”” @ nothing none:0


#2

The first example looks like a bug (something with global scope?):

julia> x = rand(2);

julia> f(x) = sin.(x);

julia> f(x)
2-element Array{Float64,1}:
 0.3560585848659661
 0.7432072794002402

julia> sin.(x)
ERROR: MethodError: no method matching getproperty(::typeof(sin), ::Tuple{Array{Float64,1}})
Closest candidates are:
  getproperty(::Any, ::Symbol) at sysimg.jl:18

The third example is


#3

Thanks for the info. I can’t say I understand all of the design implications, but I’m hoping most of the dot syntax is preserved. I think its among Julia’s best features.


#4

What version of v0.7 are you using?
This is the version I’m using:

julia> versioninfo()
Julia Version 0.7.0-DEV.4806
Commit 98b1206 (2018-04-06 19:49 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin17.5.0)
  CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Environment:

I thought that some of that might be fixed already.


#5

Confirmed on latest master. Filed as https://github.com/JuliaLang/julia/issues/26739.


#6

It looks like example 1 is a bug and 3 is in flux. Does anyone know the status behind the second example?


#7

That should be the same as

julia> [1 2] + 3
β”Œ Warning: `a::AbstractArray + b::Number` is deprecated, use `broadcast(+, a, b)` instead.
β”‚   caller = top-level scope
β”” @ Core :0
1Γ—2 Array{Int64,2}:
 4  5

which is a valid warning β€” the + is applied elementwise in your example, with the elements being vectors and numbers.


#8

Interesting. It works in .6.2 for some reason. It adds 1 to the first element of each sub-array and 2 to the second element of each sub-array. Is there a way to achieve that in .7?


#9

Correction: it creates a 10Γ—2 Array{Array{Float64,1},2}. It works in .6.2 nonetheless.


#10

The reason is that they were deprecated for v0.7. See


#11

Excellent. Thank you.


#12
x .+ [[1;2]]