contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
declaration/definition   remainder    
  Related Syntax   Related Concepts  

Syntax

  remainder shelf-type argument-name (argument-separator)?


Purpose

A remainder argument is a special kind of argument. It is used to pass a number of discrete values to a function as a single argument. OmniMark does this by "creating" a read-only shelf argument initialized by the values being passed.

If a function has a remainder argument, it must be the last argument. In the case that remainder is the first and only argument of a function, and it has no leading herald, the second herald must be defined.

Within the function, the remainder argument behaves exactly as a read-only shelf. The size of the shelf depends on the number of values passed.

Remainder arguments cannot be optional. If no values are passed in the remainder argument, then the created argument shelf is still specified. It simply has no items.

An item on a remainder argument shelf may be passed to a function either individually as a value argument or as part of a remainder shelf argument. The entire remainder argument shelf can be passed as a read-only argument.

External functions cannot have remainder arguments.

The following sample shows that by using the argument separator before the remainder argument, the separator can act as both the introductory herald for the argument as well as the item separator if the second herald is omitted.

To illustrate this point, the second herald for the remainder has been omitted, and therefore the first herald acts in the dual role described above.

  define counter function sum
                 (value counter x0 , remainder counter xx) as
     local counter s
     set s to x0
     repeat over xx
        increment s by xx
     again
     return s

A call to "sum" would look like this:

  set k to sum (1, 2, 3, 4, 5)   ; "k" gets the value 15.

In this function, the remainder argument is the first (and only) argument. As there is no leading herald, in this case the second herald must be defined.

    Related Syntax
   external-function
   optional
 
Related Concepts
   Functions: argument classes
   Functions: argument shelf types
   Functions: passing expressions as arguments
   Functions: passing multiple values as a single argument
   Functions: using the same argument separator in different definitions
 
----

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:14 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.