[RFC] Unsigned modes

Jose E. Marchesi jemarch@gnu.org
Fri Sep 25 05:23:21 GMT 2026


Hello people!

In standard Algol 68 integral modes are always signed.

Having unsigned integral modes would help with:

1. While doing FFI or transput, in which unsigned quantities should have
   some particular precision.

2. When unsigned arithmetic is desired, i.e. wrapping logic on overflow.

To this effect I propose the following.

There is no need to introduce new standard modes in order to achieve
unsigned modes.  The standard `bits' mode is naturally implemented as
unsigned magnitudes with the same size than the corresponding signed
ints.  That is the case of ga68.  So it would be enough to define
unsigned arithmetic operators in the expanded standard preclude that
operate on bits, +, -, %, *, etc.  And implement these as compiler
built-ins. This does NOT require any language extension.  With this, one
would just use `bits', `long bits', etc, for operating with unsigned
integral values, rather than `int', `long int', etc.  Note we support
decimal radix 10r in bits denotations, as a GNU extension.

We could improve ergonomics by going a little bit further:

OPTIONALLY, we could have the compiler understand `uint' as a synonym of
`bits'.  A language extension would be necessary for this so one could
write `SIZETY uint' declarers.

Opinions?


More information about the Algol68 mailing list