swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax    
declaration/definition  

optional

 
 

Syntax

  argument-class argument-type argument-name optional (initial {initial-values})?


Purpose

Declares a function's argument as optional. An optional argument can be omitted from a call by omitting the preceding function argument separator together with the value of the argument.

The initial value of an optional function argument can be a dynamic value. The default initial value is calculated each time the function is called and the default value is needed. This means that default values can depend on global and constant values.

A value argument that is declared optional can also be provided with a default value or values in curly braces ("{ }"). Modifiable and read-only arguments can also be declared optional, but they can't have default values. Remainder arguments can't be optional.

When an optional argument with no default value is omitted from a function call, it is illegal to access that argument from within the function in any way, except to test whether it was specified. (Whether an optional argument was specified in a call can be determined using the is specified argument test.)

In particular, for an argument whose value is not specified in the function call, these two statements can be made:

For example, the following function is defined with an optional argument:

  define function increment modifiable integer x
             by value integer y optional initial {1} as
      set x to x + y

    Related Syntax
   remainder
   is specified
 
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACYLIBRARIES ] [ ERRORS ]

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:45:40 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.