I am pretty sure that promote_rule and promote_type derive from an era before we had modules. Following up on https://github.com/JuliaLang/julia/pull/23939#discussion_r142649713, the suggestion is to not use "namespacing by underscoring" and just use namespacing directly. promote.jl could define a Promote module and export promote but not rule, so that users would write Promote.rule. (#23939 is planning to introduce Broadcast.rule.)
There's one huge hitch with this suggestion: promote_type should become Promote.type, and you can't define a function called type. We could call it Promote.typejoin and have it fall back to Base.typejoin.
you can't define a function called
type
Should be possible for 1.0 though?
But if we can't use it for 0.7, can we use it for 1.0?
promote_type promotes types, so that is perhaps not a case of "namespacing by underscoring".
For a little bit more context, at https://github.com/JuliaLang/julia/pull/20815 I propose another promotion mechanism for array concatenation, which could be called cat_rule or something like that. So it would make sense to unify the naming of the three promotion systems.
However, Promote.type looks really weird. Maybe better stick with the current names. The main reason for this suggestion is that the Broadcast module would provide rule, similar and indices, but maybe we can find another solution.
It doesn't fully make sense to me that Promote would be a module.
So should we go with namespacing by underscore then, and have Broadcast export broadcast_rule, broadcast_indices, and broadcast_similar to Base? I don't think it makes any sense to type
Base.Broadcast.broadcast_rule(...) = ...
but
Base.broadcast_rule(...) = ...
seems OK.
Seems like there's consensus, I'll close.
Most helpful comment
So should we go with namespacing by underscore then, and have Broadcast export
broadcast_rule,broadcast_indices, andbroadcast_similarto Base? I don't think it makes any sense to typebut
seems OK.