The $ZORDER function is a legacy function. Newer code should use $QUERY instead.


ObjectScript allows indirect access to object property values via $PROPERTY, but also to parameters, methods and class methods using $PARAMETER, $METHOD and $CLASSMETHOD respectively.

For instance:

ObjectScript supports try/catch statements. Old code would have to resort to using the $ETRAP system variable, as in:

    new $etrap
    set $etrap = "do somethingElse()"

    // Execute "do somethingElse()" if "do something()" throws an exception
    do something()

This should be replaced with:

Setting the $ECODE special variable is especially confusing and, moreover, dangerous:

  • it will throw an exception if and only if the value is not an empty string;
  • since this is the SET command, in addition to this, there may also be a postconditional.

As a result, when reading this line:

The QUIT command can be used for three different scenarios in program code:

  • exit the method with no value;
  • exit the method with a value;
  • breaking out of a loop statement, try block or catch block.

As a result, this can lead to code where it is very confusing to actually detect the usage, all the more that the nesting level is deep and the code is long; consider for instance:

Non short circuit operators will evaluate all expressions even if one would normally stop the execution if short circuit operators were used instead.

If the use of such an operator is done on purpose, this is very often an indication that one or more checks in the boolean expression have side effects, which is undesirable. Try and refactor the code so as to avoid the use of such operators.

Using GOTO for control flow is not recommended. Moreover, it can lead to unsuspected runtime failures. Look at this code for instance:

Method m()
    goto out;
    write "Writing", arg," and out", !

out is really a subroutine embedded in the method, and it expects an argument. Here however, there isn't any, and the failure will not occur until runtime.

In some situations, an application may want to switch namespaces temporarily using, for instance:

    Method m()
        set oldNs = $namespace
        set $namespace = newNs // or: znspace newNs
        do ..something()
        set $namespace = oldNs // or: znspace oldNs

But if the code between namespace changes fails for any reason, the namespace will not be switched back. The solution is to use new $namespace instead:

This check reports all classes or methods which are not documented.

ObjectScript does allow more than one statement on the same line, and in fact if you use legacy flow control statements (which you shouldn't, really) you even have to put more than one statement on a same line.

However, this can lead to quite confusing code; recall that statements have no delimiters bewteen them other than spacing. Consider:

    // If c is true, write variable "x" then quit
    if c w x q