Bytes, chars, ints, etc (gnu algol 68, C, ...)
Mohammad-Reza Nabipoor
mnabipoor@gnu.org
Fri Jan 16 20:01:48 GMT 2026
- Previous message (by thread): Bytes, chars, ints, etc (gnu algol 68, C, ...)
- Next message (by thread): Bytes, chars, ints, etc (gnu algol 68, C, ...)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Hi.
On Thu, Jan 15, 2026 at 09:43:07PM +0100, Jose E. Marchesi wrote:
>
> What I am coming to realize is that the C aliases would be pretty
> useless for Algol 68. This is because there are no implicit coercions
> from, say, `short int' to `int'. Widening only happens from int to real
> of same sizety, and from real to complex of same sizety. (Genie has an
> extension to allow the other kind of coercions, but I don't want to
> support it.) This means that you would start writing something like the
> following, to initialize a counter to zero:
>
>
> Int64 counter := _
>
>
> and then, what, should you write:
>
> Int64 counter := long 0;
>
> or should you write:
>
> Int64 counter := long long 0;
>
Soon or late, somebody have to deal with other people's C code from Algol68
and then one need Int8, Int16, ..., Intptr, Bits8, Bits16, ..., Bitsptr to
reduce the impedance with the external world.
And as a work-around for the raised problem, we can do something like this
in the compiler:
(
mode Intptr = long int;
op AS_INTPTR = (long long int i) long int: SHORTEN i,
AS_INTPTR = (int i) long int: LENG i,
AS_INTPTR = (short int i) long int: LENG LENG i,
AS_INTPTR = (short short int i) long int: LENG LENG LENG i;
Intptr i := AS_INTPTR 0;
skip
)
TBH I don't like AS_INTPTR that much as an identifier, if somebody have a better
idea, please mention it (I also considered TO_INTPTR, but I prefer AS_INTPTR).
For me, `Intptr' and `Bitsptr' are important to be able to deal with external C
code.
If we don't want this, one option for us is to define ga68's `int' to always be
32-bit on all platforms, which, IMHO, is not of a big deal for an application
programming language like Algol 68.
Regards,
Mohammad-Reza
- Previous message (by thread): Bytes, chars, ints, etc (gnu algol 68, C, ...)
- Next message (by thread): Bytes, chars, ints, etc (gnu algol 68, C, ...)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Algol68
mailing list