Some patterns mimic language-style control methods: conditionals ( Pif ), loops ( Pwhile ) and error cleanup ( Pprotect ).
Pif(condition, iftrue, iffalse, default)
condition
that returns true or false. Then, one value is taken from the true or false branch before going back to evaluate the condition again. The default
value or pattern comes into play when the true or false branch stops producing values (returns nil). If the default
is not given, Pif returns control to the parent upon nil from either branch.
Pseed(randSeed, pattern)
pattern
, effectively restarting the random number generator at the start of the pattern.
Pprotect(pattern, func)
protect
error handling method, if an error occurs while getting the next value from the pattern, the function will be evaluated before the error interrupts execution.Ptrace(pattern, key, printStream, prefix)
trace
message: aPattern.trace(key, printStream, prefix) --> Ptrace(aPattern, key, printStream, prefix)
.Pwhile(func, pattern)
Previous: Pattern Guide 06d: Parallel Patterns
Next: Pattern Guide 06f: Server Control