external next up previous contents index
Next: 16.7 Debugging Code Up: 16.6 Eval Previous: Basic Eval (by Andy

Eval Options (by Andy Bakun)

 

Acknowledgment: This text is a formatted version of a message posted to *Teaching on WorldMOO by Andy Bakun.

A few options are available to eval to make it easier to use and more informative. By default, you can't use the variables 'me' and 'here' in an eval. Before your eval is executed, the eval verb inserts the contents of your .eval_env prop. $prog's .eval_env is defined as "here=player.location;me=player" so all descandants of $prog can use 'me' and 'here' in their evals.

   ;me
   => #1353 (ThwartedEfforts)

You can add more things to your .eval_env prop, , I have 'su=$string_utils;lu=$list_utils; in my .eval_env, so I can use 'lu' and 'su' in my evals (which is much easier to type). One of the drawbacks of this is that if your eval crashes with a traceback, the line number count will be off from what you entered for your eval. (small price to pay)

You can also have it tell you about how many ticks and seconds your eval ate up, by setting your .eval_time prop to 1. (try ;me.eval_time = 1). This will not be accurate if your eval fork()'ed or suspended().

Unfortately, if you use .eval_time and .eval_env, your tick count will be effected by all the ticks that are in your .eval_env. This can be fixed by setting your .eval_ticks prop with the number of ticks your eval_env eats up. To find out how many ticks your eval_env takes, set your .eval_ticks to 0, eval_time to 1 and then put your preliminary set up code in your .eval_env. Then just do an empty eval:

   ;
   => 0
   [used 23 ticks, 1 second.]

and it will tell you how many ticks your empty eval took. Use that value to set your .eval_ticks prop. Above, my empty eval took 23 ticks, so I set my .eval_ticks prop to 23. Then an empty eval will take 0 ticks, as it should, since there isn't any code. The usefulness of this is so that only the code that you want to evaluate will have the tick count, and your setup code will not be included.


next up previous contents index external
Next: 16.7 Debugging Code Up: 16.6 Eval Previous: Basic Eval (by Andy

Daniel K. Schneider
Thu Apr 17 12:43:52 MET DST 1997