What is a sigil? In Gekko, sigils are used to denote general variable types, for instance %x if it is a scalar (string/value/date), #x if it is a collection (list, matrix or map), and plain x if it is a timeseries. The use of # was inherited from AREMOS, but AREMOS uses # for all kinds of variables (except timeseries), so in command files (programs), one would often wonder whether a variable is, for instance, a string or a list (kudos to the guys at DØRS for pointing this out years ago). Hence, in Gekko 2.0, the % sigil was introduced for scalar values.
Now, why use sigils at all? That is a good question, and Gekko could run just fine without sigils. But there are benefits to them, first of all readability of command files. In an integrated development environment (IDE), the user can just hover the cursor over some variable x, and the type of x and other info will pop up. But Gekko users do not use IDE’s, they use different kinds of text editors to handle the command files. Granted, it is possible to have the editor color Gekko command names etc. (for instance, for Sublime Text, here). Such coloring helps, but it still does not tell you the type of different variables. This is what the sigils do. A statement like “z = %x * y;” is pretty clear in the sense that %x is a scalar value (the statement does not make sense if %x were a string or date), and z and y are timeseries. Similarly, a statement like “PRINT x{%x};” prints a single variable. If %x is the string ‘a’, the statement is equivalent to “PRT xa;”. On the contrary, a statement like “PRINT x{#x};” prints a list of variables. If #x is a list of the strings ‘a’ and ‘b’, the statement is equivalent to “PRINT xa, xb;”. So, in large command files, the sigils help out regarding readability.
Another, but less important advantage of sigils is that text substitution gets a bit easier. You can write “%s = ‘The %a runs fast’;”, and Gekko will insert the string %a (an animal name, for instance). Without sigils, you would have to do something like “s = ‘The ‘ + a + ‘runs fast’;”. Still, that is just a minor benefit.
The use of sigils permits some typing short-cuts, too. For instance, it can be convenient to state a list of strings like this: “#m = a, b, c, d;” instead of the more cumbersome “#m = ‘a’, ‘b’, ‘c’, ‘d’;”. The easier version can be permitted, since we know that a, b, c and d are timeseries names (and not, for instance, string variables, scalars or other types). Another example is in options, where we can write, for instance, “COPY<from=bank1>;” instead of “COPY<from=’bank1’>;” and Gekko will also understand bank1 as the string ‘bank1’ in the first variant, and not try to look up a variable named bank1. It may also at some point be permitted to use x[a] instead of x[‘a’] for array-timeseries, because x[a] does not make sense, if a is a timeseries.
Finally, sigils enhance the namespace. This is not that important per se, but it means that you can use the same variable names for different types, for instance x for the timeseries, %x for a related scalar, and #x for a related collection.
All in all, the benefits of sigils in Gekko probably outweighs the drawbacks, the primary benefit being that large command files (programs) become easier to decipher at a glance, since the timeseries, scalars and collections stand out via the sigils. The drawbacks are that some users may find the sigils strange, or difficult to remember. It is not the intention to use sigils for other things than indicating variable type, and there will probably never be other sigils than # and % in Gekko. Turbocharging sigils with all sorts of complicated capabilities like in, for instance the computer language Perl (not least the infamous Perl 6), is not going to happen in Gekko. The next post (“How to think about sigils?”) deals with the question of how to think about the sigils in Gekko. It is actually very simple, read for yourself!
Recent Comments