Template:Prelude/general.a68

From Rosetta Code
Revision as of 06:46, 26 August 2011 by rosettacode>NevilleDNZ (add prefix white space)
COMMENT
  This is an ALGOL 68 prelude file called prelude/general.
  It contains small routine that are not part of any standard, 
  but are none the less useful and widely used.
USAGE
  PR READ "prelude/general.a68" PR
END COMMENT
##########################################
# Define some general routines and MODES #
##########################################
MODE UTFCHAR = STRING;
MODE UTF=FLEX[0]UTFCHAR;
MODE SIMPLEOUT = [0]UNION(INT, CHAR, STRING, []STRING);
MODE MOID = VOID; # Use in cases where the OP should really return a MODE #

PROC raise exception = (STRING type, SIMPLEOUT argv)VOID:(
  BOOL exception = FALSE;
  putf(stand error, ($g$, "Exception"," ",type, ": ", argv, $l$));
  ASSERT (exception)
);

PROC raise undefined = (SIMPLEOUT argv)VOID:
  raise exception("Undefined", argv);

PROC raise value error = (SIMPLEOUT argv)VOID:
  raise exception("Value Error",argv);

This is a template. There are many others. See Category:RCTemplates for a complete list of templates.