ExpandCollapsePrev Next Index

+ 9.1 Simple procedure definitions

It is also possible to defined new commands, these are called procedures. Procedures do not return a value, and may and generally should have side-effects. Here is a simple example:

  proc prompt (x:string) {
    write$ stdout, x; 
    fflush stdout;
  prompt "Input string: ";
  println$ readln$ stdin;

Road Runner beats Coyote!

Input string: Road Runner beats Coyote!
Road Runner beats Coyote!


  • The proc binder introduces a procedure.
  • The procedure prompt issues a prompt on stdout with a fflush to force the output to the device.
  • Procedures have side effects, here it is I/O.
  • Procedures cannot return values