Hi.
I recently started reading through Julia base library code and stumbled on the following syntax (char.jl):
Char
(::Type{T})(x::Number) where {T<:AbstractChar} = T(UInt32(x))
(::Type{AbstractChar})(x::Number) = Char(x)
(::Type{T})(x::AbstractChar) where {T<:Union{Number,AbstractChar}} = T(codepoint(x))
(::Type{T})(x::T) where {T<:AbstractChar} = x
I have read through entire Julia documentation but can’t remember anything like this. Why the ‘Char’ statement in a separate line? What’s with those ‘(::Type{T})’? Have I missed a chapter somewhere?
Thank you!
PS: Its a pity Julia decided not to follow Python design of modules reflected by file & directory structure. It is becoming increasingly hard to read large code bases in Julia without syntactical analysis, even harder than C++. IMHO, Python’s design to reflect program logical structure with file structure is brilliant and allows to quickly grasp code structure and navigate even large code bases without getting lost. The argument for code re-usage with 'include’s can be easily resolved by naming convention. For example *.jl files may reflect modules structure, while *.ji files are includes and ignored by compiler unless included. It is still possible to adopt this system by inverting such naming convention, like *.jl files are includes and *.jm files are modules, so no existing code will be broken.