home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / intercal.zip / doc / intercal.txt < prev    next >
Text File  |  1996-09-03  |  104KB  |  3,565 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.              TTHHEE IINNTTEERRCCAALL PPRROOGGRRAAMMMMIINNGG LLAANNGGUUAAGGEE
  8.                   RREEVVIISSEEDD RREEFFEERREENNCCEE MMAANNUUAALL
  9.  
  10.                       _D_o_n_a_l_d _R_. _W_o_o_d_s
  11.                             _a_n_d
  12.                        _J_a_m_e_s _M_. _L_y_o_n
  13.  
  14.                    _C_-_I_N_T_E_R_C_A_L _r_e_v_i_s_i_o_n_s_:
  15.                         _L_o_u_i_s _H_o_w_e_l_l
  16.                             _a_n_d
  17.                       _E_r_i_c _S_. _R_a_y_m_o_n_d
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.            _C_o_p_y_r_i_g_h_t _(_C_) _1_9_7_3 _b_y _D_o_n_a_l_d _R_. _W_o_o_d_s
  25.                      _a_n_d _J_a_m_e_s _M_. _L_y_o_n
  26.            _C_o_p_y_r_i_g_h_t _(_C_) _1_9_9_6 _b_y _E_r_i_c _S_. _R_a_y_m_o_n_d
  27.             _R_e_d_i_s_t_r_i_b_u_t_i_o_n _e_n_c_o_u_r_a_g_e_d _u_n_d_e_r _G_P_L
  28.  
  29.       _(_T_h_i_s _v_e_r_s_i_o_n _d_i_s_t_r_i_b_u_t_e_d _w_i_t_h _C_-_I_N_T_E_R_C_A_L _0_._1_5_)
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                             - 1 -
  71.  
  72.  
  73.  
  74. _1_.  _I_N_T_R_O_D_U_C_T_I_O_N
  75.  
  76. The  names  you  are  about to ignore are true. However, the
  77. story has been changed significantly. Any resemblance of the
  78. programming  language  portrayed  here  to other programming
  79. languages, living or dead, is purely coincidental.
  80.  
  81. _1_._1  _O_r_i_g_i_n _a_n_d _P_u_r_p_o_s_e
  82.  
  83. The INTERCAL programming language was designed  the  morning
  84. of  May  26,  1972  by Donald R. Woods and James M. Lyon, at
  85. Princeton University.  Exactly  when  in  the  morning  will
  86. become apparent in the course of this manual.
  87.  
  88. Eighteen  years  later  (give  or take a few months) Eric S.
  89. Raymond perpetrated a UNIX-hosted  INTERCAL  compiler  as  a
  90. weekend  hack.  The C-INTERCAL implementation has since been
  91. maintained and extended by  an  international  community  of
  92. technomasochists,  including  Louis  Howell,  Steve  Swales,
  93. Michael Ernst, and Brian Raiter.
  94.  
  95. (There  was  evidently  an  Atari  implementation   sometime
  96. between   these  two;  notes  on  it  got  appended  to  the
  97. INTERCAL-72 manual.  The culprits have sensibly declined  to
  98. identify themselves.)
  99.  
  100. INTERCAL  was  inspired  by one ambition: to have a compiler
  101. language which has nothing at all in common with  any  other
  102. major language. By 'major' was meant anything with which the
  103. authors were at all familiar, e.g., FORTRAN,  BASIC,  COBOL,
  104. ALGOL,  SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and
  105. PL/I. For the most part, INTERCAL has remained true to  this
  106. goal,  sharing  only  the  basic elements such as variables,
  107. arrays, and  the  ability  to  do  I/O,  and  eschewing  all
  108. conventional  operations other than the assignment statement
  109. (FORTRAN "=").
  110.  
  111. _1_._2  _A_c_r_o_n_y_m
  112.  
  113. The full name of the compiler is "Compiler Language With  No
  114. Pronounceable  Acronym",  which  is,  for  obvious  reasons,
  115. abbreviated "INTERCAL".
  116.  
  117. _1_._3  _A_c_k_n_o_w_l_e_d_g_m_e_n_t_s
  118.  
  119. The authors are deeply indebted to Eric M. Van and Daniel J.
  120. Warmenhoven,  without whose unwitting assistance this manual
  121. would still have been possible.
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                             - 2 -
  137.  
  138.  
  139.  
  140. _2_.  _F_U_N_D_A_M_E_N_T_A_L _C_O_N_C_E_P_T_S
  141.  
  142. In this section an attempt is made to describe how  and  why
  143. INTERCAL  may  be used; i.e., what it is like and what it is
  144. good for.
  145.  
  146. _2_._1  _S_a_m_p_l_e _P_r_o_g_r_a_m
  147.  
  148. Shown below is a relatively simple  INTERCAL  program  which
  149. will read in 32-bit unsigned integers, treat them as signed,
  150. 2's-complement numbers, and print out their absolute values.
  151. The  program  exits  if  the absolute value is zero. Note in
  152. particular the inversion routine (statements 6 through  14),
  153. which  could be greatly simplified if the subroutine library
  154. (see section 7) were used.
  155.  
  156. A more detailed analysis of a program is made in  section  8
  157. of this manual.
  158.  
  159.         DO (5) NEXT
  160.     (5) DO FORGET #1
  161.         PLEASE WRITE IN :1
  162.         DO .1 <- 'V-":1~'#32768c/#0'"c/#1'~#3
  163.         DO (1) NEXT
  164.         DO :1 <- "'V-":1~'#65535c/#0'"c/#65535'
  165.                 ~'#0c/#65535'"c/"'V-":1~'#0c/#65535'"
  166.                 c/#65535'~'#0c/#65535'"
  167.         DO :2 <- #1
  168.         PLEASE DO (4) NEXT
  169.     (4) DO FORGET #1
  170.         DO .1 <- "V-':1~:2'c/#1"~#3
  171.         DO :1 <- "'V-":1~'#65535c/#0'"c/":2~'#65535
  172.                 c/#0'"'~'#0c/#65535'"c/"'V-":1~'#0
  173.                 c/#65535'"c/":2~'#65535c/#0'"'~'#0c/#65535'"
  174.         DO (1) NEXT
  175.         DO :2 <- ":2~'#0c/#65535'"
  176.                 c/"'":2~'#65535c/#0'"c/#0'~'#32767c/#1'"
  177.         DO (4) NEXT
  178.     (2) DO RESUME .1
  179.     (1) PLEASE DO (2) NEXT
  180.         PLEASE FORGET #1
  181.         DO READ OUT :1
  182.         PLEASE DO .1 <- 'V-"':1~:1'~#1"c/#1'~#3
  183.         DO (3) NEXT
  184.         PLEASE DO (5) NEXT
  185.     (3) DO (2) NEXT
  186.         PLEASE GIVE UP
  187.  
  188. _2_._2  _U_s_e_s _f_o_r _I_N_T_E_R_C_A_L
  189.  
  190. INTERCAL's  main  advantage over other programming languages
  191. is its strict simplicity. It has few capabilities, and  thus
  192. there  are  few restrictions to be kept in mind. Since it is
  193. an exceedingly easy language to learn, one might  expect  it
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                             - 3 -
  203.  
  204.  
  205.  
  206. would  be a good language for initiating novice programmers.
  207. Perhaps surprising, than, is the fact that it would be  more
  208. likely  to  initiate a novice into a search for another line
  209. of work. As it turns out, INTERCAL  is  more  useful  (which
  210. isn't   saying   much)   as   a  challenge  to  professional
  211. programmers.  Those who doubt this need only refer  back  to
  212. the sample program in section 2.1. This 22-statement program
  213. took somewhere from 15 to 30 minutes to write,  whereas  the
  214. same objectives can be achieved by single-statement programs
  215. in either SNOBOL;
  216.  
  217.         PLEASE INPUT POS(0) ('-' ! '')
  218.         + (SPAN('0123456789') $ OUTPUT)
  219.         + *NE(OUTPUT) :S(PLEASE)F(END)
  220.  
  221. or APL;
  222.  
  223.         [1] ->0!=[]<-|[]
  224.  
  225. Admittedly, neither  of  these  is  likely  to  appear  more
  226. intelligible   to   anyone  unfamiliar  with  the  languages
  227. involved, but they took roughly 60 seconds and  15  seconds,
  228. respectively,  to  write.  Such is the overwhelming power of
  229. INTERCAL!
  230.  
  231. The other major importance of INTERCAL lies in its seemingly
  232. inexhaustible capacity for amazing one's fellow programmers,
  233. confounding programming shop managers, winning friends,  and
  234. influencing  people. It is a well-known and oft-demonstrated
  235. fact that a person whose work is incomprehensible is held in
  236. high  esteem.  For  example,  if  one were to state that the
  237. simplest way to store a value of 65536 in a 32-bit  INTERCAL
  238. variable is:
  239.  
  240.         DO :1 <- #0c/#256
  241.  
  242. any  sensible  programmer  would  say  that that was absurd.
  243. Since this is indeed the  simplest  method,  the  programmer
  244. would  be  made  to  look  foolish in front of his boss, who
  245. would of course happened to turn up, as bosses are  wont  to
  246. do.  The  effect  would  be  no  less  devastating  for  the
  247. programmer having been correct.
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                             - 4 -
  269.  
  270.  
  271.  
  272. _3_.  _D_E_S_C_R_I_P_T_I_O_N
  273.  
  274. The examples of INTERCAL programming which have appeared  in
  275. the  preceding  sections of this manual have probably seemed
  276. highly esoteric to the reader unfamiliar with the  language.
  277. With  the  aim  of  making  them  more so, we present here a
  278. description of INTERCAL.
  279.  
  280. _3_._1  _V_a_r_i_a_b_l_e_s
  281.  
  282. INTERCAL allows only 2 different  types  of  variables,  the
  283. 1166--bbiitt   iinntteeggeerr   and   the   3322--bbiitt  iinntteeggeerr..   These  are
  284. represented by a spot (.)  or  two-spot  (:),  respectively,
  285. followed  by  any  number  between  1  and 65535, inclusive.
  286. These variables may contain only non-negative numbers;  thus
  287. they  have the respective ranges of values: 0 to 65535 and 0
  288. to  4294967295.  Note:  .123  and  :123  are  two   distinct
  289. variables.  On  the  other hand, .1 and .0001 are identical.
  290. Furthermore, the latter may NOT be written as 1E-3.
  291.  
  292. _3_._2  _C_o_n_s_t_a_n_t_s
  293.  
  294. CCoonnssttaannttss are 16-bit values only and may  range  from  0  to
  295. 65535.  They  are  prefixed by a mesh (#). Caution! Under no
  296. circumstances confuse the mesh with the interleave operator,
  297. except under confusing circumstances!
  298.  
  299. _3_._3  _A_r_r_a_y_s
  300.  
  301. AArrrraayyss are represented by a tail (,) for 16-bit values, or a
  302. hybrid (;) for 32-bit values, followed by a number between 1
  303. and  65535,  inclusive.  The  number is suffixed by the word
  304. SUB, followed by the  subscripts,  separated  optionally  by
  305. spaces.  Subscripts  may be any expressions, including those
  306. involving subscripted variables. This occasionally leads  to
  307. ambiguous  constructions, which are resolved as discussed in
  308. section 3.4.3.   Definition  of  array  dimensions  will  be
  309. discussed  later  in  greater detail, since discussing it in
  310. less detail would be difficult. As before, ,123 and ;123 are
  311. distinct.   In summary, .123, :123, #123, ,123, and :123 are
  312. all distinct.
  313.  
  314. _3_._4  _O_p_e_r_a_t_o_r_s
  315.  
  316. INTERCAL recognizes 5 operators -- 2  binary  and  3  unary.
  317. Please  be  kind  to  our  operators:  they  may not be very
  318. intelligent, but they're all we've got.  In a sense,  all  5
  319. operators  are  binary, as they are all bit-oriented, but it
  320. is not our purpose here to quibble about bits of trivia.
  321.  
  322. _3_._4_._1  _B_i_n_a_r_y _O_p_e_r_a_t_o_r_s
  323.  
  324. The binary operators are iinntteerrlleeaavvee (also called mmiinnggllee) and
  325. sseelleecctt,  which are represented by a change (c/) and a sqiggle
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                             - 5 -
  335.  
  336.  
  337.  
  338. [sic]   (~),   respectively.    (In    C-INTERCAL'S    ASCII
  339. environment, EBCDIC c/ is replaced by a big money ($).)
  340.  
  341. The interleave operator takes two 16-bit values and produces
  342. a 32-bit result by alternating the  bits  of  the  operands.
  343. Thus,  #65535c/#0  has the 32-bit binary form 101010....10 or
  344. 2863311530 decimal, while #0c/#65535 =  0101....01  binary  =
  345. 1431655765 decimal, and #255c/#255 is equivalent to #65535.
  346.  
  347. The  select  operator takes from the first operand whichever
  348. bits correspond to 1's in  the  second  operand,  and  packs
  349. these  bits  to  the right in the result.  Both operands are
  350. automatically padded on the  left  with  zeros  to  32  bits
  351. before  the selection takes place, so the variable types are
  352. unrestricted.  If more than 16 bits are selected, the result
  353. is  a  32-bit  value,  otherwise  it  is a 16-bit value. For
  354. example, #179~#201 (binary value 10110011~11001001)  selects
  355. from the first argument the 8th, 7th, 4th, and 1st from last
  356. bits, namely, 1001, which = 9. But  #201~#179  selects  from
  357. binary  11001001  the  8th, 6th, 5th, 2nd, and 1st from last
  358. bits, giving 10001 = 17. #179~#179 has the value  31,  while
  359. #201~#201 has the value 15.
  360.  
  361. _3_._4_._1_._1  _R_e_t_u_r_n _t_y_p_e _o_f _S_E_L_E_C_T
  362.  
  363. INTERCAL-72 defined the return type of a SELECT operation to
  364. depend on the  number  of  bits  SELECTed.   The  C-INTERCAL
  365. compiler  takes the easier route of defining the return type
  366. to be that of the right operand, independent of  its  actual
  367. value.   This  form  has the advantage that all types can be
  368. determined at  compile  time.   Putting  in  run  time  type
  369. checking would add significant overhead and complication, to
  370. effect a very minor change in language semantics.
  371.  
  372. The only time this distinction makes any difference is  when
  373. a  unary  operator  is  applied  to the SELECT result.  This
  374. happens  extremely  rarely  in  practice,  the  only   known
  375. instance  being the 32-bit greater-than test in the standard
  376. library, where an XOR operator is applied to the  result  of
  377. SELECTing  a number against itself.  The INTERCAL-72 authors
  378. first SELECT the result against #65535c/#65535 to insure that
  379. XOR  sees  a  32-bit  value.  With the current compiler this
  380. extra step is unnecessary, but harmless.
  381.  
  382. The cautious programmer should  write  code  that  does  not
  383. depend  on  the  compiler  version being used.  We therefore
  384. suggest the following guideline for determining  the  SELECT
  385. return type:
  386.  
  387. A  SELECT  operation  with  a 16-bit right operand returns a
  388. 16-bit value.  The return type of a SELECT operation with  a
  389. 32-bit  right  operand is undefined, but is guaranteed to be
  390. an acceptable input to a MINGLE operation so long as  16  or
  391. fewer  bits  are actually selected.  Correct code should not
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                             - 6 -
  401.  
  402.  
  403.  
  404. depend on whether the return type is 16 or 32 bits.
  405.  
  406. Perhaps a simpler way of understanding the operation of  the
  407. select operator would be to examine the logic diagram on the
  408. following  page  (Figure  1),  which  performs  the   select
  409. operation upon two 8-bit values, A and B. The gates used are
  410. Warmenhovian logic gates, which means the outputs have  four
  411. possible   values:   low,   high,  undefined  (value  of  an
  412. uninitialized flip-flop), and oscillating (output of  a  NOR
  413. gate with one input low and the other input connected to the
  414. output). These values are represented symbolically  by  '0',
  415. '1',  '?', and 'O|'.  Note in particular that, while NOT-0 is
  416. 1 and NOT-1 is 0 as in two-valued  logic,  NOT-?  is  ?  and
  417. NOT-O| is O|. The functions of the various gates are listed in
  418. Table 1.
  419.  
  420. [Warning: The following picture will be garbled or  missing.
  421. Get a better output device.]
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                             - 7 -
  467.  
  468.  
  469.  
  470.  --+-+----     --+----  +--+----   --+----  +--+----
  471. A1   | | 1  +-+--+-+ 2  +-++-+ 3  ++-+-+ 3  ++|--+ 1  +--
  472. B --+++    | |--+-+    | || |    ||||++    |||| |    |       TO
  473. 1   +++------++-+-+------+|-+---  +++++-----++|-+---      ---NEW
  474.     +-------++-+---------+-------+++++-----+ |             YORK
  475.    +-+------++-+-+-----+ | +---- ||| +-----+ | +----        TO
  476. A2 --+-+    | || +-+    || --+    |+++-+    |+-+-+    |    ---NEW
  477.  --+-+ 1  +-++-+-+ 2  +++--+ 7  +-++-+ 3  +--+-+ 2  +--    YOTROK
  478. B2   |-+---   |||+-+---  || -+---   |+-+------++-+-------  ---NEW
  479.    +--------+++-+------++---------+--------+|+---------    YORK
  480.    +-+------+++-++-----++--+-----+| ++-----++--+-----+      TO
  481. A --+-+    | +++-++    |++--+    |++-++    ||+--+    || B ---NEW
  482. 3     | 1  +-+++-+| 2  +-++-+ 3  +-++++ 3  ++++-+ 3  ++-    YORK
  483. B3 --+-+---  ||||+++---  |||-+---  ++|++---  ||+++---  |      TO
  484.    +-------++++++------+++-------++++------++++------+-U ---NEW
  485.    +-+-----+++-+++-----+++-+-----+++||     ++++|     |     YORK
  486. A --+-+----|||| ||+----||++-+----||++++----|+++++----|| S    TO
  487. 4     | 1  +++++|++ 2  ++++-+ 7  ++++++ 3  ++++-+ 4  ++-  ---NEW
  488. B --+-+---  ||||+-+---  ||+-+---  |||++--- ++--++---  |     YOTROK
  489. 4   |       |||+++      ++--+ +---++++++++++|+-+------+   ---NEW
  490.    +-------+++-++-------++++-+--+||+++++++-++++--+         YORK
  491.  --+-+-----+++-+++-----+++++-+--+++-++++++ +++++-+--   L    TO
  492. A5     | 1  ++++++++ 2  ++++++ 3  +++ ++ 3  +-++++ 5  +--  ---NEW
  493. B --+-+    |||+++++    |  |||    ||| ||    |++++|    |      YORK
  494. 5   |-+---  |||||++-------|++----+|+--+-----+++++-------I    TO
  495.    +-------+++++--------++------++++ +---  |+++          ---NEW
  496.    +-+-----+++++-+-----+|| +----++++++-----+|||+----   N   YORK
  497. A6 --+-+    |||-++++    |+++-+    |+++++    | ++++    |       TO
  498.  --+-+ 1  +++-++++ 2  ++++-+ 3  +-++++ 4  ++++++ 4  +--  ---NEW
  499. B6   |-+---  +++++++---  +++-+-----+||++-----+++++-------E   YORK
  500.    +--------++++--------++------+|||       ++-+          ---TO
  501.    +-+------++++-+-----+|| +----++++++---- ||  +----       NEW
  502. A --+-+    | -+++-+    |+++-+    |+++++    ||+--+    |      YOTROK
  503. 7     | 1  +--+|+-+ 2  +-++-+ 3  ++|+++ 4  ++-+-+ 5  +--  ---NEW
  504. B7 --+-+---   ||++-+---   ||++---  || ++---  --+++---        YORK
  505.    +----+---++++--------+++------++ +------+-++------+-     TO
  506.    +-+--+---++++-+-------+||     |  ||     |  ||     |   ---NEW
  507. A --+-+----| |+++-+----|+-+++----|+--++----||+--+----||     YORK
  508. 8     | 1  +-+ |+-+ 2  ++ +++ 4  ++ +++ 3  ++++-+ 5  ++-8    TO
  509. B --+-+---     +--+---  |  ++---  | |++---  | |-+---  |   ---NEW
  510. 8   +----------------+  ++-+      +-++---+ ++-+------+|     YORK
  511.                     +--+++--------+||   +-++++------++-     TO
  512.      +----  +-+--+-----+++-+----  ++++----+|++-+----++-  ---NEW
  513.      | 6  +-+ +--+ 2  ++-+-+ 7  +-++-+ 3  +++|++ 4  ++-    YOTROK
  514.      |    |  -+--+    |+---+    |  | |    || |||    ||   --P-HILA-
  515.     -+---    |  -+---     -+---    |-+---  +-+++---  |   DELPHIA
  516.              +---------------------+---------+-------+-
  517.      +----   |+--+---------+------++-+-----+   +----
  518.      |    |  ++--+    |  +-+    | |--+    ||+--+    |
  519.      | 6  +--++--+ 1  +-++-+ 1  +-+--+ 1  +++--+ 1  ++
  520.     -+---       -+--- --++-+---   | -+---  |  -+-----+-
  521.                         ---                         ---
  522.                 FIGURE 1. CIRCUITOUS DIAGRAM
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                             - 8 -
  533.  
  534.  
  535.  
  536.    __________________________________________________________
  537.   |\                                                         \
  538.   | \ 1. Logic gate.  Inputs A, B.  Output O = AB.            \
  539.   |  \                                                         \
  540.   | \ \ 2. Logic gate.  Inputs A, B, C.  Output O = A+BC.       \
  541.   | |\ \                                                         \
  542.   | | \ \ 3. Logic gate.  Inputs A, B.  Output O = A+AB.          \
  543.   | |  \ \                                                         \
  544.   | |  |\ \ 4. Logic gate.  Inputs A, B.  Output O = AB O+ -(A+-B)   \
  545.   | |  | \ \                                                         \
  546.   | |  |  \ \ 5. Logic gate.  Inputs A, B.  Output O = AO+A + AA       \
  547.   | |  |   \ \                                                         \
  548.   | |  |    \ \ 6. Uninitialized flip-flop.  Inputs none.  Output O = ? \
  549.   | |  |     \ \                                                         \
  550.   | |  |      \ \ 7. Flip-flop-flap.  Inputs A, B, C.  Output O = 1 if    \
  551.   | |  |       \ \    A=0 or B+C=0 and A=1.  O = 0 if AC=1, B=0.  O = O| if \
  552.   | |  |        \ \    AB=1, C=0.  O = ? if ABC=1.  O as yet undetermined   \
  553.   | |  |         \ \    for other Warmenhovian inputs.  See Figure 2.        \
  554.   | |  |          \ \                                                         \
  555.   | |  |           \ \ 8. Bus line.                                            \
  556.   | |  |            \ \_________________________________________________________\
  557.   | |  |             \ |                                                         |
  558.   | |  |             | |  _____________________________________________________  |
  559.   | |  |             | |  |                              | |  |             | |  |
  560.   | |  |             | |  |                              | |  |             | |  |
  561.   | |  |             | |  |                              | |  |             | |  |
  562.   | |  |             | |  |                              | |  |             | |  |
  563.   | |  |             | |  |                              | |  |             | |  |
  564.    \|__|             | |  |                               \|__|             | |  |
  565.                      | |  |                                                 | |  |
  566.                      | |  |                                                 | |  |
  567.                      | |  |                                                 | |  |
  568.                      | |  |                                                 | |  |
  569.                      | |  |                                                 | |  |
  570.                      | |  |                                                 | |  |
  571.                      | |  |                                                 | |  |
  572.                      | |  |                                                 | |  |
  573.                      | |  |                                                 | |  |
  574.                      | |  |                                                 | |  |
  575.                      | |  |                                                 | |  |
  576.                      | |  |                                                 | |  |
  577.                      | |  |                                                 | |  |
  578.                      | |  |                                                 | |  |
  579.                      | |  |                                                 | |  |
  580.                      | |  |                                                 | |  |
  581.                      | |  |                                                 | |  |
  582.                      | |  |                                                 | |  |
  583.                       \|__|                                                  \|__|
  584.  
  585.           Table 1.  Logical (and other) functions.
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                             - 9 -
  599.  
  600.  
  601.  
  602. [Warning:  The following picture will be garbled or missing.
  603. Get a better output device.]
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614. -------------------------+----
  615. A                     +---+    |----+------------D
  616.                      |   |    |    |
  617.                          +----
  618.  
  619.  
  620.  
  621.                      |   |            |
  622.                      +---+----        |
  623. B-------------------------+    |----+  |
  624.                          +----|    |  |
  625.                                    |  |
  626.                                    |  |
  627.                                    |  |
  628.                                    |  |
  629.                          |         |  |
  630. C-------------------------+----|    |  |
  631.         +----------------+    |--+ |  |
  632.         |                +----   | |  |
  633.         |                        | |  |
  634.         |                             |
  635.         |                             |
  636.         |                             |
  637.         |            | | |            |
  638.         |            | +-+----|       |
  639.         |            +---+ +- +-------+
  640.         |                +-+--
  641.   1-----+
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.                   FIGURE 2. FLIP FLAP FLOP
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                            - 10 -
  665.  
  666.  
  667.  
  668. [Warning: The following picture will be garbled or  missing.
  669. Get a better output device.]
  670.  
  671. -----
  672. -----   -----
  673. -----
  674. -----   -----
  675.  
  676. -----   -----
  677. -----
  678. -----   -----
  679. -----                         GATE TYPE 9.  BLACK BOX
  680. ----- 9 -----                 INPUTS A1-8,  B1-8.
  681. -----                         OUTPUT D1-8 = A1-8~B1=8
  682. -----   -----
  683. -----
  684. -----   -----
  685.  
  686. -----   -----
  687. -----
  688. -----   -----
  689. -----
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.               FIGURE 1  (CONTINUED).  NEW YORK
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                            - 11 -
  731.  
  732.  
  733.  
  734. _3_._4_._2  _U_n_a_r_y _O_p_e_r_a_t_o_r_s
  735.  
  736. The unary operators are & (logical AANNDD), V (logical OORR), and
  737. V-  (logical  XXOORR).  This  last  character  is  obtained   by
  738. overpunching  a worm (-) on a V (V).  (In C-INTERCAL'S ASCII
  739. environment, EBCDIC V- is  replaced  by  the  what  (?).  The
  740. compiler  recognizes -<backspace>V as a valid equivalent, in
  741. case  you  are  concerned  about  compatibility   with   the
  742. Princeton  compiler.   The  operator is inserted between the
  743. spot, two-spot, mesh, or  what-have-you,  and  the  integer,
  744. thus:  .&123,  #V-123.  Multiple  unary  operators may not be
  745. concatenated, thus the form #V-&123 is invalid. This will  be
  746. covered  later when precedence is discussed. These operators
  747. perform their respective logical operations on all pairs  of
  748. adjacent bits, the result from the first and last bits going
  749. into the first bit of the result.  The  effect  is  that  of
  750. rotating  the  operand  one  place  to the right and ANDing,
  751. ORing, or XORing with its initial value. Thus, #&77  (binary
  752. =  1001101)  is  binary 0000000000000100 = 4, #V77 is binary
  753. 1000000001101111   =   32879,    and    #V-77    is    binary
  754. 1000000001101011 = 32875.
  755.  
  756. _3_._4_._3  _P_r_e_c_e_d_e_n_c_e
  757.  
  758. Precedence of operators is as follows:
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769. (The remainder of this page intentionally left blank)1
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785. ____________________
  786.  
  787. 1. Keep  in  mind  that the aim in designing INTERCAL was to
  788.    have no precedents.
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                            - 12 -
  797.  
  798.  
  799.  
  800. This precedence  (or  lack  thereof)  may  be  overruled  by
  801. grouping  expressions between pairs of sparks (') or rabbit-
  802. ears    (").    Thus    '#165c/#203'~#358    (binary    value
  803. '10100101c/11001011'~101100110)   has   the   value  15,  but
  804. #165c/'#203~#358' has the value 34915, and #165c/#203~#358  is
  805. invalid  syntax  and is completely valueless (except perhaps
  806. as an educational tool to the programmer). A unary  operator
  807. is  applied  to  a  sparked  or  rabbit-eared  expression by
  808. inserting the operator  immediately  following  the  opening
  809. spark  or  ears.  Thus, the invalid expression #V-&123, which
  810. was  described  earlier,  could  be  coded  as  'V-#&123'  or
  811. 'V-"{"'.   Note:  In  the  interests  of  simplifying the
  812. sometimes  overly-complex  form  of  expressions,   INTERCAL
  813. allows  a  spark-spot combination ('.) to be replaced with a
  814. wow (!). Thus '.1~.2' is equivalent to !1~.2', and  'V.1c/.2'
  815. is equivalent to "V!1c/.2'".
  816.  
  817. Combining  a rabbit-ears with a spot to form a rabbit (".) is
  818. not permitted, although the programmer is  free  to  use  it
  819. should   he  find  an  EBCDIC  reader  which  will  properly
  820. translate a 12-3-7-8 punch.
  821.  
  822. Sparks and/or rabbit-ears must also be used  to  distinguish
  823. among  such  otherwise  ambiguous  subscripted and multiply-
  824. subscripted expressions as:
  825.  
  826.         ,1 SUB #1 ~ #2
  827.         ,1 SUB ,2 SUB #1 #2 #3
  828.         ,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 "
  829.  
  830. The third case may be isolated into either of  its  possible
  831. interpretations by simply changing some pairs of rabbit-ears
  832. to sparks, instead of adding more  ears  (which  would  only
  833. confuse  the  issue further). Ambiguous cases are defined as
  834. those for which the compiler being used finds  a  legitimate
  835. interpretation  which  is different from that which the user
  836. had in mind. See also section 12.
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.                            - 13 -
  863.  
  864.  
  865.  
  866. _4_.  _S_T_A_T_E_M_E_N_T_S
  867.  
  868. In  this  section  is  described  the  format  of   INTERCAL
  869. statements.
  870.  
  871. _4_._1  _G_e_n_e_r_a_l _F_o_r_m_a_t
  872.  
  873. Statements  may  be  entered in 'free format'. That is, more
  874. than one statement  may  occur  on  a  single  card,  and  a
  875. statement may begin on one card and end on a later one. Note
  876. that if this is done, all  intervening  cards  and  portions
  877. thereof  must  be  part  of  the  same  statement. That this
  878. restriction is necessary is immediately  apparent  from  the
  879. following example of what might occur if statements could be
  880. interlaced.
  881.  
  882.         DO .1 <- ".1c/'&:51~"#V-1c!12~;&75SUB"V-'V.1~
  883.         DO .2 <- '"!1c/"&';V-79SUB",&7SUB:173"'~!V-9c/
  884.         .2'c/,&1SUB:5~#33578"'"'"~'#65535c/"V-'V#&85'"'
  885.         #8196'"'~.1"c/.2'~'#&5c/"'#1279c/#4351'~#65535"'
  886.  
  887. The above statements are obviously  meaningless.  (For  that
  888. matter, so are the statements
  889.  
  890.         DO .1 <- ".1c/"&:51~"#V-1c/!12~;&75SUB"V-'V.1~
  891.         .2'c/,&1SUB:5~#333578"'"'"~#65535c/"V-'V#&85'"'
  892.         DO .2 <- '"!1c/"&';V-79SUB",&7SUB:173"'~!V-9c/
  893.         #8196'"'~.1"c/.2'~'#&5c/"'#1279c/#4351'~#65535"'
  894.  
  895. but this is not of interest here.)
  896.  
  897. Spaces  may be used freely to enhance program legibility (or
  898. at least reduce program illegibility), with the  restriction
  899. that no word of a statement identifier (see section 4.3) may
  900. contain any spaces.
  901.  
  902. _4_._2  _L_a_b_e_l_s
  903.  
  904. A statement may begin with a llooggiiccaall lliinnee llaabbeell enclosed  in
  905. wax-wane  pairs (()). A statement may not have more than one
  906. label, although it is possible to omit the label entirely. A
  907. line  label  is  any  integer from 1 to 65535, which must be
  908. unique within each program. The user is cautioned,  however,
  909. that  many line labels between 1000 and 1999 are used in the
  910. INTERCAL System Library functions.
  911.  
  912. _4_._3  _I_d_e_n_t_i_f_i_e_r_s _a_n_d _Q_u_a_l_i_f_i_e_r_s
  913.  
  914. After the line label  (if  any),  must  follow  one  of  the
  915. following  statement  identifiers: DO, PLEASE, or PLEASE DO.
  916. These may be used interchangeably to improve the  aesthetics
  917. of  the  program. The identifier is then followed by either,
  918. neither,  or  both  of  the  following  optional  parameters
  919. (qualifiers):  (1)  either  of  the character strings NOT or
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                            - 14 -
  929.  
  930.  
  931.  
  932. N'T,  which  causes  the  statement  to   be   automatically
  933. abstained  from  (see  section 4.4.9) when execution begins,
  934. and (2) a number between 0 and 100, preceded by a double-oh-
  935. seven  (%),  which  causes  the  statement  to have only the
  936. specified percent chance of being executed each time  it  is
  937. encountered in the course of execution.
  938.  
  939. _4_._4  _S_t_a_t_e_m_e_n_t_s
  940.  
  941. Following   the  qualifiers  (or,  if  none  are  used,  the
  942. identifier) must occur  one  of  the  13  valid  operations.
  943. (Exception:   see   section   4.5.)   These   are  described
  944. individually in sections 4.4.1 through 4.4.14.2.
  945.  
  946. _4_._4_._1  _C_a_l_c_u_l_a_t_e
  947.  
  948. The INTERCAL equivalent of the  half-mesh  (=)  in  FORTRAN,
  949. BASIC,  PL/I,  and  others,  is  represented by an angle (<)
  950. followed by a worm (-). This  combination  is  read  'gets'.
  951. 32-bit  variables  may  be assigned 16-bit values, which are
  952. padded on the left with 16 zero bits. 16-bit  variables  may
  953. be  assigned  32-bit  values  only if the value is less than
  954. 65535. Thus, to invert the  least  significant  bit  of  the
  955. first  element  of  16-bit 2-dimensional array number 1, one
  956. could write:
  957.  
  958. ,1SUB#1#1 <- 'V-,1SUB#1#1c/#1'~'#0c/#65535'
  959.  
  960. Similarly to SNOBOL and SPITBOL, INTERCAL  uses  the  angle-
  961. worm  to  define  the  dimensions of arrays. An example will
  962. probably best describe the format.  To define  32-bit  array
  963. number  7 as 3-dimensional, the first dimension being seven,
  964. the second being the current value of 16-bit variable number
  965. seven,  and the third being the current value of the seventh
  966. element  of  16-bit  array  number  seven  (which  is   one-
  967. dimensional)  mingled  with  the  last  three bits of 32-bit
  968. variable number seven, one would  write  (just  before  they
  969. came to take him away):
  970.  
  971. ;7 <- #7 BY .7 BY ",7SUB#7"c/':7~#7'
  972.  
  973. This is, of course, different from the statement:
  974.  
  975. ;7 <- #7 BY .7 BY ,7SUB"#7c/':7~#7'"
  976.  
  977. INTERCAL  also permits the redefining of array dimensioning,
  978. which is done the same way as is the  initial  dimensioning.
  979. All   values   of   items   in   an   array  are  lost  upon
  980. redimensioning, unless they have been STASHed  (see  section
  981. 4.4.5),  in  which case restoring them also restores the old
  982. dimensions.
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.                            - 15 -
  995.  
  996.  
  997.  
  998. _4_._4_._2  _N_E_X_T
  999.  
  1000. The NEXT statement is used both for subroutine calls and for
  1001. unconditional transfers. This statement takes the form:
  1002.  
  1003. DO (label) NEXT
  1004.  
  1005. (or, of course,
  1006.  
  1007. PLEASE DO (label) NEXT
  1008.  
  1009. etc.), where (label) represents any logical line label which
  1010. appears in the program. The effect of such a statement is to
  1011. transfer control to the statement specified, and to store in
  1012. a push down list (which is  initially  empty)  the  location
  1013. from  which  the  transfer takes place. Items may be removed
  1014. from this list and may be discarded or used to return to the
  1015. statement  immediately  following  the NEXT statement. These
  1016. operations  are  described  in  sections  4.4.3  and   4.4.4
  1017. respectively. The programmer is generally advised to discard
  1018. any stack entries which he does not intend to utilize, since
  1019. the  stack  has  a  maximum depth of 79 entries. A program's
  1020. attempting to initiate an 80th level of NEXTing will  result
  1021. in  the  fatal  error message, "PROGRAM HAS DISAPPEARED INTO
  1022. THE BLACK LAGOON."
  1023.  
  1024. _4_._4_._3  _F_O_R_G_E_T
  1025.  
  1026. The statement PLEASE FORGET exp, where  exp  represents  any
  1027. expression   (except  colloquial  and  facial  expressions),
  1028. causes the expression to be  evaluated,  and  the  specified
  1029. number  of  entries to be removed from the NEXTing stack and
  1030. discarded. An attempt to FORGET more levels of NEXTing  than
  1031. are  currently  stacked  will cause the stack to be emptied,
  1032. and no error condition is indicated.  This  is  because  the
  1033. condition  is not considered to be an error. As described in
  1034. section 4.4.2, it is good programming practice to execute  a
  1035. DO   FORGET   #1   after   using  a  NEXT  statement  as  an
  1036. unconditional transfer, so  that  the  stack  does  not  get
  1037. cluttered up with unused entries:
  1038.  
  1039.         DO (123) NEXT
  1040.         .
  1041.         .
  1042.   (123) DO FORGET #1
  1043.  
  1044. _4_._4_._4  _R_E_S_U_M_E
  1045.  
  1046. The  statement  PLEASE  RESUME  exp  has  the same effect as
  1047. FORGET, except that  program  control  is  returned  to  the
  1048. statement  immediately  following  the  NEXT statement which
  1049. stored in the stack the last entry to be removed. Note  that
  1050. a  rough  equivalent of the FORTRAN computed GO TO and BASIC
  1051. ON exp GO TO is performed by a sequence of the form:
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                            - 16 -
  1061.  
  1062.  
  1063.  
  1064.         DO (1) NEXT
  1065.         .
  1066.         .
  1067.     (1) DO (2) NEXT
  1068.         PLEASE FORGET #1
  1069.         .
  1070.         .
  1071.     (2) DO RESUME .1
  1072.  
  1073. Unlike the FORGET  statement,  an  attempt  to  RESUME  more
  1074. levels  of  NEXTing  than  been  stacked  will cause program
  1075. termination. See also section 4.4.11.
  1076.  
  1077. _4_._4_._5  _S_T_A_S_H
  1078.  
  1079. Since  subroutines  are  not   explicitly   implemented   in
  1080. INTERCAL,  the  NEXT  and  RESUME statements must be used to
  1081. execute common routines. However, as  these  routines  might
  1082. use  the same variables as the main program, it is necessary
  1083. for them to save the values of any  variables  whose  values
  1084. they   alter,  and  later  restore  them.  This  process  is
  1085. simplified by the STASH statement, which  has  the  form  DO
  1086. STASH  list,  where  list represents a string of one or more
  1087. variable or array names,  separated  by  intersections  (+).
  1088. Thus
  1089.  
  1090. PLEASE STASH .123+:123+,123
  1091.  
  1092. stashes  the  values  of two variables and one entire array.
  1093. The values are left intact, and copies thereof are saved for
  1094. later retrieval by (what else?)  the RETRIEVE statement (see
  1095. section 4.4.6). It is not possible  to  STASH  single  array
  1096. items.
  1097.  
  1098. _4_._4_._6  _R_E_T_R_I_E_V_E
  1099.  
  1100. PLEASE  RETRIEVE list restores the previously STASHed values
  1101. of the variables and arrays named in the list.  If  a  value
  1102. has  been  stashed more than once, the most recently STASHed
  1103. values are RETRIEVEd, and a second RETRIEVE will restore the
  1104. second  most recent values STASHed. Attempting to RETRIEVE a
  1105. value which has not been STASHed will result  in  the  error
  1106. message, "THROW STICK BEFORE RETRIEVING."
  1107.  
  1108. _4_._4_._7  _I_G_N_O_R_E
  1109.  
  1110. The   statement   DO   IGNORE  list  causes  all  subsequent
  1111. statements to have no effect upon  variables  and/or  arrays
  1112. named in the list. Thus, for example, after the sequence
  1113.  
  1114.         DO .1 <- #1
  1115.         PLEASE IGNORE .1
  1116.         DO .1 <- #0
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.                            - 17 -
  1127.  
  1128.  
  1129.  
  1130. 16-bit  variable  number  1  would  have the value 1, not 0.
  1131. Inputting (see section 4.4.12) into an IGNOREd variable also
  1132. has  no  effect.  The condition is annulled via the REMEMBER
  1133. statement (see section 4.4.8). Note that, when a variable is
  1134. being   IGNOREd,  its  value,  though  immutable,  is  still
  1135. available for use in expressions and the like.
  1136.  
  1137. Though the INTERCAL-72 manual laid down that the value of an
  1138. IGNOREd variable cannot change, it was unclear about whether
  1139. or not a  statement  which  appears  to  change  an  IGNOREd
  1140. variable  is executed or not.  This may appear to be a "If a
  1141. tree falls in the forest..." type of question,  but  if  the
  1142. statement in question has other side effects it is not.
  1143.  
  1144. Since another mechanism already exists for ABSTAINing from a
  1145. statement, C-INTERCAL's IGNORE only prevents the changing of
  1146. the  specific variable in question, not the execution of the
  1147. entire statement.  In the present version  of  the  language
  1148. this  only  makes  a  difference for the WRITE IN statement.
  1149. Attempting to WRITE IN to an IGNOREd variable will  cause  a
  1150. number  to  be  read from the input, which will be discarded
  1151. since it cannot be stored in the variable.
  1152.  
  1153. _4_._4_._8  _R_E_M_E_M_B_E_R
  1154.  
  1155. PLEASE REMEMBER list terminates the  effect  of  the  IGNORE
  1156. statement for all variables and/or arrays named in the list.
  1157. It does not matter if a variable has been IGNOREd more  than
  1158. once,  nor  is  it  an  error  if  the variable has not been
  1159. IGNOREd at all.
  1160.  
  1161. _4_._4_._9  _A_B_S_T_A_I_N
  1162.  
  1163. INTERCAL contains no simple equivalent to an IF statement or
  1164. computed  GO  TO,  making  it  difficult  to combine similar
  1165. sections of code into a single  routine  which  occasionally
  1166. skips  around  certain statements. The IGNORE statement (see
  1167. section 4.4.7) is helpful in some cases, but a  more  viable
  1168. method  is  often  required.  In  keeping  with  the goal of
  1169. INTERCAL having nothing in common with any  other  language,
  1170. this is made possible via the ABSTAIN statement.
  1171.  
  1172. This statement takes on one of two forms. It may not take on
  1173. both at any one time. DO ABSTAIN  FROM  (label)  causes  the
  1174. statement   whose  logical  line  label  is  (label)  to  be
  1175. abstained from. PLEASE ABSTAIN FROM gerund list  causes  all
  1176. statements of the specified type(s) to be abstained from, as
  1177. in
  1178.  
  1179.         PLEASE ABSTAIN FROM STASHING
  1180.         PLEASE ABSTAIN FROM IGNORING + FORGETTING
  1181.         PLEASE ABSTAIN FROM NEXTING
  1182.      or PLEASE ABSTAIN FROM CALCULATING
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                            - 18 -
  1193.  
  1194.  
  1195.  
  1196. Statements may also be automatically abstained from  at  the
  1197. start of execution via the NOT or N'T parameter (see section
  1198. 4.3).
  1199.  
  1200. If, in the course of execution, a statement  is  encountered
  1201. which  is  being  abstained  from, it is ignored and control
  1202. passes to the next statement in the program (unless it, too,
  1203. is being abstained from).
  1204.  
  1205. The statement DO ABSTAIN FROM ABSTAINING is perfectly valid,
  1206. as is DO ABSTAIN FROM REINSTATING (although this  latter  is
  1207. not  usually recommended). However, the statement DO ABSTAIN
  1208. FROM GIVING UP is not accepted, even though  DON'T  GIVE  UP
  1209. is.
  1210.  
  1211. _4_._4_._1_0  _R_E_I_N_S_T_A_T_E
  1212.  
  1213. The  REINSTATE  statement,  like  the  ABSTAIN,  takes as an
  1214. argument either a line label or a gerund list. No other form
  1215. of  argument  is permitted. For example, the following is an
  1216. invalid argument:
  1217.  
  1218.         Given: x!=0, y!=0,  Prove: x+y=0
  1219.         Since x!=0, then x+1!=1, x+a!=a, x+y!=y.
  1220.         But what is y? y is anything but 0.
  1221.         Thus x+y != anything but 0.
  1222.         Since x+y cannot equal anything but 0, x+y=0.
  1223.                                                          Q.E.D.
  1224.  
  1225. REINSTATEment nullifies the effects of an abstention. Either
  1226. form  of  REINSTATEment  can  be used to "free" a statement,
  1227. regardless of whether the statement was  abstained  from  by
  1228. gerund  list,  line  label,  or  NOT. Thus, PLEASE REINSTATE
  1229. REINSTATING is  not  necessarily  an  irrelevant  statement,
  1230. since it might free a DON'T REINSTATE command or a REINSTATE
  1231. the line label of which  was  abstained  from.  However,  DO
  1232. REINSTATE  GIVING UP is invalid, and attempting to REINSTATE
  1233. a GIVE UP statement by line label will have no effect.  Note
  1234. that  this  insures that DON'T GIVE UP will always be a "do-
  1235. nothing" statement.
  1236.  
  1237. _4_._4_._1_1  _G_I_V_E _U_P
  1238.  
  1239. PLEASE GIVE UP is used to exit from a program.  It  has  the
  1240. effect  of  a  PLEASE RESUME #80. DON'T GIVE UP, as noted in
  1241. section 4.4.10, is effectively a null statement.
  1242.  
  1243. _4_._4_._1_2  _I_n_p_u_t
  1244.  
  1245. Input is accomplished with the statement DO WRITE  IN  list,
  1246. where  list represents a string of variables and/or elements
  1247. or  arrays,  separated   by   intersections.   Numbers   are
  1248. represented  on  cards,  each  number on a separate card, by
  1249. spelling out each digit  (in  English)  and  separating  the
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.                            - 19 -
  1259.  
  1260.  
  1261.  
  1262. digits with one or more spaces. A zero (0) may be spelled as
  1263. either ZERO or OH.  Thus the range of (32-bit) input  values
  1264. permissible  extends from ZERO (or OH) through FOUR TWO NINE
  1265. FOUR NINE SIX SEVEN TWO NINE FIVE.  (For the convenience  of
  1266. aviators,  C-INTERCAL  accepts  the spelling NINER for NINE.
  1267. In the  service  of  internationalization,  C-INTERCAL  also
  1268. accepts input digits in Sanskrit, Basque, Tagalog, Classical
  1269. Nahuatl, Georgian, Kwakiutl, and Volapuk.
  1270.  
  1271. Attempting to write in a value greater than or equal to  SIX
  1272. FIVE FIVE THREE SIX for a 16-bit variable will result in the
  1273. error message, "DON'T BYTE OFF MORE THAN YOU CAN CHEW."
  1274.  
  1275. _4_._4_._1_3  _O_u_t_p_u_t
  1276.  
  1277. Values may be output to the printer, one value per line, via
  1278. the  statement  DO  READ  OUT  list, where the list contains
  1279. variables, array elements, and/or constants.  Output  is  in
  1280. the   form   of   "extended"  Roman  numerals  (also  called
  1281. "butchered" Roman numerals), with an overline indicating the
  1282. value   below   is  "times  1000",  and  lower-case  letters
  1283. indicating "times 1000000". Zero is indicated by an overline
  1284. with  no  character  underneath. Thus, the range of (32-bit)
  1285. output values possible is from
  1286. _
  1287.  
  1288. through
  1289. __      ____________
  1290. ivccxcivCMLXVIICCXCV.
  1291. Note: For values whose residues modulo 1000000 are less than
  1292. 4000, M is used to represent 1000; for values whose residues
  1293. are 4000 or greater,
  1294. _
  1295. I
  1296. is used. Thus #3999 would read  out  as  MMMCMXCIX  2  while
  1297. #4000 would readout as
  1298. __
  1299. IV
  1300. Similar rules apply to the use of
  1301. _
  1302. M
  1303. and i for 1000000, and to that of m and
  1304. _
  1305. i
  1306. for 1000000000.
  1307.  
  1308.  
  1309.  
  1310.  
  1311. ____________________
  1312.  
  1313. 2. The original INTERCAL-72 manual claimed that #3999 should
  1314.    render as MMMIM, but the C-INTERCAL developers have  been
  1315.    unable  to  find  an  algorithm  that  does  this  and is
  1316.    consistent with the rest of the rules.
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.                            - 20 -
  1325.  
  1326.  
  1327.  
  1328. _4_._4_._1_4  _C_O_M_E _F_R_O_M
  1329.  
  1330. In which we try to precisely define a statement that  should
  1331. never  have  been  born, but is nevertheless one of the more
  1332. useful statements in INTERCAL.
  1333.  
  1334. _4_._4_._1_4_._1  _B_a_c_k_g_r_o_u_n_d
  1335.  
  1336. The earliest known description of the COME FROM statement in
  1337. the  computing  literature is in [R. L. Clark, "A linguistic
  1338. contribution  to  GOTO-less  programming,"  Commun.  ACM  27
  1339. (1984),  pp. 349--350], part of the famous April Fools issue
  1340. of CACM.  The  subsequent  rush  by  language  designers  to
  1341. include  the statement in their languages was underwhelming,
  1342. one might even say nonexistent.  It  was  therefore  decided
  1343. that  COME  FROM  would  be  an  appropriate  addition to C-
  1344. INTERCAL.
  1345.  
  1346. _4_._4_._1_4_._2  _D_e_s_c_r_i_p_t_i_o_n
  1347.  
  1348. There are two useful ways to visualize  the  action  of  the
  1349. COME  FROM  statement.   The  simpler is to see that it acts
  1350. like a GOTO when the program is traced  backwards  in  time.
  1351. More precisely, the statements
  1352.  
  1353. (1)     DO <any statement>
  1354.         .
  1355.         .
  1356.         .
  1357. (2)     DO COME FROM (1)
  1358.  
  1359. should be thought of as being equivalent to
  1360.  
  1361. (1)     DO <any statement>
  1362. (2)     DO GOTO (3)
  1363.         .
  1364.         .
  1365.         .
  1366. (3)     DO NOTHING
  1367.  
  1368. if  INTERCAL  actually had a GOTO statement at all, which of
  1369. course it doesn't.
  1370.  
  1371. What this boils down to is that the statement DO  COME  FROM
  1372. (label), anywhere in the program, places a kind of invisible
  1373. trap door immediately after statement (label).  Execution or
  1374. abstention  of  that statement is immediately followed by an
  1375. unconditional jump to the COME FROM,  unless  the  (label)ed
  1376. statement is an executed NEXT, in which case the jump occurs
  1377. if  the  program  attempts  to  RESUME  back  to  that  NEXT
  1378. statement.   It  is  an error for more than one COME FROM to
  1379. refer to the same (label).
  1380.  
  1381. Modification of the target statement by ABSTAIN or by the  %
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.                            - 21 -
  1391.  
  1392.  
  1393.  
  1394. qualifier  affects  only  that statement, not the subsequent
  1395. jump.  Such modifications to the COME FROM itself,  however,
  1396. do  affect  the  jump.  Encountering the COME FROM statement
  1397. itself, rather than its target, has no effect.
  1398.  
  1399. _4_._5  _C_o_m_m_e_n_t_s
  1400.  
  1401. Unrecognizable  statements,  as  noted  in  section  9,  are
  1402. flagged  with  a  splat  (*) during compilation, and are not
  1403. considered fatal errors unless they are  encountered  during
  1404. execution,   at  which  time  the  statement  (as  input  at
  1405. compilation time) is printed and  execution  is  terminated.
  1406. This  allows  for an interesting (and, by necessity, unique)
  1407. means of including comments  in  an  INTERCAL  listing.  For
  1408. example, the statement:
  1409.  
  1410. *       PLEASE NOTE THAT THIS LINE HAS NO EFFECT
  1411.  
  1412. will be ignored during execution due to the inclusion of the
  1413. NOT qualifier.  User-supplied error messages are  also  easy
  1414. to implement:
  1415.  
  1416. *       DO SOMETHING ABOUT OVERFLOW IN ;3
  1417.  
  1418. as are certain simple conditional errors:
  1419.  
  1420. * (123) DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED
  1421.                 ONCE?
  1422.         PLEASE REINSTATE (123)
  1423.  
  1424. This  pair of statements will cause an error exit the second
  1425. time they are encountered. Caution!!  The  appearance  of  a
  1426. statement identifier in an intended comment will be taken as
  1427. the beginning of a new statement. Thus, the first example on
  1428. the preceding page could not have been:
  1429.  
  1430. *       PLEASE NOTE THAT THIS LINE DOES NOTHING
  1431.  
  1432. The third example, however, is valid, despite the appearance
  1433. of two cases of D-space-O, since INTERCAL  does  not  ignore
  1434. extraneous spaces in statement identifiers.
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.                            - 22 -
  1457.  
  1458.  
  1459.  
  1460. _5_.  _O_U_T_S_I_D_E _C_O_M_M_U_N_I_C_A_T_I_O_N
  1461.  
  1462. In  which  we  try  to  remedy  the  fact  that,  due to I/O
  1463. limitations, INTERCAL can not even in principle perform  the
  1464. same  tasks  as  other  languages.   It  is  hoped that this
  1465. addition will permit INTERCAL users to waste vast quantities
  1466. of computer time well into the 21st century.
  1467.  
  1468. _5_._1  _M_o_t_i_v_a_t_i_o_n
  1469.  
  1470. One  of  the  goals  of  INTERCAL  was to provide a language
  1471. which,  though  different  from  all  other  languages,   is
  1472. nevertheless  theoretically  capable  of all the same tasks.
  1473. INTERCAL-72  failed  to  accomplish  this  because  its  I/O
  1474. functions  could  not  handle  arbitrary streams of bits, or
  1475. even arbitrary sequences of characters.   A  language  which
  1476. can't  even send its input directly to its output can hardly
  1477. be considered as capable as other languages.
  1478.  
  1479. _5_._2  _T_u_r_i_n_g _T_e_x_t _M_o_d_e_l
  1480.  
  1481. To remedy this problem, character I/O is now provided  in  a
  1482. form  based  on the "Turing Text" model, originally proposed
  1483. by Jon Blow.  The  C-INTERCAL  programmer  can  access  this
  1484. capability  by  placing a one- dimensional array in the list
  1485. of items given to a WRITE IN  or  READ  OUT  statement.   On
  1486. execution  of the statement, the elements of the array will,
  1487. from first to last, be either loaded from the input or  sent
  1488. to  the  output,  as  appropriate,  in  the manner described
  1489. below.  There is currently  no  support  for  I/O  involving
  1490. higher-dimensional  arrays,  but some form of graphics might
  1491. be a possible 2-D interpretation.
  1492.  
  1493. The heart of  the  Turing  Text  model  is  the  idea  of  a
  1494. continuous  loop  of  tape  containing,  in  order,  all the
  1495. characters in the machine's character set.  When a character
  1496. is  received  by the input routine, the tape is advanced the
  1497. appropriate number of spaces to bring that  character  under
  1498. the  tape  head, and the number of spaces the tape was moved
  1499. is the number that is actually seen by the INTERCAL program.
  1500. Another  way  to  say  this  is that the number placed in an
  1501. INTERCAL array is the difference between the character  just
  1502. received  and  the  previous character, modulo the number of
  1503. characters in the machine character set.
  1504.  
  1505. Output works in just the opposite fashion, except  that  the
  1506. characters  being  output  come  from  the other side of the
  1507. tape.  From this position the characters on the tape  appear
  1508. to  be  in  reverse order, and are individually backwards as
  1509. well.  (We would show you what it looks like, but  we  don't
  1510. have  a  font  with  backwards  letters available.  Use your
  1511. imagination.)  The effect is that a number is taken  out  of
  1512. an  INTERCAL  array,  subtracted  from  the  last  character
  1513. output--- i.e., the result  of  the  last  subtraction---and
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.                            - 23 -
  1523.  
  1524.  
  1525.  
  1526. then  sent  on  down  the output channel.  The only catch is
  1527. that the character as seen by the INTERCAL  program  is  the
  1528. mirror-image of the character as seen by the machine and the
  1529. user.  The bits of the  character  are  therefore  taken  in
  1530. reverse  order  as it is sent to the output.  Note that this
  1531. bit reversal affects only the character seen by the  outside
  1532. world; it does not affect the character stored internally by
  1533. the program, from which  the  next  output  number  will  be
  1534. subtracted.   All subtractions are done modulo the number of
  1535. characters in the character set.
  1536.  
  1537. Two different tapes are used for input  and  for  output  to
  1538. allow  for  future  expansion  of  the  language  to include
  1539. multiple input and output channels.   Both  tapes  start  at
  1540. character 0 when a program begins execution.  On input, when
  1541. an end of file marker is reached the number  placed  in  the
  1542. array is one greater than the highest- numbered character on
  1543. the tape.
  1544.  
  1545. _5_._3  _E_x_a_m_p_l_e _P_r_o_g_r_a_m
  1546.  
  1547. If all this seems terribly complicated, it  should  be  made
  1548. perfectly  clear  by  the  following  example program, which
  1549. simply maps its input to its output (like a simplified  UNIX
  1550. "cat").   It  assumes  that  characters are 8 bits long, but
  1551. that's fine since the current  version  of  C-INTERCAL  does
  1552. too.  It uses the standard library routines for addition and
  1553. subtraction.
  1554.  
  1555.         DO ,1 <- #1
  1556.         DO .4 <- #0
  1557.         DO .5 <- #0
  1558.         DO COME FROM (30)
  1559.         DO WRITE IN ,1
  1560.         DO .1 <- ,1SUB#1
  1561.         DO (10) NEXT
  1562.         PLEASE GIVE UP
  1563. (20)    PLEASE RESUME '?.1$#256'~'#256$#256'
  1564. (10)    DO (20) NEXT
  1565.         DO FORGET #1
  1566.         DO .2 <- .4
  1567.         DO (1000) NEXT
  1568.         DO .4 <- .3~#255
  1569.         DO .3 <- !3~#15'$!3~#240'
  1570.         DO .3 <- !3~#15'$!3~#240'
  1571.         DO .2 <- !3~#15'$!3~#240'
  1572.         DO .1 <- .5
  1573.         DO (1010) NEXT
  1574.         DO .5 <- .2
  1575.         DO ,1SUB#1 <- .3
  1576. (30)    PLEASE READ OUT ,1
  1577.  
  1578. For each number received in the  input  array,  the  program
  1579. first  tests the #256 bit to see if the end of file has been
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.                            - 24 -
  1589.  
  1590.  
  1591.  
  1592. reached.  If not, the previous input character is subtracted
  1593. off  to  obtain the current input character.  Then the order
  1594. of the bits is reversed to find out what character should be
  1595. sent  to  the  output, and the result is subtracted from the
  1596. last character sent.  Finally, the difference is  placed  in
  1597. an  array  and given to a READ OUT statement.  See?  We told
  1598. you it was simple!
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.                            - 25 -
  1655.  
  1656.  
  1657.  
  1658. _6_.  _T_r_i_I_N_T_E_R_C_A_L
  1659.  
  1660. In which it is revealed  that  bitwise  operations  are  too
  1661. ordinary  for hard-core INTERCAL programmers, and extensions
  1662. to other bases  are  discussed.   These  are  not,  strictly
  1663. speaking,  extensions  to  INTERCAL  itself,  but rather new
  1664. dialects  sharing  most  of  the  features  of  the   parent
  1665. language.
  1666.  
  1667. _6_._1  _M_o_t_i_v_a_t_i_o_n
  1668.  
  1669. INTERCAL  is  really a pretty sissy language.  It tries hard
  1670. to be different, but when you get right down to  its  roots,
  1671. what  do  you  find?  You find bits, that's what.  Plain old
  1672. ones and zeroes, in groups of 16 and  32,  just  like  every
  1673. other  language  you've  ever heard of.  And what operations
  1674. can you perform on these bits?  The INTERCAL  operators  may
  1675. arrange and permute them in weird and wonderful ways, but at
  1676. the bit level the operators are the same  AND,  OR  and  XOR
  1677. you've seen countless times before.
  1678.  
  1679. Once the prospective INTERCAL programmer masters the unusual
  1680. syntax, she finds herself working with the familiar  Boolean
  1681. operators  on  perfectly  ordinary  unsigned  integer words.
  1682. Even the constants she uses are familiar.   After  all,  who
  1683. would  not  immediately recognize #65535 and #32768?  It may
  1684. take a just a moment more to figure out #65280,  and  #21845
  1685. and  #43690 could be puzzles until she notices that they sum
  1686. to #65535, but basically she's still on her home turf.   The
  1687. 16-bit limit on constants actually works in the programmer's
  1688. favor by insuring that very long anonymous constants can not
  1689. appear in INTERCAL programs.  And this is in a language that
  1690. is supposed to be different from any other!
  1691.  
  1692. _6_._2  _A_b_a_n_d_o_n _A_l_l _H_o_p_e_._._.
  1693.  
  1694. Standard  INTERCAL  is  based  on  variables  consisting  of
  1695. ordinary bits and familiar Boolean operations on those bits.
  1696. In pursuit of uniqueness, it seems appropriate to provide  a
  1697. new  dialect, otherwise identical to INTERCAL, which instead
  1698. uses variables consisting of trits, i.e. ternary digits, and
  1699. operators  based  on  tritwise  logical operations.  This is
  1700. intended to be a separate dialect, rather than an  extension
  1701. to  INTERCAL itself, for a number of reasons.  Doing it this
  1702. way  avoids  word-length  conflicts,  does  not  spoil   the
  1703. elegance  of  the  Spartan INTERCAL operator set, and dodges
  1704. the objections of those who  might  feel  it  too  great  an
  1705. alteration  to  the  original  language.  Primarily, though,
  1706. giving INTERCAL programmers the ability  to  switch  numeric
  1707. base  at  will  amounts to excessive functionality.  So much
  1708. better that a programmer choose a base  at  the  outset  and
  1709. then  be  forced  to  stick with it for the remainder of the
  1710. program.
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.                            - 26 -
  1721.  
  1722.  
  1723.  
  1724. _6_._3  _C_o_m_p_i_l_e_r _O_p_e_r_a_t_i_o_n
  1725.  
  1726. The  same  compiler,  ick,  supports   both   INTERCAL   and
  1727. TriINTERCAL.   This  has the advantage that future bug fixes
  1728. and additions to the  language  not  related  to  arithmetic
  1729. immediately apply to both versions.  The compiler recognizes
  1730. INTERCAL source files by the extension '.i', and TriINTERCAL
  1731. source  files  by  the  extension  '.3i'.  It's as simple as
  1732. that.  There is no  way  to  mix  INTERCAL  and  TriINTERCAL
  1733. source in the same program, and it is not always possible to
  1734. determine which dialect a program  is  written  in  just  by
  1735. looking at the source code.
  1736.  
  1737. _6_._4  _D_a_t_a _T_y_p_e_s
  1738.  
  1739. The two TriINTERCAL data types are 10-trit unsigned integers
  1740. and 20-trit unsigned  integers.   All  INTERCAL  syntax  for
  1741. distinguishing  data  types  is ported to these new types in
  1742. the obvious way.  Small words may contain numbers from #0 to
  1743. #59048,  large  words  may  contain  numbers  from  #0$#0 to
  1744. #59048$#59048.  Errors are signaled  for  constants  greater
  1745. than  #59048  and for attempts to WRITE IN numbers too large
  1746. for a given variable or array element to hold.
  1747.  
  1748. Note that though TriINTERCAL considers  all  numbers  to  be
  1749. unsigned,  nothing prevents the programmer from implementing
  1750. arithmetic operations that treat their operands  as  signed.
  1751. Three's  complement  is  one  obvious  choice,  but balanced
  1752. ternary notation is also a possibility.  This  latter  is  a
  1753. very  pretty and symmetrical system in which all 2 trits are
  1754. treated as if they had the value -1.
  1755.  
  1756. _6_._5  _O_p_e_r_a_t_o_r_s
  1757.  
  1758. The  TriINTERCAL  operators  are  designed  to  inherit  the
  1759. relevant  properties  of the standard INTERCAL operators, so
  1760. that both can be considered as merely different  aspects  of
  1761. the same Platonic ideal.  (Not that the word "ideal" is ever
  1762. particularly  relevant  when   used   in   connection   with
  1763. INTERCAL.)
  1764.  
  1765. _6_._5_._1  _B_i_n_a_r_y _O_p_e_r_a_t_o_r_s _I
  1766.  
  1767. The  binary  operators carry over from the original language
  1768. with only minor changes.  The MINGLE operator ($) creates  a
  1769. 20-trit  word  by  alternating  trits  from  its two 10-trit
  1770. operands.   The  SELECT  operator  (~)  is  a  little   more
  1771. complicated,  since  the  ternary tritmask may contain 0, 1,
  1772. and 2 trits.  If we observe that  the  SELECT  operation  on
  1773. binary   operands   amounts   to  a  bitwise  AND  and  some
  1774. rearrangement of bits, it  seems  appropriate  to  base  the
  1775. SELECT  for  ternary  operands  on  a  tritwise  AND  in the
  1776. analogous fashion.  We therefore postpone the definition  of
  1777. SELECT until we know what a tritwise AND looks like.
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.                            - 27 -
  1787.  
  1788.  
  1789.  
  1790. _6_._5_._2  _U_n_a_r_y _O_p_e_r_a_t_o_r_s
  1791.  
  1792. The  unary  operators  in  INTERCAL are all derived from the
  1793. familiar Boolean operations on single bits.  To extend these
  1794. operations  to  trits,  we  first  ask  ourselves  what  the
  1795. important properties of these operations are that we wish to
  1796. be  preserved,  then  design  the tritwise operators so that
  1797. they behave in a similar fashion.
  1798.  
  1799. _6_._5_._2_._1  _U_n_a_r_y _L_o_g_i_c_a_l _O_p_e_r_a_t_o_r_s
  1800.  
  1801. Let's start with AND and OR.  To begin with,  these  can  be
  1802. considered  "choice"  or  "preference"  operators,  as  they
  1803. always return one of their operands.  AND can  be  described
  1804. as  wanting  to  return 0, but returning 1 if it is given no
  1805. other choice, i.e., if both operands are 1.   Similarly,  OR
  1806. wants  to return 1 but returns 0 if that is its only choice.
  1807. From this it is immediately apparent that each operator  has
  1808. an  identity  element  that  "always loses", and a dominator
  1809. element that "always wins".
  1810.  
  1811. AND  and  OR  are  commutative  and  associative,  and  each
  1812. distributes  over  the  other.  They are also symmetric with
  1813. each other, in the sense that AND looks like OR and OR looks
  1814. like  AND  when  the  roles  of 0 and 1 are interchanged (De
  1815. Morgan's Laws).  This symmetry property seems to  be  a  key
  1816. element  to  the  idea  that  these are logical, rather than
  1817. arithmetic, operators.  In a  three-valued  logic  we  would
  1818. similarly  expect  a  three-  way  symmetry  among the three
  1819. values 0, 1 and 2 and the three operators AND,  OR  and  (of
  1820. course) BUT.
  1821.  
  1822. The  following  tritwise  operations  have  all  the desired
  1823. properties: OR returns the  greater  of  its  two  operands.
  1824. That  is,  it  returns  2 if it can get it, else it tries to
  1825. return 1, and it returns 0 only if both operands are 0.  AND
  1826. wants  to  return  0,  will  return 2 if it can't get 0, and
  1827. returns 1 only if forced.  BUT wants 1,  will  take  0,  and
  1828. tries to avoid 2.  The equivalents to De Morgan's Laws apply
  1829. to rotations of the three elements, e.g., 0 -> 1, 1 -> 2,  2
  1830. ->  0.   Each  operator  distributes  over exactly one other
  1831. operator, so the property "X  distributes  over  Y"  is  not
  1832. transitive.   The  question of which way this distributivity
  1833. ring goes around is left as an exercise for the student.
  1834.  
  1835. In TriINTERCAL programs the whirlpool (@) symbol denotes the
  1836. unary   tritwise  BUT  operation.   You  can  think  of  the
  1837. whirlpool  as  drawing  values  preferentially  towards  the
  1838. central  value  1.   Alternatively,  you  can think of it as
  1839. drawing your soul and your sanity inexorably down...
  1840.  
  1841. On the other hand, maybe it's best you _n_o_t think of it  that
  1842. way.
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.                            - 28 -
  1853.  
  1854.  
  1855.  
  1856. A  few  comments  about how these operators can be used.  OR
  1857. acts like a tritwise maximum operation.   AND  can  be  used
  1858. with  tritmasks.   0's  in a mask wipe out the corresponding
  1859. elements  in  the  other  operand,   while   1's   let   the
  1860. corresponding  elements  pass  through  unchanged.  2's in a
  1861. mask consolidate the values of nonzero elements, as both 1's
  1862. and  2's  in the other operand yield 2's in the output.  BUT
  1863. can be used to create "partial tritmasks".  0's  in  a  mask
  1864. let  BUT  eliminate 2's from the other operand while leaving
  1865. other values unchanged.  Of course,  the  symmetry  property
  1866. guarantees   that   the   operators   don't   really  behave
  1867. differently from each other  in  any  fundamental  way;  the
  1868. apparent  differences  come from the intuitive view that a 0
  1869. trit is "not set" while a 1 or 2 trit is "set".
  1870.  
  1871. _6_._5_._2_._2  _B_i_n_a_r_y _O_p_e_r_a_t_o_r_s _I_I
  1872.  
  1873. At this point we can define SELECT, since we now  know  what
  1874. the  tritwise  AND  looks  like.   SELECT  takes  the binary
  1875. tritwise AND of its two operands.  It shifts all  the  trits
  1876. of the result corresponding to 2's in the right operand over
  1877. to the right (low) end of the result, then follows them with
  1878. all  the  output  trits  corresponding  to  1's in the right
  1879. operand.  Trits corresponding to 0's in the  right  operand,
  1880. which  are  all  0 anyway, occupy the remaining space at the
  1881. left end of the  output  word.   Both  10-trit  and  20-trit
  1882. operands  are  accepted,  and  are padded with zeroes on the
  1883. left if necessary.  The output type is determined  the  same
  1884. way as in standard INTERCAL.
  1885.  
  1886. _6_._5_._2_._3  _U_n_a_r_y _A_r_i_t_h_m_e_t_i_c _O_p_e_r_a_t_o_r_s
  1887.  
  1888. Now  that  we've got all that settled, what about XOR?  This
  1889. is easily  the  most-useful  of  the  three  unary  INTERCAL
  1890. operators, because it combines in one package the operations
  1891. ADD WITHOUT CARRY, SUBTRACT  WITHOUT  BORROW,  BITWISE  NOT-
  1892. EQUAL, and BITWISE NOT.  In TriINTERCAL we can't have all of
  1893. these in the same operator, since addition  and  subtraction
  1894. are  no longer the same thing.  The solution is to split the
  1895. XOR concept into  two  operators.   The  ADD  WITHOUT  CARRY
  1896. operation  is  represented  by  the new sharkfin (^) symbol,
  1897. while the old what (?) symbol  represents  SUBTRACT  WITHOUT
  1898. BORROW.  The reason for this choice is so that what (?) will
  1899. also represent the TRITWISE NOT-EQUAL operation.
  1900.  
  1901. Note that what (?), unlike the other four  unary  operators,
  1902. is not symmetrical.  It should be thought of as rotating its
  1903. operand one trit to the right  (with  wraparound)  and  then
  1904. subtracting  off  the  trits  of the original number.  These
  1905. subtractions are done without borrowing, i.e.,  trit-by-trit
  1906. modulo 3.
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.                            - 29 -
  1919.  
  1920.  
  1921.  
  1922. _6_._5_._3  _E_x_a_m_p_l_e_s
  1923.  
  1924. The  TriINTERCAL  operators  really aren't all that bad once
  1925. you get used to them.  Let's look at a few examples to  show
  1926. how  they can be used in practice.  In all of these examples
  1927. the input value is contained in the 10-trit variable .3.
  1928.  
  1929. In INTERCAL, single-bit values often have  to  be  converted
  1930. from  {0,1} to {1,2} for use in RESUME statements.  Examples
  1931. of how to  do  this  appear  in  the  original  manual.   In
  1932. TriINTERCAL the expression "^.3$#1"~#1 sends 0 -> 1 and 1 ->
  1933. 2.  If the 1-trit input value can take on any of  its  three
  1934. possible states, however, we will also have to deal with the
  1935. 2 case.  The expression "V.3$#1"~#1 sends {0,1} -> 1  and  2
  1936. ->   2.    To   test   if   a   trit  is  set,  we  can  use
  1937. "V'"&.3$#2"~#1'$#1"~#1, sending 0 -> 1 and {1,2} ->  2.   To
  1938. reverse the test we use "?'"&.3$#2"~#1'$#1"~#1, sending 0 ->
  1939. 2 and {1,2} -> 1.  Note that we have not  been  taking  full
  1940. advantage  of  the  new  SELECT  operator.   These  last two
  1941. expressions  can  be  simplified  into  "V!3~#2'$#1"~#1  and
  1942. "?!3~#2'$#1"~#1,  which  perform  exactly the same mappings.
  1943. Finally,  if  we   need   a   3-way   test,   we   can   use
  1944. "@'"^.3$#7"~#4'$#2"~#10,  which obviously sends 0 -> 1, 1 ->
  1945. 2, and 2 -> 3.
  1946.  
  1947. For     an     unrelated     example,     the     expression
  1948. "^.3$.3"~"#0$#29524"  converts all of the 1-trits of .3 into
  1949. 2's and all of the 2-trits into 1's.  In  balanced  ternary,
  1950. where  2-trits  represent  -1  values,  this is the negation
  1951. operation.
  1952.  
  1953. _6_._6  _B_e_y_o_n_d _T_e_r_n_a_r_y_._._.
  1954.  
  1955. While we're at it, we might as  well  extend  this  multiple
  1956. bases  business a little farther.  The ick compiler actually
  1957. recognizes filename suffixes of the form '.Ni', where  N  is
  1958. any  number  from  2  to  7.   2  of  course  gives standard
  1959. INTERCAL, while 3 gives TriINTERCAL.  We cut  off  before  8
  1960. because   octal  notation  is  the  smallest  base  used  to
  1961. facilitate human-to-machine communication,  and  this  seems
  1962. quite contrary to the basic principles behind INTERCAL.  The
  1963. small data types hold 16 bits, 10 trits, 8 quarts, 6 quints,
  1964. 6  sexts,  or  5 septs, and the large types are always twice
  1965. this size.
  1966.  
  1967. As for operators, '?' is always SUBTRACT WITHOUT BORROW, and
  1968. '^'  is  always  ADD WITHOUT CARRY.  'V' is the OR operation
  1969. and always returns the max of its inputs.  '&'  is  the  AND
  1970. operation, which chooses 0 if possible but otherwise returns
  1971. the max of the inputs.  '@' is BUT, which prefers 1, then 0,
  1972. then  the  max  of the remaining possibilities.  Rather than
  1973. add more special symbols forever, a numeric modifier may  be
  1974. placed  directly  before  the  '@'  symbol  to  indicate the
  1975. operation  that  prefers  one  of  the  digits  not  already
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.                            - 30 -
  1985.  
  1986.  
  1987.  
  1988. represented.   Thus  in files ending in '.5i', the permitted
  1989. unary operators are '?', '^', '&', '@', '2@', '3@', and 'V'.
  1990. Use  of  such  barbarisms  as  '0@' to represent '&' are not
  1991. permitted, nor is the use of '@' or '^' in files with either
  1992. of  the extensions '.i' or '.2i'.  Why not?  You just can't,
  1993. that's why.  Don't ask so many questions.
  1994.  
  1995. As a closing example,  we  note  that  in  balanced  quinary
  1996. notation,  where  3  means  -2  and 4 means -1, the negation
  1997. operation can be written as either
  1998.  
  1999.   DO .1 <- "^'"^.3$.3"~"#0$#3906"'$'"^.3$.3"~"#0$#3906"'"~"#0$#3906"
  2000.  
  2001. or as
  2002.  
  2003.   DO .1 <- "^.3$.3"~"#0$#3906"
  2004.   DO .1 <- "^.1$.1"~"#0$#3906"
  2005.  
  2006. These work because multiplication  by  -1  is  the  same  as
  2007. multiplication by 4, modulo 5.
  2008.  
  2009. Now go beat your head against the wall for a while.
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.                            - 31 -
  2051.  
  2052.  
  2053.  
  2054. _7_.  _S_U_B_R_O_U_T_I_N_E _L_I_B_R_A_R_Y
  2055.  
  2056. INTERCAL  provides  several  built-in  subroutines  to which
  2057. control can be transferred to  perform  various  operations.
  2058. These operations include many useful functions which are not
  2059. easily  representable  in  INTERCAL,   such   as   addition,
  2060. subtraction, etc.
  2061.  
  2062. _7_._1  _U_s_a_g_e
  2063.  
  2064. In  general, the operands are .1, .2, etc., or :1, :2, etc.,
  2065. and the result(s) are stored in what  would  have  been  the
  2066. next operand(s). For instance, one routine adds .1 to .2 and
  2067. store the  sum  in  .3,  with  .4  being  used  to  indicate
  2068. overflow.  All  variables  not  used  for  results  are left
  2069. unchanged.
  2070.  
  2071. _7_._2  _A_v_a_i_l_a_b_l_e _F_u_n_c_t_i_o_n_s
  2072.  
  2073. At the time of  this  writing,  only  the  most  fundamental
  2074. operations  are  offered  in the library, as a more complete
  2075. selection  would  require  prohibitive  time  and  coree  to
  2076. implement.  These  functions, along with their corresponding
  2077. entry points (entered via DO (entry) NEXT) are listed below.
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                            - 32 -
  2117.  
  2118.  
  2119.  
  2120.  (1000) .3 <- .1 plus .2, error exit on overflow
  2121.  (1009) .3 <- .1 plus .2
  2122.         .4 <- #1 if no overflow, else .4 <- #2
  2123.  (1010) .3 <- .1 minus .2, no action on overflow
  2124.  (1020) .1 <- .1 plus #1, no action on overflow
  2125.  (1030) .3 <- .1 times .2, error exit on overflow
  2126.  (1039) .3 <- .1 times .2
  2127.         .4 <- #1 if no overflow, else .4 <- #2
  2128.  (1040) .3 <- .1 divided by .2
  2129.         .3 <- #0 if .2 is #0
  2130.  (1050) .2 <- :1 divided by .1, error exit on overflow
  2131.         .2 <- #0 if .1 is #0
  2132. (1060) .3 <- logical or of .1 and .2
  2133.  (1070) .3 <- logical and of .1 and .2
  2134.  (1080) .3 <- logical xor of .1 and .2
  2135.  
  2136.  (1500) :3 <- :1 plus :2, error exit on overflow
  2137.  (1509) :3 <- :1 plus :2
  2138.         :4 <- #1 if no overflow, else :4 <- #2
  2139.  (1510) :3 <- :1 minus :2, no action on overflow
  2140.  (1520) :1 <- .1 concatenated with .2
  2141.  (1525) This subroutine is intended solely for internal
  2142.         use within the subroutine library and is therefore
  2143.         not described here. Its effect is to shift .3
  2144.         logically 8 bits to the left.
  2145.  (1530) :1 <- .1 times .2
  2146.  (1540) :3 <- :1 times :2, error exit on overflow
  2147.  (1549) :3 <- :1 times :2
  2148.         :4 <- #1 if no overflow, else :4 <- #2
  2149.  (1550) :3 <- :1 divided by :2
  2150.         :3 <- #0 if :2 is #0
  2151.  
  2152.  (1900) .1 <- uniform random no. from #0 to #65535
  2153.  (1910) .2 <- normal random no. from #0 to .1, with
  2154.               standard deviation .1 divided by #12
  2155.  
  2156. _7_._3  _A_u_t_o_m_a_g_i_c_a_l _I_n_c_l_u_s_i_o_n _O_f _T_h_e _S_u_b_r_o_u_t_i_n_e _L_i_b_r_a_r_y
  2157.  
  2158. The  C-INTERCAL  compiler  will  automatically  include  the
  2159. system library if a DO (1xxx) NEXT statement is used, and if
  2160. no  (1xxx)  labels  are  defined anywhere, where (1xxx) is a
  2161. label in the 1000-1999 range, inclusive.  This  was  not  an
  2162. INTERCAL-72 feature.
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.                            - 33 -
  2183.  
  2184.  
  2185.  
  2186. _8_.  _P_R_O_G_R_A_M_M_I_N_G _H_I_N_T_S
  2187.  
  2188. For  the  user  looking  to  become  more  familiar with the
  2189. INTERCAL language, we present in this section an analysis of
  2190. a  complex  program,  as well as some suggested projects for
  2191. the ambitious programmer.
  2192.  
  2193. Considering the  effort  involved  in  writing  an  INTERCAL
  2194. program,  it  was decided in putting together this manual to
  2195. use an already existing program  for  instructive  analysis.
  2196. Since  there  was  only  one such program available, we have
  2197. proceeded to use it. It is known  as  the  "INTERCAL  System
  2198. Library."
  2199.  
  2200. _8_._1  _D_e_s_c_r_i_p_t_i_o_n
  2201.  
  2202. The  program listing begins on the second page following. It
  2203. is in the same format as would be produced by the  Princeton
  2204. INTERCAL  compiler in FORMAT mode with WIDTH=62 (see section
  2205. 12). For a description of the  functions  performed  by  the
  2206. Library, see section 7.2.
  2207.  
  2208. _8_._2  _A_n_a_l_y_s_i_s
  2209.  
  2210. We  shall  not  attempt to discuss here the algorithms used,
  2211. but rather we shall point out some of the general techniques
  2212. applicable to a wide range of problems.
  2213.  
  2214. Statements 10, 14, 15, and 26 make up a virtual "computed GO
  2215. TO".  When  statement  10  is   executed,   control   passes
  2216. eventually  to  statement  16 or 11, depending on whether .5
  2217. contains  #1  or  #2,  respectively.  The  value  of  .5  is
  2218. determined  in statement 9, which demonstrates another handy
  2219. technique.  To turn an expression, exp, with value #0 or #1,
  2220. into  #1  or  #2 (for use in a "GO TO"), use "V-'exp'c/#1"~#3.
  2221. To reverse the condition (i.e., convert #0 to #2  and  leave
  2222. #1 alone) use "V-'exp'c/#2"~#3.
  2223.  
  2224. Certain  conditions are easily checked. For example, to test
  2225. for zero, select the value from itself and select the bottom
  2226. bit  (see  statement  54).   To test for all bits being 1's,
  2227. select the value from itself and select  the  top  bit  (see
  2228. statement  261).  The  test  for  greater than, performed in
  2229. statements 192 and 193  on  32-bit  values,  employs  binary
  2230. logical operations, which are performed as follows:
  2231.  
  2232. 'V-.1c/.2'~'#0c/#65535'
  2233.  
  2234. for 16-bit values or, for 32-bit values:
  2235.  
  2236.         "'V-":1~'#65535c/30'"c/":2~'#65535c/#0'"'~'#0
  2237.         c/#65535'"c/"'V-":1~'#0c/#65535'"c/":2~'#0
  2238.         c/#65535'"'~'#0c/#65535'"
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.                            - 34 -
  2249.  
  2250.  
  2251.  
  2252. (The proofs are left as an exercise to the reader.)
  2253.  
  2254. Testing  for  greater-than  with  16-bit  values is somewhat
  2255. simpler and is done with the pair of statements:
  2256.  
  2257.         DO .C <- 'V-.Ac.B'~'#0c/#65535'
  2258.         DO .C <- '&"'.A~.C'~'"V-'V-.C~.C'c/#32768"
  2259.                 ~"#0c/#65535"'"c/".C~.C"'~#1
  2260.  
  2261. This sets .C (a dummy variable) to #1 if .A  >  .B,  and  #0
  2262. otherwise. The expression may be expanded as described above
  2263. to instead set .C to #1 or #2.
  2264.  
  2265. Note   also   in   statement   220   the    occurrence    of
  2266. ~"#65535c/#65535".   Although  these  operations  select  the
  2267. entire value, they are not extraneous, as they  ensure  that
  2268. the forthcoming V-s will be operating on 32-bit values.
  2269.  
  2270. In  several  virtual  computed  GO  TOs  the  DO  FORGET  #1
  2271. (statement 15 in the  earlier  example)  has  been  omitted,
  2272. since  the next transfer of control would be a DO RESUME #1.
  2273. By making this a DO RESUME #2 instead,  the  FORGET  may  be
  2274. forgotten.
  2275.  
  2276. In  statement  64, note that .2 is STASHed twice by a single
  2277. statement. This is perfectly legal.
  2278.  
  2279. Lastly,  note  in  statements  243  and  214   respectively,
  2280. expressions  for shifting 16- and 32-bit variables logically
  2281. one place to the left.  Statement  231  demonstrates  right-
  2282. shifting for 32-bit variables.
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.                            - 35 -
  2315.  
  2316.  
  2317.  
  2318. _8_._3  _P_r_o_g_r_a_m _L_i_s_t_i_n_g
  2319.  
  2320.     1   (1000)  PLEASE IGNORE .4
  2321.     2           PLEASE ABSTAIN FROM (1005)
  2322.     3   (1009)  DO STASH .1 + .2 + .5 + .6
  2323.     4           DO .4 <- #1
  2324.     5           DO (1004) NEXT
  2325.     6   (1004)  PLEASE FORGET #1
  2326.     7           DO .3 <- 'V-.1c/.2'~'#0c/#65535'
  2327.     8           DO .6 <- '&.1c/.2'~'#0c/#65535'
  2328.     9           PLEASE DO .5 <- "V-!6~#32768'c/#1"~#3
  2329.    10           DO (1002) NEXT
  2330.    11           DO .4 <- #2
  2331.    12   (1005)  DO (1006) NEXT
  2332. *  13   (1999)  DOUBLE OR SINGLE PRECISION OVERFLOW
  2333.    14   (1002)  DO (1001) NEXT
  2334.    15   (1006)  PLEASE FORGET #1
  2335.    16           DO .5 <- 'V-"!6~.6'~#1"c/#1'~#3
  2336.    17           DO (1003) NEXT
  2337.    18           DO .1 <- .3
  2338.    19           DO .2 <- !6c/#0'~'#32767c/#1'
  2339.    20           DO (1004) NEXT
  2340.    21   (1003)  DO (1001) NEXT
  2341.    22           DO REINSTATE (1005)
  2342.    23   (1007)  PLEASE RETRIEVE .1 + .2 + .5 + .6
  2343.    24           DO REMEMBER .4
  2344.    25           PLEASE RESUME #2
  2345.    26   (1001)  DO RESUME .5
  2346.    27   (1010)  DO STASH .1 + .2 + .4
  2347.    28           DO .4 <- .1
  2348.    29           DO .1 <- 'V-.2c/#65535'~'#0c/#65535'
  2349.    30           DO (1020) NEXT
  2350.    31           PLEASE DO .2 <- .4
  2351.    32           PLEASE DO (1009) NEXT
  2352.    33           DO RETRIEVE .1 + .2 + .4
  2353.    34           PLEASE RESUME #1
  2354.    35   (1020)  DO STASH .2 + .3
  2355.    36           DO .2 <- #1
  2356.    37           PLEASE DO (1021) NEXT
  2357.    38   (1021)  DO FORGET #1
  2358.    39           DO .3 <- "V-!1~.2'c/#1"~#3
  2359.    40           PLEASE DO .1 <- 'V-.1c/.2'~'#0c/#65535'
  2360.    41           DO (1022) NEXT
  2361.    42           DO .2 <- !2c/#0'~'#32767c/#1'
  2362.    43           DO (1021) NEXT
  2363.    44   (1023)  PLEASE RESUME .3
  2364.    45   (1022)  DO (1023) NEXT
  2365.    46           PLEASE RETRIEVE .2 + .3
  2366.    47           PLEASE RESUME #2
  2367.    48   (1030)  DO ABSTAIN FROM (1033)
  2368.    49           PLEASE ABSTAIN FROM (1032)
  2369.    50   (1039)  DO STASH :1 + .5
  2370.    51           DO (1530) NEXT
  2371.    52           DO .3 <- :1~#65535
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.                            - 36 -
  2381.  
  2382.  
  2383.  
  2384.    53           PLEASE DO .5 <- :1~'#65280c/#65280'
  2385.    54           DO .5 <- 'V-"!5~.5'~#1"c/#1'~#3
  2386.    55           DO (1031) NEXT
  2387.    56   (1032)  DO (1033) NEXT
  2388.    57           DO (1999) NEXT
  2389.    58   (1031)  DO (1001) NEXT
  2390.    59   (1033)  DO .4 <- .5
  2391.    60           DO REINSTATE (1032)
  2392.    61           PLEASE REINSTATE (1033)
  2393.    62           DO RETRIEVE :1 + .5
  2394.    63           PLEASE RESUME #2
  2395.    64   (1040)  PLEASE STASH .1 + .2 + .2 + :1 + :2 + :3
  2396.    65           DO .2 <- #0
  2397.    66           DO (1520) NEXT
  2398.    67           DO STASH :1
  2399.    68           PLEASE RETRIEVE .2
  2400.    69           DO .1 <- .2
  2401.    70           DO .2 <- #0
  2402.    71           PLEASE DO (1520) NEXT
  2403.    72           DO :2 <- :1
  2404.    73           DO RETRIEVE .1 + .2 + :1
  2405.    74           DO (1550) NEXT
  2406.    75           PLEASE DO .3 <- :3
  2407.    76           DO RETRIEVE :1 + :2 + :3
  2408.    77           DO RESUME #1
  2409.    78   (1050)  PLEASE STASH :2 + :3 + .5
  2410.    79           DO :2 <- .1
  2411.    80           PLEASE DO (1550) NEXT
  2412.    81           DO .5 <- :3~'#65280c/#65280'
  2413.    82           DO .5 <- 'V-"!5~.5'~#1"c/#1'~#3
  2414.    83           DO (1051) NEXT
  2415.    84           DO (1999) NEXT
  2416.    85   (1051)  DO (1001) NEXT
  2417.    86           DO .2 <- :3
  2418.    87           PLEASE RETRIEVE :2 + :3 + .5
  2419.    88           DO RESUME #2
  2420.    89   (1500)  PLEASE ABSTAIN FROM (1502)
  2421.    90           PLEASE ABSTAIN FROM (1506)
  2422.    91   (1509)  PLEASE STASH :1 + .1 + .2 + .3 + .4 + .5 + .6
  2423.    92           DO .1 <- :1~#65535
  2424.    93           PLEASE DO .2 <- :2~#65535
  2425.    94           DO (1009) NEXT
  2426.    95           DO .5 <- .3
  2427.    96           PLEASE DO .6 <- .4
  2428.    97           DO .1 <- :1~'#65280c/#65280'
  2429.    98           DO .2 <- :2~'#65280c/#65280'
  2430.    99           DO (1009) NEXT
  2431.   100           DO .1 <- .3
  2432.   101           PLEASE DO (1503) NEXT
  2433.   102           DO .6 <- .4
  2434.   103           DO .2 <- #1
  2435.   104           DO (1009) NEXT
  2436.   105           DO .1 <- .3
  2437.   106           DO (1501) NEXT
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.                            - 37 -
  2447.  
  2448.  
  2449.  
  2450.   107   (1504)  PLEASE RESUME .6
  2451.   108   (1503)  DO (1504) NEXT
  2452.   109   (1501)  DO .2 <- .5
  2453.   110           DO .5 <- 'V-"'&.6c/.4'~#1"c/#2'~#3
  2454.   111           DO (1505) NEXT
  2455.   112   (1506)  DO (1502) NEXT
  2456.   113           PLEASE DO (1999) NEXT
  2457.   114   (1505)  DO (1001) NEXT
  2458.   115   (1502)  DO :4 <- .5
  2459.   116           DO (1520) NEXT
  2460.   117           DO :3 <- :1
  2461.   118           PLEASE RETRIEVE :1 + .1 + .2 + .3 + .4 + .5 + .6
  2462.   119           DO REINSTATE (1502)
  2463.   120           DO REINSTATE (1506)
  2464.   121           PLEASE RESUME #3
  2465.   122   (1510)  DO STASH :1 + :2 + :4
  2466.   123           DO :1 <- "'V-":2~'#65535c/#0'"c/#65535'~'#0c/#6553
  2467.             5'"c/"'V-":2~'#0c/#65535'"c/#65535'~'#0c/#65535
  2468.             '"
  2469.   124           DO :2 <- #1
  2470.   125           DO (1509) NEXT
  2471.   126           PLEASE RETRIEVE :1
  2472.   127           DO :2 <- :3
  2473.   128           PLEASE DO (1509) NEXT
  2474.   129           DO RETRIEVE :2 + :4
  2475.   130           PLEASE RESUME #1
  2476.   131   (1520)  PLEASE STASH .3 + .4
  2477.   132           DO .3 <- .1~#43690
  2478.   133           DO (1525) NEXT
  2479.   134           PLEASE DO .4 <- 'V.3c/".2~#43690"'~'#0c/#65535'
  2480.   135           DO .3 <- .1~#21845
  2481.   136           PLEASE DO (1525) NEXT
  2482.   137           DO :1 <- .4c/"'V.3c/".2~#21845"'~'#0c/#65535'"
  2483.   138           PLEASE RETRIEVE .3 + .4
  2484.   139           DO RESUME #1
  2485.   140   (1525)  DO .3 <- '"'"'"!3c/#0'~'#32767c/#1'"c/#0'~'#32767
  2486.             c/#1'"c/#0'~'#16383c/#3'"c/#0'~'#4095c/#15'
  2487.   141           PLEASE RESUME #1
  2488.   142   (1530)  DO STASH :2 + :3 + .3 + .5
  2489.   143           DO :1 <- #0
  2490.   144           DO :2 <- .2
  2491.   145           DO .3 <- #1
  2492.   146           DO (1535) NEXT
  2493.   147   (1535)  PLEASE FORGET #1
  2494.   148           DO .5 <- "V-!1~.3'c/#1"~#3
  2495.   149           DO (1531) NEXT
  2496.   150           DO (1500) NEXT
  2497.   151           DO :1 <- :3
  2498.   152           PLEASE DO (1533) NEXT
  2499.   153   (1531)  PLEASE DO (1001) NEXT
  2500.   154   (1533)  DO FORGET #1
  2501.   155           DO .3 <- !3c/#0'~'#32767c/#1'
  2502.   156           DO :2 <- ":2~'#0c/#65535'"c/"'":2~'#32767c/#0'"c/#
  2503.             0'~'#32767c/#1'"
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.                            - 38 -
  2513.  
  2514.  
  2515.  
  2516.   157           PLEASE DO .5 <- "V-!3~.3'c/#1"~#3
  2517.   158           DO (1532) NEXT
  2518.   159           DO (1535) NEXT
  2519.   160   (1532)  DO (1001) NEXT
  2520.   161           PLEASE RETRIEVE :2 + :3 + .3 + .5
  2521.   162           DO RESUME #2
  2522.   163   (1540)  PLEASE ABSTAIN FROM (1541)
  2523.   164           DO ABSTAIN FROM (1542)
  2524.   165   (1549)  PLEASE STASH :1 + :2 + :4 + :5 + .1 + .2 + .5
  2525.   166           DO .1 <- :1~#65535
  2526.   167           PLEASE DO .2 <- :2~'#65280c/#65280'
  2527.   168           DO .5 <- :1~'#65280c/#65280'
  2528.   169           DO (1530) NEXT
  2529.   170           DO :3 <- :1
  2530.   171           DO .2 <- :2~#65535
  2531.   172           PLEASE DO (1530) NEXT
  2532.   173           DO :5 <- :1
  2533.   174           DO .1 <- .5
  2534.   175           DO (1530) NEXT
  2535.   176           DO :4 <- :1
  2536.   177           PLEASE DO :1 <- ":3~'#65280c/#65280'"c/":5~'#652
  2537.             80c/#65280'"
  2538.   178           DO .5 <- ':1~:1'~#1
  2539.   179           DO .2 <- :2~'#65280c/#65280'
  2540.   180           DO (1530) NEXT
  2541.   181           PLEASE DO .5 <- '"':1~:1'~#1"c/.5'~#3
  2542.   182           DO .1 <- :3~#65535
  2543.   183           DO .2 <- #0
  2544.   184           DO (1520) NEXT
  2545.   185           PLEASE DO :2 <- :1
  2546.   186           PLEASE DO .1 <- :4~#65535
  2547.   187           DO (1520) NEXT
  2548.   188           DO (1509) NEXT
  2549.   189           DO .5 <- !5c/":4~#3"'~#15
  2550.   190           DO :1 <- :3
  2551.   191           DO :2 <- :5
  2552.   192           DO (1509) NEXT
  2553.   193           PLEASE DO .5 <- !5c/":4~#3"'~#63
  2554.   194           DO .5 <- 'V-"!5~.5'~#1"c/#1'~#3
  2555.   195           PLEASE RETRIEVE :4
  2556.   196   (1541)  DO :4 <- .5
  2557.   197           DO (1543) NEXT
  2558.   198   (1542)  DO (1544) NEXT
  2559.   199           PLEASE DO (1999) NEXT
  2560.   200   (1543)  DO (1001) NEXT
  2561.   201   (1544)  DO REINSTATE (1541)
  2562.   202           PLEASE REINSTATE (1542)
  2563.   203           PLEASE RETRIEVE :1 + :2 + :5 + .1 + .2 + .5
  2564.   204           DO RESUME #2
  2565.   205   (1550)  DO STASH :1 + :4 + :5 + .5
  2566.   206           DO :3 <- #0
  2567.   207           DO .5 <- 'V-"':2~:2'~#1"c/#1'~#3
  2568.   208           PLEASE DO (1551) NEXT
  2569.   209           DO :4 <- #1
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.                            - 39 -
  2579.  
  2580.  
  2581.  
  2582.   210           PLEASE DO (1553) NEXT
  2583.   211   (1553)  DO FORGET #1
  2584.   212           DO .5 <- 'V-":2~'#32768c/#0'"c/#2'~#3
  2585.   213           DO (1552) NEXT
  2586.   214           DO :2 <- ":2~'#0c/#65535'"c/"'":2~'#32767c/#0'"c/#
  2587.                    0'~'#32767c/#1'"
  2588.   215           PLEASE DO :4 <- ":4~'#0c/#65535'"c/"'":4~'#32767
  2589.                      c/#0'"c/#0'~'#32767c/#1'"
  2590.   216           DO (1553) NEXT
  2591.   217   (1552)  DO (1001) NEXT
  2592.   218   (1556)  PLEASE FORGET #1
  2593.   219           DO :5 <- "'V-":1~'#65535c/#0'"c/":2~'#65535c/#0'"'
  2594.                      ~'#0c/#65535'"c/"'V-":1~'#0c/#65535'"c/":2~'#0c/
  2595.                      #65535'"'~'#0c/#65535'"
  2596.   220           DO .5 <- 'V-"'&"':2~:5'~'"'V-"'V-":5~:5"~"#65535~
  2597.                      #65535"'~'#65535c/#0'"c/#32768'~'#0c/#65535'"
  2598.                      c/"'V-":5~:5"~"#65535c/#65535"'~'#0c/#65535'"'
  2599.                      "c/"':5~:5'~#1"'~#1"c/#2'~#3
  2600.   221           DO (1554) NEXT
  2601.   222           DO :5 <- :3
  2602.   223           DO (1510) NEXT
  2603.   224           PLEASE DO :1 <- :3
  2604.   225           DO :3 <- "'V":4~'#65535c/#0'"c/":5~'#65535c/#0'"'
  2605.                      ~'#0c/#65535'"c/"'V":4~'#0c/#65535'"c/":5~'#0c/
  2606.                      #65535'"'~'#0c/#65535'"
  2607.   226           DO (1555) NEXT
  2608.   227   (1554)  PLEASE DO (1001) NEXT
  2609.   228   (1555)  DO FORGET #1
  2610.   229           DO .5 <- "V-':4~#1'c/#2"~#3
  2611.   230           DO (1551) NEXT
  2612.   231           DO :2 <- ":2~'#0c/#65534'"c/":2~'#65535c/#0'"
  2613.   232           DO :4 <- ":4~'#0c/#65534'"c/":4~'#65535c/#0'"
  2614.   233           PLEASE DO (1556) NEXT
  2615.   234   (1551)  DO (1001) NEXT
  2616.   235           PLEASE RETRIEVE :1 + :4 + :5 + .5
  2617.   236           PLEASE RESUME #2
  2618.   237   (1900)  DO STASH .2 + .3 + .5
  2619.   238           DO .1 <- #0
  2620.   239           DO .2 <- #1
  2621.   240           PLEASE DO (1901) NEXT
  2622.   241   (1901)  DO FORGET #1
  2623.   242           DO %50 .1 <- 'V.1c/.2'~'#0c/#65535'
  2624.   243           DO .2 <- !2c/#0'~'#32767c/#1'
  2625.   244           PLEASE DO .5 <- "V-!2~.2'c/#1"~#3
  2626.   245           DO (1902) NEXT
  2627.   246           DO (1901) NEXT
  2628.   247   (1902)  DO (1001) NEXT
  2629.   248           DO RETRIEVE .2 + .3 + .5
  2630.   249           PLEASE RESUME #2
  2631.   250   (1910)  PLEASE STASH .1 + .3 + .5 + :1 + :2 + :3
  2632.   251           DO .3 <- #65524
  2633.   252           DO :1 <- #6
  2634.   253           DO (1911) NEXT
  2635. * 254           PLEASE NOTE THAT YOU CAN'T GET THERE FROM HERE
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.                            - 40 -
  2645.  
  2646.  
  2647.  
  2648.   255   (1912)  DO (1001) NEXT
  2649.   256   (1911)  DO FORGET #1
  2650.   257           PLEASE DO (1900) NEXT
  2651.   258           DO :2 <- .1
  2652.   259           DO (1500) NEXT
  2653.   260           PLEASE DO :1 <- :3
  2654.   261           DO .1 <- .3
  2655.   262           DO (1020) NEXT
  2656.   263           PLEASE DO .3 <- .1
  2657.   264           DO .5 <- 'V-"!3~.3'~#1"c/#2'~#3
  2658.   265           DO (1912) NEXT
  2659.   266           DO .1 <- #12
  2660.   267           PLEASE DO (1050) NEXT
  2661.   268           DO RETRIEVE .1
  2662.   269           DO (1530) NEXT
  2663.   270           DO :2 <- #32768
  2664.   271           DO (1500) NEXT
  2665.   272           PLEASE DO .2 <- :3~'#65280c/#65280'
  2666.   273           PLEASE RETRIEVE .3 + .5 + :1 + :2 + :3
  2667.   274           DO RESUME #1
  2668. 275   (1060)  DO .3<-'V".1c/.2"'~'#0c/#65535'
  2669.   276   (1070)  DO .3<-'&".1c/.2"'~'#0c/#65535'
  2670.   277   (1080)  DO .3<-'V-".1c/.2"'~'#0c/#65535'
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                            - 41 -
  2711.  
  2712.  
  2713.  
  2714. _8_._4  _P_r_o_g_r_a_m_m_i_n_g _S_u_g_g_e_s_t_i_o_n_s
  2715.  
  2716. For  the  novice INTERCAL programmer, we provide here a list
  2717. of suggested INTERCAL programming projects:
  2718.  
  2719. Write an integer exponentiation subroutine.  :1 <- .1 raised
  2720. to the .2 power.
  2721.  
  2722. Write  a  double-precision  sorting subroutine. Given 32-bit
  2723. array ;1 of size :1,  sort  the  contents  into  numerically
  2724. increasing order, leaving the results in ;1.
  2725.  
  2726. Generate a table of prime numbers.
  2727.  
  2728. Put   together   a   floating-point  library,  using  32-bit
  2729. variables to represent floating-point numbers (let the upper
  2730. half   be   the   mantissa   and   the  lower  half  be  the
  2731. characteristic).   The  library   should   be   capable   of
  2732. performing     floating-point     addition,     subtraction,
  2733. multiplication,  and  division,  as  well  as  the   natural
  2734. logarithm function.
  2735.  
  2736. Program  a Fast Fourier Transform (FFT).  This project would
  2737. probably entail the writing of the floating-point library as
  2738. well as sine and cosine functions.
  2739.  
  2740. Calculate, to :1 places, the value of pi.
  2741.  
  2742. (The  first  three  and  last one of the preceding suggested
  2743. projects from the INTERCAL-72 manual are included in the  C-
  2744. INTERCAL  distribution's  pit directory of sample code.  The
  2745. floating-point library and  FFT  routine  remain  as  worthy
  2746. challenges...)
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.                            - 42 -
  2777.  
  2778.  
  2779.  
  2780. _9_.  _E_R_R_O_R _M_E_S_S_A_G_E_S
  2781.  
  2782. Due  to  INTERCAL's  implementation  of  comment  lines (see
  2783. section  4.5),  most  error  messages  are  produced  during
  2784. execution  instead of during compilation.  All errors except
  2785. those not causing immediate termination of program execution
  2786. are treated as fatal.
  2787.  
  2788. _9_._1  _F_o_r_m_a_t
  2789.  
  2790. All error messages appear in the following form:
  2791.  
  2792.         ICLnnnI (error message)
  2793.                 ON THE WAY TO STATEMENT nnnn
  2794.                 CORRECT SOURCE AND RESUBMIT
  2795.  
  2796. The  message  varies depending upon the error involved.  For
  2797. undecodable statements the message is the statement  itself.
  2798. The  second  line  tells  which  statement  would  have been
  2799. executed next had the error not occurred.  Note that if  the
  2800. error  is  due  to  80  attempted  levels  of  NEXTing,  the
  2801. statement which would have been executed next  need  not  be
  2802. anywhere near the statement causing the error.
  2803.  
  2804. _9_._2  _M_e_s_s_a_g_e_s
  2805.  
  2806. Brief  descriptions  of the different error types are listed
  2807. below according to message number.
  2808.  
  2809.  000 An undecodable statement has been  encountered  in  the
  2810.      course  of  execution. Note that keypunching errors can
  2811.      be  slightly  disastrous,  since   if   'FORGET'   were
  2812.      misspelled  F-O-R-G-E-R, the results would probably not
  2813.      be those desired. Extreme misspellings  may  have  even
  2814.      more  surprising consequences. For example, misspelling
  2815.      'FORGET' R-E-S-U-M-E could have drastic results.
  2816.  
  2817.  017 An expression contains a syntax error.
  2818.  
  2819.  079 Improper use has been made of statement identifiers.
  2820.  
  2821.  099 Improper use has been made of statement identifiers.
  2822.  
  2823.  123 Program has attempted 80 levels of NEXTing.
  2824.  
  2825.  129 Program has attempted to  transfer  to  a  non-existent
  2826.      line label.
  2827.  
  2828.  139 An  ABSTAIN  or  REINSTATE  statement references a non-
  2829.      existent line label.
  2830.  
  2831.  182 A line label has been multiply defined.
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.                            - 43 -
  2843.  
  2844.  
  2845.  
  2846.  197 An invalid line label has been encountered.
  2847.  
  2848.  200 An expression involves an unidentified variable.
  2849.  
  2850.  240 An attempt has been made to give an array  a  dimension
  2851.      of zero.
  2852.  
  2853.  241 Invalid   dimensioning   information  was  supplied  in
  2854.      defining or using an array.
  2855.  
  2856.  275 A 32-bit value has been assigned to a 16-bit  variable.
  2857.  
  2858.  436 A  retrieval has been attempted for an unSTASHed value.
  2859.  
  2860.  533 A WRITE IN statement or interleave  (c/)  operation  has
  2861.      produced a value requiring over 32 bits to represent.
  2862.  
  2863.  562 Insufficient data.
  2864.  
  2865.  579 Input data is invalid.
  2866.  
  2867.  621 The expression of a RESUME statement evaluated to #0.
  2868.  
  2869.  632 Program execution was terminated via a RESUME statement
  2870.      instead of GIVE UP.
  2871.  
  2872.  633 Execution has passed beyond the last statement  of  the
  2873.      program.
  2874.  
  2875.  774 A compiler error has occurred (see section 12).
  2876.  
  2877.  778 An unexplainable compiler error has occurred.
  2878.  
  2879. The following error codes are new in C-INTERCAL:
  2880.  
  2881.  111 You  tried  to  use  a  C-INTERCAL  extension  with the
  2882.      `traditional' flag on.
  2883.  
  2884.  127 Can't find syslib.i file when it's needed  for  magical
  2885.      inclusion.
  2886.  
  2887.  222 Out of stash space.
  2888.  
  2889.  333 Too many variables.
  2890.  
  2891.  444 A  COME  FROM  statement references a non-existent line
  2892.      label.
  2893.  
  2894.  555 More than one COME FROM references the same label.
  2895.  
  2896.  666 Too many source lines.
  2897.  
  2898.  777 No such source file.
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.                            - 44 -
  2909.  
  2910.  
  2911.  
  2912.  888 Can't open C output file
  2913.  
  2914.  999 Can't open C skeleton file.
  2915.  
  2916.  998 Source file name with  invalid  extension  (use  .i  or
  2917.      .[3-7]i).
  2918.  
  2919.  997 Illegal possession of a controlled unary operator.
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.                            - 45 -
  2975.  
  2976.  
  2977.  
  2978. _1_0_.  _T_h_e _C_-_I_N_T_E_R_C_A_L _C_o_m_p_i_l_e_r
  2979.  
  2980. _1_0_._1  _C_h_a_r_a_c_t_e_r _S_e_t
  2981.  
  2982. The  C-INTERCAL  compiler  uses ASCII rather than EBCDIC. We
  2983. follow the Atari implementation by (a) replacing the  change
  2984. sign  (c/) with big money ($) as the mingle operator, and (b)
  2985. replacing the bookworm (V-)  symbol  with  what  (?)  as  the
  2986. exclusive-or operator.
  2987.  
  2988. _1_0_._2  _U_s_a_g_e _a_n_d _C_o_m_p_i_l_a_t_i_o_n _O_p_t_i_o_n_s
  2989.  
  2990. To  compile  an INTERCAL program `foo.i' to executable code,
  2991. just do
  2992.  
  2993.         ick foo.i
  2994.  
  2995. There's a -c option that leaves  the  generated  C  code  in
  2996. place  for  inspection  (suppressing  compilation to machine
  2997. code), a -d option that enables verbose parse reporting from
  2998. the  yacc/bison  parser,  a  -t  option that requires strict
  2999. INTERCAL-72  compliance  (rejecting  COME   FROM   and   the
  3000. extensions  for  bases  other  than  two),  a -b option that
  3001. disables the INTERCAL-72 random-bug feature (E774),  and  an
  3002. -O  option  that enables the (hah!) optimizer.  Invoking ick
  3003. -?  prints a usage message.
  3004.  
  3005. Another  compilation  switch  affects  C-INTERCAL's  runtime
  3006. behavior.   The  `-C'  option  forces  output in "clockface"
  3007. mode, for  superstitious  users  who  believe  writing  "IV"
  3008. upside-down offends IVPITER and would rather see IIII.
  3009.  
  3010. _1_0_._3  _R_u_n_t_i_m_e _O_p_t_i_o_n_s
  3011.  
  3012. Every  C-INTERCAL  runtime  also  accepts certain options at
  3013. runtime.  These  include  [+/-]help,  [+/-]traditional,  and
  3014. [+/-]wimpmode.   The  help  option  (with  either  +  or  -)
  3015. triggers a  'usage'  message.  The  +traditional  option  is
  3016. presently a no-op.
  3017.  
  3018. Steve   explains:   "The   wimpmode   option   is  the  most
  3019. interesting. I found myself always running my test  programs
  3020. with  filters  on  both  ends  to  work  around  the 'nifty'
  3021. INTERCAL number representations. This was so painful that  I
  3022. decided  it would be LESS painful (and a lot less code) if I
  3023. added a 'wimp' option.  With the +wimpmode option, the  user
  3024. is  subjected  to a humiliating message about what a wimp he
  3025. or she is to use this mode, but after that is allowed to use
  3026. conventional   numerical   notation.    While  such  a  mode
  3027. doubtless violates to some extent the  INTERCAL  philosophy,
  3028. the  fact that a 'unbutcher' command has been posted clearly
  3029. indicates the need for it. Anyway... if you don't  like  it,
  3030. don't  use  it...  the  default  is -wimpmode (i.e. NOT wimp
  3031. mode)."
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.                            - 46 -
  3041.  
  3042.  
  3043.  
  3044. _1_0_._4  _P_L_E_A_S_E _P_o_l_i_t_e_s_s_e _C_h_e_c_k_i_n_g
  3045.  
  3046. A feature of INTERCAL-72  not  documented  in  the  original
  3047. manual  was  that  it  required a certain level of politesse
  3048. from the programmer.  If fewer than  1/5th  of  the  program
  3049. statements  included the PLEASE qualifier, the program would
  3050. be rejected as insufficiently polite.  If more than 1/3rd of
  3051. them  included  PLEASE,  the  program  would  be rejected as
  3052. excessively polite.
  3053.  
  3054. This check has been implemented in  C-INTERCAL.   To  assist
  3055. programmers in coping with it, the intercal.el mode included
  3056. with the distribution randomly  expands  "do  "  in  entered
  3057. source to "DO PLEASE" or "PLEASE DO" 1/4th of the time.
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.                            - 47 -
  3107.  
  3108.  
  3109.  
  3110. _1_1_.  _T_h_e _A_t_a_r_i _I_m_p_l_e_m_e_n_t_a_t_i_o_n
  3111.  
  3112. The  Atari  implementation  of  INTERCAL  differs  from  the
  3113. original Princeton version primarily in  the  use  of  ASCII
  3114. rather  than  EBCDIC. Since there is no "change" sign (c/) in
  3115. ASCII, we have substituted the "big money" ($) as the mingle
  3116. operator.   We  feel  that  this  correctly  represents  the
  3117. increasing  cost  of  software  in  relation  to   hardware.
  3118. (Consider that in 1970 one could get RUNOFF for free, to run
  3119. on a $20K machine, whereas today a  not  quite  as  powerful
  3120. formatter  costs  $99  and  runs on a $75 machine.)  We also
  3121. feel that there should  be  no  defensible  contention  that
  3122. INTERCAL   has  any  sense.   Also,  since  overpunches  are
  3123. difficult to read  on  the  average  VDT,  the  exclusive-or
  3124. operator  may  be  written  ?.  This correctly expresses the
  3125. average person's reaction on first  encountering  exclusive-
  3126. or,  especially  on  a  PDP-11.   Note that in both of these
  3127. cases, the over-punched symbol may also be used  if  one  is
  3128. masochistic,  or concerned with portability to the Princeton
  3129. compiler.   The   correct   over-punch   for   "change"   is
  3130. "c<backspace>/"   and   the  correct  over-punch  for  V-  is
  3131. "V<backspace>-".  These codes will be  properly  printed  if
  3132. you have a proper printer, and the corresponding EBCDIC code
  3133. will be produced by the /IBM option on the LIST command.
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.                            - 48 -
  3173.  
  3174.  
  3175.  
  3176. _1_2_.  _T_h_e _P_r_i_n_c_e_t_o_n _C_o_m_p_i_l_e_r
  3177.  
  3178. The Princeton compiler, written in  SPITBOL  (a  variant  of
  3179. SNOBOL),  performs  the compilation in two stages. First the
  3180. INTERCAL source is converted into SPITBOL source,  then  the
  3181. latter is compiled and executed.
  3182.  
  3183. It  should  be  noted  that  the Princeton compiler fails to
  3184. properly interpret certain multiply-subscripted expressions,
  3185. such as:
  3186.  
  3187.         ",1SUB",2SUB#1"#2"
  3188.  
  3189. This  is  not  a  "bug".  Being  documented,  it is merely a
  3190. "restriction". Such cases may  be  resolved  by  alternating
  3191. sparks and ears in various levels of expression nesting:
  3192.  
  3193.         ",1SUB',2SUB#1'#2"
  3194.  
  3195. which  is  advisable in any case, since INTERCAL expressions
  3196. are unreadable enough as is.
  3197.  
  3198. Since  there  is  currently  no  catalogued  procedure   for
  3199. invoking  the  compiler,  the  user must include the in-line
  3200. procedure shown on the following page in his job before  the
  3201. compilation  step.  Copies  of this in-line procedure may be
  3202. obtained at any keypunch if the proper keys are struck.
  3203.  
  3204. The compiler is then executed in the usual manner:
  3205.  
  3206.  
  3207.         // EXEC INTERCAL[,PARM='parameters']
  3208.         //COMPILE.SYSIN DD *
  3209.         {INTERCAL source deck}
  3210.         /*
  3211.         //EXECUTE.SYSWRITE DD *
  3212.         {input data}
  3213.         /*
  3214.  
  3215.  
  3216. The various parameters are described following  the  in-line
  3217. procedure.  At most one parameter from each set may apply to
  3218. a given compilation; if more than  one  are  specified,  the
  3219. results  are  undefined,  and  may  vary  depending upon the
  3220. particular  set  of  options.  The  default  parameters  are
  3221. underlined.
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.                            - 49 -
  3239.  
  3240.  
  3241.  
  3242.         //INTERCAL PROC
  3243.         //COMPILE EXEC PGM=INTERCAL
  3244.         //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
  3245.         //             DD DSN=SYS1.FORTLIB,DISP=SHR
  3246.         //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
  3247.         //SYSPUNCH DD DUMMY
  3248.         //SCRATCH DD DSN=&COMPSET,UNIT=SYSDA,SPACE=(CYL,(3,1)),DISP=(,PASS)
  3249.         //EXECUTE EXEC PGM=EXECUTE,COND=(4,LT)   3
  3250.         //SOURCES DD DSN=U.INTERCAL.SOURCES,DISP=SHR
  3251.         //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
  3252.         //             DD DSN=SYS5.SPITLIB,DISP=SHR
  3253.         //             DD DSN=SYS1.FORTLIB,DISP=SHR
  3254.         //SYSIN DD DSN=&COMPSET,DISP=(OLD,DELETE)
  3255.         //SYSOBJ DD SYSOUT=B,DCB=(BLKSIZE=80,LRECL=80,RECFM=F)
  3256.         //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
  3257.         //SYSPUNCH DD DUMMY
  3258.         // PEND
  3259.  
  3260.       Figure 3.  Inline procedure for using INTERCAL.
  3261.  
  3262. OOPPTT
  3263. NOOPT
  3264.      In the default mode, the compiler will print a list  of
  3265.      all  options  in  effect,  including  the  defaults for
  3266.      unspecified parameter groups and the  effective  option
  3267.      for  those  sets  where  one was specified. If NOOPT is
  3268.      requested, it causes the default mode to be assumed.
  3269.  
  3270. OOPPTTSSUUBB
  3271. NOOPTSUB
  3272. NOSUB
  3273.      Unless 'NOOPTSUB' is requested, the System  Library  is
  3274.      optimized,   resulting   in   much   more  rapid  NOSUB
  3275.      processing  of  function  calls.  Specifying   NOOPTSUB
  3276.      causes the non-optimized INTERCAL code shown in section
  3277.      6.3 to be used, whereas NOSUB requests that the  System
  3278.      Library be omitted altogether.
  3279.  
  3280. IAMBIC
  3281. PPRROOSSEE
  3282.      The  IAMBIC  parameter  permits  the  programmer to use
  3283.      poetic license and thus write in verse. If  the  reader
  3284.      does   not  believe  it  possible  to  write  verse  in
  3285.  
  3286. ____________________
  3287.  
  3288. 3. Pending  acquisition  of SPITBOL release 3.0, the SOURCES
  3289.    DD card must be replaced by the five cards:
  3290.  
  3291.            //NOOPTPFX DD DSN=U.INTERCAL.SOURCES(NOOPTPFX),DISP=SHR
  3292.            //NOOPTSUB DD DSN=U.INTERCAL.SOURCES(NOOPTSUB),DISP=SHR
  3293.            //OPTPFX DD DSN=U.INTERCAL.SOURCES(OPTPFX),DISP=SHR
  3294.            //OPTSUB DD DSN=U.INTERCAL.SOURCES(OPTSUB),DISP=SHR
  3295.            //PRELIM DD DSN=U.INTERCAL.SOURCES(PRELIM),DISP=SHR
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.                            - 50 -
  3305.  
  3306.  
  3307.  
  3308.      INTERCAL, he should send the authors a  stamped,  self-
  3309.      addressed  envelope,  along  with any INTERCAL program,
  3310.      and they will provide one which is verse.
  3311.  
  3312. FFOORRMMAATT
  3313. NOFORMAT
  3314.      In FORMAT mode, each statement  printed  is  put  on  a
  3315.      separate  line  (or lines). In NOFORMAT mode, the free-
  3316.      format source is printed exactly  as  input.   In  this
  3317.      latter  case,  statement  numbers are provided only for
  3318.      the first statement on a card, and  they  may  be  only
  3319.      approximate.  Also,  unrecognizable  statements are not
  3320.      flagged.
  3321.  
  3322. SEQ
  3323. NNOOSSEEQQ
  3324.      If the source deck has sequence numbers in  columns  73
  3325.      through  80,  specifying  'SEQ'  will  cause them to be
  3326.      ignored.
  3327.  
  3328. SOURCE
  3329. NNOOSSOOUURRCCEE
  3330.      If  NOSOURCE  is  selected,  all  source   listing   is
  3331.      suppressed.
  3332.  
  3333. LIST
  3334. NNOOLLIISSTT
  3335.      If  LIST is specified, the compiler will provide a list
  3336.      of statement numbers catalogued according  to  type  of
  3337.      statement.  The  compiler  uses  this  table to perform
  3338.      abstentions by gerund.
  3339.  
  3340. WIDTH=nn
  3341.      This sets the width (in number of  characters)  of  the
  3342.      output line for FORMAT mode output. The default is 113322..
  3343.  
  3344. CODE
  3345. NNOOCCOODDEE
  3346.      Include 'CODE'  in  the  parameter  list  to  obtain  a
  3347.      listing  of the SPITBOL code produced for each INTERCAL
  3348.      statement.
  3349.  
  3350. LINES=nn
  3351.      This determines the number of lines  per  page,  during
  3352.      both compilation and execution. The default is 6600..
  3353.  
  3354. DECK
  3355. NNOODDEECCKK
  3356.      Selecting 'DECK' will cause the compiler to punch out a
  3357.      SPITBOL object deck  which  may  then  be  run  without
  3358.      reinvoking the INTERCAL (or SPITBOL) compiler.
  3359.  
  3360. KKIIDDDDIINNGG
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.                            - 51 -
  3371.  
  3372.  
  3373.  
  3374. NOKIDDING
  3375.      Select  NOKIDDING  to eliminate the snide remarks which
  3376.      ordinarily accompany INTERCAL error messages.
  3377.  
  3378. GGOO
  3379. NOGO
  3380.      Specifying  'NOGO'  will  cause   the  program  to   be
  3381.      compiled  but  not  executed.  EXECUTE/NOEXECUTE may be
  3382.      substituted for GO/NOGO, but this  will  result  in  an
  3383.      error, and GO will be assumed.
  3384.  
  3385. BBUUGG
  3386. NOBUG
  3387.      Under  the  default,  there is a fixed probability of a
  3388.      fatal compiler bug being  worked  at  random  into  the
  3389.      program  being  compiled.  Encountering this bug during
  3390.      execution results in error  message  774  (see  section
  3391.      7.2).   This  probability  is  reduced  to  zero  under
  3392.      'NOBUG'.  This  does   not   affect   the   probability
  3393.      (presumably negligible) of error message 778.
  3394. _1_2_._1  _O_t_h_e_r _I_N_T_E_R_C_A_L _C_o_m_p_i_l_e_r_s
  3395.  
  3396. There are no other INTERCAL compilers. 4
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423. ____________________
  3424.  
  3425. 4. This  assertion  in  the INTERCAL-72 manual was blatantly
  3426.    contradicted by some notes  on  an  Atari  implementation
  3427.    included  at  the  end  of  the  manual.   So, you expect
  3428.    compiler manuals to be consistent?
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.                            - 52 -
  3437.  
  3438.  
  3439.  
  3440.                           TTOONNSSIILL AA
  3441.  
  3442.  
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.             The Official INTERCAL Character Set
  3449.  
  3450. Tabulated  on  page  53  are  all  the  characters  used  in
  3451. INTERCAL,  excepting  letters  and  digits, along with their
  3452. names  and  interpretations.  Also  included   are   several
  3453. characters  not  used  in  INTERCAL, which are presented for
  3454. completeness and to allow for future expansion.
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488. ____________________
  3489.  
  3490. 4. Since all other reference manuals have Appendices, it was
  3491.    decided  that  the  INTERCAL  manual  should contain some
  3492.    other type of removable organ.
  3493.  
  3494. 4. 5 This footnote intentionally unreferenced.
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.                            - 53 -
  3503.  
  3504.  
  3505.  
  3506. +-----------------------------------------------------------------------+
  3507. |             Character       Name    Use (if any)                      |
  3508. +-----------------------------------------------------------------------+
  3509. |.     spot    identify 16-bit variable                                 |
  3510. |:       two-spot        identify 32-bit variable                       |
  3511. |,       tail    identify 16-bit array                                  |
  3512. |;       hybrid  identify 32-bit array                                  |
  3513. |#       mesh    identify constant                                      |
  3514. |=     half-mesh                                                        |
  3515. |'      spark   grouper                                                 |
  3516. |`       backspark                                                      |
  3517. |!       wow     equivalent to spark-spot                               |
  3518. |?       what    _u_n_a_r_y _e_x_l_u_s_i_v_e _O_R _(_A_S_C_I_I_)                              |
  3519. |"       rabbit-ears     grouper                                        |
  3520. |".  rabbit  equivalent to ears-spot                                     |
  3521. ||       spike                                                          |
  3522. |%       double-oh-seven percentage qualifier                           |
  3523. |-      worm    used with angles                                        |
  3524. |<       angle   used with worms                                        |
  3525. |>       right angle                                                    |
  3526. |(       wax     precedes line label                                    |
  3527. |)       wane    follows line label                                     |
  3528. |[       U turn                                                         |
  3529. |]       U turn back                                                    |
  3530. |{       embrace                                                        |
  3531. |}       bracelet                                                       |
  3532. |*       splat   flags invalid statements                               |
  3533. |&       ampersand7    unary logical AND                                |
  3534. |V       V (or book)     unary logical OR                               |
  3535. |V-   bookworm (or universal qualifier)       unary exclusive OR         |
  3536. |$       big money       _b_i_n_a_r_y _m_i_n_g_l_e _(_A_S_C_I_I_)                          |
  3537. |c/   change  binary mingle                                              |
  3538. |~       sqiggle binary select                                          |
  3539. |_     flat worm                                                        |
  3540. |-   overline        indicates "times 1000"                             |
  3541. |+       intersection    separates list items                           |
  3542. |/       slat                                                           |
  3543. |\      backslat                                                        |
  3544. |@       whirlpool                                                      |
  3545. |-'   hookworm                                                           |
  3546. |^       shark (or simply sharkfin)                                     |
  3547. |#*[]      blotch                                                         |
  3548. +--------T-a-b-l-e--2--(-t-o-p--v-i-e-w-)-.--I-N-T-E-R-C-A-L--c-h-a-r-a-c-t-e-r--s-e-t-.---------------------+
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558. ____________________
  3559.  
  3560. 7. Got any better ideas?
  3561.  
  3562.  
  3563.  
  3564.  
  3565.