[RFC] Unsigned modes

Jose E. Marchesi jemarch@gnu.org
Fri Sep 25 09:34:50 GMT 2026


Hi Chris.

Thanks for the comments.

> Good morning everyone,
>
> On Fri, Sep 25, 2026, 07:25 Jose E. Marchesi <jemarch@gnu.org> wrote:
>
>>
>> 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?
>>
>
> I like the idea of broadening the utility of language with operators per
> your first option.
>
> Not being a "deeply grounded in C" person I also prefer thinking of bits
> for shifting and logical operations, rather than integers.

Yes I do the same.

> I don't mind slipping back and forth between int and bits to mix logical
> and arithmetic operations. It can feel clumsy but it also makes clear what
> is going on. However, the business of overflowing from positive to negative
> requires extra effort to detect and I would definitely prefer to have < >
> etc available for bits.
>
> So in general more operators but no new fundamental modes would be my
> preference.

Ok we are on the same page then :)

>
>>


More information about the Algol68 mailing list