The language indicant C is used to access C variables and
calling C functions:
nest C "[&]symbol"
The row char denotation should contain a symbol corresponding to a C
variable or function, optionally preceded by an ampersand &.
It is the responsibility of the programmer to make sure the specified
symbol actually corresponds to an entity with the right type. In case
a malformed symbol is specified it will very likely result in an
assembler error.
For example, this is how we can access a C variable as an Algol 68 constant:
int counter = nest C "counter"; if counter = 0 then ... fi;
If we wanted to be able to change the value of the C variable
counter then we need to add a leading ampersand to the row
denotation, and of course change the mode on the Algol 68 side to a
ref int:
ref int counter = nest C "&counter"; counter +:= 1;
If we wanted to access a C pointer variable int *ptr as an
Algol 68 name we could do:
ref int ptr = nest C "ptr";
ptr := 100; { Changes the value pointed by the C pointer ptr,
not of ptr itself }
If we wanted to call the standard POSIX functions random and
srandom we could do:
proc long int random = nest C "random"; proc(bits)void srandom = nest C "srandom"; if random < 100 then ... fi
The modes accepted in a formal hole for C are:
voidAs C void.
boolAs C bool.
charAs C 32-bit integer.
intAs C int.
short intAs C short.
short short intAs C char.
long intAs C long or as C int.
long long intAs C long long or as C long or as C int.
bitsAs C unsigned int.
short bitsAs C unsigned short.
short short bitsAs C unsigned char.
long bitsAs C unsigned long or as C unsigned int.
long long bitsAs C unsigned long long or as C unsigned long or as C unsigned int.
realAs C float
long realAs C double
As the corresponding C functions.
As the corresponding C structs.