File: gprolog037.html

package info (click to toggle)
gprolog 1.3.0-6.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 13,512 kB
  • ctags: 8,954
  • sloc: ansic: 57,431; perl: 16,620; sh: 5,900; makefile: 1,284
file content (1477 lines) | stat: -rw-r--r-- 72,146 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="gprolog.css">
<TITLE>
Term input/output
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="gprolog036.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog038.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H3 CLASS="subsection"><A NAME="htoc150">7.14</A>&nbsp;&nbsp;Term input/output</H3><UL>
<LI><A HREF="gprolog037.html#toc115"><TT>read_term/3</TT>,
 <TT>read_term/2</TT>,
 <TT>read/2</TT>,
 <TT>read/1</TT></A>
<LI><A HREF="gprolog037.html#toc116"><TT>read_atom/2</TT>,
 <TT>read_atom/1</TT>, 
 <TT>read_integer/2</TT>,
 <TT>read_integer/1</TT>,<BR>
<TT>read_number/2</TT>,
 <TT>read_number/1</TT></A>
<LI><A HREF="gprolog037.html#toc117"><TT>read_token/2</TT>,
 <TT>read_token/1</TT></A>
<LI><A HREF="gprolog037.html#toc118"><TT>syntax_error_info/4</TT></A>
<LI><A HREF="gprolog037.html#toc119"><TT>last_read_start_line_column/2</TT></A>
<LI><A HREF="gprolog037.html#toc120"><TT>write_term/3</TT>,
 <TT>write_term/2</TT>,
 <TT>write/2</TT>,
 <TT>write/1</TT>,
 <TT>writeq/2</TT>,
 <TT>writeq/1</TT>,<BR>
<TT>write_canonical/2</TT>,
 <TT>write_canonical/1</TT>,
 <TT>display/2</TT>,
 <TT>display/1</TT>,
 <TT>print/2</TT>,<BR>
<TT>print/1</TT></A>
<LI><A HREF="gprolog037.html#toc121"><TT>format/3</TT>,
 <TT>format/2</TT></A>
<LI><A HREF="gprolog037.html#toc122"><TT>portray_clause/2</TT>,
 <TT>portray_clause/1</TT></A>
<LI><A HREF="gprolog037.html#toc123"><TT>get_print_stream/1</TT></A>
<LI><A HREF="gprolog037.html#toc124"><TT>op/3</TT></A>
<LI><A HREF="gprolog037.html#toc125"><TT>current_op/3</TT></A>
<LI><A HREF="gprolog037.html#toc126"><TT>char_conversion/2</TT></A>
<LI><A HREF="gprolog037.html#toc127"><TT>current_char_conversion/2</TT></A>
</UL>

<A NAME="Term-input/output"></A>
These built-in predicates enable a Prolog term to be input from or output to
a text stream. The atom <TT>end_of_file</TT> is returned as term to
indicate the end-of-file. The syntax of such terms can also be altered by
changing the operators (section&nbsp;<A HREF="#op/3:(Term-input/output)">7.14.10</A>), and making some
characters equivalent to others (section&nbsp;<A HREF="#char-conversion/2">7.14.12</A>) if the
<TT>char_conversion</TT> Prolog flag is <TT>on</TT>
(section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>). Double quoted tokens will be returned as an atom
or a character list or a character code list depending on the value of the
<TT>double_quotes</TT> Prolog flag (section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>). Similarly, back quoted tokens are returned depending on the value of the
<TT>back_quotes</TT> Prolog flag.<BR>
<BR>
<A NAME="toc115"></A>
<H4 CLASS="subsubsection"><A NAME="htoc151">7.14.1</A>&nbsp;&nbsp;<TT>read_term/3</TT>,
 <TT>read_term/2</TT>,
 <TT>read/2</TT>,
 <TT>read/1</TT></H4>
