996
|
1 Alex Smith, 26 March 2008
|
|
2
|
|
3 syslibc.c is an example of a C program designed to be used with the
|
|
4 INTERCAL external call code. It only attempts to emulate the base 2
|
|
5 algorithms, but in a base 2 program it should be a valid drop-in
|
|
6 replacement for the real system library. (Don't forget to use the -eE
|
|
7 options when linking this to an INTERCAL program; -e to allow C
|
|
8 programs to be linked in, and -E to suppress the 'real' syslib.)
|
|
9
|
|
10 The library is designed foremost to ensure that all errors are checked
|
|
11 (as they would be in the INTERCAL, although you get the error messages
|
|
12 produced by C code), and secondarily for speed (it is substantially
|
|
13 faster than the INTERCAL version of the system library, but that isn't
|
|
14 particularly surprising).
|
|
15
|
|
16 Note that some INTERCAL programs rely on undocumented features of the
|
|
17 system library; I have implemented the commonly-used (1001), but some
|
|
18 of the example programs (for instance primes.i) NEXT to other
|
|
19 undocumented internal lines of syslib.i, and such programs will error
|
|
20 out on the C version of the syslib.
|
|
21
|
|
22 There are some situations in which the C program will cause errors,
|
|
23 but the INTERCAL version wouldn't; remember that any attempt to alter
|
|
24 or view an INTERCAL variable from C code causes an error if that
|
|
25 variable doesn't exist in the INTERCAL program. Therefore, in order to
|
|
26 use a particular routine, you should mention all the variables that
|
|
27 are its inputs and outputs somewhere in your INTERCAL program; in
|
|
28 particular, if you're using overflow-checked routines, make sure you
|
|
29 mention .4 at least once in your program.
|