Repository navigation
Coercion, casting and arithmetic ops #158
zimri-leisher
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'd like a more consistent, frictionless and safe approach to coercion, casting and arithmetic in Fpy.
One big problem is that by forcing users to write lots of casts, and having the casts wrap/truncate/saturate, we introduce a lot of that behavior forcibly into their programs. Two obvious things:
I think #1 is a shoo-in (only problem is i will have to add like 8 new directives to fpyseq). #2 is also necessary, but it probably shouldn't be automatic, as that gives the user more footguns. The fewest footguns are allowing exactly no automatic conversion between numeric types, like Rust. But we could take Rust and allow widening between types of same kind.
One idea I had was breaking out casting into actual named functions which describe what they're doing, e.g.
wrap_u8(wrap some integer to a U8),round_f32(round an f64 to an f32), etc. I'm just afraid that users right now won't know that the casts they're writing have these behaviors.@Brian-Campuzano if you're interested, can discuss this stuff here
All reactions