referents-displayed

modifier

Syntax
with referents-displayed (& open-modifier)


Purpose

This modifier allows referents to be written to the stream. The referents are immediately converted to a string expression identifying the name of the referent and its current value. This string expression is an ordinary value. No replacement is done when referents are resolved.

The purpose of this modifier is to allow referents to be written to streams without buffering those streams until referents are resolved, and to display something useful when doing so. This is primarily useful in programmer-generated errors, warnings, or information messages, where the contents of a buffer containing referents needs to be displayed.

For example, the following block of code write the same referent to two files, one with referents-allowed modifier and the other with referents-displayed.

  process
     using output as (file "foo.txt" with referents-allowed) &  (file "bar.txt" with referents-displayed)
        output referent "greeting"
  
     set referent "greeting" to "Hello, World!"

After the run, the contents of the file foo.txt will be

  Hello, World!
and file bar.txt will contain
   <?REF "greeting">

Related Syntax