Tcl Octalogue

Octalogue is eight rules that describe Tcl language as found from https://wiki.tcl-lang.org/page/Dodekalogue.

Script
A script is composed of commands delimited by newlines and semicolons, and a command is composed of words delimited by whitespace.
Evaluation
After escapes and substitutions in each word are processed, words preceded by {*} are transformed into multiple words in the command, the first word of each command is used to locate a routine, and that routine is called with the remaining words as its arguments.

Comment
If # is the first character in the name of a command and is not otherwise escaped or quoted, the characters up to the next newline are a comment. No command execution is attempted, and no characters in the line are interpreted, except that a newline preceded by an odd number of \ characters is ignored.
$varname
Replaced by the value of the variable named varname, which is composed only of one or more sequences letters, digits, or underscore characters delimited by namespace separators. If varname is enclosed in braces, it is composed of all the characters between the braces and no substitution or escaping is performed on the name. Where varname contains an opening parenthesis and ends with a closing parenthesis, the characters between the first open parenthis and the last are the name of a member variable in the array. The member variable name is subject to backslash interpretation and substitutions.
\char
Replaced with the character following char, except when char is a, b, f, n, t, r, v, which respectively signify the unicode characters audible alert (7), backspace (8), form feed (c), newline (a), carriage return (d), tab (9), and vertical tab (b). Additionally, when char is o, x, u, or ‘U”’, it specififies a unicode character by 1 to 3 octal digits, 2 hexadecimal digits, 1 to 4 hexadecimal digits, or 1 to 8 hexadecimal digits, respectively.
Brackets
A script may be embedded at any position of any word by enclosing it in brackets. The embedded script is passed verbatim, without any processing, to the interpreter for execution and the result is inserted in its place in the embedding script. The result of a script is the result of the last routine in the script.
Quotes
In a word enclosed in quotes, whitespace and semicolons have no special meaning.
Braces
In a word enclosed in braces, whitespace, semicolons, $, brackets, and \ have no special meaning. However \newline substitution is performed when the newline character is preceded by an odd number of \ characters. Any nested opening brace character must be paired with a matching closing brace character later. An opening or closing brace character preceded by an odd number of \ characters is not considered as one of any pair.

Leave a Reply

Your email address will not be published. Required fields are marked *