Wrap and inherit Number

Very cool.

I’d like to add some clarity as well:
The “thing” that would be most useful (and maybe I should open a new topic for this), is if we could just have something that acts exactly like a Number (in every meaning), but that we can override some of the functions that already accept it as an argument.

So here’s an instance of Float64:
Float64(33.0)
We can do all sorts of things with it. Here is an instance of a custom type A:
A(33.0)
We can do exactly the same things like the Float64 version from before. Now I change the existing sin function to the following (silly):
sin(x::A) = 2x.
There. Instances of A do everything, say, floats can do, and I modified the behavior of a few select functions. Winning.

1 Like