Transcription of User Manual - ECLiPSe
1 ECLi PSe user Manual Release Abderrahamane Aggoun (ECRC). David Chan (ECRC). Pierre Dufresne (ECRC). Eamon Falvey (ICL-ITC). Hugh Grant (ICL-ITC). Warwick Harvey (IC-Parc and CrossCore). Alexander Herold (ECRC). Geoffrey Macartney (ECRC). Micha Meier (ECRC). David Miller (ICL-ITC). Shyam Mudambi (ECRC). Stefano Novello (ECRC and IC-Parc). Bruno Perez (ECRC). Emmanuel van Rossum (ECRC). Joachim Schimpf (ECRC, IC-Parc, CrossCore and Cisco). Kish Shen (IC-Parc, CrossCore and Cisco). Periklis Andreas Tsahageas (ECRC). Dominique Henry de Villeneuve (ECRC). August 4, 2018. Trademarks UNIX is a trademark of AT&T Bell Laboratories. Quintus and Quintus Prolog are trademarks of Quintus Computer Systems, Incorporated. VAX is a trademark of Digital Equipment Corporation SUN-3 and SUN-4 are trademarks of Sun Microsystems, Inc. c 1990 2006 Cisco Systems, Inc. Contents Contents i 1 Introduction 1. What is ECLi PSe ? .. 1. Overview.
2 1. Further Information .. 2. Reporting Problems .. 2. 2 Terminology 3. 3 Getting started with ECLi PSe 7. How do I install the ECLi PSe system? .. 7. How do I run my ECLi PSe programs? .. 7. How do I use TkECLi PSe ? .. 7. Getting started .. 7. How do I write an ECLi PSe program? .. 7. Compiling a program .. 8. Executing a query .. 8. Editing a file .. 9. Debugging a program .. 9. Getting help .. 10. Other tools .. 10. Preference Editor .. 12. How do I use ECLiPSe ? .. 12. Getting started .. 12. Interacting with the top level loop .. 12. Compiling a program .. 12. Entering a program from the terminal .. 13. Executing a query .. 13. Interrupting the execution .. 14. Debugging a program .. 15. The history mechanism .. 15. Getting help .. 15. How do I make things happen at compile time? .. 15. How do I use ECLi PSe libraries in my programs? .. 16. How do I make my programs run faster? .. 16. Other tips .. 17. i Initialization at start-up.
3 17. Recommended file names .. 17. 4 The TkECLi PSe Development Tools 19. Display Matrix .. 19. Invoking display matrix tool interactively .. 21. Using the development tools in applications .. 21. Using the Development tools in the Tcl/Tk Embedding Interface .. 22. Using the Remote Development Tools .. 22. 5 ECLi PSe -specific Language Features 27. Structure Notation .. 27. Updating Structures .. 28. Arity and Functor of Structures .. 28. Printing Structures .. 28. Inheritance .. 28. Visibility .. 29. Loop/Iterator Constructs .. 29. Examples .. 32. Array Notation .. 37. Implementation Note .. 38. The String Data Type .. 39. Choosing The Appropriate Data Type .. 39. Built-in Support for Strings .. 41. Matching Clauses .. 41. Soft Cut .. 42. 6 The Compiler 43. Summary .. 43. Compiler Invocation .. 43. Source Files .. 44. Main Compiler Options .. 45. Source Structure .. 46. Clauses and Predicates .. 46. Compilation and Modules.
4 47. Incrementality .. 47. Directives .. 47. Modules and Declarations .. 47. Conditional Compilation .. 48. Include Directives .. 48. Compiler Pragmas .. 48. Precompiled (ECO) Files .. 49. Making Precompiled Files .. 49. Restrictions .. 50. Loading Precompiled Files .. 50. Using the Compiler with a Makefile .. 51. Special Compiler Features .. 51. ii Compiling Non-Textual Source .. 51. Mode Declarations .. 51. Inlining .. 52. Clause Expansion .. 53. Writing Efficient Code .. 53. Implementation Notes .. 56. 7 Engines and Threads 57. 8 The Module System 59. Basics .. 59. Purpose of Modules .. 59. What is under Visibility Control? .. 59. What Modules are There? .. 60. Getting Started .. 60. Creating a Module .. 60. Exporting .. 60. Importing .. 61. Definitions, Visibility and Accessibility .. 62. Advanced Topics .. 62. Solving Name Conflicts .. 62. Qualified Access via :/2 .. 63. Reexport - Making Modules from Modules.
5 64. Modules and Source Files .. 64. Tools and Caller Modules .. 65. Lookup Module vs Caller Module .. 67. The Module Interface .. 67. Module-related Predicate Properties .. 67. Less Common Topics .. 67. Modules That Use Other Languages .. 67. Creating and Erasing Modules at Runtime .. 68. Initialization and Finalization .. 68. Locking Modules .. 68. 9 Arithmetic Evaluation 71. Built-Ins to Evaluate Arithmetic Expressions .. 71. Arithmetic Evaluation vs Arithmetic Constraint Solving .. 71. Numeric Types and Type Conversions .. 72. Integers .. 72. Rationals .. 72. Floating Point Numbers .. 72. Bounded Real Numbers .. 73. Type Conversions .. 73. Arithmetic Functions .. 73. Predefined Arithmetic Functions .. 73. Evaluation Mechanism .. 75. user Defined Arithmetic Functions .. 75. iii Runtime Expressions .. 76. Low Level Arithmetic Builtins .. 76. The Multi-Directional Arithmetic Predicates .. 77. Arithmetic and Coroutining.
6 77. 10 Non-logical Storage and References 79. Introduction .. 79. Bags .. 79. Records .. 80. Shelves .. 81. Stores .. 81. Non-logical Variables .. 83. Non-logical Arrays .. 84. Global References .. 85. 11 Input and Output 87. Streams .. 87. Predefined Streams .. 87. Stream Handles and Aliases .. 88. Opening New Streams .. 89. Closing Streams .. 90. Redirecting Streams .. 91. Finding Streams .. 91. Stream Properties .. 91. Communication via Streams .. 91. Character I/O .. 92. Token I/O .. 92. Term I/O .. 93. Newlines .. 93. General Parsing and Text Generation .. 94. Flushing .. 94. Prompting .. 94. Positioning .. 94. In-memory Streams .. 94. String Streams .. 95. Queue streams .. 95. Term Output Formats .. 96. Write term and Printf .. 96. Other Term Output Predicates .. 98. Default Output Options .. 98. 12 Dynamic Code 99. Compiling Procedures as Dynamic or Static .. 99. Altering programs at run time .. 101.
7 Differences between static and dynamic code .. 101. iv 13 ECLi PSe Macros 103. Introduction .. 103. Using the macros .. 103. Source annotation aware macro transformations .. 106. Definite Clause Grammars DCGs .. 108. Simple DCG example .. 109. Mapping to Prolog clauses .. 111. Parsing other data structures .. 111. 14 Events and Interrupts 113. Events .. 113. Event Identifiers and Event Handling .. 113. Raising Events .. 114. Events and Waking .. 116. Aborting an Execution with Events .. 116. Errors .. 117. Error Handlers .. 118. Arguments of Error Handlers .. 119. user Defined Errors .. 120. Interrupts .. 120. Interrupt Identifiers .. 120. Asynchronous handling .. 121. 15 Debugging 123. The Box Model .. 123. Breakpoints .. 125. Format of the Tracing Messages .. 126. Debugging-related Predicate Properties .. 127. Starting the Debugger .. 128. Debugging Parts of Programs .. 129. Mixing debuggable and non-debuggable code.
8 129. Using the Debugger via the Command Line Interface .. 131. Counters and Command Arguments .. 131. Commands to Continue Execution .. 131. Commands to Modify Execution .. 133. Display Commands .. 133. Navigating among Goals .. 135. Inspecting Goals and Data .. 136. Changing the Settings .. 144. Environment Commands .. 145. Extending the Debugger .. 146. user -defined Ports .. 146. Attaching a Different user Interface .. 147. Switching To Creep Mode With CTRL-C .. 147. v 16 Development Support Tools 149. Available Tools and Libraries .. 149. Heuristic Program Checker .. 150. Document Generation Tools .. 151. Cross Referencing Tool .. 152. Pretty Printer Tool .. 153. Timing Profiler .. 154. Port Profiler .. 156. Line coverage .. 157. Compilation .. 158. Results .. 158. Mode analysis .. 158. 17 Attributed Variables 161. Introduction .. 161. Declaration .. 161. Syntax .. 162. Creating Attributed Variables .. 162.
9 Decomposing Attributed Variables .. 162. Attribute Modification .. 163. Attributed Variable Handlers .. 163. Printing Attributed Variables .. 166. Built-Ins and Attributed Variables .. 167. Examples of Using Attributed Variables .. 167. Variables with Enumerated Domains .. 167. Specification .. 169. 18 Advanced Control Features 171. Introduction .. 171. Concepts .. 171. The Structured Resolvent .. 171. Floundering .. 172. Suspending Built-Ins and the Suspend-Library .. 172. Development System Support .. 173. Declarative Suspension: Delay Clauses .. 173. Explicit suspension with suspend/3 .. 175. Waking conditions .. 177. Standard Waking Conditions on Variables .. 177. Library-defined Waking Conditions on Variables .. 180. Global Symbolic Waking Conditions: Triggers .. 181. Lower-level Primitives .. 182. Suspensions and Suspension Lists .. 182. Creating Suspended Goals .. 182. Operations on Suspensions .. 183.
10 Examining the Resolvent .. 184. Attaching Suspensions to Variables .. 184. user -defined Suspension Lists .. 184. vi Attaching Suspensions to Global Triggers .. 185. Scheduling Suspensions for Waking .. 185. Demon Predicates .. 185. about Priorities .. 186. Changing Priority Explicitly .. 187. Choice of Priorities .. 187. of the Execution Mechanism .. 188. Particularities of Waking by Unification .. 188. Cuts and Suspended Goals .. 189. the Delay-Primitives of other Systems .. 190. 19 More About Suspension 191. Waiting for Instantiation .. 191. Waiting for Binding .. 193. Waiting for other Constraints .. 199. 20 Memory Organisation And Garbage Collection 203. Introduction .. 203. The Shared/Private Heap .. 204. The Local Stack .. 205. The Control Stack .. 205. The Global Stack .. 205. The Trail Stack .. 206. Garbage collection .. 206. 21 Operating System Interface 209. Introduction .. 209. Environment Access.