Com S 541 Lecture -*- Outline -*- * Nondeclarative needs (3.8) Q: Are nondeclarative operations needed to interface with the world? it's easier that way, although there have been attempts, e.g. in the Haskell community... Operations on the external state are collected in modules. Q: What is a module? def: A module is "a record the groups together related operations." ** text input/output with files (3.8.1) Uses the module File ------------------------------------------ FILE MODULE declare [File] = {Module.link ['File.ozf']} L = {File.readList "foo.txt"} D = {WordFreq L} {File.writeOpen 'word.freq'} for X in {Domain D} do {File.write {Get D X} # ' occurrences of word ' # X # '\n'} end ------------------------------------------ See the book for details including using using URLs to specify files ------------------------------------------ VIRTUAL STRINGS - Data that specifies a string - Avoids actual concatenation Examples: 'a virtual string' 'a' # ' virtual' # "string" ['a' ' virtual ' 'string'] ------------------------------------------ Q: Why is it useful to avoid explicit concatenation? ** Text input/output with a graphical user interface (3.8.2) Uses QTk, see book ** Stateless data I/O with files Uses system module "Pickle"..