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

2.4 A Review Of FunnelWeb Syntax

One of the disadvantages of FunnelWeb is its clumsy macro definition and calling syntax. Compared to (say) the C preprocessor, FunnelWeb's macro call syntax is like a freight train in a china shop. Unfortunately, all attempts to convert this syntax to something more elgant have failed, because the existing syntax is the simplest from a conceptual point of view and is the least likely to cause semantic confusion. This page discusses and justifies the FunnelWeb syntax.

Macro Definition Syntax

FunnelWeb's macro definition syntax results in definitions that look like this:

    @$@<Put out the cat@>==@{@-
    Open the door
    Say out
    Close the door@}

Here's why this syntax was chosen:

> Dollars: The `@$` is necessary to cue a definition. Without it, the definition might somehow be mistaken for an invocation.

> Name delimiters: The `@<` and `@>` are required to delimit the name and to resonate syntactically with macro calls.

> Content delimiters: The `@{` and `@}` delimit the content of the macro.

> EOL suppressor: The `@-` is a result of the simplifying rule that the content of a macro is "exactly the text between the `@{` and `@}`."

The only real target for a syntax purge the "`==`" which is optional anyway.

An alternative minimalist approach to macro definitions is:

    @<Put out the cat@>
    Open the door
    Say out
    Close the door@}

but this is too dangerous for my tastes as there is no syntax surrounding the name of the macro to indicate that it is a macro definition and not a macro call.

Parameterized Macro Definition Syntax

The definitions of parameterized macros are even messier than the normal definitions.

    @$@<Put out the cat@>@(@3@)==@{@-
    Open the door
    Say out
    Close the door@}

This is messy, but the "natural" alternative is even worse:

    @$@<Put out the cat@>@(@1@,@2@,@3@)==@{@-
    Open the door
    Say out
    Close the door@}

Given that the parameters don't have names, it seems cleaner just to specify the number of parameters. pecifying the number of parameters seems sensible.

Macro Call Syntax

Here are some syntaxes that were considered for FunnelWeb macro calls.

    Open the door
    @<Say Out@>         @! Current style.
    Close the door

    Open the door
    @<Say out>@
    Close the door

    Open the door
    @"Say out@"
    Close the door

    Open the door
    @(Say out@)
    Close the door

    Open the door
    @<Say out>
    Close the door

Of these, the first was chosen.

Parameterized Macro Call Syntax

FunnelWeb V1 provided a messy parameterized macro call syntax:

    @<Say Out@>@(@"firstparam@"  @,
       @"Secondparam@" @,
       @"thirdparam@" @)

This syntax was cleaned up considerably in V3.0 by making the `@"` symbols optional:

    @<Say Out@>@(firstparam@,@-
    Secondparam@,thirdparam@)

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