<A NAME="read-term/3"></A>
 
 
 
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
read_term(+stream_or_alias, ?term, +read_option_list)<BR>
read_term(?term, +read_option_list)<BR>
read(+stream_or_alias, ?term)<BR>
read(?term)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>read_term(SorA, Term, Options)</TT> is true if
<TT>Term</TT> unifies with the next term read from the stream associated
with the stream-term or alias <TT>SorA</TT> according to the options given by
<TT>Options</TT>.<BR>
<BR>
<B>Read options</B>: <TT>Options</TT> is a list of read options. If this
list contains contradictory options, the rightmost option is the one which
applies. Possible options are:
<UL CLASS="itemize"><LI CLASS="li-itemize"><TT>variables(VL)</TT>: <TT>VL</TT> is unified with the
list of all variables of the input term, in left-to-right traversal
order. Anonymous variables are included in the list <TT>VL</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>variable_names(VNL)</TT>: <TT>VNL</TT> is
unified with the list of pairs <TT>Name = Var</TT> where <TT>Var</TT> is a
named variable of the term and <TT>Name</TT> is the atom associated with the
name of <TT>Var</TT>. Anonymous variables are not included in the list
<TT>VNL</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>singletons(SL)</TT>: <TT>SL</TT> is unified with the
list of pairs <TT>Name = Var</TT> where <TT>Var</TT> is a named variable
which occurs only once in the term and <TT>Name</TT> is the atom associated
to the name of <TT>Var</TT>. Anonymous variables are not included in the list
<TT>SL</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>syntax_error(error</TT>/<TT>warning</TT>/<TT>fail)</TT>:
specifies the effect of a syntax error:
<UL CLASS="itemize"><LI CLASS="li-itemize"><TT>error</TT>: a <TT>syntax_error</TT> is raised.<BR>
<BR>
<LI CLASS="li-itemize"><TT>warning</TT>: a warning message is displayed and the predicate
fails.<BR>
<BR>
<LI CLASS="li-itemize"><TT>fail</TT>: the predicate quietly fails.</UL><BR>
The default value is the value of the <TT>syntax_error</TT>
Prolog flag (section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>).<BR>
<BR>
<LI CLASS="li-itemize"><TT>end_of_term(dot</TT>/<TT>eof)</TT>: specifies the
end-of-term delimiter: <TT>dot</TT> is the classical full-stop delimiter (a
dot followed with a layout character), <TT>eof</TT> is the end-of-file
delimiter. This option is useful for predicates like
<TT>read_term_from_atom/3</TT> (section&nbsp;<A HREF="gprolog038.html#read-term-from-atom/3">7.15.1</A>) to avoid to add a
terminal dot at the end of the atom. The default value is <TT>dot</TT>.</UL>
<TT>read(SorA, Term)</TT> is equivalent to
<TT>read_term(SorA, Term, [])</TT>.<BR>
<BR>
<TT>read_term/2</TT> and <TT>read/1</TT> apply to the current input stream.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Options</TT> is a partial list or a list with an element
<TT>E</TT> which is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is neither a variable nor a stream-term or alias</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(stream_or_alias, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Options</TT> is neither a partial list nor a list</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(list, Options)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Options</TT> list is neither a
variable nor a valid read option</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(read_option, E)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is not associated with an open stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is an output stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is associated with a binary stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, binary_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> has stream properties <TT>end_of_stream(past)</TT>
and <TT>eof_action(error)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, past_end_of_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>a syntax error occurs and the value of the <TT>syntax_error</TT>
Prolog flag is <TT>error</TT> (section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>)</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>syntax_error(<I>atom explaining the error</I>)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
ISO predicates. The ISO reference raises a
<TT>representation_error(Flag)</TT> where <TT>Flag</TT> is
<TT>max_arity</TT>,<TT> max_integer</TT>, or<TT> min_integer</TT> when
the read term breaches an implementation defined limit specified by
<TT>Flag</TT>. GNU Prolog detects neither <TT>min_integer</TT> nor
<TT>max_integer</TT> violation and treats a <TT>max_arity</TT> violation
as a syntax error. The read options <TT>syntax_error/1</TT> and
<TT>end_of_term/1</TT> are GNU Prolog extensions.<BR>
<BR>
<A NAME="toc116"></A>
<H4 CLASS="subsubsection"><A NAME="htoc152">7.14.2</A>&nbsp;&nbsp;<TT>read_atom/2</TT>,
 <TT>read_atom/1</TT>, 
 <TT>read_integer/2</TT>,
 <TT>read_integer/1</TT>,<BR>
<TT>read_number/2</TT>,
 <TT>read_number/1</TT></H4>
<A NAME="read-atom/2"></A>
 
 
 
 
 
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
read_atom(+stream_or_alias, ?atom)<BR>
read_atom(?atom)<BR>
read_integer(+stream_or_alias, ?integer)<BR>
read_integer(?integer)<BR>
read_number(+stream_or_alias, ?number)<BR>
read_number(?number)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>read_atom(SorA, Atom)</TT> succeeds if <TT>Atom</TT>
unifies with the next atom read from the stream associated with the
stream-term or alias <TT>SorA</TT>.<BR>
<BR>
<TT>read_integer(SorA, Integer)</TT> succeeds if
<TT>Integer</TT> unifies with the next integer read from the stream
associated with the stream-term or alias <TT>SorA</TT>.<BR>
<BR>
<TT>read_number(SorA, Number)</TT> succeeds if
<TT>Number</TT> unifies with the next number (integer or floating point
number) read from the stream associated with the stream-term or alias
<TT>SorA</TT>.<BR>
<BR>
<TT>read_atom/1</TT>, <TT>read_integer/1</TT> and <TT>read_number/1</TT>
apply to the current input stream.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Atom</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Integer</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Integer)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Number</TT> is neither a variable nor a number</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(number, Number)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is neither a variable nor a stream-term or alias</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(stream_or_alias, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is not associated with an open stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is an output stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is associated with a binary stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, binary_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> has stream properties <TT>end_of_stream(past)</TT>
and <TT>eof_action(error)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, past_end_of_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>a syntax error occurs and the value of the <TT>syntax_error</TT>
Prolog flag is <TT>error</TT> (section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>)</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>syntax_error(<I>atom explaining the error</I>)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<A NAME="toc117"></A>
<H4 CLASS="subsubsection"><A NAME="htoc153">7.14.3</A>&nbsp;&nbsp;<TT>read_token/2</TT>,
 <TT>read_token/1</TT></H4>
<A NAME="read-token/2"></A>
 
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
read_token(+stream_or_alias, ?nonvar)<BR>
read_token(?nonvar)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>read_token(SorA, Token)</TT> succeeds if <TT>Token</TT> unifies with
the encoding of the next Prolog token read from the stream associated with
stream-term or alias <TT>SorA</TT>.<BR>
<BR>
<B>Token encoding</B>:
<UL CLASS="itemize"><LI CLASS="li-itemize"><TT>var(A)</TT>: a variable is read whose name is the atom
<TT>A</TT>.<BR>
<BR>
<LI CLASS="li-itemize">an atom <TT>A</TT>: an atom <TT>A</TT> is read.<BR>
<BR>
<LI CLASS="li-itemize">integer <TT>N</TT>: an integer <TT>N</TT> is read.<BR>
<BR>
<LI CLASS="li-itemize">floating point number <TT>N</TT>: a floating point number <TT>N</TT>
is read.<BR>
<BR>
<LI CLASS="li-itemize"><TT>string(A)</TT>: a string (double quoted item) is read whose
characters forms the atom <TT>A</TT>. <BR>
<BR>
<LI CLASS="li-itemize"><TT>punct(P)</TT>: a punctuation character <TT>P</TT> is read
(<TT>P</TT> is a one-character atom in <TT>()[]{|}</TT>, the atom
<TT>full_stop</TT> or the atom <TT>end_of_file</TT>).<BR>
<BR>
<LI CLASS="li-itemize"><TT>back_quotes(A)</TT>: a back quoted item is read
whose characters forms the atom <TT>A</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>extended(A)</TT>: an extended character <TT>A</TT> (an
atom) is read.</UL>
As for <TT>read_term/3</TT>, the behavior of <TT>read_token/2</TT> can be
affected by some Prolog flags (section&nbsp;<A HREF="#Term-input/output">7.14</A>).<BR>
<BR>
<TT>read_token/1</TT> applies to the current input stream.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is neither a variable nor a stream-term or alias</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(stream_or_alias, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is not associated with an open stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is an output stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is associated with a binary stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, binary_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> has stream properties <TT>end_of_stream(past)</TT>
and <TT>eof_action(error)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(input, past_end_of_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>a syntax error occurs and the value of the <TT>syntax_error</TT>
Prolog flag is <TT>error</TT> (section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>)</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>syntax_error(<I>atom explaining the error</I>)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<A NAME="toc118"></A>
<H4 CLASS="subsubsection"><A NAME="htoc154">7.14.4</A>&nbsp;&nbsp;<TT>syntax_error_info/4</TT></H4>
<A NAME="syntax-error-info/4"></A>
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
syntax_error_info(?atom, ?integer, ?integer, ?atom)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>syntax_error_info(FileName, Line, Column, Error)</TT> returns the
information associated with the last syntax error. <TT>Line</TT> is the line
number of the error, <TT>Column</TT> is the column number of the error and
<TT>Error</TT> is an atom explaining the error.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>FileName</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, FileName)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Line</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Line)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Column</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Column)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Error</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Error)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>
<A NAME="toc119"></A>
<H4 CLASS="subsubsection"><A NAME="htoc155">7.14.5</A>&nbsp;&nbsp;<TT>last_read_start_line_column/2</TT></H4>
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
last_read_start_line_column(?integer, ?integer)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>last_read_start_line_column(Line, Column)</TT> unifies <TT>Line</TT>
and <TT>Column</TT> with the line number and the column number associated with
the start of the last read predicate. This predicate can be used after
calling one of the following predicates: <TT>read_term/3</TT>,
<TT>read_term/2</TT>, <TT>read/2</TT>, <TT>read/1</TT>
(section&nbsp;<A HREF="#read-term/3">7.14.1</A>), <TT>read_atom/2</TT>, <TT>read_atom/1</TT>,
<TT>read_integer/2</TT>, <TT>read_integer/1</TT>, <TT>read_number/2</TT>,
<TT>read_number/1</TT> (section&nbsp;<A HREF="#read-atom/2">7.14.2</A>) or <TT>read_token/2</TT>,
<TT>read_token/1</TT> (section&nbsp;<A HREF="#read-token/2">7.14.3</A>).<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Line</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Line)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Column</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Column)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>
<A NAME="toc120"></A>
<H4 CLASS="subsubsection"><A NAME="htoc156">7.14.6</A>&nbsp;&nbsp;<TT>write_term/3</TT>,
 <TT>write_term/2</TT>,
 <TT>write/2</TT>,
 <TT>write/1</TT>,
 <TT>writeq/2</TT>,
 <TT>writeq/1</TT>,<BR>
