I have already read the manual, the relevant issue, and have done some fair share of googling, so I am getting a little frustrated that I cannot find the missing information.
I come from a C++ background, I wanted to follow a pattern that I follow in my C++ code for performance and flexibility reasons (the c++ templates) and I know that Julia supported something like this at some point:
f{T}(parameters that do not have type T) = computation using type T inside
This is, a method that receives a explicit type clearly known in compilation time, and that is not the type of any of its arguments, and use this information to define which object will be used to perform some computation inside the method and/or help to define the return type of the method.
Using the new where syntax I was able to to the following:
f() where {T} = some code
However, I do not know how to call this method, as I do not know how to inform T to the method. Obviously, just calling the method, as in:
f()
gives
ERROR: UndefVarError: T not defined
what I consider expected, but the old syntax:
f{Int64}()
gives
ERROR: TypeError: in Type{...} expression, expected UnionAll, got typeof(f)
What I suppose means that it expected a type constructor? Not sure, but as this is the old syntax I also understand it should not work. I did not however find any reference to how do this. The comment of StefanKarpinski (that I cited above) is almost what I want, as it seems to mention my problem:
The only really odd case, as you mention, is
f(...) where T = body
without any type bound, but Iâve found that even this case fairly quickly loses its unfamiliarity.
but he just says that and do not explain how to call. He also says
The syntax used to define a method always matches the syntax used to call it.
but:
f() where {Int64}
gives
ERROR: UndefVarError: T not defined
So I am not sure by what he did mean by âalways matchesâ.
Sorry if it is a stupid question, this clearly has a simple answer, but I cannot see it.