chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.78k stars 419 forks source link

BigInteger coercions #17743

Open lydia-duncan opened 3 years ago

lydia-duncan commented 3 years ago

Over on https://github.com/chapel-lang/chapel/issues/17689#issuecomment-840103346 Brad said:

it makes me wish we had int->bigint and uint->bigint coercions so that [cases like exponentiation with an integer base] would just "fall out" rather than requiring explicit overloads ... it seems like it could remove some redundancy in the code base for cases where we're just taking the integral, converting to bigint, and calling the bigint version? And it'd be an issue in which coercions seem very reasonable to carry along the conversation we started after the last release

bradcray commented 3 years ago

To me, int->bigint and bigint->int coercions seem like a model case for user-defined coercions, to provide similar benefits to int(8)->int(64) coercions and the like but for a type defined outside of the language. Many operations have (and benefit from) explicit bigint op int combinations, but for those that don't, it seems artificial to require additional overloads that just do explicit conversions within the routine.