Hi everyone, I have a question regarding Types/Functions that came up after I discovered the PkgTemplates.jl package.
In this package I can define an object of type Template like so:
t = Template();
Then, to actually create the template, I do:
t(“PkgName”);
And I cannot understand why I can call t, which is a Type, like it is a function? I looked at the source Code, and the (I think) relevant part is this:
“”"
(::Template)(pkg::AbstractString)
Generate a package namedpkg
from aTemplate
.
“”"
function (t::Template)(pkg::AbstractString)
…
…
…
end
Can someone explain to me what this construct does? Does it convert any Template Type into a function of the same name? I looked at the documentation for functions and types but I can’t figure it out. Why not just create a function like
createtemplate(t::Template) = ...
?
Thanks in advance for any explainations!