This could be done as primitive functions added at https://github.com/gluon-lang/gluon/blob/6c79166ae76b77a620e3ae929e12653994ddeedd/vm/src/primitives.rs#L371-L430
I think I can find some time for this this evening.
I think in the long run I'd like to have custom implicit instances of Num for num, but I am pretty sure that it won't work out unless there is a way to pull in implicit instance and override one that is already in scope. Since Byte and Int always have the normal Num Int/Num Byte in scope a adding wrapping or saturating instance in scope will always cause ambiguities.
```f#
// Normal Num Int
let { ? } = import! std.int
1 + 2 // OK
let { ? } = (import! std.int).wrapping
1 + 2 // Error ambigous
let { ? } = (import! std.int).wrapping
1 + 2 // Ok since wrapping is selected
```
I think in the long run I'd like to have custom implicit instances of Num for num, but I am pretty sure that it won't work out unless there is a way to pull in implicit instance and override one that is already in scope.
Yeah, that seems really useful. I'm a bit torn on this, on one hand I actually like the explicitness of using a different function, on the other I can see how this would be really annoying when you are using it a lot. I guess this is just a thing where you have to be careful and only introduce the new binding in a new scope, so it doesn't override the behaviour of (+) half way through the file.
By the way, I just noticed that currently VmInt is defined as isize, but according to the gluon std docs it's always a i64. The alias should probably just be i64 then (it will be on most systems anyway).
By the way, I just noticed that currently VmInt is defined as isize, but according to the gluon std docs it's always a i64. The alias should probably just be i64 then (it will be on most systems anyway).
Yeah that's #403 . Should just stabilize on i64