Core Help Root: Commands: @eval


PROGRAMMER COMMAND

Syntax: @eval [<code>]

This command is a powerful tool given to programmers. Its primary function is to allow programmers to execute ColdC code without actually programming it as a method. Anything specified in <code> is compiled and executed immediately. Furthermore, it also provides profiling and debugging tools, and an alternate feature that will show the interpreter opcodes it becomes, rather than executing it.

The shortcut ; can also be used in place of @eval.

Example:

>; .location().announce("Testing.")
Testing.
=> $courtyard (the Courtyard)
[ seconds: 1.1022141; operations: 1506 (1506 ticks per second) ]

In this example, the .location() gives us the object name of where we currently are ($courtyard). The .announce() says that this location should announce to all the players in this location our message ("Testing."). If the code executes correctly, our message is displayed to everybody, and the @eval command returns the result of the expression, as well as the amount of time, operations, and ticks per second it took to perform the execution. Note: when measuring performance, the actual time it takes to execute is more important than the number of operations (because this is an interpreted language, different operations can be faster than the others, so the actual count is not a true representation of performance).

Execution Environment

By default, @eval will assume the code you are specifying is an expression, and will prefix it with 'return', so the value of the expression is returned. This is a problem if your code is a statement, instead of an expression (such as a looping statement). To avoid this you can define variables, or include 'return' in your code where it should be--and @eval will not prefix it.

Furthermore, @eval defines a set of variables which can be used by the ColdC code. These are: me and here, representing your own object and your current location, respectively.

Environment Substitution

Anywhere within the ColdC code (other than inside strings) you can use the carat character (^) followed by a string token of alphanumeric characters. If @eval finds this, it will try to match the token as a name against objects in your environment. If a match is found it will replace that token with the dbref for that object.

Execution Flags

One of the following flags can be defined before the ColdC code (seperated with a semi-colon), which will change the execution behaviour: trace, debug, profile or opcodes.

If trace is defined, a trace of all method calls made during the execution will be printed after execution is complete--along with the tick number they were made at. If debug is defined, the output is similar to trace but the tick number of the return statement is also included. If profile is defined, a breakdown of all method calls is provided, along with the number of ticks consumed by the method--sorted by the largest first. If opcodes is defined, the code will not actually execute, but instead will return the interpreter's opcodes for the method.



the Cold Dark