RossNet

FunnelWeb

Reference

Developer

Tutorial
1 Introduction
2 Macros
3 Typesetting
4 Example
5 Hints
6 Examples
7 Webmaking

SEARCH
FunnelWeb Tutorial Manual

2.3 Indentation

The body of the print macro of the previous example contains two lines of text. A literal substitution of this macro's body in its context would result in:

   {
    printf("Hello World!");
printf("\n");
    printf("Hello World!");
printf("\n");
   }

But instead, it comes out as (have a look at this part of hello.c now):

   {
    printf("Hello World!");
    printf("\n");
    printf("Hello World!");
    printf("\n");
   }

The explanation is that FunnelWeb indents each line of multiline macros by the level of indentation at the point of call. This means that, as in the case above, program texts, which are usually highly indented, come out looking "right".

In other circumstances, where the model of the text is one dimensional, FunnelWeb's indentation could become an impediment or even a danger. In these cases, it can be switched off by including the FunnelWeb pragma line

@p indentation = none

anywhere in the input file.

One of the design goals of FunnelWeb is to allow the user total control over the product files. This contrasts with the approach of Knuth's WEB system [Knuth83] (upon which FunnelWeb is based), which mangles the input text at the Pascal program syntax level, truncating identifiers, converting the text to upper case, and paragraphing text. Here is an example of part of a Pascal program produced by WEB (from page 14 of [Knuth83]):

IF R=0 THEN XREF[P]:=XREFPTR ELSE
XMEM[R].XLINKFIELD:=XREFPTR;END;{:51}
{58:}FUNCTION IDLOOKUP(T:EIGHTBITS):NAMEPOINTER;
LABEL 31;
VAR I:0..LONGBUFSIZE;H:0..HASHSIZE;K:0..MAXBYTES;
W:0..1;
L:0..LONGBUFSIZE;P:NAMEPOINTER;BEGIN
L:=IDLOC-IDFIRST;{59:}
H:=BUFFER[IDFIRST];I=IDFIRST+1;
WHILE I<IDLOC DO BEGIN H:=(H+H+BUFFER[I])MOD
HASHSIZE;I=I+1;END{:59};

Knuth's theory is that the program generated by a literate programming system should be treated as object code and hence should look like object code too. While this may be an admirable approach in the long run, the present programming environment is one of faulty compilers and buggy tools. The FunnelWeb view is that, in this environment, the programmer needs all the help he can get and that therefore he should be allowed total control over the product file. Another reason for FunnelWeb's providing total control over the product file, is that FunnelWeb is intended to be target language independent, and so even if Knuth's view were adopted, it would not be clear what a legitimate transformation of the text could be.

Prev Up Next


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