Is there a way to create a type alias with a custom constructor?
FloatyMcFloatFace = Float64
FloatyMcFloatFace(x) = new(x+1)
Is there a way to create a type alias with a custom constructor?
FloatyMcFloatFace = Float64
FloatyMcFloatFace(x) = new(x+1)
No. Aliases are just another name for exactly the same type, so they can’t have separate methods.
Is there a good way to have a custom type that automatically inherits all the methods of the “aliased” type? I would like to have a custom type that has all the properties and functions of a Matrix but has custom show and constructors.
You have to implement some methods and make your type a subtype of AbstractMatrix: Interfaces · The Julia Language
I was trying to avoid that. Matrix
type is fairly well documented but for a lot of types that would mean run the code and implement the method from the error stack trace. I need a catch all
https://docs.juliahub.com/Lazy/mi7Ul/0.15.0/autodocs/#Lazy.@forward-Tuple{Any,Any}
could help but you can’t avoid doing:
Lazy.@forward
looks great. Thanks!