Text preview for : CSL_79-3_Mesa_Language_Manual_Version_5.0_Apr79.pdf part of xerox CSL 79-3 Mesa Language Manual Version 5.0 Apr79 xerox mesa 5.0_1979 documentation CSL_79-3_Mesa_Language_Manual_Version_5.0_Apr79.pdf



Back to : CSL_79-3_Mesa_Language_Ma | Home

, I




Mesa Language Manual


by James G. Mitchell
William Maybury
Richard Sweet



Version 5.0
April 1979

CSL-79-3



The Mesa language is one component of a programming system intended for developing and
maintaining a wide range of systems and applications programs. Mesa supports the
development of systems composed of separate modules with controlled sharing of information
among them. The language includes facilities for user-defined data types, strong compile-
time checking of both types and interfaces, procedure and coroutine control mechanisms,
and control structures for dealing with concurrency and exceptional conditions.




XEROX
PALO ALTO RESEARCH CENTER
SYSTEMS DEVELOPMENT DEPARTMENT
3333 Coyote Hill Road / Palo Alto / California 94304
@ Copyright 1979 by Xerox Corporation
CONTENTS I




CHAPTER 1. INTRODUCTION 1
1.1. Syntax notation 2

CHAPTER 2. BASIC DATA TYPES AND EXPRESSIONS 4
2.1. A slice of Mesa code 4
2.1.1. Basic lexical structure 5
2.2. Simple declarations 6
2.3. The fundamental operations, .. , =, and # 6
2.4. Basic types 7
2.4.1. The numeric types INTEGER and CARDINAL 7
2.4.1.1. Numeric literals 8
2.4.2. Type BOOLEAN 8
2.4.3. Type CHARACTER 9
2.4.4. The numeric types LONG INTEGER and LONG CARDINAL 9
2.4.5. Type REAL 10
2.4.6. Relations among basic types 10
2.5. Expressions 11
2.5.1. Numeric operators 12
-.. 2.5.1.1. Domains of the numeric operators 13
2.5.1.2. The operator LONG 14
2.5.1.3. CHARACTER operators 15
2.5.2. Relational operators 15
2.5.3. BOOLEAN operators 16
2.5.4. Assignment expressions 17
2.5.5. Operator precedence 17
2.6. Initializing variables in declarations 17
2.6.1. Compile-time constants 18
2.7. More general declarations 19

CHAPTER 3. COMMON CONSTRUCTED DATA TYPES 20
3.1. The element types 22
3.1.1. Enumerated types 22
3.1.2. Subrange types 24
3.1.2.1. Subranges of numeric types 26
3.1.2.2. Range assertions 26
3.2. Arrays . 27
3.2.1. Declaration of arrays 29
3.2.2. Array constructors 30
3.3. Records 31
3.3.1. Field lists 31
3.3.2. Declaration of records 32
3.3.3. Qualified references 34
3.3.4. Record Constructors 35
3.3.5. Default field values 36
3.3.6. Extractors 38
3.4. Pointers 39
3.4.1. Constructing pointer types 41
3.4.2. Pointer operations 42
3.4.3. Long Pointers 43
3.4.4. Automatic dereferencing 44




i
3.5. Type determination 45
3.5.1. Type conversion 46
3.5.2. Balancing 47
3.5.3. Free conformance 48
3.6. Determination of representation 49
CHAPTER 4. ORDINARY STATEMENTS 51
4.1. Assignment statements 51
4.1.1. Assignment expressions 52
4.2. IF statements 52
4.2.1. IF expressions 53
4.3. SELECT statements 54
4.3.1. Forms and options for SELECT 54
4.3.2. The NULL statement 56
4.3.3. SELECT expressions 56
4.4. Blocks 57
4.4.1. GOTO statements 57
4.4.2. OPEN clauses 59
4.5. Loop statements 61
4.5.1. Loop control 62
4.5.2. GOTOS, LOOPS, EXITS, and loops 64
CHAPTERS. PROCEDURES 67
5.1. Procedure types 69
5.1.1. Procedure values and compatibility 70
5.2. Procedure calls 71
5.2.1. Arguments and parameters 72
5.2.2. Termination and results 72
5.3. Procedure bodies 73
5.3.1. RETURN statements 74
5.4. A package of procedures 75
5.4.1. The example 77
5.4.2. Invoking procedures in other modules 78
5.5. Nested procedures 78
5.5.1. Scopes defined by procedures 79
5.6. Inline procedures 80

CHAPTER 6. STRINGS, ARRAY DESCRIPTORS, RELATIVE POINTERS, 82
AND VARIANT RECORDS
6.1. Strings 82
6.1.1. String literals and string expressions 83
6.1.2. Declaring strings 84
6.1.3. Long strings 85
6.2. Array descriptors 85
6.2.1. Array descriptor types 85
6.2.2. Long descriptors 87
6.3. Base and relative pointers 88
6.3.1. Syntax for base and relative pointers 88
6.3.2. A relative pointer example 89
6.3.3" Relative pointer types 90
6.3.4. Relative array descriptors 91
6.4. Variant records 92
6.4.1. Declaring variant records 93
6.4.2. Bound variant types 95



