Control Structures: General Concepts Commentary

General: As I have mentioned many times, Glee doesn't have semantics in the classical sense. It simply processes tokens in a left to right fashion. In general, Glee does short right scoping. This means it only looks one token ahead in deciding what to do. There are exceptions to this. One is the case where Glee has to resolve compound variables like "sales.reg2.south". Another case is with structures.




How it works: Control structure tokens are delimited by a leading colon ( : )as in ":for". The parser knows these tokens. When the parser sees the first :control token, it scans ahead collecting all additional related tokens until it has the entire suite for processing. For example: seeing :for, the parser looks for a parenthesis token "(...)" and then a block token "{...}". In cases where tokens may be elided, the collector internally puts in dummies having benign effect. In this documentation, I show tokens which can be elided in italics. Each of the various control structure sections will discuss their special scanning techniques. In general, all are totally intuitive. You should seldom need the full complex forms. As usual, you should avoid getting too cute. Once Glee has collected all the elements making up the control structure, it begins to process them as if they were a totally separate program. Actually, for some of the compound structures like "switch/case/default" and "if/elseif/else" it treats all the individual blocks as separate segments of code linked together by namespaces. It uses a separate instance of the parser and maintains communication between elements with namespace objects. The iterative structures like ":for" and ":do" may create vectors of results. If they do, they return a sequence containing these result elements. As usual, the tutorial examples will do more than many many words to help you understand the concepts and issues.






The :for structure: The :for structure is of the general form ":for (iterators) {code}". Additionally, iterators and code are of the general form "values[fieldlist]{code}. This is the same structuring already familiar to you from studying blocks, field lists, arguments, and namespaces. This general structure gives you much more flexibility and control over operation within the structure than any other language.





:




:




: