Template:Prelude/general.a68

From Rosetta Code
Revision as of 06:45, 26 August 2011 by rosettacode>NevilleDNZ (→‎ALGOL_68/prelude/general.a68: useful base routines.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
  1. 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.