next up previous
Next: Built-in classes and the run-time library
Up: The WOM language
Previous: Instances inside pages

Plain text and standard HTML inside pages


Suppose now that the file also contained some HTML and plain text:

Field 1: <TextField size=10 value="0">
Field 2: <TextField size=11 value="1">
Then the compiler would translate it in a similar way as before, but adding these HTML strings to the contents list:
::class example subclass Page public

  ::method init
    expose contents
    contents = .list~of(,
                         "Field 1: ",,
                         "Field 2: ",,

  ::method emit
    expose contents
    use arg output_stream
    do item over contents
      if item~class = .String then
        output_stream~charout( item )
        item~emit( output_stream )

So anything not recognised by the compiler as a WOM construct gets added to the contents list as a string, and emitted verbatim when necessary. For simplicity, I have omitted the line-break characters between the two fields, and between the other text and the fields, in this and the previous example, but they would be included.

In fact, to save memory, long strings are not included as constants like this. Instead, the compiler generates byte pointers back into the original source file, and the text between these is emitted at run-time. That however, is just an optimisation: it does not change the semantics.

Jocelyn Ireson-Paine
Fri May 30 14:03:06 BST 1997