Lucid, the Dataflow Programming Language

Lucid, the Dataflow Programming Language

Lucid, the Dataflow Programming Langugage1 William W. Wadge Edward A. Ashcroft 1Published by Academic Press, 1985. ii Contents Preface vii 1 Introduction 1 1.1 What Makes Lucid Run? . 2 1.2 Imperative Programming . 5 1.3 Control Flow versus Dataflow . 7 1.4 The Problems with the Imperative Approach . 10 1.5 Some Suggested Solutions . 13 1.6 Honest, Folks, We Was Just Funnin' . 14 1.7 Nonprocedural Languages . 16 1.8 Lucid, the Well-Balanced Language . 18 1.9 Lucid|The Dataflow Programming Language? . 22 2 ISWIM and Algebras 25 2.1 Algebras . 28 2.2 The Syntax of Iswim . 30 2.3 The Semantics of Iswim . 31 2.4 A Sample Program . 33 2.5 The Operational Semantics of Iswim . 33 2.6 Calling and Binding in Iswim . 35 2.7 Lazy Evaluation . 37 2.8 Infinitary Programming . 39 3 The Language Luswim 43 3.1 Iteration through Sequences . 44 3.2 Luswim: The Abstract Approach to Iteration . 45 3.3 Iterative Programs in Luswim . 47 3.4 Variables in PASCAL and Luswim . 51 3.5 Continuously Operating Programs . 54 3.6 Programs with Memory . 56 3.7 Functions in Luswim . 57 3.8 Continuously Operating Functions . 59 3.9 Filters and Recursion . 61 3.10 Programs and Flow Graphs . 62 3.11 Implementing Luswim . 64 4 Lucid: Luswim with Nested Iteration 69 4.1 The Operation asa .................................... 70 4.2 Nesting in HyperIswim . 72 4.3 Nesting with whenever and upon ............................ 74 4.4 Going beyond Luswim . 74 4.5 The is current Declaration . 76 iii iv CONTENTS 4.6 Mixed Clauses . 79 5 Programming in Lucid 83 5.1 Hamming's Problem, a Simple Dataflow Example . 84 5.2 Using Dataflow to Enumerate the Primes . 86 5.3 Processing Text as Streams of Characters . 91 5.4 A Data Processing Example . 93 5.5 Swap Sorting in Lucid . 94 5.6 Dataflow Sorting in Lucid . 97 5.7 Input/Output in Lucid . 101 5.8 Debugging Lucid Programs . 104 5.9 Interfacing with UNIX, or Lucid Goes Cowboy . 106 5.10 Interactive and Real-Time Programming . 108 6 Program Transformation 113 6.1 The Basis Rule . 114 6.2 The Substitution Rule . 116 6.3 The Calling Rule . 120 6.4 The Renaming Rules . 122 6.5 The Addition and Elimination Rules . 123 6.6 The Amalgamation Rule . 124 6.7 The Import and Export Rules . 126 6.8 The Parameter Insertion and Deletion Rules . 127 6.9 Symbolic Evaluation . 129 6.10 The Symbolic Evaluation of Iterative Programs . 133 6.11 Binding and Calling Conventions . 136 6.12 Proving Assertions about Programs . 139 6.13 Verification Aiding Transformation: An Example . 142 7 Beyond Lucid 147 7.1 Types and Type Checking . 147 7.2 Tupling, or Filters with Multiple Outputs . 150 7.3 Arrays, or Frozen Streams . 154 7.4 ILucid, Lucid with Multidimensional Time . 159 7.5 Lambda Lucid, Lucid with Higher-Order Functions . 162 Bibliography 167 A The pLucid Programmers Manual: Introduction 171 B Lucid Expressions 175 B.1 The where clause . 175 B.2 The operators next, fby and first . 175 B.3 User-defined functions (UDF's) . 177 B.4 The operators asa, whenever, upon and attime . 179 B.4.1 asa ........................................ 179 B.4.2 whenever ..................................... 180 B.4.3 upon ........................................ 180 B.4.4 attime ...................................... 182 B.5 The is current declaration . 182 CONTENTS v C The pLucid Data Types 185 C.1 Numeric expressions . 185 C.2 Non-numeric data processing . 186 C.2.1 Word processing . 186 C.2.2 Boolean expressions and predefined variables . 188 C.2.3 String processing . 188 C.2.4 List processing . 190 C.3 The objects eod and error ................................ 194 C.4 pLucid conditional expressions . 196 D Scope Rules 199 E Running pLucid Under UNIX 201 E.1 The Basics . 201 E.1.1 Pop input versus character input . 202 E.1.2 Character input . 202 E.1.3 Character output . 203 E.1.4 A simple program . 203 E.1.5 More than one free variable . 203 E.1.6 pLucid programs as standard UNIX processes . 204 E.2 The filter and arg operators . 204 E.2.1 An application of the filter function . 205 E.3 Runtime errors . 205 E.3.1 The arg function . 206 E.4 A facility for file inclusion . 207 E.5 UNIX manual entry for pLucid . 207 F Tables and Rules 211 F.1 Tables of operators . 211 F.2 Associativity and precedence rules . 213 F.3 Reserved words . 214 G Miscellaneous 217 G.1 Plucid grammar . 217 G.2 Syntax diagrams . 221 G.3 Programming example . 228 vi CONTENTS Preface When Academic Press first suggested that we might write a book about Lucid, we readily agreed. Producing a book would be relatively easy (we thought); we could simply collect a number of existing papers and reports, add a few editorial comments, and that would be that. Once that was taken care of, we could then move on to some more ambitious project. However, when we went back and reread the papers and reports, we realized that our initial plan was unworkable. Lucid was (and still is) a very new development; nevertheless, it had already evolved so much that the various papers we proposed to include had become incompatible. Some of the changes were of a detailed or technical nature, but on the whole they reflected a radical shift in the underlying motivation. Lucid was born in 1974 at the University of Waterloo in Canada, where at the time both authors were teaching in the Faculty of Mathematics. The original goals in developing Lucid were very modest. We wanted to show that conventional, `mainstream' programming could be done in a purely declarative language, one without assignment or goto statements. We felt then (and still do now) that real \structured programming" required first the elimination of both these features and that.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    241 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us