On Sun, Nov 02, 2025 at 01:09:27AM +0100, Grégory Vanuxem wrote:
> hello,
>
> U64Int exports Ring I wonder why. Wouldn't it be something like
> OrderedAbelianMonoid, eventually OrderedAbelianMonoidSup, or something
> like that? I know its use from the documentation (u32vec.spad):
>
> )abbrev domain U64INT U64Int
> ++ Description: Domain of unsigned 64-bit integers. It is used
> ++ to declare that values of local variables fit into 64 bits.
> U64Int : Ring with
> qconvert : Integer -> %
> == Integer add
> qconvert(x) == x pretend %
For current needs we probably could replace Ring by Type. In
other words I do not think we use any categorical properties
of U64Int.
Logically, U64Int is a subset of integers which fits into 64 bits.
So strictly speaking only handful of operations like comparisons
is valid for all arguments. But the idea is that as long as
arguments and value fit into 64-bit operation is well defined.
In ususal style we could have something like 'addIfCan', etc.
But the whole reason to have such type at all is to allow direct use of machine instructions. So while currently '+', '-', '*' are unimplemented, they make sense and should translate to
corresponding machine instructions.
As I wrote, currently all ring operations are unimplementd (and
unused), so Ring basically serves as a comment indicating that
'+', '-', '*'. We can change this in the future, ATM it is not
clear to me if we should use very restrictive type, like
Type or BasicType, or something more general. We may wish to
use U64Int in generic code, which could force us to add more
operations. Ring looked reasonable to me, because if needed
we can provide corresponding operations and it appears frequently
as requirement for generic operations.
--
Waldek Hebisch