Template:Prelude/general.a68: Difference between revisions
Content added Content deleted
(add some more useful MODEs and exceptions) |
m (fix typo) |
||
Line 2: | Line 2: | ||
COMMENT |
COMMENT |
||
This is an ALGOL 68 prelude file called prelude/general. |
This is an ALGOL 68 prelude file called prelude/general. |
||
It contains small |
It contains small routines that are not part of any standard, |
||
but are none the less useful and widely used. |
but are none the less useful and widely used. |
||
USAGE |
USAGE |
Revision as of 02:20, 2 September 2011
<lang algol68># -*- coding: utf-8 -*- # COMMENT
This is an ALGOL 68 prelude file called prelude/general. It contains small routines 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
- -*- coding: utf-8 -*- #
- Define some general routines and MODES #
MODE
UTFCHAR = STRING, LONGCHAR = UTFCHAR, UTF=FLEX[0]LONGCHAR, LBITS = UNION(SHORT SHORT BITS, SHORT BITS, BITS, LONG BITS, LONG LONG BITS), LBYTES = UNION(SHORT SHORT BYTES, SHORT BYTES, BYTES, LONG BYTES, LONG LONG BYTES), LINT = UNION(SHORT SHORT INT, SHORT INT, INT, LONG INT, LONG LONG INT), LREAL = UNION(SHORT SHORT REAL, SHORT REAL, REAL, LONG REAL, LONG LONG REAL), LCOMPL = UNION(SHORT SHORT COMPL, SHORT COMPL, COMPL, LONG COMPL, LONG LONG COMPL);
MODE SIMPLEOUT = [0]UNION(BOOL, CHAR, STRING, UTF, LBITS, # LBYTES,# LINT, LREAL, LCOMPL);
- Use MOID with "*:=" OPerators who's where the returned MODE is often VOIDed for convenience #
MODE MOID = VOID;
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);
PROC raise index error = (SIMPLEOUT argv)VOID:
raise exception("Index Error",argv);
- KEEP * #</lang>