Pop-11 provides several means of printing information so that it goes to the terminal, into a file, into the editor buffer, or into a data-structure.
One of the most commonly used is the print-arrow, which we have seen previously. This comes in two versions.
=> (ordinary print arrow)This prints everything `on the stack', preceded by `**', unless called from inside a procedure, in which case it prints out only the top item of the stack, preceded by `**'. The stack is explained below. Roughly think of => as printing out the `unused' results of previously executed procedures.
==> (pretty-print arrow)This prints out only ONE object. If the object is a list or a vector, then if printing it out would take more than one line, the object is printed in a special format using indentation to make its structure clearer.
Examples:
33 + 66 => ;;; print sum of 33 and 66, preceded by two asterisks. ** 99 234 + 22 > 33 * 66 => ;;; is 234 + 22 bigger than 33 times 66? ** <false> X + 5 < Y => ;;; is the sum of X and 5 less than Y? ;;; X and Y should have numbers as values. 99 + 5 = 95 + 9 => ;;; is 99 + 5 equal to 95 + 9? ** <true> X = Y => ;;; does X have the same value as Y? X => ;;; print out the value of X. 10 // 3 => ;;; prints out remainder and quotient ** 1 3Complex structures, like lists of lists, can print out in a rather messy and unreadable manner using "=>"
[a [nested list of several words] and [another nested list of several words] too long to print easily] => ** [a [nested list of several words] and [another nested list of several words] too long to print easily]Compare how the pretty print arrow prints the same list:
[a [nested list of several words] and [another nested list of several words] too long to print easily] ==> ** [a [nested list of several words] and [another nested list of several words] too long to print easily]When lists are deeply nested the printout from => can be very confusing, so it is then best to use ==> instead. You can in fact always use `==>'. This is especially useful for a list of several lists of similar format. E.g.: Make a list of lists of information about people
[ [the mother of mary is suzy] [the father of mary is joe] [the mother of joe is miranda] [the father of joe is fred] ] ==>Which causes the following to be printed out neatly:
** [[the mother of mary is suzy] [the father of mary is joe] [the mother of joe is miranda] [the father of joe is fred]]Whereas using => would have produced:
** [[the mother of mary is suzy] [the father of mary is joe] [the mother of joe is miranda] [the father of joe is fred]]Note that => or ==> can be used to terminate an imperative without a semi-colon. They act as `separators' for imperatives.
Pop-11 provides a number of built in procedures for printing things in a more controlled format than the print arrows. In particular, the procedures pr and spr print things without starting a new line, and without printing the asterisks `**'. The difference is that spr prints a space after printing its argument. So:
pr("cat"); pr("mouse"); spr("hat"); spr("coat"); pr(99); catmousehat coat 99Similarly npr can be used to print things separated by newlines. It prints a newline after printing its argument.
pr("cat"); pr("mouse"); spr("hat"); npr("coat"); pr(99); catmousehat coat 99Using the built in printing procedures, it is fairly easy in Pop-11 to define your own procedures to print things out in whatever format you like. More information about printing can be found in the online file HELP PRINT. The REF PRINT file gives more complete information about printing mechanisms. There are utilities that simplify formatted printing, in particular the procedure printf, described in REF PRINT