Print

Writes a formatted record to standard output.

Declaration

Syntax

Print(expr text)

Arguments

Argument

Description

text

the text to write, normally a StringFormat holding the format and the output list.

Return values

None.

Description

Print carries a single expression rather than a format and a list of values: formatting is StringFormat’s job, so a backend that can produce a string already has everything it needs to implement print.

print *, x is a Print whose text is a StringFormat with a nil format, meaning list-directed output.

Examples

(Print
  :text (StringFormat
    :fmt nil
    :args [
      (Var
        :v (SymbolRef 1 "n")
      )
    ]
    :kind :FormatFortran
    :type (String
      :kind 1
      :len nil
      :len_kind :DeferredLength
      :physical_type :DescriptorString
    )
    :value nil
  )
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "n" (Variable
              :parent_symtab 1
              :name "n"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
          }
        )
        :name "main"
        :dependencies []
        :body [
          (Print
            :text (StringFormat
              :fmt nil
              :args [
                (Var
                  :v (SymbolRef 1 "n")
                )
              ]
              :kind :FormatFortran
              :type (String
                :kind 1
                :len nil
                :len_kind :DeferredLength
                :physical_type :DescriptorString
              )
              :value nil
            )
          )
        ]
      )
    }
  )
  :items []
)

See Also

StringFormat, FileWrite