Skip to content

Commit a2b9015

Browse files
committed
broadcast.jl cleanup:
* Slightly clearer recursion through arg lists in not_nested * Move show(::IO, ::Broadcasted) to a more sensible location and have it print its type fully qualified with the `Style` parameter.
1 parent db690e0 commit a2b9015

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

base/broadcast.jl

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ end
181181
Base.convert(::Type{Broadcasted{NewStyle}}, bc::Broadcasted{Style,Axes,F,Args}) where {NewStyle,Style,Axes,F,Args} =
182182
Broadcasted{NewStyle,Axes,F,Args}(bc.f, bc.args, bc.axes)
183183

184-
# Fully-instantiatiated Broadcasted
185-
const BroadcastedF{Style<:Union{Nothing,BroadcastStyle}, N, F, Args<:Tuple} =
186-
Broadcasted{Style, <:Indices{N}, F, Args}
184+
Base.show(io::IO, bc::Broadcasted{Style}) where {Style} = print(io, Broadcasted, '{', Style, "}(", bc.f, ", ", bc.args, ')')
187185

188186
## Allocating the output container
189187
"""
@@ -233,10 +231,10 @@ argtype(::Type{Broadcasted{Style,Axes,F,Args}}) where {Style,Axes,F,Args} = Args
233231
argtype(bc::Broadcasted) = argtype(typeof(bc))
234232

235233
const NestedTuple = Tuple{<:Broadcasted,Vararg{Any}}
236-
not_nested(bc::Broadcasted) = not_nested(bc.args)
237-
not_nested(t::Tuple) = not_nested(tail(t))
238-
not_nested(::NestedTuple) = false
239-
not_nested(::Tuple{}) = true
234+
not_nested(bc::Broadcasted) = _not_nested(bc.args)
235+
_not_nested(t::Tuple) = _not_nested(tail(t))
236+
_not_nested(::NestedTuple) = false
237+
_not_nested(::Tuple{}) = true
240238

241239
## Instantiation fills in the "missing" fields in Broadcasted.
242240
instantiate(x) = x
@@ -564,11 +562,6 @@ Base.@propagate_inbounds _getindex(args::Tuple{}, I) = ()
564562

565563
@inline _broadcast_getindex_evalf(f::Tf, args::Vararg{Any,N}) where {Tf,N} = f(args...) # not propagate_inbounds
566564

567-
@noinline function broadcast_getindex_error(bc, I)
568-
isa(bc, BroadcastedF) && error("axes $(axes(bc)) does not match $I")
569-
error("indexing requires complete instantiation")
570-
end
571-
572565
"""
573566
broadcastable(x)
574567
@@ -1187,8 +1180,6 @@ macro __dot__(x)
11871180
esc(__dot__(x))
11881181
end
11891182

1190-
Base.show(io::IO, bc::Broadcasted) = print(io, "Broadcasted(", bc.f, ", ", bc.args, ')')
1191-
11921183
@inline make_kwsyntax(f, args...; kwargs...) = make((args...)->f(args...; kwargs...), args...)
11931184
@inline function make(f, args...)
11941185
args′ = map(broadcastable, args)

0 commit comments

Comments
 (0)