Next: , Up: System Libraries   [Index]


8.1 syslib

INTERCAL-72 C-INTERCAL CLC-INTERCAL J-INTERCAL
yes all versions no all versions

INTERCAL has a system library, called ‘syslib’ (versions for bases other than 2 will have a numeric suffix on the name).

The intention of the system library is to provide a range of useful capabilities, like multiplication, that can otherwise be hard to write in INTERCAL. System library routines are used by NEXTING to their line number (see NEXT), where they will make changes to certain variables depending on certain other variables (depending on which routine is called), and RESUME back to the original program. As the system library is itself written in INTERCAL, there are some restrictions that need to be obeyed for calls to it to be guaranteed to work; none of the variables it uses (.1 to .6 and :1 to :5) should be read-only or overloaded (although the value of any variables that aren’t mentioned in the routine’s description will be preserved by the routine), and none of the lines in it should have their abstention status changed by lines outside it (this can happen with blatant infractions like DO ABSTAIN FROM (1500) or more subtle problems like gerund-abstention) or have COME FROMs or NEXT FROMs aiming at them.

The system library is currently available in all bases from 2 to 7 (see TriINTERCAL), but not every command is available in every base, and C-INTERCAL is the only one of the three compilers listed above that has the system library to ship with a version in bases other than 2. (This table was originally based on the INTERCAL-72 manual, but has had extra information added for bases other than 2.) Here, “overflow checked” means that #1 is assigned to .4 if there is not an overflow, and #2 is assigned to .4 if there is; “overflow captured” means that if there is overflow, the digit that overflowed is stored in the variable referenced. In all cases, division by 0 returns 0.

Line Description Bases
(1000) .3 <- .1 plus .2, error exit on overflow 2, 3, 4, 5, 6, 7
(1009) .3 <- .1 plus .2, overflow checked 2, 3, 4, 5, 6, 7
(1010) .3 <- .1 minus .2, no action on overflow 2, 3, 4, 5, 6, 7
(1020) .1 <- .1 plus #1, no action on overflow 2, 3, 4, 5, 6, 7
(1030) .3 <- .1 times .2, error exit on overflow 2, 3, 4, 5, 6, 7
(1039) .3 <- .1 times .2, overflow checked 2, 3, 4, 5, 6, 7
(1040) .3 <- .1 divided by .2 2, 3, 4, 5, 6, 7
(1050) .2 <- :1 divided by .1, error exit on overflow 2, 3, 4, 5, 6, 7
(1200) .2 <- .1 times #2, overflow captured in .3 4, 6
(1210) .2 <- .1 divided by #2, one digit after the quartic or sextic point stored in .3 4, 6
(1500) :3 <- :1 plus :2, error exit on overflow 2, 3, 4, 5, 6, 7
(1509) :3 <- :1 plus :2, overflow checked 2, 3, 4, 5, 6, 7
(1510) :3 <- :1 minus :2, no action on overflow 2, 3, 4, 5, 6, 7
(1520) :1 <- .1 concatenated with .2 2, 3, 4, 5, 6, 7
(1530) :1 <- .1 times .2 2, 3, 4, 5, 6, 7
(1540) :3 <- :1 times :2, error exit on overflow 2, 3, 4, 5, 6, 7
(1549) :3 <- :1 times :2, overflow checked 2, 3, 4, 5, 6, 7
(1550) :3 <- :1 divided by :2 2, 3, 4, 5, 6, 7
(1700) :2 <- :1 times #2, overflow captured in .1 4, 6
(1710) :2 <- :1 divided by #2, one digit after the quartic or sextic point stored in .1 4, 6
(1720) :2 <- :1 times the least significant digit of .1, overflow captured in .2 5, 7
(1900) .1 <- uniform random number from #0 to #65535 2, 3, 4, 5, 6, 7
(1910) .2 <- normal random number from #0 to .1, with standard deviation .1 divided by #12 2, 3, 4, 5, 6, 7

If you happen to be using base 2, and are either using the external call system (see External Calls) or are willing to use it, it is possible to use a version of the system library written in C for speed, rather than the default version (which is written in INTERCAL). To do this, use the command line options -eE (before the INTERCAL file), and syslibc (at the end of the command line).


Next: , Up: System Libraries   [Index]