ii
6.4.3. Accessing entire variant parts, and variant constructors 96 I
6.4.4. Accessing components of variants _ 97
CHAPTER 7. MODULES, PROGRAMS, AND CONFIGURATIONS 101
7.1. Interfaces 101
7.2. The fundamentals of Mesa modules 104
7.2.1. Including modules: the DIRECTORY clause 105
7.2.1.1. Enumerating items from an included module: the USING clause 106
7.2.2. Accessing items from an included module 106
7.2.2.1. Qualification 106
7.2.2.2. OPEN clauses 107
7.2.3. Scopes for identifiers in a module 108
7.2.4. Implications of recompiling included modules 109
7.3. DEFINITIONS modules 110
7.3.1. Interface variables 111
7.3.2. Default fields in interfaces 112
7.3.3. Inline procedures in interfaces 113
7.3.4. Usage hints for inline procedures in interfaces 114
7.4. PROGRAM modules: IMPORTS and EXPORTS 114
7.4.1. IMPORTS, interface types, and interface records 115
7.4.2. Importing program modules 116
7.4.3. Exporting interfaces and program modules 116
7.4.4. IMPORTS in DEFINITIONS modules 116
7.5. Controlling module interfaces: PUBLIC and PRIVATE 117
7.5.1. Access attributes in declarations 117
7.5.1.1. Declared names 118
7.5.1.2. Names specified in field lists 118
7.5.1.3. Names for variant parts and for tags in variant records 118
7.5.2. Access attributes in TYPE definitions 119
7.5.3. Default global access 120
7.5.4. Accessing the PRIVATE predefined symbols of other modules 120
7.6. The Mesa configuration language, an introductory example 120
7.6.1. Lexicon: a module implementing LexiconDefs 121
7.6.2. LexiconClient: a client module 123
7.6.3. Binding, loading, and running a configuration: an overview 123
7.6.4. A configuration description for running LexiconClient 124
7.7. ClMesa: syntax and semantics 125
7.7.1. IMPORTS, EXPORTS, and DIRECTORY in C/Mesa 126
7.7.2. Explicit naming, IMPORTS, and EXPORTS 126
7.7.3. Default names for interfaces and instances 127
7.7.4. Multiple exported interfaces from a single component 128
7.7.5. Multiple components implementing a single interface 129
7.7.6. Nested (local) configurations 130
7.S. Loading modules and configurations: NEW and START 131
7.8.1. The NEW operation for making copies of modules 131
7.8.2. How the loader binds interfaces 132
7.8.3. STARTing, STOPping, and RESTARTing module instances 132
7.8.4. Loading and starting configurations 133

CHAPTER 8. SIGNALLING AND SIGNAL DATA TYPES 134
f.1. Declaring and generating SIGNALS and ERRORS 134
8.1.1. ERROR in expressions 136
S.2. Control of generated signals 136
8.2.1. Preparing to catch signals: catch phrases 137



iii
8.2.2. The scope of variables in catch phrases 138
8.2.3. Catching signals 139
8.2.4. RETRY and CONTINUE in catch phrases 141
8.2.5. Resuming from a catch phrase: RESUME 141
8.3. Sig~als within signals 142
CHAPTER 9. PORTS AND CONTROL STRUCTURES 144
9.1. Syntax and an example of PORTS 145
9.2. Creating and starting coroutines 146
9.2.1. The CONNECT statement 147
9.2.2. Low-level actions for a PORT call 148
9.2.3. Control faults and linkage faults 149
9.2.4. Saving arguments during faults 150
9.3. RESPONDING PORTS 151
CHAPTER 10. PROCESSES AND CONCURRENCY 152
10.1. Concurrent execution, FORK and JOIN 152
10.1.1. A process example 152
10.1.2. Process language constructs 153
10.2. Monitors 154
10.2.1. An overview of monitors 155
10.2.2. Monitor locks 156
10.2.3. Declaring monitor modules, ENTRY and INTERNAL procedures 156
10.2.4. Interfaces to monitors 157
10.2.5. Interactions of processes and monitors 158
103. Condition variables 158
10.3.1. Wait, notify, and broadcast 158
10.3.2. Timeouts 161
10.4. More about monitors 161
10.4.1. The LOCKS clause 161
10.4.2. Monitored records 162
10.4.3. Monitors and module instances 162
10.4.4. Multi-module monitors 163
10.4.5. Object monitors 165
10.4.6. Explicit declaration of monitor locks 166
10.4.7. Inline ENTRY procedures 166
10.5. Signals 166
10.5.1. Signals and processes 166
10.5.2. Signals and monitors 166
10.6. Initialization 168

APPENDICES
A. Pronouncing Mesa 169
B. Programming Conventions 170
B.1. Names 170
B.2. Layout 170
B.3. Spaces 171
C. Alto/Mesa M~lchine Dependencies 172
C.1. Numeric limits 172
C.2. AltoDefs 172
C.3. ASCII character set and ordering of character values 173
C.4. Alto/Mesa STRING procedures 174




iv
D. Binder Extensions 175 I

D.1. Code packing 175
D.1.1. Syntax 175
D.1.2. Restrictions 176
D.2~Extemallinks 176
0.2.1. Syntax 176
D.2.2. Restrictions 177
E. Mesa Reserved Words 178
F. Collected Grammar 179
INDEX 185




v
Preface

This document describes the Mesa programming language. Its approach is tutorial, and it is
intended to be read somewhat as a textbook. It is neither a user's guide nor a reference manual.
'1