The DefaultResult Object

The DefaultResult object defines a result that will be returned by a function as its result if none of the clauses generate a result.

Functions in Sym will return the Null object if none of the clauses generate a result. In many cases, this is the desired result since a function on the right-hand side of a clause that returns null will cause the execution of the function to fall through to the next clause of the function. In other cases, if may be desirable for a function to always return a result. The DefaultResult object can be used in cases where a function is used in both ways.

The DefaultResult object is always used on one of the parameters of a function call. It can be used in functions that have more than one parameter.

The DefaultResult object is really just shorthand for an ElseList. In fact, in the Build function the DefaultResult object is converted to an ElseList. For example, if the function call is

then the build process will convert this to:

The DefaultResult object can also be used with functions with more than one parameter. In this case, the DefaultResult object is placed around the expression that will be the result if the function call returns null.