The basic YCP
data types we got to know in Chapter 2, YCP Data Types are evaluated in a rather straight
forward way as will be shown in the following list.
Evaluation of basic data types
Simple data types
Most of the YCP data types can't be “evaluated” at
all, as they simply evaluate to themselves. This holds for the
simple types void
, boolean
,
integer
, float
,
string
, symbol
and
path
.
list
When evaluating a list, the interpreter evaluates all the list elements thereby forming a new list.
{ list list_var = [ 1 + 1, true || false, "foo" + "bar" ]; y2milestone("list_var: %1", list_var ); }
yields the log file entry
...ycp/list_eval.ycp:4 list_var: [2, true, "foobar"]
map
A map is handled similar to a list. The values (but not the keys) are evaluated to form a new map.
{ map map_var = $[ "one" : `one, `two : "one" + "one" ]; y2milestone("map_var: %1", map_var ); }
yields the log file entry
...ycp/map_eval.ycp:4 map_var: $["one":`one, `two:"oneone"]
term
Upon evaluation, term parameters are evaluated to form a new term.
{ term term_var = `val ( 1 + 1, true || false, "foo" + "bar" ); y2milestone("term_var: %1", term_var ); }
yields the log file entry
...ycp/term_eval.ycp:4 term_var: `val(2, true, "foobar")
All the evaluations we have seen above are closely related to
operators that may be used within an expression to act on the
variables. The next section will give an overview of the operators
that can be used in YCP
.