BOOL has an
#inline option for Action definitions that allows (but does not require) treating an Action as if it was inserted into the code flow. There is also the idea of native Actions, defined as such by the standard, which are also allowed to be inline.
But a design goal is the ability to implement basic language constructs (such as
if statements and
while loops) in the language itself.
So here are some of those native Actions:
In the third entry in the Actions series showed an example of how an
if-elseif-else Action might be written.
@@while >> *one expr >> *any list << *bool swx = t:expr; =? swx . list . set:sxw t:expr;;
And the Until version:
@@until >> *one expr >> *any list << *bool swx = f:expr; =? swx . list . set:sxw f:expr;;
We might use the
while like this:
= . *bool flag = TRUE . @while flag . . // --do loop stuff-- . . set:flag status
Presumably, status is set by something in the loop. (Or by time elapsing or by loop cycles or by something, ’cause the loop continues until flag is FALSE!)
The sub-clauses allow some interesting constructs:
@@Section >> *any intro @@Preamble #optional >> *one test-pre >> *any list-pre @@Paragraph #repeatable >> *one test-para >> *any list-para @@Postscript #optional >> *one test-post >> *any list-post [Section] . intro [Preamble] =? true:test-pre . list-pre [Paragraph] =? true:test-para . list-para [Postscript] =? true:test-post . list-post
This allows authors to write code like this:
= . @Section . . @print "Begin Section" . . *int angle . @Preamble test-expression . . // --do header stuff-- . @Paragraph test-expression . . // --- paragraph one --- . @Paragraph test-expression . . // --- paragraph one --- . @Paragraph test-expression . . // --- paragraph one --- . @Paragraph test-expression . . // --- paragraph one --- . @Postscript test-expression . . // --do footer stuff-- .
@Paragraph clauses can appear as often as desired (at least one is required); the
@Postscript clauses are optional. The parts must occur in the order defined by the Action.