Your description of the problem is what “functors” are about:
julia> struct Object
a::Float64
end
julia> (o::Object)(x) = o.a*x
julia> o = Object(4)
Object(4.0)
julia> o(5)
20.0
julia> b = Object(2)
Object(2.0)
julia> b(5)
10.0
but maybe if you describe your problem in more detail other better and simpler solutions may be what you want.
It is more common just to separate the “function” from its parameters, and pass the parameters explicitly to the function. If many of them, packed into a struct:
julia> f(x,parameters) = parameters.a*x + parameters.b*x
f (generic function with 1 method)
julia> struct Parameters
a::Float64
b::Float64
end
julia> p = Parameters(5.0,10.0)
Parameters(5.0, 10.0)
julia> f(2.0,p)
30.0