_assert(cond: bool, msg:
any): bool
If cond is TRUE, _assert returns TRUE.
Otherwise, it prints the value msg as with the
_print function and terminates the evaluation with a runtime
error.
This is a better method for indicating failure than using the
err type, as it terminates execution immediately and prints
a message which may be helpful in diagnosing the problem.
_print(v: any,
dependencies:
int = 0, verbose: bool = FALSE): any
Prints out the value v to standard output. Primarily this
is useful for debugging your models. The return value of
_print
is just the first parameter v. Setting dependencies
to 1 or 2 and/or setting
verbose to TRUE gives
increasing amounts of information about the value printed.
name = "my_program";
_print("Building program " + name) // Produces the output "Building program my_program"
_print([ foo = 1, bar = "some text" ]) // Produces the output [foo=1,bar="some text"]
Note that in the Vesta SDL a
function call is a type of
expression but not a type
of
statement. This means that if you write this in your model code,
you'll get a syntax error:
_print(myVar);
Instead, you have to write this.
dummy = _print(myVar);
If deps is greater than zero, the value's dependencies
are also printed. In the current implementation, values of 1 and 2 provide
different levels of detail. This feature is probably only useful for debugging
the evaluator itself.
Passing TRUE for verbose affects the printing
of text and function
values:
-
A text value that is represented
by a file (e.g. a source imported in a files
clause or a result file generated by a tool
invocation) is normally printed as "<file 0xXXXXXXXX>"
where "XXXXXXXX" is the file's unique identifying number (known
as a "shortid"). If verbose is TRUE, the
contents of the file are printed as a double-quoted string (with newlines
represented by "\n", etc.). text
values without backing files are always printed as double-quoted strings.
-
A user-defined function
is normally printed as "<Closure>". If verbose
is TRUE, the complete list of formal parameters, the function
body, and the definition context are printed. A function
value that represents a model is always printed
as "<Model name>", where name is a name
for the model file in the repository. A function
value that represents a primitive function is
always printed as the name of the primitve function.
Kenneth C. Schalk
<ken@xorian.net>
/ Primitive Functions / Vesta
SDL Programmer's Reference