<TT>write_canonical/2</TT>,
 <TT>write_canonical/1</TT>,
 <TT>display/2</TT>,
 <TT>display/1</TT>,
 <TT>print/2</TT>,<BR>
<TT>print/1</TT></H4>
<A NAME="write-term/3"></A>
 
 
 
 
 
 
 
 
 
 
 
 
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
write_term(+stream_or_alias, ?term, +write_option_list)<BR>
write_term(?term, +write_option_list)<BR>
write(+stream_or_alias, ?term)<BR>
write(?term)<BR>
writeq(+stream_or_alias, ?term)<BR>
writeq(?term)<BR>
write_canonical(+stream_or_alias, ?term)<BR>
write_canonical(?term)<BR>
display(+stream_or_alias, ?term)<BR>
display(?term)<BR>
print(+stream_or_alias, ?term)<BR>
print(?term)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>write_term(SorA, Term, Options)</TT> writes
<TT>Term</TT> to the stream associated with the stream-term or alias
<TT>SorA</TT> according to the options given by <TT>Options</TT>.<BR>
<BR>
<B>Write options</B>: <TT>Options</TT> is a list of write options. If this
list contains contradictory options, the rightmost option is the one which
applies. Possible options are:
<UL CLASS="itemize"><LI CLASS="li-itemize"><TT>quoted(true</TT>/<TT>false)</TT>: if <TT>true</TT> each
atom and functor is quoted if this would be necessary for the term to be
input by <TT>read_term/3</TT>. If <TT>false</TT> no extra quotes are
written. The default value is <TT>false</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>ignore_ops(true</TT>/<TT>false)</TT>: if
<TT>true</TT> each compound term is output in functional notation (neither
operator notation nor list notation is used). If <TT>false</TT> operator and
list notations are used. The default value is <TT>false</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>numbervars(true</TT>/<TT>false)</TT>: if
<TT>true</TT> a term of the form <TT>'$VAR'(N)</TT>, where <TT>N</TT> is an
integer, is output as a variable name (see below). If <TT>false</TT>
such a term is output normally (according to the other options). The
default value is
<TT>true</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>namevars(true</TT>/<TT>false)</TT>: if <TT>true</TT> a
term of the form <TT>'$VARNAME'(Name)</TT>, where <TT>Name</TT> is an atom,
is output as a variable name (see below). If <TT>false</TT> such a term is
output normally (according to the other options). The default value is
<TT>true</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>space_args(true</TT>/<TT>false)</TT>: if
<TT>true</TT> an extra space character is emitted after each comma
separating the arguments of a compound term in functional notation or of a
list. If <TT>false</TT> no extra space is emitted. The default value is
<TT>false</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>portrayed(true</TT>/<TT>false)</TT>: if <TT>true</TT>
and if there exists a predicate <TT>portray/1</TT>, <TT>write_term/3</TT>
acts as follows: if <TT>Term</TT> is a variable it is simply written. If
<TT>Term</TT> is non-variable then it is passed to <TT>portray/1</TT>. If
this succeeds then it is assumed that <TT>Term</TT> has been output.
Otherwise <TT>write_term/3</TT> outputs the principal functor of
<TT>Term</TT> (<TT>Term</TT> itself if it is atomic) according to other
options and recursively calls <TT>portray/1</TT> on the components of
<TT>Term</TT> (if it is a compound term). With <TT>ignore_ops(false)</TT> a
list is first passed to <TT>portray/1</TT> and only if this call fails each
element of the list is passed to <TT>portray/1</TT> (thus every sub-list is
not passed). The default value is <TT>false</TT>.<BR>
<BR>
<LI CLASS="li-itemize"><TT>max_depth(N)</TT>: controls the depth of output for
compound terms. <TT>N</TT> is an integer specifying the depth. The output of
a term whose depth is greater than <TT>N</TT> gives rise to the output of
<TT>...</TT> (3 dots). By default there is no depth limit.<BR>
<BR>
<LI CLASS="li-itemize"><TT>priority(N)</TT>: specifies the starting priority 
to output the term. This option controls if <TT>Term</TT> should be enclosed
in brackets. <TT>N</TT> is a positive integer &#8804; 1200. By default
<TT>N</TT> = 1200.</UL>
<B>Variable numbering</B>: when the <TT>numbervars(true)</TT> option is
passed to <TT>write_term/3</TT> any term of the form <TT>'$VAR'(N)</TT>
where <TT>N</TT> is an integer is output as a variable name consisting of a
capital letter possibly followed by an integer. The capital letter is the
<TT>(I+1)</TT><EM>th</EM> letter of the alphabet and the integer is
<TT>J</TT>, where <TT>I = N mod 26</TT> and <TT>J = N // 26</TT>. The
integer <TT>J</TT> is omitted if it is zero. For example: 
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD ALIGN=left NOWRAP><TT>'$VAR'(0)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD ALIGN=left NOWRAP>is written as <TT>A</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>'$VAR'(1)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD ALIGN=left NOWRAP>is written as <TT>B</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP COLSPAN=3><TT>...</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>'$VAR'(25)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD ALIGN=left NOWRAP>is written as <TT>Z</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>'$VAR'(26)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD ALIGN=left NOWRAP>is written as <TT>A1</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>'$VAR'(27)</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD ALIGN=left NOWRAP>is written as <TT>B1</TT></TD>
</TR></TABLE></DL>
<B>Variable naming</B>: when the <TT>namevars(true)</TT> option is passed
to <TT>write_term/3</TT> any term of the form <TT>'$VARNAME'(Name)</TT>
where <TT>Name</TT> is an atom is output as a variable name consisting of
the characters <TT>Name</TT>. For example: <TT>'$VARNAME'('A')</TT> is
written as <TT>A</TT> (even in the presence of the <TT>quoted(true)</TT>
option).<BR>
<BR>
<TT>write(SorA, Term)</TT> is equivalent to
<TT>write_term(SorA, Term, [])</TT>.<BR>
<BR>
<TT>writeq(SorA, Term)</TT> is equivalent to
<TT>write_term(SorA, Term, [quoted(true)])</TT>.<BR>
<BR>
<TT>write_canonical(SorA, Term)</TT> is equivalent to
<TT>write_term(SorA, Term, [quoted(true),<BR>
ignore_ops(true), numbervars(false)])</TT>.<BR>
<BR>
<TT>display(SorA, Term)</TT> is equivalent to
<TT>write_term(SorA, Term, [ignore_ops(true),<BR>
numbervars(false)])</TT>.<BR>
<BR>
<TT>print(SorA, Term)</TT> is equivalent to
<TT>write_term(SorA, Term, [numbervars(false),<BR>
portrayed(true)])</TT>.<BR>
<BR>
<TT>write_term/2</TT>, <TT>write/1</TT>, <TT>writeq/1</TT>,
<TT>write_canonical/1</TT>, <TT>display/1</TT> and <TT>print/1</TT> apply
to the current output stream.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Options</TT> is a partial list or a list with an element
<TT>E</TT> which is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Options</TT> is neither a partial list nor a list</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(list, Options)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is neither a variable nor a stream-term or alias</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(stream_or_alias, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Options</TT> list is neither a
variable nor a valid write-option</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(write_option, E)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is not associated with an open stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is an input stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(output, stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is associated with a binary stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(output, binary_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
ISO predicates except <TT>display/1-2</TT> and <TT>print/1-2</TT> that
are GNU Prolog predicates. <TT>namevars/1</TT>, <TT>space_args/1</TT>,
<TT>portrayed/1</TT>, <TT>max_depth/1</TT> and <TT>priority/1</TT>
options are GNU Prolog extensions.<BR>
<BR>
<A NAME="toc121"></A>
<H4 CLASS="subsubsection"><A NAME="htoc157">7.14.7</A>&nbsp;&nbsp;<TT>format/3</TT>,
 <TT>format/2</TT></H4>
<A NAME="format/3"></A>
 
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
format(+stream_or_alias, +character_code_list_or_atom,
+list)<BR>
format(+character_code_list_or_atom, +list)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>format(SorA, Format, Arguments)</TT> writes the <TT>Format</TT> string
replacing each format control sequence <TT>F</TT> by the corresponding
element of <TT>Arguments</TT> (formatted according to <TT>F</TT>) to the
stream associated with the stream-term or alias <TT>SorA</TT>.<BR>
<BR>
<B>Format control sequences</B>: the general format of a control sequence
is <TT>'~NC'</TT>. The character <TT>C</TT> determines the type of
the control sequence. <TT>N</TT> is an optional numeric argument. An
alternative form of <TT>N</TT> is <TT>'*'</TT>. <TT>'*'</TT> implies
that the next argument <TT>Arg</TT> in <TT>Arguments</TT> should be
used as a numeric argument in the control sequence. The use of C
<TT>printf()</TT> formatting sequence (beginning by the character
<TT>%</TT>) is also allowed. The following control sequences are
available:<BR>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center">Format sequence</DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">type of the argument</DIV></TD>
<TD VALIGN=top ALIGN=left>Description</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~Na</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">atom</DIV></TD>
<TD VALIGN=top ALIGN=left>print the atom without quoting. <TT>N</TT> is minimal number of characters to print using spaces on the rigth if needed (default: the length of the atom)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~Nc</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">character code</DIV></TD>
<TD VALIGN=top ALIGN=left>print the character associated with the
code. <TT>N</TT> is the number of times to print the character (default: 1)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT> ~Nf</TT>
<BR>
<TT>~Ne ~NE ~Ng ~NG</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">float expression</DIV></TD>
<TD VALIGN=top ALIGN=left>pass the argument <TT>Arg</TT> and 
 <TT>N</TT> to the C <TT>printf()</TT>
 function as: 
<BR>
if <TT>N</TT> is not specified 
 <TT>printf("%f",Arg)</TT> else
 <TT>printf("%.Nf",Arg)</TT>.
<BR>
Similarly for <TT>~Ne</TT>, <TT>~NE</TT>, <TT>~Ng</TT> and <TT>~NG</TT></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~Nd</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">integer expression</DIV></TD>
<TD VALIGN=top ALIGN=left>print the argument. <TT>N</TT> is the
number of digits after the decimal point. If <TT>N</TT> is 0 no
decimal point is printed (default: 0)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~ND</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">integer expression</DIV></TD>
<TD VALIGN=top ALIGN=left>identical to <TT>~Nd</TT> except
that <TT>','</TT> separates groups of three digits to the left of the
decimal point</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~Nr</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">integer expression</DIV></TD>
<TD VALIGN=top ALIGN=left>print the argument according to the
radix <TT>N</TT>. 2 &#8804; <TT>N</TT> &#8804; 36 (default: 8). The letters
<TT>a-z</TT> denote digits &gt; 9</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~NR</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">integer expression</DIV></TD>
<TD VALIGN=top ALIGN=left>identical to <TT>~Nr</TT> except
that the letters <TT>A-Z</TT> denote digits &gt; 9</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~Ns</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">character code list</DIV></TD>
<TD VALIGN=top ALIGN=left>print exactly <TT>N</TT> characters 
(default: the length of the list)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~NS</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">character list</DIV></TD>
<TD VALIGN=top ALIGN=left>print exactly <TT>N</TT> characters
(default: the length of the list)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~i</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">term</DIV></TD>
<TD VALIGN=top ALIGN=left>ignore the current argument</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~k</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">term</DIV></TD>
<TD VALIGN=top ALIGN=left>pass the argument to
<TT>write_canonical/1</TT> (section&nbsp;<A HREF="#write-term/3">7.14.6</A>)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~p</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">term</DIV></TD>
<TD VALIGN=top ALIGN=left>pass the argument to <TT>print/1</TT>
(section&nbsp;<A HREF="#write-term/3">7.14.6</A>)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~q</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">term</DIV></TD>
<TD VALIGN=top ALIGN=left>pass the argument to <TT>writeq/1</TT>
(section&nbsp;<A HREF="#write-term/3">7.14.6</A>)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~w</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">term</DIV></TD>
<TD VALIGN=top ALIGN=left>pass the argument to <TT>write/1</TT>
(section&nbsp;<A HREF="#write-term/3">7.14.6</A>)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~~</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">none</DIV></TD>
<TD VALIGN=top ALIGN=left>print the character <TT>'~'</TT></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~Nn</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">none</DIV></TD>
<TD VALIGN=top ALIGN=left>print <TT>N</TT> new-line characters (default: 1)</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~N</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">none</DIV></TD>
<TD VALIGN=top ALIGN=left>print a new-line character if not at the beginning
of a line</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>~?</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">atom</DIV></TD>
<TD VALIGN=top ALIGN=left>use the argument as a nested format string</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><DIV CLASS="center"><TT>%F</TT></DIV></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="center">atom, integer or float expression</DIV></TD>
<TD VALIGN=top ALIGN=left>interface to the C
function <TT>printf(3)</TT> for outputting atoms (C string), integers and
floating point numbers. <TT>*</TT> are also allowed.</TD>
</TR></TABLE><BR>
<TT>format/2</TT> applies to the current output stream.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Format</TT> is a partial list or a list with an element
<TT>E</TT> which is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Arguments</TT> is a partial list</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Format</TT> is neither a partial list nor a list or an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(list, Format)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Arguments</TT> is neither a partial list nor a list</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(list, Arguments)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Format</TT> list is neither a
variable nor a character code</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>representation_error(character_code, E)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is neither a variable nor a stream-term or alias</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(stream_or_alias, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of Format is not a valid format control
sequence</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(format_control_sequence, E)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>the <TT>Arguments</TT> list does not contain sufficient elements</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(non_empty_list, [])</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Arguments</TT> list is a variable
while a non-variable term was expected</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Arguments</TT> list is neither
variable nor an atom while an atom was expected</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, E)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Arguments</TT> cannot be evaluated
as an arithmetic expression while an integer or a floating point number was
expected</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left>an arithmetic error (section&nbsp;<A HREF="gprolog029.html#Evaluation-of-an-arithmetic-expression">7.6.1</A>)</TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Arguments</TT> list is neither
variable nor character code while a character code was expected</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>representation_error(character_code, E)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is not associated with an open stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is an input stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(output, stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is associated with a binary stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(output, binary_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates. <BR>
<BR>
<A NAME="toc122"></A>
<H4 CLASS="subsubsection"><A NAME="htoc158">7.14.8</A>&nbsp;&nbsp;<TT>portray_clause/2</TT>,
 <TT>portray_clause/1</TT></H4>
<A NAME="portray-clause/2"></A>
 
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
portray_clause(+stream_or_alias, +clause)<BR>
portray_clause(+clause)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>portray_clause(SorA, Clause)</TT> pretty prints
<TT>Clause</TT> to the stream associated with the stream-term or alias
<TT>SorA</TT>.
<TT>portray_clause/2</TT> uses the variable binding predicates
<TT>name_singleton_vars/1</TT> (section&nbsp;<A HREF="gprolog028.html#name-singleton-vars/1">7.5.1</A>) and
<TT>numbervars/1</TT> (section&nbsp;<A HREF="gprolog028.html#bind-variables/2">7.5.3</A>). This predicate is
used by <TT>listing/1</TT> (section&nbsp;<A HREF="gprolog046.html#listing/1">7.23.3</A>).<BR>
<BR>
<TT>portray_clause/1</TT> applies to the current output stream.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Clause</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Clause</TT> is neither a variable nor a callable term</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(callable, Clause)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is neither a variable nor a stream-term or alias</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(stream_or_alias, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is not associated with an open stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is an input stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(output, stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>SorA</TT> is associated with a binary stream</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(output, binary_stream, SorA)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicates.<BR>
<BR>
<A NAME="toc123"></A>
<H4 CLASS="subsubsection"><A NAME="htoc159">7.14.9</A>&nbsp;&nbsp;<TT>get_print_stream/1</TT></H4>
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
get_print_stream(?stream)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>get_print_stream(Stream)</TT> unifies <TT>Stream</TT> with the
stream-term associated with the output stream used by <TT>print/2</TT>
(section&nbsp;<A HREF="#write-term/3">7.14.6</A>). The purpose of this predicate is to allow a
user-defined <TT>portray/1</TT> predicate to identify the output stream in
use.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Stream</TT> is neither a variable nor a stream-term</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(stream, Stream)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>
<A NAME="toc124"></A>
<H4 CLASS="subsubsection"><A NAME="htoc160">7.14.10</A>&nbsp;&nbsp;<TT>op/3</TT></H4>
<A NAME="op/3:(Term-input/output)"></A>
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
op(+integer, +operator_specifier, +atom_or_atom_list)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>op(Priority, OpSpecifier, Operator)</TT> alters the operator table.
<TT>Operator</TT> is declared as an operator with properties defined by
specifier <TT>OpSpecifier</TT> and <TT>Priority</TT>. <TT>Priority</TT> must
be an integer &#8805; 0 and &#8804; 1200. If <TT>Priority</TT> is 0 then the
operator properties of <TT>Operator</TT> (if any) are canceled.
<TT>Operator</TT> may also be a list of atoms in which case all of them are
declared to be operators. In general, operators can be removed from
the operator table and their priority or specifier can be changed. However,
it is an error to attempt to change the <TT>','</TT> operator from its
initial status. An atom can have multiple operator definitions (e.g.
prefix and infix like <TT>+</TT>) however an atom cannot have both an
infix and a postfix operator definitions.<BR>
<BR>
<B>Operator specifiers</B>: the following specifiers are available:<BR>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>
<TR><TD ALIGN=center NOWRAP>Specifier</TD>
<TD ALIGN=center NOWRAP>Type</TD>
<TD ALIGN=center NOWRAP>Associativity</TD>
</TR>
<TR><TD ALIGN=center NOWRAP><TT>fx</TT></TD>
<TD ALIGN=center NOWRAP>prefix</TD>
<TD ALIGN=center NOWRAP>no</TD>
</TR>
<TR><TD ALIGN=center NOWRAP><TT>fy</TT></TD>
<TD ALIGN=center NOWRAP>prefix</TD>
<TD ALIGN=center NOWRAP>yes</TD>
</TR>
<TR><TD ALIGN=center NOWRAP><TT>xf</TT></TD>
<TD ALIGN=center NOWRAP>postfix</TD>
<TD ALIGN=center NOWRAP>no</TD>
</TR>
<TR><TD ALIGN=center NOWRAP><TT>yf</TT></TD>
<TD ALIGN=center NOWRAP>postfix</TD>
<TD ALIGN=center NOWRAP>yes</TD>
</TR>
<TR><TD ALIGN=center NOWRAP><TT>xfx</TT></TD>
<TD ALIGN=center NOWRAP>infix</TD>
<TD ALIGN=center NOWRAP>no</TD>
</TR>
<TR><TD ALIGN=center NOWRAP><TT>yfx</TT></TD>
<TD ALIGN=center NOWRAP>infix</TD>
<TD ALIGN=center NOWRAP>left</TD>
</TR>
<TR><TD ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD ALIGN=center NOWRAP>infix</TD>
<TD ALIGN=center NOWRAP>right</TD>
</TR></TABLE><BR>
<B>Prolog predefined operators</B>:<BR>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>
<TR><TD VALIGN=top ALIGN=right NOWRAP>Priority</TD>
<TD VALIGN=top ALIGN=center NOWRAP>Specifier</TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">Operators</DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>1200</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>:- &nbsp;&ndash;&gt;</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>1200</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>fx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>:-</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>1100</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>;</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>1050</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>-&gt;</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>1000</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>,</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>900</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>fy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>\+</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>700</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>= &nbsp;\= &nbsp;=.. &nbsp;== &nbsp;\== &nbsp;@&lt;
&nbsp;@=&lt; &nbsp;@&gt; &nbsp;@&gt;= &nbsp;is &nbsp;=:= &nbsp;=\= &nbsp;&lt; &nbsp;=&lt; &nbsp;&gt; &nbsp;&gt;=</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>600</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>:</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>500</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>yfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>+ &nbsp;- &nbsp;/\ &nbsp;\/</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>400</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>yfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>* &nbsp;/ &nbsp;// &nbsp;rem &nbsp;mod &nbsp;&lt;&lt;
&nbsp;&gt;&gt;</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>200</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>** &nbsp;^</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>200</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>fy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>+ &nbsp;- &nbsp;\</TT></DIV></TD>
</TR></TABLE><BR>
<B>FD predefined operators</B>:<BR>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>
<TR><TD VALIGN=top ALIGN=right NOWRAP>Priority</TD>
<TD VALIGN=top ALIGN=center NOWRAP>Specifier</TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">Operators</DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>750</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>#&lt;=&gt; &nbsp;#\&lt;=&gt;</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>740</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>#==&gt; &nbsp;#\==&gt;</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>730</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>## &nbsp;#\/ &nbsp;#\\/</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>720</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>yfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>#/\ &nbsp;#\/\</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>710</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>fy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>#\</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>700</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>#= &nbsp;#\= &nbsp;#&lt; &nbsp;#=&lt;
&nbsp;#&gt; &nbsp;#&gt;= &nbsp;#=# &nbsp;#\=# &nbsp;#&lt;# &nbsp;#=&lt;# &nbsp;#&gt;#
&nbsp;#&gt;=#</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>500</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>yfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>+ &nbsp;-</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>400</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>yfx</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>* &nbsp;/ &nbsp;// &nbsp;rem</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>200</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>xfy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>**</TT></DIV></TD>
</TR>
<TR><TD VALIGN=top ALIGN=right NOWRAP><TT>200</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP><TT>fy</TT></TD>
<TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>+ &nbsp;-</TT></DIV></TD>
</TR></TABLE><BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Priority</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OpSpecifier</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Operator</TT> is a partial list or a list with an element
<TT>E</TT> which is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Priority</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Priority)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OpSpecifier</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, OpSpecifier)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Operator</TT> is neither a partial list nor a list nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(list, Operator)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Operator</TT> list is neither a
variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, E)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Priority</TT> is an integer not &#8805; 0 and &#8804; 1200</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(operator_priority, Priority)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OpSpecifier</TT> is not a valid operator specifier</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(operator_specifier, OpSpecifier)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Operator</TT> is <TT>','</TT> or an element of the
<TT>Operator</TT> list is <TT>','</TT></TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(modify, operator, ',')</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OpSpecifier</TT> is a specifier such that <TT>Operator</TT>
would have a postfix and an infix definition.</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>permission_error(create, operator, Operator)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
ISO predicate. <BR>
<BR>
The ISO reference implies that if a program calls <TT>current_op/3</TT>,
then modifies an operator definition by calling <TT>op/3</TT> and backtracks
into the call to <TT>current_op/3</TT>, then the changes are guaranteed not
to affect that <TT>current_op/3</TT> goal. This is not guaranteed by
GNU Prolog.<BR>
<BR>
<A NAME="toc125"></A>
<H4 CLASS="subsubsection"><A NAME="htoc161">7.14.11</A>&nbsp;&nbsp;<TT>current_op/3</TT></H4>
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
current_op(?integer, ?operator_specifier, ?atom)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>current_op(Priority, OpSpecifier, Operator)</TT> succeeds if
<TT>Operator</TT> is an operator with properties defined by specifier
<TT>OpSpecifier</TT> and <TT>Priority</TT>. This predicate is re-executable
on backtracking.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Priority</TT> is neither a variable nor an operator priority</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(operator_priority, Priority)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OpSpecifier</TT> is neither a variable nor an operator
specifier</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(operator_specifier, OpSpecifier)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Operator</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Operator)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
ISO predicate. <BR>
<BR>
<A NAME="toc126"></A>
<H4 CLASS="subsubsection"><A NAME="htoc162">7.14.12</A>&nbsp;&nbsp;<TT>char_conversion/2</TT></H4>
<A NAME="char-conversion/2"></A>
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
char_conversion(+character, +character)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>char_conversion(InChar, OutChar)</TT> alters the character-conversion
mapping. This mapping is used by the following read predicates:
<TT>read_term/3</TT> (section&nbsp;<A HREF="#read-term/3">7.14.1</A>), <TT>read_atom/2</TT>,
<TT>read_integer/2</TT>, <TT>read_number/2</TT> (section&nbsp;<A HREF="#read-atom/2">7.14.2</A>) and
<TT>read_token/2</TT> (section&nbsp;<A HREF="#read-token/2">7.14.3</A>) to replace any occurrence of a
character <TT>InChar</TT> by <TT>OutChar</TT>. However the conversion
mechanism should have been previously activated by switching on the
<TT>char_conversion</TT> Prolog flag (section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>). When
<TT>InChar</TT> and <TT>OutChar</TT> are the same, the effect is to remove
any conversion of a character <TT>InChar</TT>.<BR>
<BR>
Note that the single character read predicates (e.g. <TT>get_char/2</TT>)
never do character conversion. If such behavior is required, it must be
explicitly done using <TT>current_char_conversion/2</TT>
(section&nbsp;<A HREF="#current-char-conversion/2">7.14.13</A>).<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>InChar</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OutChar</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>InChar</TT> is neither a variable nor a character</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(character, InChar)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OutChar</TT> is neither a variable nor a character</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(character, OutChar)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
ISO predicate. The <TT>type_error(character,...)</TT> is a GNU Prolog
behavior, the ISO reference instead defines a
<TT>representation_error(character)</TT> in this case. This seems to be an
error of the ISO reference since, for many other built-in predicates
accepting a character (e.g. <TT>char_code/2</TT>, <TT>put_char/2</TT>), a
<TT>type_error</TT> is raised. <BR>
<BR>
The ISO reference implies that if a program calls
<TT>current_char_conversion/2</TT>, then modifies the character mapping by
calling <TT>char_conversion/2</TT>, and backtracks into the call to
<TT>current_char_conversion/2</TT> then the changes are guaranteed not to
affect that <TT>current_char_conversion/2</TT> goal. This is not guaranteed
by GNU Prolog.<BR>
<BR>
<A NAME="toc127"></A>
<H4 CLASS="subsubsection"><A NAME="htoc163">7.14.13</A>&nbsp;&nbsp;<TT>current_char_conversion/2</TT></H4>
<A NAME="current-char-conversion/2"></A>
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
current_char_conversion(?character, ?character)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>current_char_conversion(InChar, OutChar)</TT> succeeds if the
conversion of <TT>InChar</TT> is <TT>OutChar</TT> according to the
character-conversion mapping. In that case, <TT>InChar</TT> and
<TT>OutChar</TT> are different. This predicate is re-executable on
backtracking.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>InChar</TT> is neither a variable nor a character</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(character, InChar)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>OutChar</TT> is neither a variable nor a character</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(character, OutChar)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
ISO predicate. Same remark as for char_conversion/2
(section&nbsp;<A HREF="#char-conversion/2">7.14.12</A>).<BR>
<BR>

<HR SIZE=2>
Copyright (C) 1999-2007 Daniel Diaz
<BR>
<BR>
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. <BR>
<BR>
<A HREF="index.html#copyright">More about the copyright</A>
<HR>
<A HREF="gprolog036.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog038.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>