Next: Tokens

Example Method

Here is an example of a simple C-- method. This method might be used in a mud server to handle a tell_contents message sent to a container object. Here is the code for the method:

arg str;
var obj;

for obj in (contents) { // Tell the string to the object. (| obj.tell(str) |); }

This method takes one argument, str, a string to send to each object in the room. The method uses a local variable obj to traverse the list stored in the object variable contents. The body of the method is a for loop, which traverses the contents list. For each element in the for list, this method sends a tell message with the string. The parenthesis and vertical bar delimiters ((| and |)) surrounding the message expression mark it as a critical expression. Errors which occur inside a critical expression are ignored; thus, errors which occur during the processing of the tell messages won't cause the tell_contents method to abort.