This is the usual way to do something like that:
struct Foo
z
function Foo(x, y)
self = new(x + y)
return self
end
end
I add the usual advice that it’s better in the long run to declare the struct so that z has a concrete or a parameterized type.