Am I missing something, or why isn't there this solution:
@enum Metric RIEMANNIAN LORENTZIAN # ...
immutable Sphere{Matric}
dim::Int
end
function metric(s::Sphere{RIEMANNIAN})
end
function metric(s::Sphere{LORENTZIAN})
end
Am Montag, 18. Januar 2016 16:08:38 UTC+1 schrieb Anonymous:
>
> Is the following code considered bad form in Julia?
>
> immutable Foo
> func::Function
> end
>
> foo = Foo(x->x^2)
> foo.func(3)
>
> This mimics the behavior of OOP since just like in OOP the internal method
> cannot be changed (since the type is immutable). Sometimes it really does
> make the most sense to attach a function to an instance of a type, do I
> take a performance hit doing things this way?
>