C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

pTAL Code C Code
STRUCT rec (*); struct rec
BEGIN {
INT d; short d;
INT .p (rec); struct rec *p;
END; };
BLOCK joe;
INT .EXT joes (rec); struct rec *JOE;
END BLOCK;
PROC tonga (p); void CALEDONIA
INT .EXT p (rec); (struct rec *p)
BEGIN {
!Lots of code /* Lots of code */
END; }
Each language can call the other, passing the address in the pointer by value:
pTAL Code C Code
CALL caledonia (joes); TONGA (joe);
Here are examples of pTAL and C structure pointers (large-memory model) that implement a linked
list:
pTAL Code C Code
STRUCT rec (*); struct rec
BEGIN {
INT x; short x;
INT .EXT strptr (rec); struct rec *p;
END; };
STRUCT .EXT joe (rec); struct rec joe;
PROC callme (param1); void f1 (struct rec *param1);
INT .EXT param1 (rec);
EXTERNAL;
Enumeration Variables
Using C enumeration variables, you can associate a group of named constant values with an int
variable. A C enumeration variable occupies 16 bits of memory for TNS programs and 32 bits
for native programs. You define all integer operations on them. The C compiler provides no range
checking, so an enumeration variable can hold a value not represented in the enumeration.
A C routine can share an enumeration variable with pTAL routines. A pTAL routine cannot access
the enumeration variables, but it can declare LITERALs for readability. For example:
pTAL Code C Code
LITERAL no = 0, typedef enum choice
yes = 3, { no = 0,
maybe = 4; yes = 3,
maybe = 4
BLOCK answer; } choice;
INT answer_var;
END BLOCK; choice ANSWER;
A C routine can pass enumeration parameters to pTAL routines, placing the actual value in a pTAL
INT variable. For example:
pTAL Code C Code
LITERAL no = 0, enum choice {no = 0,
yes = 3, yes = 3,
maybe = 4; maybe = 4 };
enum choice answer;
PROC tal_proc (n);
INT n; _tal void TAL_PROC (short);
Considerations When Interfacing to pTAL 137