Experience has shown in the past that such limiting assumptions might be badly mistaken, and that programmers find ways of using the language in strange and obscure ways, up to a point where the original intention gets entirely out of sight. Perl is a nice example of a language that has grown far beyond whatever its original designer might have had in mind at the time.
In any case, RainCode provides a convenient and flexible sub-routine mechanism that can be used to factorize a functionality and reuse it from several different places in a script. This mechanism can also be used to abstract a piece of code in a separate sub-routine, to improve readability and structure, and thereby, ease maintenance.
ProcedureDeclaration ::=
PROCEDURE Identifier QFormals
QLocals
BEGIN
StatementList
END Identifier ";"
QFormals ::= "(" IdentList ")" |
<void>
QLocals ::= VarDeclarations | <void>
RainCode's routines are called procedures. For instance, consider the following example:
PROCEDURE Dump (a);
BEGIN
OUT.WriteLn ("a is : " , a);
END Dump;
The Dump procedure can be called, using the common Pascal-like syntax:
Dump("Hello world");
RainCode performs no type checking on a procedure's argument.
It is a true polymorphic language. Executing Dump(79)
will display:
a is : 79
on the standard output stream.