I’ve seen many examples of Julia code where methods are defined without any variable name bindings. My usage of terminology my be inaccurate here, but for example:
eltype(::Type{<:AbstractArray{T}}) where {T} = T
As far as I can tell, this is equivalent to the following code.
eltype(S::Type{<:AbstractArray{T}}) where {T} = T
But since we don’t need to do any computation with the value S
, we don’t need to bind the value to this symbol, so we can just use the first way of defining the method, so long as we have keep the reference to T
, which we do care about in this context.
Is my understanding correct here?
Regardless, is this pattern documented anywhere? I’ve read through the manual sections on methods, and the only places I’ve found this kind of method definition don’t explicitly call out this pattern.