Gekko uses the ‘funny symbols’ (sigils) % and # to indicate scalars and collections (for instance lists), respectively. More about these in the previous post. But how to think about them? For instance, in Gekko 2.0, a scalar value is written like “VAL v = 100;”, not “VAL %v = 100;”, but how come the % sigil is dropped? Also, how to denote a scalar %v residing in a databank bank1? Should it be bank1:%v, or should it be %bank1:v? The first one is perhaps obvious, but the last one also makes kind of sense, if the % sigil is used to say: the following is of scalar type. Fortunately, there is one interpretation of sigils that removes all ambiguities: that the sigil is just a character that happens to be part of the name. So %v could just as well have been scalar_v, and #m could have been collection_m, using ‘scalar_’ instead of ‘%’, and ‘collection_’ instead of ‘#’. So the right way to think about sigils in Gekko is that they are just special kinds of allowed characters to compose a variable name from, so ‘%’ and ‘#’ should be thought of as a kind of enhanced alphabet for variable names, among the other characters like ‘a’, ‘b’, etc. So in this sense, % and # are just characters, but they have some special properties. First, the % and # sigil must always be the first character of the variable name. Second, when a variable is assigned, the type of the right-hand side must match the kind of sigil on the left-hand side. So “x = 2015q3;” will issue an error, since the right-hand side scalar date cannot be transformed into a timeseries x, and similarly “%x = (100, 200);” would not work either, since the right-hand side list of values cannot be transformed into a scalar (neither of string, value or date type).

So to return to the initial question, the conclusion is that “VAL v = 100;” is just short-hand for the more strict “VAL %v = 100;”, since VAL already indicates that v is a scalar. In Gekko 3.0, the even more terse “%v = 100;” will be legal, too, dropping the VAL. So referring to %v in the databank bank1 can only be done in one way: bank1:%v. The other variant, %bank1:v does not make sense, since databank names are always plain characters without sigils. Sigils also live happily inside MAP-type collections, for instance “#m = (%start = 2020q1, %factor = 100);”. (The MAP type is a new dictionary type for Gekko 3.0 that can be thought of as a kind of mini-databank to store things). Later, these can be referenced to by means of indexer references like #m[‘%start’] or #m[‘%factor’], or the short-hand dot notation #m.%start or #m.%factor. Realizing that the sigils are just characters among other characters makes thinking about such syntax very straightforward.

In the next post, we will look at the question of frequency indicator, since this can be understood as a sigil, too.