swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
    Related Concepts  
operator  

|| (concatenation)

 
 

Return type: markup source
Returns:        Concatenation of its two arguments.

Syntax

source expression || source expression
    


Purpose

The infix operator || concatenates its two arguments. It can be applied to string, string source, or markup source arguments. The result is a string source if both arguments are of the string or string source type. For example, the expression "Input file: " || file "input.txt" has the type string source. If either argument is a markup source, as in the expression #content || "%n", the result type is markup source.

The || operator consumes its arguments lazily: it starts consuming its second argument only when the first argument is exhausted. This can be important in examples like the following, when the second argument is a string source function:

  define string source function
     generate-instance
  as
     output "<" || #doctype || ">"
         || #main-input
         || "</" || #doctype || ">"
  
  process
     do sgml-parse document scan file "input.dtd" || generate-instance
        output "%c"
     done
          

If the function generate-instance was forced to run before the DTD was parsed, it could not obtain the document type it needs to generate the top-level element.

Another thing to note about this example is that the body of generate-instance consists of a single output action with six || operators. Because the concatenation operator is lazy, this definition behaves the same as the following one with multiple output actions:

  define string source function
     generate-instance
  as
     output "<" || #doctype || ">"
     output #main-input
     output "</" || #doctype || ">"
          

      Related Concepts
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:51:21 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.