Open goretkin opened 3 years ago
on Julia 1.6
julia> (@fix Base.Broadcast.BroadcastFunction(+)(1, _))(1:3)
3-element Vector{Int64}:
2
3
4
Already true on v1.5, infix and prefix broadcasted functions parse differently:
julia> dump(:(f.(1,2)))
Expr
head: Symbol .
args: Array{Any}((2,))
1: Symbol f
2: Expr
head: Symbol tuple
args: Array{Any}((2,))
1: Int64 1
2: Int64 2
julia> dump(:(1 .+ 2))
Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol .+
2: Int64 1
3: Int64 2
because .$operator
is handled specially by the parser.
julia> :(.+)
:.+
julia> :(f.)
ERROR: syntax: unexpected ")"
Stacktrace:
[1] top-level scope at none:1
julia> :(.f)
ERROR: syntax: invalid identifier name "."
Stacktrace:
[1] top-level scope at none:1
because
Note that
Perhaps
Base.Broadcast.Broadcasted{Nothing}(+, ())
can be used to represent.+
, or we can define new wrapper type, or better yet just useBroadcastFunction
from https://github.com/JuliaLang/julia/pull/37583