Download SICStus Prolog User`s Manual

Transcript
v
9
Mixing Java and Prolog . . . . . . . . . . . . . . . . . . 213
9.1
9.2
9.3
9.4
9.5
9.6
10
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Calling Java from Prolog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2.1 Static and Dynamic Linking . . . . . . . . . . . . . . . . . . .
9.2.2 Declarating Java-methods . . . . . . . . . . . . . . . . . . . . .
Conversions between Prolog Arguments and Java Types . .
9.3.1 Calling Java from Prolog: An Example . . . . . . . . .
Calling Prolog from Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Jasper Package Class Reference . . . . . . . . . . . . . . . . . . . . . . . .
Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Handling Wide Characters . . . . . . . . . . . . . . 223
10.1
10.2
10.3
10.4
10.5
10.6
10.7
10.8
10.9
10.10
11
213
213
214
214
215
218
220
222
222
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Summary of Prolog level WCX features . . . . . . . . . . . . . . . .
Selecting the WCX mode using environment variables . . .
Selecting the WCX mode using hooks. . . . . . . . . . . . . . . . . .
Summary of WCX features in the foreign interface . . . . . .
Summary of WCX-related features in the libraries . . . . . .
WCX related utility functions . . . . . . . . . . . . . . . . . . . . . . . . .
Representation of EUC wide characters . . . . . . . . . . . . . . . .
A sample Wide Character Extension (WCX) box . . . . . .
223
223
225
225
227
233
235
235
237
238
Programming Tips and Examples . . . . . . . . 241
11.1
11.2
11.3
11.4
11.5
Programming Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Indexing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Last Call Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
If-Then-Else Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
11.5.1 Simple List Processing . . . . . . . . . . . . . . . . . . . . . . . 243
11.5.2 Family Example (descendants). . . . . . . . . . . . . . . . 243
11.5.3 Association List Primitives . . . . . . . . . . . . . . . . . . . 244
11.5.4 Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
11.5.5 Use of Meta-Logical Predicates . . . . . . . . . . . . . . . 244
11.5.6 Use of Term Expansion . . . . . . . . . . . . . . . . . . . . . . 245
11.5.7 Prolog in Prolog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
11.5.8 Translating English Sentences into Logic Formulae
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
12
The Prolog Library . . . . . . . . . . . . . . . . . . . . . 249
13
Array Operations . . . . . . . . . . . . . . . . . . . . . . . 251
14
Association Lists . . . . . . . . . . . . . . . . . . . . . . . 253
15
Attributed Variables . . . . . . . . . . . . . . . . . . . . 255