-
-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addc and subc functions not implemented for U128 and I128 #2409
Comments
Forgive me if I'm missing something, I've only just come across pony this week, and haven't used it outside of trivial playground examples, so I've not had occasion to see if anything works as well in practice as I'd expect. I'm wondering if it using an interface would make more sense in this particular example. Something like: interface ArithmeticC[T]
fun addc(x: T): (T, Bool)
fun subc(x: T): (T, Bool)
fun mulc(x: T): (T, Bool)
class GenericSum[T: (Int & ArithmeticC[T] val)] // maybe just ArithmeticC[T] val
fun _plus_safe(x: T, y: T): (T, Bool) =>
x.addc(y)
fun sum(x: T, y: T): T ? =>
(let res, let overflow) = _plus_safe(x, y)
if overflow then error end
res
actor Main
new create(env: Env) =>
try
env.out.print(GenericSum[U8].sum(1, 2)?.string())
end That's not to say that |
Yes, my example definitely needs an interface or trait that contains the |
@jemc has a PR for this, he just hasn't opened it yet. But, is planning on it. |
I was trying to define a generic function, that works for all of the
Int
types, that wrapsaddc
. I tried the following without success:http://playground.ponylang.org/?gist=4c4e8a4001e4f360ea21d18bfa141b5e
Pony claims to be unable to find
addc
.I found out that both
I128
andU128
do not implementaddc
norsubc
although they can still overflow. The only reason i see is that there is no LLVM intrinsic for those types. What would it take to implement this?The text was updated successfully, but these errors were encountered: