Reference Tutorial Developer 1 Compile 2 Design 3 Implement 4 Modify 5 Misc 6 Licence SEARCH

2.9 Constraints On The Number of Instantiations

Experience with FunnelWeb V1 demonstrated the need to be able to specify in each macro definitions how many times the macro was expected to be called. FunnelWeb V1 generated an error if a macro is not used, but permited macros to be called more than once. This caused problems for macro libraries, many of whose macros were not called.

By default, FunnelWeb V3.0 requires that each macro (except for the ones attached to output files) be called exactly once. However, it also provides syntax that allows you to specify that a macro be allowed to be called zero times or many times. This allows a macro to be specified with the following permissible ranges of numbers of calls depending on the presence or absence of "`@Z`" and "`@M`":

       0..1          @$@<Sloth@>@Z...
          1          @$@<Sloth@>...
          1..n       @$@<Sloth@>@M...
       0.....n       @$@<Sloth@>@Z@M...

The initial proposal for this syntax was to allow the user to insert zero, one, or both of `@?` and `@M` just after the `@$` of a macro definition. Here are some other ideas that were considered for the syntax of the calling number constraint.

    @?@M@$@<Slothy dogs@>@(@5@)==@{@-
    This is a short macro.
    With only a line or two@}

    @$@<Slothy dogs@>@?@M@(@5@)==@{@-
    This is a short macro.
    With only a line or two@}

    @$@<Slothy dogs@>@(@5@)@?@M==@{@-
    This is a short macro.
    With only a line or two@

The first form was rejected because it is a good visual rule to start all the macros with `@$`. The second form was rejected because it detaches the macro name from the parameter list, thus making it look less like a call, which is a desirable syntactic resonance. The third form is messy, but was adopted with the change that `@?` was changed to `@M`.

After some thought, it was decided that the third syntax was the best, but that the "`@?`" sequence be reserved for a possible future conditional facility. It was replaced by `@Z`.

Example of final syntax:

    @$@<Slothy dogs@>@(@5@)@Z@M+=@{@-
    This is a short macro.
    With only a line or two@}

Webmaster Copyright © Ross N. Williams 1992,1999. All rights reserved.