0 1024 07531 // Octal 7531, equal to 3929 decimal 0xa0 // Hex a0, equal to 160 decimal
Text literals follow the C/C++ convention for double-quoted strings. Examples of valid text literals:
"" "Simple text." "Text with \"quotes\"." "Examples of\n\tescaped whitespace.\n"
List literals are enclosed in angle brackets with individual elements separated by commas:
<1, "abcdefg", FALSE>List elements can be specified by any arbitrary expression, including lists:
<1, <"abc", "def", "ghi"> >A trailing comma is allowed after the last list element:
<1, 2, 3, 4, >The empty list can be represented by angle brackets with nothing between them:
Binding literals are enclosed in square brackets with commas separating individual assignments. As with lists, the empty binding can be represented with empty square brackets:
The simplest way to write a binding is as though it were a sequence of variable assignments:
[ foo = 1, bar = TRUE, msg = "a string", ]The values can be arbitrary expressions (including other lists, nested bindings, etc.). Note that, as with lists, a trailing comma is allowed. Beyond this form, there are a variety of shortcuts and more complicated forms for creating bindings. The simplest of these is the self-assigning binding:
[ foo, bar, msg ]This is equivalent to writing:
[ foo = foo, bar = bar, msg = msg ]If foo, bar, and msg are variables with values assigned to them, then this would capture the values of those variables in the binding. As with lists, it is possible to have bindings containing bindings:
[ foo = [ a = 1 ], bar = [ b = 2] ]However, it can quickly become tedious to write nested bindings in this fashion. For this reason, there's a shortcut. The following binding is equivalent to the previous one:
[ foo/a = 1, bar/b = 2 ]These nested binding "paths" can be arbitrarily deep. For example, these two bindings are equivalent:
[ Cxx/switches/program/shared_libs = "-non_shared" ]It's possible to replace either the name in a binding assignment or one of the names in a binding path assignment with a variable or an arbitrary expression. If there is a variable containing a text value, it can be prepended with the dollar sign to use its value as a name:
[ Cxx = [ switches = [ program = [ shared_libs = "-non_shared" ] ] ] ]
There are two different but equivalent forms with which arbitrary expressions can be used in place of names in bindings: $(expression) and %expression%. For example:name = "foo"; ... [ $name = 1 ] // Same as [ foo = 1] ... [ bar/$name/a = "a string" ] // Same as [ bar/foo/a = "a string"]
[ $("foo" + "bar") = TRUE ] // Same as [ foobar = TRUE ] [ %"foo" + "bar"% = FALSE ] // Same as [ foobar = FALSE ] [ foo/$(_sub("barbaz", 0, 3))/a = <1, 2, 3> ] // Same as [ foo/bar/a = <1,2,3> ] [ foo/%_sub("barbaz", 3, 3)%/b = <4, 5, 6> ] // Same as [ foo/baz/b = <4,5,6> ]
There is only one literal of type err: ERR.
The use of ERR is considered deprecated at this point, and is supported only to provide backward-compatibility with older Vesta models. A much better way to indicate a run-time error is with the _assert primitive function.
The Vesta evaluator currently treats type expressions as syntactically checked comments; it performs no other checking. Future implementations may type-check expressions at run-time and report an error if the value does not match the specified type.
The simplest form of type expression is just the name of one of the basic types: bool, int, text, list, binding, function. Also, you can express that something may be of any type with the keyword any. Each of the three aggregate types (list, binding, function) has more complex forms which allow you to specify the types of its componenets.
Would be a list of booleans. Incidentally, list by itself is equivalent to list(any).list(bool)
Specifies a binding where the value portion of each element is of type text. You can also specify that a binding must have particular names bound to particular types:binding(:text)
The above specifies a binding which must have three names (x, y, and z) all bound to integer values.binding(x:int, y:int, z:int)
Indicates a function which returns a boolean with unspecified arguments. Conversely:function : bool
Specifies a function which takes a single text string argument, but whose return type is unspecified. When argument types are specified, argument names may be as well:function(text)
The above describes a function taking a text argument named t and an integer argument named i and which returns a text string.function(t: text, i: int): text
Describes a function which:function(function(text, bool): int, binding(:bool)): list(int)