Codebase list swi-prolog / 3c2c41e
New upstream version 7.6.3+dfsg Lev Lamberov 6 years ago
231 changed file(s) with 20470 addition(s) and 11810 deletion(s). Raw diff Collapse all Expand all
0 7.6.2
0 7.6.3
55
66 SWI-Prolog 7.6
77 Reference Manual
8 _U_p_d_a_t_e_d _f_o_r _v_e_r_s_i_o_n _7_._6_-_2_, _N_o_v_e_m_b_e_r _2_0_1_7
8 _U_p_d_a_t_e_d _f_o_r _v_e_r_s_i_o_n _7_._6_-_3_, _N_o_v_e_m_b_e_r _2_0_1_7
99
1010 _J_a_n _W_i_e_l_e_m_a_k_e_r
1111 J.Wielemaker@vu.nl
3035730357 ignores the first _C_o_u_n_t solutions.
3035830358
3035930359
30360 oorrddeerr__bbyy((_S_p_e_c_, _G_o_a_l))
30360 ccaallll__nntthh((_:_G_o_a_l_, _?_N_t_h))
30361 True when _G_o_a_l succeeded for the _N_t_h time. If _N_t_h is bound on
30362 entry, the predicate succeeds deterministically if there are at
30363 least _N_t_h solutions for _G_o_a_l.
30364
30365
30366 oorrddeerr__bbyy((_+_S_p_e_c_, _:_G_o_a_l))
3036130367 Order solutions according to _S_p_e_c. _S_p_e_c is a list of terms, where
3036230368 each element is one of. The ordering of solutions of _G_o_a_l that
3036330369 only differ in variables that are _n_o_t shared with _S_p_e_c is not
3414434150
3414534151 1188..22..3344 lliibbrraarryy((ssoolluuttiioonn__sseeqquueenncceess))
3414634152
34153 call_nth/2 True when Goal succeeded for the Nth time.
3414734154 distinct/1 True if Goal is true and no previous solution of Goal bound Witness to the same value.
3414834155 distinct/2 True if Goal is true and no previous solution of Goal bound Witness to the same value.
3414934156 group_by/4 Group bindings of Template that have the same value for By.
3415134158 offset/2 Ignore the first Count solutions.
3415234159 order_by/2 Order solutions according to Spec.
3415334160 reduced/1 Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.
34161
3415434162 reduced/3 Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.
3415534163
3415634164
3444034448 _A_r_t _o_f _P_r_o_l_o_g. MIT Press, Cambridge,
3444134449 Massachusetts, 1986.
3444234450
34443 1966
34451 1967
11231123 predicate(reduced,3,'Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.',30335,30347).
11241124 predicate(limit,2,'Limit the number of solutions.',30349,30353).
11251125 predicate(offset,2,'Ignore the first Count solutions.',30355,30359).
1126 predicate(group_by,4,'Group bindings of Template that have the same value for By.',30374,30380).
1127 predicate(table,1,'Declare predicate to be tabled',30656,30674).
1128 predicate(abolish_all_tables,0,'Abolish computed tables',30676,30683).
1129 predicate(abolish_table_subgoals,1,'Abolish tables for a goal',30685,30687).
1130 predicate(thread_pool_create,3,'Create a pool of threads.',30781,30798).
1131 predicate(thread_pool_destroy,1,'Destroy the thread pool named Name.',30800,30804).
1132 predicate(current_thread_pool,1,'True if Name refers to a defined thread pool.',30806,30808).
1133 predicate(thread_pool_property,2,'True if Property is a property of thread pool Name.',30810,30831).
1134 predicate(thread_create_in_pool,4,'Create a thread in Pool.',30833,30847).
1135 predicate(create_pool,1,'Hook to create a thread pool lazily.',30849,30863).
1136 predicate(vertices_edges_to_ugraph,3,'Create unweighted graph',30894,30912).
1137 predicate(vertices,2,'Find vertices in graph',30914,30920).
1138 predicate(edges,2,'Find edges in graph',30922,30929).
1139 predicate(add_vertices,3,'Add vertices to graph',30931,30939).
1140 predicate(del_vertices,3,'Delete vertices from graph',30941,30953).
1141 predicate(add_edges,3,'Add edges to graph',30955,30967).
1142 predicate(del_edges,3,'Delete edges from graph',30969,30979).
1143 predicate(transpose_ugraph,2,'Invert the direction of all edges',30981,30992).
1144 predicate(neighbours,3,'Find neighbors of vertice',30994,31003).
1145 predicate(neighbors,3,'Find neighbors of vertice',31005,31007).
1146 predicate(complement,2,'Inverse presense of edges',31009,31019).
1147 predicate(compose,3,'',31021,31029).
1148 predicate(ugraph_union,3,'Union of two graphs',31031,31038).
1149 predicate(top_sort,2,'Sort graph topologically',31040,31050).
1150 predicate(top_sort,3,'Sort graph topologically',31052,31055).
1151 predicate(transitive_closure,2,'Create transitive closure of graph',31057,31065).
1152 predicate(reachable,3,'Find all reachable vertices',31067,31075).
1153 predicate(global_url,3,'Translate a possibly relative URL into an absolute one.',31098,31102).
1154 predicate(is_absolute_url,1,'True if URL is an absolute URL.',31104,31107).
1155 predicate(http_location,2,'Construct or analyze an HTTP location.',31109,31120).
1156 predicate(parse_url,2,'Construct or analyse a URL.',31122,31179).
1157 predicate(parse_url,3,'Similar to parse_url/2 for relative URLs.',31181,31184).
1158 predicate(www_form_encode,2,'En/decode to/from application/x-www-form-encoded.',31186,31187).
1159 predicate(www_form_encode,2,'En/decode to/from application/x-www-form-encoded.',31189,31200).
1160 predicate(set_url_encoding,2,'Query and set the encoding for URLs.',31202,31209).
1161 predicate(url_iri,2,'Convert between a URL, encoding in US-ASCII and an IRI.',31211,31212).
1162 predicate(url_iri,2,'Convert between a URL, encoding in US-ASCII and an IRI.',31214,31218).
1163 predicate(parse_url_search,2,'Construct or analyze an HTTP search specification.',31220,31224).
1164 predicate(file_name_to_url,2,'Translate between a filename and a file:Sidiv{} URL.',31226,31227).
1165 predicate(file_name_to_url,2,'Translate between a filename and a file:Sidiv{} URL.',31229,31234).
1166 predicate(numbervars,1,'Number variables in Term using $VAR(N).',31260,31265).
1167 predicate(varnumbers,2,'Inverse of numbervars/1.',31267,31269).
1168 predicate(varnumbers,3,'Inverse of numbervars/3.',31271,31282).
1169 predicate(max_var_number,3,'True when Max is the max of Start and the highest numbered $VAR(N) term.',31284,31291).
1170 predicate(varnumbers_names,3,'If Term is a term with numbered and named variables using the reserved term \'$VAR\'(X), Copy is a copy of Term where each \'$VAR\'(X) is consistently replaced by a fresh variable and Bindings is a list `X = Var`, relating the `X` terms with the variable it is mapped to.',31293,31302).
1171 predicate(>>,2,'Calls a copy of Lambda.',31377,31378).
1172 predicate(>>,3,'Calls a copy of Lambda.',31380,31381).
1173 predicate(>>,4,'Calls a copy of Lambda.',31383,31384).
1174 predicate(>>,5,'Calls a copy of Lambda.',31386,31387).
1175 predicate(>>,6,'Calls a copy of Lambda.',31389,31390).
1176 predicate(>>,7,'Calls a copy of Lambda.',31392,31393).
1177 predicate(>>,8,'Calls a copy of Lambda.',31395,31396).
1178 predicate(>>,9,'Calls a copy of Lambda.',31398,31415).
1179 predicate(/,2,'Shorthand for `Free/[]Srshift{}Lambda`.',31417,31418).
1180 predicate(/,3,'Shorthand for `Free/[]Srshift{}Lambda`.',31420,31421).
1181 predicate(/,4,'Shorthand for `Free/[]Srshift{}Lambda`.',31423,31424).
1182 predicate(/,5,'Shorthand for `Free/[]Srshift{}Lambda`.',31426,31427).
1183 predicate(/,6,'Shorthand for `Free/[]Srshift{}Lambda`.',31429,31430).
1184 predicate(/,7,'Shorthand for `Free/[]Srshift{}Lambda`.',31432,31433).
1185 predicate(/,8,'Shorthand for `Free/[]Srshift{}Lambda`.',31435,31436).
1186 predicate(/,9,'Shorthand for `Free/[]Srshift{}Lambda`.',31438,31461).
1187 predicate(is_lambda,1,'True if Term is a valid Lambda expression.',31463,31465).
1188 predicate(lambda_calls,2,'Goal is the goal called if call/N is applied to LambdaExpression, where ExtraArgs are the additional arguments to call/N.',31467,31468).
1189 predicate(lambda_calls,3,'Goal is the goal called if call/N is applied to LambdaExpression, where ExtraArgs are the additional arguments to call/N.',31470,31475).
1190 predicate(prolog_current_frame,1,'Reference to goal\'s environment stack',31490,31496).
1191 predicate(prolog_current_choice,1,'Reference to most recent choice point',31498,31502).
1192 predicate(prolog_frame_attribute,3,'Obtain information on a goal environment',31504,31587).
1193 predicate(prolog_choice_attribute,3,'Examine the choice point stack',31589,31611).
1194 predicate(deterministic,1,'Test deterministicy of current clause',31613,31620).
1195 predicate(prolog_cut_to,1,'Realise global cuts',31625,31638).
1196 predicate(prolog_trace_interception,4,'library(user) Intercept the Prolog tracer',31643,31756).
1197 predicate(prolog_skip_frame,1,'Perform `skip\' on a frame',31758,31765).
1198 predicate(prolog_skip_level,2,'Indicate deepest recursion to trace',31767,31774).
1199 predicate(break_hook,6,'Hook (prolog) Debugger hook',31786,31863).
1200 predicate(prolog_exception_hook,4,'Rewrite exceptions',31873,31917).
1201 predicate(exception,3,'Hook (user) Handle runtime exceptions',31932,31958).
1202 predicate(prolog_list_goal,1,'Hook (user) Intercept tracer \'L\' command',31970,31976).
1203 predicate(debug_control_hook,1,'Hook (prolog) Extend spy/1, etc.',31978,32004).
1204 predicate(help_hook,1,'Hook (prolog) User-hook in the help-system',32006,32021).
1205 predicate(prolog_load_file,2,'Hook (user) Program load_files/2',32030,32041).
1206 predicate(comment_hook,3,'Hook (prolog) handle comments in sources',32043,32062).
1207 predicate(expects_dialect,1,'For which Prolog dialect is this code written?',32105,32131).
1208 predicate(exists_source,1,'Check existence of a Prolog source',32133,32137).
1209 predicate(source_exports,2,'Check whether source exports a predicate',32139,32142).
1210 predicate(license,0,'Evaluate licenses of loaded modules',32690,32697).
1211 predicate(license,2,'Define license for named module',32699,32717).
1212 predicate(license,1,'Define license for current file',32719,32722).
1213 predicate(known_licenses,0,'Print known licenses',32729,32733).
1126 predicate(call_nth,2,'True when Goal succeeded for the Nth time.',30361,30365).
1127 predicate(order_by,2,'Order solutions according to Spec.',30367,30378).
1128 predicate(group_by,4,'Group bindings of Template that have the same value for By.',30380,30386).
1129 predicate(table,1,'Declare predicate to be tabled',30662,30680).
1130 predicate(abolish_all_tables,0,'Abolish computed tables',30682,30689).
1131 predicate(abolish_table_subgoals,1,'Abolish tables for a goal',30691,30693).
1132 predicate(thread_pool_create,3,'Create a pool of threads.',30787,30804).
1133 predicate(thread_pool_destroy,1,'Destroy the thread pool named Name.',30806,30810).
1134 predicate(current_thread_pool,1,'True if Name refers to a defined thread pool.',30812,30814).
1135 predicate(thread_pool_property,2,'True if Property is a property of thread pool Name.',30816,30837).
1136 predicate(thread_create_in_pool,4,'Create a thread in Pool.',30839,30853).
1137 predicate(create_pool,1,'Hook to create a thread pool lazily.',30855,30869).
1138 predicate(vertices_edges_to_ugraph,3,'Create unweighted graph',30900,30918).
1139 predicate(vertices,2,'Find vertices in graph',30920,30926).
1140 predicate(edges,2,'Find edges in graph',30928,30935).
1141 predicate(add_vertices,3,'Add vertices to graph',30937,30945).
1142 predicate(del_vertices,3,'Delete vertices from graph',30947,30959).
1143 predicate(add_edges,3,'Add edges to graph',30961,30973).
1144 predicate(del_edges,3,'Delete edges from graph',30975,30985).
1145 predicate(transpose_ugraph,2,'Invert the direction of all edges',30987,30998).
1146 predicate(neighbours,3,'Find neighbors of vertice',31000,31009).
1147 predicate(neighbors,3,'Find neighbors of vertice',31011,31013).
1148 predicate(complement,2,'Inverse presense of edges',31015,31025).
1149 predicate(compose,3,'',31027,31035).
1150 predicate(ugraph_union,3,'Union of two graphs',31037,31044).
1151 predicate(top_sort,2,'Sort graph topologically',31046,31056).
1152 predicate(top_sort,3,'Sort graph topologically',31058,31061).
1153 predicate(transitive_closure,2,'Create transitive closure of graph',31063,31071).
1154 predicate(reachable,3,'Find all reachable vertices',31073,31081).
1155 predicate(global_url,3,'Translate a possibly relative URL into an absolute one.',31104,31108).
1156 predicate(is_absolute_url,1,'True if URL is an absolute URL.',31110,31113).
1157 predicate(http_location,2,'Construct or analyze an HTTP location.',31115,31126).
1158 predicate(parse_url,2,'Construct or analyse a URL.',31128,31185).
1159 predicate(parse_url,3,'Similar to parse_url/2 for relative URLs.',31187,31190).
1160 predicate(www_form_encode,2,'En/decode to/from application/x-www-form-encoded.',31192,31193).
1161 predicate(www_form_encode,2,'En/decode to/from application/x-www-form-encoded.',31195,31206).
1162 predicate(set_url_encoding,2,'Query and set the encoding for URLs.',31208,31215).
1163 predicate(url_iri,2,'Convert between a URL, encoding in US-ASCII and an IRI.',31217,31218).
1164 predicate(url_iri,2,'Convert between a URL, encoding in US-ASCII and an IRI.',31220,31224).
1165 predicate(parse_url_search,2,'Construct or analyze an HTTP search specification.',31226,31230).
1166 predicate(file_name_to_url,2,'Translate between a filename and a file:Sidiv{} URL.',31232,31233).
1167 predicate(file_name_to_url,2,'Translate between a filename and a file:Sidiv{} URL.',31235,31240).
1168 predicate(numbervars,1,'Number variables in Term using $VAR(N).',31266,31271).
1169 predicate(varnumbers,2,'Inverse of numbervars/1.',31273,31275).
1170 predicate(varnumbers,3,'Inverse of numbervars/3.',31277,31288).
1171 predicate(max_var_number,3,'True when Max is the max of Start and the highest numbered $VAR(N) term.',31290,31297).
1172 predicate(varnumbers_names,3,'If Term is a term with numbered and named variables using the reserved term \'$VAR\'(X), Copy is a copy of Term where each \'$VAR\'(X) is consistently replaced by a fresh variable and Bindings is a list `X = Var`, relating the `X` terms with the variable it is mapped to.',31299,31308).
1173 predicate(>>,2,'Calls a copy of Lambda.',31383,31384).
1174 predicate(>>,3,'Calls a copy of Lambda.',31386,31387).
1175 predicate(>>,4,'Calls a copy of Lambda.',31389,31390).
1176 predicate(>>,5,'Calls a copy of Lambda.',31392,31393).
1177 predicate(>>,6,'Calls a copy of Lambda.',31395,31396).
1178 predicate(>>,7,'Calls a copy of Lambda.',31398,31399).
1179 predicate(>>,8,'Calls a copy of Lambda.',31401,31402).
1180 predicate(>>,9,'Calls a copy of Lambda.',31404,31421).
1181 predicate(/,2,'Shorthand for `Free/[]Srshift{}Lambda`.',31423,31424).
1182 predicate(/,3,'Shorthand for `Free/[]Srshift{}Lambda`.',31426,31427).
1183 predicate(/,4,'Shorthand for `Free/[]Srshift{}Lambda`.',31429,31430).
1184 predicate(/,5,'Shorthand for `Free/[]Srshift{}Lambda`.',31432,31433).
1185 predicate(/,6,'Shorthand for `Free/[]Srshift{}Lambda`.',31435,31436).
1186 predicate(/,7,'Shorthand for `Free/[]Srshift{}Lambda`.',31438,31439).
1187 predicate(/,8,'Shorthand for `Free/[]Srshift{}Lambda`.',31441,31442).
1188 predicate(/,9,'Shorthand for `Free/[]Srshift{}Lambda`.',31444,31467).
1189 predicate(is_lambda,1,'True if Term is a valid Lambda expression.',31469,31471).
1190 predicate(lambda_calls,2,'Goal is the goal called if call/N is applied to LambdaExpression, where ExtraArgs are the additional arguments to call/N.',31473,31474).
1191 predicate(lambda_calls,3,'Goal is the goal called if call/N is applied to LambdaExpression, where ExtraArgs are the additional arguments to call/N.',31476,31481).
1192 predicate(prolog_current_frame,1,'Reference to goal\'s environment stack',31496,31502).
1193 predicate(prolog_current_choice,1,'Reference to most recent choice point',31504,31508).
1194 predicate(prolog_frame_attribute,3,'Obtain information on a goal environment',31510,31593).
1195 predicate(prolog_choice_attribute,3,'Examine the choice point stack',31595,31617).
1196 predicate(deterministic,1,'Test deterministicy of current clause',31619,31626).
1197 predicate(prolog_cut_to,1,'Realise global cuts',31631,31644).
1198 predicate(prolog_trace_interception,4,'library(user) Intercept the Prolog tracer',31649,31762).
1199 predicate(prolog_skip_frame,1,'Perform `skip\' on a frame',31764,31771).
1200 predicate(prolog_skip_level,2,'Indicate deepest recursion to trace',31773,31780).
1201 predicate(break_hook,6,'Hook (prolog) Debugger hook',31792,31869).
1202 predicate(prolog_exception_hook,4,'Rewrite exceptions',31879,31923).
1203 predicate(exception,3,'Hook (user) Handle runtime exceptions',31938,31964).
1204 predicate(prolog_list_goal,1,'Hook (user) Intercept tracer \'L\' command',31976,31982).
1205 predicate(debug_control_hook,1,'Hook (prolog) Extend spy/1, etc.',31984,32010).
1206 predicate(help_hook,1,'Hook (prolog) User-hook in the help-system',32012,32027).
1207 predicate(prolog_load_file,2,'Hook (user) Program load_files/2',32036,32047).
1208 predicate(comment_hook,3,'Hook (prolog) handle comments in sources',32049,32068).
1209 predicate(expects_dialect,1,'For which Prolog dialect is this code written?',32111,32137).
1210 predicate(exists_source,1,'Check existence of a Prolog source',32139,32143).
1211 predicate(source_exports,2,'Check whether source exports a predicate',32145,32148).
1212 predicate(license,0,'Evaluate licenses of loaded modules',32696,32703).
1213 predicate(license,2,'Define license for named module',32705,32723).
1214 predicate(license,1,'Define license for current file',32725,32728).
1215 predicate(known_licenses,0,'Print known licenses',32735,32739).
12141216
12151217
12161218 % Predicate section/4
13521354 section([4,17,1],'Predefined stream aliases',8024,8060).
13531355 section([4,17,2],'ISO Input and Output Streams',8062,8585).
13541356 section([4,17,3],'Edinburgh-style I/O',8587,8705).
1355 section([],'Compatibility notes',8635,34444).
1357 section([],'Compatibility notes',8635,34452).
13561358 section([4,17,4],'Switching between Edinburgh and ISO I/O',8707,8731).
13571359 section([4,17,5],'Write onto atoms, code-lists, etc.',8733,8786).
13581360 section([4,17,6],'Fast binary term I/O',8788,8829).
15741576 section([12,3,2],'The swipl-rc program',23837,23866).
15751577 section([12,4],'Finding Application files',23868,23913).
15761578 section([12,4,1],'Specifying a file search path from the command line',23900,23913).
1577 section([13],'THE SWI-PROLOG LIBRARY',23915,31475).
1579 section([13],'THE SWI-PROLOG LIBRARY',23915,31481).
15781580 section([13,1],'library(aggregate): Aggregation operators on backtrackable',23939,24105).
15791581 section([13,2],'library(apply): Apply predicates on a list',24107,24219).
15801582 section([13,3],'library(assoc): Association lists',24221,24384).
16681670 section([13,33,4,1],'Example 1',30116,30149).
16691671 section([13,33,4,2],'Example 2',30151,30211).
16701672 section([13,33,4,3],'Example 3',30213,30261).
1671 section([13,34],'library(solution_sequences): Modify solution sequences',30263,30380).
1672 section([13,35],'library(tabling): Tabled execution (SLG)',30382,30743).
1673 section([13,35,0,1],'Example 1: using tabling for memoizing',30412,30497).
1674 section([13,35,0,2],'Example 2: avoiding non-termination',30499,30560).
1675 section([13,35,0,3],'Mode directed tabling',30562,30651).
1676 section([13,35,1],'Tabling predicate reference',30653,30743).
1677 section([13,35,1,1],'About the tabling implementation',30689,30723).
1678 section([13,35,1,2],'Status of tabling',30725,30743).
1679 section([13,36],'library(thread_pool): Resource bounded thread management',30745,30863).
1680 section([13,37],'library(ugraphs): Unweighted Graphs',30865,31075).
1681 section([13,38],'library(url): Analysing and constructing URL',31077,31234).
1682 section([13,39],'library(varnumbers): Utilities for numbered terms',31236,31302).
1683 section([13,40],'library(yall): Lambda expressions',31304,31475).
1684 section([14],'HACKERS CORNER',31477,32062).
1685 section([14,1],'Examining the Environment Stack',31487,31620).
1686 section([14,2],'Ancestral cuts',31622,31638).
1687 section([14,3],'Intercepting the Tracer',31640,31774).
1688 section([14,4],'Breakpoint and watchpoint handling',31776,31863).
1689 section([14,5],'Adding context to errors: prolog_exception_hook',31865,31917).
1690 section([14,6],'Hooks using the exception predicate',31919,31958).
1691 section([14,7],'Hooks for integrating libraries',31960,32021).
1692 section([14,8],'Hooks for loading files',32023,32062).
1693 section([15],'COMPATIBILITY WITH OTHER PROLOG DIALECTS',32064,32260).
1694 section([15,1],'Some considerations for writing portable code',32144,32260).
1695 section([16],'GLOSSARY OF TERMS',32262,32606).
1696 section([17],'SWI-PROLOG LICENSE CONDITIONS AND TOOLS',32608,32769).
1697 section([17,1],'Contributing to the SWI-Prolog project',32668,32677).
1698 section([17,2],'Software support to keep track of license conditions',32679,32733).
1699 section([17,3],'License conditions inherited from used code',32735,32769).
1700 section([17,3,1],'Cryptographic routines',32738,32769).
1701 section([18],'SUMMARY',32771,34353).
1702 section([18,1],'Predicates',32774,33628).
1703 section([18,2],'Library predicates',33630,34200).
1704 section([18,2,1],'library(aggregate)',33633,33641).
1705 section([18,2,2],'library(apply)',33643,33664).
1706 section([18,2,3],'library(assoc)',33666,33683).
1707 section([18,2,4],'library(broadcast)',33685,33695).
1708 section([18,2,5],'library(charsio)',33697,33714).
1709 section([18,2,6],'library(check)',33716,33733).
1710 section([18,2,7],'library(clpb)',33735,33743).
1711 section([18,2,8],'library(clpfd)',33745,33794).
1712 section([18,2,9],'library(clpqr)',33796,33808).
1713 section([18,2,10],'library(csv)',33810,33823).
1714 section([18,2,11],'library(debug)',33825,33838).
1715 section([18,2,12],'library(error)',33840,33856).
1716 section([18,2,13],'library(iostream)',33858,33859).
1717 section([18,2,14],'library(summaries.d/iostream/tex)',33861,33862).
1718 section([18,2,15],'library(lists)',33864,33902).
1719 section([18,2,16],'library(main)',33904,33908).
1720 section([18,2,17],'library(option)',33910,33919).
1721 section([18,2,18],'library(optparse)',33921,33928).
1722 section([18,2,19],'library(ordsets)',33930,33954).
1723 section([18,2,20],'library(persistency)',33956,33965).
1724 section([18,2,21],'library(predicate_options)',33967,33981).
1725 section([18,2,22],'library(prologpack)',33983,33999).
1726 section([18,2,23],'library(prologxref)',34001,34013).
1727 section([18,2,24],'library(pairs)',34015,34023).
1728 section([18,2,25],'library(pio)',34025,34037).
1729 section([18,2,25,1],'library(pure_input)',34028,34037).
1730 section([18,2,26],'library(random)',34039,34056).
1731 section([18,2,27],'library(readutil)',34058,34066).
1732 section([18,2,28],'library(record)',34068,34071).
1733 section([18,2,29],'library(registry)',34073,34085).
1734 section([18,2,30],'library(simplex)',34087,34101).
1735 section([18,2,31],'library(ugraphs)',34103,34124).
1736 section([18,2,32],'library(url)',34126,34139).
1737 section([18,2,33],'library(www_browser)',34141,34144).
1738 section([18,2,34],'library(solution_sequences)',34146,34156).
1739 section([18,2,35],'library(thread_pool)',34158,34166).
1740 section([18,2,36],'library(varnumbers)',34168,34175).
1741 section([18,2,37],'library(yall)',34177,34200).
1742 section([18,3],'Arithmetic Functions',34202,34286).
1743 section([18,4],'Operators',34288,34353).
1744 section([19],'Bibliography',34355,34444).
1673 section([13,34],'library(solution_sequences): Modify solution sequences',30263,30386).
1674 section([13,35],'library(tabling): Tabled execution (SLG)',30388,30749).
1675 section([13,35,0,1],'Example 1: using tabling for memoizing',30418,30503).
1676 section([13,35,0,2],'Example 2: avoiding non-termination',30505,30566).
1677 section([13,35,0,3],'Mode directed tabling',30568,30657).
1678 section([13,35,1],'Tabling predicate reference',30659,30749).
1679 section([13,35,1,1],'About the tabling implementation',30695,30729).
1680 section([13,35,1,2],'Status of tabling',30731,30749).
1681 section([13,36],'library(thread_pool): Resource bounded thread management',30751,30869).
1682 section([13,37],'library(ugraphs): Unweighted Graphs',30871,31081).
1683 section([13,38],'library(url): Analysing and constructing URL',31083,31240).
1684 section([13,39],'library(varnumbers): Utilities for numbered terms',31242,31308).
1685 section([13,40],'library(yall): Lambda expressions',31310,31481).
1686 section([14],'HACKERS CORNER',31483,32068).
1687 section([14,1],'Examining the Environment Stack',31493,31626).
1688 section([14,2],'Ancestral cuts',31628,31644).
1689 section([14,3],'Intercepting the Tracer',31646,31780).
1690 section([14,4],'Breakpoint and watchpoint handling',31782,31869).
1691 section([14,5],'Adding context to errors: prolog_exception_hook',31871,31923).
1692 section([14,6],'Hooks using the exception predicate',31925,31964).
1693 section([14,7],'Hooks for integrating libraries',31966,32027).
1694 section([14,8],'Hooks for loading files',32029,32068).
1695 section([15],'COMPATIBILITY WITH OTHER PROLOG DIALECTS',32070,32266).
1696 section([15,1],'Some considerations for writing portable code',32150,32266).
1697 section([16],'GLOSSARY OF TERMS',32268,32612).
1698 section([17],'SWI-PROLOG LICENSE CONDITIONS AND TOOLS',32614,32775).
1699 section([17,1],'Contributing to the SWI-Prolog project',32674,32683).
1700 section([17,2],'Software support to keep track of license conditions',32685,32739).
1701 section([17,3],'License conditions inherited from used code',32741,32775).
1702 section([17,3,1],'Cryptographic routines',32744,32775).
1703 section([18],'SUMMARY',32777,34361).
1704 section([18,1],'Predicates',32780,33634).
1705 section([18,2],'Library predicates',33636,34208).
1706 section([18,2,1],'library(aggregate)',33639,33647).
1707 section([18,2,2],'library(apply)',33649,33670).
1708 section([18,2,3],'library(assoc)',33672,33689).
1709 section([18,2,4],'library(broadcast)',33691,33701).
1710 section([18,2,5],'library(charsio)',33703,33720).
1711 section([18,2,6],'library(check)',33722,33739).
1712 section([18,2,7],'library(clpb)',33741,33749).
1713 section([18,2,8],'library(clpfd)',33751,33800).
1714 section([18,2,9],'library(clpqr)',33802,33814).
1715 section([18,2,10],'library(csv)',33816,33829).
1716 section([18,2,11],'library(debug)',33831,33844).
1717 section([18,2,12],'library(error)',33846,33862).
1718 section([18,2,13],'library(iostream)',33864,33865).
1719 section([18,2,14],'library(summaries.d/iostream/tex)',33867,33868).
1720 section([18,2,15],'library(lists)',33870,33908).
1721 section([18,2,16],'library(main)',33910,33914).
1722 section([18,2,17],'library(option)',33916,33925).
1723 section([18,2,18],'library(optparse)',33927,33934).
1724 section([18,2,19],'library(ordsets)',33936,33960).
1725 section([18,2,20],'library(persistency)',33962,33971).
1726 section([18,2,21],'library(predicate_options)',33973,33987).
1727 section([18,2,22],'library(prologpack)',33989,34005).
1728 section([18,2,23],'library(prologxref)',34007,34019).
1729 section([18,2,24],'library(pairs)',34021,34029).
1730 section([18,2,25],'library(pio)',34031,34043).
1731 section([18,2,25,1],'library(pure_input)',34034,34043).
1732 section([18,2,26],'library(random)',34045,34062).
1733 section([18,2,27],'library(readutil)',34064,34072).
1734 section([18,2,28],'library(record)',34074,34077).
1735 section([18,2,29],'library(registry)',34079,34091).
1736 section([18,2,30],'library(simplex)',34093,34107).
1737 section([18,2,31],'library(ugraphs)',34109,34130).
1738 section([18,2,32],'library(url)',34132,34145).
1739 section([18,2,33],'library(www_browser)',34147,34150).
1740 section([18,2,34],'library(solution_sequences)',34152,34164).
1741 section([18,2,35],'library(thread_pool)',34166,34174).
1742 section([18,2,36],'library(varnumbers)',34176,34183).
1743 section([18,2,37],'library(yall)',34185,34208).
1744 section([18,3],'Arithmetic Functions',34210,34294).
1745 section([18,4],'Operators',34296,34361).
1746 section([19],'Bibliography',34363,34452).
17451747
17461748
17471749 % Predicate function/3
19751977 function('PL_malloc_atomic_uncollectable',23407,23413).
19761978 function('PL_malloc_stubborn',23415,23416).
19771979 function('PL_end_stubborn_change',23418,23421).
1978 function('PL_license',32724,32727).
1980 function('PL_license',32730,32733).
19791981
19801982
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.21</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.21</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="limits.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="IDE.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:64bits"><a name="sec:2.21"><span class="sec-nr">2.21</span> <span class="sec-title">SWI-Prolog
235 <h2 id="sec:64bits"><a id="sec:2.21"><span class="sec-nr">2.21</span> <span class="sec-title">SWI-Prolog
195236 and 64-bit machines</span></a></h2>
196237
197 <a name="sec:64bits"></a>
198
199 <p><a name="idx:bits64:285"></a>Most of today's 64-bit platforms are
238 <a id="sec:64bits"></a>
239
240 <p><a id="idx:bits64:285"></a>Most of today's 64-bit platforms are
200241 capable of running both 32-bit and 64-bit applications. This asks for
201242 some clarifications on the advantages and drawbacks of 64-bit addressing
202243 for (SWI-)Prolog.
203244
204 <p><h3 id="sec:64bitsplatforms"><a name="sec:2.21.1"><span class="sec-nr">2.21.1</span> <span class="sec-title">Supported
245 <p><h3 id="sec:64bitsplatforms"><a id="sec:2.21.1"><span class="sec-nr">2.21.1</span> <span class="sec-title">Supported
205246 platforms</span></a></h3>
206247
207 <a name="sec:64bitsplatforms"></a>
208
209 <p><a name="idx:64bitsplatforms:286"></a>SWI-Prolog can be compiled for
210 a 32- or 64-bit address space on any system with a suitable C compiler.
248 <a id="sec:64bitsplatforms"></a>
249
250 <p><a id="idx:64bitsplatforms:286"></a>SWI-Prolog can be compiled for a
251 32- or 64-bit address space on any system with a suitable C compiler.
211252 Pointer arithmetic is based on the type (u)intptr_t from <code>stdint.h</code>,
212253 with suitable emulation on MS-Windows.
213254
214 <p><h3 id="sec:32vs64bits"><a name="sec:2.21.2"><span class="sec-nr">2.21.2</span> <span class="sec-title">Comparing
255 <p><h3 id="sec:32vs64bits"><a id="sec:2.21.2"><span class="sec-nr">2.21.2</span> <span class="sec-title">Comparing
215256 32- and 64-bits Prolog</span></a></h3>
216257
217 <a name="sec:32vs64bits"></a>
258 <a id="sec:32vs64bits"></a>
218259
219260 <p>Most of Prolog's memory usage consists of pointers. This indicates
220261 the primary drawback: Prolog memory usage almost doubles when using the
233274
234275 <p>Multi-threaded applications profit much more because every thread has
235276 its own set of stacks. The Prolog stacks start small and are dynamically
236 expanded (see <a class="sec" href="limits.html">section 2.20.1</a>). The
237 C stack is also dynamically expanded, but the maximum size is <em>reserved</em>
238 when a thread is started. Using 100 threads at the maximum default C
239 stack of 8Mb (Linux) costs 800Mb virtual memory!<sup class="fn">35<span class="fn-text">C-recursion
277 expanded (see <a class="sec" href="limits.html#sec:2.20.1">section
278 2.20.1</a>). The C stack is also dynamically expanded, but the maximum
279 size is <em>reserved</em> when a thread is started. Using 100 threads at
280 the maximum default C stack of 8Mb (Linux) costs 800Mb virtual memory!<sup class="fn">35<span class="fn-text">C-recursion
240281 over Prolog data structures is removed from most of SWI-Prolog. When
241282 removed from all predicates it will often be possible to use lower
242283 limits in threads. See <a class="url" href="http://www.swi-prolog.org/Devel/CStack.html">http://www.swi-prolog.org/Devel/CStack.html</a></span></sup>
243284
244 <p><a name="idx:IA32:287"></a><a name="idx:AMD64:288"></a>The
245 implications of theoretical performance loss due to increased memory
246 bandwidth implied by exchanging wider pointers depend on the design of
247 the hardware. We only have data for the popular IA32 vs. AMD64
285 <p><a id="idx:IA32:287"></a><a id="idx:AMD64:288"></a>The implications
286 of theoretical performance loss due to increased memory bandwidth
287 implied by exchanging wider pointers depend on the design of the
288 hardware. We only have data for the popular IA32 vs. AMD64
248289 architectures. Here, it appears that the loss is compensated for by an
249290 instruction set that has been optimized for modern programming. In
250291 particular, the AMD64 has more registers and the relative addressing
252293 degradation when placing the SWI-Prolog kernel in a Unix shared object,
253294 we cannot find a measurable difference on AMD64.
254295
255 <p><h3 id="sec:32vs64bitschoice"><a name="sec:2.21.3"><span class="sec-nr">2.21.3</span> <span class="sec-title">Choosing
296 <p><h3 id="sec:32vs64bitschoice"><a id="sec:2.21.3"><span class="sec-nr">2.21.3</span> <span class="sec-title">Choosing
256297 between 32- and 64-bit Prolog</span></a></h3>
257298
258 <a name="sec:32vs64bitschoice"></a>
299 <a id="sec:32vs64bitschoice"></a>
259300
260301 <p>For those cases where we can choose between 32 and 64 bits, either
261302 because the hardware and OS support both or because we can still choose
280321 of 32-bit hardware is 4GB, but in many cases the operating system
281322 provides less to user applications.
282323
283 <p><a name="idx:RDFmemoryusage:289"></a>The only standard SWI-Prolog
324 <p><a id="idx:RDFmemoryusage:289"></a>The only standard SWI-Prolog
284325 library adding significantly to this calculation is the RDF database
285326 provided by the <em>semweb</em> package. It uses approximately 80 bytes
286327 per triple on 32-bit hardware and 150 bytes on 64-bit hardware. Details
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
192233 <a class="nav" href="DocIndex.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194235
195 <h1><a name="sec:G"><span class="sec-nr">G</span> <span class="sec-title">Bibliography</span></a></h1>
236 <h1><a id="sec:G"><span class="sec-nr">G</span> <span class="sec-title">Bibliography</span></a></h1>
196237
197238 <dl class="bib">
198 <dt class="bib"><a name="Bowen:83"><strong>Bowen <em>et al.</em>, 1983</strong></a></dt>
239 <dt class="bib"><a id="Bowen:83"><strong>Bowen <em>et al.</em>, 1983</strong></a></dt>
199240 <dd class="bib">
200241 D.&nbsp;L. Bowen, L.&nbsp;M. Byrd, and WF. Clocksin. A portable Prolog
201242 compiler. In L.&nbsp;M. Pereira, editor, <em>Proceedings of the Logic
202243 Programming Workshop 1983</em>, Lisabon, Portugal, 1983. Universidade
203244 nova de Lisboa.</dd>
204 <dt class="bib"><a name="Bratko:86"><strong>Bratko, 1986</strong></a></dt>
245 <dt class="bib"><a id="Bratko:86"><strong>Bratko, 1986</strong></a></dt>
205246 <dd class="bib">
206247 I.&nbsp;Bratko.
207248 <em>Prolog Programming for Artificial Intelligence</em>. Addison-Wesley,
208249 Reading, Massachusetts, 1986.</dd>
209 <dt class="bib"><a name="Butenhof:1997:PPT"><strong>Butenhof, 1997</strong></a></dt>
250 <dt class="bib"><a id="Butenhof:1997:PPT"><strong>Butenhof, 1997</strong></a></dt>
210251 <dd class="bib">
211252 David&nbsp;R. Butenhof.
212253 <em>Programming with POSIX threads</em>. Ad d i s on-Wes l ey, Reading,
213254 MA, USA, 1997.</dd>
214 <dt class="bib"><a name="Byrd:80"><strong>Byrd, 1980</strong></a></dt>
255 <dt class="bib"><a id="Byrd:80"><strong>Byrd, 1980</strong></a></dt>
215256 <dd class="bib">
216257 L.&nbsp;Byrd. Understanding the control flow of Prolog programs.
217258 <em>Logic Programming Workshop</em>, 1980.</dd>
218 <dt class="bib"><a name="Clocksin:87"><strong>Clocksin &amp; Melish,
219 1987</strong></a></dt>
259 <dt class="bib"><a id="Clocksin:87"><strong>Clocksin &amp; Melish, 1987</strong></a></dt>
220260 <dd class="bib">
221261 W.&nbsp;F. Clocksin and C.&nbsp;S. Melish.
222262 <em>Programming in Prolog</em>. Springer-Verlag, New York, Third, Revised
223263 and Extended edition, 1987.</dd>
224 <dt class="bib"><a name="Demoen:CW350"><strong>Demoen, 2002</strong></a></dt>
264 <dt class="bib"><a id="Demoen:CW350"><strong>Demoen, 2002</strong></a></dt>
225265 <dd class="bib">
226266 Bart Demoen.
227267 Dynamic attributes, their hProlog implementation, and a first
228268 evaluation. Report CW 350, Department of Computer Science, K.U.Leuven,
229269 Leuven, Belgium, oct 2002. URL =
230270 http://www.cs.kuleuven.ac.be/publicaties/rapporten/cw/CW350.abs.html.</dd>
231 <dt class="bib"><a name="DBLP:journals/tplp/DesouterDS15"><strong>Desouter <em>et
271 <dt class="bib"><a id="DBLP:journals/tplp/DesouterDS15"><strong>Desouter <em>et
232272 al.</em>, 2015</strong></a></dt>
233273 <dd class="bib">
234274 Benoit Desouter, Marko van Dooren, and Tom Schrijvers. Tabling as a
235275 library with delimited control.
236276 <em>TPLP</em>, 15(4-5):419--433, 2015.</dd>
237 <dt class="bib"><a name="oai:CiteSeerPSU:36493"><strong>Freire <em>et
238 al.</em>, 1997</strong></a></dt>
277 <dt class="bib"><a id="oai:CiteSeerPSU:36493"><strong>Freire <em>et al.</em>,
278 1997</strong></a></dt>
239279 <dd class="bib">
240280 Juliana Freire, David&nbsp;S. Warren, Konstantinos Sagonas, Prasad Rao,
241281 and Terrance Swift.
242282 XSB: A system for efficiently computing well-founded semantics. In <em>Proceedings
243283 of LPNMR 97</em>, pages 430--440, Berlin, Germany, jan 1997. Springer
244284 Verlag. LNCS 1265.</dd>
245 <dt class="bib"><a name="chrSite"><strong>Fr&uuml;hwirth,</strong></a></dt>
285 <dt class="bib"><a id="chrSite"><strong>Fr&uuml;hwirth,</strong></a></dt>
246286 <dd class="bib">
247287 T.&nbsp;Fr&uuml;hwirth. Thom Fruehwirth's constraint handling rules
248288 website. http://www.constraint-handling-rules.org.</dd>
249 <dt class="bib"><a name="Freuhwirth:2009"><strong>Fr&uuml;hwirth, 2009</strong></a></dt>
289 <dt class="bib"><a id="Freuhwirth:2009"><strong>Fr&uuml;hwirth, 2009</strong></a></dt>
250290 <dd class="bib">
251291 T.&nbsp;Fr&uuml;hwirth.
252292 <em>Constraint Handling Rules</em>. Cambridge University Press, 2009.</dd>
253 <dt class="bib"><a name="graham82gprof"><strong>Graham <em>et al.</em>,
293 <dt class="bib"><a id="graham82gprof"><strong>Graham <em>et al.</em>,
254294 1982</strong></a></dt>
255295 <dd class="bib">
256296 Susan&nbsp;L. Graham, Peter&nbsp;B. Kessler, and Marshall&nbsp;K.
257297 McKusick. gprof: a call graph execution profiler. In <em>SIGPLAN
258298 Symposium on Compiler Construction</em>, pages 120--126, 1982.</dd>
259 <dt class="bib"><a name="stdprolog:98"><strong>Hodgson, 1998</strong></a></dt>
299 <dt class="bib"><a id="stdprolog:98"><strong>Hodgson, 1998</strong></a></dt>
260300 <dd class="bib">
261301 Jonathan Hodgson. validation suite for conformance with part 1 of the
262302 standard, 1998,
263303 <a class="url" href="http://www.sju.edu/~jhodgson/pub/suite.tar.gz">http://www.sju.edu/~jhodgson/pub/suite.tar.gz</a>.</dd>
264 <dt class="bib"><a name="holzbaur:1992"><strong>Holzbaur, 1992</strong></a></dt>
304 <dt class="bib"><a id="holzbaur:1992"><strong>Holzbaur, 1992</strong></a></dt>
265305 <dd class="bib">
266306 Christian Holzbaur. Metastructures versus attributed variables in the
267307 context of extensible unification. In <em>PLILP</em>, volume 631, pages
268308 260--268. Springer-Verlag, 1992. LNCS 631.</dd>
269 <dt class="bib"><a name="Kernighan:78"><strong>Kernighan &amp; Ritchie,
309 <dt class="bib"><a id="Kernighan:78"><strong>Kernighan &amp; Ritchie,
270310 1978</strong></a></dt>
271311 <dd class="bib">
272312 B.&nbsp;W. Kernighan and D.&nbsp;M. Ritchie.
273313 <em>The C Programming Language</em>. Prentice-Hall, Englewood Cliffs,
274314 New Jersey, 1978.</dd>
275 <dt class="bib"><a name="Neumerkel:93"><strong>Neumerkel, 1993</strong></a></dt>
315 <dt class="bib"><a id="Neumerkel:93"><strong>Neumerkel, 1993</strong></a></dt>
276316 <dd class="bib">
277317 Ulrich Neumerkel. The binary WAM, a simplified Prolog engine. Technical
278318 report, Technische Universit&auml;t Wien , 1993.
279319 http://www.complang.tuwien.ac.at/ulrich/papers/PDF/binwam-nov93.pdf.</dd>
280 <dt class="bib"><a name="Keefe:90"><strong>O'Keefe, 1990</strong></a></dt>
320 <dt class="bib"><a id="Keefe:90"><strong>O'Keefe, 1990</strong></a></dt>
281321 <dd class="bib">
282322 R.&nbsp;A. O'Keefe.
283323 <em>The Craft of Prolog</em>. MIT Press, Massachussetts, 1990.</dd>
284 <dt class="bib"><a name="CPROLOG:manual"><strong>Pereira, 1986</strong></a></dt>
324 <dt class="bib"><a id="CPROLOG:manual"><strong>Pereira, 1986</strong></a></dt>
285325 <dd class="bib">
286326 F.&nbsp;Pereira.
287327 <em>C-Prolog User's Manual</em>. EdCaad, University of Edinburgh, 1986.</dd>
288 <dt class="bib"><a name="QUINTUS:manual"><strong>Qui, 1997</strong></a></dt>
328 <dt class="bib"><a id="QUINTUS:manual"><strong>Qui, 1997</strong></a></dt>
289329 <dd class="bib">
290330 AI International ltd., Berkhamsted, UK.
291331 <em>Quintus Prolog, User Guide and Reference Manual</em>, 1997.</dd>
292 <dt class="bib"><a name="logicalloops:2002"><strong>Schimpf, 2002</strong></a></dt>
332 <dt class="bib"><a id="logicalloops:2002"><strong>Schimpf, 2002</strong></a></dt>
293333 <dd class="bib">
294334 Joachim Schimpf. Logical loops. In PeterJ. Stuckey, editor, <em>Logic
295335 Programming</em>, volume 2401 of
296336 <em>Lecture Notes in Computer Science</em>, pages 224--238. Springer
297337 Berlin Heidelberg, 2002.</dd>
298 <dt class="bib"><a name="DBLP:journals/tplp/SchrijversDDW13"><strong>Schrijvers <em>et
338 <dt class="bib"><a id="DBLP:journals/tplp/SchrijversDDW13"><strong>Schrijvers <em>et
299339 al.</em>, 2013</strong></a></dt>
300340 <dd class="bib">
301341 Tom Schrijvers, Bart Demoen, Benoit Desouter, and Jan Wielemaker.
302342 Delimited continuations for prolog.
303343 <em>TPLP</em>, 13(4-5):533--546, 2013.</dd>
304 <dt class="bib"><a name="Sterling:86"><strong>Sterling &amp; Shapiro,
305 1986</strong></a></dt>
344 <dt class="bib"><a id="Sterling:86"><strong>Sterling &amp; Shapiro, 1986</strong></a></dt>
306345 <dd class="bib">
307346 L.&nbsp;Sterling and E.&nbsp;Shapiro.
308347 <em>The Art of Prolog</em>. MIT Press, Cambridge, Massachusetts, 1986.</dd>
309 <dt class="bib"><a name="DBLP:conf/coordination/Tarau11"><strong>Tarau,
348 <dt class="bib"><a id="DBLP:conf/coordination/Tarau11"><strong>Tarau,
310349 2011</strong></a></dt>
311350 <dd class="bib">
312351 Paul Tarau. Coordination and concurrency in multi-engine prolog. In
315354 COORDINATION 2011, Reykjavik, Iceland, June 6-9, 2011. Proceedings</em>,
316355 volume 6721 of <em>Lecture Notes in Computer Science</em>, pages
317356 157--171. Springer, 2011.</dd>
318 <dt class="bib"><a name="clpb:Triska2016"><strong>Triska, 2016</strong></a></dt>
357 <dt class="bib"><a id="clpb:Triska2016"><strong>Triska, 2016</strong></a></dt>
319358 <dd class="bib">
320359 Markus Triska. The Boolean constraint solver of SWI-Prolog: System
321360 description. In <em>FLOPS</em>, volume 9613 of <em>LNCS</em>, pages
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
192233 <a class="nav" href="intro.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194235
195 <h1><a name="document-contents">Table of Contents</a></h1>
236 <h1><a id="document-contents">Table of Contents</a></h1>
196237
197238 <div class="toc">
198239 <div class="toc-h1"><a class="sec" href="intro.html"><span class="sec-nr">1</span> <span class="sec-title">Introduction</span></a></div>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.13</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="signal.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="db.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:DCG"><a name="sec:4.13"><span class="sec-nr">4.13</span> <span class="sec-title">DCG
235 <h2 id="sec:DCG"><a id="sec:4.13"><span class="sec-nr">4.13</span> <span class="sec-title">DCG
195236 Grammar rules</span></a></h2>
196237
197 <a name="sec:DCG"></a>
198
199 <p><a name="idx:DCG:777"></a><a name="idx:serialize:778"></a><a name="idx:deserialize:779"></a>Grammar
238 <a id="sec:DCG"></a>
239
240 <p><a id="idx:DCG:777"></a><a id="idx:serialize:778"></a><a id="idx:deserialize:779"></a>Grammar
200241 rules form a comfortable interface to <em>difference lists</em>. They
201242 are designed both to support writing parsers that build a parse tree
202243 from a list of characters or tokens and for generating a flat list from
204245
205246 <p>Grammar rules look like ordinary clauses using <code><code>--&gt;</code>/2</code>
206247 for separating the head and body rather than <code><code>:-</code>/2</code>.
207 Expanding grammar rules is done by <a name="idx:expandterm2:780"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>,
248 Expanding grammar rules is done by <a id="idx:expandterm2:780"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>,
208249 which adds two additional arguments to each term for representing the
209250 difference list.
210251
239280 }.
240281 </pre>
241282
242 <p>Grammar rule sets are called using the built-in predicates <a name="idx:phrase2:781"></a><a class="pred" href="DCG.html#phrase/2">phrase/2</a>
243 and <a name="idx:phrase3:782"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>:
283 <p>Grammar rule sets are called using the built-in predicates <a id="idx:phrase2:781"></a><a class="pred" href="DCG.html#phrase/2">phrase/2</a>
284 and <a id="idx:phrase3:782"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>:
244285
245286 <dl class="latex">
246 <dt class="pubdef"><a name="phrase/2"><strong>phrase</strong>(<var>:DCGBody,
287 <dt class="pubdef"><a id="phrase/2"><strong>phrase</strong>(<var>:DCGBody,
247288 ?List</var>)</a></dt>
248289 <dd class="defbody">
249290 Equivalent to <code>phrase(<var>DCGBody</var>, <var>InputList</var>, [])</code>.
250291 </dd>
251 <dt class="pubdef"><a name="phrase/3"><strong>phrase</strong>(<var>:DCGBody,
292 <dt class="pubdef"><a id="phrase/3"><strong>phrase</strong>(<var>:DCGBody,
252293 ?List, ?Rest</var>)</a></dt>
253294 <dd class="defbody">
254295 True when <var>DCGBody</var> applies to the difference
257298 <em>callable</em> term that denotes a grammar rule, it can be any term
258299 that is valid as the body of a DCG rule.
259300
260 <p>The example below calls the rule set <a name="idx:integer1:783"></a><span class="pred-ext">integer/3</span>
261 defined in <a class="sec" href="DCG.html">section 4.13</a> and available
262 from <code>library(library(dcg/basics))</code>, binding <var>Rest</var>
301 <p>The example below calls the rule set <a id="idx:integer1:783"></a><span class="pred-ext">integer//1</span>
302 defined in <a class="sec" href="DCG.html#sec:4.13">section 4.13</a> and
303 available from <code>library(library(dcg/basics))</code>, binding <var>Rest</var>
263304 to the remainder of the input after matching the integer.
264305
265306 <pre class="code">
271312 </pre>
272313
273314 <p>The next example exploits a complete body. Given the following
274 definition of digit_weight1, we can pose the query below.
315 definition of digit_weight//1 , we can pose the query below.
275316
276317 <pre class="code">
277318 digit_weight(W) --&gt;
288329 Minor = 4.
289330 </pre>
290331
291 <p>The SWI-Prolog implementation of <a name="idx:phrase3:784"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
332 <p>The SWI-Prolog implementation of <a id="idx:phrase3:784"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
292333 verifies that the <var>List</var> and <var>Rest</var> arguments are
293334 unbound, bound to the empty list or a list
294335 <em>cons cell</em>. Other values raise a type error.<sup class="fn">71<span class="fn-text">The
295336 ISO standard allows for both raising a type error and accepting any term
296337 as input and output. Note the tail of the list is not checked for
297 performance reasons.</span></sup> The predicate <a name="idx:calldcg3:785"></a><a class="pred" href="DCG.html#call_dcg/3">call_dcg/3</a>
338 performance reasons.</span></sup> The predicate <a id="idx:calldcg3:785"></a><a class="pred" href="DCG.html#call_dcg/3">call_dcg/3</a>
298339 is provided to use grammar rules with terms that are not lists.
299340
300341 <p>Note that the syntax for lists of codes changed in SWI-Prolog version&nbsp;7
301 (see <a class="sec" href="strings.html">section 5.2</a>). If a DCG body
302 is translated, both <code>"text"</code> and <code>`text`</code> is a
303 valid code-list literal in version&nbsp;7. A version&nbsp;7 string (<code>"text"</code>)
304 is <b>not</b> acceptable for the second and third arguments of <a name="idx:phrase3:786"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.
342 (see <a class="sec" href="strings.html#sec:5.2">section 5.2</a>). If a
343 DCG body is translated, both <code>"text"</code> and <code>`text`</code>
344 is a valid code-list literal in version&nbsp;7. A version&nbsp;7 string
345 (<code>"text"</code>) is <b>not</b> acceptable for the second and third
346 arguments of <a id="idx:phrase3:786"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.
305347 This is typically not a problem for applications as the input of a DCG
306348 rarely appears in the source code. For testing in the toplevel, one must
307349 use double quoted text in versions prior to&nbsp;7 and back quoted text
308350 in version&nbsp;7 or later.
309351
310 <p>See also <a name="idx:portraytext1:787"></a><span class="pred-ext">portray_text/1</span>,
352 <p>See also <a id="idx:portraytext1:787"></a><span class="pred-ext">portray_text/1</span>,
311353 which can be used to print lists of character codes as a string to the
312354 top level and debugger to facilitate debugging DCGs that process
313 character codes. The library <code>library(apply_macros)</code> compiles <a name="idx:phrase3:788"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
355 character codes. The library <code>library(apply_macros)</code> compiles <a id="idx:phrase3:788"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
314356 if the argument is sufficiently instantiated, eliminating the runtime
315357 overhead of translating <var>DCGBody</var> and meta-calling.</dd>
316 <dt class="pubdef"><a name="call_dcg/3"><strong>call_dcg</strong>(<var>:DCGBody,
358 <dt class="pubdef"><a id="call_dcg/3"><strong>call_dcg</strong>(<var>:DCGBody,
317359 ?State0, ?State</var>)</a></dt>
318360 <dd class="defbody">
319 As <a name="idx:phrase3:789"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>,
361 As <a id="idx:phrase3:789"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>,
320362 but without type checking <var>State0</var> and <var>State</var>. This
321363 allows for using DCG rules for threading an arbitrary state variable.
322364 This predicate was introduced after type checking was added to
323 <a name="idx:phrase3:790"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.<sup class="fn">72<span class="fn-text">After
365 <a id="idx:phrase3:790"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.<sup class="fn">72<span class="fn-text">After
324366 discussion with Samer Abdallah.</span></sup>
325367
326368 <p>A portable solution for threading state through a DCG can be
339381
340382 <p>As stated above, grammar rules are a general interface to difference
341383 lists. To illustrate, we show a DCG-based implementation of
342 <a name="idx:reverse2:791"></a><a class="pred" href="lists.html#reverse/2">reverse/2</a>:
384 <a id="idx:reverse2:791"></a><a class="pred" href="lists.html#reverse/2">reverse/2</a>:
343385
344386 <pre class="code">
345387 reverse(List, Reversed) :-
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.43</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.43</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="memory.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="miscpreds.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:DDE"><a name="sec:4.43"><span class="sec-nr">4.43</span> <span class="sec-title">Windows
235 <h2 id="sec:DDE"><a id="sec:4.43"><span class="sec-nr">4.43</span> <span class="sec-title">Windows
195236 DDE interface</span></a></h2>
196237
197 <a name="sec:DDE"></a>
238 <a id="sec:DDE"></a>
198239
199240 <p>The predicates in this section deal with MS-Windows `Dynamic Data
200241 Exchange' or DDE protocol.<sup class="fn">141<span class="fn-text">This
212253 error(dde_error(Operation, Message), Context)
213254 </pre>
214255
215 <p><h3 id="sec:dde-client"><a name="sec:4.43.1"><span class="sec-nr">4.43.1</span> <span class="sec-title">DDE
256 <p><h3 id="sec:dde-client"><a id="sec:4.43.1"><span class="sec-nr">4.43.1</span> <span class="sec-title">DDE
216257 client interface</span></a></h3>
217258
218 <a name="sec:dde-client"></a>
259 <a id="sec:dde-client"></a>
219260
220261 <p>The DDE client interface allows Prolog to talk to DDE server
221262 programs. We will demonstrate the use of the DDE interface using the
242283 setup scripts in Prolog.
243284
244285 <dl class="latex">
245 <dt class="pubdef"><a name="open_dde_conversation/3"><strong>open_dde_conversation</strong>(<var>+Service,
286 <dt class="pubdef"><a id="open_dde_conversation/3"><strong>open_dde_conversation</strong>(<var>+Service,
246287 +Topic, -Handle</var>)</a></dt>
247288 <dd class="defbody">
248289 Open a conversation with a server supporting the given service name and
249290 topic (atoms). If successful, <var>Handle</var> may be used to send
250291 transactions to the server. If no willing server is found this predicate
251292 fails silently.</dd>
252 <dt class="pubdef"><a name="close_dde_conversation/1"><strong>close_dde_conversation</strong>(<var>+Handle</var>)</a></dt>
293 <dt class="pubdef"><a id="close_dde_conversation/1"><strong>close_dde_conversation</strong>(<var>+Handle</var>)</a></dt>
253294 <dd class="defbody">
254295 Close the conversation associated with <var>Handle</var>. All opened
255296 conversations should be closed when they're no longer needed, although
256297 the system will close any that remain open on process termination.</dd>
257 <dt class="pubdef"><a name="dde_request/3"><strong>dde_request</strong>(<var>+Handle,
298 <dt class="pubdef"><a id="dde_request/3"><strong>dde_request</strong>(<var>+Handle,
258299 +Item, -Value</var>)</a></dt>
259300 <dd class="defbody">
260301 Request a value from the server. <var>Item</var> is an atom that
261302 identifies the requested data, and <var>Value</var> will be a string (<code>CF_TEXT</code>
262303 data in DDE parlance) representing that data, if the request is
263304 successful.</dd>
264 <dt class="pubdef"><a name="dde_execute/2"><strong>dde_execute</strong>(<var>+Handle,
305 <dt class="pubdef"><a id="dde_execute/2"><strong>dde_execute</strong>(<var>+Handle,
265306 +Command</var>)</a></dt>
266307 <dd class="defbody">
267308 Request the DDE server to execute the given command string. Succeeds if
268309 the command could be executed and fails with an error message otherwise.</dd>
269 <dt class="pubdef"><a name="dde_poke/4"><strong>dde_poke</strong>(<var>+Handle,
310 <dt class="pubdef"><a id="dde_poke/4"><strong>dde_poke</strong>(<var>+Handle,
270311 +Item, +Command</var>)</a></dt>
271312 <dd class="defbody">
272313 Issue a <code>POKE</code> command to the server on the specified <var>Item</var>.
274315 </dd>
275316 </dl>
276317
277 <p><h3 id="sec:dde-server"><a name="sec:4.43.2"><span class="sec-nr">4.43.2</span> <span class="sec-title">DDE
318 <p><h3 id="sec:dde-server"><a id="sec:4.43.2"><span class="sec-nr">4.43.2</span> <span class="sec-title">DDE
278319 server mode</span></a></h3>
279320
280 <a name="sec:dde-server"></a>
321 <a id="sec:dde-server"></a>
281322
282323 <p>The <code>library(dde)</code> defines primitives to realise simple
283324 DDE server applications in SWI-Prolog. These features are provided as of
286327 provided by this interface, please study <code>library(dde)</code>.
287328
288329 <dl class="latex">
289 <dt class="pubdef"><a name="dde_register_service/2"><strong>dde_register_service</strong>(<var>+Template,
330 <dt class="pubdef"><a id="dde_register_service/2"><strong>dde_register_service</strong>(<var>+Template,
290331 +Goal</var>)</a></dt>
291332 <dd class="defbody">
292333 Register a server to handle DDE request or DDE <code>execute</code>
303344 to version 3.4.5 this was a list of character codes. As recent versions
304345 have atom garbage collection there is no need for this anymore.</span></sup>
305346
306 <p>The example below registers the Prolog <a name="idx:currentprologflag2:1585"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
347 <p>The example below registers the Prolog <a id="idx:currentprologflag2:1585"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
307348 predicate to be accessible from other applications. The request may be
308349 given from the same Prolog as well as from another application.
309350
327368 requests either succeed or fail. If <var>Goal</var> fails, a `not
328369 processed' is passed back to the caller of the DDE request.
329370 </dd>
330 <dt class="pubdef"><a name="dde_unregister_service/1"><strong>dde_unregister_service</strong>(<var>+Service</var>)</a></dt>
371 <dt class="pubdef"><a id="dde_unregister_service/1"><strong>dde_unregister_service</strong>(<var>+Service</var>)</a></dt>
331372 <dd class="defbody">
332373 Stop responding to <var>Service</var>. If Prolog is halted, it will
333374 automatically call this on all open services.
334375 </dd>
335 <dt class="pubdef"><a name="dde_current_service/2"><strong>dde_current_service</strong>(<var>-Service,
376 <dt class="pubdef"><a id="dde_current_service/2"><strong>dde_current_service</strong>(<var>-Service,
336377 -Topic</var>)</a></dt>
337378 <dd class="defbody">
338379 Find currently registered services and the topics served on them.
339380 </dd>
340 <dt class="pubdef"><a name="dde_current_connection/2"><strong>dde_current_connection</strong>(<var>-Service,
381 <dt class="pubdef"><a id="dde_current_connection/2"><strong>dde_current_connection</strong>(<var>-Service,
341382 -Topic</var>)</a></dt>
342383 <dd class="defbody">
343384 Find currently open conversations.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1616 { margin-bottom: 1em;
1717 }
1818
19 dt.pubdef
20 { background-color: #c5e1ff;
19 dt.pubdef, dt.multidef
20 { color: #fff;
21 padding: 2px 10px 0px 10px;
22 margin-bottom: 5px;
23 font-size: 18px;
24 vertical-align: middle;
25 overflow: hidden;
2126 }
2227
23 dt.multidef
24 { background-color: #c8ffc7;
25 }
28 dt.pubdef { background-color: #0c3d6e; }
29 dt.multidef { background-color: #ef9439; }
2630
2731 .bib dd
2832 { margin-bottom: 1em;
116120 padding-top: 0.2em;
117121 font-size: 80%;
118122 font-style: italic;
119 color: #202020;
123 color: #fff;
120124 }
121125
122126 div.caption
126130 }
127131
128132 /* Footnotes */
129
130 sup.fn { color: blue; text-decoration: underline; }
131 span.fn-text { display: none; }
132 sup.fn span {display: none;}
133 sup:hover span
134 { display: block !important;
135 position: absolute; top: auto; left: auto; width: 80%;
136 color: #000; background: white;
137 border: 2px solid;
138 padding: 5px; margin: 10px; z-index: 100;
139 font-size: smaller;
133 .fn {
134 color: red;
135 font-size: 70%;
136 }
137
138 .fn-text, .fnp {
139 position: absolute;
140 top: auto;
141 left: 10%;
142 border: 1px solid #000;
143 box-shadow: 5px 5px 5px #888;
144 display: none;
145 background: #fff;
146 color: #000;
147 margin-top: 25px;
148 padding: 8px 12px;
149 font-size: larger;
150 }
151
152 sup:hover span.fn-text
153 { display: block;
140154 }
141155
142156 /* Lists */
180194 font-size: +1;
181195 margin-top: 1ex;
182196 }
197
198 /* Tables */
199
200 table.center
201 { margin: auto;
202 }
203
204 table.latex
205 { border-collapse:collapse;
206 }
207
208 table.latex tr
209 { vertical-align: text-top;
210 }
211
212 table.latex td,th
213 { padding: 2px 1em;
214 }
215
216 table.latex tr.hline td,th
217 { border-top: 1px solid black;
218 }
219
220 table.frame-box
221 { border: 2px solid black;
222 }
223
183224 </style>
184225 </head>
185226 <body style="background:white">
190231 <a class="nav" href="Bibliography.html"><img src="prev.gif" alt="Previous"></a>
191232 </div>
192233
193 <h1><a name="document-index">Index</a></h1>
234 <h1><a id="document-index">Index</a></h1>
194235
195236 <dl>
196237 <dt class="index-sep">?</dt>
216257 <dt><a class="idx" href="tabling.html#abolish_table_subgoals/1">abolish_table_subgoals/1</a></dt>
217258 <dt><a class="idx" href="toplevel.html#abort/0">abort/0</a></dt>
218259 <dd>
219 <a class="idx" href="cmdline.html#idx:abort0:45">2.4.4</a> <a class="idx" href="debugoverview.html#idx:abort0:66">2.9</a> <a class="idx" href="exception.html#idx:abort0:710">4.11</a> <a class="idx" href="exception.html#idx:abort0:712">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:717">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:720">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:721">4.11.1</a> <a class="idx" href="IO.html#idx:abort0:976">4.17.2</a> <a class="idx" href="IO.html#idx:abort0:984">4.17.2</a> <a class="idx" href="IO.html#idx:abort0:1018">4.17.2</a> <a class="idx" href="debugging.html#idx:abort0:1817">8.4.2</a> <a class="idx" href="foreigninclude.html#idx:abort0:2064">11.4.16</a> <a class="idx" href="foreigninclude.html#idx:abort0:2068">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:abort0:2069">11.4.19</a> <a class="idx" href="tracehook.html#idx:abort0:2194">B.3</a></dd>
260 <a class="idx" href="cmdline.html#idx:abort0:45">2.4.4</a> <a class="idx" href="debugoverview.html#idx:abort0:66">2.9</a> <a class="idx" href="exception.html#idx:abort0:710">4.11</a> <a class="idx" href="exception.html#idx:abort0:712">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:717">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:720">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:721">4.11.1</a> <a class="idx" href="IO.html#idx:abort0:976">4.17.2</a> <a class="idx" href="IO.html#idx:abort0:984">4.17.2</a> <a class="idx" href="IO.html#idx:abort0:1018">4.17.2</a> <a class="idx" href="debugging.html#idx:abort0:1821">8.4.2</a> <a class="idx" href="foreigninclude.html#idx:abort0:2068">11.4.16</a> <a class="idx" href="foreigninclude.html#idx:abort0:2072">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:abort0:2073">11.4.19</a> <a class="idx" href="tracehook.html#idx:abort0:2198">B.3</a></dd>
220261 <dt><a class="idx" href="files.html#absolute_file_name/2">absolute_file_name/2</a></dt>
221262 <dd>
222 <a class="idx" href="acknowledge.html#idx:absolutefilename2:5">1.6</a> <a class="idx" href="consulting.html#idx:absolutefilename2:397">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename2:473">4.3</a> <a class="idx" href="files.html#idx:absolutefilename2:1513">4.36</a> <a class="idx" href="files.html#idx:absolutefilename2:1519">4.36</a> <a class="idx" href="useresource.html#idx:absolutefilename2:2124">12.3.1</a></dd>
263 <a class="idx" href="acknowledge.html#idx:absolutefilename2:5">1.6</a> <a class="idx" href="consulting.html#idx:absolutefilename2:397">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename2:473">4.3</a> <a class="idx" href="files.html#idx:absolutefilename2:1513">4.36</a> <a class="idx" href="files.html#idx:absolutefilename2:1519">4.36</a> <a class="idx" href="useresource.html#idx:absolutefilename2:2128">12.3.1</a></dd>
223264 <dt><a class="idx" href="files.html#absolute_file_name/3">absolute_file_name/3</a></dt>
224265 <dd>
225 <a class="idx" href="flags.html#idx:absolutefilename3:113">2.11</a> <a class="idx" href="flags.html#idx:absolutefilename3:134">2.11</a> <a class="idx" href="hooks.html#idx:absolutefilename3:171">2.12</a> <a class="idx" href="hooks.html#idx:absolutefilename3:172">2.12</a> <a class="idx" href="packs.html#idx:absolutefilename3:208">2.14</a> <a class="idx" href="xref.html#idx:absolutefilename3:324">3.7</a> <a class="idx" href="consulting.html#idx:absolutefilename3:363">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:365">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:464">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:469">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:495">4.3</a> <a class="idx" href="system.html#idx:absolutefilename3:1474">4.35.1</a> <a class="idx" href="files.html#idx:absolutefilename3:1504">4.36</a> <a class="idx" href="files.html#idx:absolutefilename3:1506">4.36</a> <a class="idx" href="foreigninclude.html#idx:absolutefilename3:2055">11.4.14.3</a> <a class="idx" href="foreigninclude.html#idx:absolutefilename3:2056">11.4.14.3</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2158">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2159">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2162">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2163">A.30</a></dd>
266 <a class="idx" href="flags.html#idx:absolutefilename3:113">2.11</a> <a class="idx" href="flags.html#idx:absolutefilename3:134">2.11</a> <a class="idx" href="hooks.html#idx:absolutefilename3:171">2.12</a> <a class="idx" href="hooks.html#idx:absolutefilename3:172">2.12</a> <a class="idx" href="packs.html#idx:absolutefilename3:208">2.14</a> <a class="idx" href="xref.html#idx:absolutefilename3:324">3.7</a> <a class="idx" href="consulting.html#idx:absolutefilename3:363">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:365">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:464">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:469">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:495">4.3</a> <a class="idx" href="system.html#idx:absolutefilename3:1474">4.35.1</a> <a class="idx" href="files.html#idx:absolutefilename3:1504">4.36</a> <a class="idx" href="files.html#idx:absolutefilename3:1506">4.36</a> <a class="idx" href="foreigninclude.html#idx:absolutefilename3:2059">11.4.14.3</a> <a class="idx" href="foreigninclude.html#idx:absolutefilename3:2060">11.4.14.3</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2162">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2163">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2166">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2167">A.30</a></dd>
226267 <dt>absolute_file_name/[2,3]</dt>
227268 <dd>
228269 <a class="idx" href="flags.html#idx:absolutefilename23:155">2.11</a> <a class="idx" href="consulting.html#idx:absolutefilename23:468">4.3</a> <a class="idx" href="files.html#idx:absolutefilename23:1508">4.36</a></dd>
236277 <dt><a class="idx" href="ugraphs.html#add_edges/3">add_edges/3</a></dt>
237278 <dt><a class="idx" href="importmodule.html#add_import_module/3">add_import_module/3</a></dt>
238279 <dd>
239 <a class="idx" href="importmodule.html#idx:addimportmodule3:1719">6.9</a> <a class="idx" href="modulecompat.html#idx:addimportmodule3:1757">6.15</a></dd>
280 <a class="idx" href="importmodule.html#idx:addimportmodule3:1723">6.9</a> <a class="idx" href="modulecompat.html#idx:addimportmodule3:1761">6.15</a></dd>
240281 <dt><a class="idx" href="nb_set.html#add_nb_set/2">add_nb_set/2</a></dt>
241282 <dt><a class="idx" href="nb_set.html#add_nb_set/3">add_nb_set/3</a></dt>
242283 <dd>
243 <a class="idx" href="nb_set.html#idx:addnbset3:2146">A.17</a> <a class="idx" href="nb_set.html#idx:addnbset3:2147">A.17</a></dd>
284 <a class="idx" href="nb_set.html#idx:addnbset3:2150">A.17</a> <a class="idx" href="nb_set.html#idx:addnbset3:2151">A.17</a></dd>
244285 <dt><a class="idx" href="ugraphs.html#add_vertices/3">add_vertices/3</a></dt>
245286 <dt>agent</dt>
246287 <dd>
247 <a class="idx" href="broadcast.html#idx:agent:2135">A.4</a></dd>
288 <a class="idx" href="broadcast.html#idx:agent:2139">A.4</a></dd>
248289 <dt><a class="idx" href="aggregate.html#aggregate/3">aggregate/3</a></dt>
249290 <dd>
250 <a class="idx" href="db.html#idx:aggregate3:793">4.14</a> <a class="idx" href="metapred.html#idx:aggregate3:1695">6.4</a></dd>
291 <a class="idx" href="db.html#idx:aggregate3:793">4.14</a> <a class="idx" href="metapred.html#idx:aggregate3:1699">6.4</a></dd>
251292 <dt><a class="idx" href="aggregate.html#aggregate/4">aggregate/4</a></dt>
252293 <dd>
253 <a class="idx" href="metapred.html#idx:aggregate4:1696">6.4</a></dd>
294 <a class="idx" href="metapred.html#idx:aggregate4:1700">6.4</a></dd>
254295 <dt><a class="idx" href="aggregate.html#aggregate_all/3">aggregate_all/3</a></dt>
255296 <dd>
256297 <a class="idx" href="db.html#idx:aggregateall3:813">4.14</a></dd>
259300 <dt><a class="idx" href="clpfd.html#all_distinct/1">all_distinct/1</a></dt>
260301 <dt>anonymous variable</dt>
261302 <dd>
262 <a class="idx" href="glossary.html#idx:anonymousvariable:2266">D</a></dd>
303 <a class="idx" href="glossary.html#idx:anonymousvariable:2270">D</a></dd>
263304 <dt>anonymous,variable</dt>
264305 <dd>
265306 <a class="idx" href="syntax.html#idx:anonymousvariable:223">2.16.1.9</a></dd>
268309 <a class="idx" href="exception.html#idx:ansiformat3:760">4.11.4</a></dd>
269310 <dt>answer subsumption,tabling</dt>
270311 <dd>
271 <a class="idx" href="tabling.html#idx:answersubsumptiontabling:2174">A.35.3</a></dd>
312 <a class="idx" href="tabling.html#idx:answersubsumptiontabling:2178">A.35.3</a></dd>
272313 <dt><a class="idx" href="IO.html#append/1">append/1</a></dt>
273314 <dd>
274315 <a class="idx" href="IO.html#idx:append1:1033">4.17.3</a></dd>
275316 <dt><a class="idx" href="lists.html#append/2">append/2</a></dt>
276317 <dd>
277 <a class="idx" href="import.html#idx:append2:1678">6.3</a></dd>
318 <a class="idx" href="import.html#idx:append2:1682">6.3</a></dd>
278319 <dt><a class="idx" href="lists.html#append/3">append/3</a></dt>
279320 <dd>
280321 <a class="idx" href="examineprog.html#idx:append3:939">4.16</a> <a class="idx" href="manipatom.html#idx:append3:1273">4.22</a></dd>
281322 <dt><a class="idx" href="metacall.html#apply/2">apply/2</a></dt>
282323 <dt><a class="idx" href="help.html#apropos/1">apropos/1</a></dt>
283324 <dd>
284 <a class="idx" href="help.html#idx:apropos1:49">2.6</a> <a class="idx" href="help.html#idx:apropos1:50">2.6</a> <a class="idx" href="hooks.html#idx:apropos1:188">2.12</a> <a class="idx" href="intlibs.html#idx:apropos1:2235">B.7</a> <a class="idx" href="predsummary.html#idx:apropos1:2345">F.1</a></dd>
325 <a class="idx" href="help.html#idx:apropos1:49">2.6</a> <a class="idx" href="help.html#idx:apropos1:50">2.6</a> <a class="idx" href="hooks.html#idx:apropos1:188">2.12</a> <a class="idx" href="intlibs.html#idx:apropos1:2239">B.7</a> <a class="idx" href="predsummary.html#idx:apropos1:2349">F.1</a></dd>
285326 <dt><a class="idx" href="manipterm.html#arg/3">arg/3</a></dt>
286327 <dd>
287328 <a class="idx" href="manipterm.html#idx:arg3:1192">4.21</a></dd>
288329 <dt><a class="idx" href="main.html#argv_options/3">argv_options/3</a></dt>
289330 <dt>arithmetic_function/1</dt>
290331 <dd>
291 <a class="idx" href="foreigninclude.html#idx:arithmeticfunction1:2047">11.4.12</a></dd>
332 <a class="idx" href="foreigninclude.html#idx:arithmeticfunction1:2051">11.4.12</a></dd>
292333 <dt>arity</dt>
293334 <dd>
294 <a class="idx" href="glossary.html#idx:arity:2268">D</a></dd>
335 <a class="idx" href="glossary.html#idx:arity:2272">D</a></dd>
295336 <dt>assert</dt>
296337 <dd>
297 <a class="idx" href="glossary.html#idx:assert:2269">D</a></dd>
338 <a class="idx" href="glossary.html#idx:assert:2273">D</a></dd>
298339 <dt><a class="idx" href="db.html#assert/1">assert/1</a></dt>
299340 <dd>
300 <a class="idx" href="consulting.html#idx:assert1:371">4.3</a> <a class="idx" href="db.html#idx:assert1:831">4.14.1</a> <a class="idx" href="db.html#idx:assert1:837">4.14.1</a> <a class="idx" href="db.html#idx:assert1:862">4.14.5</a> <a class="idx" href="dynamic.html#idx:assert1:880">4.15</a> <a class="idx" href="dynamic.html#idx:assert1:885">4.15</a> <a class="idx" href="dynamic.html#idx:assert1:886">4.15</a> <a class="idx" href="examineprog.html#idx:assert1:913">4.16</a> <a class="idx" href="gvar.html#idx:assert1:1411">4.33</a> <a class="idx" href="modules.html#idx:assert1:1659">6</a> <a class="idx" href="metapred.html#idx:assert1:1686">6.4</a> <a class="idx" href="threadcom.html#idx:assert1:1917">9.3.3</a></dd>
341 <a class="idx" href="consulting.html#idx:assert1:371">4.3</a> <a class="idx" href="db.html#idx:assert1:831">4.14.1</a> <a class="idx" href="db.html#idx:assert1:837">4.14.1</a> <a class="idx" href="db.html#idx:assert1:862">4.14.5</a> <a class="idx" href="dynamic.html#idx:assert1:880">4.15</a> <a class="idx" href="dynamic.html#idx:assert1:885">4.15</a> <a class="idx" href="dynamic.html#idx:assert1:886">4.15</a> <a class="idx" href="examineprog.html#idx:assert1:913">4.16</a> <a class="idx" href="gvar.html#idx:assert1:1411">4.33</a> <a class="idx" href="modules.html#idx:assert1:1663">6</a> <a class="idx" href="metapred.html#idx:assert1:1690">6.4</a> <a class="idx" href="threadcom.html#idx:assert1:1921">9.3.3</a></dd>
301342 <dt><a class="idx" href="db.html#assert/2">assert/2</a></dt>
302343 <dd>
303344 <a class="idx" href="flags.html#idx:assert2:99">2.11</a> <a class="idx" href="db.html#idx:assert2:849">4.14.2</a> <a class="idx" href="examineprog.html#idx:assert2:937">4.16</a></dd>
304345 <dt><a class="idx" href="predicate_options.html#assert_predicate_options/4">assert_predicate_options/4</a></dt>
305346 <dt><a class="idx" href="db.html#asserta/1">asserta/1</a></dt>
306347 <dd>
307 <a class="idx" href="cmdline.html#idx:asserta1:37">2.4.2</a> <a class="idx" href="cyclic.html#idx:asserta1:254">2.17</a> <a class="idx" href="jitindex.html#idx:asserta1:256">2.18</a> <a class="idx" href="consulting.html#idx:asserta1:461">4.3</a> <a class="idx" href="compare.html#idx:asserta1:636">4.7.2</a> <a class="idx" href="db.html#idx:asserta1:794">4.14</a> <a class="idx" href="db.html#idx:asserta1:829">4.14.1</a> <a class="idx" href="db.html#idx:asserta1:834">4.14.1</a> <a class="idx" href="db.html#idx:asserta1:835">4.14.1</a> <a class="idx" href="overrule.html#idx:asserta1:1702">6.5</a> <a class="idx" href="overrule.html#idx:asserta1:1704">6.5.1</a> <a class="idx" href="glossary.html#idx:asserta1:2270">D</a></dd>
348 <a class="idx" href="cmdline.html#idx:asserta1:37">2.4.2</a> <a class="idx" href="cyclic.html#idx:asserta1:254">2.17</a> <a class="idx" href="jitindex.html#idx:asserta1:256">2.18</a> <a class="idx" href="consulting.html#idx:asserta1:461">4.3</a> <a class="idx" href="compare.html#idx:asserta1:636">4.7.2</a> <a class="idx" href="db.html#idx:asserta1:794">4.14</a> <a class="idx" href="db.html#idx:asserta1:829">4.14.1</a> <a class="idx" href="db.html#idx:asserta1:834">4.14.1</a> <a class="idx" href="db.html#idx:asserta1:835">4.14.1</a> <a class="idx" href="overrule.html#idx:asserta1:1706">6.5</a> <a class="idx" href="overrule.html#idx:asserta1:1708">6.5.1</a> <a class="idx" href="glossary.html#idx:asserta1:2274">D</a></dd>
308349 <dt><a class="idx" href="db.html#asserta/2">asserta/2</a></dt>
309350 <dd>
310351 <a class="idx" href="db.html#idx:asserta2:850">4.14.2</a></dd>
311352 <dt><a class="idx" href="debug.html#assertion/1">assertion/1</a></dt>
312353 <dd>
313 <a class="idx" href="breakpoint.html#idx:assertion1:2203">B.4</a></dd>
354 <a class="idx" href="breakpoint.html#idx:assertion1:2207">B.4</a></dd>
314355 <dt><a class="idx" href="db.html#assertz/1">assertz/1</a></dt>
315356 <dd>
316 <a class="idx" href="quickstart.html#idx:assertz1:8">2.1.2</a> <a class="idx" href="consulting.html#idx:assertz1:460">4.3</a> <a class="idx" href="db.html#idx:assertz1:795">4.14</a> <a class="idx" href="db.html#idx:assertz1:822">4.14.1</a> <a class="idx" href="db.html#idx:assertz1:830">4.14.1</a> <a class="idx" href="db.html#idx:assertz1:832">4.14.1</a> <a class="idx" href="db.html#idx:assertz1:836">4.14.1</a> <a class="idx" href="examineprog.html#idx:assertz1:927">4.16</a> <a class="idx" href="examineprog.html#idx:assertz1:944">4.16</a> <a class="idx" href="manipmodule.html#idx:assertz1:1750">6.14</a> <a class="idx" href="clp.html#idx:assertz1:1766">7</a> <a class="idx" href="engine-examples.html#idx:assertz1:1971">10.1.2</a> <a class="idx" href="glossary.html#idx:assertz1:2271">D</a></dd>
357 <a class="idx" href="quickstart.html#idx:assertz1:8">2.1.2</a> <a class="idx" href="consulting.html#idx:assertz1:460">4.3</a> <a class="idx" href="db.html#idx:assertz1:795">4.14</a> <a class="idx" href="db.html#idx:assertz1:822">4.14.1</a> <a class="idx" href="db.html#idx:assertz1:830">4.14.1</a> <a class="idx" href="db.html#idx:assertz1:832">4.14.1</a> <a class="idx" href="db.html#idx:assertz1:836">4.14.1</a> <a class="idx" href="examineprog.html#idx:assertz1:927">4.16</a> <a class="idx" href="examineprog.html#idx:assertz1:944">4.16</a> <a class="idx" href="manipmodule.html#idx:assertz1:1754">6.14</a> <a class="idx" href="clp.html#idx:assertz1:1770">7</a> <a class="idx" href="engine-examples.html#idx:assertz1:1975">10.1.2</a> <a class="idx" href="glossary.html#idx:assertz1:2275">D</a></dd>
317358 <dt><a class="idx" href="db.html#assertz/2">assertz/2</a></dt>
318359 <dd>
319360 <a class="idx" href="db.html#idx:assertz2:851">4.14.2</a></dd>
327368 <a class="idx" href="chario.html#idx:atendofstream1:1107">4.19</a></dd>
328369 <dt>at_end_of_stream/[0,1]</dt>
329370 <dd>
330 <a class="idx" href="IO.html#idx:atendofstream01:985">4.17.2</a> <a class="idx" href="readutil.html#idx:atendofstream01:2155">A.30</a></dd>
371 <a class="idx" href="IO.html#idx:atendofstream01:985">4.17.2</a> <a class="idx" href="readutil.html#idx:atendofstream01:2159">A.30</a></dd>
331372 <dt><a class="idx" href="consulting.html#at_halt/1">at_halt/1</a></dt>
332373 <dd>
333 <a class="idx" href="flags.html#idx:athalt1:108">2.11</a> <a class="idx" href="consulting.html#idx:athalt1:501">4.3</a> <a class="idx" href="toplevel.html#idx:athalt1:1530">4.37</a> <a class="idx" href="threadcreate.html#idx:athalt1:1865">9.1</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2070">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2071">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2072">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2083">11.4.21</a> <a class="idx" href="predsummary.html#idx:athalt1:2352">F.1</a></dd>
374 <a class="idx" href="flags.html#idx:athalt1:108">2.11</a> <a class="idx" href="consulting.html#idx:athalt1:501">4.3</a> <a class="idx" href="toplevel.html#idx:athalt1:1530">4.37</a> <a class="idx" href="threadcreate.html#idx:athalt1:1869">9.1</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2074">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2075">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2076">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2087">11.4.21</a> <a class="idx" href="predsummary.html#idx:athalt1:2356">F.1</a></dd>
334375 <dt>atom</dt>
335376 <dd>
336 <a class="idx" href="glossary.html#idx:atom:2272">D</a></dd>
377 <a class="idx" href="glossary.html#idx:atom:2276">D</a></dd>
337378 <dt><a class="idx" href="typetest.html#atom/1">atom/1</a></dt>
338379 <dd>
339 <a class="idx" href="typetest.html#idx:atom1:604">4.6</a> <a class="idx" href="coroutining.html#idx:atom1:1795">7.2</a> <a class="idx" href="foreigninclude.html#idx:atom1:2016">11.4.3</a></dd>
380 <a class="idx" href="typetest.html#idx:atom1:604">4.6</a> <a class="idx" href="coroutining.html#idx:atom1:1799">7.2</a> <a class="idx" href="foreigninclude.html#idx:atom1:2020">11.4.3</a></dd>
340381 <dt><a class="idx" href="manipatom.html#atom_chars/2">atom_chars/2</a></dt>
341382 <dd>
342 <a class="idx" href="chars.html#idx:atomchars2:345">4.2</a> <a class="idx" href="IO.html#idx:atomchars2:1059">4.17.5</a> <a class="idx" href="chario.html#idx:atomchars2:1084">4.19</a> <a class="idx" href="manipatom.html#idx:atomchars2:1246">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1247">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1249">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1251">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1253">4.22</a> <a class="idx" href="chartype.html#idx:atomchars2:1298">4.24</a> <a class="idx" href="ext-issues.html#idx:atomchars2:1656">5.6</a></dd>
383 <a class="idx" href="chars.html#idx:atomchars2:345">4.2</a> <a class="idx" href="IO.html#idx:atomchars2:1059">4.17.5</a> <a class="idx" href="chario.html#idx:atomchars2:1084">4.19</a> <a class="idx" href="manipatom.html#idx:atomchars2:1246">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1247">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1249">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1251">4.22</a> <a class="idx" href="manipatom.html#idx:atomchars2:1253">4.22</a> <a class="idx" href="chartype.html#idx:atomchars2:1298">4.24</a> <a class="idx" href="ext-issues.html#idx:atomchars2:1660">5.6</a></dd>
343384 <dt><a class="idx" href="manipatom.html#atom_codes/2">atom_codes/2</a></dt>
344385 <dd>
345 <a class="idx" href="chars.html#idx:atomcodes2:343">4.2</a> <a class="idx" href="chars.html#idx:atomcodes2:346">4.2</a> <a class="idx" href="IO.html#idx:atomcodes2:1058">4.17.5</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1240">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1243">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1248">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1250">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1252">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1257">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1263">4.22</a> <a class="idx" href="chartype.html#idx:atomcodes2:1299">4.24</a> <a class="idx" href="ext-issues.html#idx:atomcodes2:1655">5.6</a></dd>
386 <a class="idx" href="chars.html#idx:atomcodes2:343">4.2</a> <a class="idx" href="chars.html#idx:atomcodes2:346">4.2</a> <a class="idx" href="IO.html#idx:atomcodes2:1058">4.17.5</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1240">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1243">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1248">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1250">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1252">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1257">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1263">4.22</a> <a class="idx" href="chartype.html#idx:atomcodes2:1299">4.24</a> <a class="idx" href="ext-issues.html#idx:atomcodes2:1659">5.6</a></dd>
346387 <dt><a class="idx" href="manipatom.html#atom_concat/3">atom_concat/3</a></dt>
347388 <dd>
348389 <a class="idx" href="strings.html#idx:atomconcat3:1602">5.2.1</a></dd>
355396 <dt><a class="idx" href="manipatom.html#atom_prefix/2">atom_prefix/2</a></dt>
356397 <dt>atom_result/2</dt>
357398 <dd>
358 <a class="idx" href="ctxmodule.html#idx:atomresult2:1741">6.13</a></dd>
399 <a class="idx" href="ctxmodule.html#idx:atomresult2:1745">6.13</a></dd>
359400 <dt><a class="idx" href="strings.html#atom_string/2">atom_string/2</a></dt>
360401 <dt><a class="idx" href="charsio.html#atom_to_chars/2">atom_to_chars/2</a></dt>
361402 <dt><a class="idx" href="charsio.html#atom_to_chars/3">atom_to_chars/3</a></dt>
378419 <dt><a class="idx" href="strings.html#atomics_to_string/3">atomics_to_string/3</a></dt>
379420 <dt><a class="idx" href="thutil.html#attach_console/0">attach_console/0</a></dt>
380421 <dd>
381 <a class="idx" href="thutil.html#idx:attachconsole0:1938">9.5</a> <a class="idx" href="thutil.html#idx:attachconsole0:1940">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:attachconsole0:2066">11.4.16</a></dd>
422 <a class="idx" href="thutil.html#idx:attachconsole0:1942">9.5</a> <a class="idx" href="thutil.html#idx:attachconsole0:1944">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:attachconsole0:2070">11.4.16</a></dd>
382423 <dt><a class="idx" href="packs.html#attach_packs/0">attach_packs/0</a></dt>
383424 <dd>
384425 <a class="idx" href="packs.html#idx:attachpacks0:209">2.14</a></dd>
391432 <a class="idx" href="termrw.html#idx:attrportrayhook2:1120">4.20</a></dd>
392433 <dt><a class="idx" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a></dt>
393434 <dd>
394 <a class="idx" href="attvar.html#idx:attrunifyhook2:1771">7.1</a> <a class="idx" href="attvar.html#idx:attrunifyhook2:1773">7.1</a></dd>
395 <dt>attribute_goals//1</dt>
396 <dd>
397 <a class="idx" href="attvar.html#idx:attributegoals1:1774">7.1</a> <a class="idx" href="attvar.html#idx:attributegoals1:1780">7.1.2</a> <a class="idx" href="attvar.html#idx:attributegoals1:1785">7.1.2</a> <a class="idx" href="attvar.html#idx:attributegoals1:1786">7.1.3</a></dd>
398 <dt><a class="idx" href="attvar.html#attribute_goals/1">attribute_goals/1</a></dt>
435 <a class="idx" href="attvar.html#idx:attrunifyhook2:1775">7.1</a> <a class="idx" href="attvar.html#idx:attrunifyhook2:1777">7.1</a></dd>
436 <dt><a class="idx" href="attvar.html#attribute_goals//1">attribute_goals//1</a></dt>
437 <dd>
438 <a class="idx" href="attvar.html#idx:attributegoals1:1778">7.1</a> <a class="idx" href="attvar.html#idx:attributegoals1:1784">7.1.2</a> <a class="idx" href="attvar.html#idx:attributegoals1:1789">7.1.2</a> <a class="idx" href="attvar.html#idx:attributegoals1:1790">7.1.3</a></dd>
399439 <dt><a class="idx" href="attvar.html#attvar/1">attvar/1</a></dt>
400440 <dt><a class="idx" href="runtime.html#autoload/0">autoload/0</a></dt>
401441 <dd>
402 <a class="idx" href="autoload.html#idx:autoload0:207">2.13</a> <a class="idx" href="consulting.html#idx:autoload0:453">4.3</a> <a class="idx" href="runtime.html#idx:autoload0:2100">12</a> <a class="idx" href="runtime.html#idx:autoload0:2104">12</a></dd>
442 <a class="idx" href="autoload.html#idx:autoload0:207">2.13</a> <a class="idx" href="consulting.html#idx:autoload0:453">4.3</a> <a class="idx" href="runtime.html#idx:autoload0:2104">12</a> <a class="idx" href="runtime.html#idx:autoload0:2108">12</a></dd>
403443 <dt><a class="idx" href="autoload.html#autoload_path/1">autoload_path/1</a></dt>
404444 <dt><a class="idx" href="clpfd.html#automaton/3">automaton/3</a></dt>
405445 <dt><a class="idx" href="clpfd.html#automaton/8">automaton/8</a></dt>
409449 <dt><a class="idx" href="dicts.html#b_set_dict/3">b_set_dict/3</a></dt>
410450 <dt><a class="idx" href="gvar.html#b_setval/2">b_setval/2</a></dt>
411451 <dd>
412 <a class="idx" href="flags.html#idx:bsetval2:140">2.11</a> <a class="idx" href="db.html#idx:bsetval2:809">4.14</a> <a class="idx" href="gvar.html#idx:bsetval2:1414">4.33</a> <a class="idx" href="gvar.html#idx:bsetval2:1415">4.33</a> <a class="idx" href="dicts.html#idx:bsetval2:1641">5.4.2.1</a> <a class="idx" href="engine-examples.html#idx:bsetval2:1973">10.1.2</a> <a class="idx" href="exception3.html#idx:bsetval2:2218">B.6</a></dd>
452 <a class="idx" href="flags.html#idx:bsetval2:140">2.11</a> <a class="idx" href="db.html#idx:bsetval2:809">4.14</a> <a class="idx" href="gvar.html#idx:bsetval2:1414">4.33</a> <a class="idx" href="gvar.html#idx:bsetval2:1415">4.33</a> <a class="idx" href="dicts.html#idx:bsetval2:1645">5.4.2.1</a> <a class="idx" href="engine-examples.html#idx:bsetval2:1977">10.1.2</a> <a class="idx" href="exception3.html#idx:bsetval2:2222">B.6</a></dd>
413453 <dt>backtracking</dt>
414454 <dd>
415 <a class="idx" href="glossary.html#idx:backtracking:2273">D</a></dd>
455 <a class="idx" href="glossary.html#idx:backtracking:2277">D</a></dd>
416456 <dt><a class="idx" href="allsolutions.html#bagof/3">bagof/3</a></dt>
417457 <dd>
418 <a class="idx" href="cyclic.html#idx:bagof3:233">2.17</a> <a class="idx" href="allsolutions.html#idx:bagof3:1362">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1363">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1369">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1370">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1371">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1372">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1373">4.30</a> <a class="idx" href="metapred.html#idx:bagof3:1694">6.4</a> <a class="idx" href="engine-examples.html#idx:bagof3:1967">10.1.1</a> <a class="idx" href="predsummary.html#idx:bagof3:2347">F.1</a></dd>
458 <a class="idx" href="cyclic.html#idx:bagof3:233">2.17</a> <a class="idx" href="allsolutions.html#idx:bagof3:1362">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1363">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1369">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1370">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1371">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1372">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1373">4.30</a> <a class="idx" href="metapred.html#idx:bagof3:1698">6.4</a> <a class="idx" href="engine-examples.html#idx:bagof3:1971">10.1.1</a> <a class="idx" href="predsummary.html#idx:bagof3:2351">F.1</a></dd>
419459 <dt><a class="idx" href="clpqr.html#bb_inf/3">bb_inf/3</a></dt>
420460 <dt><a class="idx" href="clpqr.html#bb_inf/4">bb_inf/4</a></dt>
421461 <dt><a class="idx" href="clpqr.html#bb_inf/5">bb_inf/5</a></dt>
424464 <a class="idx" href="arith.html#idx:between3:1321">4.27.1</a></dd>
425465 <dt>binding</dt>
426466 <dd>
427 <a class="idx" href="glossary.html#idx:binding:2274">D</a></dd>
467 <a class="idx" href="glossary.html#idx:binding:2278">D</a></dd>
428468 <dt>bits, 64</dt>
429469 <dd>
430470 <a class="idx" href="64bits.html#idx:bits64:285">2.21</a></dd>
431471 <dt>blackboard</dt>
432472 <dd>
433 <a class="idx" href="broadcast.html#idx:blackboard:2134">A.4</a></dd>
473 <a class="idx" href="broadcast.html#idx:blackboard:2138">A.4</a></dd>
434474 <dt><a class="idx" href="typetest.html#blob/2">blob/2</a></dt>
435475 <dd>
436476 <a class="idx" href="typetest.html#idx:blob2:608">4.6</a> <a class="idx" href="IO.html#idx:blob2:970">4.17.2</a></dd>
437477 <dt>body</dt>
438478 <dd>
439 <a class="idx" href="glossary.html#idx:body:2277">D</a></dd>
479 <a class="idx" href="glossary.html#idx:body:2281">D</a></dd>
440480 <dt><a class="idx" href="toplevel.html#break/0">break/0</a></dt>
441481 <dd>
442 <a class="idx" href="cmdline.html#idx:break0:44">2.4.4</a> <a class="idx" href="debugoverview.html#idx:break0:67">2.9</a> <a class="idx" href="flags.html#idx:break0:91">2.11</a> <a class="idx" href="flags.html#idx:break0:143">2.11</a> <a class="idx" href="debugging.html#idx:break0:1816">8.4.2</a> <a class="idx" href="foreigninclude.html#idx:break0:2065">11.4.16</a></dd>
482 <a class="idx" href="cmdline.html#idx:break0:44">2.4.4</a> <a class="idx" href="debugoverview.html#idx:break0:67">2.9</a> <a class="idx" href="flags.html#idx:break0:91">2.11</a> <a class="idx" href="flags.html#idx:break0:143">2.11</a> <a class="idx" href="debugging.html#idx:break0:1820">8.4.2</a> <a class="idx" href="foreigninclude.html#idx:break0:2069">11.4.16</a></dd>
443483 <dt>broadcast</dt>
444484 <dd>
445 <a class="idx" href="broadcast.html#idx:broadcast:2132">A.4</a></dd>
485 <a class="idx" href="broadcast.html#idx:broadcast:2136">A.4</a></dd>
446486 <dt><a class="idx" href="broadcast.html#broadcast/1">broadcast/1</a></dt>
447487 <dd>
448 <a class="idx" href="broadcast.html#idx:broadcast1:2137">A.4</a> <a class="idx" href="broadcast.html#idx:broadcast1:2138">A.4</a></dd>
488 <a class="idx" href="broadcast.html#idx:broadcast1:2141">A.4</a> <a class="idx" href="broadcast.html#idx:broadcast1:2142">A.4</a></dd>
449489 <dt><a class="idx" href="broadcast.html#broadcast_request/1">broadcast_request/1</a></dt>
450490 <dt>built-in predicate</dt>
451491 <dd>
452 <a class="idx" href="glossary.html#idx:builtinpredicate:2275">D</a></dd>
492 <a class="idx" href="glossary.html#idx:builtinpredicate:2279">D</a></dd>
453493 <dt><a class="idx" href="streamstat.html#byte_count/2">byte_count/2</a></dt>
454494 <dd>
455495 <a class="idx" href="IO.html#idx:bytecount2:1002">4.17.2</a></dd>
456496 <dt><a class="idx" href="metacall.html#call/1">call/1</a></dt>
457497 <dd>
458 <a class="idx" href="xref.html#idx:call1:322">3.7</a> <a class="idx" href="typetest.html#idx:call1:612">4.6</a> <a class="idx" href="typetest.html#idx:call1:614">4.6</a> <a class="idx" href="typetest.html#idx:call1:617">4.6</a> <a class="idx" href="control.html#idx:call1:646">4.8</a> <a class="idx" href="metacall.html#idx:call1:649">4.9</a> <a class="idx" href="exception.html#idx:call1:693">4.11</a> <a class="idx" href="exception.html#idx:call1:697">4.11</a> <a class="idx" href="exception.html#idx:call1:699">4.11</a> <a class="idx" href="debugger.html#idx:call1:1553">4.39</a> <a class="idx" href="statistics.html#idx:call1:1565">4.40</a> <a class="idx" href="profile.html#idx:call1:1570">4.41.1</a> <a class="idx" href="profile.html#idx:call1:1573">4.41.3</a> <a class="idx" href="profile.html#idx:call1:1574">4.41.3</a> <a class="idx" href="modules.html#idx:call1:1658">6</a> <a class="idx" href="coroutining.html#idx:call1:1804">7.2</a> <a class="idx" href="foreigninclude.html#idx:call1:2040">11.4.9</a> <a class="idx" href="breakpoint.html#idx:call1:2202">B.4</a></dd>
498 <a class="idx" href="xref.html#idx:call1:322">3.7</a> <a class="idx" href="typetest.html#idx:call1:612">4.6</a> <a class="idx" href="typetest.html#idx:call1:614">4.6</a> <a class="idx" href="typetest.html#idx:call1:617">4.6</a> <a class="idx" href="control.html#idx:call1:646">4.8</a> <a class="idx" href="metacall.html#idx:call1:649">4.9</a> <a class="idx" href="exception.html#idx:call1:693">4.11</a> <a class="idx" href="exception.html#idx:call1:697">4.11</a> <a class="idx" href="exception.html#idx:call1:699">4.11</a> <a class="idx" href="debugger.html#idx:call1:1553">4.39</a> <a class="idx" href="statistics.html#idx:call1:1565">4.40</a> <a class="idx" href="profile.html#idx:call1:1570">4.41.1</a> <a class="idx" href="profile.html#idx:call1:1573">4.41.3</a> <a class="idx" href="profile.html#idx:call1:1574">4.41.3</a> <a class="idx" href="modules.html#idx:call1:1662">6</a> <a class="idx" href="coroutining.html#idx:call1:1808">7.2</a> <a class="idx" href="foreigninclude.html#idx:call1:2044">11.4.9</a> <a class="idx" href="breakpoint.html#idx:call1:2206">B.4</a></dd>
459499 <dt><a class="idx" href="metacall.html#call/2">call/2</a></dt>
460500 <dd>
461501 <a class="idx" href="typetest.html#idx:call2:613">4.6</a></dd>
467507 <a class="idx" href="metacall.html#idx:call28:650">4.9</a></dd>
468508 <dt><a class="idx" href="metacall.html#call_cleanup/2">call_cleanup/2</a></dt>
469509 <dd>
470 <a class="idx" href="metacall.html#idx:callcleanup2:674">4.9</a> <a class="idx" href="metacall.html#idx:callcleanup2:675">4.9</a> <a class="idx" href="metacall.html#idx:callcleanup2:677">4.9</a> <a class="idx" href="IO.html#idx:callcleanup2:1057">4.17.5</a> <a class="idx" href="manipstack.html#idx:callcleanup2:2186">B.1</a> <a class="idx" href="portabilitystrategies.html#idx:callcleanup2:2256">C.1</a></dd>
510 <a class="idx" href="metacall.html#idx:callcleanup2:674">4.9</a> <a class="idx" href="metacall.html#idx:callcleanup2:675">4.9</a> <a class="idx" href="metacall.html#idx:callcleanup2:677">4.9</a> <a class="idx" href="IO.html#idx:callcleanup2:1057">4.17.5</a> <a class="idx" href="manipstack.html#idx:callcleanup2:2190">B.1</a> <a class="idx" href="portabilitystrategies.html#idx:callcleanup2:2260">C.1</a></dd>
471511 <dt><a class="idx" href="metacall.html#call_cleanup/3">call_cleanup/3</a></dt>
472512 <dt><a class="idx" href="DCG.html#call_dcg/3">call_dcg/3</a></dt>
473513 <dd>
474514 <a class="idx" href="DCG.html#idx:calldcg3:785">4.13</a></dd>
515 <dt><a class="idx" href="solutionsequences.html#call_nth/2">call_nth/2</a></dt>
475516 <dt><a class="idx" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a></dt>
476517 <dd>
477 <a class="idx" href="coroutining.html#idx:callresiduevars2:1798">7.2</a> <a class="idx" href="coroutining.html#idx:callresiduevars2:1809">7.2</a> <a class="idx" href="coroutining.html#idx:callresiduevars2:1810">7.2</a></dd>
518 <a class="idx" href="coroutining.html#idx:callresiduevars2:1802">7.2</a> <a class="idx" href="coroutining.html#idx:callresiduevars2:1813">7.2</a> <a class="idx" href="coroutining.html#idx:callresiduevars2:1814">7.2</a></dd>
478519 <dt><a class="idx" href="foreignlink.html#call_shared_object_function/2">call_shared_object_function/2</a></dt>
479520 <dt><a class="idx" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a></dt>
480521 <dd>
487528 <a class="idx" href="metacall.html#idx:callwithtimelimit2:665">4.9</a> <a class="idx" href="metacall.html#idx:callwithtimelimit2:666">4.9</a> <a class="idx" href="exception.html#idx:callwithtimelimit2:718">4.11.1</a></dd>
488529 <dt><a class="idx" href="typetest.html#callable/1">callable/1</a></dt>
489530 <dd>
490 <a class="idx" href="typetest.html#idx:callable1:616">4.6</a> <a class="idx" href="foreigninclude.html#idx:callable1:2018">11.4.3.1</a> <a class="idx" href="prolog_xref.html#idx:callable1:2153">A.27</a></dd>
531 <a class="idx" href="typetest.html#idx:callable1:616">4.6</a> <a class="idx" href="foreigninclude.html#idx:callable1:2022">11.4.3.1</a> <a class="idx" href="prolog_xref.html#idx:callable1:2157">A.27</a></dd>
491532 <dt><a class="idx" href="consulting.html#cancel_halt/1">cancel_halt/1</a></dt>
492533 <dd>
493 <a class="idx" href="consulting.html#idx:cancelhalt1:499">4.3</a> <a class="idx" href="toplevel.html#idx:cancelhalt1:1531">4.37</a> <a class="idx" href="foreigninclude.html#idx:cancelhalt1:2084">11.4.21</a></dd>
534 <a class="idx" href="consulting.html#idx:cancelhalt1:499">4.3</a> <a class="idx" href="toplevel.html#idx:cancelhalt1:1531">4.37</a> <a class="idx" href="foreigninclude.html#idx:cancelhalt1:2088">11.4.21</a></dd>
494535 <dt><a class="idx" href="exception.html#catch/3">catch/3</a></dt>
495536 <dd>
496 <a class="idx" href="delcont.html#idx:catch3:682">4.10</a> <a class="idx" href="exception.html#idx:catch3:691">4.11</a> <a class="idx" href="exception.html#idx:catch3:696">4.11</a> <a class="idx" href="exception.html#idx:catch3:698">4.11</a> <a class="idx" href="exception.html#idx:catch3:701">4.11</a> <a class="idx" href="exception.html#idx:catch3:702">4.11</a> <a class="idx" href="exception.html#idx:catch3:703">4.11</a> <a class="idx" href="exception.html#idx:catch3:705">4.11</a> <a class="idx" href="exception.html#idx:catch3:706">4.11</a> <a class="idx" href="exception.html#idx:catch3:707">4.11</a> <a class="idx" href="exception.html#idx:catch3:708">4.11</a> <a class="idx" href="exception.html#idx:catch3:722">4.11.1</a> <a class="idx" href="exception.html#idx:catch3:725">4.11.2</a> <a class="idx" href="exception.html#idx:catch3:726">4.11.2</a> <a class="idx" href="exception.html#idx:catch3:727">4.11.2</a> <a class="idx" href="termrw.html#idx:catch3:1167">4.20</a> <a class="idx" href="files.html#idx:catch3:1494">4.36</a> <a class="idx" href="toplevel.html#idx:catch3:1527">4.37</a> <a class="idx" href="profile.html#idx:catch3:1572">4.41.1</a> <a class="idx" href="threadcreate.html#idx:catch3:1844">9.1</a> <a class="idx" href="thmonitor.html#idx:catch3:1872">9.2</a> <a class="idx" href="thmonitor.html#idx:catch3:1877">9.2</a> <a class="idx" href="engine-examples.html#idx:catch3:1978">10.1.2</a> <a class="idx" href="manipstack.html#idx:catch3:2184">B.1</a> <a class="idx" href="excepthook.html#idx:catch3:2207">B.5</a> <a class="idx" href="exception3.html#idx:catch3:2212">B.6</a> <a class="idx" href="exception3.html#idx:catch3:2215">B.6</a> <a class="idx" href="predsummary.html#idx:catch3:2370">F.1</a></dd>
537 <a class="idx" href="delcont.html#idx:catch3:682">4.10</a> <a class="idx" href="exception.html#idx:catch3:691">4.11</a> <a class="idx" href="exception.html#idx:catch3:696">4.11</a> <a class="idx" href="exception.html#idx:catch3:698">4.11</a> <a class="idx" href="exception.html#idx:catch3:701">4.11</a> <a class="idx" href="exception.html#idx:catch3:702">4.11</a> <a class="idx" href="exception.html#idx:catch3:703">4.11</a> <a class="idx" href="exception.html#idx:catch3:705">4.11</a> <a class="idx" href="exception.html#idx:catch3:706">4.11</a> <a class="idx" href="exception.html#idx:catch3:707">4.11</a> <a class="idx" href="exception.html#idx:catch3:708">4.11</a> <a class="idx" href="exception.html#idx:catch3:722">4.11.1</a> <a class="idx" href="exception.html#idx:catch3:725">4.11.2</a> <a class="idx" href="exception.html#idx:catch3:726">4.11.2</a> <a class="idx" href="exception.html#idx:catch3:727">4.11.2</a> <a class="idx" href="termrw.html#idx:catch3:1167">4.20</a> <a class="idx" href="files.html#idx:catch3:1494">4.36</a> <a class="idx" href="toplevel.html#idx:catch3:1527">4.37</a> <a class="idx" href="profile.html#idx:catch3:1572">4.41.1</a> <a class="idx" href="threadcreate.html#idx:catch3:1848">9.1</a> <a class="idx" href="thmonitor.html#idx:catch3:1876">9.2</a> <a class="idx" href="thmonitor.html#idx:catch3:1881">9.2</a> <a class="idx" href="engine-examples.html#idx:catch3:1982">10.1.2</a> <a class="idx" href="manipstack.html#idx:catch3:2188">B.1</a> <a class="idx" href="excepthook.html#idx:catch3:2211">B.5</a> <a class="idx" href="exception3.html#idx:catch3:2216">B.6</a> <a class="idx" href="exception3.html#idx:catch3:2219">B.6</a> <a class="idx" href="predsummary.html#idx:catch3:2374">F.1</a></dd>
497538 <dt><a class="idx" href="clpfd.html#chain/2">chain/2</a></dt>
498539 <dt><a class="idx" href="manipatom.html#char_code/2">char_code/2</a></dt>
499540 <dd>
523564 <dt><a class="idx" href="check.html#checker/2">checker/2</a></dt>
524565 <dt>choice point</dt>
525566 <dd>
526 <a class="idx" href="glossary.html#idx:choicepoint:2278">D</a></dd>
567 <a class="idx" href="glossary.html#idx:choicepoint:2282">D</a></dd>
527568 <dt><a class="idx" href="practical.html#chr_constraint/1">chr_constraint/1</a></dt>
528569 <dd>
529 <a class="idx" href="practical.html#idx:chrconstraint1:1811">8.3.2</a> <a class="idx" href="sicstus-chr.html#idx:chrconstraint1:1823">8.6.1</a></dd>
570 <a class="idx" href="practical.html#idx:chrconstraint1:1815">8.3.2</a> <a class="idx" href="sicstus-chr.html#idx:chrconstraint1:1827">8.6.1</a></dd>
530571 <dt><a class="idx" href="debugging.html#chr_leash/1">chr_leash/1</a></dt>
531572 <dt><a class="idx" href="debugging.html#chr_notrace/0">chr_notrace/0</a></dt>
532573 <dd>
533 <a class="idx" href="debugging.html#idx:chrnotrace0:1815">8.4.2</a></dd>
574 <a class="idx" href="debugging.html#idx:chrnotrace0:1819">8.4.2</a></dd>
534575 <dt><a class="idx" href="SyntaxAndSemantics.html#chr_option/2">chr_option/2</a></dt>
535576 <dd>
536 <a class="idx" href="sicstus-chr.html#idx:chroption2:1824">8.6.1</a></dd>
577 <a class="idx" href="sicstus-chr.html#idx:chroption2:1828">8.6.1</a></dd>
537578 <dt><a class="idx" href="debugging.html#chr_show_store/1">chr_show_store/1</a></dt>
538579 <dt><a class="idx" href="debugging.html#chr_trace/0">chr_trace/0</a></dt>
539580 <dd>
540 <a class="idx" href="debugging.html#idx:chrtrace0:1814">8.4.2</a></dd>
581 <a class="idx" href="debugging.html#idx:chrtrace0:1818">8.4.2</a></dd>
541582 <dt><a class="idx" href="practical.html#chr_type/1">chr_type/1</a></dt>
542583 <dd>
543 <a class="idx" href="practical.html#idx:chrtype1:1812">8.3.2</a></dd>
584 <a class="idx" href="practical.html#idx:chrtype1:1816">8.3.2</a></dd>
544585 <dt><a class="idx" href="clpfd.html#circuit/1">circuit/1</a></dt>
545586 <dt>clause</dt>
546587 <dd>
547 <a class="idx" href="glossary.html#idx:clause:2279">D</a></dd>
588 <a class="idx" href="glossary.html#idx:clause:2283">D</a></dd>
548589 <dt><a class="idx" href="examineprog.html#clause/2">clause/2</a></dt>
549590 <dd>
550 <a class="idx" href="flags.html#idx:clause2:128">2.11</a> <a class="idx" href="flags.html#idx:clause2:129">2.11</a> <a class="idx" href="listing.html#idx:clause2:595">4.5</a> <a class="idx" href="control.html#idx:clause2:648">4.8</a> <a class="idx" href="examineprog.html#idx:clause2:936">4.16</a> <a class="idx" href="runtime.html#idx:clause2:2105">12</a></dd>
591 <a class="idx" href="flags.html#idx:clause2:128">2.11</a> <a class="idx" href="flags.html#idx:clause2:129">2.11</a> <a class="idx" href="listing.html#idx:clause2:595">4.5</a> <a class="idx" href="control.html#idx:clause2:648">4.8</a> <a class="idx" href="examineprog.html#idx:clause2:936">4.16</a> <a class="idx" href="runtime.html#idx:clause2:2109">12</a></dd>
551592 <dt><a class="idx" href="examineprog.html#clause/3">clause/3</a></dt>
552593 <dd>
553 <a class="idx" href="db.html#idx:clause3:838">4.14.1</a> <a class="idx" href="db.html#idx:clause3:848">4.14.2</a> <a class="idx" href="examineprog.html#idx:clause3:940">4.16</a> <a class="idx" href="examineprog.html#idx:clause3:946">4.16</a> <a class="idx" href="qsavelimits.html#idx:clause3:2114">12.1</a></dd>
594 <a class="idx" href="db.html#idx:clause3:838">4.14.1</a> <a class="idx" href="db.html#idx:clause3:848">4.14.2</a> <a class="idx" href="examineprog.html#idx:clause3:940">4.16</a> <a class="idx" href="examineprog.html#idx:clause3:946">4.16</a> <a class="idx" href="qsavelimits.html#idx:clause3:2118">12.1</a></dd>
554595 <dt>clause/[2,3]</dt>
555596 <dd>
556597 <a class="idx" href="flags.html#idx:clause23:117">2.11</a></dd>
557598 <dt><a class="idx" href="examineprog.html#clause_property/2">clause_property/2</a></dt>
558599 <dd>
559 <a class="idx" href="consulting.html#idx:clauseproperty2:450">4.3</a> <a class="idx" href="consulting.html#idx:clauseproperty2:474">4.3</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:918">4.16</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:921">4.16</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:943">4.16</a> <a class="idx" href="manipstack.html#idx:clauseproperty2:2181">B.1</a></dd>
600 <a class="idx" href="consulting.html#idx:clauseproperty2:450">4.3</a> <a class="idx" href="consulting.html#idx:clauseproperty2:474">4.3</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:918">4.16</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:921">4.16</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:943">4.16</a> <a class="idx" href="manipstack.html#idx:clauseproperty2:2185">B.1</a></dd>
560601 <dt><a class="idx" href="IO.html#close/1">close/1</a></dt>
561602 <dd>
562603 <a class="idx" href="IO.html#idx:close1:948">4.17</a> <a class="idx" href="IO.html#idx:close1:982">4.17.2</a> <a class="idx" href="IO.html#idx:close1:995">4.17.2</a></dd>
582623 <a class="idx" href="chartype.html#idx:comparelanguagespecific:1308">4.24.3</a></dd>
583624 <dt><a class="idx" href="compare.html#compare/3">compare/3</a></dt>
584625 <dd>
585 <a class="idx" href="cyclic.html#idx:compare3:234">2.17</a> <a class="idx" href="builtinlist.html#idx:compare3:1358">4.29</a> <a class="idx" href="foreigninclude.html#idx:compare3:2051">11.4.14.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2259">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2260">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2261">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2264">C.1</a></dd>
626 <a class="idx" href="cyclic.html#idx:compare3:234">2.17</a> <a class="idx" href="builtinlist.html#idx:compare3:1358">4.29</a> <a class="idx" href="foreigninclude.html#idx:compare3:2055">11.4.14.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2263">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2264">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2265">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2268">C.1</a></dd>
586627 <dt><a class="idx" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a></dt>
587628 <dd>
588629 <a class="idx" href="consulting.html#idx:compileauxclauses1:375">4.3</a> <a class="idx" href="examineprog.html#idx:compileauxclauses1:912">4.16</a></dd>
596637 <dt><a class="idx" href="ugraphs.html#compose/3">compose/3</a></dt>
597638 <dt>compound</dt>
598639 <dd>
599 <a class="idx" href="glossary.html#idx:compound:2280">D</a></dd>
640 <a class="idx" href="glossary.html#idx:compound:2284">D</a></dd>
600641 <dt><a class="idx" href="typetest.html#compound/1">compound/1</a></dt>
601642 <dt><a class="idx" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a></dt>
602643 <dd>
609650 <a class="idx" href="manipatom.html#idx:concatatom3:1276">4.22</a></dd>
610651 <dt>constraint programming</dt>
611652 <dd>
612 <a class="idx" href="clp.html#idx:constraintprogramming:1760">7</a></dd>
653 <a class="idx" href="clp.html#idx:constraintprogramming:1764">7</a></dd>
613654 <dt><a class="idx" href="simplex.html#constraint/3">constraint/3</a></dt>
614655 <dt><a class="idx" href="simplex.html#constraint/4">constraint/4</a></dt>
615656 <dt><a class="idx" href="simplex.html#constraint_add/4">constraint_add/4</a></dt>
618659 <a class="idx" href="quickstart.html#idx:consult1:6">2.1.1.1</a> <a class="idx" href="initfile.html#idx:consult1:21">2.2</a> <a class="idx" href="hooks.html#idx:consult1:177">2.12</a> <a class="idx" href="pceemacs.html#idx:consult1:313">3.4.3.1</a> <a class="idx" href="consulting.html#idx:consult1:359">4.3</a> <a class="idx" href="consulting.html#idx:consult1:380">4.3</a> <a class="idx" href="consulting.html#idx:consult1:386">4.3</a> <a class="idx" href="consulting.html#idx:consult1:392">4.3</a> <a class="idx" href="consulting.html#idx:consult1:403">4.3</a> <a class="idx" href="consulting.html#idx:consult1:422">4.3</a> <a class="idx" href="consulting.html#idx:consult1:426">4.3</a> <a class="idx" href="consulting.html#idx:consult1:427">4.3</a> <a class="idx" href="consulting.html#idx:consult1:429">4.3</a> <a class="idx" href="consulting.html#idx:consult1:431">4.3</a> <a class="idx" href="consulting.html#idx:consult1:441">4.3</a> <a class="idx" href="consulting.html#idx:consult1:454">4.3</a> <a class="idx" href="consulting.html#idx:consult1:565">4.3.2.1</a> <a class="idx" href="consulting.html#idx:consult1:566">4.3.2.1</a> <a class="idx" href="consulting.html#idx:consult1:572">4.3.2.1</a> <a class="idx" href="consulting.html#idx:consult1:577">4.3.3</a> <a class="idx" href="consulting.html#idx:consult1:578">4.3.3</a> <a class="idx" href="consulting.html#idx:consult1:579">4.3.3</a> <a class="idx" href="dynamic.html#idx:consult1:888">4.15</a></dd>
619660 <dt>context module</dt>
620661 <dd>
621 <a class="idx" href="glossary.html#idx:contextmodule:2281">D</a></dd>
662 <a class="idx" href="glossary.html#idx:contextmodule:2285">D</a></dd>
622663 <dt><a class="idx" href="ctxmodule.html#context_module/1">context_module/1</a></dt>
623664 <dd>
624 <a class="idx" href="metapred.html#idx:contextmodule1:1700">6.4</a> <a class="idx" href="ctxmodule.html#idx:contextmodule1:1745">6.13</a> <a class="idx" href="foreigninclude.html#idx:contextmodule1:2042">11.4.9.2</a></dd>
665 <a class="idx" href="metapred.html#idx:contextmodule1:1704">6.4</a> <a class="idx" href="ctxmodule.html#idx:contextmodule1:1749">6.13</a> <a class="idx" href="foreigninclude.html#idx:contextmodule1:2046">11.4.9.2</a></dd>
625666 <dt>convert_time/[2,8]</dt>
626667 <dd>
627668 <a class="idx" href="files.html#idx:converttime28:1502">4.36</a></dd>
638679 <a class="idx" href="IO.html#idx:copystreamdata3:1008">4.17.2</a></dd>
639680 <dt><a class="idx" href="manipterm.html#copy_term/2">copy_term/2</a></dt>
640681 <dd>
641 <a class="idx" href="cyclic.html#idx:copyterm2:235">2.17</a> <a class="idx" href="compare.html#idx:copyterm2:634">4.7.2</a> <a class="idx" href="manipterm.html#idx:copyterm2:1215">4.21</a> <a class="idx" href="manipterm.html#idx:copyterm2:1222">4.21.1</a> <a class="idx" href="manipterm.html#idx:copyterm2:1233">4.21.1</a> <a class="idx" href="gvar.html#idx:copyterm2:1420">4.33</a> <a class="idx" href="dicts.html#idx:copyterm2:1639">5.4.2.1</a> <a class="idx" href="clp.html#idx:copyterm2:1769">7</a> <a class="idx" href="attvar.html#idx:copyterm2:1787">7.1.3</a></dd>
682 <a class="idx" href="cyclic.html#idx:copyterm2:235">2.17</a> <a class="idx" href="compare.html#idx:copyterm2:634">4.7.2</a> <a class="idx" href="manipterm.html#idx:copyterm2:1215">4.21</a> <a class="idx" href="manipterm.html#idx:copyterm2:1222">4.21.1</a> <a class="idx" href="manipterm.html#idx:copyterm2:1233">4.21.1</a> <a class="idx" href="gvar.html#idx:copyterm2:1420">4.33</a> <a class="idx" href="dicts.html#idx:copyterm2:1643">5.4.2.1</a> <a class="idx" href="clp.html#idx:copyterm2:1773">7</a> <a class="idx" href="attvar.html#idx:copyterm2:1791">7.1.3</a></dd>
642683 <dt><a class="idx" href="attvar.html#copy_term/3">copy_term/3</a></dt>
643684 <dd>
644 <a class="idx" href="IO.html#idx:copyterm3:1064">4.17.6</a> <a class="idx" href="termrw.html#idx:copyterm3:1137">4.20</a> <a class="idx" href="clp.html#idx:copyterm3:1770">7</a> <a class="idx" href="attvar.html#idx:copyterm3:1781">7.1.2</a> <a class="idx" href="attvar.html#idx:copyterm3:1784">7.1.2</a></dd>
685 <a class="idx" href="IO.html#idx:copyterm3:1064">4.17.6</a> <a class="idx" href="termrw.html#idx:copyterm3:1137">4.20</a> <a class="idx" href="clp.html#idx:copyterm3:1774">7</a> <a class="idx" href="attvar.html#idx:copyterm3:1785">7.1.2</a> <a class="idx" href="attvar.html#idx:copyterm3:1788">7.1.2</a></dd>
645686 <dt><a class="idx" href="attvar.html#copy_term_nat/2">copy_term_nat/2</a></dt>
646687 <dt>count_atom_results/3</dt>
647688 <dd>
648 <a class="idx" href="ctxmodule.html#idx:countatomresults3:1740">6.13</a> <a class="idx" href="ctxmodule.html#idx:countatomresults3:1742">6.13</a></dd>
689 <a class="idx" href="ctxmodule.html#idx:countatomresults3:1744">6.13</a> <a class="idx" href="ctxmodule.html#idx:countatomresults3:1746">6.13</a></dd>
649690 <dt><a class="idx" href="threadpool.html#create_pool/1">create_pool/1</a></dt>
650691 <dt><a class="idx" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a></dt>
651692 <dd>
652 <a class="idx" href="flags.html#idx:createprologflag3:84">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:151">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:152">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:165">2.11</a> <a class="idx" href="foreigninclude.html#idx:createprologflag3:2059">11.4.14.4</a></dd>
693 <a class="idx" href="flags.html#idx:createprologflag3:84">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:151">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:152">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:165">2.11</a> <a class="idx" href="foreigninclude.html#idx:createprologflag3:2063">11.4.14.4</a></dd>
653694 <dt>crypto_n_random_bytes/2</dt>
654695 <dd>
655696 <a class="idx" href="arith.html#idx:cryptonrandombytes2:1335">4.27.2.3</a></dd>
656 <dt><a class="idx" href="csv.html#csv/1">csv/1</a></dt>
657 <dt><a class="idx" href="csv.html#csv/2">csv/2</a></dt>
697 <dt><a class="idx" href="csv.html#csv//1">csv//1</a></dt>
698 <dt><a class="idx" href="csv.html#csv//2">csv//2</a></dt>
658699 <dt><a class="idx" href="csv.html#csv_options/2">csv_options/2</a></dt>
659700 <dt><a class="idx" href="csv.html#csv_read_file/2">csv_read_file/2</a></dt>
660701 <dd>
673714 <a class="idx" href="examineprog.html#idx:currentatom1:895">4.16</a></dd>
674715 <dt><a class="idx" href="examineprog.html#current_blob/2">current_blob/2</a></dt>
675716 <dd>
676 <a class="idx" href="foreigninclude.html#idx:currentblob2:2038">11.4.7.1</a></dd>
717 <a class="idx" href="foreigninclude.html#idx:currentblob2:2042">11.4.7.1</a></dd>
677718 <dt><a class="idx" href="charconv.html#current_char_conversion/2">current_char_conversion/2</a></dt>
678719 <dd>
679720 <a class="idx" href="charconv.html#idx:currentcharconversion2:1319">4.26</a></dd>
681722 <dt><a class="idx" href="examineprog.html#current_flag/1">current_flag/1</a></dt>
682723 <dt><a class="idx" href="foreignlink.html#current_foreign_library/2">current_foreign_library/2</a></dt>
683724 <dd>
684 <a class="idx" href="runtime.html#idx:currentforeignlibrary2:2101">12</a></dd>
725 <a class="idx" href="runtime.html#idx:currentforeignlibrary2:2105">12</a></dd>
685726 <dt><a class="idx" href="format.html#current_format_predicate/2">current_format_predicate/2</a></dt>
686727 <dt><a class="idx" href="examineprog.html#current_functor/2">current_functor/2</a></dt>
687728 <dd>
712753 <dt><a class="idx" href="predicate_options.html#current_predicate_options/3">current_predicate_options/3</a></dt>
713754 <dt><a class="idx" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a></dt>
714755 <dd>
715 <a class="idx" href="cmdline.html#idx:currentprologflag2:27">2.4.2</a> <a class="idx" href="cmdline.html#idx:currentprologflag2:32">2.4.2</a> <a class="idx" href="cmdline.html#idx:currentprologflag2:40">2.4.2</a> <a class="idx" href="flags.html#idx:currentprologflag2:80">2.11</a> <a class="idx" href="flags.html#idx:currentprologflag2:82">2.11</a> <a class="idx" href="autoload.html#idx:currentprologflag2:192">2.13</a> <a class="idx" href="gc.html#idx:currentprologflag2:211">2.15</a> <a class="idx" href="syntax.html#idx:currentprologflag2:214">2.16.1.3</a> <a class="idx" href="consulting.html#idx:currentprologflag2:399">4.3</a> <a class="idx" href="termrw.html#idx:currentprologflag2:1168">4.20</a> <a class="idx" href="DDE.html#idx:currentprologflag2:1585">4.43.2</a> <a class="idx" href="foreignlink.html#idx:currentprologflag2:2008">11.2.1</a> <a class="idx" href="foreigninclude.html#idx:currentprologflag2:2060">11.4.14.4</a> <a class="idx" href="libpl.html#idx:currentprologflag2:2131">A</a> <a class="idx" href="glossary.html#idx:currentprologflag2:2303">D</a></dd>
756 <a class="idx" href="cmdline.html#idx:currentprologflag2:27">2.4.2</a> <a class="idx" href="cmdline.html#idx:currentprologflag2:32">2.4.2</a> <a class="idx" href="cmdline.html#idx:currentprologflag2:40">2.4.2</a> <a class="idx" href="flags.html#idx:currentprologflag2:80">2.11</a> <a class="idx" href="flags.html#idx:currentprologflag2:82">2.11</a> <a class="idx" href="autoload.html#idx:currentprologflag2:192">2.13</a> <a class="idx" href="gc.html#idx:currentprologflag2:211">2.15</a> <a class="idx" href="syntax.html#idx:currentprologflag2:214">2.16.1.3</a> <a class="idx" href="consulting.html#idx:currentprologflag2:399">4.3</a> <a class="idx" href="termrw.html#idx:currentprologflag2:1168">4.20</a> <a class="idx" href="DDE.html#idx:currentprologflag2:1585">4.43.2</a> <a class="idx" href="foreignlink.html#idx:currentprologflag2:2012">11.2.1</a> <a class="idx" href="foreigninclude.html#idx:currentprologflag2:2064">11.4.14.4</a> <a class="idx" href="libpl.html#idx:currentprologflag2:2135">A</a> <a class="idx" href="glossary.html#idx:currentprologflag2:2307">D</a></dd>
716757 <dt><a class="idx" href="signal.html#current_signal/3">current_signal/3</a></dt>
717758 <dd>
718759 <a class="idx" href="signal.html#idx:currentsignal3:774">4.12</a></dd>
732773 <a class="idx" href="cyclic.html#idx:cyclicterm1:236">2.17</a> <a class="idx" href="typetest.html#idx:cyclicterm1:621">4.6</a> <a class="idx" href="typetest.html#idx:cyclicterm1:623">4.6</a></dd>
733774 <dt>daemon</dt>
734775 <dd>
735 <a class="idx" href="broadcast.html#idx:daemon:2136">A.4</a></dd>
776 <a class="idx" href="broadcast.html#idx:daemon:2140">A.4</a></dd>
736777 <dt><a class="idx" href="system.html#date_time_stamp/2">date_time_stamp/2</a></dt>
737778 <dt><a class="idx" href="system.html#date_time_value/3">date_time_value/3</a></dt>
738779 <dd>
745786 <dt><a class="idx" href="persistency.html#db_sync_all/1">db_sync_all/1</a></dt>
746787 <dt>dcg</dt>
747788 <dd>
748 <a class="idx" href="glossary.html#idx:dcg:2284">D</a></dd>
789 <a class="idx" href="glossary.html#idx:dcg:2288">D</a></dd>
749790 <dt><a class="idx" href="consulting.html#dcg_translate_rule/2">dcg_translate_rule/2</a></dt>
750791 <dd>
751792 <a class="idx" href="consulting.html#idx:dcgtranslaterule2:530">4.3.1</a></dd>
759800 <dt><a class="idx" href="DDE.html#dde_unregister_service/1">dde_unregister_service/1</a></dt>
760801 <dt><a class="idx" href="debugger.html#debug/0">debug/0</a></dt>
761802 <dd>
762 <a class="idx" href="debugoverview.html#idx:debug0:57">2.9</a> <a class="idx" href="debugoverview.html#idx:debug0:70">2.9</a> <a class="idx" href="flags.html#idx:debug0:144">2.11</a> <a class="idx" href="exception.html#idx:debug0:728">4.11.2</a> <a class="idx" href="debugger.html#idx:debug0:1548">4.39</a> <a class="idx" href="debugger.html#idx:debug0:1556">4.39</a> <a class="idx" href="memory.html#idx:debug0:1579">4.42</a> <a class="idx" href="thutil.html#idx:debug0:1942">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:debug0:2062">11.4.16</a> <a class="idx" href="breakpoint.html#idx:debug0:2200">B.4</a> <a class="idx" href="excepthook.html#idx:debug0:2210">B.5</a></dd>
803 <a class="idx" href="debugoverview.html#idx:debug0:57">2.9</a> <a class="idx" href="debugoverview.html#idx:debug0:70">2.9</a> <a class="idx" href="flags.html#idx:debug0:144">2.11</a> <a class="idx" href="exception.html#idx:debug0:728">4.11.2</a> <a class="idx" href="debugger.html#idx:debug0:1548">4.39</a> <a class="idx" href="debugger.html#idx:debug0:1556">4.39</a> <a class="idx" href="memory.html#idx:debug0:1579">4.42</a> <a class="idx" href="thutil.html#idx:debug0:1946">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:debug0:2066">11.4.16</a> <a class="idx" href="breakpoint.html#idx:debug0:2204">B.4</a> <a class="idx" href="excepthook.html#idx:debug0:2214">B.5</a></dd>
763804 <dt><a class="idx" href="debug.html#debug/1">debug/1</a></dt>
764805 <dt><a class="idx" href="debug.html#debug/3">debug/3</a></dt>
765806 <dd>
770811 <a class="idx" href="exception.html#idx:debuggingexceptions:724">4.11.2</a></dd>
771812 <dt><a class="idx" href="debugger.html#debugging/0">debugging/0</a></dt>
772813 <dd>
773 <a class="idx" href="hooks.html#idx:debugging0:185">2.12</a> <a class="idx" href="debugger.html#idx:debugging0:1551">4.39</a> <a class="idx" href="intlibs.html#idx:debugging0:2228">B.7</a> <a class="idx" href="intlibs.html#idx:debugging0:2229">B.7</a></dd>
814 <a class="idx" href="hooks.html#idx:debugging0:185">2.12</a> <a class="idx" href="debugger.html#idx:debugging0:1551">4.39</a> <a class="idx" href="intlibs.html#idx:debugging0:2232">B.7</a> <a class="idx" href="intlibs.html#idx:debugging0:2233">B.7</a></dd>
774815 <dt><a class="idx" href="debug.html#debugging/1">debugging/1</a></dt>
775816 <dt><a class="idx" href="debug.html#debugging/2">debugging/2</a></dt>
776817 <dt>declarative</dt>
777818 <dd>
778 <a class="idx" href="clp.html#idx:declarative:1764">7</a></dd>
819 <a class="idx" href="clp.html#idx:declarative:1768">7</a></dd>
779820 <dt><a class="idx" href="importmodule.html#default_module/2">default_module/2</a></dt>
780821 <dd>
781 <a class="idx" href="consulting.html#idx:defaultmodule2:538">4.3.1</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:909">4.16</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:919">4.16</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:932">4.16</a> <a class="idx" href="importmodule.html#idx:defaultmodule2:1721">6.9</a></dd>
822 <a class="idx" href="consulting.html#idx:defaultmodule2:538">4.3.1</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:909">4.16</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:919">4.16</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:932">4.16</a> <a class="idx" href="importmodule.html#idx:defaultmodule2:1725">6.9</a></dd>
782823 <dt><a class="idx" href="assoc.html#del_assoc/4">del_assoc/4</a></dt>
783824 <dt><a class="idx" href="attvar.html#del_attr/2">del_attr/2</a></dt>
784825 <dd>
785 <a class="idx" href="attvar.html#idx:delattr2:1791">7.1.4</a></dd>
826 <a class="idx" href="attvar.html#idx:delattr2:1795">7.1.4</a></dd>
786827 <dt><a class="idx" href="attvar.html#del_attrs/1">del_attrs/1</a></dt>
787828 <dt><a class="idx" href="dicts.html#del_dict/4">del_dict/4</a></dt>
788829 <dt><a class="idx" href="ugraphs.html#del_edges/3">del_edges/3</a></dt>
796837 <a class="idx" href="system.html#idx:deletefile1:1445">4.35</a> <a class="idx" href="files.html#idx:deletefile1:1518">4.36</a></dd>
797838 <dt><a class="idx" href="importmodule.html#delete_import_module/2">delete_import_module/2</a></dt>
798839 <dd>
799 <a class="idx" href="importmodule.html#idx:deleteimportmodule2:1720">6.9</a> <a class="idx" href="importmodule.html#idx:deleteimportmodule2:1724">6.9</a> <a class="idx" href="modulecompat.html#idx:deleteimportmodule2:1758">6.15</a></dd>
840 <a class="idx" href="importmodule.html#idx:deleteimportmodule2:1724">6.9</a> <a class="idx" href="importmodule.html#idx:deleteimportmodule2:1728">6.9</a> <a class="idx" href="modulecompat.html#idx:deleteimportmodule2:1762">6.15</a></dd>
800841 <dt><a class="idx" href="predicate_options.html#derive_predicate_options/0">derive_predicate_options/0</a></dt>
801842 <dt><a class="idx" href="predicate_options.html#derived_predicate_options/1">derived_predicate_options/1</a></dt>
802843 <dt><a class="idx" href="predicate_options.html#derived_predicate_options/3">derived_predicate_options/3</a></dt>
805846 <a class="idx" href="DCG.html#idx:deserialize:779">4.13</a></dd>
806847 <dt>det</dt>
807848 <dd>
808 <a class="idx" href="glossary.html#idx:det:2285">D</a></dd>
849 <a class="idx" href="glossary.html#idx:det:2289">D</a></dd>
809850 <dt>determinism</dt>
810851 <dd>
811 <a class="idx" href="glossary.html#idx:determinism:2286">D</a></dd>
852 <a class="idx" href="glossary.html#idx:determinism:2290">D</a></dd>
812853 <dt>deterministic</dt>
813854 <dd>
814 <a class="idx" href="glossary.html#idx:deterministic:2287">D</a></dd>
855 <a class="idx" href="glossary.html#idx:deterministic:2291">D</a></dd>
815856 <dt><a class="idx" href="manipstack.html#deterministic/1">deterministic/1</a></dt>
816857 <dd>
817858 <a class="idx" href="metacall.html#idx:deterministic1:673">4.9</a></dd>
818859 <dt><a class="idx" href="dicts.html#dict_create/3">dict_create/3</a></dt>
819860 <dd>
820 <a class="idx" href="dicts.html#idx:dictcreate3:1636">5.4.2</a></dd>
861 <a class="idx" href="dicts.html#idx:dictcreate3:1640">5.4.2</a></dd>
821862 <dt><a class="idx" href="option.html#dict_options/2">dict_options/2</a></dt>
822863 <dt><a class="idx" href="dicts.html#dict_pairs/3">dict_pairs/3</a></dt>
823864 <dd>
824 <a class="idx" href="dicts.html#idx:dictpairs3:1653">5.4.3</a></dd>
865 <a class="idx" href="dicts.html#idx:dictpairs3:1657">5.4.3</a></dd>
825866 <dt><a class="idx" href="coroutining.html#dif/2">dif/2</a></dt>
826867 <dd>
827 <a class="idx" href="cyclic.html#idx:dif2:237">2.17</a> <a class="idx" href="compare.html#idx:dif2:624">4.7</a> <a class="idx" href="compare.html#idx:dif2:640">4.7.2</a> <a class="idx" href="clp.html#idx:dif2:1762">7</a> <a class="idx" href="coroutining.html#idx:dif2:1793">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1799">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1800">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1801">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1802">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1807">7.2</a></dd>
868 <a class="idx" href="cyclic.html#idx:dif2:237">2.17</a> <a class="idx" href="compare.html#idx:dif2:624">4.7</a> <a class="idx" href="compare.html#idx:dif2:640">4.7.2</a> <a class="idx" href="clp.html#idx:dif2:1766">7</a> <a class="idx" href="coroutining.html#idx:dif2:1797">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1803">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1804">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1805">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1806">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1811">7.2</a></dd>
828869 <dt>directory_file_path/3</dt>
829870 <dd>
830871 <a class="idx" href="files.html#idx:directoryfilepath3:1495">4.36</a></dd>
835876 <dt><a class="idx" href="clpfd.html#disjoint2/1">disjoint2/1</a></dt>
836877 <dt>display/1</dt>
837878 <dd>
838 <a class="idx" href="format.html#idx:display1:1395">4.32.1</a> <a class="idx" href="foreigninclude.html#idx:display1:2025">11.4.3.6</a> <a class="idx" href="foreigninclude.html#idx:display1:2026">11.4.3.6</a></dd>
879 <a class="idx" href="format.html#idx:display1:1395">4.32.1</a> <a class="idx" href="foreigninclude.html#idx:display1:2029">11.4.3.6</a> <a class="idx" href="foreigninclude.html#idx:display1:2030">11.4.3.6</a></dd>
839880 <dt><a class="idx" href="solutionsequences.html#distinct/1">distinct/1</a></dt>
840881 <dt><a class="idx" href="solutionsequences.html#distinct/2">distinct/2</a></dt>
841882 <dt><a class="idx" href="arith.html#divmod/4">divmod/4</a></dt>
843884 <a class="idx" href="arith.html#idx:divmod4:1323">4.27.1</a></dd>
844885 <dt>dld</dt>
845886 <dd>
846 <a class="idx" href="foreignlink.html#idx:dld:2007">11.2</a></dd>
887 <a class="idx" href="foreignlink.html#idx:dld:2011">11.2</a></dd>
847888 <dt>do_not_use/1</dt>
848889 <dd>
849 <a class="idx" href="reexport.html#idx:donotuse1:1711">6.7</a></dd>
890 <a class="idx" href="reexport.html#idx:donotuse1:1715">6.7</a></dd>
850891 <dt>domain/2</dt>
851892 <dd>
852 <a class="idx" href="attvar.html#idx:domain2:1772">7.1</a></dd>
893 <a class="idx" href="attvar.html#idx:domain2:1776">7.1</a></dd>
853894 <dt><a class="idx" href="error.html#domain_error/2">domain_error/2</a></dt>
854895 <dd>
855 <a class="idx" href="foreigninclude.html#idx:domainerror2:2032">11.4.6</a></dd>
896 <a class="idx" href="foreigninclude.html#idx:domainerror2:2036">11.4.6</a></dd>
856897 <dt><a class="idx" href="chartype.html#downcase_atom/2">downcase_atom/2</a></dt>
857898 <dd>
858899 <a class="idx" href="chartype.html#idx:downcaseatom2:1294">4.24</a> <a class="idx" href="chartype.html#idx:downcaseatom2:1296">4.24</a> <a class="idx" href="chartype.html#idx:downcaseatom2:1303">4.24.1</a></dd>
859900 <dt><a class="idx" href="clpqr.html#dump/3">dump/3</a></dt>
860901 <dd>
861 <a class="idx" href="clpqr.html#idx:dump3:2144">A.9.5</a></dd>
902 <a class="idx" href="clpqr.html#idx:dump3:2148">A.9.5</a></dd>
862903 <dt><a class="idx" href="manipterm.html#duplicate_term/2">duplicate_term/2</a></dt>
863904 <dd>
864905 <a class="idx" href="cyclic.html#idx:duplicateterm2:238">2.17</a> <a class="idx" href="manipterm.html#idx:duplicateterm2:1217">4.21</a> <a class="idx" href="manipterm.html#idx:duplicateterm2:1225">4.21.1</a> <a class="idx" href="gvar.html#idx:duplicateterm2:1422">4.33</a></dd>
869910 <dt><a class="idx" href="examineprog.html#dwim_predicate/2">dwim_predicate/2</a></dt>
870911 <dt>dynamic predicate</dt>
871912 <dd>
872 <a class="idx" href="glossary.html#idx:dynamicpredicate:2288">D</a></dd>
913 <a class="idx" href="glossary.html#idx:dynamicpredicate:2292">D</a></dd>
873914 <dt><a class="idx" href="dynamic.html#dynamic/1">dynamic/1</a></dt>
874915 <dd>
875 <a class="idx" href="flags.html#idx:dynamic1:123">2.11</a> <a class="idx" href="flags.html#idx:dynamic1:148">2.11</a> <a class="idx" href="preddesc.html#idx:dynamic1:339">4.1</a> <a class="idx" href="consulting.html#idx:dynamic1:434">4.3</a> <a class="idx" href="db.html#idx:dynamic1:798">4.14</a> <a class="idx" href="db.html#idx:dynamic1:827">4.14.1</a> <a class="idx" href="db.html#idx:dynamic1:828">4.14.1</a> <a class="idx" href="dynamic.html#idx:dynamic1:875">4.15</a> <a class="idx" href="dynamic.html#idx:dynamic1:884">4.15</a> <a class="idx" href="examineprog.html#idx:dynamic1:915">4.16</a> <a class="idx" href="ctxmodule.html#idx:dynamic1:1744">6.13</a> <a class="idx" href="threadcom.html#idx:dynamic1:1914">9.3.3</a> <a class="idx" href="threadcom.html#idx:dynamic1:1916">9.3.3</a> <a class="idx" href="runtime.html#idx:dynamic1:2110">12</a></dd>
916 <a class="idx" href="flags.html#idx:dynamic1:123">2.11</a> <a class="idx" href="flags.html#idx:dynamic1:148">2.11</a> <a class="idx" href="preddesc.html#idx:dynamic1:339">4.1</a> <a class="idx" href="consulting.html#idx:dynamic1:434">4.3</a> <a class="idx" href="db.html#idx:dynamic1:798">4.14</a> <a class="idx" href="db.html#idx:dynamic1:827">4.14.1</a> <a class="idx" href="db.html#idx:dynamic1:828">4.14.1</a> <a class="idx" href="dynamic.html#idx:dynamic1:875">4.15</a> <a class="idx" href="dynamic.html#idx:dynamic1:884">4.15</a> <a class="idx" href="examineprog.html#idx:dynamic1:915">4.16</a> <a class="idx" href="ctxmodule.html#idx:dynamic1:1748">6.13</a> <a class="idx" href="threadcom.html#idx:dynamic1:1918">9.3.3</a> <a class="idx" href="threadcom.html#idx:dynamic1:1920">9.3.3</a> <a class="idx" href="runtime.html#idx:dynamic1:2114">12</a></dd>
876917 <dt><a class="idx" href="ugraphs.html#edges/2">edges/2</a></dt>
877918 <dt><a class="idx" href="edit.html#edit/0">edit/0</a></dt>
878919 <dd>
879920 <a class="idx" href="flags.html#idx:edit0:90">2.11</a></dd>
880921 <dt><a class="idx" href="edit.html#edit/1">edit/1</a></dt>
881922 <dd>
882 <a class="idx" href="quickstart.html#idx:edit1:10">2.1.4</a> <a class="idx" href="flags.html#idx:edit1:105">2.11</a> <a class="idx" href="hooks.html#idx:edit1:179">2.12</a> <a class="idx" href="hooks.html#idx:edit1:180">2.12</a> <a class="idx" href="hooks.html#idx:edit1:181">2.12</a> <a class="idx" href="editreload.html#idx:edit1:306">3.3.1</a> <a class="idx" href="pceemacs.html#idx:edit1:309">3.4.1</a> <a class="idx" href="pceemacs.html#idx:edit1:310">3.4.3.1</a> <a class="idx" href="idesummary.html#idx:edit1:327">3.9</a> <a class="idx" href="idesummary.html#idx:edit1:328">3.9</a> <a class="idx" href="consulting.html#idx:edit1:447">4.3</a> <a class="idx" href="consulting.html#idx:edit1:456">4.3</a> <a class="idx" href="edit.html#idx:edit1:585">4.4</a> <a class="idx" href="edit.html#idx:edit1:586">4.4</a> <a class="idx" href="edit.html#idx:edit1:587">4.4</a> <a class="idx" href="edit.html#idx:edit1:588">4.4</a> <a class="idx" href="edit.html#idx:edit1:589">4.4.1</a> <a class="idx" href="edit.html#idx:edit1:590">4.4.1</a> <a class="idx" href="edit.html#idx:edit1:591">4.4.1</a> <a class="idx" href="edit.html#idx:edit1:592">4.4.1</a> <a class="idx" href="mtoplevel.html#idx:edit1:1706">6.6</a> <a class="idx" href="predsummary.html#idx:edit1:2362">F.1</a> <a class="idx" href="predsummary.html#idx:edit1:2363">F.1</a> <a class="idx" href="predsummary.html#idx:edit1:2364">F.1</a> <a class="idx" href="predsummary.html#idx:edit1:2365">F.1</a></dd>
923 <a class="idx" href="quickstart.html#idx:edit1:10">2.1.4</a> <a class="idx" href="flags.html#idx:edit1:105">2.11</a> <a class="idx" href="hooks.html#idx:edit1:179">2.12</a> <a class="idx" href="hooks.html#idx:edit1:180">2.12</a> <a class="idx" href="hooks.html#idx:edit1:181">2.12</a> <a class="idx" href="editreload.html#idx:edit1:306">3.3.1</a> <a class="idx" href="pceemacs.html#idx:edit1:309">3.4.1</a> <a class="idx" href="pceemacs.html#idx:edit1:310">3.4.3.1</a> <a class="idx" href="idesummary.html#idx:edit1:327">3.9</a> <a class="idx" href="idesummary.html#idx:edit1:328">3.9</a> <a class="idx" href="consulting.html#idx:edit1:447">4.3</a> <a class="idx" href="consulting.html#idx:edit1:456">4.3</a> <a class="idx" href="edit.html#idx:edit1:585">4.4</a> <a class="idx" href="edit.html#idx:edit1:586">4.4</a> <a class="idx" href="edit.html#idx:edit1:587">4.4</a> <a class="idx" href="edit.html#idx:edit1:588">4.4</a> <a class="idx" href="edit.html#idx:edit1:589">4.4.1</a> <a class="idx" href="edit.html#idx:edit1:590">4.4.1</a> <a class="idx" href="edit.html#idx:edit1:591">4.4.1</a> <a class="idx" href="edit.html#idx:edit1:592">4.4.1</a> <a class="idx" href="mtoplevel.html#idx:edit1:1710">6.6</a> <a class="idx" href="predsummary.html#idx:edit1:2366">F.1</a> <a class="idx" href="predsummary.html#idx:edit1:2367">F.1</a> <a class="idx" href="predsummary.html#idx:edit1:2368">F.1</a> <a class="idx" href="predsummary.html#idx:edit1:2369">F.1</a></dd>
883924 <dt><a class="idx" href="clpfd.html#element/3">element/3</a></dt>
884925 <dt><a class="idx" href="consulting.html#elif/1">elif/1</a></dt>
885926 <dt><a class="idx" href="consulting.html#else/0">else/0</a></dt>
891932 <dt><a class="idx" href="consulting.html#endif/0">endif/0</a></dt>
892933 <dt><a class="idx" href="engine-predicates.html#engine_create/3">engine_create/3</a></dt>
893934 <dd>
894 <a class="idx" href="engine-predicates.html#idx:enginecreate3:1993">10.3</a></dd>
935 <a class="idx" href="engine-predicates.html#idx:enginecreate3:1997">10.3</a></dd>
895936 <dt><a class="idx" href="engine-predicates.html#engine_create/4">engine_create/4</a></dt>
896937 <dt><a class="idx" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a></dt>
897938 <dd>
898 <a class="idx" href="engine-resources.html#idx:enginedestroy1:1984">10.2</a> <a class="idx" href="engine-resources.html#idx:enginedestroy1:1985">10.2</a> <a class="idx" href="engine-resources.html#idx:enginedestroy1:1986">10.2</a></dd>
939 <a class="idx" href="engine-resources.html#idx:enginedestroy1:1988">10.2</a> <a class="idx" href="engine-resources.html#idx:enginedestroy1:1989">10.2</a> <a class="idx" href="engine-resources.html#idx:enginedestroy1:1990">10.2</a></dd>
899940 <dt><a class="idx" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a></dt>
900941 <dd>
901 <a class="idx" href="engine-examples.html#idx:enginefetch1:1976">10.1.2</a> <a class="idx" href="engine-predicates.html#idx:enginefetch1:1997">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginefetch1:1999">10.3</a></dd>
942 <a class="idx" href="engine-examples.html#idx:enginefetch1:1980">10.1.2</a> <a class="idx" href="engine-predicates.html#idx:enginefetch1:2001">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginefetch1:2003">10.3</a></dd>
902943 <dt>engine_next/1</dt>
903944 <dd>
904 <a class="idx" href="engine-examples.html#idx:enginenext1:1965">10.1.1</a></dd>
945 <a class="idx" href="engine-examples.html#idx:enginenext1:1969">10.1.1</a></dd>
905946 <dt><a class="idx" href="engine-predicates.html#engine_next/2">engine_next/2</a></dt>
906947 <dd>
907 <a class="idx" href="engines.html#idx:enginenext2:1963">10</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:1991">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:1996">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:1998">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2001">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2002">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2003">10.3</a></dd>
948 <a class="idx" href="engines.html#idx:enginenext2:1967">10</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:1995">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2000">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2002">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2005">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2006">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:2007">10.3</a></dd>
908949 <dt><a class="idx" href="engine-predicates.html#engine_next_reified/2">engine_next_reified/2</a></dt>
909950 <dt><a class="idx" href="engine-predicates.html#engine_post/2">engine_post/2</a></dt>
910951 <dd>
911 <a class="idx" href="engine-predicates.html#idx:enginepost2:2000">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginepost2:2005">10.3</a></dd>
952 <a class="idx" href="engine-predicates.html#idx:enginepost2:2004">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginepost2:2009">10.3</a></dd>
912953 <dt><a class="idx" href="engine-predicates.html#engine_post/3">engine_post/3</a></dt>
913954 <dd>
914 <a class="idx" href="engine-predicates.html#idx:enginepost3:2006">10.3</a></dd>
955 <a class="idx" href="engine-predicates.html#idx:enginepost3:2010">10.3</a></dd>
915956 <dt><a class="idx" href="engine-predicates.html#engine_self/1">engine_self/1</a></dt>
916957 <dt><a class="idx" href="engine-predicates.html#engine_yield/1">engine_yield/1</a></dt>
917958 <dd>
918 <a class="idx" href="engines.html#idx:engineyield1:1964">10</a> <a class="idx" href="engine-examples.html#idx:engineyield1:1977">10.1.2</a> <a class="idx" href="engine-resources.html#idx:engineyield1:1989">10.2</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:1994">10.3</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:1995">10.3</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:2004">10.3</a></dd>
959 <a class="idx" href="engines.html#idx:engineyield1:1968">10</a> <a class="idx" href="engine-examples.html#idx:engineyield1:1981">10.1.2</a> <a class="idx" href="engine-resources.html#idx:engineyield1:1993">10.2</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:1998">10.3</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:1999">10.3</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:2008">10.3</a></dd>
919960 <dt><a class="idx" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a></dt>
920961 <dd>
921 <a class="idx" href="compilation.html#idx:ensureloaded1:72">2.10.1</a> <a class="idx" href="consulting.html#idx:ensureloaded1:360">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:381">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:387">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:430">4.3</a> <a class="idx" href="import.html#idx:ensureloaded1:1668">6.3</a> <a class="idx" href="import.html#idx:ensureloaded1:1669">6.3</a></dd>
962 <a class="idx" href="compilation.html#idx:ensureloaded1:72">2.10.1</a> <a class="idx" href="consulting.html#idx:ensureloaded1:360">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:381">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:387">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:430">4.3</a> <a class="idx" href="import.html#idx:ensureloaded1:1672">6.3</a> <a class="idx" href="import.html#idx:ensureloaded1:1673">6.3</a></dd>
922963 <dt><a class="idx" href="clpqr.html#entailed/1">entailed/1</a></dt>
923964 <dt><a class="idx" href="prologpack.html#environment/2">environment/2</a></dt>
924965 <dt><a class="idx" href="db.html#erase/1">erase/1</a></dt>
926967 <a class="idx" href="db.html#idx:erase1:805">4.14</a> <a class="idx" href="db.html#idx:erase1:839">4.14.1</a> <a class="idx" href="db.html#idx:erase1:840">4.14.2</a> <a class="idx" href="examineprog.html#idx:erase1:938">4.16</a></dd>
927968 <dt><a class="idx" href="exception3.html#exception/3">exception/3</a></dt>
928969 <dd>
929 <a class="idx" href="gvar.html#idx:exception3:1419">4.33</a> <a class="idx" href="exception3.html#idx:exception3:2211">B.6</a> <a class="idx" href="exception3.html#idx:exception3:2214">B.6</a></dd>
970 <a class="idx" href="gvar.html#idx:exception3:1419">4.33</a> <a class="idx" href="exception3.html#idx:exception3:2215">B.6</a> <a class="idx" href="exception3.html#idx:exception3:2218">B.6</a></dd>
930971 <dt>exceptions,debugging</dt>
931972 <dd>
932973 <a class="idx" href="exception.html#idx:exceptionsdebugging:723">4.11.2</a></dd>
938979 <a class="idx" href="flags.html#idx:existsfile1:110">2.11</a></dd>
939980 <dt><a class="idx" href="dialect.html#exists_source/1">exists_source/1</a></dt>
940981 <dd>
941 <a class="idx" href="dialect.html#idx:existssource1:2246">C</a></dd>
982 <a class="idx" href="dialect.html#idx:existssource1:2250">C</a></dd>
942983 <dt><a class="idx" href="toplevel.html#expand_answer/2">expand_answer/2</a></dt>
943984 <dd>
944985 <a class="idx" href="toplevel.html#idx:expandanswer2:1536">4.37</a></dd>
953994 <dt><a class="idx" href="toplevel.html#expand_query/4">expand_query/4</a></dt>
954995 <dt><a class="idx" href="consulting.html#expand_term/2">expand_term/2</a></dt>
955996 <dd>
956 <a class="idx" href="consulting.html#idx:expandterm2:492">4.3</a> <a class="idx" href="consulting.html#idx:expandterm2:517">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:522">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:524">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:526">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:534">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:549">4.3.1</a> <a class="idx" href="DCG.html#idx:expandterm2:780">4.13</a> <a class="idx" href="record.html#idx:expandterm2:2169">A.31</a></dd>
997 <a class="idx" href="consulting.html#idx:expandterm2:492">4.3</a> <a class="idx" href="consulting.html#idx:expandterm2:517">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:522">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:524">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:526">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:534">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:549">4.3.1</a> <a class="idx" href="DCG.html#idx:expandterm2:780">4.13</a> <a class="idx" href="record.html#idx:expandterm2:2173">A.31</a></dd>
957998 <dt><a class="idx" href="consulting.html#expand_term/4">expand_term/4</a></dt>
958999 <dt><a class="idx" href="dialect.html#expects_dialect/1">expects_dialect/1</a></dt>
9591000 <dd>
960 <a class="idx" href="consulting.html#idx:expectsdialect1:401">4.3</a> <a class="idx" href="consulting.html#idx:expectsdialect1:421">4.3</a> <a class="idx" href="consulting.html#idx:expectsdialect1:488">4.3</a> <a class="idx" href="dialect.html#idx:expectsdialect1:2245">C</a></dd>
1001 <a class="idx" href="consulting.html#idx:expectsdialect1:401">4.3</a> <a class="idx" href="consulting.html#idx:expectsdialect1:421">4.3</a> <a class="idx" href="consulting.html#idx:expectsdialect1:488">4.3</a> <a class="idx" href="dialect.html#idx:expectsdialect1:2249">C</a></dd>
9611002 <dt><a class="idx" href="help.html#explain/1">explain/1</a></dt>
9621003 <dd>
9631004 <a class="idx" href="help.html#idx:explain1:51">2.6</a></dd>
9641005 <dt><a class="idx" href="help.html#explain/2">explain/2</a></dt>
9651006 <dt><a class="idx" href="altmoduleapi.html#export/1">export/1</a></dt>
9661007 <dd>
967 <a class="idx" href="consulting.html#idx:export1:558">4.3.2</a> <a class="idx" href="dynamic.html#idx:export1:894">4.15</a> <a class="idx" href="altmoduleapi.html#idx:export1:1729">6.11</a> <a class="idx" href="altmoduleapi.html#idx:export1:1732">6.11</a> <a class="idx" href="dynamic-modules.html#idx:export1:1735">6.12</a></dd>
1008 <a class="idx" href="consulting.html#idx:export1:558">4.3.2</a> <a class="idx" href="dynamic.html#idx:export1:894">4.15</a> <a class="idx" href="altmoduleapi.html#idx:export1:1733">6.11</a> <a class="idx" href="altmoduleapi.html#idx:export1:1736">6.11</a> <a class="idx" href="dynamic-modules.html#idx:export1:1739">6.12</a></dd>
9681009 <dt>export_list/2</dt>
9691010 <dd>
970 <a class="idx" href="altmoduleapi.html#idx:exportlist2:1733">6.11</a></dd>
1011 <a class="idx" href="altmoduleapi.html#idx:exportlist2:1737">6.11</a></dd>
9711012 <dt>exported predicate</dt>
9721013 <dd>
973 <a class="idx" href="glossary.html#idx:exportedpredicate:2290">D</a></dd>
1014 <a class="idx" href="glossary.html#idx:exportedpredicate:2294">D</a></dd>
9741015 <dt><a class="idx" href="arith.html#f-**/2">f-**/2</a></dt>
9751016 <dt><a class="idx" href="arith.html#f-*/2">f-*/2</a></dt>
9761017 <dt><a class="idx" href="arith.html#f-+/1">f-+/1</a></dt>
10451086 <dt><a class="idx" href="arith.html#f-xor/2">f-xor/2</a></dt>
10461087 <dt>fact</dt>
10471088 <dd>
1048 <a class="idx" href="glossary.html#idx:fact:2293">D</a></dd>
1089 <a class="idx" href="glossary.html#idx:fact:2297">D</a></dd>
10491090 <dt><a class="idx" href="control.html#fail/0">fail/0</a></dt>
10501091 <dd>
10511092 <a class="idx" href="consulting.html#idx:fail0:545">4.3.1</a> <a class="idx" href="control.html#idx:fail0:644">4.8</a></dd>
10681109 <dt><a class="idx" href="url.html#file_name_to_url/2">file_name_to_url/2</a></dt>
10691110 <dt>file_of_label/2</dt>
10701111 <dd>
1071 <a class="idx" href="mtoplevel.html#idx:fileoflabel2:1709">6.6</a></dd>
1112 <a class="idx" href="mtoplevel.html#idx:fileoflabel2:1713">6.6</a></dd>
10721113 <dt><a class="idx" href="consulting.html#file_search_path/2">file_search_path/2</a></dt>
10731114 <dd>
1074 <a class="idx" href="initfile.html#idx:filesearchpath2:22">2.2</a> <a class="idx" href="cmdline.html#idx:filesearchpath2:36">2.4.2</a> <a class="idx" href="cmdline.html#idx:filesearchpath2:38">2.4.2</a> <a class="idx" href="flags.html#idx:filesearchpath2:89">2.11</a> <a class="idx" href="flags.html#idx:filesearchpath2:156">2.11</a> <a class="idx" href="autoload.html#idx:filesearchpath2:190">2.13</a> <a class="idx" href="autoload.html#idx:filesearchpath2:196">2.13</a> <a class="idx" href="autoload.html#idx:filesearchpath2:202">2.13</a> <a class="idx" href="projectfiles.html#idx:filesearchpath2:299">3.1.1.3</a> <a class="idx" href="projectfiles.html#idx:filesearchpath2:300">3.1.1.3</a> <a class="idx" href="xref.html#idx:filesearchpath2:323">3.7</a> <a class="idx" href="consulting.html#idx:filesearchpath2:404">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:463">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:465">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:467">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:470">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:471">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:494">4.3</a> <a class="idx" href="foreigninclude.html#idx:filesearchpath2:2057">11.4.14.3</a> <a class="idx" href="findhome.html#idx:filesearchpath2:2089">11.6</a> <a class="idx" href="qsaveforeign.html#idx:filesearchpath2:2117">12.2</a> <a class="idx" href="qsaveforeign.html#idx:filesearchpath2:2118">12.2</a> <a class="idx" href="useresource.html#idx:filesearchpath2:2123">12.3.1</a> <a class="idx" href="useresource.html#idx:filesearchpath2:2125">12.3.1</a> <a class="idx" href="findappfile.html#idx:filesearchpath2:2129">12.4</a></dd>
1115 <a class="idx" href="initfile.html#idx:filesearchpath2:22">2.2</a> <a class="idx" href="cmdline.html#idx:filesearchpath2:36">2.4.2</a> <a class="idx" href="cmdline.html#idx:filesearchpath2:38">2.4.2</a> <a class="idx" href="flags.html#idx:filesearchpath2:89">2.11</a> <a class="idx" href="flags.html#idx:filesearchpath2:156">2.11</a> <a class="idx" href="autoload.html#idx:filesearchpath2:190">2.13</a> <a class="idx" href="autoload.html#idx:filesearchpath2:196">2.13</a> <a class="idx" href="autoload.html#idx:filesearchpath2:202">2.13</a> <a class="idx" href="projectfiles.html#idx:filesearchpath2:299">3.1.1.3</a> <a class="idx" href="projectfiles.html#idx:filesearchpath2:300">3.1.1.3</a> <a class="idx" href="xref.html#idx:filesearchpath2:323">3.7</a> <a class="idx" href="consulting.html#idx:filesearchpath2:404">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:463">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:465">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:467">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:470">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:471">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:494">4.3</a> <a class="idx" href="foreigninclude.html#idx:filesearchpath2:2061">11.4.14.3</a> <a class="idx" href="findhome.html#idx:filesearchpath2:2093">11.6</a> <a class="idx" href="qsaveforeign.html#idx:filesearchpath2:2121">12.2</a> <a class="idx" href="qsaveforeign.html#idx:filesearchpath2:2122">12.2</a> <a class="idx" href="useresource.html#idx:filesearchpath2:2127">12.3.1</a> <a class="idx" href="useresource.html#idx:filesearchpath2:2129">12.3.1</a> <a class="idx" href="findappfile.html#idx:filesearchpath2:2133">12.4</a></dd>
10751116 <dt><a class="idx" href="chario.html#fill_buffer/1">fill_buffer/1</a></dt>
10761117 <dt><a class="idx" href="debugging.html#find_chr_constraint/1">find_chr_constraint/1</a></dt>
10771118 <dt><a class="idx" href="allsolutions.html#findall/3">findall/3</a></dt>
10781119 <dd>
1079 <a class="idx" href="cyclic.html#idx:findall3:239">2.17</a> <a class="idx" href="compare.html#idx:findall3:635">4.7.2</a> <a class="idx" href="control.html#idx:findall3:643">4.8</a> <a class="idx" href="db.html#idx:findall3:792">4.14</a> <a class="idx" href="allsolutions.html#idx:findall3:1361">4.30</a> <a class="idx" href="allsolutions.html#idx:findall3:1364">4.30</a> <a class="idx" href="allsolutions.html#idx:findall3:1365">4.30</a> <a class="idx" href="forall2.html#idx:findall3:1381">4.31</a> <a class="idx" href="dicts.html#idx:findall3:1649">5.4.3</a> <a class="idx" href="clp.html#idx:findall3:1768">7</a> <a class="idx" href="engine-examples.html#idx:findall3:1966">10.1.1</a> <a class="idx" href="engine-examples.html#idx:findall3:1968">10.1.1</a> <a class="idx" href="engine-examples.html#idx:findall3:1969">10.1.1</a> <a class="idx" href="engine-examples.html#idx:findall3:1970">10.1.1</a> <a class="idx" href="engine-predicates.html#idx:findall3:1990">10.3</a> <a class="idx" href="predsummary.html#idx:findall3:2355">F.1</a></dd>
1120 <a class="idx" href="cyclic.html#idx:findall3:239">2.17</a> <a class="idx" href="compare.html#idx:findall3:635">4.7.2</a> <a class="idx" href="control.html#idx:findall3:643">4.8</a> <a class="idx" href="db.html#idx:findall3:792">4.14</a> <a class="idx" href="allsolutions.html#idx:findall3:1361">4.30</a> <a class="idx" href="allsolutions.html#idx:findall3:1364">4.30</a> <a class="idx" href="allsolutions.html#idx:findall3:1365">4.30</a> <a class="idx" href="forall2.html#idx:findall3:1381">4.31</a> <a class="idx" href="dicts.html#idx:findall3:1653">5.4.3</a> <a class="idx" href="clp.html#idx:findall3:1772">7</a> <a class="idx" href="engine-examples.html#idx:findall3:1970">10.1.1</a> <a class="idx" href="engine-examples.html#idx:findall3:1972">10.1.1</a> <a class="idx" href="engine-examples.html#idx:findall3:1973">10.1.1</a> <a class="idx" href="engine-examples.html#idx:findall3:1974">10.1.1</a> <a class="idx" href="engine-predicates.html#idx:findall3:1994">10.3</a> <a class="idx" href="predsummary.html#idx:findall3:2359">F.1</a></dd>
10801121 <dt><a class="idx" href="allsolutions.html#findall/4">findall/4</a></dt>
10811122 <dd>
10821123 <a class="idx" href="allsolutions.html#idx:findall4:1366">4.30</a></dd>
10831124 <dt><a class="idx" href="allsolutions.html#findnsols/4">findnsols/4</a></dt>
10841125 <dd>
1085 <a class="idx" href="predsummary.html#idx:findnsols4:2356">F.1</a></dd>
1126 <a class="idx" href="predsummary.html#idx:findnsols4:2360">F.1</a></dd>
10861127 <dt><a class="idx" href="allsolutions.html#findnsols/5">findnsols/5</a></dt>
10871128 <dt><a class="idx" href="db.html#flag/3">flag/3</a></dt>
10881129 <dd>
10891130 <a class="idx" href="db.html#idx:flag3:807">4.14</a> <a class="idx" href="db.html#idx:flag3:808">4.14</a> <a class="idx" href="db.html#idx:flag3:852">4.14.3</a> <a class="idx" href="examineprog.html#idx:flag3:897">4.16</a> <a class="idx" href="manipterm.html#idx:flag3:1229">4.21.1</a></dd>
10901131 <dt><a class="idx" href="lists.html#flatten/2">flatten/2</a></dt>
10911132 <dd>
1092 <a class="idx" href="import.html#idx:flatten2:1670">6.3</a> <a class="idx" href="import.html#idx:flatten2:1673">6.3</a></dd>
1133 <a class="idx" href="import.html#idx:flatten2:1674">6.3</a> <a class="idx" href="import.html#idx:flatten2:1677">6.3</a></dd>
10931134 <dt><a class="idx" href="typetest.html#float/1">float/1</a></dt>
10941135 <dd>
10951136 <a class="idx" href="typetest.html#idx:float1:607">4.6</a></dd>
10961137 <dt>flounder</dt>
10971138 <dd>
1098 <a class="idx" href="coroutining.html#idx:flounder:1797">7.2</a></dd>
1139 <a class="idx" href="coroutining.html#idx:flounder:1801">7.2</a></dd>
10991140 <dt><a class="idx" href="chario.html#flush_output/0">flush_output/0</a></dt>
11001141 <dd>
11011142 <a class="idx" href="chario.html#idx:flushoutput0:1080">4.19</a></dd>
11261167 <a class="idx" href="exception.html#idx:format3:734">4.11.4</a> <a class="idx" href="exception.html#idx:format3:747">4.11.4</a> <a class="idx" href="exception.html#idx:format3:750">4.11.4</a> <a class="idx" href="exception.html#idx:format3:761">4.11.4</a> <a class="idx" href="exception.html#idx:format3:765">4.11.4.1</a> <a class="idx" href="IO.html#idx:format3:961">4.17.1</a> <a class="idx" href="IO.html#idx:format3:1054">4.17.5</a> <a class="idx" href="termrw.html#idx:format3:1117">4.20</a> <a class="idx" href="manipatom.html#idx:format3:1254">4.22</a> <a class="idx" href="manipatom.html#idx:format3:1267">4.22</a> <a class="idx" href="locale.html#idx:format3:1287">4.23</a> <a class="idx" href="chartype.html#idx:format3:1305">4.24.2</a> <a class="idx" href="arith.html#idx:format3:1331">4.27.2.1</a> <a class="idx" href="arith.html#idx:format3:1333">4.27.2.2</a> <a class="idx" href="format.html#idx:format3:1388">4.32</a> <a class="idx" href="format.html#idx:format3:1404">4.32.2</a> <a class="idx" href="format.html#idx:format3:1409">4.32.3</a> <a class="idx" href="strings.html#idx:format3:1611">5.2.2</a> <a class="idx" href="strings.html#idx:format3:1620">5.2.3</a></dd>
11271168 <dt>format/[1,2]</dt>
11281169 <dd>
1129 <a class="idx" href="termrw.html#idx:format12:1114">4.20</a> <a class="idx" href="predsummary.html#idx:format12:2357">F.1</a></dd>
1170 <a class="idx" href="termrw.html#idx:format12:1114">4.20</a> <a class="idx" href="predsummary.html#idx:format12:2361">F.1</a></dd>
11301171 <dt>format/[2,3]</dt>
11311172 <dd>
11321173 <a class="idx" href="syntax.html#idx:format23:218">2.16.1.3</a></dd>
11421183 <dt><a class="idx" href="aggregate.html#free_variables/4">free_variables/4</a></dt>
11431184 <dt><a class="idx" href="coroutining.html#freeze/2">freeze/2</a></dt>
11441185 <dd>
1145 <a class="idx" href="coroutining.html#idx:freeze2:1794">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1803">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1805">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1806">7.2</a></dd>
1186 <a class="idx" href="coroutining.html#idx:freeze2:1798">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1807">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1809">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1810">7.2</a></dd>
11461187 <dt><a class="idx" href="coroutining.html#frozen/2">frozen/2</a></dt>
11471188 <dt>functor</dt>
11481189 <dd>
1149 <a class="idx" href="glossary.html#idx:functor:2294">D</a></dd>
1190 <a class="idx" href="glossary.html#idx:functor:2298">D</a></dd>
11501191 <dt><a class="idx" href="manipterm.html#functor/3">functor/3</a></dt>
11511192 <dd>
11521193 <a class="idx" href="typetest.html#idx:functor3:609">4.6</a> <a class="idx" href="examineprog.html#idx:functor3:906">4.16</a> <a class="idx" href="manipterm.html#idx:functor3:1191">4.21</a> <a class="idx" href="manipterm.html#idx:functor3:1194">4.21</a> <a class="idx" href="manipterm.html#idx:functor3:1195">4.21</a> <a class="idx" href="gvar.html#idx:functor3:1433">4.33.1</a> <a class="idx" href="ext-syntax.html#idx:functor3:1625">5.3.2</a> <a class="idx" href="dicts.html#idx:functor3:1631">5.4.1</a></dd>
11531194 <dt><a class="idx" href="memory.html#garbage_collect/0">garbage_collect/0</a></dt>
11541195 <dd>
1155 <a class="idx" href="engine-examples.html#idx:garbagecollect0:1981">10.1.3</a> <a class="idx" href="engine-resources.html#idx:garbagecollect0:1987">10.2</a></dd>
1196 <a class="idx" href="engine-examples.html#idx:garbagecollect0:1985">10.1.3</a> <a class="idx" href="engine-resources.html#idx:garbagecollect0:1991">10.2</a></dd>
11561197 <dt><a class="idx" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a></dt>
11571198 <dd>
1158 <a class="idx" href="flags.html#idx:garbagecollectatoms0:85">2.11</a> <a class="idx" href="memory.html#idx:garbagecollectatoms0:1576">4.42</a> <a class="idx" href="engine-resources.html#idx:garbagecollectatoms0:1983">10.2</a> <a class="idx" href="foreigninclude.html#idx:garbagecollectatoms0:2073">11.4.19</a></dd>
1199 <a class="idx" href="flags.html#idx:garbagecollectatoms0:85">2.11</a> <a class="idx" href="memory.html#idx:garbagecollectatoms0:1576">4.42</a> <a class="idx" href="engine-resources.html#idx:garbagecollectatoms0:1987">10.2</a> <a class="idx" href="foreigninclude.html#idx:garbagecollectatoms0:2077">11.4.19</a></dd>
11591200 <dt><a class="idx" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a></dt>
11601201 <dd>
11611202 <a class="idx" href="jitindex.html#idx:garbagecollectclauses0:257">2.18</a> <a class="idx" href="jitindex.html#idx:garbagecollectclauses0:258">2.18</a> <a class="idx" href="consulting.html#idx:garbagecollectclauses0:557">4.3.2</a> <a class="idx" href="consulting.html#idx:garbagecollectclauses0:559">4.3.2</a> <a class="idx" href="db.html#idx:garbagecollectclauses0:801">4.14</a></dd>
11761217 <a class="idx" href="chario.html#idx:get02:1098">4.19</a></dd>
11771218 <dt><a class="idx" href="assoc.html#get_assoc/3">get_assoc/3</a></dt>
11781219 <dd>
1179 <a class="idx" href="dicts.html#idx:getassoc3:1652">5.4.3</a></dd>
1220 <a class="idx" href="dicts.html#idx:getassoc3:1656">5.4.3</a></dd>
11801221 <dt><a class="idx" href="assoc.html#get_assoc/5">get_assoc/5</a></dt>
11811222 <dt><a class="idx" href="attvar.html#get_attr/3">get_attr/3</a></dt>
11821223 <dd>
1183 <a class="idx" href="attvar.html#idx:getattr3:1790">7.1.4</a></dd>
1224 <a class="idx" href="attvar.html#idx:getattr3:1794">7.1.4</a></dd>
11841225 <dt><a class="idx" href="attvar.html#get_attrs/2">get_attrs/2</a></dt>
11851226 <dd>
1186 <a class="idx" href="attvar.html#idx:getattrs2:1792">7.1.4</a></dd>
1227 <a class="idx" href="attvar.html#idx:getattrs2:1796">7.1.4</a></dd>
11871228 <dt><a class="idx" href="chario.html#get_byte/1">get_byte/1</a></dt>
11881229 <dd>
11891230 <a class="idx" href="chario.html#idx:getbyte1:1090">4.19</a></dd>
12121253 <dd>
12131254 <a class="idx" href="chars.html#idx:getcode12:350">4.2</a></dd>
12141255 <dt><a class="idx" href="dicts.html#get_dict/3">get_dict/3</a></dt>
1256 <dd>
1257 <a class="idx" href="dicts.html#idx:getdict3:1636">5.4.1.2</a></dd>
12151258 <dt><a class="idx" href="dicts.html#get_dict/5">get_dict/5</a></dt>
12161259 <dt>get_dict_ex/3</dt>
12171260 <dd>
1218 <a class="idx" href="dicts.html#idx:getdictex3:1634">5.4.1</a></dd>
1261 <a class="idx" href="dicts.html#idx:getdictex3:1634">5.4.1</a> <a class="idx" href="dicts.html#idx:getdictex3:1637">5.4.1.2</a></dd>
12191262 <dt><a class="idx" href="db.html#get_flag/2">get_flag/2</a></dt>
12201263 <dt><a class="idx" href="chario.html#get_single_char/1">get_single_char/1</a></dt>
12211264 <dd>
12231266 <dt><a class="idx" href="strings.html#get_string_code/3">get_string_code/3</a></dt>
12241267 <dt><a class="idx" href="system.html#get_time/1">get_time/1</a></dt>
12251268 <dd>
1226 <a class="idx" href="files.html#idx:gettime1:1503">4.36</a> <a class="idx" href="statistics.html#idx:gettime1:1563">4.40</a> <a class="idx" href="threadcom.html#idx:gettime1:1888">9.3.1</a> <a class="idx" href="threadcom.html#idx:gettime1:1902">9.3.1</a></dd>
1269 <a class="idx" href="files.html#idx:gettime1:1503">4.36</a> <a class="idx" href="statistics.html#idx:gettime1:1563">4.40</a> <a class="idx" href="threadcom.html#idx:gettime1:1892">9.3.1</a> <a class="idx" href="threadcom.html#idx:gettime1:1906">9.3.1</a></dd>
12271270 <dt><a class="idx" href="system.html#getenv/2">getenv/2</a></dt>
12281271 <dd>
1229 <a class="idx" href="system.html#idx:getenv2:1450">4.35</a> <a class="idx" href="www_browser.html#idx:getenv2:2149">A.18</a></dd>
1272 <a class="idx" href="system.html#idx:getenv2:1450">4.35</a> <a class="idx" href="www_browser.html#idx:getenv2:2153">A.18</a></dd>
12301273 <dt><a class="idx" href="random.html#getrand/1">getrand/1</a></dt>
12311274 <dt><a class="idx" href="clpfd.html#global_cardinality/2">global_cardinality/2</a></dt>
12321275 <dt><a class="idx" href="clpfd.html#global_cardinality/3">global_cardinality/3</a></dt>
12361279 <a class="idx" href="ext-syntax.html#idx:go0:1630">5.3.2</a></dd>
12371280 <dt>goal</dt>
12381281 <dd>
1239 <a class="idx" href="glossary.html#idx:goal:2295">D</a></dd>
1282 <a class="idx" href="glossary.html#idx:goal:2299">D</a></dd>
12401283 <dt><a class="idx" href="consulting.html#goal_expansion/2">goal_expansion/2</a></dt>
12411284 <dd>
1242 <a class="idx" href="flags.html#idx:goalexpansion2:164">2.11</a> <a class="idx" href="consulting.html#idx:goalexpansion2:369">4.3</a> <a class="idx" href="consulting.html#idx:goalexpansion2:485">4.3</a> <a class="idx" href="consulting.html#idx:goalexpansion2:519">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:527">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:533">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:536">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:537">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:539">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:542">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:546">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:547">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:550">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:554">4.3.1.2</a> <a class="idx" href="consulting.html#idx:goalexpansion2:561">4.3.2</a> <a class="idx" href="dialect.html#idx:goalexpansion2:2254">C</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2258">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2263">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2265">C.1</a> <a class="idx" href="predsummary.html#idx:goalexpansion2:2353">F.1</a></dd>
1285 <a class="idx" href="flags.html#idx:goalexpansion2:164">2.11</a> <a class="idx" href="consulting.html#idx:goalexpansion2:369">4.3</a> <a class="idx" href="consulting.html#idx:goalexpansion2:485">4.3</a> <a class="idx" href="consulting.html#idx:goalexpansion2:519">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:527">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:533">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:536">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:537">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:539">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:542">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:546">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:547">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:550">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:554">4.3.1.2</a> <a class="idx" href="consulting.html#idx:goalexpansion2:561">4.3.2</a> <a class="idx" href="dialect.html#idx:goalexpansion2:2258">C</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2262">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2267">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2269">C.1</a> <a class="idx" href="predsummary.html#idx:goalexpansion2:2357">F.1</a></dd>
12431286 <dt><a class="idx" href="consulting.html#goal_expansion/4">goal_expansion/4</a></dt>
12441287 <dd>
12451288 <a class="idx" href="consulting.html#idx:goalexpansion4:370">4.3</a></dd>
12461289 <dt><a class="idx" href="typetest.html#ground/1">ground/1</a></dt>
12471290 <dd>
1248 <a class="idx" href="cyclic.html#idx:ground1:240">2.17</a> <a class="idx" href="db.html#idx:ground1:867">4.14.6</a> <a class="idx" href="manipterm.html#idx:ground1:1210">4.21</a> <a class="idx" href="foreigninclude.html#idx:ground1:2017">11.4.3.1</a></dd>
1291 <a class="idx" href="cyclic.html#idx:ground1:240">2.17</a> <a class="idx" href="db.html#idx:ground1:867">4.14.6</a> <a class="idx" href="manipterm.html#idx:ground1:1210">4.21</a> <a class="idx" href="foreigninclude.html#idx:ground1:2021">11.4.3.1</a></dd>
12491292 <dt><a class="idx" href="solutionsequences.html#group_by/4">group_by/4</a></dt>
12501293 <dt><a class="idx" href="pairs.html#group_pairs_by_key/2">group_pairs_by_key/2</a></dt>
12511294 <dt><a class="idx" href="guitracer.html#gspy/1">gspy/1</a></dt>
12521295 <dt><a class="idx" href="guitracer.html#gtrace/0">gtrace/0</a></dt>
12531296 <dd>
1254 <a class="idx" href="thutil.html#idx:gtrace0:1941">9.5.1</a></dd>
1297 <a class="idx" href="thutil.html#idx:gtrace0:1945">9.5.1</a></dd>
12551298 <dt><a class="idx" href="guitracer.html#guitracer/0">guitracer/0</a></dt>
12561299 <dd>
12571300 <a class="idx" href="guitracer.html#idx:guitracer0:315">3.5.1</a> <a class="idx" href="guitracer.html#idx:guitracer0:321">3.5.1</a> <a class="idx" href="idesummary.html#idx:guitracer0:330">3.9</a> <a class="idx" href="debugger.html#idx:guitracer0:1541">4.39</a></dd>
12581301 <dt><a class="idx" href="xref.html#gxref/0">gxref/0</a></dt>
12591302 <dd>
1260 <a class="idx" href="help.html#idx:gxref0:52">2.6</a> <a class="idx" href="import.html#idx:gxref0:1684">6.3</a> <a class="idx" href="runtime.html#idx:gxref0:2108">12</a> <a class="idx" href="prolog_xref.html#idx:gxref0:2151">A.27</a></dd>
1303 <a class="idx" href="help.html#idx:gxref0:52">2.6</a> <a class="idx" href="import.html#idx:gxref0:1688">6.3</a> <a class="idx" href="runtime.html#idx:gxref0:2112">12</a> <a class="idx" href="prolog_xref.html#idx:gxref0:2155">A.27</a></dd>
12611304 <dt><a class="idx" href="toplevel.html#halt/0">halt/0</a></dt>
12621305 <dd>
1263 <a class="idx" href="quickstart.html#idx:halt0:17">2.1.5</a> <a class="idx" href="debugoverview.html#idx:halt0:68">2.9</a> <a class="idx" href="flags.html#idx:halt0:139">2.11</a> <a class="idx" href="consulting.html#idx:halt0:500">4.3</a> <a class="idx" href="consulting.html#idx:halt0:512">4.3</a> <a class="idx" href="predsummary.html#idx:halt0:2351">F.1</a></dd>
1306 <a class="idx" href="quickstart.html#idx:halt0:17">2.1.5</a> <a class="idx" href="debugoverview.html#idx:halt0:68">2.9</a> <a class="idx" href="flags.html#idx:halt0:139">2.11</a> <a class="idx" href="consulting.html#idx:halt0:500">4.3</a> <a class="idx" href="consulting.html#idx:halt0:512">4.3</a> <a class="idx" href="predsummary.html#idx:halt0:2355">F.1</a></dd>
12641307 <dt><a class="idx" href="toplevel.html#halt/1">halt/1</a></dt>
12651308 <dd>
1266 <a class="idx" href="flags.html#idx:halt1:107">2.11</a> <a class="idx" href="toplevel.html#idx:halt1:1529">4.37</a> <a class="idx" href="foreigninclude.html#idx:halt1:2063">11.4.16</a> <a class="idx" href="predsummary.html#idx:halt1:2349">F.1</a></dd>
1309 <a class="idx" href="flags.html#idx:halt1:107">2.11</a> <a class="idx" href="toplevel.html#idx:halt1:1529">4.37</a> <a class="idx" href="foreigninclude.html#idx:halt1:2067">11.4.16</a> <a class="idx" href="predsummary.html#idx:halt1:2353">F.1</a></dd>
12671310 <dt>halt/[0,1]</dt>
12681311 <dd>
12691312 <a class="idx" href="consulting.html#idx:halt01:498">4.3</a></dd>
12701313 <dt><a class="idx" href="error.html#has_type/2">has_type/2</a></dt>
12711314 <dt>hashing</dt>
12721315 <dd>
1273 <a class="idx" href="glossary.html#idx:hashing:2297">D</a></dd>
1316 <a class="idx" href="glossary.html#idx:hashing:2301">D</a></dd>
12741317 <dt>head</dt>
12751318 <dd>
1276 <a class="idx" href="glossary.html#idx:head:2298">D</a></dd>
1319 <a class="idx" href="glossary.html#idx:head:2302">D</a></dd>
12771320 <dt><a class="idx" href="help.html#help/0">help/0</a></dt>
12781321 <dd>
1279 <a class="idx" href="hooks.html#idx:help0:186">2.12</a> <a class="idx" href="useresource.html#idx:help0:2122">12.3</a> <a class="idx" href="intlibs.html#idx:help0:2230">B.7</a> <a class="idx" href="intlibs.html#idx:help0:2232">B.7</a></dd>
1322 <a class="idx" href="hooks.html#idx:help0:186">2.12</a> <a class="idx" href="useresource.html#idx:help0:2126">12.3</a> <a class="idx" href="intlibs.html#idx:help0:2234">B.7</a> <a class="idx" href="intlibs.html#idx:help0:2236">B.7</a></dd>
12801323 <dt><a class="idx" href="help.html#help/1">help/1</a></dt>
12811324 <dd>
1282 <a class="idx" href="help.html#idx:help1:48">2.6</a> <a class="idx" href="flags.html#idx:help1:162">2.11</a> <a class="idx" href="hooks.html#idx:help1:187">2.12</a> <a class="idx" href="intlibs.html#idx:help1:2231">B.7</a> <a class="idx" href="intlibs.html#idx:help1:2233">B.7</a> <a class="idx" href="intlibs.html#idx:help1:2234">B.7</a></dd>
1325 <a class="idx" href="help.html#idx:help1:48">2.6</a> <a class="idx" href="flags.html#idx:help1:162">2.11</a> <a class="idx" href="hooks.html#idx:help1:187">2.12</a> <a class="idx" href="intlibs.html#idx:help1:2235">B.7</a> <a class="idx" href="intlibs.html#idx:help1:2237">B.7</a> <a class="idx" href="intlibs.html#idx:help1:2238">B.7</a></dd>
12831326 <dt>hooks</dt>
12841327 <dd>
12851328 <a class="idx" href="hooks.html#idx:hooks:167">2.12</a></dd>
12981341 <a class="idx" href="consulting.html#idx:if1:487">4.3</a></dd>
12991342 <dt><a class="idx" href="metacall.html#ignore/1">ignore/1</a></dt>
13001343 <dd>
1301 <a class="idx" href="profile.html#idx:ignore1:1571">4.41.1</a> <a class="idx" href="threadcreate.html#idx:ignore1:1843">9.1</a></dd>
1344 <a class="idx" href="profile.html#idx:ignore1:1571">4.41.1</a> <a class="idx" href="threadcreate.html#idx:ignore1:1847">9.1</a></dd>
13021345 <dt>immediate, update view</dt>
13031346 <dd>
13041347 <a class="idx" href="db.html#idx:immediateupdateview:860">4.14.5</a></dd>
13051348 <dt><a class="idx" href="altmoduleapi.html#import/1">import/1</a></dt>
13061349 <dd>
1307 <a class="idx" href="altmoduleapi.html#idx:import1:1731">6.11</a> <a class="idx" href="dynamic-modules.html#idx:import1:1734">6.12</a></dd>
1350 <a class="idx" href="altmoduleapi.html#idx:import1:1735">6.11</a> <a class="idx" href="dynamic-modules.html#idx:import1:1738">6.12</a></dd>
13081351 <dt><a class="idx" href="importmodule.html#import_module/2">import_module/2</a></dt>
13091352 <dd>
1310 <a class="idx" href="examineprog.html#idx:importmodule2:903">4.16</a> <a class="idx" href="importmodule.html#idx:importmodule2:1722">6.9</a> <a class="idx" href="importmodule.html#idx:importmodule2:1723">6.9</a></dd>
1353 <a class="idx" href="examineprog.html#idx:importmodule2:903">4.16</a> <a class="idx" href="importmodule.html#idx:importmodule2:1726">6.9</a> <a class="idx" href="importmodule.html#idx:importmodule2:1727">6.9</a></dd>
13111354 <dt>imported predicate</dt>
13121355 <dd>
1313 <a class="idx" href="glossary.html#idx:importedpredicate:2299">D</a></dd>
1356 <a class="idx" href="glossary.html#idx:importedpredicate:2303">D</a></dd>
13141357 <dt><a class="idx" href="clpfd.html#in/2">in/2</a></dt>
13151358 <dt><a class="idx" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a></dt>
13161359 <dd>
1317 <a class="idx" href="mt-xpce.html#idx:inpcethread1:1956">9.7</a> <a class="idx" href="mt-xpce.html#idx:inpcethread1:1957">9.7</a> <a class="idx" href="mt-xpce.html#idx:inpcethread1:1958">9.7</a></dd>
1360 <a class="idx" href="mt-xpce.html#idx:inpcethread1:1960">9.7</a> <a class="idx" href="mt-xpce.html#idx:inpcethread1:1961">9.7</a> <a class="idx" href="mt-xpce.html#idx:inpcethread1:1962">9.7</a></dd>
13181361 <dt><a class="idx" href="mt-xpce.html#in_pce_thread_sync/1">in_pce_thread_sync/1</a></dt>
13191362 <dd>
1320 <a class="idx" href="mt-xpce.html#idx:inpcethreadsync1:1959">9.7</a> <a class="idx" href="mt-xpce.html#idx:inpcethreadsync1:1961">9.7</a></dd>
1363 <a class="idx" href="mt-xpce.html#idx:inpcethreadsync1:1963">9.7</a> <a class="idx" href="mt-xpce.html#idx:inpcethreadsync1:1965">9.7</a></dd>
13211364 <dt><a class="idx" href="consulting.html#include/1">include/1</a></dt>
13221365 <dd>
13231366 <a class="idx" href="consulting.html#idx:include1:362">4.3</a> <a class="idx" href="consulting.html#idx:include1:395">4.3</a> <a class="idx" href="consulting.html#idx:include1:437">4.3</a> <a class="idx" href="consulting.html#idx:include1:439">4.3</a> <a class="idx" href="consulting.html#idx:include1:440">4.3</a> <a class="idx" href="consulting.html#idx:include1:442">4.3</a> <a class="idx" href="consulting.html#idx:include1:443">4.3</a> <a class="idx" href="consulting.html#idx:include1:444">4.3</a> <a class="idx" href="consulting.html#idx:include1:475">4.3</a> <a class="idx" href="consulting.html#idx:include1:476">4.3</a> <a class="idx" href="consulting.html#idx:include1:479">4.3</a> <a class="idx" href="examineprog.html#idx:include1:945">4.16</a></dd>
13241367 <dt><a class="idx" href="apply.html#include/3">include/3</a></dt>
13251368 <dt>indexing</dt>
13261369 <dd>
1327 <a class="idx" href="glossary.html#idx:indexing:2301">D</a></dd>
1370 <a class="idx" href="glossary.html#idx:indexing:2305">D</a></dd>
13281371 <dt>indexing,term-hashes</dt>
13291372 <dd>
13301373 <a class="idx" href="db.html#idx:indexingtermhashes:864">4.14.6</a></dd>
13361379 <dt><a class="idx" href="consulting.html#initialization/0">initialization/0</a></dt>
13371380 <dt><a class="idx" href="consulting.html#initialization/1">initialization/1</a></dt>
13381381 <dd>
1339 <a class="idx" href="consulting.html#idx:initialization1:377">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:503">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:504">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:506">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:509">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:510">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:563">4.3.2</a> <a class="idx" href="consulting.html#idx:initialization1:574">4.3.2.2</a> <a class="idx" href="gvar.html#idx:initialization1:1417">4.33</a> <a class="idx" href="threadcreate.html#idx:initialization1:1863">9.1</a> <a class="idx" href="threadcreate.html#idx:initialization1:1864">9.1</a> <a class="idx" href="foreignlink.html#idx:initialization1:2011">11.2.2</a> <a class="idx" href="foreigninclude.html#idx:initialization1:2075">11.4.21</a> <a class="idx" href="qsavelimits.html#idx:initialization1:2113">12.1</a></dd>
1382 <a class="idx" href="consulting.html#idx:initialization1:377">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:503">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:504">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:506">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:509">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:510">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:563">4.3.2</a> <a class="idx" href="consulting.html#idx:initialization1:574">4.3.2.2</a> <a class="idx" href="gvar.html#idx:initialization1:1417">4.33</a> <a class="idx" href="threadcreate.html#idx:initialization1:1867">9.1</a> <a class="idx" href="threadcreate.html#idx:initialization1:1868">9.1</a> <a class="idx" href="foreignlink.html#idx:initialization1:2015">11.2.2</a> <a class="idx" href="foreigninclude.html#idx:initialization1:2079">11.4.21</a> <a class="idx" href="qsavelimits.html#idx:initialization1:2117">12.1</a></dd>
13401383 <dt><a class="idx" href="consulting.html#initialization/2">initialization/2</a></dt>
13411384 <dd>
13421385 <a class="idx" href="cmdline.html#idx:initialization2:33">2.4.2</a> <a class="idx" href="compilation.html#idx:initialization2:73">2.10.2.1</a> <a class="idx" href="flags.html#idx:initialization2:138">2.11</a> <a class="idx" href="consulting.html#idx:initialization2:564">4.3.2</a></dd>
13471390 <dt><a class="idx" href="db.html#instance/2">instance/2</a></dt>
13481391 <dt>instantiation</dt>
13491392 <dd>
1350 <a class="idx" href="glossary.html#idx:instantiation:2305">D</a></dd>
1393 <a class="idx" href="glossary.html#idx:instantiation:2309">D</a></dd>
13511394 <dt><a class="idx" href="error.html#instantiation_error/1">instantiation_error/1</a></dt>
13521395 <dd>
1353 <a class="idx" href="foreigninclude.html#idx:instantiationerror1:2028">11.4.6</a></dd>
1396 <a class="idx" href="foreigninclude.html#idx:instantiationerror1:2032">11.4.6</a></dd>
13541397 <dt>integer</dt>
13551398 <dd>
1356 <a class="idx" href="glossary.html#idx:integer:2302">D</a></dd>
1399 <a class="idx" href="glossary.html#idx:integer:2306">D</a></dd>
13571400 <dt>integer,unbounded</dt>
13581401 <dd>
13591402 <a class="idx" href="arith.html#idx:integerunbounded:1326">4.27.2.1</a></dd>
13711414 <a class="idx" href="widechars.html#idx:internationalization:265">2.19</a></dd>
13721415 <dt>interpreted</dt>
13731416 <dd>
1374 <a class="idx" href="glossary.html#idx:interpreted:2304">D</a></dd>
1417 <a class="idx" href="glossary.html#idx:interpreted:2308">D</a></dd>
13751418 <dt><a class="idx" href="lists.html#intersection/3">intersection/3</a></dt>
13761419 <dt><a class="idx" href="arith.html#is/2">is/2</a></dt>
13771420 <dd>
1378 <a class="idx" href="arith.html#idx:is2:1325">4.27.2</a> <a class="idx" href="arith.html#idx:is2:1330">4.27.2.1</a> <a class="idx" href="arith.html#idx:is2:1336">4.27.2.3</a> <a class="idx" href="sicstus-chr.html#idx:is2:1825">8.6.1</a></dd>
1421 <a class="idx" href="arith.html#idx:is2:1325">4.27.2</a> <a class="idx" href="arith.html#idx:is2:1330">4.27.2.1</a> <a class="idx" href="arith.html#idx:is2:1336">4.27.2.3</a> <a class="idx" href="sicstus-chr.html#idx:is2:1829">8.6.1</a></dd>
13791422 <dt><a class="idx" href="files.html#is_absolute_file_name/1">is_absolute_file_name/1</a></dt>
13801423 <dt><a class="idx" href="url.html#is_absolute_url/1">is_absolute_url/1</a></dt>
13811424 <dt><a class="idx" href="assoc.html#is_assoc/1">is_assoc/1</a></dt>
14021445 <a class="idx" href="jitindex.html#idx:jitindex:255">2.18</a></dd>
14031446 <dt><a class="idx" href="thutil.html#join_threads/0">join_threads/0</a></dt>
14041447 <dd>
1405 <a class="idx" href="thutil.html#idx:jointhreads0:1937">9.5</a></dd>
1448 <a class="idx" href="thutil.html#idx:jointhreads0:1941">9.5</a></dd>
14061449 <dt><a class="idx" href="builtinlist.html#keysort/2">keysort/2</a></dt>
14071450 <dd>
14081451 <a class="idx" href="builtinlist.html#idx:keysort2:1352">4.29</a> <a class="idx" href="builtinlist.html#idx:keysort2:1356">4.29</a> <a class="idx" href="builtinlist.html#idx:keysort2:1360">4.29</a></dd>
14091452 <dt><a class="idx" href="softlicense.html#known_licenses/0">known_licenses/0</a></dt>
14101453 <dd>
1411 <a class="idx" href="softlicense.html#idx:knownlicenses0:2341">E.2</a></dd>
1454 <a class="idx" href="softlicense.html#idx:knownlicenses0:2345">E.2</a></dd>
14121455 <dt><a class="idx" href="clpfd.html#label/1">label/1</a></dt>
14131456 <dt><a class="idx" href="clpb.html#labeling/1">labeling/1</a></dt>
14141457 <dt><a class="idx" href="clpfd.html#labeling/2">labeling/2</a></dt>
14151458 <dt><a class="idx" href="yall.html#lambda_calls/2">lambda_calls/2</a></dt>
14161459 <dt><a class="idx" href="yall.html#lambda_calls/3">lambda_calls/3</a></dt>
14171460 <dt><a class="idx" href="lists.html#last/2">last/2</a></dt>
1418 <dt><a class="idx" href="pio.html#lazy_list_character_count/1">lazy_list_character_count/1</a></dt>
1419 <dt><a class="idx" href="pio.html#lazy_list_location/1">lazy_list_location/1</a></dt>
1461 <dt><a class="idx" href="pio.html#lazy_list_character_count//1">lazy_list_character_count//1</a></dt>
1462 <dt><a class="idx" href="pio.html#lazy_list_location//1">lazy_list_location//1</a></dt>
14201463 <dt><a class="idx" href="debugger.html#leash/1">leash/1</a></dt>
14211464 <dd>
1422 <a class="idx" href="debugoverview.html#idx:leash1:60">2.9</a> <a class="idx" href="debugger.html#idx:leash1:1557">4.39</a> <a class="idx" href="debugging.html#idx:leash1:1822">8.4.3</a> <a class="idx" href="tracehook.html#idx:leash1:2189">B.3</a></dd>
1465 <a class="idx" href="debugoverview.html#idx:leash1:60">2.9</a> <a class="idx" href="debugger.html#idx:leash1:1557">4.39</a> <a class="idx" href="debugging.html#idx:leash1:1826">8.4.3</a> <a class="idx" href="tracehook.html#idx:leash1:2193">B.3</a></dd>
14231466 <dt><a class="idx" href="builtinlist.html#length/2">length/2</a></dt>
14241467 <dd>
14251468 <a class="idx" href="dicts.html#idx:length2:1635">5.4.1.1</a></dd>
14291472 <a class="idx" href="autoload.html#idx:librarydirectory1:189">2.13</a> <a class="idx" href="autoload.html#idx:librarydirectory1:195">2.13</a> <a class="idx" href="autoload.html#idx:librarydirectory1:199">2.13</a> <a class="idx" href="autoload.html#idx:librarydirectory1:201">2.13</a></dd>
14301473 <dt><a class="idx" href="softlicense.html#license/0">license/0</a></dt>
14311474 <dd>
1432 <a class="idx" href="softlicense.html#idx:license0:2340">E.2</a></dd>
1475 <a class="idx" href="softlicense.html#idx:license0:2344">E.2</a></dd>
14331476 <dt><a class="idx" href="softlicense.html#license/1">license/1</a></dt>
14341477 <dd>
1435 <a class="idx" href="contrib.html#idx:license1:2339">E.1</a></dd>
1478 <a class="idx" href="contrib.html#idx:license1:2343">E.1</a></dd>
14361479 <dt><a class="idx" href="softlicense.html#license/2">license/2</a></dt>
14371480 <dd>
1438 <a class="idx" href="softlicense.html#idx:license2:2342">E.2</a> <a class="idx" href="softlicense.html#idx:license2:2343">E.2</a></dd>
1481 <a class="idx" href="softlicense.html#idx:license2:2346">E.2</a> <a class="idx" href="softlicense.html#idx:license2:2347">E.2</a></dd>
14391482 <dt><a class="idx" href="solutionsequences.html#limit/2">limit/2</a></dt>
14401483 <dt><a class="idx" href="streamstat.html#line_count/2">line_count/2</a></dt>
14411484 <dd>
14521495 <dt><a class="idx" href="check.html#list_strings/1">list_strings/1</a></dt>
14531496 <dt><a class="idx" href="assoc.html#list_to_assoc/2">list_to_assoc/2</a></dt>
14541497 <dd>
1455 <a class="idx" href="dicts.html#idx:listtoassoc2:1651">5.4.3</a></dd>
1498 <a class="idx" href="dicts.html#idx:listtoassoc2:1655">5.4.3</a></dd>
14561499 <dt><a class="idx" href="ordsets.html#list_to_ord_set/2">list_to_ord_set/2</a></dt>
14571500 <dt><a class="idx" href="lists.html#list_to_set/2">list_to_set/2</a></dt>
14581501 <dt><a class="idx" href="check.html#list_trivial_fails/0">list_trivial_fails/0</a></dt>
14641507 <dt><a class="idx" href="check.html#list_void_declarations/0">list_void_declarations/0</a></dt>
14651508 <dt><a class="idx" href="broadcast.html#listen/2">listen/2</a></dt>
14661509 <dd>
1467 <a class="idx" href="broadcast.html#idx:listen2:2139">A.4</a></dd>
1510 <a class="idx" href="broadcast.html#idx:listen2:2143">A.4</a></dd>
14681511 <dt><a class="idx" href="broadcast.html#listen/3">listen/3</a></dt>
14691512 <dd>
1470 <a class="idx" href="broadcast.html#idx:listen3:2141">A.4</a> <a class="idx" href="broadcast.html#idx:listen3:2142">A.4</a> <a class="idx" href="broadcast.html#idx:listen3:2143">A.4</a></dd>
1513 <a class="idx" href="broadcast.html#idx:listen3:2145">A.4</a> <a class="idx" href="broadcast.html#idx:listen3:2146">A.4</a> <a class="idx" href="broadcast.html#idx:listen3:2147">A.4</a></dd>
14711514 <dt><a class="idx" href="broadcast.html#listening/3">listening/3</a></dt>
14721515 <dt><a class="idx" href="listing.html#listing/0">listing/0</a></dt>
14731516 <dd>
14781521 <dt><a class="idx" href="consulting.html#load_files/1">load_files/1</a></dt>
14791522 <dt><a class="idx" href="consulting.html#load_files/2">load_files/2</a></dt>
14801523 <dd>
1481 <a class="idx" href="flags.html#idx:loadfiles2:130">2.11</a> <a class="idx" href="flags.html#idx:loadfiles2:132">2.11</a> <a class="idx" href="flags.html#idx:loadfiles2:154">2.11</a> <a class="idx" href="hooks.html#idx:loadfiles2:173">2.12</a> <a class="idx" href="hooks.html#idx:loadfiles2:175">2.12</a> <a class="idx" href="hooks.html#idx:loadfiles2:176">2.12</a> <a class="idx" href="widechars.html#idx:loadfiles2:268">2.19.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:379">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:385">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:393">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:394">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:396">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:413">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:423">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:425">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:428">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:477">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:478">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:480">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:481">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:483">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:567">4.3.2.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:570">4.3.2.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:573">4.3.2.2</a> <a class="idx" href="consulting.html#idx:loadfiles2:575">4.3.2.2</a> <a class="idx" href="consulting.html#idx:loadfiles2:584">4.3.3</a> <a class="idx" href="debugger.html#idx:loadfiles2:1559">4.39</a> <a class="idx" href="import.html#idx:loadfiles2:1676">6.3</a> <a class="idx" href="prolog_xref.html#idx:loadfiles2:2152">A.27</a> <a class="idx" href="loadfilehook.html#idx:loadfiles2:2236">B.8</a> <a class="idx" href="loadfilehook.html#idx:loadfiles2:2238">B.8</a> <a class="idx" href="dialect.html#idx:loadfiles2:2255">C</a> <a class="idx" href="predsummary.html#idx:loadfiles2:2366">F.1</a></dd>
1524 <a class="idx" href="flags.html#idx:loadfiles2:130">2.11</a> <a class="idx" href="flags.html#idx:loadfiles2:132">2.11</a> <a class="idx" href="flags.html#idx:loadfiles2:154">2.11</a> <a class="idx" href="hooks.html#idx:loadfiles2:173">2.12</a> <a class="idx" href="hooks.html#idx:loadfiles2:175">2.12</a> <a class="idx" href="hooks.html#idx:loadfiles2:176">2.12</a> <a class="idx" href="widechars.html#idx:loadfiles2:268">2.19.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:379">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:385">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:393">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:394">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:396">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:413">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:423">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:425">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:428">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:477">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:478">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:480">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:481">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:483">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:567">4.3.2.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:570">4.3.2.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:573">4.3.2.2</a> <a class="idx" href="consulting.html#idx:loadfiles2:575">4.3.2.2</a> <a class="idx" href="consulting.html#idx:loadfiles2:584">4.3.3</a> <a class="idx" href="debugger.html#idx:loadfiles2:1559">4.39</a> <a class="idx" href="import.html#idx:loadfiles2:1680">6.3</a> <a class="idx" href="prolog_xref.html#idx:loadfiles2:2156">A.27</a> <a class="idx" href="loadfilehook.html#idx:loadfiles2:2240">B.8</a> <a class="idx" href="loadfilehook.html#idx:loadfiles2:2242">B.8</a> <a class="idx" href="dialect.html#idx:loadfiles2:2259">C</a> <a class="idx" href="predsummary.html#idx:loadfiles2:2370">F.1</a></dd>
14821525 <dt><a class="idx" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a></dt>
14831526 <dd>
1484 <a class="idx" href="consulting.html#idx:loadforeignlibrary1:507">4.3</a> <a class="idx" href="foreignlink.html#idx:loadforeignlibrary1:2013">11.2.4</a> <a class="idx" href="plld.html#idx:loadforeignlibrary1:2087">11.5</a> <a class="idx" href="qsaveforeign.html#idx:loadforeignlibrary1:2116">12.2</a></dd>
1527 <a class="idx" href="consulting.html#idx:loadforeignlibrary1:507">4.3</a> <a class="idx" href="foreignlink.html#idx:loadforeignlibrary1:2017">11.2.4</a> <a class="idx" href="plld.html#idx:loadforeignlibrary1:2091">11.5</a> <a class="idx" href="qsaveforeign.html#idx:loadforeignlibrary1:2120">12.2</a></dd>
14851528 <dt><a class="idx" href="foreignlink.html#load_foreign_library/2">load_foreign_library/2</a></dt>
14861529 <dt>locale</dt>
14871530 <dd>
14991542 <dt>logical,update view</dt>
15001543 <dd>
15011544 <a class="idx" href="db.html#idx:logicalupdateview:859">4.14.5</a></dd>
1545 <dt><a class="idx" href="dicts.html#m-get-1">m-get-1</a></dt>
1546 <dt><a class="idx" href="dicts.html#m-put-1">m-put-1</a></dt>
1547 <dt><a class="idx" href="dicts.html#m-put-2">m-put-2</a></dt>
15021548 <dt><a class="idx" href="main.html#main/0">main/0</a></dt>
15031549 <dd>
15041550 <a class="idx" href="compilation.html#idx:main0:74">2.10.2.1</a></dd>
15251571 <dt><a class="idx" href="pairs.html#map_list_to_pairs/3">map_list_to_pairs/3</a></dt>
15261572 <dt><a class="idx" href="apply.html#maplist/2">maplist/2</a></dt>
15271573 <dd>
1528 <a class="idx" href="forall2.html#idx:maplist2:1380">4.31</a> <a class="idx" href="ext-issues.html#idx:maplist2:1657">5.6</a></dd>
1574 <a class="idx" href="forall2.html#idx:maplist2:1380">4.31</a> <a class="idx" href="ext-issues.html#idx:maplist2:1661">5.6</a></dd>
15291575 <dt><a class="idx" href="apply.html#maplist/3">maplist/3</a></dt>
15301576 <dd>
1531 <a class="idx" href="dicts.html#idx:maplist3:1650">5.4.3</a> <a class="idx" href="metapred.html#idx:maplist3:1688">6.4</a> <a class="idx" href="metapred.html#idx:maplist3:1690">6.4</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1737">6.13</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1738">6.13</a></dd>
1577 <a class="idx" href="dicts.html#idx:maplist3:1654">5.4.3</a> <a class="idx" href="metapred.html#idx:maplist3:1692">6.4</a> <a class="idx" href="metapred.html#idx:maplist3:1694">6.4</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1741">6.13</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1742">6.13</a></dd>
15321578 <dt><a class="idx" href="apply.html#maplist/4">maplist/4</a></dt>
15331579 <dt><a class="idx" href="apply.html#maplist/5">maplist/5</a></dt>
15341580 <dt>maplist_/3</dt>
15351581 <dd>
1536 <a class="idx" href="metapred.html#idx:maplist3:1689">6.4</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1739">6.13</a></dd>
1582 <a class="idx" href="metapred.html#idx:maplist3:1693">6.4</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1743">6.13</a></dd>
15371583 <dt><a class="idx" href="assoc.html#max_assoc/3">max_assoc/3</a></dt>
15381584 <dt><a class="idx" href="lists.html#max_list/2">max_list/2</a></dt>
15391585 <dt><a class="idx" href="lists.html#max_member/2">max_member/2</a></dt>
15451591 <dt><a class="idx" href="random.html#maybe/2">maybe/2</a></dt>
15461592 <dt><a class="idx" href="lists.html#member/2">member/2</a></dt>
15471593 <dd>
1548 <a class="idx" href="debugoverview.html#idx:member2:63">2.9</a> <a class="idx" href="debugoverview.html#idx:member2:64">2.9</a> <a class="idx" href="metacall.html#idx:member2:669">4.9</a> <a class="idx" href="builtinlist.html#idx:member2:1345">4.29</a> <a class="idx" href="files.html#idx:member2:1512">4.36</a> <a class="idx" href="import.html#idx:member2:1677">6.3</a> <a class="idx" href="predsummary.html#idx:member2:2358">F.1</a></dd>
1594 <a class="idx" href="debugoverview.html#idx:member2:63">2.9</a> <a class="idx" href="debugoverview.html#idx:member2:64">2.9</a> <a class="idx" href="metacall.html#idx:member2:669">4.9</a> <a class="idx" href="builtinlist.html#idx:member2:1345">4.29</a> <a class="idx" href="files.html#idx:member2:1512">4.36</a> <a class="idx" href="import.html#idx:member2:1681">6.3</a> <a class="idx" href="predsummary.html#idx:member2:2362">F.1</a></dd>
15491595 <dt><a class="idx" href="builtinlist.html#memberchk/2">memberchk/2</a></dt>
15501596 <dd>
15511597 <a class="idx" href="compare.html#idx:memberchk2:639">4.7.2</a> <a class="idx" href="builtinlist.html#idx:memberchk2:1346">4.29</a> <a class="idx" href="builtinlist.html#idx:memberchk2:1347">4.29</a> <a class="idx" href="strings.html#idx:memberchk2:1623">5.2.4</a></dd>
15551601 <dt><a class="idx" href="option.html#merge_options/3">merge_options/3</a></dt>
15561602 <dt>message,service</dt>
15571603 <dd>
1558 <a class="idx" href="broadcast.html#idx:messageservice:2133">A.4</a></dd>
1604 <a class="idx" href="broadcast.html#idx:messageservice:2137">A.4</a></dd>
15591605 <dt><a class="idx" href="exception.html#message_hook/3">message_hook/3</a></dt>
15601606 <dd>
1561 <a class="idx" href="exception.html#idx:messagehook3:732">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:735">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:738">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:742">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:743">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:752">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:757">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:759">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:772">4.11.4.1</a> <a class="idx" href="memory.html#idx:messagehook3:1581">4.42</a> <a class="idx" href="predsummary.html#idx:messagehook3:2369">F.1</a></dd>
1607 <a class="idx" href="exception.html#idx:messagehook3:732">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:735">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:738">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:742">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:743">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:752">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:757">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:759">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:772">4.11.4.1</a> <a class="idx" href="memory.html#idx:messagehook3:1581">4.42</a> <a class="idx" href="predsummary.html#idx:messagehook3:2373">F.1</a></dd>
15621608 <dt><a class="idx" href="exception.html#message_property/2">message_property/2</a></dt>
15631609 <dd>
15641610 <a class="idx" href="flags.html#idx:messageproperty2:94">2.11</a></dd>
15651611 <dt><a class="idx" href="threadcom.html#message_queue_create/1">message_queue_create/1</a></dt>
15661612 <dd>
1567 <a class="idx" href="threadcom.html#idx:messagequeuecreate1:1882">9.3.1</a> <a class="idx" href="threadcom.html#idx:messagequeuecreate1:1897">9.3.1</a></dd>
1613 <a class="idx" href="threadcom.html#idx:messagequeuecreate1:1886">9.3.1</a> <a class="idx" href="threadcom.html#idx:messagequeuecreate1:1901">9.3.1</a></dd>
15681614 <dt><a class="idx" href="threadcom.html#message_queue_create/2">message_queue_create/2</a></dt>
15691615 <dd>
1570 <a class="idx" href="threadcom.html#idx:messagequeuecreate2:1895">9.3.1</a> <a class="idx" href="threadcom.html#idx:messagequeuecreate2:1908">9.3.1</a></dd>
1616 <a class="idx" href="threadcom.html#idx:messagequeuecreate2:1899">9.3.1</a> <a class="idx" href="threadcom.html#idx:messagequeuecreate2:1912">9.3.1</a></dd>
15711617 <dt>message_queue_create/3</dt>
15721618 <dd>
1573 <a class="idx" href="threadsync.html#idx:messagequeuecreate3:1924">9.4</a></dd>
1619 <a class="idx" href="threadsync.html#idx:messagequeuecreate3:1928">9.4</a></dd>
15741620 <dt><a class="idx" href="threadcom.html#message_queue_destroy/1">message_queue_destroy/1</a></dt>
15751621 <dd>
1576 <a class="idx" href="threadcom.html#idx:messagequeuedestroy1:1900">9.3.1</a></dd>
1622 <a class="idx" href="threadcom.html#idx:messagequeuedestroy1:1904">9.3.1</a></dd>
15771623 <dt><a class="idx" href="threadcom.html#message_queue_property/2">message_queue_property/2</a></dt>
15781624 <dd>
1579 <a class="idx" href="thmonitor.html#idx:messagequeueproperty2:1879">9.2</a></dd>
1625 <a class="idx" href="thmonitor.html#idx:messagequeueproperty2:1883">9.2</a></dd>
15801626 <dt><a class="idx" href="exception.html#message_to_string/2">message_to_string/2</a></dt>
15811627 <dd>
15821628 <a class="idx" href="exception.html#idx:messagetostring2:745">4.11.4</a> <a class="idx" href="exception.html#idx:messagetostring2:756">4.11.4</a></dd>
15831629 <dt>meta-predicate</dt>
15841630 <dd>
1585 <a class="idx" href="glossary.html#idx:metapredicate:2306">D</a></dd>
1631 <a class="idx" href="glossary.html#idx:metapredicate:2310">D</a></dd>
15861632 <dt><a class="idx" href="option.html#meta_options/3">meta_options/3</a></dt>
15871633 <dd>
1588 <a class="idx" href="import.html#idx:metaoptions3:1679">6.3</a></dd>
1634 <a class="idx" href="import.html#idx:metaoptions3:1683">6.3</a></dd>
15891635 <dt><a class="idx" href="metapred.html#meta_predicate/1">meta_predicate/1</a></dt>
15901636 <dd>
1591 <a class="idx" href="flags.html#idx:metapredicate1:96">2.11</a> <a class="idx" href="consulting.html#idx:metapredicate1:540">4.3.1</a> <a class="idx" href="typetest.html#idx:metapredicate1:615">4.6</a> <a class="idx" href="examineprog.html#idx:metapredicate1:923">4.16</a> <a class="idx" href="examineprog.html#idx:metapredicate1:924">4.16</a> <a class="idx" href="examineprog.html#idx:metapredicate1:930">4.16</a> <a class="idx" href="metapred.html#idx:metapredicate1:1687">6.4</a> <a class="idx" href="metapred.html#idx:metapredicate1:1691">6.4</a> <a class="idx" href="metapred.html#idx:metapredicate1:1698">6.4</a> <a class="idx" href="ctxmodule.html#idx:metapredicate1:1736">6.13</a> <a class="idx" href="modulecompat.html#idx:metapredicate1:1754">6.15</a> <a class="idx" href="modulecompat.html#idx:metapredicate1:1755">6.15</a> <a class="idx" href="foreigninclude.html#idx:metapredicate1:2041">11.4.9.2</a> <a class="idx" href="foreigninclude.html#idx:metapredicate1:2067">11.4.18</a> <a class="idx" href="runtime.html#idx:metapredicate1:2106">12</a> <a class="idx" href="runtime.html#idx:metapredicate1:2109">12</a></dd>
1637 <a class="idx" href="flags.html#idx:metapredicate1:96">2.11</a> <a class="idx" href="consulting.html#idx:metapredicate1:540">4.3.1</a> <a class="idx" href="typetest.html#idx:metapredicate1:615">4.6</a> <a class="idx" href="examineprog.html#idx:metapredicate1:923">4.16</a> <a class="idx" href="examineprog.html#idx:metapredicate1:924">4.16</a> <a class="idx" href="examineprog.html#idx:metapredicate1:930">4.16</a> <a class="idx" href="metapred.html#idx:metapredicate1:1691">6.4</a> <a class="idx" href="metapred.html#idx:metapredicate1:1695">6.4</a> <a class="idx" href="metapred.html#idx:metapredicate1:1702">6.4</a> <a class="idx" href="ctxmodule.html#idx:metapredicate1:1740">6.13</a> <a class="idx" href="modulecompat.html#idx:metapredicate1:1758">6.15</a> <a class="idx" href="modulecompat.html#idx:metapredicate1:1759">6.15</a> <a class="idx" href="foreigninclude.html#idx:metapredicate1:2045">11.4.9.2</a> <a class="idx" href="foreigninclude.html#idx:metapredicate1:2071">11.4.18</a> <a class="idx" href="runtime.html#idx:metapredicate1:2110">12</a> <a class="idx" href="runtime.html#idx:metapredicate1:2113">12</a></dd>
15921638 <dt>mild/1</dt>
15931639 <dd>
15941640 <a class="idx" href="quickstart.html#idx:mild1:15">2.1.4</a></dd>
15991645 <dt><a class="idx" href="simplex.html#minimize/3">minimize/3</a></dt>
16001646 <dt>mode</dt>
16011647 <dd>
1602 <a class="idx" href="glossary.html#idx:mode:2307">D</a></dd>
1648 <a class="idx" href="glossary.html#idx:mode:2311">D</a></dd>
16031649 <dt>module</dt>
16041650 <dd>
1605 <a class="idx" href="glossary.html#idx:module:2308">D</a></dd>
1651 <a class="idx" href="glossary.html#idx:module:2312">D</a></dd>
16061652 <dt>module transparent</dt>
16071653 <dd>
1608 <a class="idx" href="glossary.html#idx:moduletransparent:2309">D</a></dd>
1654 <a class="idx" href="glossary.html#idx:moduletransparent:2313">D</a></dd>
16091655 <dt>module,contex</dt>
16101656 <dd>
1611 <a class="idx" href="glossary.html#idx:modulecontex:2282">D</a></dd>
1657 <a class="idx" href="glossary.html#idx:modulecontex:2286">D</a></dd>
16121658 <dt><a class="idx" href="mtoplevel.html#module/1">module/1</a></dt>
16131659 <dd>
1614 <a class="idx" href="flags.html#idx:module1:142">2.11</a> <a class="idx" href="consulting.html#idx:module1:358">4.3</a> <a class="idx" href="dynamic.html#idx:module1:893">4.15</a> <a class="idx" href="mtoplevel.html#idx:module1:1707">6.6</a> <a class="idx" href="threadcreate.html#idx:module1:1847">9.1</a></dd>
1660 <a class="idx" href="flags.html#idx:module1:142">2.11</a> <a class="idx" href="consulting.html#idx:module1:358">4.3</a> <a class="idx" href="dynamic.html#idx:module1:893">4.15</a> <a class="idx" href="mtoplevel.html#idx:module1:1711">6.6</a> <a class="idx" href="threadcreate.html#idx:module1:1851">9.1</a></dd>
16151661 <dt><a class="idx" href="defmodule.html#module/2">module/2</a></dt>
16161662 <dd>
1617 <a class="idx" href="consulting.html#idx:module2:521">4.3.1</a> <a class="idx" href="operators.html#idx:module2:1315">4.25</a> <a class="idx" href="operators.html#idx:module2:1316">4.25</a> <a class="idx" href="defmodule.html#idx:module2:1660">6.2</a> <a class="idx" href="defmodule.html#idx:module2:1661">6.2</a> <a class="idx" href="defmodule.html#idx:module2:1664">6.2</a> <a class="idx" href="import.html#idx:module2:1681">6.3</a> <a class="idx" href="moduleop.html#idx:module2:1717">6.8</a> <a class="idx" href="altmoduleapi.html#idx:module2:1728">6.11</a> <a class="idx" href="modulecompat.html#idx:module2:1756">6.15</a></dd>
1663 <a class="idx" href="consulting.html#idx:module2:521">4.3.1</a> <a class="idx" href="operators.html#idx:module2:1315">4.25</a> <a class="idx" href="operators.html#idx:module2:1316">4.25</a> <a class="idx" href="defmodule.html#idx:module2:1664">6.2</a> <a class="idx" href="defmodule.html#idx:module2:1665">6.2</a> <a class="idx" href="defmodule.html#idx:module2:1668">6.2</a> <a class="idx" href="import.html#idx:module2:1685">6.3</a> <a class="idx" href="moduleop.html#idx:module2:1721">6.8</a> <a class="idx" href="altmoduleapi.html#idx:module2:1732">6.11</a> <a class="idx" href="modulecompat.html#idx:module2:1760">6.15</a></dd>
16181664 <dt><a class="idx" href="defmodule.html#module/3">module/3</a></dt>
16191665 <dt><a class="idx" href="manipmodule.html#module_property/2">module_property/2</a></dt>
16201666 <dd>
1621 <a class="idx" href="manipmodule.html#idx:moduleproperty2:1749">6.14</a> <a class="idx" href="manipmodule.html#idx:moduleproperty2:1751">6.14</a></dd>
1667 <a class="idx" href="manipmodule.html#idx:moduleproperty2:1753">6.14</a> <a class="idx" href="manipmodule.html#idx:moduleproperty2:1755">6.14</a></dd>
16221668 <dt><a class="idx" href="ctxmodule.html#module_transparent/1">module_transparent/1</a></dt>
16231669 <dd>
1624 <a class="idx" href="examineprog.html#idx:moduletransparent1:929">4.16</a> <a class="idx" href="metapred.html#idx:moduletransparent1:1699">6.4</a> <a class="idx" href="overrule.html#idx:moduletransparent1:1703">6.5.1</a> <a class="idx" href="modulecompat.html#idx:moduletransparent1:1752">6.15</a> <a class="idx" href="foreigninclude.html#idx:moduletransparent1:2043">11.4.9.2</a> <a class="idx" href="glossary.html#idx:moduletransparent1:2283">D</a></dd>
1670 <a class="idx" href="examineprog.html#idx:moduletransparent1:929">4.16</a> <a class="idx" href="metapred.html#idx:moduletransparent1:1703">6.4</a> <a class="idx" href="overrule.html#idx:moduletransparent1:1707">6.5.1</a> <a class="idx" href="modulecompat.html#idx:moduletransparent1:1756">6.15</a> <a class="idx" href="foreigninclude.html#idx:moduletransparent1:2047">11.4.9.2</a> <a class="idx" href="glossary.html#idx:moduletransparent1:2287">D</a></dd>
16251671 <dt><a class="idx" href="builtinlist.html#msort/2">msort/2</a></dt>
16261672 <dd>
16271673 <a class="idx" href="builtinlist.html#idx:msort2:1351">4.29</a></dd>
16281674 <dt>multi</dt>
16291675 <dd>
1630 <a class="idx" href="glossary.html#idx:multi:2311">D</a></dd>
1676 <a class="idx" href="glossary.html#idx:multi:2315">D</a></dd>
16311677 <dt><a class="idx" href="dynamic.html#multifile/1">multifile/1</a></dt>
16321678 <dd>
1633 <a class="idx" href="flags.html#idx:multifile1:149">2.11</a> <a class="idx" href="consulting.html#idx:multifile1:435">4.3</a> <a class="idx" href="consulting.html#idx:multifile1:446">4.3</a> <a class="idx" href="dynamic.html#idx:multifile1:876">4.15</a> <a class="idx" href="examineprog.html#idx:multifile1:922">4.16</a> <a class="idx" href="intlibs.html#idx:multifile1:2220">B.7</a> <a class="idx" href="glossary.html#idx:multifile1:2312">D</a></dd>
1679 <a class="idx" href="flags.html#idx:multifile1:149">2.11</a> <a class="idx" href="consulting.html#idx:multifile1:435">4.3</a> <a class="idx" href="consulting.html#idx:multifile1:446">4.3</a> <a class="idx" href="dynamic.html#idx:multifile1:876">4.15</a> <a class="idx" href="examineprog.html#idx:multifile1:922">4.16</a> <a class="idx" href="intlibs.html#idx:multifile1:2224">B.7</a> <a class="idx" href="glossary.html#idx:multifile1:2316">D</a></dd>
16341680 <dt><a class="idx" href="error.html#must_be/2">must_be/2</a></dt>
16351681 <dd>
1636 <a class="idx" href="record.html#idx:mustbe2:2166">A.31</a></dd>
1682 <a class="idx" href="record.html#idx:mustbe2:2170">A.31</a></dd>
16371683 <dt><a class="idx" href="threadsync.html#mutex_create/1">mutex_create/1</a></dt>
16381684 <dd>
1639 <a class="idx" href="threadsync.html#idx:mutexcreate1:1926">9.4</a> <a class="idx" href="threadsync.html#idx:mutexcreate1:1929">9.4</a></dd>
1685 <a class="idx" href="threadsync.html#idx:mutexcreate1:1930">9.4</a> <a class="idx" href="threadsync.html#idx:mutexcreate1:1933">9.4</a></dd>
16401686 <dt><a class="idx" href="threadsync.html#mutex_create/2">mutex_create/2</a></dt>
16411687 <dd>
1642 <a class="idx" href="threadsync.html#idx:mutexcreate2:1936">9.4</a></dd>
1688 <a class="idx" href="threadsync.html#idx:mutexcreate2:1940">9.4</a></dd>
16431689 <dt><a class="idx" href="threadsync.html#mutex_destroy/1">mutex_destroy/1</a></dt>
16441690 <dt><a class="idx" href="threadsync.html#mutex_lock/1">mutex_lock/1</a></dt>
16451691 <dd>
1646 <a class="idx" href="threadsync.html#idx:mutexlock1:1932">9.4</a></dd>
1692 <a class="idx" href="threadsync.html#idx:mutexlock1:1936">9.4</a></dd>
16471693 <dt><a class="idx" href="threadsync.html#mutex_property/2">mutex_property/2</a></dt>
16481694 <dt><a class="idx" href="thmonitor.html#mutex_statistics/0">mutex_statistics/0</a></dt>
16491695 <dt><a class="idx" href="threadsync.html#mutex_trylock/1">mutex_trylock/1</a></dt>
16511697 <dt><a class="idx" href="threadsync.html#mutex_unlock_all/0">mutex_unlock_all/0</a></dt>
16521698 <dt>my_compare/3</dt>
16531699 <dd>
1654 <a class="idx" href="portabilitystrategies.html#idx:mycompare3:2262">C.1</a></dd>
1700 <a class="idx" href="portabilitystrategies.html#idx:mycompare3:2266">C.1</a></dd>
16551701 <dt>mypred/1</dt>
16561702 <dd>
1657 <a class="idx" href="reexport.html#idx:mypred1:1713">6.7</a></dd>
1703 <a class="idx" href="reexport.html#idx:mypred1:1717">6.7</a></dd>
16581704 <dt>name/1</dt>
16591705 <dd>
1660 <a class="idx" href="metapred.html#idx:name1:1685">6.4</a></dd>
1706 <a class="idx" href="metapred.html#idx:name1:1689">6.4</a></dd>
16611707 <dt><a class="idx" href="manipatom.html#name/2">name/2</a></dt>
16621708 <dd>
16631709 <a class="idx" href="manipatom.html#idx:name2:1242">4.22</a> <a class="idx" href="manipatom.html#idx:name2:1245">4.22</a></dd>
16641710 <dt>name_of/2</dt>
16651711 <dd>
1666 <a class="idx" href="broadcast.html#idx:nameof2:2140">A.4</a></dd>
1712 <a class="idx" href="broadcast.html#idx:nameof2:2144">A.4</a></dd>
16671713 <dt><a class="idx" href="gvar.html#nb_current/2">nb_current/2</a></dt>
16681714 <dd>
16691715 <a class="idx" href="gvar.html#idx:nbcurrent2:1426">4.33</a> <a class="idx" href="gvar.html#idx:nbcurrent2:1428">4.33</a></dd>
16741720 <dt><a class="idx" href="dicts.html#nb_link_dict/3">nb_link_dict/3</a></dt>
16751721 <dt><a class="idx" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a></dt>
16761722 <dd>
1677 <a class="idx" href="manipterm.html#idx:nblinkarg3:1228">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkarg3:1238">4.21.1</a> <a class="idx" href="dicts.html#idx:nblinkarg3:1644">5.4.2.1</a></dd>
1723 <a class="idx" href="manipterm.html#idx:nblinkarg3:1228">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkarg3:1238">4.21.1</a> <a class="idx" href="dicts.html#idx:nblinkarg3:1648">5.4.2.1</a></dd>
16781724 <dt><a class="idx" href="gvar.html#nb_linkval/2">nb_linkval/2</a></dt>
16791725 <dd>
1680 <a class="idx" href="manipterm.html#idx:nblinkval2:1231">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkval2:1232">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkval2:1236">4.21.1</a> <a class="idx" href="gvar.html#idx:nblinkval2:1431">4.33.1</a> <a class="idx" href="dicts.html#idx:nblinkval2:1645">5.4.2.1</a> <a class="idx" href="dicts.html#idx:nblinkval2:1646">5.4.2.1</a></dd>
1726 <a class="idx" href="manipterm.html#idx:nblinkval2:1231">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkval2:1232">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkval2:1236">4.21.1</a> <a class="idx" href="gvar.html#idx:nblinkval2:1431">4.33.1</a> <a class="idx" href="dicts.html#idx:nblinkval2:1649">5.4.2.1</a> <a class="idx" href="dicts.html#idx:nblinkval2:1650">5.4.2.1</a></dd>
16811727 <dt><a class="idx" href="dicts.html#nb_set_dict/3">nb_set_dict/3</a></dt>
16821728 <dt><a class="idx" href="nb_set.html#nb_set_to_list/2">nb_set_to_list/2</a></dt>
16831729 <dt><a class="idx" href="manipterm.html#nb_setarg/3">nb_setarg/3</a></dt>
16841730 <dd>
1685 <a class="idx" href="preddesc.html#idx:nbsetarg3:336">4.1</a> <a class="idx" href="db.html#idx:nbsetarg3:812">4.14</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1219">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1230">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1237">4.21.1</a> <a class="idx" href="allsolutions.html#idx:nbsetarg3:1367">4.30</a> <a class="idx" href="dicts.html#idx:nbsetarg3:1642">5.4.2.1</a> <a class="idx" href="nb_set.html#idx:nbsetarg3:2145">A.17</a> <a class="idx" href="record.html#idx:nbsetarg3:2168">A.31</a></dd>
1731 <a class="idx" href="preddesc.html#idx:nbsetarg3:336">4.1</a> <a class="idx" href="db.html#idx:nbsetarg3:812">4.14</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1219">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1230">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1237">4.21.1</a> <a class="idx" href="allsolutions.html#idx:nbsetarg3:1367">4.30</a> <a class="idx" href="dicts.html#idx:nbsetarg3:1646">5.4.2.1</a> <a class="idx" href="nb_set.html#idx:nbsetarg3:2149">A.17</a> <a class="idx" href="record.html#idx:nbsetarg3:2172">A.31</a></dd>
16861732 <dt><a class="idx" href="gvar.html#nb_setval/2">nb_setval/2</a></dt>
16871733 <dd>
1688 <a class="idx" href="db.html#idx:nbsetval2:810">4.14</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1226">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1227">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1235">4.21.1</a> <a class="idx" href="gvar.html#idx:nbsetval2:1413">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1416">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1427">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1430">4.33.1</a> <a class="idx" href="dicts.html#idx:nbsetval2:1643">5.4.2.1</a> <a class="idx" href="engine-examples.html#idx:nbsetval2:1974">10.1.2</a> <a class="idx" href="exception3.html#idx:nbsetval2:2217">B.6</a></dd>
1734 <a class="idx" href="db.html#idx:nbsetval2:810">4.14</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1226">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1227">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1235">4.21.1</a> <a class="idx" href="gvar.html#idx:nbsetval2:1413">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1416">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1427">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1430">4.33.1</a> <a class="idx" href="dicts.html#idx:nbsetval2:1647">5.4.2.1</a> <a class="idx" href="engine-examples.html#idx:nbsetval2:1978">10.1.2</a> <a class="idx" href="exception3.html#idx:nbsetval2:2221">B.6</a></dd>
16891735 <dt>neck</dt>
16901736 <dd>
1691 <a class="idx" href="glossary.html#idx:neck:2313">D</a></dd>
1737 <a class="idx" href="glossary.html#idx:neck:2317">D</a></dd>
16921738 <dt><a class="idx" href="ugraphs.html#neighbors/3">neighbors/3</a></dt>
16931739 <dt><a class="idx" href="ugraphs.html#neighbours/3">neighbours/3</a></dt>
16941740 <dd>
1695 <a class="idx" href="ugraphs.html#idx:neighbours3:2176">A.37</a></dd>
1741 <a class="idx" href="ugraphs.html#idx:neighbours3:2180">A.37</a></dd>
16961742 <dt><a class="idx" href="lists.html#nextto/3">nextto/3</a></dt>
16971743 <dt><a class="idx" href="chario.html#nl/0">nl/0</a></dt>
16981744 <dd>
17031749 <a class="idx" href="format.html#idx:nl01:1390">4.32.1</a></dd>
17041750 <dt><a class="idx" href="debugger.html#nodebug/0">nodebug/0</a></dt>
17051751 <dd>
1706 <a class="idx" href="debugger.html#idx:nodebug0:1554">4.39</a> <a class="idx" href="tracehook.html#idx:nodebug0:2195">B.3</a></dd>
1752 <a class="idx" href="debugger.html#idx:nodebug0:1554">4.39</a> <a class="idx" href="tracehook.html#idx:nodebug0:2199">B.3</a></dd>
17071753 <dt><a class="idx" href="debug.html#nodebug/1">nodebug/1</a></dt>
17081754 <dt><a class="idx" href="guitracer.html#noguitracer/0">noguitracer/0</a></dt>
17091755 <dd>
17101756 <a class="idx" href="guitracer.html#idx:noguitracer0:316">3.5.1</a> <a class="idx" href="idesummary.html#idx:noguitracer0:331">3.9</a></dd>
17111757 <dt>non deterministic</dt>
17121758 <dd>
1713 <a class="idx" href="glossary.html#idx:nondeterministic:2315">D</a></dd>
1759 <a class="idx" href="glossary.html#idx:nondeterministic:2319">D</a></dd>
17141760 <dt>nondet</dt>
17151761 <dd>
1716 <a class="idx" href="glossary.html#idx:nondet:2314">D</a></dd>
1762 <a class="idx" href="glossary.html#idx:nondet:2318">D</a></dd>
17171763 <dt><a class="idx" href="manipterm.html#nonground/2">nonground/2</a></dt>
17181764 <dd>
17191765 <a class="idx" href="typetest.html#idx:nonground2:618">4.6</a> <a class="idx" href="manipterm.html#idx:nonground2:1209">4.21</a></dd>
17231769 <dt><a class="idx" href="chartype.html#normalize_space/2">normalize_space/2</a></dt>
17241770 <dt><a class="idx" href="debugger.html#nospy/1">nospy/1</a></dt>
17251771 <dd>
1726 <a class="idx" href="debugoverview.html#idx:nospy1:62">2.9</a> <a class="idx" href="hooks.html#idx:nospy1:183">2.12</a> <a class="idx" href="thutil.html#idx:nospy1:1949">9.5.1</a> <a class="idx" href="intlibs.html#idx:nospy1:2223">B.7</a> <a class="idx" href="intlibs.html#idx:nospy1:2224">B.7</a> <a class="idx" href="intlibs.html#idx:nospy1:2226">B.7</a></dd>
1772 <a class="idx" href="debugoverview.html#idx:nospy1:62">2.9</a> <a class="idx" href="hooks.html#idx:nospy1:183">2.12</a> <a class="idx" href="thutil.html#idx:nospy1:1953">9.5.1</a> <a class="idx" href="intlibs.html#idx:nospy1:2227">B.7</a> <a class="idx" href="intlibs.html#idx:nospy1:2228">B.7</a> <a class="idx" href="intlibs.html#idx:nospy1:2230">B.7</a></dd>
17271773 <dt><a class="idx" href="debugger.html#nospyall/0">nospyall/0</a></dt>
17281774 <dd>
1729 <a class="idx" href="hooks.html#idx:nospyall0:184">2.12</a> <a class="idx" href="intlibs.html#idx:nospyall0:2227">B.7</a></dd>
1775 <a class="idx" href="hooks.html#idx:nospyall0:184">2.12</a> <a class="idx" href="intlibs.html#idx:nospyall0:2231">B.7</a></dd>
17301776 <dt><a class="idx" href="metacall.html#not/1">not/1</a></dt>
17311777 <dd>
1732 <a class="idx" href="predsummary.html#idx:not1:2346">F.1</a></dd>
1778 <a class="idx" href="predsummary.html#idx:not1:2350">F.1</a></dd>
17331779 <dt><a class="idx" href="debugger.html#notrace/0">notrace/0</a></dt>
17341780 <dd>
1735 <a class="idx" href="debugger.html#idx:notrace0:1545">4.39</a> <a class="idx" href="debugging.html#idx:notrace0:1819">8.4.3</a> <a class="idx" href="debugging.html#idx:notrace0:1821">8.4.3</a></dd>
1781 <a class="idx" href="debugger.html#idx:notrace0:1545">4.39</a> <a class="idx" href="debugging.html#idx:notrace0:1823">8.4.3</a> <a class="idx" href="debugging.html#idx:notrace0:1825">8.4.3</a></dd>
17361782 <dt><a class="idx" href="debugger.html#notrace/1">notrace/1</a></dt>
17371783 <dt><a class="idx" href="lists.html#nth0/3">nth0/3</a></dt>
17381784 <dt><a class="idx" href="lists.html#nth0/4">nth0/4</a></dt>
17401786 <dt><a class="idx" href="lists.html#nth1/4">nth1/4</a></dt>
17411787 <dt><a class="idx" href="examineprog.html#nth_clause/3">nth_clause/3</a></dt>
17421788 <dd>
1743 <a class="idx" href="examineprog.html#idx:nthclause3:917">4.16</a> <a class="idx" href="examineprog.html#idx:nthclause3:941">4.16</a> <a class="idx" href="manipstack.html#idx:nthclause3:2180">B.1</a></dd>
1789 <a class="idx" href="examineprog.html#idx:nthclause3:917">4.16</a> <a class="idx" href="examineprog.html#idx:nthclause3:941">4.16</a> <a class="idx" href="manipstack.html#idx:nthclause3:2184">B.1</a></dd>
17441790 <dt><a class="idx" href="arith.html#nth_integer_root_and_remainder/4">nth_integer_root_and_remainder/4</a></dt>
17451791 <dt>number,rational</dt>
17461792 <dd>
17751821 <a class="idx" href="signal.html#idx:onsignal3:773">4.12</a> <a class="idx" href="signal.html#idx:onsignal3:775">4.12</a></dd>
17761822 <dt><a class="idx" href="metacall.html#once/1">once/1</a></dt>
17771823 <dd>
1778 <a class="idx" href="control.html#idx:once1:647">4.8</a> <a class="idx" href="metacall.html#idx:once1:653">4.9</a> <a class="idx" href="metacall.html#idx:once1:654">4.9</a> <a class="idx" href="metacall.html#idx:once1:655">4.9</a> <a class="idx" href="metacall.html#idx:once1:668">4.9</a> <a class="idx" href="IO.html#idx:once1:1050">4.17.5</a> <a class="idx" href="allsolutions.html#idx:once1:1368">4.30</a> <a class="idx" href="toplevel.html#idx:once1:1528">4.37</a> <a class="idx" href="debugger.html#idx:once1:1552">4.39</a> <a class="idx" href="profile.html#idx:once1:1566">4.41.1</a> <a class="idx" href="profile.html#idx:once1:1567">4.41.1</a> <a class="idx" href="threadsync.html#idx:once1:1922">9.4</a> <a class="idx" href="threadsync.html#idx:once1:1925">9.4</a> <a class="idx" href="threadsync.html#idx:once1:1928">9.4</a> <a class="idx" href="foreigninclude.html#idx:once1:2046">11.4.9.2</a></dd>
1824 <a class="idx" href="control.html#idx:once1:647">4.8</a> <a class="idx" href="metacall.html#idx:once1:653">4.9</a> <a class="idx" href="metacall.html#idx:once1:654">4.9</a> <a class="idx" href="metacall.html#idx:once1:655">4.9</a> <a class="idx" href="metacall.html#idx:once1:668">4.9</a> <a class="idx" href="IO.html#idx:once1:1050">4.17.5</a> <a class="idx" href="allsolutions.html#idx:once1:1368">4.30</a> <a class="idx" href="toplevel.html#idx:once1:1528">4.37</a> <a class="idx" href="debugger.html#idx:once1:1552">4.39</a> <a class="idx" href="profile.html#idx:once1:1566">4.41.1</a> <a class="idx" href="profile.html#idx:once1:1567">4.41.1</a> <a class="idx" href="threadsync.html#idx:once1:1926">9.4</a> <a class="idx" href="threadsync.html#idx:once1:1929">9.4</a> <a class="idx" href="threadsync.html#idx:once1:1932">9.4</a> <a class="idx" href="foreigninclude.html#idx:once1:2050">11.4.9.2</a></dd>
17791825 <dt><a class="idx" href="operators.html#op/3">op/3</a></dt>
17801826 <dd>
1781 <a class="idx" href="dynamic.html#idx:op3:879">4.15</a> <a class="idx" href="termrw.html#idx:op3:1125">4.20</a> <a class="idx" href="operators.html#idx:op3:1317">4.25</a> <a class="idx" href="moduleop.html#idx:op3:1716">6.8</a></dd>
1827 <a class="idx" href="dynamic.html#idx:op3:879">4.15</a> <a class="idx" href="termrw.html#idx:op3:1125">4.20</a> <a class="idx" href="operators.html#idx:op3:1317">4.25</a> <a class="idx" href="moduleop.html#idx:op3:1720">6.8</a></dd>
17821828 <dt><a class="idx" href="IO.html#open/3">open/3</a></dt>
17831829 <dd>
1784 <a class="idx" href="flags.html#idx:open3:109">2.11</a> <a class="idx" href="preddesc.html#idx:open3:334">4.1</a> <a class="idx" href="IO.html#idx:open3:947">4.17</a> <a class="idx" href="IO.html#idx:open3:966">4.17.2</a> <a class="idx" href="foreigninclude.html#idx:open3:2029">11.4.6</a></dd>
1830 <a class="idx" href="flags.html#idx:open3:109">2.11</a> <a class="idx" href="preddesc.html#idx:open3:334">4.1</a> <a class="idx" href="IO.html#idx:open3:947">4.17</a> <a class="idx" href="IO.html#idx:open3:966">4.17.2</a> <a class="idx" href="foreigninclude.html#idx:open3:2033">11.4.6</a></dd>
17851831 <dt><a class="idx" href="IO.html#open/4">open/4</a></dt>
17861832 <dd>
1787 <a class="idx" href="widechars.html#idx:open4:269">2.19.1</a> <a class="idx" href="widechars.html#idx:open4:275">2.19.1.1</a> <a class="idx" href="widechars.html#idx:open4:277">2.19.1.1</a> <a class="idx" href="chars.html#idx:open4:340">4.2</a> <a class="idx" href="IO.html#idx:open4:972">4.17.2</a> <a class="idx" href="IO.html#idx:open4:980">4.17.2</a> <a class="idx" href="IO.html#idx:open4:983">4.17.2</a> <a class="idx" href="IO.html#idx:open4:986">4.17.2</a> <a class="idx" href="IO.html#idx:open4:987">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1004">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1015">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1025">4.17.2</a> <a class="idx" href="chario.html#idx:open4:1103">4.19</a> <a class="idx" href="locale.html#idx:open4:1290">4.23</a> <a class="idx" href="files.html#idx:open4:1493">4.36</a> <a class="idx" href="dicts.html#idx:open4:1648">5.4.3</a> <a class="idx" href="dicts.html#idx:open4:1654">5.4.4</a> <a class="idx" href="readutil.html#idx:open4:2160">A.30</a> <a class="idx" href="readutil.html#idx:open4:2164">A.30</a></dd>
1833 <a class="idx" href="widechars.html#idx:open4:269">2.19.1</a> <a class="idx" href="widechars.html#idx:open4:275">2.19.1.1</a> <a class="idx" href="widechars.html#idx:open4:277">2.19.1.1</a> <a class="idx" href="chars.html#idx:open4:340">4.2</a> <a class="idx" href="IO.html#idx:open4:972">4.17.2</a> <a class="idx" href="IO.html#idx:open4:980">4.17.2</a> <a class="idx" href="IO.html#idx:open4:983">4.17.2</a> <a class="idx" href="IO.html#idx:open4:986">4.17.2</a> <a class="idx" href="IO.html#idx:open4:987">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1004">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1015">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1025">4.17.2</a> <a class="idx" href="chario.html#idx:open4:1103">4.19</a> <a class="idx" href="locale.html#idx:open4:1290">4.23</a> <a class="idx" href="files.html#idx:open4:1493">4.36</a> <a class="idx" href="dicts.html#idx:open4:1652">5.4.3</a> <a class="idx" href="dicts.html#idx:open4:1658">5.4.4</a> <a class="idx" href="readutil.html#idx:open4:2164">A.30</a> <a class="idx" href="readutil.html#idx:open4:2168">A.30</a></dd>
17881834 <dt><a class="idx" href="iostream.html#open_any/5">open_any/5</a></dt>
17891835 <dt><a class="idx" href="charsio.html#open_chars_stream/2">open_chars_stream/2</a></dt>
17901836 <dt><a class="idx" href="DDE.html#open_dde_conversation/3">open_dde_conversation/3</a></dt>
17941840 <a class="idx" href="IO.html#idx:opennullstream1:1009">4.17.2</a></dd>
17951841 <dt><a class="idx" href="useresource.html#open_resource/3">open_resource/3</a></dt>
17961842 <dd>
1797 <a class="idx" href="foreigninclude.html#idx:openresource3:2078">11.4.21</a> <a class="idx" href="foreigninclude.html#idx:openresource3:2079">11.4.21</a> <a class="idx" href="foreigninclude.html#idx:openresource3:2080">11.4.21</a> <a class="idx" href="runtime.html#idx:openresource3:2097">12</a> <a class="idx" href="useresource.html#idx:openresource3:2121">12.3</a> <a class="idx" href="useresource.html#idx:openresource3:2126">12.3.1</a></dd>
1843 <a class="idx" href="foreigninclude.html#idx:openresource3:2082">11.4.21</a> <a class="idx" href="foreigninclude.html#idx:openresource3:2083">11.4.21</a> <a class="idx" href="foreigninclude.html#idx:openresource3:2084">11.4.21</a> <a class="idx" href="runtime.html#idx:openresource3:2101">12</a> <a class="idx" href="useresource.html#idx:openresource3:2125">12.3</a> <a class="idx" href="useresource.html#idx:openresource3:2130">12.3.1</a></dd>
17981844 <dt><a class="idx" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a></dt>
17991845 <dd>
1800 <a class="idx" href="flags.html#idx:opensharedobject2:120">2.11</a> <a class="idx" href="system.html#idx:opensharedobject2:1476">4.35.1</a> <a class="idx" href="foreignlink.html#idx:opensharedobject2:2009">11.2.1</a> <a class="idx" href="foreignlink.html#idx:opensharedobject2:2014">11.2.4</a></dd>
1846 <a class="idx" href="flags.html#idx:opensharedobject2:120">2.11</a> <a class="idx" href="system.html#idx:opensharedobject2:1476">4.35.1</a> <a class="idx" href="foreignlink.html#idx:opensharedobject2:2013">11.2.1</a> <a class="idx" href="foreignlink.html#idx:opensharedobject2:2018">11.2.4</a></dd>
18011847 <dt><a class="idx" href="foreignlink.html#open_shared_object/3">open_shared_object/3</a></dt>
18021848 <dd>
1803 <a class="idx" href="foreignlink.html#idx:opensharedobject3:2012">11.2.4</a></dd>
1849 <a class="idx" href="foreignlink.html#idx:opensharedobject3:2016">11.2.4</a></dd>
18041850 <dt><a class="idx" href="strings.html#open_string/2">open_string/2</a></dt>
18051851 <dt>operand</dt>
18061852 <dd>
1807 <a class="idx" href="glossary.html#idx:operand:2317">D</a></dd>
1853 <a class="idx" href="glossary.html#idx:operand:2321">D</a></dd>
18081854 <dt>operator</dt>
18091855 <dd>
1810 <a class="idx" href="glossary.html#idx:operator:2316">D</a></dd>
1856 <a class="idx" href="glossary.html#idx:operator:2320">D</a></dd>
18111857 <dt>operator,and modules</dt>
18121858 <dd>
18131859 <a class="idx" href="operators.html#idx:operatorandmodules:1314">4.25</a></dd>
18661912 <dt><a class="idx" href="apply.html#partition/5">partition/5</a></dt>
18671913 <dt><a class="idx" href="mt-xpce.html#pce_dispatch/1">pce_dispatch/1</a></dt>
18681914 <dd>
1869 <a class="idx" href="mt-xpce.html#idx:pcedispatch1:1955">9.7</a></dd>
1915 <a class="idx" href="mt-xpce.html#idx:pcedispatch1:1959">9.7</a></dd>
18701916 <dt>pce_thread/1</dt>
18711917 <dd>
1872 <a class="idx" href="mt-xpce.html#idx:pcethread1:1960">9.7</a></dd>
1918 <a class="idx" href="mt-xpce.html#idx:pcethread1:1964">9.7</a></dd>
18731919 <dt><a class="idx" href="chario.html#peek_byte/1">peek_byte/1</a></dt>
18741920 <dt><a class="idx" href="chario.html#peek_byte/2">peek_byte/2</a></dt>
18751921 <dt>peek_byte/[1,2]</dt>
18881934 <dt><a class="idx" href="chario.html#peek_string/3">peek_string/3</a></dt>
18891935 <dt><a class="idx" href="error.html#permission_error/3">permission_error/3</a></dt>
18901936 <dd>
1891 <a class="idx" href="foreigninclude.html#idx:permissionerror3:2034">11.4.6</a></dd>
1937 <a class="idx" href="foreigninclude.html#idx:permissionerror3:2038">11.4.6</a></dd>
18921938 <dt><a class="idx" href="lists.html#permutation/2">permutation/2</a></dt>
18931939 <dt><a class="idx" href="persistency.html#persistent/1">persistent/1</a></dt>
18941940 <dt><a class="idx" href="DCG.html#phrase/2">phrase/2</a></dt>
18961942 <a class="idx" href="DCG.html#idx:phrase2:781">4.13</a></dd>
18971943 <dt><a class="idx" href="DCG.html#phrase/3">phrase/3</a></dt>
18981944 <dd>
1899 <a class="idx" href="DCG.html#idx:phrase3:782">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:784">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:786">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:788">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:789">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:790">4.13</a> <a class="idx" href="strings.html#idx:phrase3:1609">5.2.2</a> <a class="idx" href="metapred.html#idx:phrase3:1697">6.4</a> <a class="idx" href="predsummary.html#idx:phrase3:2350">F.1</a></dd>
1945 <a class="idx" href="DCG.html#idx:phrase3:782">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:784">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:786">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:788">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:789">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:790">4.13</a> <a class="idx" href="strings.html#idx:phrase3:1609">5.2.2</a> <a class="idx" href="metapred.html#idx:phrase3:1701">6.4</a> <a class="idx" href="predsummary.html#idx:phrase3:2354">F.1</a></dd>
19001946 <dt><a class="idx" href="pio.html#phrase_from_file/2">phrase_from_file/2</a></dt>
19011947 <dt><a class="idx" href="pio.html#phrase_from_file/3">phrase_from_file/3</a></dt>
19021948 <dt><a class="idx" href="quasiquotations.html#phrase_from_quasi_quotation/2">phrase_from_quasi_quotation/2</a></dt>
19071953 <a class="idx" href="streamstat.html#idx:poll:1069">4.18</a></dd>
19081954 <dt>portable,prolog code</dt>
19091955 <dd>
1910 <a class="idx" href="dialect.html#idx:portableprologcode:2244">C</a></dd>
1956 <a class="idx" href="dialect.html#idx:portableprologcode:2248">C</a></dd>
19111957 <dt><a class="idx" href="termrw.html#portray/1">portray/1</a></dt>
19121958 <dd>
1913 <a class="idx" href="debugoverview.html#idx:portray1:69">2.9</a> <a class="idx" href="projectfiles.html#idx:portray1:303">3.1.2</a> <a class="idx" href="termrw.html#idx:portray1:1121">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1128">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1130">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1131">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1150">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1151">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1154">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1155">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1156">4.20</a> <a class="idx" href="foreigninclude.html#idx:portray1:2045">11.4.9.2</a> <a class="idx" href="foreigninclude.html#idx:portray1:2074">11.4.20</a> <a class="idx" href="intlibs.html#idx:portray1:2219">B.7</a></dd>
1959 <a class="idx" href="debugoverview.html#idx:portray1:69">2.9</a> <a class="idx" href="projectfiles.html#idx:portray1:303">3.1.2</a> <a class="idx" href="termrw.html#idx:portray1:1121">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1128">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1130">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1131">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1150">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1151">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1154">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1155">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1156">4.20</a> <a class="idx" href="foreigninclude.html#idx:portray1:2049">11.4.9.2</a> <a class="idx" href="foreigninclude.html#idx:portray1:2078">11.4.20</a> <a class="idx" href="intlibs.html#idx:portray1:2223">B.7</a></dd>
19141960 <dt><a class="idx" href="listing.html#portray_clause/1">portray_clause/1</a></dt>
19151961 <dd>
19161962 <a class="idx" href="listing.html#idx:portrayclause1:596">4.5</a> <a class="idx" href="listing.html#idx:portrayclause1:597">4.5</a> <a class="idx" href="listing.html#idx:portrayclause1:600">4.5</a></dd>
19221968 <a class="idx" href="DCG.html#idx:portraytext1:787">4.13</a> <a class="idx" href="strings.html#idx:portraytext1:1621">5.2.4</a></dd>
19231969 <dt>precedence</dt>
19241970 <dd>
1925 <a class="idx" href="glossary.html#idx:precedence:2318">D</a></dd>
1971 <a class="idx" href="glossary.html#idx:precedence:2322">D</a></dd>
19261972 <dt>pred/1</dt>
19271973 <dd>
1928 <a class="idx" href="reexport.html#idx:pred1:1710">6.7</a> <a class="idx" href="reexport.html#idx:pred1:1712">6.7</a></dd>
1974 <a class="idx" href="reexport.html#idx:pred1:1714">6.7</a> <a class="idx" href="reexport.html#idx:pred1:1716">6.7</a></dd>
19291975 <dt>predicate</dt>
19301976 <dd>
1931 <a class="idx" href="glossary.html#idx:predicate:2319">D</a></dd>
1977 <a class="idx" href="glossary.html#idx:predicate:2323">D</a></dd>
19321978 <dt>predicate indicator</dt>
19331979 <dd>
1934 <a class="idx" href="preddesc.html#idx:predicateindicator:337">4.1</a> <a class="idx" href="glossary.html#idx:predicateindicator:2320">D</a></dd>
1980 <a class="idx" href="preddesc.html#idx:predicateindicator:337">4.1</a> <a class="idx" href="glossary.html#idx:predicateindicator:2324">D</a></dd>
19351981 <dt>predicate,dynamic</dt>
19361982 <dd>
1937 <a class="idx" href="glossary.html#idx:predicatedynamic:2289">D</a></dd>
1983 <a class="idx" href="glossary.html#idx:predicatedynamic:2293">D</a></dd>
19381984 <dt>predicate,exported</dt>
19391985 <dd>
1940 <a class="idx" href="glossary.html#idx:predicateexported:2291">D</a></dd>
1986 <a class="idx" href="glossary.html#idx:predicateexported:2295">D</a></dd>
19411987 <dt>predicate,imported</dt>
19421988 <dd>
1943 <a class="idx" href="glossary.html#idx:predicateimported:2300">D</a></dd>
1989 <a class="idx" href="glossary.html#idx:predicateimported:2304">D</a></dd>
19441990 <dt><a class="idx" href="predicate_options.html#predicate_options/3">predicate_options/3</a></dt>
19451991 <dt><a class="idx" href="examineprog.html#predicate_property/2">predicate_property/2</a></dt>
19461992 <dd>
1947 <a class="idx" href="consulting.html#idx:predicateproperty2:410">4.3</a> <a class="idx" href="consulting.html#idx:predicateproperty2:449">4.3</a> <a class="idx" href="consulting.html#idx:predicateproperty2:548">4.3.1</a> <a class="idx" href="metacall.html#idx:predicateproperty2:652">4.9</a> <a class="idx" href="dynamic.html#idx:predicateproperty2:891">4.15</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:901">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:904">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:908">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:910">4.16</a> <a class="idx" href="metapred.html#idx:predicateproperty2:1692">6.4</a> <a class="idx" href="manipmodule.html#idx:predicateproperty2:1746">6.14</a> <a class="idx" href="manipmodule.html#idx:predicateproperty2:1748">6.14</a></dd>
1993 <a class="idx" href="consulting.html#idx:predicateproperty2:410">4.3</a> <a class="idx" href="consulting.html#idx:predicateproperty2:449">4.3</a> <a class="idx" href="consulting.html#idx:predicateproperty2:548">4.3.1</a> <a class="idx" href="metacall.html#idx:predicateproperty2:652">4.9</a> <a class="idx" href="dynamic.html#idx:predicateproperty2:891">4.15</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:901">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:904">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:908">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:910">4.16</a> <a class="idx" href="metapred.html#idx:predicateproperty2:1696">6.4</a> <a class="idx" href="manipmodule.html#idx:predicateproperty2:1750">6.14</a> <a class="idx" href="manipmodule.html#idx:predicateproperty2:1752">6.14</a></dd>
19481994 <dt><a class="idx" href="builtinlist.html#predsort/3">predsort/3</a></dt>
19491995 <dd>
19501996 <a class="idx" href="builtinlist.html#idx:predsort3:1353">4.29</a></dd>
19511997 <dt><a class="idx" href="lists.html#prefix/2">prefix/2</a></dt>
19521998 <dt><a class="idx" href="termrw.html#print/1">print/1</a></dt>
19531999 <dd>
1954 <a class="idx" href="flags.html#idx:print1:125">2.11</a> <a class="idx" href="termrw.html#idx:print1:1132">4.20</a> <a class="idx" href="termrw.html#idx:print1:1145">4.20</a> <a class="idx" href="termrw.html#idx:print1:1146">4.20</a> <a class="idx" href="termrw.html#idx:print1:1152">4.20</a> <a class="idx" href="termrw.html#idx:print1:1153">4.20</a> <a class="idx" href="termrw.html#idx:print1:1157">4.20</a> <a class="idx" href="format.html#idx:print1:1391">4.32.1</a> <a class="idx" href="format.html#idx:print1:1396">4.32.1</a> <a class="idx" href="format.html#idx:print1:1401">4.32.2</a> <a class="idx" href="foreigninclude.html#idx:print1:2044">11.4.9.2</a> <a class="idx" href="predsummary.html#idx:print1:2361">F.1</a></dd>
2000 <a class="idx" href="flags.html#idx:print1:125">2.11</a> <a class="idx" href="termrw.html#idx:print1:1132">4.20</a> <a class="idx" href="termrw.html#idx:print1:1145">4.20</a> <a class="idx" href="termrw.html#idx:print1:1146">4.20</a> <a class="idx" href="termrw.html#idx:print1:1152">4.20</a> <a class="idx" href="termrw.html#idx:print1:1153">4.20</a> <a class="idx" href="termrw.html#idx:print1:1157">4.20</a> <a class="idx" href="format.html#idx:print1:1391">4.32.1</a> <a class="idx" href="format.html#idx:print1:1396">4.32.1</a> <a class="idx" href="format.html#idx:print1:1401">4.32.2</a> <a class="idx" href="foreigninclude.html#idx:print1:2048">11.4.9.2</a> <a class="idx" href="predsummary.html#idx:print1:2365">F.1</a></dd>
19552001 <dt><a class="idx" href="termrw.html#print/2">print/2</a></dt>
19562002 <dd>
19572003 <a class="idx" href="flags.html#idx:print2:126">2.11</a></dd>
19582004 <dt><a class="idx" href="exception.html#print_message/2">print_message/2</a></dt>
19592005 <dd>
1960 <a class="idx" href="flags.html#idx:printmessage2:95">2.11</a> <a class="idx" href="flags.html#idx:printmessage2:153">2.11</a> <a class="idx" href="hooks.html#idx:printmessage2:169">2.12</a> <a class="idx" href="hooks.html#idx:printmessage2:170">2.12</a> <a class="idx" href="consulting.html#idx:printmessage2:398">4.3</a> <a class="idx" href="consulting.html#idx:printmessage2:497">4.3</a> <a class="idx" href="exception.html#idx:printmessage2:715">4.11.1</a> <a class="idx" href="exception.html#idx:printmessage2:730">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:731">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:733">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:740">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:744">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:746">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:751">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:753">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:754">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:766">4.11.4.1</a> <a class="idx" href="exception.html#idx:printmessage2:767">4.11.4.1</a> <a class="idx" href="termrw.html#idx:printmessage2:1148">4.20</a> <a class="idx" href="termrw.html#idx:printmessage2:1175">4.20</a> <a class="idx" href="termrw.html#idx:printmessage2:1176">4.20</a> <a class="idx" href="memory.html#idx:printmessage2:1580">4.42</a> <a class="idx" href="threadcreate.html#idx:printmessage2:1842">9.1</a> <a class="idx" href="threadcreate.html#idx:printmessage2:1854">9.1</a> <a class="idx" href="predsummary.html#idx:printmessage2:2359">F.1</a></dd>
2006 <a class="idx" href="flags.html#idx:printmessage2:95">2.11</a> <a class="idx" href="flags.html#idx:printmessage2:153">2.11</a> <a class="idx" href="hooks.html#idx:printmessage2:169">2.12</a> <a class="idx" href="hooks.html#idx:printmessage2:170">2.12</a> <a class="idx" href="consulting.html#idx:printmessage2:398">4.3</a> <a class="idx" href="consulting.html#idx:printmessage2:497">4.3</a> <a class="idx" href="exception.html#idx:printmessage2:715">4.11.1</a> <a class="idx" href="exception.html#idx:printmessage2:730">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:731">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:733">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:740">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:744">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:746">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:751">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:753">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:754">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:766">4.11.4.1</a> <a class="idx" href="exception.html#idx:printmessage2:767">4.11.4.1</a> <a class="idx" href="termrw.html#idx:printmessage2:1148">4.20</a> <a class="idx" href="termrw.html#idx:printmessage2:1175">4.20</a> <a class="idx" href="termrw.html#idx:printmessage2:1176">4.20</a> <a class="idx" href="memory.html#idx:printmessage2:1580">4.42</a> <a class="idx" href="threadcreate.html#idx:printmessage2:1846">9.1</a> <a class="idx" href="threadcreate.html#idx:printmessage2:1858">9.1</a> <a class="idx" href="predsummary.html#idx:printmessage2:2363">F.1</a></dd>
19612007 <dt><a class="idx" href="exception.html#print_message_lines/3">print_message_lines/3</a></dt>
19622008 <dd>
1963 <a class="idx" href="exception.html#idx:printmessagelines3:741">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:755">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:762">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:771">4.11.4.1</a> <a class="idx" href="predsummary.html#idx:printmessagelines3:2360">F.1</a></dd>
2009 <a class="idx" href="exception.html#idx:printmessagelines3:741">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:755">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:762">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:771">4.11.4.1</a> <a class="idx" href="predsummary.html#idx:printmessagelines3:2364">F.1</a></dd>
19642010 <dt>priority</dt>
19652011 <dd>
1966 <a class="idx" href="glossary.html#idx:priority:2321">D</a></dd>
2012 <a class="idx" href="glossary.html#idx:priority:2325">D</a></dd>
19672013 <dt>process_create/3</dt>
19682014 <dd>
19692015 <a class="idx" href="IO.html#idx:processcreate3:971">4.17.2</a> <a class="idx" href="system.html#idx:processcreate3:1448">4.35</a> <a class="idx" href="system.html#idx:processcreate3:1468">4.35.1</a></dd>
19722018 <a class="idx" href="initfile.html#idx:profilefile:20">2.2</a></dd>
19732019 <dt><a class="idx" href="profile.html#profile/1">profile/1</a></dt>
19742020 <dd>
1975 <a class="idx" href="thutil.html#idx:profile1:1951">9.5.2</a> <a class="idx" href="foreigninclude.html#idx:profile1:2085">11.4.21</a></dd>
2021 <a class="idx" href="thutil.html#idx:profile1:1955">9.5.2</a> <a class="idx" href="foreigninclude.html#idx:profile1:2089">11.4.21</a></dd>
19762022 <dt><a class="idx" href="profile.html#profile/3">profile/3</a></dt>
19772023 <dt><a class="idx" href="profile.html#profiler/2">profiler/2</a></dt>
19782024 <dt>profiling,foreign code</dt>
19792025 <dd>
1980 <a class="idx" href="foreignnotes.html#idx:profilingforeigncode:2095">11.8.4</a></dd>
2026 <a class="idx" href="foreignnotes.html#idx:profilingforeigncode:2099">11.8.4</a></dd>
19812027 <dt>program</dt>
19822028 <dd>
1983 <a class="idx" href="glossary.html#idx:program:2322">D</a></dd>
2029 <a class="idx" href="glossary.html#idx:program:2326">D</a></dd>
19842030 <dt><a class="idx" href="attvar.html#project_attributes/2">project_attributes/2</a></dt>
19852031 <dd>
1986 <a class="idx" href="attvar.html#idx:projectattributes2:1782">7.1.2</a></dd>
2032 <a class="idx" href="attvar.html#idx:projectattributes2:1786">7.1.2</a></dd>
19872033 <dt><a class="idx" href="toplevel.html#prolog/0">prolog/0</a></dt>
19882034 <dd>
1989 <a class="idx" href="cmdline.html#idx:prolog0:43">2.4.4</a> <a class="idx" href="IO.html#idx:prolog0:1030">4.17.2</a> <a class="idx" href="toplevel.html#idx:prolog0:1525">4.37</a> <a class="idx" href="toplevel.html#idx:prolog0:1533">4.37</a> <a class="idx" href="toplevel.html#idx:prolog0:1535">4.37</a> <a class="idx" href="mtoplevel.html#idx:prolog0:1708">6.6</a> <a class="idx" href="foreigninclude.html#idx:prolog0:2082">11.4.21</a> <a class="idx" href="manipstack.html#idx:prolog0:2185">B.1</a></dd>
2035 <a class="idx" href="cmdline.html#idx:prolog0:43">2.4.4</a> <a class="idx" href="IO.html#idx:prolog0:1030">4.17.2</a> <a class="idx" href="toplevel.html#idx:prolog0:1525">4.37</a> <a class="idx" href="toplevel.html#idx:prolog0:1533">4.37</a> <a class="idx" href="toplevel.html#idx:prolog0:1535">4.37</a> <a class="idx" href="mtoplevel.html#idx:prolog0:1712">6.6</a> <a class="idx" href="foreigninclude.html#idx:prolog0:2086">11.4.21</a> <a class="idx" href="manipstack.html#idx:prolog0:2189">B.1</a></dd>
19902036 <dt><a class="idx" href="debug.html#prolog:assertion_failed/2">prolog:assertion_failed/2</a></dt>
19912037 <dt><a class="idx" href="breakpoint.html#prolog:break_hook/6">prolog:break_hook/6</a></dt>
19922038 <dt><a class="idx" href="prolog_xref.html#prolog:called_by/2">prolog:called_by/2</a></dt>
19972043 <dt><a class="idx" href="exception.html#prolog:message_line_element/2">prolog:message_line_element/2</a></dt>
19982044 <dt><a class="idx" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a></dt>
19992045 <dd>
2000 <a class="idx" href="manipstack.html#idx:prologchoiceattribute3:2177">B.1</a> <a class="idx" href="tracehook.html#idx:prologchoiceattribute3:2193">B.3</a></dd>
2046 <a class="idx" href="manipstack.html#idx:prologchoiceattribute3:2181">B.1</a> <a class="idx" href="tracehook.html#idx:prologchoiceattribute3:2197">B.3</a></dd>
20012047 <dt><a class="idx" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a></dt>
20022048 <dd>
2003 <a class="idx" href="manipstack.html#idx:prologcurrentchoice1:2183">B.1</a> <a class="idx" href="ancestral-cut.html#idx:prologcurrentchoice1:2187">B.2</a></dd>
2049 <a class="idx" href="manipstack.html#idx:prologcurrentchoice1:2187">B.1</a> <a class="idx" href="ancestral-cut.html#idx:prologcurrentchoice1:2191">B.2</a></dd>
20042050 <dt><a class="idx" href="manipstack.html#prolog_current_frame/1">prolog_current_frame/1</a></dt>
20052051 <dd>
2006 <a class="idx" href="manipstack.html#idx:prologcurrentframe1:2178">B.1</a></dd>
2052 <a class="idx" href="manipstack.html#idx:prologcurrentframe1:2182">B.1</a></dd>
20072053 <dt><a class="idx" href="ancestral-cut.html#prolog_cut_to/1">prolog_cut_to/1</a></dt>
20082054 <dd>
2009 <a class="idx" href="ancestral-cut.html#idx:prologcutto1:2188">B.2</a></dd>
2055 <a class="idx" href="ancestral-cut.html#idx:prologcutto1:2192">B.2</a></dd>
20102056 <dt><a class="idx" href="foreignnotes.html#prolog_debug/1">prolog_debug/1</a></dt>
20112057 <dd>
2012 <a class="idx" href="foreignnotes.html#idx:prologdebug1:2090">11.8.1</a></dd>
2058 <a class="idx" href="foreignnotes.html#idx:prologdebug1:2094">11.8.1</a></dd>
20132059 <dt><a class="idx" href="edit.html#prolog_edit:edit_command/2">prolog_edit:edit_command/2</a></dt>
20142060 <dt><a class="idx" href="edit.html#prolog_edit:edit_source/1">prolog_edit:edit_source/1</a></dt>
20152061 <dt><a class="idx" href="edit.html#prolog_edit:load/0">prolog_edit:load/0</a></dt>
20202066 <a class="idx" href="exception.html#idx:prologeventhook1:713">4.11.1</a></dd>
20212067 <dt><a class="idx" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a></dt>
20222068 <dd>
2023 <a class="idx" href="exception.html#idx:prologexceptionhook4:700">4.11</a> <a class="idx" href="exception.html#idx:prologexceptionhook4:714">4.11.1</a> <a class="idx" href="exception.html#idx:prologexceptionhook4:729">4.11.2</a> <a class="idx" href="memory.html#idx:prologexceptionhook4:1583">4.42</a> <a class="idx" href="excepthook.html#idx:prologexceptionhook4:2204">B.5</a> <a class="idx" href="excepthook.html#idx:prologexceptionhook4:2208">B.5</a></dd>
2069 <a class="idx" href="exception.html#idx:prologexceptionhook4:700">4.11</a> <a class="idx" href="exception.html#idx:prologexceptionhook4:714">4.11.1</a> <a class="idx" href="exception.html#idx:prologexceptionhook4:729">4.11.2</a> <a class="idx" href="memory.html#idx:prologexceptionhook4:1583">4.42</a> <a class="idx" href="excepthook.html#idx:prologexceptionhook4:2208">B.5</a> <a class="idx" href="excepthook.html#idx:prologexceptionhook4:2212">B.5</a></dd>
20242070 <dt><a class="idx" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a></dt>
20252071 <dd>
20262072 <a class="idx" href="consulting.html#idx:prologfiletype2:364">4.3</a> <a class="idx" href="consulting.html#idx:prologfiletype2:472">4.3</a> <a class="idx" href="files.html#idx:prologfiletype2:1510">4.36</a></dd>
20272073 <dt><a class="idx" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a></dt>
20282074 <dd>
2029 <a class="idx" href="examineprog.html#idx:prologframeattribute3:942">4.16</a> <a class="idx" href="tracehook.html#idx:prologframeattribute3:2191">B.3</a> <a class="idx" href="tracehook.html#idx:prologframeattribute3:2192">B.3</a> <a class="idx" href="excepthook.html#idx:prologframeattribute3:2206">B.5</a></dd>
2075 <a class="idx" href="examineprog.html#idx:prologframeattribute3:942">4.16</a> <a class="idx" href="tracehook.html#idx:prologframeattribute3:2195">B.3</a> <a class="idx" href="tracehook.html#idx:prologframeattribute3:2196">B.3</a> <a class="idx" href="excepthook.html#idx:prologframeattribute3:2210">B.5</a></dd>
20302076 <dt><a class="idx" href="idepreds.html#prolog_ide/1">prolog_ide/1</a></dt>
20312077 <dd>
20322078 <a class="idx" href="idepreds.html#idx:prologide1:326">3.8</a></dd>
20332079 <dt><a class="idx" href="intlibs.html#prolog_list_goal/1">prolog_list_goal/1</a></dt>
20342080 <dt><a class="idx" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a></dt>
20352081 <dd>
2036 <a class="idx" href="consulting.html#idx:prologloadcontext2:496">4.3</a> <a class="idx" href="consulting.html#idx:prologloadcontext2:541">4.3.1</a> <a class="idx" href="termrw.html#idx:prologloadcontext2:1165">4.20</a> <a class="idx" href="dialect.html#idx:prologloadcontext2:2253">C</a></dd>
2082 <a class="idx" href="consulting.html#idx:prologloadcontext2:496">4.3</a> <a class="idx" href="consulting.html#idx:prologloadcontext2:541">4.3.1</a> <a class="idx" href="termrw.html#idx:prologloadcontext2:1165">4.20</a> <a class="idx" href="dialect.html#idx:prologloadcontext2:2257">C</a></dd>
20372083 <dt><a class="idx" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a></dt>
20382084 <dd>
2039 <a class="idx" href="consulting.html#idx:prologloadfile2:424">4.3</a> <a class="idx" href="loadfilehook.html#idx:prologloadfile2:2237">B.8</a></dd>
2085 <a class="idx" href="consulting.html#idx:prologloadfile2:424">4.3</a> <a class="idx" href="loadfilehook.html#idx:prologloadfile2:2241">B.8</a></dd>
20402086 <dt><a class="idx" href="foreignnotes.html#prolog_nodebug/1">prolog_nodebug/1</a></dt>
20412087 <dd>
2042 <a class="idx" href="foreignnotes.html#idx:prolognodebug1:2091">11.8.1</a></dd>
2088 <a class="idx" href="foreignnotes.html#idx:prolognodebug1:2095">11.8.1</a></dd>
20432089 <dt><a class="idx" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a></dt>
20442090 <dd>
2045 <a class="idx" href="tracehook.html#idx:prologskipframe1:2197">B.3</a> <a class="idx" href="tracehook.html#idx:prologskipframe1:2198">B.3</a></dd>
2091 <a class="idx" href="tracehook.html#idx:prologskipframe1:2201">B.3</a> <a class="idx" href="tracehook.html#idx:prologskipframe1:2202">B.3</a></dd>
20462092 <dt><a class="idx" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a></dt>
20472093 <dd>
2048 <a class="idx" href="tracehook.html#idx:prologskiplevel2:2196">B.3</a></dd>
2094 <a class="idx" href="tracehook.html#idx:prologskiplevel2:2200">B.3</a></dd>
20492095 <dt><a class="idx" href="memory.html#prolog_stack_property/2">prolog_stack_property/2</a></dt>
20502096 <dd>
20512097 <a class="idx" href="memory.html#idx:prologstackproperty2:1577">4.42</a></dd>
20542100 <a class="idx" href="projectfiles.html#idx:prologtoosfilename2:296">3.1.1.2</a> <a class="idx" href="projectfiles.html#idx:prologtoosfilename2:297">3.1.1.2</a> <a class="idx" href="system.html#idx:prologtoosfilename2:1472">4.35.1</a> <a class="idx" href="files.html#idx:prologtoosfilename2:1498">4.36</a> <a class="idx" href="files.html#idx:prologtoosfilename2:1514">4.36</a></dd>
20552101 <dt><a class="idx" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a></dt>
20562102 <dd>
2057 <a class="idx" href="guitracer.html#idx:prologtraceinterception4:314">3.5</a> <a class="idx" href="debugger.html#idx:prologtraceinterception4:1546">4.39</a> <a class="idx" href="memory.html#idx:prologtraceinterception4:1582">4.42</a> <a class="idx" href="manipstack.html#idx:prologtraceinterception4:2179">B.1</a> <a class="idx" href="manipstack.html#idx:prologtraceinterception4:2182">B.1</a></dd>
2103 <a class="idx" href="guitracer.html#idx:prologtraceinterception4:314">3.5</a> <a class="idx" href="debugger.html#idx:prologtraceinterception4:1546">4.39</a> <a class="idx" href="memory.html#idx:prologtraceinterception4:1582">4.42</a> <a class="idx" href="manipstack.html#idx:prologtraceinterception4:2183">B.1</a> <a class="idx" href="manipstack.html#idx:prologtraceinterception4:2186">B.1</a></dd>
20582104 <dt>prompt, alternatives</dt>
20592105 <dd>
20602106 <a class="idx" href="flags.html#idx:promptalternatives:127">2.11</a></dd>
20612107 <dt><a class="idx" href="termrw.html#prompt/2">prompt/2</a></dt>
20622108 <dd>
2063 <a class="idx" href="termrw.html#idx:prompt2:1186">4.20</a> <a class="idx" href="termrw.html#idx:prompt2:1189">4.20</a> <a class="idx" href="threadcreate.html#idx:prompt2:1846">9.1</a></dd>
2109 <a class="idx" href="termrw.html#idx:prompt2:1186">4.20</a> <a class="idx" href="termrw.html#idx:prompt2:1189">4.20</a> <a class="idx" href="threadcreate.html#idx:prompt2:1850">9.1</a></dd>
20642110 <dt><a class="idx" href="termrw.html#prompt1/1">prompt1/1</a></dt>
20652111 <dt>propagation</dt>
20662112 <dd>
2067 <a class="idx" href="clp.html#idx:propagation:1763">7</a></dd>
2113 <a class="idx" href="clp.html#idx:propagation:1767">7</a></dd>
20682114 <dt><a class="idx" href="lists.html#proper_length/2">proper_length/2</a></dt>
20692115 <dt>property</dt>
20702116 <dd>
2071 <a class="idx" href="glossary.html#idx:property:2323">D</a></dd>
2117 <a class="idx" href="glossary.html#idx:property:2327">D</a></dd>
20722118 <dt><a class="idx" href="protocol.html#protocol/1">protocol/1</a></dt>
20732119 <dd>
20742120 <a class="idx" href="protocol.html#idx:protocol1:1538">4.38</a> <a class="idx" href="protocol.html#idx:protocol1:1539">4.38</a></dd>
20782124 <dt><a class="idx" href="protocol.html#protocolling/1">protocolling/1</a></dt>
20792125 <dt>prove</dt>
20802126 <dd>
2081 <a class="idx" href="glossary.html#idx:prove:2324">D</a></dd>
2127 <a class="idx" href="glossary.html#idx:prove:2328">D</a></dd>
20822128 <dt>public list</dt>
20832129 <dd>
2084 <a class="idx" href="glossary.html#idx:publiclist:2325">D</a></dd>
2130 <a class="idx" href="glossary.html#idx:publiclist:2329">D</a></dd>
20852131 <dt><a class="idx" href="dynamic.html#public/1">public/1</a></dt>
20862132 <dd>
2087 <a class="idx" href="dynamic.html#idx:public1:878">4.15</a> <a class="idx" href="dynamic.html#idx:public1:890">4.15</a> <a class="idx" href="dynamic.html#idx:public1:892">4.15</a> <a class="idx" href="examineprog.html#idx:public1:925">4.16</a> <a class="idx" href="runtime.html#idx:public1:2111">12</a></dd>
2133 <a class="idx" href="dynamic.html#idx:public1:878">4.15</a> <a class="idx" href="dynamic.html#idx:public1:890">4.15</a> <a class="idx" href="dynamic.html#idx:public1:892">4.15</a> <a class="idx" href="examineprog.html#idx:public1:925">4.16</a> <a class="idx" href="runtime.html#idx:public1:2115">12</a></dd>
20882134 <dt><a class="idx" href="chario.html#put/1">put/1</a></dt>
20892135 <dd>
20902136 <a class="idx" href="chario.html#idx:put1:1077">4.19</a></dd>
20922138 <dt><a class="idx" href="assoc.html#put_assoc/4">put_assoc/4</a></dt>
20932139 <dt><a class="idx" href="attvar.html#put_attr/3">put_attr/3</a></dt>
20942140 <dd>
2095 <a class="idx" href="manipterm.html#idx:putattr3:1223">4.21.1</a> <a class="idx" href="attvar.html#idx:putattr3:1777">7.1.1</a> <a class="idx" href="attvar.html#idx:putattr3:1779">7.1.2</a> <a class="idx" href="attvar.html#idx:putattr3:1789">7.1.4</a></dd>
2141 <a class="idx" href="manipterm.html#idx:putattr3:1223">4.21.1</a> <a class="idx" href="attvar.html#idx:putattr3:1781">7.1.1</a> <a class="idx" href="attvar.html#idx:putattr3:1783">7.1.2</a> <a class="idx" href="attvar.html#idx:putattr3:1793">7.1.4</a></dd>
20962142 <dt><a class="idx" href="attvar.html#put_attrs/2">put_attrs/2</a></dt>
20972143 <dt><a class="idx" href="chario.html#put_byte/1">put_byte/1</a></dt>
20982144 <dt><a class="idx" href="chario.html#put_byte/2">put_byte/2</a></dt>
21162162 <dd>
21172163 <a class="idx" href="chars.html#idx:putcode12:355">4.2</a></dd>
21182164 <dt><a class="idx" href="dicts.html#put_dict/3">put_dict/3</a></dt>
2165 <dd>
2166 <a class="idx" href="dicts.html#idx:putdict3:1638">5.4.1.2</a></dd>
21192167 <dt><a class="idx" href="dicts.html#put_dict/4">put_dict/4</a></dt>
2168 <dd>
2169 <a class="idx" href="dicts.html#idx:putdict4:1639">5.4.1.2</a></dd>
21202170 <dt><a class="idx" href="consulting.html#qcompile/1">qcompile/1</a></dt>
21212171 <dd>
2122 <a class="idx" href="swiorother.html#idx:qcompile1:2">1.3</a> <a class="idx" href="consulting.html#idx:qcompile1:374">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:405">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:412">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:414">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:513">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:576">4.3.3</a> <a class="idx" href="consulting.html#idx:qcompile1:583">4.3.3</a> <a class="idx" href="guidelines.html#idx:qcompile1:1826">8.7</a></dd>
2172 <a class="idx" href="swiorother.html#idx:qcompile1:2">1.3</a> <a class="idx" href="consulting.html#idx:qcompile1:374">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:405">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:412">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:414">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:513">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:576">4.3.3</a> <a class="idx" href="consulting.html#idx:qcompile1:583">4.3.3</a> <a class="idx" href="guidelines.html#idx:qcompile1:1830">8.7</a></dd>
21232173 <dt><a class="idx" href="consulting.html#qcompile/2">qcompile/2</a></dt>
21242174 <dt><a class="idx" href="runtime.html#qsave_program/1">qsave_program/1</a></dt>
21252175 <dd>
21262176 <a class="idx" href="flags.html#idx:qsaveprogram1:101">2.11</a> <a class="idx" href="consulting.html#idx:qsaveprogram1:502">4.3</a> <a class="idx" href="consulting.html#idx:qsaveprogram1:505">4.3</a></dd>
21272177 <dt><a class="idx" href="runtime.html#qsave_program/2">qsave_program/2</a></dt>
21282178 <dd>
2129 <a class="idx" href="swiorother.html#idx:qsaveprogram2:3">1.3</a> <a class="idx" href="compilation.html#idx:qsaveprogram2:77">2.10.2.4</a> <a class="idx" href="compilation.html#idx:qsaveprogram2:78">2.10.2.4</a> <a class="idx" href="compilation.html#idx:qsaveprogram2:79">2.10.2.4</a> <a class="idx" href="flags.html#idx:qsaveprogram2:106">2.11</a> <a class="idx" href="autoload.html#idx:qsaveprogram2:206">2.13</a> <a class="idx" href="projectfiles.html#idx:qsaveprogram2:302">3.1.2</a> <a class="idx" href="idepreds.html#idx:qsaveprogram2:325">3.8</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram2:2077">11.4.21</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram2:2081">11.4.21</a> <a class="idx" href="runtime.html#idx:qsaveprogram2:2098">12</a> <a class="idx" href="useresource.html#idx:qsaveprogram2:2119">12.3</a></dd>
2179 <a class="idx" href="swiorother.html#idx:qsaveprogram2:3">1.3</a> <a class="idx" href="compilation.html#idx:qsaveprogram2:77">2.10.2.4</a> <a class="idx" href="compilation.html#idx:qsaveprogram2:78">2.10.2.4</a> <a class="idx" href="compilation.html#idx:qsaveprogram2:79">2.10.2.4</a> <a class="idx" href="flags.html#idx:qsaveprogram2:106">2.11</a> <a class="idx" href="autoload.html#idx:qsaveprogram2:206">2.13</a> <a class="idx" href="projectfiles.html#idx:qsaveprogram2:302">3.1.2</a> <a class="idx" href="idepreds.html#idx:qsaveprogram2:325">3.8</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram2:2081">11.4.21</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram2:2085">11.4.21</a> <a class="idx" href="runtime.html#idx:qsaveprogram2:2102">12</a> <a class="idx" href="useresource.html#idx:qsaveprogram2:2123">12.3</a></dd>
21302180 <dt>qsave_program/[1,2]</dt>
21312181 <dd>
2132 <a class="idx" href="cmdline.html#idx:qsaveprogram12:35">2.4.2</a> <a class="idx" href="compilation.html#idx:qsaveprogram12:76">2.10.2.3</a> <a class="idx" href="flags.html#idx:qsaveprogram12:133">2.11</a> <a class="idx" href="examineprog.html#idx:qsaveprogram12:933">4.16</a> <a class="idx" href="foreignlink.html#idx:qsaveprogram12:2010">11.2.2</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram12:2076">11.4.21</a> <a class="idx" href="findhome.html#idx:qsaveprogram12:2088">11.6</a> <a class="idx" href="runtime.html#idx:qsaveprogram12:2103">12</a> <a class="idx" href="qsavelimits.html#idx:qsaveprogram12:2112">12.1</a></dd>
2182 <a class="idx" href="cmdline.html#idx:qsaveprogram12:35">2.4.2</a> <a class="idx" href="compilation.html#idx:qsaveprogram12:76">2.10.2.3</a> <a class="idx" href="flags.html#idx:qsaveprogram12:133">2.11</a> <a class="idx" href="examineprog.html#idx:qsaveprogram12:933">4.16</a> <a class="idx" href="foreignlink.html#idx:qsaveprogram12:2014">11.2.2</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram12:2080">11.4.21</a> <a class="idx" href="findhome.html#idx:qsaveprogram12:2092">11.6</a> <a class="idx" href="runtime.html#idx:qsaveprogram12:2107">12</a> <a class="idx" href="qsavelimits.html#idx:qsaveprogram12:2116">12.1</a></dd>
21332183 <dt><a class="idx" href="quasiquotations.html#quasi_quotation_syntax/1">quasi_quotation_syntax/1</a></dt>
21342184 <dd>
21352185 <a class="idx" href="examineprog.html#idx:quasiquotationsyntax1:926">4.16</a></dd>
21362186 <dt><a class="idx" href="quasiquotations.html#quasi_quotation_syntax_error/1">quasi_quotation_syntax_error/1</a></dt>
21372187 <dt>query</dt>
21382188 <dd>
2139 <a class="idx" href="glossary.html#idx:query:2296">D</a></dd>
2189 <a class="idx" href="glossary.html#idx:query:2300">D</a></dd>
21402190 <dt>quiet</dt>
21412191 <dd>
21422192 <a class="idx" href="cmdline.html#idx:quiet:26">2.4.2</a></dd>
21662216 <dt><a class="idx" href="ugraphs.html#reachable/3">reachable/3</a></dt>
21672217 <dt><a class="idx" href="termrw.html#read/1">read/1</a></dt>
21682218 <dd>
2169 <a class="idx" href="flags.html#idx:read1:87">2.11</a> <a class="idx" href="flags.html#idx:read1:93">2.11</a> <a class="idx" href="limits.html#idx:read1:283">2.20.2</a> <a class="idx" href="IO.html#idx:read1:953">4.17.1</a> <a class="idx" href="IO.html#idx:read1:969">4.17.2</a> <a class="idx" href="IO.html#idx:read1:978">4.17.2</a> <a class="idx" href="chario.html#idx:read1:1081">4.19</a> <a class="idx" href="termrw.html#idx:read1:1144">4.20</a> <a class="idx" href="termrw.html#idx:read1:1158">4.20</a> <a class="idx" href="termrw.html#idx:read1:1166">4.20</a> <a class="idx" href="termrw.html#idx:read1:1188">4.20</a> <a class="idx" href="gvar.html#idx:read1:1432">4.33.1</a> <a class="idx" href="readutil.html#idx:read1:2161">A.30</a> <a class="idx" href="predsummary.html#idx:read1:2367">F.1</a></dd>
2219 <a class="idx" href="flags.html#idx:read1:87">2.11</a> <a class="idx" href="flags.html#idx:read1:93">2.11</a> <a class="idx" href="limits.html#idx:read1:283">2.20.2</a> <a class="idx" href="IO.html#idx:read1:953">4.17.1</a> <a class="idx" href="IO.html#idx:read1:969">4.17.2</a> <a class="idx" href="IO.html#idx:read1:978">4.17.2</a> <a class="idx" href="chario.html#idx:read1:1081">4.19</a> <a class="idx" href="termrw.html#idx:read1:1144">4.20</a> <a class="idx" href="termrw.html#idx:read1:1158">4.20</a> <a class="idx" href="termrw.html#idx:read1:1166">4.20</a> <a class="idx" href="termrw.html#idx:read1:1188">4.20</a> <a class="idx" href="gvar.html#idx:read1:1432">4.33.1</a> <a class="idx" href="readutil.html#idx:read1:2165">A.30</a> <a class="idx" href="predsummary.html#idx:read1:2371">F.1</a></dd>
21702220 <dt><a class="idx" href="termrw.html#read/2">read/2</a></dt>
21712221 <dd>
21722222 <a class="idx" href="streamstat.html#idx:read2:1071">4.18</a></dd>
21832233 <a class="idx" href="termrw.html#idx:readhistory6:1185">4.20</a> <a class="idx" href="termrw.html#idx:readhistory6:1187">4.20</a></dd>
21842234 <dt><a class="idx" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a></dt>
21852235 <dd>
2186 <a class="idx" href="strings.html#idx:readlinetocodes2:1610">5.2.2</a> <a class="idx" href="readutil.html#idx:readlinetocodes2:2156">A.30</a></dd>
2236 <a class="idx" href="strings.html#idx:readlinetocodes2:1610">5.2.2</a> <a class="idx" href="readutil.html#idx:readlinetocodes2:2160">A.30</a></dd>
21872237 <dt><a class="idx" href="readutil.html#read_line_to_codes/3">read_line_to_codes/3</a></dt>
21882238 <dd>
2189 <a class="idx" href="readutil.html#idx:readlinetocodes3:2154">A.30</a></dd>
2239 <a class="idx" href="readutil.html#idx:readlinetocodes3:2158">A.30</a></dd>
21902240 <dt><a class="idx" href="files.html#read_link/3">read_link/3</a></dt>
21912241 <dt><a class="idx" href="chario.html#read_pending_chars/3">read_pending_chars/3</a></dt>
21922242 <dt><a class="idx" href="chario.html#read_pending_codes/3">read_pending_codes/3</a></dt>
21942244 <a class="idx" href="chario.html#idx:readpendingcodes3:1106">4.19</a> <a class="idx" href="chario.html#idx:readpendingcodes3:1113">4.19</a></dd>
21952245 <dt><a class="idx" href="readutil.html#read_stream_to_codes/2">read_stream_to_codes/2</a></dt>
21962246 <dd>
2197 <a class="idx" href="readutil.html#idx:readstreamtocodes2:2157">A.30</a></dd>
2247 <a class="idx" href="readutil.html#idx:readstreamtocodes2:2161">A.30</a></dd>
21982248 <dt><a class="idx" href="readutil.html#read_stream_to_codes/3">read_stream_to_codes/3</a></dt>
21992249 <dt><a class="idx" href="strings.html#read_string/3">read_string/3</a></dt>
22002250 <dt><a class="idx" href="strings.html#read_string/5">read_string/5</a></dt>
22022252 <a class="idx" href="strings.html#idx:readstring5:1603">5.2.1</a> <a class="idx" href="strings.html#idx:readstring5:1607">5.2.1</a></dd>
22032253 <dt><a class="idx" href="termrw.html#read_term/2">read_term/2</a></dt>
22042254 <dd>
2205 <a class="idx" href="flags.html#idx:readterm2:88">2.11</a> <a class="idx" href="consulting.html#idx:readterm2:493">4.3</a> <a class="idx" href="consulting.html#idx:readterm2:551">4.3.1.1</a> <a class="idx" href="termrw.html#idx:readterm2:1123">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1136">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1170">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1181">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1184">4.20</a> <a class="idx" href="manipatom.html#idx:readterm2:1270">4.22</a> <a class="idx" href="manipatom.html#idx:readterm2:1271">4.22</a> <a class="idx" href="ext-lists.html#idx:readterm2:1590">5.1</a> <a class="idx" href="ext-lists.html#idx:readterm2:1592">5.1</a> <a class="idx" href="strings.html#idx:readterm2:1597">5.2.1</a> <a class="idx" href="loadfilehook.html#idx:readterm2:2239">B.8</a> <a class="idx" href="loadfilehook.html#idx:readterm2:2240">B.8</a></dd>
2255 <a class="idx" href="flags.html#idx:readterm2:88">2.11</a> <a class="idx" href="consulting.html#idx:readterm2:493">4.3</a> <a class="idx" href="consulting.html#idx:readterm2:551">4.3.1.1</a> <a class="idx" href="termrw.html#idx:readterm2:1123">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1136">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1170">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1181">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1184">4.20</a> <a class="idx" href="manipatom.html#idx:readterm2:1270">4.22</a> <a class="idx" href="manipatom.html#idx:readterm2:1271">4.22</a> <a class="idx" href="ext-lists.html#idx:readterm2:1590">5.1</a> <a class="idx" href="ext-lists.html#idx:readterm2:1592">5.1</a> <a class="idx" href="strings.html#idx:readterm2:1597">5.2.1</a> <a class="idx" href="loadfilehook.html#idx:readterm2:2243">B.8</a> <a class="idx" href="loadfilehook.html#idx:readterm2:2244">B.8</a></dd>
22062256 <dt><a class="idx" href="termrw.html#read_term/3">read_term/3</a></dt>
22072257 <dd>
2208 <a class="idx" href="syntax.html#idx:readterm3:227">2.16.1.9</a> <a class="idx" href="termrw.html#idx:readterm3:1133">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1159">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1160">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1161">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1162">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1163">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1164">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1174">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1182">4.20</a> <a class="idx" href="charconv.html#idx:readterm3:1318">4.26</a> <a class="idx" href="toplevel.html#idx:readterm3:1534">4.37</a> <a class="idx" href="dicts.html#idx:readterm3:1647">5.4.3</a> <a class="idx" href="loadfilehook.html#idx:readterm3:2242">B.8</a></dd>
2258 <a class="idx" href="syntax.html#idx:readterm3:227">2.16.1.9</a> <a class="idx" href="termrw.html#idx:readterm3:1133">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1159">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1160">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1161">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1162">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1163">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1164">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1174">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1182">4.20</a> <a class="idx" href="charconv.html#idx:readterm3:1318">4.26</a> <a class="idx" href="toplevel.html#idx:readterm3:1534">4.37</a> <a class="idx" href="dicts.html#idx:readterm3:1651">5.4.3</a> <a class="idx" href="loadfilehook.html#idx:readterm3:2246">B.8</a></dd>
22092259 <dt>read_term/[2,3]</dt>
22102260 <dd>
22112261 <a class="idx" href="termrw.html#idx:readterm23:1177">4.20</a> <a class="idx" href="termrw.html#idx:readterm23:1178">4.20</a></dd>
22182268 <a class="idx" href="consulting.html#idx:reconsult:378">4.3</a></dd>
22192269 <dt><a class="idx" href="record.html#record/1">record/1</a></dt>
22202270 <dd>
2221 <a class="idx" href="record.html#idx:record1:2165">A.31</a></dd>
2271 <a class="idx" href="record.html#idx:record1:2169">A.31</a></dd>
22222272 <dt><a class="idx" href="db.html#recorda/2">recorda/2</a></dt>
22232273 <dd>
22242274 <a class="idx" href="db.html#idx:recorda2:842">4.14.2</a></dd>
22252275 <dt><a class="idx" href="db.html#recorda/3">recorda/3</a></dt>
22262276 <dd>
2227 <a class="idx" href="cyclic.html#idx:recorda3:244">2.17</a> <a class="idx" href="db.html#idx:recorda3:803">4.14</a> <a class="idx" href="db.html#idx:recorda3:841">4.14.2</a> <a class="idx" href="db.html#idx:recorda3:845">4.14.2</a> <a class="idx" href="examineprog.html#idx:recorda3:898">4.16</a> <a class="idx" href="gvar.html#idx:recorda3:1412">4.33</a> <a class="idx" href="foreigninclude.html#idx:recorda3:2052">11.4.14.2</a> <a class="idx" href="foreigninclude.html#idx:recorda3:2053">11.4.14.2</a> <a class="idx" href="foreigninclude.html#idx:recorda3:2054">11.4.14.2</a></dd>
2277 <a class="idx" href="cyclic.html#idx:recorda3:244">2.17</a> <a class="idx" href="db.html#idx:recorda3:803">4.14</a> <a class="idx" href="db.html#idx:recorda3:841">4.14.2</a> <a class="idx" href="db.html#idx:recorda3:845">4.14.2</a> <a class="idx" href="examineprog.html#idx:recorda3:898">4.16</a> <a class="idx" href="gvar.html#idx:recorda3:1412">4.33</a> <a class="idx" href="foreigninclude.html#idx:recorda3:2056">11.4.14.2</a> <a class="idx" href="foreigninclude.html#idx:recorda3:2057">11.4.14.2</a> <a class="idx" href="foreigninclude.html#idx:recorda3:2058">11.4.14.2</a></dd>
22282278 <dt><a class="idx" href="db.html#recorded/2">recorded/2</a></dt>
22292279 <dt><a class="idx" href="db.html#recorded/3">recorded/3</a></dt>
22302280 <dd>
2231 <a class="idx" href="db.html#idx:recorded3:806">4.14</a> <a class="idx" href="db.html#idx:recorded3:847">4.14.2</a> <a class="idx" href="qsavelimits.html#idx:recorded3:2115">12.1</a></dd>
2281 <a class="idx" href="db.html#idx:recorded3:806">4.14</a> <a class="idx" href="db.html#idx:recorded3:847">4.14.2</a> <a class="idx" href="qsavelimits.html#idx:recorded3:2119">12.1</a></dd>
22322282 <dt><a class="idx" href="db.html#recordz/2">recordz/2</a></dt>
22332283 <dd>
22342284 <a class="idx" href="db.html#idx:recordz2:843">4.14.2</a></dd>
22372287 <a class="idx" href="cyclic.html#idx:recordz3:245">2.17</a> <a class="idx" href="db.html#idx:recordz3:804">4.14</a> <a class="idx" href="db.html#idx:recordz3:846">4.14.2</a></dd>
22382288 <dt><a class="idx" href="db.html#redefine_system_predicate/1">redefine_system_predicate/1</a></dt>
22392289 <dd>
2240 <a class="idx" href="glossary.html#idx:redefinesystempredicate1:2276">D</a></dd>
2290 <a class="idx" href="glossary.html#idx:redefinesystempredicate1:2280">D</a></dd>
22412291 <dt><a class="idx" href="solutionsequences.html#reduced/1">reduced/1</a></dt>
22422292 <dt><a class="idx" href="solutionsequences.html#reduced/3">reduced/3</a></dt>
22432293 <dt><a class="idx" href="reexport.html#reexport/1">reexport/1</a></dt>
22442294 <dd>
2245 <a class="idx" href="consulting.html#idx:reexport1:384">4.3</a> <a class="idx" href="consulting.html#idx:reexport1:390">4.3</a> <a class="idx" href="consulting.html#idx:reexport1:416">4.3</a> <a class="idx" href="dialect.html#idx:reexport1:2251">C</a></dd>
2295 <a class="idx" href="consulting.html#idx:reexport1:384">4.3</a> <a class="idx" href="consulting.html#idx:reexport1:390">4.3</a> <a class="idx" href="consulting.html#idx:reexport1:416">4.3</a> <a class="idx" href="dialect.html#idx:reexport1:2255">C</a></dd>
22462296 <dt><a class="idx" href="reexport.html#reexport/2">reexport/2</a></dt>
22472297 <dd>
2248 <a class="idx" href="consulting.html#idx:reexport2:391">4.3</a> <a class="idx" href="consulting.html#idx:reexport2:408">4.3</a> <a class="idx" href="consulting.html#idx:reexport2:417">4.3</a> <a class="idx" href="dialect.html#idx:reexport2:2252">C</a></dd>
2298 <a class="idx" href="consulting.html#idx:reexport2:391">4.3</a> <a class="idx" href="consulting.html#idx:reexport2:408">4.3</a> <a class="idx" href="consulting.html#idx:reexport2:417">4.3</a> <a class="idx" href="dialect.html#idx:reexport2:2256">C</a></dd>
22492299 <dt>registry</dt>
22502300 <dd>
22512301 <a class="idx" href="limits.html#idx:registry:279">2.20.1</a></dd>
22672317 <a class="idx" href="control.html#idx:repeat0:642">4.8</a> <a class="idx" href="metacall.html#idx:repeat0:658">4.9</a> <a class="idx" href="metacall.html#idx:repeat0:671">4.9</a></dd>
22682318 <dt><a class="idx" href="error.html#representation_error/1">representation_error/1</a></dt>
22692319 <dd>
2270 <a class="idx" href="foreigninclude.html#idx:representationerror1:2030">11.4.6</a></dd>
2320 <a class="idx" href="foreigninclude.html#idx:representationerror1:2034">11.4.6</a></dd>
22712321 <dt><a class="idx" href="consulting.html#require/1">require/1</a></dt>
22722322 <dd>
2273 <a class="idx" href="dialect.html#idx:require1:2248">C</a></dd>
2323 <a class="idx" href="dialect.html#idx:require1:2252">C</a></dd>
22742324 <dt><a class="idx" href="delcont.html#reset/3">reset/3</a></dt>
22752325 <dd>
2276 <a class="idx" href="delcont.html#idx:reset3:678">4.10</a> <a class="idx" href="delcont.html#idx:reset3:684">4.10</a> <a class="idx" href="delcont.html#idx:reset3:687">4.10</a> <a class="idx" href="delcont.html#idx:reset3:689">4.10</a> <a class="idx" href="delcont.html#idx:reset3:690">4.10</a> <a class="idx" href="predsummary.html#idx:reset3:2368">F.1</a></dd>
2326 <a class="idx" href="delcont.html#idx:reset3:678">4.10</a> <a class="idx" href="delcont.html#idx:reset3:684">4.10</a> <a class="idx" href="delcont.html#idx:reset3:687">4.10</a> <a class="idx" href="delcont.html#idx:reset3:689">4.10</a> <a class="idx" href="delcont.html#idx:reset3:690">4.10</a> <a class="idx" href="predsummary.html#idx:reset3:2372">F.1</a></dd>
22772327 <dt><a class="idx" href="gensym.html#reset_gensym/0">reset_gensym/0</a></dt>
22782328 <dt><a class="idx" href="gensym.html#reset_gensym/1">reset_gensym/1</a></dt>
22792329 <dt><a class="idx" href="profile.html#reset_profiler/0">reset_profiler/0</a></dt>
22802330 <dt>residual</dt>
22812331 <dd>
2282 <a class="idx" href="coroutining.html#idx:residual:1796">7.2</a></dd>
2332 <a class="idx" href="coroutining.html#idx:residual:1800">7.2</a></dd>
22832333 <dt><a class="idx" href="useresource.html#resource/3">resource/3</a></dt>
22842334 <dd>
2285 <a class="idx" href="flags.html#idx:resource3:131">2.11</a> <a class="idx" href="runtime.html#idx:resource3:2096">12</a> <a class="idx" href="runtime.html#idx:resource3:2099">12</a> <a class="idx" href="useresource.html#idx:resource3:2120">12.3</a> <a class="idx" href="useresource.html#idx:resource3:2127">12.3.1</a> <a class="idx" href="useresource.html#idx:resource3:2128">12.3.1</a></dd>
2335 <a class="idx" href="flags.html#idx:resource3:131">2.11</a> <a class="idx" href="runtime.html#idx:resource3:2100">12</a> <a class="idx" href="runtime.html#idx:resource3:2103">12</a> <a class="idx" href="useresource.html#idx:resource3:2124">12.3</a> <a class="idx" href="useresource.html#idx:resource3:2131">12.3.1</a> <a class="idx" href="useresource.html#idx:resource3:2132">12.3.1</a></dd>
22862336 <dt><a class="idx" href="error.html#resource_error/1">resource_error/1</a></dt>
22872337 <dd>
2288 <a class="idx" href="foreigninclude.html#idx:resourceerror1:2035">11.4.6</a></dd>
2338 <a class="idx" href="foreigninclude.html#idx:resourceerror1:2039">11.4.6</a></dd>
22892339 <dt>retract</dt>
22902340 <dd>
2291 <a class="idx" href="glossary.html#idx:retract:2326">D</a></dd>
2341 <a class="idx" href="glossary.html#idx:retract:2330">D</a></dd>
22922342 <dt><a class="idx" href="db.html#retract/1">retract/1</a></dt>
22932343 <dd>
2294 <a class="idx" href="quickstart.html#idx:retract1:9">2.1.2</a> <a class="idx" href="consulting.html#idx:retract1:372">4.3</a> <a class="idx" href="consulting.html#idx:retract1:462">4.3</a> <a class="idx" href="db.html#idx:retract1:796">4.14</a> <a class="idx" href="db.html#idx:retract1:799">4.14</a> <a class="idx" href="db.html#idx:retract1:815">4.14.1</a> <a class="idx" href="db.html#idx:retract1:823">4.14.1</a> <a class="idx" href="db.html#idx:retract1:824">4.14.1</a> <a class="idx" href="db.html#idx:retract1:825">4.14.1</a> <a class="idx" href="db.html#idx:retract1:826">4.14.1</a> <a class="idx" href="db.html#idx:retract1:863">4.14.5</a> <a class="idx" href="dynamic.html#idx:retract1:881">4.15</a> <a class="idx" href="dynamic.html#idx:retract1:887">4.15</a> <a class="idx" href="examineprog.html#idx:retract1:914">4.16</a> <a class="idx" href="clp.html#idx:retract1:1767">7</a> <a class="idx" href="threadcom.html#idx:retract1:1918">9.3.3</a> <a class="idx" href="engine-examples.html#idx:retract1:1972">10.1.2</a></dd>
2344 <a class="idx" href="quickstart.html#idx:retract1:9">2.1.2</a> <a class="idx" href="consulting.html#idx:retract1:372">4.3</a> <a class="idx" href="consulting.html#idx:retract1:462">4.3</a> <a class="idx" href="db.html#idx:retract1:796">4.14</a> <a class="idx" href="db.html#idx:retract1:799">4.14</a> <a class="idx" href="db.html#idx:retract1:815">4.14.1</a> <a class="idx" href="db.html#idx:retract1:823">4.14.1</a> <a class="idx" href="db.html#idx:retract1:824">4.14.1</a> <a class="idx" href="db.html#idx:retract1:825">4.14.1</a> <a class="idx" href="db.html#idx:retract1:826">4.14.1</a> <a class="idx" href="db.html#idx:retract1:863">4.14.5</a> <a class="idx" href="dynamic.html#idx:retract1:881">4.15</a> <a class="idx" href="dynamic.html#idx:retract1:887">4.15</a> <a class="idx" href="examineprog.html#idx:retract1:914">4.16</a> <a class="idx" href="clp.html#idx:retract1:1771">7</a> <a class="idx" href="threadcom.html#idx:retract1:1922">9.3.3</a> <a class="idx" href="engine-examples.html#idx:retract1:1976">10.1.2</a></dd>
22952345 <dt><a class="idx" href="db.html#retractall/1">retractall/1</a></dt>
22962346 <dd>
22972347 <a class="idx" href="db.html#idx:retractall1:797">4.14</a> <a class="idx" href="db.html#idx:retractall1:800">4.14</a> <a class="idx" href="db.html#idx:retractall1:816">4.14.1</a> <a class="idx" href="db.html#idx:retractall1:819">4.14.1</a></dd>
22982348 <dt><a class="idx" href="predicate_options.html#retractall_predicate_options/0">retractall_predicate_options/0</a></dt>
22992349 <dt>rev/3</dt>
23002350 <dd>
2301 <a class="idx" href="defmodule.html#idx:rev3:1663">6.2</a></dd>
2351 <a class="idx" href="defmodule.html#idx:rev3:1667">6.2</a></dd>
23022352 <dt><a class="idx" href="lists.html#reverse/2">reverse/2</a></dt>
23032353 <dd>
2304 <a class="idx" href="DCG.html#idx:reverse2:791">4.13</a> <a class="idx" href="defmodule.html#idx:reverse2:1662">6.2</a></dd>
2354 <a class="idx" href="DCG.html#idx:reverse2:791">4.13</a> <a class="idx" href="defmodule.html#idx:reverse2:1666">6.2</a></dd>
23052355 <dt><a class="idx" href="files.html#same_file/2">same_file/2</a></dt>
23062356 <dd>
23072357 <a class="idx" href="files.html#idx:samefile2:1496">4.36</a> <a class="idx" href="files.html#idx:samefile2:1497">4.36</a> <a class="idx" href="files.html#idx:samefile2:1500">4.36</a> <a class="idx" href="files.html#idx:samefile2:1501">4.36</a></dd>
23322382 <dt><a class="idx" href="lists.html#select/4">select/4</a></dt>
23332383 <dt>select_dict/2</dt>
23342384 <dd>
2335 <a class="idx" href="dicts.html#idx:selectdict2:1637">5.4.2</a></dd>
2385 <a class="idx" href="dicts.html#idx:selectdict2:1641">5.4.2</a></dd>
23362386 <dt><a class="idx" href="dicts.html#select_dict/3">select_dict/3</a></dt>
23372387 <dd>
2338 <a class="idx" href="dicts.html#idx:selectdict3:1638">5.4.2</a></dd>
2388 <a class="idx" href="dicts.html#idx:selectdict3:1642">5.4.2</a></dd>
23392389 <dt><a class="idx" href="option.html#select_option/3">select_option/3</a></dt>
23402390 <dt><a class="idx" href="option.html#select_option/4">select_option/4</a></dt>
23412391 <dt><a class="idx" href="lists.html#selectchk/3">selectchk/3</a></dt>
23422392 <dt><a class="idx" href="lists.html#selectchk/4">selectchk/4</a></dt>
23432393 <dt>semi deterministic</dt>
23442394 <dd>
2345 <a class="idx" href="glossary.html#idx:semideterministic:2328">D</a></dd>
2395 <a class="idx" href="glossary.html#idx:semideterministic:2332">D</a></dd>
23462396 <dt>semidet</dt>
23472397 <dd>
2348 <a class="idx" href="glossary.html#idx:semidet:2327">D</a></dd>
2349 <dt><a class="idx" href="control.html#send_arrow/2">send_arrow/2</a></dt>
2398 <a class="idx" href="glossary.html#idx:semidet:2331">D</a></dd>
23502399 <dt>serialize</dt>
23512400 <dd>
23522401 <a class="idx" href="DCG.html#idx:serialize:778">4.13</a></dd>
23532402 <dt><a class="idx" href="clpfd.html#serialized/2">serialized/2</a></dt>
23542403 <dt>set_breakpoint/4</dt>
23552404 <dd>
2356 <a class="idx" href="breakpoint.html#idx:setbreakpoint4:2199">B.4</a></dd>
2405 <a class="idx" href="breakpoint.html#idx:setbreakpoint4:2203">B.4</a></dd>
23572406 <dt><a class="idx" href="chario.html#set_end_of_stream/1">set_end_of_stream/1</a></dt>
23582407 <dt><a class="idx" href="db.html#set_flag/2">set_flag/2</a></dt>
23592408 <dt><a class="idx" href="IO.html#set_input/1">set_input/1</a></dt>
23622411 <dt><a class="idx" href="locale.html#set_locale/1">set_locale/1</a></dt>
23632412 <dt><a class="idx" href="manipmodule.html#set_module/1">set_module/1</a></dt>
23642413 <dd>
2365 <a class="idx" href="db.html#idx:setmodule1:833">4.14.1</a> <a class="idx" href="importmodule.html#idx:setmodule1:1718">6.9</a> <a class="idx" href="manipmodule.html#idx:setmodule1:1747">6.14</a></dd>
2414 <a class="idx" href="db.html#idx:setmodule1:833">4.14.1</a> <a class="idx" href="importmodule.html#idx:setmodule1:1722">6.9</a> <a class="idx" href="manipmodule.html#idx:setmodule1:1751">6.14</a></dd>
23662415 <dt><a class="idx" href="IO.html#set_output/1">set_output/1</a></dt>
23672416 <dd>
23682417 <a class="idx" href="IO.html#idx:setoutput1:959">4.17.1</a> <a class="idx" href="IO.html#idx:setoutput1:1045">4.17.3</a></dd>
23692418 <dt><a class="idx" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a></dt>
23702419 <dd>
2371 <a class="idx" href="history.html#idx:setprologflag2:53">2.7</a> <a class="idx" href="flags.html#idx:setprologflag2:81">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:83">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:150">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:166">2.11</a> <a class="idx" href="consulting.html#idx:setprologflag2:376">4.3</a> <a class="idx" href="arith.html#idx:setprologflag2:1324">4.27.2</a> <a class="idx" href="foreigninclude.html#idx:setprologflag2:2058">11.4.14.4</a></dd>
2420 <a class="idx" href="history.html#idx:setprologflag2:53">2.7</a> <a class="idx" href="flags.html#idx:setprologflag2:81">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:83">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:150">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:166">2.11</a> <a class="idx" href="consulting.html#idx:setprologflag2:376">4.3</a> <a class="idx" href="arith.html#idx:setprologflag2:1324">4.27.2</a> <a class="idx" href="foreigninclude.html#idx:setprologflag2:2062">11.4.14.4</a></dd>
23722421 <dt><a class="idx" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a></dt>
23732422 <dd>
2374 <a class="idx" href="cmdline.html#idx:setprologstack2:41">2.4.3</a> <a class="idx" href="limits.html#idx:setprologstack2:278">2.20.1</a> <a class="idx" href="limits.html#idx:setprologstack2:280">2.20.1</a> <a class="idx" href="debugger.html#idx:setprologstack2:1555">4.39</a> <a class="idx" href="memory.html#idx:setprologstack2:1584">4.42</a> <a class="idx" href="strings.html#idx:setprologstack2:1594">5.2</a> <a class="idx" href="threadcreate.html#idx:setprologstack2:1849">9.1</a></dd>
2423 <a class="idx" href="cmdline.html#idx:setprologstack2:41">2.4.3</a> <a class="idx" href="limits.html#idx:setprologstack2:278">2.20.1</a> <a class="idx" href="limits.html#idx:setprologstack2:280">2.20.1</a> <a class="idx" href="debugger.html#idx:setprologstack2:1555">4.39</a> <a class="idx" href="memory.html#idx:setprologstack2:1584">4.42</a> <a class="idx" href="strings.html#idx:setprologstack2:1594">5.2</a> <a class="idx" href="threadcreate.html#idx:setprologstack2:1853">9.1</a></dd>
23752424 <dt><a class="idx" href="miscarith.html#set_random/1">set_random/1</a></dt>
23762425 <dd>
23772426 <a class="idx" href="arith.html#idx:setrandom1:1334">4.27.2.3</a> <a class="idx" href="miscarith.html#idx:setrandom1:1341">4.28</a></dd>
23842433 <dt><a class="idx" href="url.html#set_url_encoding/2">set_url_encoding/2</a></dt>
23852434 <dt><a class="idx" href="manipterm.html#setarg/3">setarg/3</a></dt>
23862435 <dd>
2387 <a class="idx" href="preddesc.html#idx:setarg3:335">4.1</a> <a class="idx" href="db.html#idx:setarg3:811">4.14</a> <a class="idx" href="manipterm.html#idx:setarg3:1216">4.21</a> <a class="idx" href="manipterm.html#idx:setarg3:1218">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1220">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1221">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1224">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1234">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1239">4.21.1</a> <a class="idx" href="gvar.html#idx:setarg3:1434">4.33.1</a> <a class="idx" href="dicts.html#idx:setarg3:1640">5.4.2.1</a> <a class="idx" href="attvar.html#idx:setarg3:1775">7.1</a> <a class="idx" href="attvar.html#idx:setarg3:1778">7.1.1</a> <a class="idx" href="record.html#idx:setarg3:2167">A.31</a></dd>
2436 <a class="idx" href="preddesc.html#idx:setarg3:335">4.1</a> <a class="idx" href="db.html#idx:setarg3:811">4.14</a> <a class="idx" href="manipterm.html#idx:setarg3:1216">4.21</a> <a class="idx" href="manipterm.html#idx:setarg3:1218">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1220">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1221">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1224">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1234">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1239">4.21.1</a> <a class="idx" href="gvar.html#idx:setarg3:1434">4.33.1</a> <a class="idx" href="dicts.html#idx:setarg3:1644">5.4.2.1</a> <a class="idx" href="attvar.html#idx:setarg3:1779">7.1</a> <a class="idx" href="attvar.html#idx:setarg3:1782">7.1.1</a> <a class="idx" href="record.html#idx:setarg3:2171">A.31</a></dd>
23882437 <dt><a class="idx" href="system.html#setenv/2">setenv/2</a></dt>
23892438 <dd>
23902439 <a class="idx" href="system.html#idx:setenv2:1452">4.35</a></dd>
23912440 <dt>setlocale/1</dt>
23922441 <dd>
2393 <a class="idx" href="threadcreate.html#idx:setlocale1:1848">9.1</a></dd>
2442 <a class="idx" href="threadcreate.html#idx:setlocale1:1852">9.1</a></dd>
23942443 <dt><a class="idx" href="system.html#setlocale/3">setlocale/3</a></dt>
23952444 <dd>
23962445 <a class="idx" href="chartype.html#idx:setlocale3:1313">4.24.3</a> <a class="idx" href="system.html#idx:setlocale3:1455">4.35</a></dd>
23972446 <dt><a class="idx" href="allsolutions.html#setof/3">setof/3</a></dt>
23982447 <dd>
2399 <a class="idx" href="cyclic.html#idx:setof3:246">2.17</a> <a class="idx" href="metapred.html#idx:setof3:1693">6.4</a> <a class="idx" href="predsummary.html#idx:setof3:2348">F.1</a></dd>
2448 <a class="idx" href="cyclic.html#idx:setof3:246">2.17</a> <a class="idx" href="metapred.html#idx:setof3:1697">6.4</a> <a class="idx" href="predsummary.html#idx:setof3:2352">F.1</a></dd>
24002449 <dt><a class="idx" href="random.html#setrand/1">setrand/1</a></dt>
24012450 <dt><a class="idx" href="metacall.html#setup_call_catcher_cleanup/4">setup_call_catcher_cleanup/4</a></dt>
24022451 <dt>setup_call_cleanup/2</dt>
24032452 <dd>
2404 <a class="idx" href="threadsync.html#idx:setupcallcleanup2:1923">9.4</a></dd>
2453 <a class="idx" href="threadsync.html#idx:setupcallcleanup2:1927">9.4</a></dd>
24052454 <dt><a class="idx" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a></dt>
24062455 <dd>
2407 <a class="idx" href="metacall.html#idx:setupcallcleanup3:670">4.9</a> <a class="idx" href="metacall.html#idx:setupcallcleanup3:672">4.9</a> <a class="idx" href="metacall.html#idx:setupcallcleanup3:676">4.9</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:711">4.11.1</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:716">4.11.1</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:719">4.11.1</a> <a class="idx" href="threadcreate.html#idx:setupcallcleanup3:1861">9.1</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1927">9.4</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1931">9.4</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1934">9.4</a></dd>
2456 <a class="idx" href="metacall.html#idx:setupcallcleanup3:670">4.9</a> <a class="idx" href="metacall.html#idx:setupcallcleanup3:672">4.9</a> <a class="idx" href="metacall.html#idx:setupcallcleanup3:676">4.9</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:711">4.11.1</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:716">4.11.1</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:719">4.11.1</a> <a class="idx" href="threadcreate.html#idx:setupcallcleanup3:1865">9.1</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1931">9.4</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1935">9.4</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1938">9.4</a></dd>
24082457 <dt><a class="idx" href="simplex.html#shadow_price/3">shadow_price/3</a></dt>
24092458 <dt>shared</dt>
24102459 <dd>
2411 <a class="idx" href="glossary.html#idx:shared:2329">D</a></dd>
2460 <a class="idx" href="glossary.html#idx:shared:2333">D</a></dd>
24122461 <dt>shell/0</dt>
24132462 <dd>
24142463 <a class="idx" href="system.html#idx:shell0:1461">4.35</a></dd>
24272476 <dt><a class="idx" href="registry.html#shell_register_dde/6">shell_register_dde/6</a></dt>
24282477 <dt><a class="idx" href="registry.html#shell_register_file_type/4">shell_register_file_type/4</a></dt>
24292478 <dd>
2430 <a class="idx" href="registry.html#idx:shellregisterfiletype4:2170">A.32</a></dd>
2479 <a class="idx" href="registry.html#idx:shellregisterfiletype4:2174">A.32</a></dd>
24312480 <dt><a class="idx" href="registry.html#shell_register_prolog/1">shell_register_prolog/1</a></dt>
24322481 <dt><a class="idx" href="delcont.html#shift/1">shift/1</a></dt>
24332482 <dd>
24372486 <a class="idx" href="profile.html#idx:showprofile1:1568">4.41.1</a> <a class="idx" href="profile.html#idx:showprofile1:1569">4.41.1</a></dd>
24382487 <dt>singleton</dt>
24392488 <dd>
2440 <a class="idx" href="glossary.html#idx:singleton:2330">D</a></dd>
2489 <a class="idx" href="glossary.html#idx:singleton:2334">D</a></dd>
24412490 <dt>singleton,variable</dt>
24422491 <dd>
24432492 <a class="idx" href="syntax.html#idx:singletonvariable:222">2.16.1.9</a></dd>
24522501 <a class="idx" href="cmdline.html#idx:sleep1:29">2.4.2</a> <a class="idx" href="miscpreds.html#idx:sleep1:1587">4.44</a></dd>
24532502 <dt>solution</dt>
24542503 <dd>
2455 <a class="idx" href="glossary.html#idx:solution:2331">D</a></dd>
2504 <a class="idx" href="glossary.html#idx:solution:2335">D</a></dd>
24562505 <dt><a class="idx" href="builtinlist.html#sort/2">sort/2</a></dt>
24572506 <dd>
24582507 <a class="idx" href="compare.html#idx:sort2:625">4.7.1</a> <a class="idx" href="metacall.html#idx:sort2:663">4.9</a> <a class="idx" href="builtinlist.html#idx:sort2:1348">4.29</a> <a class="idx" href="builtinlist.html#idx:sort2:1350">4.29</a> <a class="idx" href="builtinlist.html#idx:sort2:1355">4.29</a> <a class="idx" href="builtinlist.html#idx:sort2:1357">4.29</a> <a class="idx" href="builtinlist.html#idx:sort2:1359">4.29</a> <a class="idx" href="allsolutions.html#idx:sort2:1374">4.30</a></dd>
24592508 <dt><a class="idx" href="builtinlist.html#sort/4">sort/4</a></dt>
24602509 <dt><a class="idx" href="dialect.html#source_exports/2">source_exports/2</a></dt>
24612510 <dd>
2462 <a class="idx" href="dialect.html#idx:sourceexports2:2247">C</a></dd>
2511 <a class="idx" href="dialect.html#idx:sourceexports2:2251">C</a></dd>
24632512 <dt><a class="idx" href="consulting.html#source_file/1">source_file/1</a></dt>
24642513 <dt><a class="idx" href="consulting.html#source_file/2">source_file/2</a></dt>
24652514 <dd>
24752524 <a class="idx" href="manipatom.html#idx:splitstring4:1277">4.22</a> <a class="idx" href="strings.html#idx:splitstring4:1606">5.2.1</a> <a class="idx" href="strings.html#idx:splitstring4:1608">5.2.1</a></dd>
24762525 <dt><a class="idx" href="debugger.html#spy/1">spy/1</a></dt>
24772526 <dd>
2478 <a class="idx" href="debugoverview.html#idx:spy1:56">2.9</a> <a class="idx" href="debugoverview.html#idx:spy1:61">2.9</a> <a class="idx" href="flags.html#idx:spy1:102">2.11</a> <a class="idx" href="flags.html#idx:spy1:115">2.11</a> <a class="idx" href="hooks.html#idx:spy1:182">2.12</a> <a class="idx" href="guitracer.html#idx:spy1:318">3.5.1</a> <a class="idx" href="guitracer.html#idx:spy1:320">3.5.1</a> <a class="idx" href="idesummary.html#idx:spy1:333">3.9</a> <a class="idx" href="preddesc.html#idx:spy1:338">4.1</a> <a class="idx" href="mtoplevel.html#idx:spy1:1705">6.6</a> <a class="idx" href="thutil.html#idx:spy1:1945">9.5.1</a> <a class="idx" href="thutil.html#idx:spy1:1947">9.5.1</a> <a class="idx" href="intlibs.html#idx:spy1:2221">B.7</a> <a class="idx" href="intlibs.html#idx:spy1:2222">B.7</a> <a class="idx" href="intlibs.html#idx:spy1:2225">B.7</a> <a class="idx" href="predsummary.html#idx:spy1:2354">F.1</a></dd>
2527 <a class="idx" href="debugoverview.html#idx:spy1:56">2.9</a> <a class="idx" href="debugoverview.html#idx:spy1:61">2.9</a> <a class="idx" href="flags.html#idx:spy1:102">2.11</a> <a class="idx" href="flags.html#idx:spy1:115">2.11</a> <a class="idx" href="hooks.html#idx:spy1:182">2.12</a> <a class="idx" href="guitracer.html#idx:spy1:318">3.5.1</a> <a class="idx" href="guitracer.html#idx:spy1:320">3.5.1</a> <a class="idx" href="idesummary.html#idx:spy1:333">3.9</a> <a class="idx" href="preddesc.html#idx:spy1:338">4.1</a> <a class="idx" href="mtoplevel.html#idx:spy1:1709">6.6</a> <a class="idx" href="thutil.html#idx:spy1:1949">9.5.1</a> <a class="idx" href="thutil.html#idx:spy1:1951">9.5.1</a> <a class="idx" href="intlibs.html#idx:spy1:2225">B.7</a> <a class="idx" href="intlibs.html#idx:spy1:2226">B.7</a> <a class="idx" href="intlibs.html#idx:spy1:2229">B.7</a> <a class="idx" href="predsummary.html#idx:spy1:2358">F.1</a></dd>
24792528 <dt>stack,memory management</dt>
24802529 <dd>
24812530 <a class="idx" href="limits.html#idx:stackmemorymanagement:281">2.20.1.1</a></dd>
24902539 <a class="idx" href="exception.html#idx:statistics0:737">4.11.4</a></dd>
24912540 <dt><a class="idx" href="statistics.html#statistics/2">statistics/2</a></dt>
24922541 <dd>
2493 <a class="idx" href="arith.html#idx:statistics2:1338">4.27.2.3</a> <a class="idx" href="statistics.html#idx:statistics2:1562">4.40</a> <a class="idx" href="statistics.html#idx:statistics2:1564">4.40</a> <a class="idx" href="thmonitor.html#idx:statistics2:1880">9.2</a> <a class="idx" href="thmonitor.html#idx:statistics2:1881">9.2</a></dd>
2542 <a class="idx" href="arith.html#idx:statistics2:1338">4.27.2.3</a> <a class="idx" href="statistics.html#idx:statistics2:1562">4.40</a> <a class="idx" href="statistics.html#idx:statistics2:1564">4.40</a> <a class="idx" href="thmonitor.html#idx:statistics2:1884">9.2</a> <a class="idx" href="thmonitor.html#idx:statistics2:1885">9.2</a></dd>
24942543 <dt><a class="idx" href="IO.html#stream_pair/3">stream_pair/3</a></dt>
24952544 <dd>
24962545 <a class="idx" href="IO.html#idx:streampair3:968">4.17.2</a> <a class="idx" href="IO.html#idx:streampair3:981">4.17.2</a> <a class="idx" href="IO.html#idx:streampair3:1013">4.17.2</a></dd>
24972546 <dt><a class="idx" href="IO.html#stream_position_data/3">stream_position_data/3</a></dt>
24982547 <dd>
2499 <a class="idx" href="consulting.html#idx:streampositiondata3:491">4.3</a> <a class="idx" href="IO.html#idx:streampositiondata3:988">4.17.2</a> <a class="idx" href="termrw.html#idx:streampositiondata3:1169">4.20</a> <a class="idx" href="loadfilehook.html#idx:streampositiondata3:2241">B.8</a></dd>
2548 <a class="idx" href="consulting.html#idx:streampositiondata3:491">4.3</a> <a class="idx" href="IO.html#idx:streampositiondata3:988">4.17.2</a> <a class="idx" href="termrw.html#idx:streampositiondata3:1169">4.20</a> <a class="idx" href="loadfilehook.html#idx:streampositiondata3:2245">B.8</a></dd>
25002549 <dt><a class="idx" href="IO.html#stream_property/2">stream_property/2</a></dt>
25012550 <dd>
25022551 <a class="idx" href="widechars.html#idx:streamproperty2:276">2.19.1.1</a> <a class="idx" href="consulting.html#idx:streamproperty2:490">4.3</a> <a class="idx" href="IO.html#idx:streamproperty2:974">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:996">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:998">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1005">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1011">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1014">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1019">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1021">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1022">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1028">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1029">4.17.2</a> <a class="idx" href="termrw.html#idx:streamproperty2:1179">4.20</a></dd>
25202569 <dt><a class="idx" href="strings.html#string_upper/2">string_upper/2</a></dt>
25212570 <dt><a class="idx" href="ctxmodule.html#strip_module/3">strip_module/3</a></dt>
25222571 <dd>
2523 <a class="idx" href="metapred.html#idx:stripmodule3:1701">6.4</a> <a class="idx" href="ctxmodule.html#idx:stripmodule3:1743">6.13</a> <a class="idx" href="modulecompat.html#idx:stripmodule3:1753">6.15</a></dd>
2572 <a class="idx" href="metapred.html#idx:stripmodule3:1705">6.4</a> <a class="idx" href="ctxmodule.html#idx:stripmodule3:1747">6.13</a> <a class="idx" href="modulecompat.html#idx:stripmodule3:1757">6.15</a></dd>
25242573 <dt>structure</dt>
25252574 <dd>
2526 <a class="idx" href="glossary.html#idx:structure:2332">D</a></dd>
2575 <a class="idx" href="glossary.html#idx:structure:2336">D</a></dd>
25272576 <dt><a class="idx" href="debugger.html#style_check/1">style_check/1</a></dt>
25282577 <dd>
25292578 <a class="idx" href="syntax.html#idx:stylecheck1:224">2.16.1.9</a> <a class="idx" href="syntax.html#idx:stylecheck1:225">2.16.1.9</a> <a class="idx" href="consulting.html#idx:stylecheck1:420">4.3</a> <a class="idx" href="dynamic.html#idx:stylecheck1:889">4.15</a></dd>
25472596 <a class="idx" href="arith.html#idx:succ2:1322">4.27.1</a></dd>
25482597 <dt>succeed</dt>
25492598 <dd>
2550 <a class="idx" href="glossary.html#idx:succeed:2333">D</a></dd>
2599 <a class="idx" href="glossary.html#idx:succeed:2337">D</a></dd>
25512600 <dt><a class="idx" href="clpfd.html#sum/3">sum/3</a></dt>
25522601 <dt><a class="idx" href="lists.html#sum_list/2">sum_list/2</a></dt>
25532602 <dt><a class="idx" href="clpqr.html#sup/2">sup/2</a></dt>
25552604 <dt><a class="idx" href="format.html#swritef/3">swritef/3</a></dt>
25562605 <dd>
25572606 <a class="idx" href="IO.html#idx:swritef3:1051">4.17.5</a> <a class="idx" href="format.html#idx:swritef3:1385">4.32</a></dd>
2607 <dt><a class="idx" href="pio.html#syntax_error//1">syntax_error//1</a></dt>
25582608 <dt><a class="idx" href="error.html#syntax_error/1">syntax_error/1</a></dt>
25592609 <dt><a class="idx" href="chario.html#tab/1">tab/1</a></dt>
25602610 <dt><a class="idx" href="chario.html#tab/2">tab/2</a></dt>
25612611 <dt><a class="idx" href="tabling.html#table/1">table/1</a></dt>
25622612 <dd>
2563 <a class="idx" href="flags.html#idx:table1:136">2.11</a> <a class="idx" href="tabling.html#idx:table1:2172">A.35</a> <a class="idx" href="tabling.html#idx:table1:2173">A.35.2</a> <a class="idx" href="tabling.html#idx:table1:2175">A.35.1.1</a></dd>
2613 <a class="idx" href="flags.html#idx:table1:136">2.11</a> <a class="idx" href="tabling.html#idx:table1:2176">A.35</a> <a class="idx" href="tabling.html#idx:table1:2177">A.35.2</a> <a class="idx" href="tabling.html#idx:table1:2179">A.35.1.1</a></dd>
25642614 <dt><a class="idx" href="clpb.html#taut/2">taut/2</a></dt>
25652615 <dt><a class="idx" href="thutil.html#tdebug/0">tdebug/0</a></dt>
25662616 <dd>
2567 <a class="idx" href="threadcreate.html#idx:tdebug0:1837">9.1</a> <a class="idx" href="thutil.html#idx:tdebug0:1948">9.5.1</a></dd>
2617 <a class="idx" href="threadcreate.html#idx:tdebug0:1841">9.1</a> <a class="idx" href="thutil.html#idx:tdebug0:1952">9.5.1</a></dd>
25682618 <dt><a class="idx" href="thutil.html#tdebug/1">tdebug/1</a></dt>
25692619 <dd>
2570 <a class="idx" href="thutil.html#idx:tdebug1:1944">9.5.1</a> <a class="idx" href="thutil.html#idx:tdebug1:1946">9.5.1</a></dd>
2620 <a class="idx" href="thutil.html#idx:tdebug1:1948">9.5.1</a> <a class="idx" href="thutil.html#idx:tdebug1:1950">9.5.1</a></dd>
25712621 <dt><a class="idx" href="IO.html#tell/1">tell/1</a></dt>
25722622 <dd>
25732623 <a class="idx" href="IO.html#idx:tell1:949">4.17</a> <a class="idx" href="IO.html#idx:tell1:957">4.17.1</a> <a class="idx" href="IO.html#idx:tell1:1032">4.17.3</a> <a class="idx" href="IO.html#idx:tell1:1037">4.17.3</a> <a class="idx" href="IO.html#idx:tell1:1040">4.17.3</a> <a class="idx" href="IO.html#idx:tell1:1042">4.17.3</a> <a class="idx" href="IO.html#idx:tell1:1046">4.17.3</a></dd>
25762626 <a class="idx" href="IO.html#idx:telling1:1035">4.17.3</a> <a class="idx" href="IO.html#idx:telling1:1038">4.17.3</a> <a class="idx" href="files.html#idx:telling1:1521">4.36</a></dd>
25772627 <dt>term</dt>
25782628 <dd>
2579 <a class="idx" href="glossary.html#idx:term:2334">D</a></dd>
2629 <a class="idx" href="glossary.html#idx:term:2338">D</a></dd>
25802630 <dt>term//1</dt>
25812631 <dd>
25822632 <a class="idx" href="IO.html#idx:term1:1055">4.17.5</a></dd>
25832633 <dt><a class="idx" href="attvar.html#term_attvars/2">term_attvars/2</a></dt>
25842634 <dd>
2585 <a class="idx" href="attvar.html#idx:termattvars2:1788">7.1.3</a></dd>
2635 <a class="idx" href="attvar.html#idx:termattvars2:1792">7.1.3</a></dd>
25862636 <dt><a class="idx" href="consulting.html#term_expansion/2">term_expansion/2</a></dt>
25872637 <dd>
2588 <a class="idx" href="flags.html#idx:termexpansion2:163">2.11</a> <a class="idx" href="hooks.html#idx:termexpansion2:174">2.12</a> <a class="idx" href="consulting.html#idx:termexpansion2:367">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:373">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:484">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:514">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:516">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:518">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:523">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:525">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:529">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:532">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:553">4.3.1.2</a> <a class="idx" href="consulting.html#idx:termexpansion2:562">4.3.2</a> <a class="idx" href="consulting.html#idx:termexpansion2:580">4.3.3</a> <a class="idx" href="toplevel.html#idx:termexpansion2:1537">4.37</a> <a class="idx" href="practical.html#idx:termexpansion2:1813">8.3.3</a> <a class="idx" href="portabilitystrategies.html#idx:termexpansion2:2257">C.1</a></dd>
2638 <a class="idx" href="flags.html#idx:termexpansion2:163">2.11</a> <a class="idx" href="hooks.html#idx:termexpansion2:174">2.12</a> <a class="idx" href="consulting.html#idx:termexpansion2:367">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:373">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:484">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:514">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:516">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:518">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:523">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:525">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:529">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:532">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:553">4.3.1.2</a> <a class="idx" href="consulting.html#idx:termexpansion2:562">4.3.2</a> <a class="idx" href="consulting.html#idx:termexpansion2:580">4.3.3</a> <a class="idx" href="toplevel.html#idx:termexpansion2:1537">4.37</a> <a class="idx" href="practical.html#idx:termexpansion2:1817">8.3.3</a> <a class="idx" href="portabilitystrategies.html#idx:termexpansion2:2261">C.1</a></dd>
25892639 <dt><a class="idx" href="consulting.html#term_expansion/4">term_expansion/4</a></dt>
25902640 <dd>
25912641 <a class="idx" href="consulting.html#idx:termexpansion4:368">4.3</a></dd>
26062656 <dt><a class="idx" href="compare.html#term_subsumer/3">term_subsumer/3</a></dt>
26072657 <dt><a class="idx" href="manipatom.html#term_to_atom/2">term_to_atom/2</a></dt>
26082658 <dd>
2609 <a class="idx" href="IO.html#idx:termtoatom2:1052">4.17.5</a> <a class="idx" href="foreigninclude.html#idx:termtoatom2:2027">11.4.5</a></dd>
2659 <a class="idx" href="IO.html#idx:termtoatom2:1052">4.17.5</a> <a class="idx" href="foreigninclude.html#idx:termtoatom2:2031">11.4.5</a></dd>
26102660 <dt><a class="idx" href="manipterm.html#term_variables/2">term_variables/2</a></dt>
26112661 <dd>
26122662 <a class="idx" href="cyclic.html#idx:termvariables2:248">2.17</a> <a class="idx" href="typetest.html#idx:termvariables2:619">4.6</a> <a class="idx" href="termrw.html#idx:termvariables2:1180">4.20</a> <a class="idx" href="manipterm.html#idx:termvariables2:1207">4.21</a> <a class="idx" href="manipterm.html#idx:termvariables2:1212">4.21</a> <a class="idx" href="manipterm.html#idx:termvariables2:1213">4.21</a></dd>
26192669 <dt><a class="idx" href="strings.html#text_to_string/2">text_to_string/2</a></dt>
26202670 <dt><a class="idx" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a></dt>
26212671 <dd>
2622 <a class="idx" href="toplevel.html#idx:threadatexit1:1532">4.37</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1832">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1833">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1834">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1835">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1868">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1869">9.1</a> <a class="idx" href="foreignthread.html#idx:threadatexit1:1954">9.6.1</a></dd>
2672 <a class="idx" href="toplevel.html#idx:threadatexit1:1532">4.37</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1836">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1837">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1838">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1839">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1872">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1873">9.1</a> <a class="idx" href="foreignthread.html#idx:threadatexit1:1958">9.6.1</a></dd>
26232673 <dt><a class="idx" href="threadcreate.html#thread_create/2">thread_create/2</a></dt>
26242674 <dt><a class="idx" href="threadcreate.html#thread_create/3">thread_create/3</a></dt>
26252675 <dd>
2626 <a class="idx" href="threadcreate.html#idx:threadcreate3:1827">9.1</a> <a class="idx" href="threadcreate.html#idx:threadcreate3:1856">9.1</a> <a class="idx" href="threadcreate.html#idx:threadcreate3:1870">9.1</a> <a class="idx" href="mt-xpce.html#idx:threadcreate3:1962">9.7</a> <a class="idx" href="engine-predicates.html#idx:threadcreate3:1992">10.3</a></dd>
2676 <a class="idx" href="threadcreate.html#idx:threadcreate3:1831">9.1</a> <a class="idx" href="threadcreate.html#idx:threadcreate3:1860">9.1</a> <a class="idx" href="threadcreate.html#idx:threadcreate3:1874">9.1</a> <a class="idx" href="mt-xpce.html#idx:threadcreate3:1966">9.7</a> <a class="idx" href="engine-predicates.html#idx:threadcreate3:1996">10.3</a></dd>
26272677 <dt><a class="idx" href="threadpool.html#thread_create_in_pool/4">thread_create_in_pool/4</a></dt>
26282678 <dd>
2629 <a class="idx" href="threadcreate.html#idx:threadcreateinpool4:1845">9.1</a></dd>
2679 <a class="idx" href="threadcreate.html#idx:threadcreateinpool4:1849">9.1</a></dd>
26302680 <dt><a class="idx" href="threadcreate.html#thread_detach/1">thread_detach/1</a></dt>
26312681 <dd>
2632 <a class="idx" href="threadcreate.html#idx:threaddetach1:1829">9.1</a> <a class="idx" href="threadcreate.html#idx:threaddetach1:1841">9.1</a></dd>
2682 <a class="idx" href="threadcreate.html#idx:threaddetach1:1833">9.1</a> <a class="idx" href="threadcreate.html#idx:threaddetach1:1845">9.1</a></dd>
26332683 <dt><a class="idx" href="threadcreate.html#thread_exit/1">thread_exit/1</a></dt>
26342684 <dd>
2635 <a class="idx" href="threadcreate.html#idx:threadexit1:1855">9.1</a> <a class="idx" href="thmonitor.html#idx:threadexit1:1875">9.2</a> <a class="idx" href="threadsync.html#idx:threadexit1:1935">9.4</a></dd>
2685 <a class="idx" href="threadcreate.html#idx:threadexit1:1859">9.1</a> <a class="idx" href="thmonitor.html#idx:threadexit1:1879">9.2</a> <a class="idx" href="threadsync.html#idx:threadexit1:1939">9.4</a></dd>
26362686 <dt><a class="idx" href="threadcom.html#thread_get_message/1">thread_get_message/1</a></dt>
26372687 <dd>
2638 <a class="idx" href="threadcom.html#idx:threadgetmessage1:1899">9.3.1</a> <a class="idx" href="engine-examples.html#idx:threadgetmessage1:1980">10.1.3</a></dd>
2688 <a class="idx" href="threadcom.html#idx:threadgetmessage1:1903">9.3.1</a> <a class="idx" href="engine-examples.html#idx:threadgetmessage1:1984">10.1.3</a></dd>
26392689 <dt><a class="idx" href="threadcom.html#thread_get_message/2">thread_get_message/2</a></dt>
26402690 <dd>
2641 <a class="idx" href="threadcom.html#idx:threadgetmessage2:1898">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage2:1901">9.3.1</a></dd>
2691 <a class="idx" href="threadcom.html#idx:threadgetmessage2:1902">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage2:1905">9.3.1</a></dd>
26422692 <dt><a class="idx" href="threadcom.html#thread_get_message/3">thread_get_message/3</a></dt>
26432693 <dd>
2644 <a class="idx" href="threadcom.html#idx:threadgetmessage3:1887">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1894">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1903">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1904">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1906">9.3.1</a></dd>
2694 <a class="idx" href="threadcom.html#idx:threadgetmessage3:1891">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1898">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1907">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1908">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1910">9.3.1</a></dd>
26452695 <dt><a class="idx" href="threadcreate.html#thread_initialization/1">thread_initialization/1</a></dt>
26462696 <dd>
26472697 <a class="idx" href="gvar.html#idx:threadinitialization1:1418">4.33</a></dd>
26482698 <dt><a class="idx" href="threadcreate.html#thread_join/2">thread_join/2</a></dt>
26492699 <dd>
2650 <a class="idx" href="threadcreate.html#idx:threadjoin2:1828">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1831">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1838">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1839">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1840">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1850">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1852">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1853">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1859">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1860">9.1</a> <a class="idx" href="thmonitor.html#idx:threadjoin2:1874">9.2</a></dd>
2700 <a class="idx" href="threadcreate.html#idx:threadjoin2:1832">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1835">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1842">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1843">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1844">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1854">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1856">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1857">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1863">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1864">9.1</a> <a class="idx" href="thmonitor.html#idx:threadjoin2:1878">9.2</a></dd>
26512701 <dt><a class="idx" href="threadcom.html#thread_local/1">thread_local/1</a></dt>
26522702 <dd>
2653 <a class="idx" href="exception.html#idx:threadlocal1:758">4.11.4</a> <a class="idx" href="db.html#idx:threadlocal1:802">4.14</a> <a class="idx" href="dynamic.html#idx:threadlocal1:882">4.15</a> <a class="idx" href="examineprog.html#idx:threadlocal1:928">4.16</a> <a class="idx" href="toplevel.html#idx:threadlocal1:1526">4.37</a> <a class="idx" href="threadcom.html#idx:threadlocal1:1915">9.3.3</a> <a class="idx" href="engine-examples.html#idx:threadlocal1:1975">10.1.2</a></dd>
2703 <a class="idx" href="exception.html#idx:threadlocal1:758">4.11.4</a> <a class="idx" href="db.html#idx:threadlocal1:802">4.14</a> <a class="idx" href="dynamic.html#idx:threadlocal1:882">4.15</a> <a class="idx" href="examineprog.html#idx:threadlocal1:928">4.16</a> <a class="idx" href="toplevel.html#idx:threadlocal1:1526">4.37</a> <a class="idx" href="threadcom.html#idx:threadlocal1:1919">9.3.3</a> <a class="idx" href="engine-examples.html#idx:threadlocal1:1979">10.1.2</a></dd>
26542704 <dt><a class="idx" href="exception.html#thread_message_hook/3">thread_message_hook/3</a></dt>
26552705 <dt><a class="idx" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a></dt>
26562706 <dd>
2657 <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1892">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1893">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1907">9.3.1</a></dd>
2707 <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1896">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1897">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1911">9.3.1</a></dd>
26582708 <dt><a class="idx" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a></dt>
26592709 <dd>
2660 <a class="idx" href="threadcom.html#idx:threadpeekmessage2:1905">9.3.1</a></dd>
2710 <a class="idx" href="threadcom.html#idx:threadpeekmessage2:1909">9.3.1</a></dd>
26612711 <dt><a class="idx" href="threadpool.html#thread_pool_create/3">thread_pool_create/3</a></dt>
26622712 <dt><a class="idx" href="threadpool.html#thread_pool_destroy/1">thread_pool_destroy/1</a></dt>
26632713 <dt><a class="idx" href="threadpool.html#thread_pool_property/2">thread_pool_property/2</a></dt>
26642714 <dt><a class="idx" href="thmonitor.html#thread_property/2">thread_property/2</a></dt>
26652715 <dd>
2666 <a class="idx" href="threadcreate.html#idx:threadproperty2:1830">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1851">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1858">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1866">9.1</a> <a class="idx" href="thmonitor.html#idx:threadproperty2:1873">9.2</a></dd>
2716 <a class="idx" href="threadcreate.html#idx:threadproperty2:1834">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1855">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1862">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1870">9.1</a> <a class="idx" href="thmonitor.html#idx:threadproperty2:1877">9.2</a></dd>
26672717 <dt><a class="idx" href="threadcreate.html#thread_self/1">thread_self/1</a></dt>
26682718 <dd>
2669 <a class="idx" href="flags.html#idx:threadself1:135">2.11</a> <a class="idx" href="threadcreate.html#idx:threadself1:1857">9.1</a> <a class="idx" href="threadcreate.html#idx:threadself1:1867">9.1</a> <a class="idx" href="threadcom.html#idx:threadself1:1883">9.3.1</a></dd>
2719 <a class="idx" href="flags.html#idx:threadself1:135">2.11</a> <a class="idx" href="threadcreate.html#idx:threadself1:1861">9.1</a> <a class="idx" href="threadcreate.html#idx:threadself1:1871">9.1</a> <a class="idx" href="threadcom.html#idx:threadself1:1887">9.3.1</a></dd>
26702720 <dt><a class="idx" href="threadcom.html#thread_send_message/2">thread_send_message/2</a></dt>
26712721 <dd>
2672 <a class="idx" href="threadcom.html#idx:threadsendmessage2:1884">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage2:1885">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage2:1896">9.3.1</a> <a class="idx" href="engine-examples.html#idx:threadsendmessage2:1979">10.1.3</a></dd>
2722 <a class="idx" href="threadcom.html#idx:threadsendmessage2:1888">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage2:1889">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage2:1900">9.3.1</a> <a class="idx" href="engine-examples.html#idx:threadsendmessage2:1983">10.1.3</a></dd>
26732723 <dt><a class="idx" href="threadcom.html#thread_send_message/3">thread_send_message/3</a></dt>
26742724 <dd>
2675 <a class="idx" href="threadcom.html#idx:threadsendmessage3:1886">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage3:1889">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage3:1890">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage3:1891">9.3.1</a></dd>
2725 <a class="idx" href="threadcom.html#idx:threadsendmessage3:1890">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage3:1893">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage3:1894">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage3:1895">9.3.1</a></dd>
26762726 <dt><a class="idx" href="threadcreate.html#thread_setconcurrency/2">thread_setconcurrency/2</a></dt>
26772727 <dd>
26782728 <a class="idx" href="flags.html#idx:threadsetconcurrency2:100">2.11</a></dd>
26792729 <dt><a class="idx" href="threadcom.html#thread_signal/2">thread_signal/2</a></dt>
26802730 <dd>
2681 <a class="idx" href="cmdline.html#idx:threadsignal2:28">2.4.2</a> <a class="idx" href="metacall.html#idx:threadsignal2:667">4.9</a> <a class="idx" href="threadcom.html#idx:threadsignal2:1911">9.3.2</a> <a class="idx" href="thutil.html#idx:threadsignal2:1943">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:threadsignal2:2050">11.4.13</a> <a class="idx" href="foreigninclude.html#idx:threadsignal2:2086">11.4.21.1</a></dd>
2731 <a class="idx" href="cmdline.html#idx:threadsignal2:28">2.4.2</a> <a class="idx" href="metacall.html#idx:threadsignal2:667">4.9</a> <a class="idx" href="threadcom.html#idx:threadsignal2:1915">9.3.2</a> <a class="idx" href="thutil.html#idx:threadsignal2:1947">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:threadsignal2:2054">11.4.13</a> <a class="idx" href="foreigninclude.html#idx:threadsignal2:2090">11.4.21.1</a></dd>
26822732 <dt><a class="idx" href="thmonitor.html#thread_statistics/3">thread_statistics/3</a></dt>
26832733 <dd>
2684 <a class="idx" href="thmonitor.html#idx:threadstatistics3:1878">9.2</a></dd>
2734 <a class="idx" href="thmonitor.html#idx:threadstatistics3:1882">9.2</a></dd>
26852735 <dt><a class="idx" href="thutil.html#threads/0">threads/0</a></dt>
26862736 <dt><a class="idx" href="exception.html#throw/1">throw/1</a></dt>
26872737 <dd>
2688 <a class="idx" href="debugoverview.html#idx:throw1:54">2.9</a> <a class="idx" href="cyclic.html#idx:throw1:249">2.17</a> <a class="idx" href="delcont.html#idx:throw1:688">4.10</a> <a class="idx" href="exception.html#idx:throw1:692">4.11</a> <a class="idx" href="exception.html#idx:throw1:694">4.11</a> <a class="idx" href="exception.html#idx:throw1:695">4.11</a> <a class="idx" href="exception.html#idx:throw1:704">4.11</a> <a class="idx" href="exception.html#idx:throw1:709">4.11</a> <a class="idx" href="exception.html#idx:throw1:768">4.11.4.1</a> <a class="idx" href="signal.html#idx:throw1:776">4.12.1</a> <a class="idx" href="threadcreate.html#idx:throw1:1862">9.1</a> <a class="idx" href="thmonitor.html#idx:throw1:1876">9.2</a> <a class="idx" href="threadcom.html#idx:throw1:1910">9.3.2</a> <a class="idx" href="threadcom.html#idx:throw1:1912">9.3.2</a> <a class="idx" href="foreigninclude.html#idx:throw1:2048">11.4.12</a> <a class="idx" href="foreigninclude.html#idx:throw1:2049">11.4.12</a> <a class="idx" href="excepthook.html#idx:throw1:2205">B.5</a> <a class="idx" href="exception3.html#idx:throw1:2213">B.6</a> <a class="idx" href="exception3.html#idx:throw1:2216">B.6</a></dd>
2738 <a class="idx" href="debugoverview.html#idx:throw1:54">2.9</a> <a class="idx" href="cyclic.html#idx:throw1:249">2.17</a> <a class="idx" href="delcont.html#idx:throw1:688">4.10</a> <a class="idx" href="exception.html#idx:throw1:692">4.11</a> <a class="idx" href="exception.html#idx:throw1:694">4.11</a> <a class="idx" href="exception.html#idx:throw1:695">4.11</a> <a class="idx" href="exception.html#idx:throw1:704">4.11</a> <a class="idx" href="exception.html#idx:throw1:709">4.11</a> <a class="idx" href="exception.html#idx:throw1:768">4.11.4.1</a> <a class="idx" href="signal.html#idx:throw1:776">4.12.1</a> <a class="idx" href="threadcreate.html#idx:throw1:1866">9.1</a> <a class="idx" href="thmonitor.html#idx:throw1:1880">9.2</a> <a class="idx" href="threadcom.html#idx:throw1:1914">9.3.2</a> <a class="idx" href="threadcom.html#idx:throw1:1916">9.3.2</a> <a class="idx" href="foreigninclude.html#idx:throw1:2052">11.4.12</a> <a class="idx" href="foreigninclude.html#idx:throw1:2053">11.4.12</a> <a class="idx" href="excepthook.html#idx:throw1:2209">B.5</a> <a class="idx" href="exception3.html#idx:throw1:2217">B.6</a> <a class="idx" href="exception3.html#idx:throw1:2220">B.6</a></dd>
26892739 <dt><a class="idx" href="statistics.html#time/1">time/1</a></dt>
26902740 <dd>
26912741 <a class="idx" href="arith.html#idx:time1:1339">4.27.2.3</a></dd>
26992749 <dt><a class="idx" href="thutil.html#tnodebug/0">tnodebug/0</a></dt>
27002750 <dt><a class="idx" href="thutil.html#tnodebug/1">tnodebug/1</a></dt>
27012751 <dd>
2702 <a class="idx" href="thutil.html#idx:tnodebug1:1950">9.5.1</a></dd>
2752 <a class="idx" href="thutil.html#idx:tnodebug1:1954">9.5.1</a></dd>
27032753 <dt><a class="idx" href="IO.html#told/0">told/0</a></dt>
27042754 <dt><a class="idx" href="ugraphs.html#top_sort/2">top_sort/2</a></dt>
27052755 <dt><a class="idx" href="ugraphs.html#top_sort/3">top_sort/3</a></dt>
27062756 <dt><a class="idx" href="thutil.html#tprofile/1">tprofile/1</a></dt>
27072757 <dd>
2708 <a class="idx" href="thutil.html#idx:tprofile1:1952">9.5.2</a></dd>
2758 <a class="idx" href="thutil.html#idx:tprofile1:1956">9.5.2</a></dd>
27092759 <dt><a class="idx" href="debugger.html#trace/0">trace/0</a></dt>
27102760 <dd>
2711 <a class="idx" href="debugoverview.html#idx:trace0:55">2.9</a> <a class="idx" href="debugoverview.html#idx:trace0:58">2.9</a> <a class="idx" href="flags.html#idx:trace0:114">2.11</a> <a class="idx" href="flags.html#idx:trace0:145">2.11</a> <a class="idx" href="guitracer.html#idx:trace0:317">3.5.1</a> <a class="idx" href="guitracer.html#idx:trace0:319">3.5.1</a> <a class="idx" href="idesummary.html#idx:trace0:332">3.9</a> <a class="idx" href="debugger.html#idx:trace0:1542">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1543">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1549">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1550">4.39</a> <a class="idx" href="debugging.html#idx:trace0:1818">8.4.3</a> <a class="idx" href="debugging.html#idx:trace0:1820">8.4.3</a> <a class="idx" href="threadcom.html#idx:trace0:1913">9.3.2</a> <a class="idx" href="foreigninclude.html#idx:trace0:2061">11.4.16</a> <a class="idx" href="breakpoint.html#idx:trace0:2201">B.4</a> <a class="idx" href="excepthook.html#idx:trace0:2209">B.5</a></dd>
2761 <a class="idx" href="debugoverview.html#idx:trace0:55">2.9</a> <a class="idx" href="debugoverview.html#idx:trace0:58">2.9</a> <a class="idx" href="flags.html#idx:trace0:114">2.11</a> <a class="idx" href="flags.html#idx:trace0:145">2.11</a> <a class="idx" href="guitracer.html#idx:trace0:317">3.5.1</a> <a class="idx" href="guitracer.html#idx:trace0:319">3.5.1</a> <a class="idx" href="idesummary.html#idx:trace0:332">3.9</a> <a class="idx" href="debugger.html#idx:trace0:1542">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1543">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1549">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1550">4.39</a> <a class="idx" href="debugging.html#idx:trace0:1822">8.4.3</a> <a class="idx" href="debugging.html#idx:trace0:1824">8.4.3</a> <a class="idx" href="threadcom.html#idx:trace0:1917">9.3.2</a> <a class="idx" href="foreigninclude.html#idx:trace0:2065">11.4.16</a> <a class="idx" href="breakpoint.html#idx:trace0:2205">B.4</a> <a class="idx" href="excepthook.html#idx:trace0:2213">B.5</a></dd>
27122762 <dt><a class="idx" href="debugger.html#trace/1">trace/1</a></dt>
27132763 <dd>
27142764 <a class="idx" href="flags.html#idx:trace1:103">2.11</a></dd>
27242774 <dt><a class="idx" href="ugraphs.html#transitive_closure/2">transitive_closure/2</a></dt>
27252775 <dt>transparent</dt>
27262776 <dd>
2727 <a class="idx" href="glossary.html#idx:transparent:2310">D</a></dd>
2777 <a class="idx" href="glossary.html#idx:transparent:2314">D</a></dd>
27282778 <dt><a class="idx" href="simplex.html#transportation/4">transportation/4</a></dt>
27292779 <dt><a class="idx" href="pairs.html#transpose_pairs/2">transpose_pairs/2</a></dt>
27302780 <dt><a class="idx" href="ugraphs.html#transpose_ugraph/2">transpose_ugraph/2</a></dt>
27472797 <dt><a class="idx" href="db.html#trie_update/3">trie_update/3</a></dt>
27482798 <dt><a class="idx" href="memory.html#trim_stacks/0">trim_stacks/0</a></dt>
27492799 <dd>
2750 <a class="idx" href="memory.html#idx:trimstacks0:1575">4.42</a> <a class="idx" href="memory.html#idx:trimstacks0:1578">4.42</a> <a class="idx" href="engine-examples.html#idx:trimstacks0:1982">10.1.3</a></dd>
2800 <a class="idx" href="memory.html#idx:trimstacks0:1575">4.42</a> <a class="idx" href="memory.html#idx:trimstacks0:1578">4.42</a> <a class="idx" href="engine-examples.html#idx:trimstacks0:1986">10.1.3</a></dd>
27512801 <dt>trimm_stacks/0</dt>
27522802 <dd>
2753 <a class="idx" href="engine-resources.html#idx:trimmstacks0:1988">10.2</a></dd>
2803 <a class="idx" href="engine-resources.html#idx:trimmstacks0:1992">10.2</a></dd>
27542804 <dt><a class="idx" href="check.html#trivial_fail_goal/1">trivial_fail_goal/1</a></dt>
27552805 <dt><a class="idx" href="control.html#true/0">true/0</a></dt>
27562806 <dd>
27602810 <a class="idx" href="arith.html#idx:truncate1:1337">4.27.2.3</a></dd>
27612811 <dt><a class="idx" href="thutil.html#tspy/1">tspy/1</a></dt>
27622812 <dd>
2763 <a class="idx" href="threadcreate.html#idx:tspy1:1836">9.1</a> <a class="idx" href="thutil.html#idx:tspy1:1939">9.5.1</a></dd>
2813 <a class="idx" href="threadcreate.html#idx:tspy1:1840">9.1</a> <a class="idx" href="thutil.html#idx:tspy1:1943">9.5.1</a></dd>
27642814 <dt><a class="idx" href="thutil.html#tspy/2">tspy/2</a></dt>
27652815 <dt><a class="idx" href="tty.html#tty_get_capability/3">tty_get_capability/3</a></dt>
27662816 <dd>
27762826 <dt><a class="idx" href="clpfd.html#tuples_in/2">tuples_in/2</a></dt>
27772827 <dt><a class="idx" href="error.html#type_error/2">type_error/2</a></dt>
27782828 <dd>
2779 <a class="idx" href="exception.html#idx:typeerror2:769">4.11.4.1</a> <a class="idx" href="foreigninclude.html#idx:typeerror2:2031">11.4.6</a> <a class="idx" href="foreigninclude.html#idx:typeerror2:2033">11.4.6</a></dd>
2829 <a class="idx" href="exception.html#idx:typeerror2:769">4.11.4.1</a> <a class="idx" href="foreigninclude.html#idx:typeerror2:2035">11.4.6</a> <a class="idx" href="foreigninclude.html#idx:typeerror2:2037">11.4.6</a></dd>
27802830 <dt><a class="idx" href="ugraphs.html#ugraph_union/3">ugraph_union/3</a></dt>
27812831 <dt><a class="idx" href="compare.html#unifiable/3">unifiable/3</a></dt>
27822832 <dd>
27832833 <a class="idx" href="cyclic.html#idx:unifiable3:251">2.17</a> <a class="idx" href="compare.html#idx:unifiable3:628">4.7.2</a></dd>
27842834 <dt>unify</dt>
27852835 <dd>
2786 <a class="idx" href="glossary.html#idx:unify:2335">D</a></dd>
2836 <a class="idx" href="glossary.html#idx:unify:2339">D</a></dd>
27872837 <dt><a class="idx" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a></dt>
27882838 <dd>
27892839 <a class="idx" href="flags.html#idx:unifywithoccurscheck2:119">2.11</a> <a class="idx" href="cyclic.html#idx:unifywithoccurscheck2:250">2.17</a> <a class="idx" href="compare.html#idx:unifywithoccurscheck2:626">4.7.2</a> <a class="idx" href="compare.html#idx:unifywithoccurscheck2:630">4.7.2</a> <a class="idx" href="compare.html#idx:unifywithoccurscheck2:631">4.7.2</a></dd>
27952845 <dt><a class="idx" href="system.html#unix/1">unix/1</a></dt>
27962846 <dt><a class="idx" href="debugger.html#unknown/2">unknown/2</a></dt>
27972847 <dd>
2798 <a class="idx" href="debugger.html#idx:unknown2:1558">4.39</a> <a class="idx" href="libpl.html#idx:unknown2:2130">A</a></dd>
2848 <a class="idx" href="debugger.html#idx:unknown2:1558">4.39</a> <a class="idx" href="libpl.html#idx:unknown2:2134">A</a></dd>
27992849 <dt><a class="idx" href="broadcast.html#unlisten/1">unlisten/1</a></dt>
28002850 <dt><a class="idx" href="broadcast.html#unlisten/2">unlisten/2</a></dt>
28012851 <dt><a class="idx" href="broadcast.html#unlisten/3">unlisten/3</a></dt>
28122862 <a class="idx" href="chartype.html#idx:upcaseatom2:1293">4.24</a> <a class="idx" href="chartype.html#idx:upcaseatom2:1295">4.24</a></dd>
28132863 <dt>update view</dt>
28142864 <dd>
2815 <a class="idx" href="db.html#idx:updateview:861">4.14.5</a> <a class="idx" href="glossary.html#idx:updateview:2336">D</a></dd>
2865 <a class="idx" href="db.html#idx:updateview:861">4.14.5</a> <a class="idx" href="glossary.html#idx:updateview:2340">D</a></dd>
28162866 <dt><a class="idx" href="url.html#url_iri/2">url_iri/2</a></dt>
28172867 <dt><a class="idx" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a></dt>
28182868 <dd>
2819 <a class="idx" href="consulting.html#idx:useforeignlibrary1:466">4.3</a> <a class="idx" href="consulting.html#idx:useforeignlibrary1:508">4.3</a> <a class="idx" href="system.html#idx:useforeignlibrary1:1473">4.35.1</a> <a class="idx" href="runtime.html#idx:useforeignlibrary1:2102">12</a></dd>
2869 <a class="idx" href="consulting.html#idx:useforeignlibrary1:466">4.3</a> <a class="idx" href="consulting.html#idx:useforeignlibrary1:508">4.3</a> <a class="idx" href="system.html#idx:useforeignlibrary1:1473">4.35.1</a> <a class="idx" href="runtime.html#idx:useforeignlibrary1:2106">12</a></dd>
28202870 <dt><a class="idx" href="foreignlink.html#use_foreign_library/2">use_foreign_library/2</a></dt>
28212871 <dt><a class="idx" href="import.html#use_module/1">use_module/1</a></dt>
28222872 <dd>
2823 <a class="idx" href="flags.html#idx:usemodule1:157">2.11</a> <a class="idx" href="hooks.html#idx:usemodule1:178">2.12</a> <a class="idx" href="projectfiles.html#idx:usemodule1:301">3.1.1.3</a> <a class="idx" href="consulting.html#idx:usemodule1:382">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:388">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:406">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:438">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:568">4.3.2.1</a> <a class="idx" href="consulting.html#idx:usemodule1:569">4.3.2.1</a> <a class="idx" href="consulting.html#idx:usemodule1:571">4.3.2.1</a> <a class="idx" href="defmodule.html#idx:usemodule1:1665">6.2</a> <a class="idx" href="import.html#idx:usemodule1:1666">6.3</a> <a class="idx" href="import.html#idx:usemodule1:1674">6.3</a> <a class="idx" href="import.html#idx:usemodule1:1682">6.3</a> <a class="idx" href="reexport.html#idx:usemodule1:1714">6.7</a> <a class="idx" href="resmodules.html#idx:usemodule1:1725">6.10</a> <a class="idx" href="altmoduleapi.html#idx:usemodule1:1726">6.11</a> <a class="idx" href="runtime.html#idx:usemodule1:2107">12</a> <a class="idx" href="dialect.html#idx:usemodule1:2249">C</a></dd>
2873 <a class="idx" href="flags.html#idx:usemodule1:157">2.11</a> <a class="idx" href="hooks.html#idx:usemodule1:178">2.12</a> <a class="idx" href="projectfiles.html#idx:usemodule1:301">3.1.1.3</a> <a class="idx" href="consulting.html#idx:usemodule1:382">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:388">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:406">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:438">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:568">4.3.2.1</a> <a class="idx" href="consulting.html#idx:usemodule1:569">4.3.2.1</a> <a class="idx" href="consulting.html#idx:usemodule1:571">4.3.2.1</a> <a class="idx" href="defmodule.html#idx:usemodule1:1669">6.2</a> <a class="idx" href="import.html#idx:usemodule1:1670">6.3</a> <a class="idx" href="import.html#idx:usemodule1:1678">6.3</a> <a class="idx" href="import.html#idx:usemodule1:1686">6.3</a> <a class="idx" href="reexport.html#idx:usemodule1:1718">6.7</a> <a class="idx" href="resmodules.html#idx:usemodule1:1729">6.10</a> <a class="idx" href="altmoduleapi.html#idx:usemodule1:1730">6.11</a> <a class="idx" href="runtime.html#idx:usemodule1:2111">12</a> <a class="idx" href="dialect.html#idx:usemodule1:2253">C</a></dd>
28242874 <dt><a class="idx" href="import.html#use_module/2">use_module/2</a></dt>
28252875 <dd>
2826 <a class="idx" href="autoload.html#idx:usemodule2:193">2.13</a> <a class="idx" href="consulting.html#idx:usemodule2:383">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:389">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:407">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:409">4.3</a> <a class="idx" href="import.html#idx:usemodule2:1667">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1671">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1672">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1675">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1680">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1683">6.3</a> <a class="idx" href="reexport.html#idx:usemodule2:1715">6.7</a> <a class="idx" href="dialect.html#idx:usemodule2:2250">C</a></dd>
2876 <a class="idx" href="autoload.html#idx:usemodule2:193">2.13</a> <a class="idx" href="consulting.html#idx:usemodule2:383">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:389">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:407">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:409">4.3</a> <a class="idx" href="import.html#idx:usemodule2:1671">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1675">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1676">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1679">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1684">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1687">6.3</a> <a class="idx" href="reexport.html#idx:usemodule2:1719">6.7</a> <a class="idx" href="dialect.html#idx:usemodule2:2254">C</a></dd>
28272877 <dt>use_module/[1,2]</dt>
28282878 <dd>
2829 <a class="idx" href="compilation.html#idx:usemodule12:71">2.10.1</a> <a class="idx" href="pceemacs.html#idx:usemodule12:312">3.4.3.1</a> <a class="idx" href="consulting.html#idx:usemodule12:361">4.3</a> <a class="idx" href="consulting.html#idx:usemodule12:411">4.3</a> <a class="idx" href="consulting.html#idx:usemodule12:432">4.3</a> <a class="idx" href="altmoduleapi.html#idx:usemodule12:1727">6.11</a> <a class="idx" href="altmoduleapi.html#idx:usemodule12:1730">6.11</a> <a class="idx" href="glossary.html#idx:usemodule12:2292">D</a></dd>
2879 <a class="idx" href="compilation.html#idx:usemodule12:71">2.10.1</a> <a class="idx" href="pceemacs.html#idx:usemodule12:312">3.4.3.1</a> <a class="idx" href="consulting.html#idx:usemodule12:361">4.3</a> <a class="idx" href="consulting.html#idx:usemodule12:411">4.3</a> <a class="idx" href="consulting.html#idx:usemodule12:432">4.3</a> <a class="idx" href="altmoduleapi.html#idx:usemodule12:1731">6.11</a> <a class="idx" href="altmoduleapi.html#idx:usemodule12:1734">6.11</a> <a class="idx" href="glossary.html#idx:usemodule12:2296">D</a></dd>
28302880 <dt>user profile file</dt>
28312881 <dd>
28322882 <a class="idx" href="initfile.html#idx:userprofilefile:19">2.2</a></dd>
28352885 <a class="idx" href="chars.html#idx:utf8:341">4.2</a></dd>
28362886 <dt>valgrind</dt>
28372887 <dd>
2838 <a class="idx" href="foreignnotes.html#idx:valgrind:2094">11.8.4</a></dd>
2888 <a class="idx" href="foreignnotes.html#idx:valgrind:2098">11.8.4</a></dd>
28392889 <dt><a class="idx" href="check.html#valid_string_goal/1">valid_string_goal/1</a></dt>
28402890 <dt><a class="idx" href="typetest.html#var/1">var/1</a></dt>
28412891 <dd>
2842 <a class="idx" href="attvar.html#idx:var1:1776">7.1.1</a> <a class="idx" href="foreigninclude.html#idx:var1:2015">11.4.3</a></dd>
2892 <a class="idx" href="attvar.html#idx:var1:1780">7.1.1</a> <a class="idx" href="foreigninclude.html#idx:var1:2019">11.4.3</a></dd>
28432893 <dt><a class="idx" href="manipterm.html#var_number/2">var_number/2</a></dt>
28442894 <dt><a class="idx" href="consulting.html#var_property/2">var_property/2</a></dt>
28452895 <dt>variable</dt>
28462896 <dd>
2847 <a class="idx" href="glossary.html#idx:variable:2338">D</a></dd>
2897 <a class="idx" href="glossary.html#idx:variable:2342">D</a></dd>
28482898 <dt>variable,anonymous</dt>
28492899 <dd>
2850 <a class="idx" href="glossary.html#idx:variableanonymous:2267">D</a></dd>
2900 <a class="idx" href="glossary.html#idx:variableanonymous:2271">D</a></dd>
28512901 <dt><a class="idx" href="simplex.html#variable_value/3">variable_value/3</a></dt>
28522902 <dt>variant</dt>
28532903 <dd>
28552905 <dt><a class="idx" href="db.html#variant_hash/2">variant_hash/2</a></dt>
28562906 <dt><a class="idx" href="db.html#variant_sha1/2">variant_sha1/2</a></dt>
28572907 <dd>
2858 <a class="idx" href="db.html#idx:variantsha12:872">4.14.6</a> <a class="idx" href="db.html#idx:variantsha12:874">4.14.6</a> <a class="idx" href="otherlicenses.html#idx:variantsha12:2344">E.3.1</a></dd>
2908 <a class="idx" href="db.html#idx:variantsha12:872">4.14.6</a> <a class="idx" href="db.html#idx:variantsha12:874">4.14.6</a> <a class="idx" href="otherlicenses.html#idx:variantsha12:2348">E.3.1</a></dd>
28592909 <dt><a class="idx" href="varnumbers.html#varnumbers/2">varnumbers/2</a></dt>
28602910 <dt><a class="idx" href="varnumbers.html#varnumbers/3">varnumbers/3</a></dt>
28612911 <dt><a class="idx" href="varnumbers.html#varnumbers_names/3">varnumbers_names/3</a></dt>
28722922 <dt><a class="idx" href="ugraphs.html#vertices_edges_to_ugraph/3">vertices_edges_to_ugraph/3</a></dt>
28732923 <dt>view,update</dt>
28742924 <dd>
2875 <a class="idx" href="glossary.html#idx:viewupdate:2337">D</a></dd>
2925 <a class="idx" href="glossary.html#idx:viewupdate:2341">D</a></dd>
28762926 <dt><a class="idx" href="debugger.html#visible/1">visible/1</a></dt>
28772927 <dd>
2878 <a class="idx" href="tracehook.html#idx:visible1:2190">B.3</a></dd>
2928 <a class="idx" href="tracehook.html#idx:visible1:2194">B.3</a></dd>
28792929 <dt><a class="idx" href="runtime.html#volatile/1">volatile/1</a></dt>
28802930 <dd>
2881 <a class="idx" href="examineprog.html#idx:volatile1:934">4.16</a> <a class="idx" href="threadcom.html#idx:volatile1:1919">9.3.3</a></dd>
2931 <a class="idx" href="examineprog.html#idx:volatile1:934">4.16</a> <a class="idx" href="threadcom.html#idx:volatile1:1923">9.3.3</a></dd>
28822932 <dt><a class="idx" href="streamstat.html#wait_for_input/3">wait_for_input/3</a></dt>
28832933 <dd>
28842934 <a class="idx" href="IO.html#idx:waitforinput3:1023">4.17.2</a> <a class="idx" href="IO.html#idx:waitforinput3:1024">4.17.2</a> <a class="idx" href="streamstat.html#idx:waitforinput3:1066">4.18</a> <a class="idx" href="streamstat.html#idx:waitforinput3:1067">4.18</a> <a class="idx" href="streamstat.html#idx:waitforinput3:1070">4.18</a></dd>
28852935 <dt><a class="idx" href="clpb.html#weighted_maximum/3">weighted_maximum/3</a></dt>
28862936 <dt><a class="idx" href="coroutining.html#when/2">when/2</a></dt>
28872937 <dd>
2888 <a class="idx" href="cyclic.html#idx:when2:252">2.17</a> <a class="idx" href="compare.html#idx:when2:641">4.7.2</a> <a class="idx" href="manipterm.html#idx:when2:1211">4.21</a> <a class="idx" href="coroutining.html#idx:when2:1808">7.2</a></dd>
2938 <a class="idx" href="cyclic.html#idx:when2:252">2.17</a> <a class="idx" href="compare.html#idx:when2:641">4.7.2</a> <a class="idx" href="manipterm.html#idx:when2:1211">4.21</a> <a class="idx" href="coroutining.html#idx:when2:1812">7.2</a></dd>
28892939 <dt><a class="idx" href="miscpreds.html#wildcard_match/2">wildcard_match/2</a></dt>
28902940 <dt><a class="idx" href="system.html#win_add_dll_directory/1">win_add_dll_directory/1</a></dt>
28912941 <dt><a class="idx" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a></dt>
29102960 <a class="idx" href="system.html#idx:winremovedlldirectory1:1475">4.35.1</a></dd>
29112961 <dt><a class="idx" href="system.html#win_shell/2">win_shell/2</a></dt>
29122962 <dd>
2913 <a class="idx" href="system.html#idx:winshell2:1443">4.35</a> <a class="idx" href="system.html#idx:winshell2:1466">4.35.1</a> <a class="idx" href="www_browser.html#idx:winshell2:2148">A.18</a></dd>
2963 <a class="idx" href="system.html#idx:winshell2:1443">4.35</a> <a class="idx" href="system.html#idx:winshell2:1466">4.35.1</a> <a class="idx" href="www_browser.html#idx:winshell2:2152">A.18</a></dd>
29142964 <dt><a class="idx" href="system.html#win_shell/3">win_shell/3</a></dt>
29152965 <dt><a class="idx" href="system.html#win_window_pos/1">win_window_pos/1</a></dt>
29162966 <dt><a class="idx" href="system.html#window_title/2">window_title/2</a></dt>
29192969 <a class="idx" href="flags.html#idx:windows:159">2.11</a></dd>
29202970 <dt><a class="idx" href="threadsync.html#with_mutex/2">with_mutex/2</a></dt>
29212971 <dd>
2922 <a class="idx" href="threadcom.html#idx:withmutex2:1909">9.3.2</a> <a class="idx" href="threadsync.html#idx:withmutex2:1920">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1921">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1930">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1933">9.4</a> <a class="idx" href="foreignthread.html#idx:withmutex2:1953">9.6</a></dd>
2972 <a class="idx" href="threadcom.html#idx:withmutex2:1913">9.3.2</a> <a class="idx" href="threadsync.html#idx:withmutex2:1924">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1925">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1934">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1937">9.4</a> <a class="idx" href="foreignthread.html#idx:withmutex2:1957">9.6</a></dd>
29232973 <dt><a class="idx" href="IO.html#with_output_to/2">with_output_to/2</a></dt>
29242974 <dd>
29252975 <a class="idx" href="IO.html#idx:withoutputto2:960">4.17.1</a> <a class="idx" href="IO.html#idx:withoutputto2:962">4.17.1</a> <a class="idx" href="IO.html#idx:withoutputto2:967">4.17.2</a> <a class="idx" href="IO.html#idx:withoutputto2:1049">4.17.4</a> <a class="idx" href="IO.html#idx:withoutputto2:1056">4.17.5</a> <a class="idx" href="termrw.html#idx:withoutputto2:1116">4.20</a> <a class="idx" href="manipatom.html#idx:withoutputto2:1268">4.22</a> <a class="idx" href="chartype.html#idx:withoutputto2:1304">4.24.2</a> <a class="idx" href="format.html#idx:withoutputto2:1408">4.32.2</a> <a class="idx" href="system.html#idx:withoutputto2:1483">4.35.2.2</a></dd>
29332983 <dt><a class="idx" href="foreigninclude.html#write()">write()</a></dt>
29342984 <dt><a class="idx" href="termrw.html#write/1">write/1</a></dt>
29352985 <dd>
2936 <a class="idx" href="flags.html#idx:write1:160">2.11</a> <a class="idx" href="cyclic.html#idx:write1:253">2.17</a> <a class="idx" href="limits.html#idx:write1:284">2.20.2</a> <a class="idx" href="IO.html#idx:write1:954">4.17.1</a> <a class="idx" href="IO.html#idx:write1:965">4.17.1</a> <a class="idx" href="format.html#idx:write1:1392">4.32.1</a> <a class="idx" href="format.html#idx:write1:1405">4.32.2</a> <a class="idx" href="foreigninclude.html#idx:write1:2019">11.4.3.2</a> <a class="idx" href="foreigninclude.html#idx:write1:2020">11.4.3.2</a> <b>11.4.3.5</b> <a class="idx" href="foreigninclude.html#idx:write1:2024">11.4.3.6</a> <a class="idx" href="foreigninclude.html#idx:write1:2039">11.4.7.1</a></dd>
2986 <a class="idx" href="flags.html#idx:write1:160">2.11</a> <a class="idx" href="cyclic.html#idx:write1:253">2.17</a> <a class="idx" href="limits.html#idx:write1:284">2.20.2</a> <a class="idx" href="IO.html#idx:write1:954">4.17.1</a> <a class="idx" href="IO.html#idx:write1:965">4.17.1</a> <a class="idx" href="format.html#idx:write1:1392">4.32.1</a> <a class="idx" href="format.html#idx:write1:1405">4.32.2</a> <a class="idx" href="foreigninclude.html#idx:write1:2023">11.4.3.2</a> <a class="idx" href="foreigninclude.html#idx:write1:2024">11.4.3.2</a> <b>11.4.3.5</b> <a class="idx" href="foreigninclude.html#idx:write1:2028">11.4.3.6</a> <a class="idx" href="foreigninclude.html#idx:write1:2043">11.4.7.1</a></dd>
29372987 <dt><a class="idx" href="termrw.html#write/2">write/2</a></dt>
29382988 <dt><a class="idx" href="termrw.html#write_canonical/1">write_canonical/1</a></dt>
29392989 <dd>
29402990 <a class="idx" href="termrw.html#idx:writecanonical1:1134">4.20</a> <a class="idx" href="termrw.html#idx:writecanonical1:1143">4.20</a> <a class="idx" href="termrw.html#idx:writecanonical1:1173">4.20</a> <a class="idx" href="format.html#idx:writecanonical1:1400">4.32.2</a> <a class="idx" href="ext-lists.html#idx:writecanonical1:1589">5.1</a></dd>
29412991 <dt><a class="idx" href="termrw.html#write_canonical/2">write_canonical/2</a></dt>
29422992 <dd>
2943 <a class="idx" href="IO.html#idx:writecanonical2:1060">4.17.6</a> <a class="idx" href="IO.html#idx:writecanonical2:1061">4.17.6</a> <a class="idx" href="IO.html#idx:writecanonical2:1062">4.17.6</a> <a class="idx" href="manipterm.html#idx:writecanonical2:1205">4.21</a> <a class="idx" href="foreigninclude.html#idx:writecanonical2:2021">11.4.3.2</a></dd>
2993 <a class="idx" href="IO.html#idx:writecanonical2:1060">4.17.6</a> <a class="idx" href="IO.html#idx:writecanonical2:1061">4.17.6</a> <a class="idx" href="IO.html#idx:writecanonical2:1062">4.17.6</a> <a class="idx" href="manipterm.html#idx:writecanonical2:1205">4.21</a> <a class="idx" href="foreigninclude.html#idx:writecanonical2:2025">11.4.3.2</a></dd>
29442994 <dt><a class="idx" href="termrw.html#write_length/3">write_length/3</a></dt>
29452995 <dd>
29462996 <a class="idx" href="manipatom.html#idx:writelength3:1278">4.22</a></dd>
29472997 <dt><a class="idx" href="termrw.html#write_term/2">write_term/2</a></dt>
29482998 <dd>
2949 <a class="idx" href="debugoverview.html#idx:writeterm2:59">2.9</a> <a class="idx" href="flags.html#idx:writeterm2:104">2.11</a> <a class="idx" href="flags.html#idx:writeterm2:124">2.11</a> <a class="idx" href="flags.html#idx:writeterm2:141">2.11</a> <a class="idx" href="termrw.html#idx:writeterm2:1118">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1119">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1122">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1124">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1135">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1138">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1139">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1140">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1149">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1171">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1172">4.20</a> <a class="idx" href="manipterm.html#idx:writeterm2:1203">4.21</a> <a class="idx" href="manipatom.html#idx:writeterm2:1266">4.22</a> <a class="idx" href="format.html#idx:writeterm2:1394">4.32.1</a> <a class="idx" href="format.html#idx:writeterm2:1406">4.32.2</a> <a class="idx" href="ext-lists.html#idx:writeterm2:1591">5.1</a> <a class="idx" href="ext-lists.html#idx:writeterm2:1593">5.1</a> <a class="idx" href="strings.html#idx:writeterm2:1598">5.2.1</a> <a class="idx" href="attvar.html#idx:writeterm2:1783">7.1.2</a></dd>
2999 <a class="idx" href="debugoverview.html#idx:writeterm2:59">2.9</a> <a class="idx" href="flags.html#idx:writeterm2:104">2.11</a> <a class="idx" href="flags.html#idx:writeterm2:124">2.11</a> <a class="idx" href="flags.html#idx:writeterm2:141">2.11</a> <a class="idx" href="termrw.html#idx:writeterm2:1118">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1119">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1122">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1124">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1135">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1138">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1139">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1140">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1149">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1171">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1172">4.20</a> <a class="idx" href="manipterm.html#idx:writeterm2:1203">4.21</a> <a class="idx" href="manipatom.html#idx:writeterm2:1266">4.22</a> <a class="idx" href="format.html#idx:writeterm2:1394">4.32.1</a> <a class="idx" href="format.html#idx:writeterm2:1406">4.32.2</a> <a class="idx" href="ext-lists.html#idx:writeterm2:1591">5.1</a> <a class="idx" href="ext-lists.html#idx:writeterm2:1593">5.1</a> <a class="idx" href="strings.html#idx:writeterm2:1598">5.2.1</a> <a class="idx" href="attvar.html#idx:writeterm2:1787">7.1.2</a></dd>
29503000 <dt><a class="idx" href="termrw.html#write_term/3">write_term/3</a></dt>
29513001 <dd>
29523002 <a class="idx" href="flags.html#idx:writeterm3:161">2.11</a> <a class="idx" href="hooks.html#idx:writeterm3:168">2.12</a> <a class="idx" href="termrw.html#idx:writeterm3:1127">4.20</a> <a class="idx" href="manipterm.html#idx:writeterm3:1198">4.21</a> <a class="idx" href="manipatom.html#idx:writeterm3:1279">4.22</a></dd>
29653015 <a class="idx" href="format.html#idx:writeq1:1393">4.32.1</a> <a class="idx" href="format.html#idx:writeq1:1402">4.32.2</a></dd>
29663016 <dt><a class="idx" href="termrw.html#writeq/2">writeq/2</a></dt>
29673017 <dd>
2968 <a class="idx" href="foreigninclude.html#idx:writeq2:2022">11.4.3.2</a></dd>
3018 <a class="idx" href="foreigninclude.html#idx:writeq2:2026">11.4.3.2</a></dd>
29693019 <dt><a class="idx" href="url.html#www_form_encode/2">www_form_encode/2</a></dt>
29703020 <dt><a class="idx" href="www_browser.html#www_open_url/1">www_open_url/1</a></dt>
29713021 <dd>
2972 <a class="idx" href="www_browser.html#idx:wwwopenurl1:2150">A.18</a></dd>
3022 <a class="idx" href="www_browser.html#idx:wwwopenurl1:2154">A.18</a></dd>
29733023 <dt><a class="idx" href="prolog_xref.html#xref_built_in/1">xref_built_in/1</a></dt>
29743024 <dt><a class="idx" href="prolog_xref.html#xref_called/3">xref_called/3</a></dt>
29753025 <dt><a class="idx" href="prolog_xref.html#xref_clean/1">xref_clean/1</a></dt>
29803030 <dt><a class="idx" href="prolog_xref.html#xref_source/1">xref_source/1</a></dt>
29813031 <dt><a class="idx" href="clpfd.html#zcompare/3">zcompare/3</a></dt>
29823032 <dd>
2983 <a class="idx" href="clp.html#idx:zcompare3:1765">7</a></dd>
3033 <a class="idx" href="clp.html#idx:zcompare3:1769">7</a></dd>
29843034 <dt><a class="idx" href="control.html#!/0">!/0</a></dt>
29853035 <dt class="index-sep">#</dt>
29863036 <dt><a class="idx" href="clpfd.html##/\/2">#/ 2</a></dt>
30003050 <dt><a class="idx" href="control.html#*->/2">*-&gt;/2</a></dt>
30013051 <dt class="index-sep">,</dt>
30023052 <dt><a class="idx" href="control.html#,/2">,/2</a></dt>
3053 <dt class="index-sep">-</dt>
3054 <dt><a class="idx" href="control.html#->/2">-&gt;/2</a></dt>
30033055 <dt class="index-sep">.</dt>
30043056 <dt><a class="idx" href="dicts.html#./3">./3</a></dt>
30053057 <dt class="index-sep">/</dt>
30593111 <dt class="index-sep">B</dt>
30603112 <dt>Boehm GC</dt>
30613113 <dd>
3062 <a class="idx" href="foreignnotes.html#idx:BoehmGC:2092">11.8.2.1</a></dd>
3114 <a class="idx" href="foreignnotes.html#idx:BoehmGC:2096">11.8.2.1</a></dd>
30633115 <dt>BOM</dt>
30643116 <dd>
30653117 <a class="idx" href="widechars.html#idx:BOM:273">2.19.1.1</a></dd>
30693121 <dt class="index-sep">C</dt>
30703122 <dt>CLP</dt>
30713123 <dd>
3072 <a class="idx" href="clp.html#idx:CLP:1759">7</a></dd>
3124 <a class="idx" href="clp.html#idx:CLP:1763">7</a></dd>
30733125 <dt>COM</dt>
30743126 <dd>
3075 <a class="idx" href="foreigninclude.html#idx:COM:2037">11.4.7</a></dd>
3127 <a class="idx" href="foreigninclude.html#idx:COM:2041">11.4.7</a></dd>
30763128 <dt class="index-sep">D</dt>
30773129 <dt>Development environment</dt>
30783130 <dd>
30943146 <dt class="index-sep">H</dt>
30953147 <dt>Herbrand term</dt>
30963148 <dd>
3097 <a class="idx" href="clp.html#idx:Herbrandterm:1761">7</a></dd>
3149 <a class="idx" href="clp.html#idx:Herbrandterm:1765">7</a></dd>
30983150 <dt class="index-sep">I</dt>
30993151 <dt>IA32</dt>
31003152 <dd>
31113163 <dt class="index-sep">J</dt>
31123164 <dt>Java</dt>
31133165 <dd>
3114 <a class="idx" href="foreigninclude.html#idx:Java:2036">11.4.7</a></dd>
3166 <a class="idx" href="foreigninclude.html#idx:Java:2040">11.4.7</a></dd>
31153167 <dt class="index-sep">M</dt>
31163168 <dt>MacOS</dt>
31173169 <dd>
33543406 <dt><a class="idx" href="foreigninclude.html#PL_PARTIAL_LIST">PL_PARTIAL_LIST</a></dt>
33553407 <dt>PLVERSION</dt>
33563408 <dd>
3357 <a class="idx" href="foreignnotes.html#idx:PLVERSION:2093">11.8.3</a></dd>
3409 <a class="idx" href="foreignnotes.html#idx:PLVERSION:2097">11.8.3</a></dd>
33583410 <dt><a class="idx" href="foreigninclude.html#PL_get_file_nameW()">PL_get_file_nameW()</a></dt>
33593411 <dt class="index-sep">R</dt>
33603412 <dt>RDF,memory usage</dt>
33633415 <dt class="index-sep">S</dt>
33643416 <dt>Solaris</dt>
33653417 <dd>
3366 <a class="idx" href="threadcreate.html#idx:Solaris:1871">9.1</a></dd>
3418 <a class="idx" href="threadcreate.html#idx:Solaris:1875">9.1</a></dd>
33673419 <dt><code>/</code></dt>
33683420 <dd>
33693421 <a class="idx" href="projectfiles.html#idx:Sdiv:294">3.1.1.2</a></dd>
33723424 <a class="idx" href="projectfiles.html#idx:chrSneg:295">3.1.1.2</a></dd>
33733425 <dt>SLG,resolution</dt>
33743426 <dd>
3375 <a class="idx" href="tabling.html#idx:SLGresolution:2171">A.35</a></dd>
3427 <a class="idx" href="tabling.html#idx:SLGresolution:2175">A.35</a></dd>
33763428 <dt class="index-sep">T</dt>
33773429 <dt>TAB,completion</dt>
33783430 <dd>
33963448 <dt class="index-sep">Y</dt>
33973449 <dt>YAP,prolog</dt>
33983450 <dd>
3399 <a class="idx" href="dialect.html#idx:YAPprolog:2243">C</a></dd>
3451 <a class="idx" href="dialect.html#idx:YAPprolog:2247">C</a></dd>
34003452 <dt class="index-sep">{</dt>
34013453 <dt><a class="idx" href="clpqr.html#{}/1">/1</a></dt>
34023454 <dt class="index-sep">|</dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="64bits.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="projectfiles.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:IDE"><a name="sec:3"><span class="sec-nr">3</span> <span class="sec-title">Initialising
235 <h1 id="sec:IDE"><a id="sec:3"><span class="sec-nr">3</span> <span class="sec-title">Initialising
195236 and Managing a Prolog Project</span></a></h1>
196237
197 <a name="sec:IDE"></a>
198
199 <p><a name="idx:IDE:290"></a><a name="idx:Developmentenvironment:291"></a>Prolog
238 <a id="sec:IDE"></a>
239
240 <p><a id="idx:IDE:290"></a><a id="idx:Developmentenvironment:291"></a>Prolog
200241 text-books give you an overview of the Prolog language. The manual tells
201242 you what predicates are provided in the system and what they do. This
202243 chapter explains how to run a project. There is no ultimate `right' way
204245 SWI-Prolog's commands are there to support this practice. This chapter
205246 describes the conventions and supporting commands.
206247
207 <p>The first two sections (<a class="sec" href="projectfiles.html">section
208 3.1</a> and <a class="sec" href="usingmodules.html">section 3.2</a>)
248 <p>The first two sections (<a class="sec" href="projectfiles.html#sec:3.1">section
249 3.1</a> and <a class="sec" href="usingmodules.html#sec:3.2">section 3.2</a>)
209250 only require plain Prolog. The remainder discusses the use of the
210251 built-in graphical tools that require the XPCE graphical library
211252 installed on your system.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.17</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.17</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="examineprog.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="streamstat.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:IO"><a name="sec:4.17"><span class="sec-nr">4.17</span> <span class="sec-title">Input
235 <h2 id="sec:IO"><a id="sec:4.17"><span class="sec-nr">4.17</span> <span class="sec-title">Input
195236 and output</span></a></h2>
196237
197 <a name="sec:IO"></a>
238 <a id="sec:IO"></a>
198239
199240 <p>SWI-Prolog provides two different packages for input and output. The
200 native I/O system is based on the ISO standard predicates <a name="idx:open3:947"></a><a class="pred" href="IO.html#open/3">open/3</a>,
201 <a name="idx:close1:948"></a><a class="pred" href="IO.html#close/1">close/1</a>
241 native I/O system is based on the ISO standard predicates <a id="idx:open3:947"></a><a class="pred" href="IO.html#open/3">open/3</a>,
242 <a id="idx:close1:948"></a><a class="pred" href="IO.html#close/1">close/1</a>
202243 and friends.<sup class="fn">82<span class="fn-text">Actually based on
203244 Quintus Prolog, providing this interface before the ISO standard
204245 existed.</span></sup> Being more widely portable and equipped with a
205246 clearer and more robust specification, new code is encouraged to use
206247 these predicates for manipulation of I/O streams.
207248
208 <p><a class="sec" href="IO.html">Section 4.17.3</a> describes <a name="idx:tell1:949"></a><a class="pred" href="IO.html#tell/1">tell/1</a>, <a name="idx:see1:950"></a><a class="pred" href="IO.html#see/1">see/1</a>
249 <p><a class="sec" href="IO.html#sec:4.17.3">Section 4.17.3</a> describes <a id="idx:tell1:949"></a><a class="pred" href="IO.html#tell/1">tell/1</a>, <a id="idx:see1:950"></a><a class="pred" href="IO.html#see/1">see/1</a>
209250 and friends, providing I/O in the spirit of the traditional Edinburgh
210251 standard. These predicates are layered on top of the ISO predicates.
211252 Both packages are fully integrated; the user may switch freely between
212253 them.
213254
214 <p><h3 id="sec:streamalias"><a name="sec:4.17.1"><span class="sec-nr">4.17.1</span> <span class="sec-title">Predefined
255 <p><h3 id="sec:streamalias"><a id="sec:4.17.1"><span class="sec-nr">4.17.1</span> <span class="sec-title">Predefined
215256 stream aliases</span></a></h3>
216257
217 <a name="sec:streamalias"></a>
258 <a id="sec:streamalias"></a>
218259
219260 <p>Each thread has five stream aliases: <code>user_input</code>,
220261 <code>user_output</code>, <code>user_error</code>, <code>current_input</code>,
227268 handles 0,&nbsp;1 and&nbsp;2). These aliases may be re-bound, for
228269 example if standard I/O refers to a window such as in the <b>swipl-win.exe</b>
229270 GUI executable for Windows. They can be re-bound by the user using
230 <a name="idx:setprologIO3:951"></a><a class="pred" href="IO.html#set_prolog_IO/3">set_prolog_IO/3</a>
231 and <a name="idx:setstream2:952"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
271 <a id="idx:setprologIO3:951"></a><a class="pred" href="IO.html#set_prolog_IO/3">set_prolog_IO/3</a>
272 and <a id="idx:setstream2:952"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
232273 by setting the alias of a stream (e.g,
233274 <code>set_stream(S, alias(user_output))</code>). An example of rebinding
234275 can be found in library <code>library(prolog_server)</code>, providing a <b>telnet</b>
235276 service. The aliases <code>current_input</code> and <code>current_output</code>
236277 define the source and destination for predicates that do not take a
237 stream argument (e.g., <a name="idx:read1:953"></a><a class="pred" href="termrw.html#read/1">read/1</a>, <a name="idx:write1:954"></a><a class="pred" href="termrw.html#write/1">write/1</a>, <a name="idx:getcode1:955"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>,
278 stream argument (e.g., <a id="idx:read1:953"></a><a class="pred" href="termrw.html#read/1">read/1</a>, <a id="idx:write1:954"></a><a class="pred" href="termrw.html#write/1">write/1</a>, <a id="idx:getcode1:955"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>,
238279 ... ). Initially, these are bound to the same stream as <code>user_input</code>
239280 and
240 <code>user_error</code>. They are re-bound by <a name="idx:see1:956"></a><a class="pred" href="IO.html#see/1">see/1</a>, <a name="idx:tell1:957"></a><a class="pred" href="IO.html#tell/1">tell/1</a>, <a name="idx:setinput1:958"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>
281 <code>user_error</code>. They are re-bound by <a id="idx:see1:956"></a><a class="pred" href="IO.html#see/1">see/1</a>, <a id="idx:tell1:957"></a><a class="pred" href="IO.html#tell/1">tell/1</a>, <a id="idx:setinput1:958"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>
241282 and
242 <a name="idx:setoutput1:959"></a><a class="pred" href="IO.html#set_output/1">set_output/1</a>.
243 The <code>current_output</code> stream is also temporary re-bound by <a name="idx:withoutputto2:960"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
244 or <a name="idx:format3:961"></a><a class="pred" href="format.html#format/3">format/3</a>
283 <a id="idx:setoutput1:959"></a><a class="pred" href="IO.html#set_output/1">set_output/1</a>.
284 The <code>current_output</code> stream is also temporary re-bound by <a id="idx:withoutputto2:960"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
285 or <a id="idx:format3:961"></a><a class="pred" href="format.html#format/3">format/3</a>
245286 using e.g.,
246287 <code>format(atom(A), ...</code>. Note that code which explicitly writes
247288 to the streams <code>user_output</code> and <code>user_error</code> will
248 not be redirected by <a name="idx:withoutputto2:962"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
289 not be redirected by <a id="idx:withoutputto2:962"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
249290
250291 <p><b>Compatibility</b>
251292
252293 <p>Note that the ISO standard only defines the <code>user_*</code>
253 streams. The `current' streams can be accessed using <a name="idx:currentinput1:963"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>
294 streams. The `current' streams can be accessed using <a id="idx:currentinput1:963"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>
254295 and
255 <a name="idx:currentoutput1:964"></a><a class="pred" href="IO.html#current_output/1">current_output/1</a>.
296 <a id="idx:currentoutput1:964"></a><a class="pred" href="IO.html#current_output/1">current_output/1</a>.
256297 For example, an ISO compatible implementation of
257 <a name="idx:write1:965"></a><a class="pred" href="termrw.html#write/1">write/1</a>
298 <a id="idx:write1:965"></a><a class="pred" href="termrw.html#write/1">write/1</a>
258299 is
259300
260301 <pre class="code">
267308 write(Term) :- write(current_output, Term).
268309 </pre>
269310
270 <p><h3 id="sec:isoIO"><a name="sec:4.17.2"><span class="sec-nr">4.17.2</span> <span class="sec-title">ISO
311 <p><h3 id="sec:isoIO"><a id="sec:4.17.2"><span class="sec-nr">4.17.2</span> <span class="sec-title">ISO
271312 Input and Output Streams</span></a></h3>
272313
273 <a name="sec:isoIO"></a>
314 <a id="sec:isoIO"></a>
274315
275316 <p>The predicates described in this section provide ISO compliant I/O,
276 where streams are explicitly created using the predicate <a name="idx:open3:966"></a><a class="pred" href="IO.html#open/3">open/3</a>.
317 where streams are explicitly created using the predicate <a id="idx:open3:966"></a><a class="pred" href="IO.html#open/3">open/3</a>.
277318 The resulting stream identifier is then passed as a parameter to the
278319 reading and writing predicates to specify the source or destination of
279320 the data.
281322 <p>This schema is not vulnerable to filename and stream ambiguities as
282323 well as changes to the working directory. On the other hand, using the
283324 notion of current-I/O simplifies reusability of code without the need to
284 pass arguments around. E.g., see <a name="idx:withoutputto2:967"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
325 pass arguments around. E.g., see <a id="idx:withoutputto2:967"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
285326
286327 <p>SWI-Prolog streams are, compatible with the ISO standard, either
287328 input or output streams. To accommodate portability to other systems, a
288329 pair of streams can be packed into a <em>stream-pair</em>. See
289 <a name="idx:streampair3:968"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>
330 <a id="idx:streampair3:968"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>
290331 for details.
291332
292333 <p>SWI-Prolog stream handles are unique symbols that have no syntactical
293334 representation. They are written as <code>&lt;stream&gt;(hex-number)</code>,
294 which is not valid input for <a name="idx:read1:969"></a><a class="pred" href="termrw.html#read/1">read/1</a>.
295 They are realised using a <em>blob</em> of type <code>stream</code> (see <a name="idx:blob2:970"></a><a class="pred" href="typetest.html#blob/2">blob/2</a>
296 and <a class="sec" href="foreigninclude.html">section 11.4.7</a>).
335 which is not valid input for <a id="idx:read1:969"></a><a class="pred" href="termrw.html#read/1">read/1</a>.
336 They are realised using a <em>blob</em> of type <code>stream</code> (see <a id="idx:blob2:970"></a><a class="pred" href="typetest.html#blob/2">blob/2</a>
337 and <a class="sec" href="foreigninclude.html#sec:11.4.7">section 11.4.7</a>).
297338
298339 <dl class="latex">
299 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="open/4"><strong>open</strong>(<var>+SrcDest,
340 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="open/4"><strong>open</strong>(<var>+SrcDest,
300341 +Mode, --Stream, +Options</var>)</a></dt>
301342 <dd class="defbody">
302343 True when <var>SrcDest</var> can be opened in <var>Mode</var> and <var>Stream</var>
322363 <code>read</code>, data written by <var>Command</var> to the standard
323364 output may be read from <var>Stream</var>. On Unix systems, <var>Command</var>
324365 is handed to popen() which hands it to the Unix shell. On Windows, <var>Command</var>
325 is executed directly. See also <a name="idx:processcreate3:971"></a><span class="pred-ext">process_create/3</span>
366 is executed directly. See also <a id="idx:processcreate3:971"></a><span class="pred-ext">process_create/3</span>
326367 from <code>library(process)</code>.
327368
328 <p>The following <var>Options</var> are recognised by <a name="idx:open4:972"></a><a class="pred" href="IO.html#open/4">open/4</a>:
369 <p>The following <var>Options</var> are recognised by <a id="idx:open4:972"></a><a class="pred" href="IO.html#open/4">open/4</a>:
329370
330371 <dl class="latex">
331372 <dt><strong>alias</strong>(<var>Atom</var>)</dt>
332373 <dd class="defbody">
333374 Gives the stream a name. Below is an example. Be careful with this
334 option as stream names are global. See also <a name="idx:setstream2:973"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
375 option as stream names are global. See also <a id="idx:setstream2:973"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
335376
336377 <pre class="code">
337378 ?- open(data, read, Fd, [alias(input)]).
346387 <dd class="defbody">
347388 Check for a BOM (<em>Byte Order Marker</em>) or write one. If omitted,
348389 the default is <code>true</code> for mode <code>read</code> and
349 <code>false</code> for mode <code>write</code>. See also <a name="idx:streamproperty2:974"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
350 and especially <a class="sec" href="widechars.html">section 2.19.1.1</a>
351 for a discussion of this feature.</dd>
390 <code>false</code> for mode <code>write</code>. See also <a id="idx:streamproperty2:974"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
391 and especially <a class="sec" href="widechars.html#sec:2.19.1.1">section
392 2.19.1.1</a> for a discussion of this feature.</dd>
352393 <dt><strong>buffer</strong>(<var>Buffering</var>)</dt>
353394 <dd class="defbody">
354395 Defines output buffering. The atom <code>full</code> (default) defines
355396 full buffering, <code>line</code> buffering by line, and <code>false</code>
356397 implies the stream is fully unbuffered. Smaller buffering is useful if
357398 another process or the user is waiting for the output as it is being
358 produced. See also <a name="idx:flushoutput01:975"></a><a class="pred" href="chario.html#flush_output/0">flush_output/[0,1]</a>.
399 produced. See also <a id="idx:flushoutput01:975"></a><a class="pred" href="chario.html#flush_output/0">flush_output/[0,1]</a>.
359400 This option is not an ISO option.</dd>
360401 <dt><strong>close_on_abort</strong>(<var>Bool</var>)</dt>
361402 <dd class="defbody">
362403 If <code>true</code> (default), the stream is closed on an abort (see
363 <a name="idx:abort0:976"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
404 <a id="idx:abort0:976"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
364405 If <code>false</code>, the stream is not closed. If it is an output
365406 stream, however, it will be flushed. Useful for logfiles and if the
366407 stream is associated to a process (using the <code>pipe/1</code>
408449 The default encoding for type <code>text</code> is derived from the
409450 Prolog flag <a class="flag" href="flags.html#flag:encoding">encoding</a>.
410451 For <code>binary</code> streams the default encoding is <code>octet</code>.
411 For details on encoding issues, see <a class="sec" href="widechars.html">section
452 For details on encoding issues, see <a class="sec" href="widechars.html#sec:2.19.1">section
412453 2.19.1</a>.</dd>
413454 <dt><strong>eof_action</strong>(<var>Action</var>)</dt>
414455 <dd class="defbody">
415456 Defines what happens if the end of the input stream is reached. The
416 default value for Action is <code>eof_code</code>, which makes <a name="idx:get01:977"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
417 and friends return -1, and <a name="idx:read1:978"></a><a class="pred" href="termrw.html#read/1">read/1</a>
457 default value for Action is <code>eof_code</code>, which makes <a id="idx:get01:977"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
458 and friends return -1, and <a id="idx:read1:978"></a><a class="pred" href="termrw.html#read/1">read/1</a>
418459 and friends return the atom
419460 <code>end_of_file</code>. Repetitive reading keeps yielding the same
420461 result. Action <code>error</code> is like <code>eof_code</code>, but
423464 grown.</dd>
424465 <dt><strong>locale</strong>(<var>+Locale</var>)</dt>
425466 <dd class="defbody">
426 Set the locale that is used by notably <a name="idx:format2:979"></a><a class="pred" href="format.html#format/2">format/2</a>
427 for output on this stream. See <a class="sec" href="locale.html">section
467 Set the locale that is used by notably <a id="idx:format2:979"></a><a class="pred" href="format.html#format/2">format/2</a>
468 for output on this stream. See <a class="sec" href="locale.html#sec:4.23">section
428469 4.23</a>.</dd>
429470 <dt><strong>lock</strong>(<var>LockingMode</var>)</dt>
430471 <dd class="defbody">
462503
463504 <p>The option <code>reposition</code> is not supported in SWI-Prolog.
464505 All streams connected to a file may be repositioned.</dd>
465 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="open/3"><strong>open</strong>(<var>+SrcDest,
506 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="open/3"><strong>open</strong>(<var>+SrcDest,
466507 +Mode, --Stream</var>)</a></dt>
467508 <dd class="defbody">
468 Equivalent to <a name="idx:open4:980"></a><a class="pred" href="IO.html#open/4">open/4</a>
509 Equivalent to <a id="idx:open4:980"></a><a class="pred" href="IO.html#open/4">open/4</a>
469510 with an empty option list.</dd>
470 <dt class="pubdef"><a name="open_null_stream/1"><strong>open_null_stream</strong>(<var>--Stream</var>)</a></dt>
511 <dt class="pubdef"><a id="open_null_stream/1"><strong>open_null_stream</strong>(<var>--Stream</var>)</a></dt>
471512 <dd class="defbody">
472513 Open an output stream that produces no output. All counting functions
473514 are enabled on such a stream. It can be used to discard output (like
488529 </pre>
489530
490531 </dd>
491 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="close/1"><strong>close</strong>(<var>+Stream</var>)</a></dt>
532 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="close/1"><strong>close</strong>(<var>+Stream</var>)</a></dt>
492533 <dd class="defbody">
493534 Close the specified stream. If <var>Stream</var> is not open, an
494 existence error is raised. See <a name="idx:streampair3:981"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>
535 existence error is raised. See <a id="idx:streampair3:981"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>
495536 for the implications of closing a
496537 <em>stream pair</em>.
497538
498539 <p>If the closed stream is the current input, output or error stream,
499540 the stream alias is bound to the initial standard I/O streams of the
500 process. Calling <a name="idx:close1:982"></a><a class="pred" href="IO.html#close/1">close/1</a>
541 process. Calling <a id="idx:close1:982"></a><a class="pred" href="IO.html#close/1">close/1</a>
501542 on the initial standard I/O streams of the process is a no-op for an
502543 input stream and flushes an output stream without closing it.<sup class="fn">85<span class="fn-text">This
503544 behaviour was defined with purely interactive usage of Prolog in mind.
504545 Applications should not count on this behaviour. Future versions may
505546 allow for closing the initial standard I/O streams.</span></sup></dd>
506 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="close/2"><strong>close</strong>(<var>+Stream,
547 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="close/2"><strong>close</strong>(<var>+Stream,
507548 +Options</var>)</a></dt>
508549 <dd class="defbody">
509550 Provides <code>close(Stream, [force(true)])</code> as the only option.
510551 Called this way, any resource errors (such as write errors while
511552 flushing the output buffer) are ignored.</dd>
512 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="stream_property/2"><strong>stream_property</strong>(<var>?Stream,
553 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="stream_property/2"><strong>stream_property</strong>(<var>?Stream,
513554 ?StreamProperty</var>)</a></dt>
514555 <dd class="defbody">
515556 True when <var>StreamProperty</var> is a property of <var>Stream</var>.
530571 <dd class="defbody">
531572 SWI-Prolog extension to query the buffering mode of this stream.
532573 <var>Buffering</var> is one of <code>full</code>, <code>line</code> or <code>false</code>.
533 See also <a name="idx:open4:983"></a><a class="pred" href="IO.html#open/4">open/4</a>.</dd>
574 See also <a id="idx:open4:983"></a><a class="pred" href="IO.html#open/4">open/4</a>.</dd>
534575 <dt><strong>buffer_size</strong>(<var>Integer</var>)</dt>
535576 <dd class="defbody">
536577 SWI-Prolog extension to query the size of the I/O buffer associated to a
539580 <dd class="defbody">
540581 If present and <code>true</code>, a BOM (<em>Byte Order Mark</em>) was
541582 detected while opening the file for reading, or a BOM was written while
542 opening the stream. See <a class="sec" href="widechars.html">section
583 opening the stream. See <a class="sec" href="widechars.html#sec:2.19.1.1">section
543584 2.19.1.1</a> for details.</dd>
544585 <dt><strong>close_on_abort</strong>(<var>Bool</var>)</dt>
545586 <dd class="defbody">
546 Determine whether or not <a name="idx:abort0:984"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
587 Determine whether or not <a id="idx:abort0:984"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
547588 closes the stream. By default streams are closed.</dd>
548589 <dt><strong>close_on_exec</strong>(<var>Bool</var>)</dt>
549590 <dd class="defbody">
554595 on Windows.</dd>
555596 <dt><strong>encoding</strong>(<var>Encoding</var>)</dt>
556597 <dd class="defbody">
557 Query the encoding used for text. See <a class="sec" href="widechars.html">section
598 Query the encoding used for text. See <a class="sec" href="widechars.html#sec:2.19.1">section
558599 2.19.1</a> for an overview of wide character and encoding issues in
559600 SWI-Prolog.</dd>
560601 <dt><strong>end_of_stream</strong>(<var>E</var>)</dt>
562603 If <var>Stream</var> is an input stream, unify <var>E</var> with one of
563604 the atoms <code>not</code>, <code>at</code> or <code>past</code>. See
564605 also
565 <a name="idx:atendofstream01:985"></a><a class="pred" href="chario.html#at_end_of_stream/0">at_end_of_stream/[0,1]</a>.</dd>
606 <a id="idx:atendofstream01:985"></a><a class="pred" href="chario.html#at_end_of_stream/0">at_end_of_stream/[0,1]</a>.</dd>
566607 <dt><strong>eof_action</strong>(<var>A</var>)</dt>
567608 <dd class="defbody">
568609 Unify <var>A</var> with one of <code>eof_code</code>, <code>reset</code>
569610 or
570 <code>error</code>. See <a name="idx:open4:986"></a><a class="pred" href="IO.html#open/4">open/4</a>
611 <code>error</code>. See <a id="idx:open4:986"></a><a class="pred" href="IO.html#open/4">open/4</a>
571612 for details.</dd>
572613 <dt><strong>file_name</strong>(<var>Atom</var>)</dt>
573614 <dd class="defbody">
585626 <dt><strong>locale</strong>(<var>Locale</var>)</dt>
586627 <dd class="defbody">
587628 True when <var>Locale</var> is the current locale associated with the
588 stream. See <a class="sec" href="locale.html">section 4.23</a>.</dd>
629 stream. See <a class="sec" href="locale.html#sec:4.23">section 4.23</a>.</dd>
589630 <dt><strong>mode</strong>(<var>IOMode</var>)</dt>
590631 <dd class="defbody">
591 Unify <var>IOMode</var> to the mode given to <a name="idx:open4:987"></a><a class="pred" href="IO.html#open/4">open/4</a>
632 Unify <var>IOMode</var> to the mode given to <a id="idx:open4:987"></a><a class="pred" href="IO.html#open/4">open/4</a>
592633 for opening the stream. Values are: <code>read</code>, <code>write</code>, <code>append</code>
593634 and the SWI-Prolog extension <code>update</code>.</dd>
594635 <dt><strong>newline</strong>(<var>NewlineMode</var>)</dt>
611652 <dd class="defbody">
612653 Unify <var>Pos</var> with the current stream position. A stream position
613654 is an opaque term whose fields can be extracted using
614 <a name="idx:streampositiondata3:988"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.
615 See also <a name="idx:setstreamposition2:989"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.</dd>
655 <a id="idx:streampositiondata3:988"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.
656 See also <a id="idx:setstreamposition2:989"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.</dd>
616657 <dt><strong>reposition</strong>(<var>Bool</var>)</dt>
617658 <dd class="defbody">
618659 Unify <var>Bool</var> with <var>true</var> if the position of the stream
619 can be set (see <a name="idx:seek4:990"></a><a class="pred" href="IO.html#seek/4">seek/4</a>).
660 can be set (see <a id="idx:seek4:990"></a><a class="pred" href="IO.html#seek/4">seek/4</a>).
620661 It is assumed the position can be set if the stream has a <em>seek-function</em>
621662 and is not based on a POSIX file descriptor that is not associated to a
622663 regular file.</dd>
629670 escape code) or <code>xml</code> (write <code>&amp;#...;</code> XML
630671 character entity). The initial mode is <code>prolog</code> for the user
631672 streams and
632 <code>error</code> for all other streams. See also <a class="sec" href="widechars.html">section
633 2.19.1</a> and <a name="idx:setstream2:991"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
673 <code>error</code> for all other streams. See also <a class="sec" href="widechars.html#sec:2.19.1">section
674 2.19.1</a> and <a id="idx:setstream2:991"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
634675 <dt><strong>timeout</strong>(<var>-Time</var>)</dt>
635676 <dd class="defbody">
636677 <var>Time</var> is the timeout currently associated with the stream. See
637 <a name="idx:setstream2:992"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
678 <a id="idx:setstream2:992"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
638679 with the same option. If no timeout is specified,
639680 <var>Time</var> is unified to the atom <code>infinite</code>.</dd>
640681 <dt><strong>type</strong>(<var>Type</var>)</dt>
643684 <dt><strong>tty</strong>(<var>Bool</var>)</dt>
644685 <dd class="defbody">
645686 This property is reported with <var>Bool</var> equal to <code>true</code>
646 if the stream is associated with a terminal. See also <a name="idx:setstream2:993"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
687 if the stream is associated with a terminal. See also <a id="idx:setstream2:993"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
647688 <dt><strong>write_errors</strong>(<var>Atom</var>)</dt>
648689 <dd class="defbody">
649690 <var>Atom</var> is one of <code>error</code> (default) or <code>ignore</code>.
654695 </dl>
655696
656697 </dd>
657 <dt class="pubdef"><a name="current_stream/3"><strong>current_stream</strong>(<var>?Object,
698 <dt class="pubdef"><a id="current_stream/3"><strong>current_stream</strong>(<var>?Object,
658699 ?Mode, ?Stream</var>)</a></dt>
659700 <dd class="defbody">
660 The predicate <a name="idx:currentstream3:994"></a><a class="pred" href="IO.html#current_stream/3">current_stream/3</a>
701 The predicate <a id="idx:currentstream3:994"></a><a class="pred" href="IO.html#current_stream/3">current_stream/3</a>
661702 is used to access the status of a stream as well as to generate all open
662703 streams. <var>Object</var> is the name of the file opened if the stream
663704 refers to an open file, an integer file descriptor if the stream
664705 encapsulates an operating system stream, or the atom <code>[]</code> if
665706 the stream refers to some other object.
666707 <var>Mode</var> is one of <code>read</code> or <code>write</code>.</dd>
667 <dt class="pubdef"><a name="is_stream/1"><strong>is_stream</strong>(<var>+Term</var>)</a></dt>
708 <dt class="pubdef"><a id="is_stream/1"><strong>is_stream</strong>(<var>+Term</var>)</a></dt>
668709 <dd class="defbody">
669710 True if <var>Term</var> is a stream name or valid stream handle. This
670711 predicate realises a safe test for the existence of a stream alias or
671712 handle.</dd>
672 <dt class="pubdef"><a name="stream_pair/3"><strong>stream_pair</strong>(<var>?StreamPair,
713 <dt class="pubdef"><a id="stream_pair/3"><strong>stream_pair</strong>(<var>?StreamPair,
673714 ?Read, ?Write</var>)</a></dt>
674715 <dd class="defbody">
675716 This predicate can be used in mode (-,+,+) to create a
683724
684725 <p>Stream-pairs can be used by all I/O operations on streams, where the
685726 operation selects the appropriate member of the pair. The predicate
686 <a name="idx:close1:995"></a><a class="pred" href="IO.html#close/1">close/1</a>
727 <a id="idx:close1:995"></a><a class="pred" href="IO.html#close/1">close/1</a>
687728 closes the still open streams of the pair.<sup class="fn">86<span class="fn-text">As
688729 of version 7.1.19, it is allowed to close one of the members of the
689730 stream directly and close the pair later.</span></sup> The output stream
690731 is closed before the input stream. If closing the output stream results
691732 in an error, the input stream is still closed. Success is only returned
692733 if both streams were closed successfully.</dd>
693 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_stream_position/2"><strong>set_stream_position</strong>(<var>+Stream,
734 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_stream_position/2"><strong>set_stream_position</strong>(<var>+Stream,
694735 +Pos</var>)</a></dt>
695736 <dd class="defbody">
696737 Set the current position of <var>Stream</var> to <var>Pos</var>. <var>Pos</var>
697 is a term as returned by <a name="idx:streamproperty2:996"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
698 using the <code>position(Pos)</code> property. See also <a name="idx:seek4:997"></a><a class="pred" href="IO.html#seek/4">seek/4</a>.</dd>
699 <dt class="pubdef"><a name="stream_position_data/3"><strong>stream_position_data</strong>(<var>?Field,
738 is a term as returned by <a id="idx:streamproperty2:996"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
739 using the <code>position(Pos)</code> property. See also <a id="idx:seek4:997"></a><a class="pred" href="IO.html#seek/4">seek/4</a>.</dd>
740 <dt class="pubdef"><a id="stream_position_data/3"><strong>stream_position_data</strong>(<var>?Field,
700741 +Pos, -Data</var>)</a></dt>
701742 <dd class="defbody">
702 Extracts information from the opaque stream position term as returned by <a name="idx:streamproperty2:998"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
743 Extracts information from the opaque stream position term as returned by <a id="idx:streamproperty2:998"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
703744 requesting the <code>position(Pos)</code> property.
704745 <var>Field</var> is one of <code>line_count</code>, <code>line_position</code>,
705 <code>char_count</code> or <code>byte_count</code>. See also <a name="idx:linecount2:999"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>,
706 <a name="idx:lineposition2:1000"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>, <a name="idx:charactercount2:1001"></a><a class="pred" href="streamstat.html#character_count/2">character_count/2</a>
707 and <a name="idx:bytecount2:1002"></a><a class="pred" href="streamstat.html#byte_count/2">byte_count/2</a>.<sup class="fn">87<span class="fn-text">Introduced
746 <code>char_count</code> or <code>byte_count</code>. See also <a id="idx:linecount2:999"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>,
747 <a id="idx:lineposition2:1000"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>, <a id="idx:charactercount2:1001"></a><a class="pred" href="streamstat.html#character_count/2">character_count/2</a>
748 and <a id="idx:bytecount2:1002"></a><a class="pred" href="streamstat.html#byte_count/2">byte_count/2</a>.<sup class="fn">87<span class="fn-text">Introduced
708749 in version 5.6.4 after extending the position term with a byte count.
709750 Compatible with SICStus Prolog.</span></sup></dd>
710 <dt class="pubdef"><a name="seek/4"><strong>seek</strong>(<var>+Stream,
751 <dt class="pubdef"><a id="seek/4"><strong>seek</strong>(<var>+Stream,
711752 +Offset, +Method, -NewLocation</var>)</a></dt>
712753 <dd class="defbody">
713754 Reposition the current point of the given <var>Stream</var>. <var>Method</var>
720761 files using 2-byte Unicode encoding (2 bytes) or <em>wchar</em> encoding
721762 (sizeof(wchar_t)). The latter guarantees comfortable interaction with
722763 wide-character text objects. Otherwise, the use of
723 <a name="idx:seek4:1003"></a><a class="pred" href="IO.html#seek/4">seek/4</a>
724 on non-binary files (see <a name="idx:open4:1004"></a><a class="pred" href="IO.html#open/4">open/4</a>)
764 <a id="idx:seek4:1003"></a><a class="pred" href="IO.html#seek/4">seek/4</a>
765 on non-binary files (see <a id="idx:open4:1004"></a><a class="pred" href="IO.html#open/4">open/4</a>)
725766 is of limited use, especially when using multi-byte text encodings (e.g. UTF-8)
726767 or multi-byte newline files (e.g. DOS/Windows). On text files,
727 SWI-Prolog offers reliable backup to an old position using <a name="idx:streamproperty2:1005"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
768 SWI-Prolog offers reliable backup to an old position using <a id="idx:streamproperty2:1005"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
728769 and
729 <a name="idx:setstreamposition2:1006"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.
770 <a id="idx:setstreamposition2:1006"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.
730771 Skipping <var>N</var> character codes is achieved calling
731 <a name="idx:getcode2:1007"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a> <var>N</var>
732 times or using <a name="idx:copystreamdata3:1008"></a><a class="pred" href="chario.html#copy_stream_data/3">copy_stream_data/3</a>,
733 directing the output to a null stream (see <a name="idx:opennullstream1:1009"></a><a class="pred" href="IO.html#open_null_stream/1">open_null_stream/1</a>).
772 <a id="idx:getcode2:1007"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a> <var>N</var>
773 times or using <a id="idx:copystreamdata3:1008"></a><a class="pred" href="chario.html#copy_stream_data/3">copy_stream_data/3</a>,
774 directing the output to a null stream (see <a id="idx:opennullstream1:1009"></a><a class="pred" href="IO.html#open_null_stream/1">open_null_stream/1</a>).
734775 If the seek modifies the current location, the line number and character
735776 position in the line are set to 0.
736777
738779 is raised. If applying the offset would result in a file position less
739780 than zero, a <code>domain_error</code> is raised. Behaviour when seeking
740781 to positions beyond the size of the underlying object depend on the
741 object and possibly the operating system. The predicate <a name="idx:seek4:1010"></a><a class="pred" href="IO.html#seek/4">seek/4</a>
782 object and possibly the operating system. The predicate <a id="idx:seek4:1010"></a><a class="pred" href="IO.html#seek/4">seek/4</a>
742783 is compatible with Quintus Prolog, though the error conditions and
743 signalling is ISO compliant. See also <a name="idx:streamproperty2:1011"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
744 and <a name="idx:setstreamposition2:1012"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.</dd>
745 <dt class="pubdef"><a name="set_stream/2"><strong>set_stream</strong>(<var>+Stream,
784 signalling is ISO compliant. See also <a id="idx:streamproperty2:1011"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
785 and <a id="idx:setstreamposition2:1012"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.</dd>
786 <dt class="pubdef"><a id="set_stream/2"><strong>set_stream</strong>(<var>+Stream,
746787 +Attribute</var>)</a></dt>
747788 <dd class="defbody">
748789 Modify an attribute of an existing stream. <var>Attribute</var>
749 specifies the stream property to set. If stream is a <em>pair</em> (see <a name="idx:streampair3:1013"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>)
790 specifies the stream property to set. If stream is a <em>pair</em> (see <a id="idx:streampair3:1013"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>)
750791 both streams are modified, unless the property is only meaningful on one
751792 of the streams or setting both is not meaningful. In particular,
752793 <code>eof_action</code> only applies to the <em>read</em> stream,
753794 <code>representation_errors</code> only applies to the <em>write</em>
754795 stream and trying to set <code>alias</code> or <code>line_position</code>
755796 on a pair results in a <code>permission_error</code> exception. See also
756 <a name="idx:streamproperty2:1014"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
757 and <a name="idx:open4:1015"></a><a class="pred" href="IO.html#open/4">open/4</a>.
797 <a id="idx:streamproperty2:1014"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
798 and <a id="idx:open4:1015"></a><a class="pred" href="IO.html#open/4">open/4</a>.
758799
759800 <dl class="latex">
760801 <dt><strong>alias</strong>(<var>AliasName</var>)</dt>
761802 <dd class="defbody">
762803 Set the alias of an already created stream. If <var>AliasName</var> is
763804 the name of one of the standard streams, this stream is rebound. Thus, <code>set_stream(S,
764 current_input)</code> is the same as <a name="idx:setinput1:1016"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>,
805 current_input)</code> is the same as <a id="idx:setinput1:1016"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>,
765806 and by setting the alias of a stream to <code>user_input</code>, etc.,
766 all user terminal input is read from this stream. See also <a name="idx:interactor0:1017"></a><a class="pred" href="thutil.html#interactor/0">interactor/0</a>.</dd>
807 all user terminal input is read from this stream. See also <a id="idx:interactor0:1017"></a><a class="pred" href="thutil.html#interactor/0">interactor/0</a>.</dd>
767808 <dt><strong>buffer</strong>(<var>Buffering</var>)</dt>
768809 <dd class="defbody">
769810 Set the buffering mode of an already created stream. Buffering is one of <code>full</code>, <code>line</code>
774815 bytes.</dd>
775816 <dt><strong>close_on_abort</strong>(<var>Bool</var>)</dt>
776817 <dd class="defbody">
777 Determine whether or not the stream is closed by <a name="idx:abort0:1018"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
818 Determine whether or not the stream is closed by <a id="idx:abort0:1018"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
778819 By default, streams are closed.</dd>
779820 <dt><strong>close_on_exec</strong>(<var>Bool</var>)</dt>
780821 <dd class="defbody">
781 Set the <code>close_on_exec</code> property. See <a name="idx:streamproperty2:1019"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.</dd>
822 Set the <code>close_on_exec</code> property. See <a id="idx:streamproperty2:1019"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.</dd>
782823 <dt><strong>encoding</strong>(<var>Atom</var>)</dt>
783824 <dd class="defbody">
784825 Defines the mapping between bytes and character codes used for the
785 stream. See <a class="sec" href="widechars.html">section 2.19.1</a> for
786 supported encodings. The value
826 stream. See <a class="sec" href="widechars.html#sec:2.19.1">section
827 2.19.1</a> for supported encodings. The value
787828 <code>bom</code> causes the stream to check whether the current
788829 character is a Unicode BOM marker. If a BOM marker is found, the
789830 encoding is set accordingly and the call succeeds. Otherwise the call
805846 to correct position management of the stream after sending a terminal
806847 escape sequence (e.g., setting ANSI character attributes). Setting this
807848 attribute raises a permission error if the stream does not record
808 positions. See <a name="idx:lineposition2:1020"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>
809 and <a name="idx:streamproperty2:1021"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
849 positions. See <a id="idx:lineposition2:1020"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>
850 and <a id="idx:streamproperty2:1021"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
810851 (property <code>position</code>).</dd>
811852 <dt><strong>locale</strong>(<var>+Locale</var>)</dt>
812853 <dd class="defbody">
813 Change the locale of the stream. See <a class="sec" href="locale.html">section
854 Change the locale of the stream. See <a class="sec" href="locale.html#sec:4.23">section
814855 4.23</a>.</dd>
815856 <dt><strong>newline</strong>(<var>NewlineMode</var>)</dt>
816857 <dd class="defbody">
817858 Set input or output translation for newlines. See corresponding
818 <a name="idx:streamproperty2:1022"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
859 <a id="idx:streamproperty2:1022"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
819860 for details. In addition to the detected modes, an input stream can be
820861 set in mode <code>detect</code>. It will be set to <code>dos</code> if a <code>\r</code>
821862 character was removed.</dd>
824865 This option can be used to make streams generate an exception if it
825866 takes longer than <var>Seconds</var> before any new data arrives at the
826867 stream. The value <var>infinite</var> (default) makes the stream block
827 indefinitely. Like <a name="idx:waitforinput3:1023"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>,
868 indefinitely. Like <a id="idx:waitforinput3:1023"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>,
828869 this call only applies to streams that support the select() system call.
829 For further information about timeout handling, see <a name="idx:waitforinput3:1024"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>.
870 For further information about timeout handling, see <a id="idx:waitforinput3:1024"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>.
830871 The exception is of the form
831872 <blockquote>
832873 <code>error(<code>timeout_error(read, Stream)</code>, _)</code>
835876 <dt><strong>type</strong>(<var>Type</var>)</dt>
836877 <dd class="defbody">
837878 Set the type of the stream to one of <code>text</code> or <code>binary</code>.
838 See also <a name="idx:open4:1025"></a><a class="pred" href="IO.html#open/4">open/4</a>
879 See also <a id="idx:open4:1025"></a><a class="pred" href="IO.html#open/4">open/4</a>
839880 and the <code>encoding</code> property of streams. Switching to <code>binary</code>
840881 sets the encoding to <code>octet</code>. Switching to
841882 <code>text</code> sets the encoding to the default text encoding.</dd>
842883 <dt><strong>record_position</strong>(<var>Bool</var>)</dt>
843884 <dd class="defbody">
844 Do/do not record the line count and line position (see <a name="idx:linecount2:1026"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>
845 and <a name="idx:lineposition2:1027"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>).
885 Do/do not record the line count and line position (see <a id="idx:linecount2:1026"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>
886 and <a id="idx:lineposition2:1027"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>).
846887 Calling <code>set_stream(S, record_position(true))</code> resets the
847888 position the start of line&nbsp;1.</dd>
848889 <dt><strong>representation_errors</strong>(<var>Mode</var>)</dt>
849890 <dd class="defbody">
850891 Change the behaviour when writing characters to the stream that cannot
851 be represented by the encoding. See also <a name="idx:streamproperty2:1028"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
892 be represented by the encoding. See also <a id="idx:streamproperty2:1028"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
852893 and
853 <a class="sec" href="widechars.html">section 2.19.1</a>.</dd>
894 <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a>.</dd>
854895 <dt><strong>tty</strong>(<var>Bool</var>)</dt>
855896 <dd class="defbody">
856897 Modify whether Prolog thinks there is a terminal (i.e. human
857898 interaction) connected to this stream. On Unix systems the initial value
858899 comes from isatty(). On Windows, the initial user streams are supposed
859 to be associated to a terminal. See also <a name="idx:streamproperty2:1029"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.
900 to be associated to a terminal. See also <a id="idx:streamproperty2:1029"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.
860901 </dd>
861902 </dl>
862903
863904 </dd>
864 <dt class="pubdef"><a name="set_prolog_IO/3"><strong>set_prolog_IO</strong>(<var>+In,
905 <dt class="pubdef"><a id="set_prolog_IO/3"><strong>set_prolog_IO</strong>(<var>+In,
865906 +Out, +Error</var>)</a></dt>
866907 <dd class="defbody">
867908 Prepare the given streams for interactive behaviour normally associated
874915 is used for
875916 <code>user_error</code>. Output buffering for <var>Out</var> is set to
876917 <code>line</code> and buffering on <var>Error</var> is disabled. See
877 also <a name="idx:prolog0:1030"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
878 and <a name="idx:setstream2:1031"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
918 also <a id="idx:prolog0:1030"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
919 and <a id="idx:setstream2:1031"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
879920 The <em>clib</em> package provides the library <code>library(prolog_server)</code>,
880921 creating a TCP/IP server for creating an interactive session to Prolog.
881922 </dd>
882923 </dl>
883924
884 <p><h3 id="sec:edinburghIO"><a name="sec:4.17.3"><span class="sec-nr">4.17.3</span> <span class="sec-title">Edinburgh-style
925 <p><h3 id="sec:edinburghIO"><a id="sec:4.17.3"><span class="sec-nr">4.17.3</span> <span class="sec-title">Edinburgh-style
885926 I/O</span></a></h3>
886927
887 <a name="sec:edinburghIO"></a>
928 <a id="sec:edinburghIO"></a>
888929
889930 <p>The package for implicit input and output destinations is (almost)
890931 compatible with Edinburgh DEC-10 and C-Prolog. The reading and writing
891932 predicates refer to, resp., the <em>current</em> input and output
892933 streams. Initially these streams are connected to the terminal. The
893 current output stream is changed using <a name="idx:tell1:1032"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
894 or <a name="idx:append1:1033"></a><a class="pred" href="IO.html#append/1">append/1</a>.
895 The current input stream is changed using <a name="idx:see1:1034"></a><a class="pred" href="IO.html#see/1">see/1</a>.
896 The stream's current value can be obtained using <a name="idx:telling1:1035"></a><a class="pred" href="IO.html#telling/1">telling/1</a>
897 for output and <a name="idx:seeing1:1036"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
934 current output stream is changed using <a id="idx:tell1:1032"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
935 or <a id="idx:append1:1033"></a><a class="pred" href="IO.html#append/1">append/1</a>.
936 The current input stream is changed using <a id="idx:see1:1034"></a><a class="pred" href="IO.html#see/1">see/1</a>.
937 The stream's current value can be obtained using <a id="idx:telling1:1035"></a><a class="pred" href="IO.html#telling/1">telling/1</a>
938 for output and <a id="idx:seeing1:1036"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
898939 for input.
899940
900941 <p>Source and destination are either a file, <code>user</code>, or a
904945 In the predicate descriptions below we will call the source/destination
905946 argument `<var>SrcDest</var>'. Below are some examples of
906947 source/destination specifications.
907 <div style="text-align:center"><table border="0" frame="void" rules="groups">
908 <tr valign="top"><td><code>?- see(data).</code> </td><td>% Start reading
909 from file `data'. </td></tr>
910 <tr valign="top"><td><code>?- tell(user).</code> </td><td>% Start
911 writing to the terminal. </td></tr>
912 <tr valign="top"><td><code>?- tell(pipe(lpr)).</code> </td><td>% Start
913 writing to the printer.</td></tr>
948
949 <p><table class="latex frame-void center">
950 <tr><td><code>?- see(data).</code> </td><td>% Start reading from file
951 `data'. </td></tr>
952 <tr><td><code>?- tell(user).</code> </td><td>% Start writing to the
953 terminal. </td></tr>
954 <tr><td><code>?- tell(pipe(lpr)).</code> </td><td>% Start writing to the
955 printer.</td></tr>
914956 </table>
915 </div>
916957
917958 <p>Another example of using the <code>pipe/1</code> construct is shown
918959 below.<sup class="fn">89<span class="fn-text">As of version 5.3.15, the
935976 collect_wd([]).
936977 </pre>
937978
938 <p>The effect of <a name="idx:tell1:1037"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
979 <p>The effect of <a id="idx:tell1:1037"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
939980 is not undone on backtracking, and since the stream handle is not
940981 specified explicitly in further I/O operations when using
941982 Edinburgh-style I/O, you may write to unintended streams more easily
948989
949990 <h4>Compatibility notes</h4>
950991
951 <p>Unlike Edinburgh Prolog systems, <a name="idx:telling1:1038"></a><a class="pred" href="IO.html#telling/1">telling/1</a>
952 and <a name="idx:seeing1:1039"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
992 <p>Unlike Edinburgh Prolog systems, <a id="idx:telling1:1038"></a><a class="pred" href="IO.html#telling/1">telling/1</a>
993 and <a id="idx:seeing1:1039"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
953994 do not return the filename of the current input/output but rather the
954995 stream identifier, to ensure the design pattern below works under all
955996 circumstances:<sup class="fn">90<span class="fn-text">Filenames can be
9631004 ...,
9641005 </pre>
9651006
966 <p>The predicates <a name="idx:tell1:1040"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
967 and <a name="idx:see1:1041"></a><a class="pred" href="IO.html#see/1">see/1</a>
1007 <p>The predicates <a id="idx:tell1:1040"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
1008 and <a id="idx:see1:1041"></a><a class="pred" href="IO.html#see/1">see/1</a>
9681009 first check for <code>user</code>, the
9691010 <code>pipe(command)</code> and a stream handle. Otherwise, if the
9701011 argument is an atom it is first compared to open streams associated to a
9711012 file with <em>exactly</em> the same name. If such a stream exists,
9721013 created using
973 <a name="idx:tell1:1042"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
974 or <a name="idx:see1:1043"></a><a class="pred" href="IO.html#see/1">see/1</a>,
1014 <a id="idx:tell1:1042"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
1015 or <a id="idx:see1:1043"></a><a class="pred" href="IO.html#see/1">see/1</a>,
9751016 output (input) is switched to the open stream. Otherwise a file with the
9761017 specified name is opened.
9771018
9791020 without problems. Changing directory, non-file streams, and multiple
9801021 names referring to the same file easily lead to unexpected behaviour.
9811022 New code, especially when managing multiple I/O channels, should
982 consider using the ISO I/O predicates defined in <a class="sec" href="IO.html">section
1023 consider using the ISO I/O predicates defined in <a class="sec" href="IO.html#sec:4.17.2">section
9831024 4.17.2</a>.
9841025
9851026 <dl class="latex">
986 <dt class="pubdef"><a name="see/1"><strong>see</strong>(<var>+SrcDest</var>)</a></dt>
1027 <dt class="pubdef"><a id="see/1"><strong>see</strong>(<var>+SrcDest</var>)</a></dt>
9871028 <dd class="defbody">
9881029 Open <var>SrcDest</var> for reading and make it the current input (see
989 <a name="idx:setinput1:1044"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>).
1030 <a id="idx:setinput1:1044"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>).
9901031 If <var>SrcDest</var> is a stream handle, just make this stream the
991 current input. See the introduction of <a class="sec" href="IO.html">section
1032 current input. See the introduction of <a class="sec" href="IO.html#sec:4.17.3">section
9921033 4.17.3</a> for details.</dd>
993 <dt class="pubdef"><a name="tell/1"><strong>tell</strong>(<var>+SrcDest</var>)</a></dt>
1034 <dt class="pubdef"><a id="tell/1"><strong>tell</strong>(<var>+SrcDest</var>)</a></dt>
9941035 <dd class="defbody">
9951036 Open <var>SrcDest</var> for writing and make it the current output (see
996 <a name="idx:setoutput1:1045"></a><a class="pred" href="IO.html#set_output/1">set_output/1</a>).
1037 <a id="idx:setoutput1:1045"></a><a class="pred" href="IO.html#set_output/1">set_output/1</a>).
9971038 If <var>SrcDest</var> is a stream handle, just make this stream the
998 current output. See the introduction of <a class="sec" href="IO.html">section
1039 current output. See the introduction of <a class="sec" href="IO.html#sec:4.17.3">section
9991040 4.17.3</a> for details.</dd>
1000 <dt class="pubdef"><a name="append/1"><strong>append</strong>(<var>+File</var>)</a></dt>
1001 <dd class="defbody">
1002 Similar to <a name="idx:tell1:1046"></a><a class="pred" href="IO.html#tell/1">tell/1</a>,
1041 <dt class="pubdef"><a id="append/1"><strong>append</strong>(<var>+File</var>)</a></dt>
1042 <dd class="defbody">
1043 Similar to <a id="idx:tell1:1046"></a><a class="pred" href="IO.html#tell/1">tell/1</a>,
10031044 but positions the file pointer at the end of <var>File</var> rather than
10041045 truncating an existing file. The pipe construct is not accepted by this
10051046 predicate.</dd>
1006 <dt class="pubdef"><a name="seeing/1"><strong>seeing</strong>(<var>?SrcDest</var>)</a></dt>
1007 <dd class="defbody">
1008 Same as <a name="idx:currentinput1:1047"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>,
1047 <dt class="pubdef"><a id="seeing/1"><strong>seeing</strong>(<var>?SrcDest</var>)</a></dt>
1048 <dd class="defbody">
1049 Same as <a id="idx:currentinput1:1047"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>,
10091050 except that <code>user</code> is returned if the current input is the
10101051 stream <code>user_input</code> to improve compatibility with traditional
10111052 Edinburgh I/O. See the introduction of
1012 <a class="sec" href="IO.html">section 4.17.3</a> for details.</dd>
1013 <dt class="pubdef"><a name="telling/1"><strong>telling</strong>(<var>?SrcDest</var>)</a></dt>
1014 <dd class="defbody">
1015 Same as <a name="idx:currentoutput1:1048"></a><a class="pred" href="IO.html#current_output/1">current_output/1</a>,
1053 <a class="sec" href="IO.html#sec:4.17.3">section 4.17.3</a> for details.</dd>
1054 <dt class="pubdef"><a id="telling/1"><strong>telling</strong>(<var>?SrcDest</var>)</a></dt>
1055 <dd class="defbody">
1056 Same as <a id="idx:currentoutput1:1048"></a><a class="pred" href="IO.html#current_output/1">current_output/1</a>,
10161057 except that <code>user</code> is returned if the current output is the
10171058 stream <code>user_output</code> to improve compatibility with
10181059 traditional Edinburgh I/O. See the introduction of
1019 <a class="sec" href="IO.html">section 4.17.3</a> for details.</dd>
1020 <dt class="pubdef"><a name="seen/0"><strong>seen</strong></a></dt>
1060 <a class="sec" href="IO.html#sec:4.17.3">section 4.17.3</a> for details.</dd>
1061 <dt class="pubdef"><a id="seen/0"><strong>seen</strong></a></dt>
10211062 <dd class="defbody">
10221063 Close the current input stream. The new input stream becomes
10231064 <code>user_input</code>.</dd>
1024 <dt class="pubdef"><a name="told/0"><strong>told</strong></a></dt>
1065 <dt class="pubdef"><a id="told/0"><strong>told</strong></a></dt>
10251066 <dd class="defbody">
10261067 Close the current output stream. The new output stream becomes
10271068 <code>user_output</code>.
10281069 </dd>
10291070 </dl>
10301071
1031 <p><h3 id="sec:edinburgh-iso-io"><a name="sec:4.17.4"><span class="sec-nr">4.17.4</span> <span class="sec-title">Switching
1072 <p><h3 id="sec:edinburgh-iso-io"><a id="sec:4.17.4"><span class="sec-nr">4.17.4</span> <span class="sec-title">Switching
10321073 between Edinburgh and ISO I/O</span></a></h3>
10331074
1034 <a name="sec:edinburgh-iso-io"></a>
1075 <a id="sec:edinburgh-iso-io"></a>
10351076
10361077 <p>The predicates below can be used for switching between the implicit
10371078 and the explicit stream-based I/O predicates.
10381079
10391080 <dl class="latex">
1040 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_input/1"><strong>set_input</strong>(<var>+Stream</var>)</a></dt>
1081 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_input/1"><strong>set_input</strong>(<var>+Stream</var>)</a></dt>
10411082 <dd class="defbody">
10421083 Set the current input stream to become <var>Stream</var>. Thus, <code>open(file,
10431084 read, Stream), set_input(Stream)</code> is equivalent to <code>see(file)</code>.
10441085 </dd>
1045 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_output/1"><strong>set_output</strong>(<var>+Stream</var>)</a></dt>
1086 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_output/1"><strong>set_output</strong>(<var>+Stream</var>)</a></dt>
10461087 <dd class="defbody">
10471088 Set the current output stream to become <var>Stream</var>. See also
1048 <a name="idx:withoutputto2:1049"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
1049 </dd>
1050 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_input/1"><strong>current_input</strong>(<var>-Stream</var>)</a></dt>
1089 <a id="idx:withoutputto2:1049"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
1090 </dd>
1091 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_input/1"><strong>current_input</strong>(<var>-Stream</var>)</a></dt>
10511092 <dd class="defbody">
10521093 Get the current input stream. Useful for getting access to the status
10531094 predicates associated with streams.
10541095 </dd>
1055 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_output/1"><strong>current_output</strong>(<var>-Stream</var>)</a></dt>
1096 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_output/1"><strong>current_output</strong>(<var>-Stream</var>)</a></dt>
10561097 <dd class="defbody">
10571098 Get the current output stream.
10581099 </dd>
10591100 </dl>
10601101
1061 <p><h3 id="sec:write-on-atom"><a name="sec:4.17.5"><span class="sec-nr">4.17.5</span> <span class="sec-title">Write
1102 <p><h3 id="sec:write-on-atom"><a id="sec:4.17.5"><span class="sec-nr">4.17.5</span> <span class="sec-title">Write
10621103 onto atoms, code-lists, etc.</span></a></h3>
10631104
1064 <a name="sec:write-on-atom"></a>
1105 <a id="sec:write-on-atom"></a>
10651106
10661107 <dl class="latex">
1067 <dt class="pubdef"><a name="with_output_to/2"><strong>with_output_to</strong>(<var>+Output,
1108 <dt class="pubdef"><a id="with_output_to/2"><strong>with_output_to</strong>(<var>+Output,
10681109 :Goal</var>)</a></dt>
10691110 <dd class="defbody">
1070 Run <var>Goal</var> as <a name="idx:once1:1050"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
1111 Run <var>Goal</var> as <a id="idx:once1:1050"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
10711112 while characters written to the current output are sent to <var>Output</var>.
10721113 The predicate is SWI-Prolog-specific, inspired by various posts to the
10731114 mailinglist. It provides a flexible replacement for predicates such as
1074 sformat/3 , <a name="idx:swritef3:1051"></a><a class="pred" href="format.html#swritef/3">swritef/3</a>,
1075 <a name="idx:termtoatom2:1052"></a><a class="pred" href="manipatom.html#term_to_atom/2">term_to_atom/2</a>, <a name="idx:atomnumber2:1053"></a><a class="pred" href="manipatom.html#atom_number/2">atom_number/2</a>
1076 converting numbers to atoms, etc. The predicate <a name="idx:format3:1054"></a><a class="pred" href="format.html#format/3">format/3</a>
1115 sformat/3 , <a id="idx:swritef3:1051"></a><a class="pred" href="format.html#swritef/3">swritef/3</a>,
1116 <a id="idx:termtoatom2:1052"></a><a class="pred" href="manipatom.html#term_to_atom/2">term_to_atom/2</a>, <a id="idx:atomnumber2:1053"></a><a class="pred" href="manipatom.html#atom_number/2">atom_number/2</a>
1117 converting numbers to atoms, etc. The predicate <a id="idx:format3:1054"></a><a class="pred" href="format.html#format/3">format/3</a>
10771118 accepts the same terms as output argument.
10781119
10791120 <p>Applications should generally avoid creating atoms by breaking and
10811122 intermediate atoms generally leads to poor performance, even more so in
10821123 multithreaded applications. This predicate supports creating difference
10831124 lists from character data efficiently. The example below defines the DCG
1084 rule <a name="idx:term1:1055"></a><span class="pred-ext">term/3</span>
1085 to insert a term in the output:
1125 rule <a id="idx:term1:1055"></a><span class="pred-ext">term//1</span> to
1126 insert a term in the output:
10861127
10871128 <pre class="code">
10881129 term(Term, In, Tail) :-
10971138 <dt><b>A Stream handle or alias</b></dt>
10981139 <dd class="defbody">
10991140 Temporarily switch current output to the given stream. Redirection using
1100 <a name="idx:withoutputto2:1056"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
1141 <a id="idx:withoutputto2:1056"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
11011142 guarantees the original output is restored, also if
1102 <var>Goal</var> fails or raises an exception. See also <a name="idx:callcleanup2:1057"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.</dd>
1143 <var>Goal</var> fails or raises an exception. See also <a id="idx:callcleanup2:1057"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.</dd>
11031144 <dt><strong>atom</strong>(<var>-Atom</var>)</dt>
11041145 <dd class="defbody">
11051146 Create an atom from the emitted characters. Please note the remark
11061147 above.</dd>
11071148 <dt><strong>string</strong>(<var>-String</var>)</dt>
11081149 <dd class="defbody">
1109 Create a string object as defined in <a class="sec" href="strings.html">section
1150 Create a string object as defined in <a class="sec" href="strings.html#sec:5.2">section
11101151 5.2</a>.</dd>
11111152 <dt><strong>codes</strong>(<var>-Codes</var>)</dt>
11121153 <dd class="defbody">
11131154 Create a list of character codes from the emitted characters, similar to
1114 <a name="idx:atomcodes2:1058"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.</dd>
1155 <a id="idx:atomcodes2:1058"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.</dd>
11151156 <dt><strong>codes</strong>(<var>-Codes, -Tail</var>)</dt>
11161157 <dd class="defbody">
11171158 Create a list of character codes as a difference list.</dd>
11181159 <dt><strong>chars</strong>(<var>-Chars</var>)</dt>
11191160 <dd class="defbody">
11201161 Create a list of one-character atoms from the emitted characters,
1121 similar to <a name="idx:atomchars2:1059"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>.</dd>
1162 similar to <a id="idx:atomchars2:1059"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>.</dd>
11221163 <dt><strong>chars</strong>(<var>-Chars, -Tail</var>)</dt>
11231164 <dd class="defbody">
11241165 Create a list of one-character atoms as a difference list.
11281169 </dd>
11291170 </dl>
11301171
1131 <p><h3 id="sec:fast-term-io"><a name="sec:4.17.6"><span class="sec-nr">4.17.6</span> <span class="sec-title">Fast
1172 <p><h3 id="sec:fast-term-io"><a id="sec:4.17.6"><span class="sec-nr">4.17.6</span> <span class="sec-title">Fast
11321173 binary term I/O</span></a></h3>
11331174
1134 <a name="sec:fast-term-io"></a>
1175 <a id="sec:fast-term-io"></a>
11351176
11361177 <p>The predicates in this section provide fast binary I/O of arbitrary
11371178 Prolog terms, including cyclic terms and terms holding attributed
11391180 compatible library that extends the core primitives described below.
11401181
11411182 <p>The binary representation the same as used by <a class="func" href="foreigninclude.html#PL_record_external()">PL_record_external()</a>.
1142 The use of these primitives instead of using <a name="idx:writecanonical2:1060"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>
1183 The use of these primitives instead of using <a id="idx:writecanonical2:1060"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>
11431184 has advantages and disadvantages. Below are the main considerations:
11441185
11451186 <p>
11461187 <ul class="latex">
1147 <li>Using <a name="idx:writecanonical2:1061"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>
1188 <li>Using <a id="idx:writecanonical2:1061"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>
11481189 allows or exchange of terms with other Prolog systems. The format is
11491190 stable and, as it is text based, it can be inspected and corrected.
11501191 <li>Using the binary format improves the performance roughly 3 times.
11511192 <li>The size of both representations is comparable.
11521193 <li>The binary format can deal with cycles, sharing and attributes.
1153 Special precautions are needed to transfer such terms using <a name="idx:writecanonical2:1062"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.
1154 See <a name="idx:termfactorized3:1063"></a><span class="pred-ext">term_factorized/3</span>
1155 and <a name="idx:copyterm3:1064"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>.
1194 Special precautions are needed to transfer such terms using <a id="idx:writecanonical2:1062"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.
1195 See <a id="idx:termfactorized3:1063"></a><span class="pred-ext">term_factorized/3</span>
1196 and <a id="idx:copyterm3:1064"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>.
11561197 <li>In the current version, reading the binary format has only
11571198 incomplete consistency checks. This implies a user must be able to <b>trust
11581199 the source</b> as crafted messages may compromise the reading Prolog
11601201 </ul>
11611202
11621203 <dl class="latex">
1163 <dt class="pubdef"><a name="fast_term_serialized/2"><strong>fast_term_serialized</strong>(<var>?Term,
1204 <dt class="pubdef"><a id="fast_term_serialized/2"><strong>fast_term_serialized</strong>(<var>?Term,
11641205 ?String</var>)</a></dt>
11651206 <dd class="defbody">
11661207 (De-)serialize <var>Term</var> to/from <var>String</var>.</dd>
1167 <dt class="pubdef"><a name="fast_write/2"><strong>fast_write</strong>(<var>+Output,
1208 <dt class="pubdef"><a id="fast_write/2"><strong>fast_write</strong>(<var>+Output,
11681209 +Term</var>)</a></dt>
11691210 <dd class="defbody">
11701211 Write <var>Term</var> using the fast serialization format to the
11711212 <var>Output</var> stream. <var>Output</var> <em>must</em> be a binary
11721213 stream.</dd>
1173 <dt class="pubdef"><a name="fast_read/2"><strong>fast_read</strong>(<var>+Input,
1214 <dt class="pubdef"><a id="fast_read/2"><strong>fast_read</strong>(<var>+Input,
11741215 -Term</var>)</a></dt>
11751216 <dd class="defbody">
11761217 Read <var>Term</var> using the fast serialization format from the
11771218 <var>Input</var> stream. <var>Input</var> <em>must</em> be a binary
1178 stream.<sup class="fn">bug<span class="fn-text">The predicate <a name="idx:fastread2:1065"></a><a class="pred" href="IO.html#fast_read/2">fast_read/2</a>
1219 stream.<sup class="fn">bug<span class="fn-text">The predicate <a id="idx:fastread2:1065"></a><a class="pred" href="IO.html#fast_read/2">fast_read/2</a>
11791220 may crash on arbitrary input.</span></sup>
11801221 </dd>
11811222 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="chrintro.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="practical.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:SyntaxAndSemantics"><a name="sec:8.2"><span class="sec-nr">8.2</span> <span class="sec-title">Syntax
235 <h2 id="sec:SyntaxAndSemantics"><a id="sec:8.2"><span class="sec-nr">8.2</span> <span class="sec-title">Syntax
195236 and Semantics</span></a></h2>
196237
197 <a name="sec:SyntaxAndSemantics"></a>
198 <h3 id="sec:chr-syntax"><a name="sec:8.2.1"><span class="sec-nr">8.2.1</span> <span class="sec-title">Syntax
238 <a id="sec:SyntaxAndSemantics"></a>
239 <h3 id="sec:chr-syntax"><a id="sec:8.2.1"><span class="sec-nr">8.2.1</span> <span class="sec-title">Syntax
199240 of CHR rules</span></a></h3>
200241
201 <a name="sec:chr-syntax"></a>
242 <a id="sec:chr-syntax"></a>
202243
203244 <pre class="code">
204245 rules --&gt; rule, rules ; [].
247288 do not appear in the head of the rule, e.g. an auxiliary variable
248289 introduced in the guard.
249290
250 <p><h3 id="sec:chr-semantics"><a name="sec:8.2.2"><span class="sec-nr">8.2.2</span> <span class="sec-title">Semantics</span></a></h3>
251
252 <a name="sec:chr-semantics"></a> In this subsection the operational
291 <p><h3 id="sec:chr-semantics"><a id="sec:8.2.2"><span class="sec-nr">8.2.2</span> <span class="sec-title">Semantics</span></a></h3>
292
293 <a id="sec:chr-semantics"></a> In this subsection the operational
253294 semantics of CHR in Prolog are presented informally. They do not differ
254295 essentially from other CHR systems.
255296
334375 <p>Additional pragmas may be released in the future.
335376
336377 <dl class="latex">
337 <dt class="pubdef"><a name="chr_option/2">:- <strong>chr_option</strong>(<var>+Option,
378 <dt class="pubdef"><a id="chr_option/2">:- <strong>chr_option</strong>(<var>+Option,
338379 +Value</var>)</a></dt>
339380 <dd class="defbody">
340381 It is possible to specify options that apply to all the CHR rules in the
372413 <dd class="defbody">
373414 This option enables or disables the possibility to debug the CHR code.
374415 Possible values are <code>on</code> (default) and <code>off</code>. See
375 <a class="sec" href="debugging.html">section 8.4</a> for more details on
376 debugging. The default is derived from the Prolog flag <a class="flag" href="flags.html#flag:generate_debug_info">generate_debug_info</a>,
416 <a class="sec" href="debugging.html#sec:8.4">section 8.4</a> for more
417 details on debugging. The default is derived from the Prolog flag <a class="flag" href="flags.html#flag:generate_debug_info">generate_debug_info</a>,
377418 which is <code>true</code> by default. See <strong>-nodebug</strong>. If
378419 debugging is enabled, optimization must be disabled.
379420 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 1.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="implhistory.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="overview.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:acknowledge"><a name="sec:1.6"><span class="sec-nr">1.6</span> <span class="sec-title">Acknowledgements</span></a></h2>
195
196 <a name="sec:acknowledge"></a>
235 <h2 id="sec:acknowledge"><a id="sec:1.6"><span class="sec-nr">1.6</span> <span class="sec-title">Acknowledgements</span></a></h2>
236
237 <a id="sec:acknowledge"></a>
197238
198239 <p>Some small parts of the Prolog code of SWI-Prolog are modified
199240 versions of the corresponding Edinburgh C-Prolog code: grammar rule
200 compilation and <a name="idx:writef2:4"></a><a class="pred" href="format.html#writef/2">writef/2</a>.
241 compilation and <a id="idx:writef2:4"></a><a class="pred" href="format.html#writef/2">writef/2</a>.
201242 Also some of the C-code originates from C-Prolog: finding the path of
202 the currently running executable and some of the code underlying <a name="idx:absolutefilename2:5"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>.
243 the currently running executable and some of the code underlying <a id="idx:absolutefilename2:5"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>.
203244 Ideas on programming style and techniques originate from C-Prolog and
204245 Richard O'Keefe's <em>thief</em> editor. An important source of
205246 inspiration are the programming techniques introduced by Anjo
224265 implementation.
225266
226267 <p>Tom Schrijvers and Bart Demoen initiated the implementation of
227 <em>delimited continuations</em> (<a class="sec" href="delcont.html">section
268 <em>delimited continuations</em> (<a class="sec" href="delcont.html#sec:4.10">section
228269 4.10</a>), which was used by Benoit Desouter and Tom Schrijvers to
229 implement <em>tabling</em> (<a class="sec" href="tabling.html">section
270 implement <em>tabling</em> (<a class="sec" href="tabling.html#sec:A.35">section
230271 A.35</a>) as a library. Fabrizio Riguzzi added a first implementation
231 for <em>mode directed tabling</em> (<a class="sec" href="tabling.html">section
272 for <em>mode directed tabling</em> (<a class="sec" href="tabling.html#sec:A.35.3">section
232273 A.35.3</a>).
233274
234 <p>The SWI-Prolog&nbsp;7 extensions (<a class="sec" href="extensions.html">section
275 <p>The SWI-Prolog&nbsp;7 extensions (<a class="sec" href="extensions.html#sec:5">section
235276 5</a>) are the result of a long heated discussion on the mailinglist.
236277 Nicos Angelopoulos' wish for a smooth integration with the R language
237278 triggered the overall intend of these extensions to enable a smoother
263304
264305 <p>Kyndi (<a class="url" href="https://kyndi.com/">https://kyndi.com/</a>)
265306 sponsored the development of the
266 <em>engines</em> interface (<a class="sec" href="engines.html">chapter
307 <em>engines</em> interface (<a class="sec" href="engines.html#sec:10">chapter
267308 10</a>). The final API was established after discussion with the
268309 founding father of engines, Paul Tarau and Paulo Moura. Kyndi also
269310 sponsored JIT indexing on multiple arguments.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="libpl.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="apply.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:aggregate"><a name="sec:A.1"><span class="sec-nr">A.1</span> <span class="sec-title">library(aggregate):
235 <h2 id="sec:aggregate"><a id="sec:A.1"><span class="sec-nr">A.1</span> <span class="sec-title">library(aggregate):
195236 Aggregation operators on backtrackable predicates</span></a></h2>
196237
197 <p><a name="sec:aggregate"></a>
238 <p><a id="sec:aggregate"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">Compatibility</dt>
312353 <p><i>The development of this library was sponsored by SecuritEase, <a class="url" href="http://www.securitease.com">http://www.securitease.com</a></i>
313354
314355 <dl class="latex">
315 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="aggregate/3"><strong>aggregate</strong>(<var>+Template,
356 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="aggregate/3"><strong>aggregate</strong>(<var>+Template,
316357 :Goal, -Result</var>)</a></dt>
317358 <dd class="defbody">
318359 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
319360 The <a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
320361 version performs <a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
321362 on <var>Goal</var>.</dd>
322 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="aggregate/4"><strong>aggregate</strong>(<var>+Template,
363 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="aggregate/4"><strong>aggregate</strong>(<var>+Template,
323364 +Discriminator, :Goal, -Result</var>)</a></dt>
324365 <dd class="defbody">
325366 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
326367 The <a class="pred" href="aggregate.html#aggregate/4">aggregate/4</a>
327368 version performs <a class="pred" href="allsolutions.html#setof/3">setof/3</a>
328369 on <var>Goal</var>.</dd>
329 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="aggregate_all/3"><strong>aggregate_all</strong>(<var>+Template,
370 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="aggregate_all/3"><strong>aggregate_all</strong>(<var>+Template,
330371 :Goal, -Result</var>)</a></dt>
331372 <dd class="defbody">
332373 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
338379 <code>max(X)</code>, <code>min(X,Witness)</code> or <code>max(X,Witness)</code>
339380 and <var>Goal</var> has no solutions, i.e., the minumum and maximum of
340381 an empty set is undefined.</dd>
341 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="aggregate_all/4"><strong>aggregate_all</strong>(<var>+Template,
382 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="aggregate_all/4"><strong>aggregate_all</strong>(<var>+Template,
342383 +Discriminator, :Goal, -Result</var>)</a></dt>
343384 <dd class="defbody">
344385 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
348389 followed by <a class="pred" href="builtinlist.html#sort/2">sort/2</a> on
349390 <var>Goal</var>. See <a class="pred" href="aggregate.html#aggregate_all/3">aggregate_all/3</a>
350391 to understand why this predicate can fail.</dd>
351 <dt class="pubdef"><a name="foreach/2"><strong>foreach</strong>(<var>:Generator,
392 <dt class="pubdef"><a id="foreach/2"><strong>foreach</strong>(<var>:Generator,
352393 :Goal</var>)</a></dt>
353394 <dd class="defbody">
354395 True if conjunction of results is true. Unlike <a class="pred" href="forall2.html#forall/2">forall/2</a>,
381422 </dl>
382423
383424 </dd>
384 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="free_variables/4"><strong>free_variables</strong>(<var>:Generator,
425 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="free_variables/4"><strong>free_variables</strong>(<var>:Generator,
385426 +Template, +VarList0, -VarList</var>)</a></dt>
386427 <dd class="defbody">
387428 Find free variables in bagof/setof template. In order to handle
417458 </dl>
418459
419460 </dd>
420 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="sandbox:safe_meta/2"><span class="module">sandbox</span>:<strong>safe_meta</strong>(<var>+Goal,
461 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="sandbox:safe_meta/2"><span class="module">sandbox</span>:<strong>safe_meta</strong>(<var>+Goal,
421462 -Called</var>)</a></dt>
422463 <dd class="defbody">
423464 Declare the aggregate meta-calls safe. This cannot be proven due to the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.30</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.30</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="builtinlist.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="forall2.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:allsolutions"><a name="sec:4.30"><span class="sec-nr">4.30</span> <span class="sec-title">Finding
235 <h2 id="sec:allsolutions"><a id="sec:4.30"><span class="sec-nr">4.30</span> <span class="sec-title">Finding
195236 all Solutions to a Goal</span></a></h2>
196237
197 <a name="sec:allsolutions"></a>
238 <a id="sec:allsolutions"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="findall/3"><strong>findall</strong>(<var>+Template,
241 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="findall/3"><strong>findall</strong>(<var>+Template,
201242 :Goal, -Bag</var>)</a></dt>
202243 <dd class="defbody">
203244 Create a list of the instantiations <var>Template</var> gets
204245 successively on backtracking over <var>Goal</var> and unify the result
205246 with <var>Bag</var>. Succeeds with an empty list if <var>Goal</var> has
206 no solutions. <a name="idx:findall3:1361"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
207 is equivalent to <a name="idx:bagof3:1362"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
247 no solutions. <a id="idx:findall3:1361"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
248 is equivalent to <a id="idx:bagof3:1362"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
208249 with all free variables bound with the existential operator (<strong><code>^</code></strong>),
209 except that <a name="idx:bagof3:1363"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
250 except that <a id="idx:bagof3:1363"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
210251 fails when <var>Goal</var> has no solutions.</dd>
211 <dt class="pubdef"><a name="findall/4"><strong>findall</strong>(<var>+Template,
252 <dt class="pubdef"><a id="findall/4"><strong>findall</strong>(<var>+Template,
212253 :Goal, -Bag, +Tail</var>)</a></dt>
213254 <dd class="defbody">
214 As <a name="idx:findall3:1364"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
255 As <a id="idx:findall3:1364"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
215256 but returns the result as the difference list
216257 <var>Bag</var>-<var>Tail</var>. The 3-argument version is defined as
217258
221262 </pre>
222263
223264 </dd>
224 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="findnsols/4"><strong>findnsols</strong>(<var>+N,
265 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="findnsols/4"><strong>findnsols</strong>(<var>+N,
225266 @Template, :Goal, -List</var>)</a></dt>
226 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="findnsols/5"><strong>findnsols</strong>(<var>+N,
267 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="findnsols/5"><strong>findnsols</strong>(<var>+N,
227268 @Template, :Goal, -List, ?Tail</var>)</a></dt>
228269 <dd class="defbody">
229 As <a name="idx:findall3:1365"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
230 and <a name="idx:findall4:1366"></a><a class="pred" href="allsolutions.html#findall/4">findall/4</a>,
270 As <a id="idx:findall3:1365"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
271 and <a id="idx:findall4:1366"></a><a class="pred" href="allsolutions.html#findall/4">findall/4</a>,
231272 but generates at most <var>N</var> solutions. If
232273 <var>N</var> solutions are returned, this predicate succeeds with a
233274 choice point if <var>Goal</var> has a choice point. Backtracking returns
234275 the next chunk of (at most) <var>N</var> solutions. In addition to
235276 passing a plain integer for <var>N</var>, a term of the form <code>count(N)</code>
236277 is accepted. Using <code>count(N)</code>, the size of the next chunk can
237 be controlled using <a name="idx:nbsetarg3:1367"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
278 be controlled using <a id="idx:nbsetarg3:1367"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
238279 The non-deterministic behaviour used to implement the
239280 <em>chunk</em> option in <code>library(pengines)</code>. Based on Ciao,
240281 but the Ciao version is deterministic. Portability can be achieved by
241 wrapping the goal in <a name="idx:once1:1368"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
282 wrapping the goal in <a id="idx:once1:1368"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
242283 Below are three examples. The first illustrates standard chunking of
243284 answers. The second illustrates that the chunk size can be adjusted
244285 dynamically and the last illustrates that no choice point is left if <var>Goal</var>
262303 </pre>
263304
264305 </dd>
265 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="bagof/3"><strong>bagof</strong>(<var>+Template,
306 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="bagof/3"><strong>bagof</strong>(<var>+Template,
266307 :Goal, -Bag</var>)</a></dt>
267308 <dd class="defbody">
268309 Unify <var>Bag</var> with the alternatives of <var>Template</var>. If <var>Goal</var>
269 has free variables besides the one sharing with <var>Template</var>, <a name="idx:bagof3:1369"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
310 has free variables besides the one sharing with <var>Template</var>, <a id="idx:bagof3:1369"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
270311 will backtrack over the alternatives of these free variables, unifying
271312 <var>Bag</var> with the corresponding alternatives of <var>Template</var>.
272313 The construct <code>+<var>Var</var><code>^</code><var>Goal</var></code>
273 tells <a name="idx:bagof3:1370"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
314 tells <a id="idx:bagof3:1370"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
274315 not to bind
275 <var>Var</var> in <var>Goal</var>. <a name="idx:bagof3:1371"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
316 <var>Var</var> in <var>Goal</var>. <a id="idx:bagof3:1371"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
276317 fails if <var>Goal</var> has no solutions.
277318
278 <p>The example below illustrates <a name="idx:bagof3:1372"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
319 <p>The example below illustrates <a id="idx:bagof3:1372"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
279320 and the <strong><code>^</code></strong> operator. The variable bindings
280321 are printed together on one line to save paper.
281322
301342 </pre>
302343
303344 </dd>
304 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="setof/3"><strong>setof</strong>(<var>+Template,
345 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="setof/3"><strong>setof</strong>(<var>+Template,
305346 +Goal, -Set</var>)</a></dt>
306347 <dd class="defbody">
307 Equivalent to <a name="idx:bagof3:1373"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
308 but sorts the result using <a name="idx:sort2:1374"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
348 Equivalent to <a id="idx:bagof3:1373"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
349 but sorts the result using <a id="idx:sort2:1374"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
309350 to get a sorted list of alternatives without duplicates.
310351 </dd>
311352 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.11</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="resmodules.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="dynamic-modules.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:altmoduleapi"><a name="sec:6.11"><span class="sec-nr">6.11</span> <span class="sec-title">An
235 <h2 id="sec:altmoduleapi"><a id="sec:6.11"><span class="sec-nr">6.11</span> <span class="sec-title">An
195236 alternative import/export interface</span></a></h2>
196237
197 <a name="sec:altmoduleapi"></a>
198
199 <p>The <a name="idx:usemodule1:1726"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
200 predicate from <a class="sec" href="import.html">section 6.3</a> defines
201 import and export relations based on the filename from which a module is
202 loaded. If modules are created differently, such as by asserting
203 predicates into a new module as described in <a class="sec" href="dynamic-modules.html">section
238 <a id="sec:altmoduleapi"></a>
239
240 <p>The <a id="idx:usemodule1:1730"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
241 predicate from <a class="sec" href="import.html#sec:6.3">section 6.3</a>
242 defines import and export relations based on the filename from which a
243 module is loaded. If modules are created differently, such as by
244 asserting predicates into a new module as described in <a class="sec" href="dynamic-modules.html#sec:6.12">section
204245 6.12</a>, this interface cannot be used. The interface below provides
205246 for import/export from modules that are not created using a module file.
206247
207248 <dl class="latex">
208 <dt class="pubdef"><a name="export/1"><strong>export</strong>(<var>+PredicateIndicator,
249 <dt class="pubdef"><a id="export/1"><strong>export</strong>(<var>+PredicateIndicator,
209250 ...</var>)</a></dt>
210251 <dd class="defbody">
211252 Add predicates to the public list of the context module. This implies
212253 the predicate will be imported into another module if this module is
213 imported with <a name="idx:usemodule12:1727"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
214 Note that predicates are normally exported using the directive <a name="idx:module2:1728"></a><a class="pred" href="defmodule.html#module/2">module/2</a>. <a name="idx:export1:1729"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
254 imported with <a id="idx:usemodule12:1731"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
255 Note that predicates are normally exported using the directive <a id="idx:module2:1732"></a><a class="pred" href="defmodule.html#module/2">module/2</a>. <a id="idx:export1:1733"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
215256 is meant to handle export from dynamically created modules.</dd>
216 <dt class="pubdef"><a name="import/1"><strong>import</strong>(<var>+PredicateIndicator,
257 <dt class="pubdef"><a id="import/1"><strong>import</strong>(<var>+PredicateIndicator,
217258 ...</var>)</a></dt>
218259 <dd class="defbody">
219260 Import predicates <var>PredicateIndicator</var> into the current context
220261 module. <var>PredicateIndicator</var> must specify the source module
221262 using the &lt;<var>module</var>&gt;:&lt;<var>pi</var>&gt; construct.
222 Note that predicates are normally imported using one of the directives <a name="idx:usemodule12:1730"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
223 The <a name="idx:import1:1731"></a><a class="pred" href="altmoduleapi.html#import/1">import/1</a>
263 Note that predicates are normally imported using one of the directives <a id="idx:usemodule12:1734"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
264 The <a id="idx:import1:1735"></a><a class="pred" href="altmoduleapi.html#import/1">import/1</a>
224265 alternative is meant for handling imports into dynamically created
225 modules. See also <a name="idx:export1:1732"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
226 and <a name="idx:exportlist2:1733"></a><span class="pred-ext">export_list/2</span>.
266 modules. See also <a id="idx:export1:1736"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
267 and <a id="idx:exportlist2:1737"></a><span class="pred-ext">export_list/2</span>.
227268 </dd>
228269 </dl>
229270
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="manipstack.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="tracehook.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ancestral-cut"><a name="sec:B.2"><span class="sec-nr">B.2</span> <span class="sec-title">Ancestral
235 <h2 id="sec:ancestral-cut"><a id="sec:B.2"><span class="sec-nr">B.2</span> <span class="sec-title">Ancestral
195236 cuts</span></a></h2>
196237
197 <a name="sec:ancestral-cut"></a>
238 <a id="sec:ancestral-cut"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="prolog_cut_to/1"><strong>prolog_cut_to</strong>(<var>+Choice</var>)</a></dt>
241 <dt class="pubdef"><a id="prolog_cut_to/1"><strong>prolog_cut_to</strong>(<var>+Choice</var>)</a></dt>
201242 <dd class="defbody">
202243 Prunes all choice points created since <var>Choice</var>. Can be used
203 together with <a name="idx:prologcurrentchoice1:2187"></a><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a>
244 together with <a id="idx:prologcurrentchoice1:2191"></a><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a>
204245 to implement <em>ancestral</em> cuts. This predicate is in the hackers
205246 corner because it should not be used in normal Prolog code. It may be
206247 used to create new high level control structures, particularly for
210251 environment frames are <em>not</em> reclaimed. As a consequence, where
211252 predicates that are deterministic due to clause indexing, normal cuts or
212253 <code>(if\send{then};else)</code> and and tail recursive run in bounded
213 local stack space, predicates using <a name="idx:prologcutto1:2188"></a><a class="pred" href="ancestral-cut.html#prolog_cut_to/1">prolog_cut_to/1</a>
254 local stack space, predicates using <a id="idx:prologcutto1:2192"></a><a class="pred" href="ancestral-cut.html#prolog_cut_to/1">prolog_cut_to/1</a>
214255 will run out of stack.
215256 </dd>
216257 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="aggregate.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="assoc.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:apply"><a name="sec:A.2"><span class="sec-nr">A.2</span> <span class="sec-title">library(apply):
235 <h2 id="sec:apply"><a id="sec:A.2"><span class="sec-nr">A.2</span> <span class="sec-title">library(apply):
195236 Apply predicates on a list</span></a></h2>
196237
197 <p><a name="sec:apply"></a>
238 <p><a id="sec:apply"></a>
198239
199240 <dl class="tags">
200241 <dt class="mtag">See also</dt>
213254 members of a list.
214255
215256 <dl class="latex">
216 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="include/3"><strong>include</strong>(<var>:Goal,
257 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="include/3"><strong>include</strong>(<var>:Goal,
217258 +List1, ?List2</var>)</a></dt>
218259 <dd class="defbody">
219260 Filter elements for which <var>Goal</var> succeeds. True if <var>List2</var>
229270 </dl>
230271
231272 </dd>
232 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="exclude/3"><strong>exclude</strong>(<var>:Goal,
273 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="exclude/3"><strong>exclude</strong>(<var>:Goal,
233274 +List1, ?List2</var>)</a></dt>
234275 <dd class="defbody">
235276 Filter elements for which <var>Goal</var> fails. True if <var>List2</var>
236277 contains those elements Xi of <var>List1</var> for which <code>call(Goal, Xi)</code>
237278 fails.</dd>
238 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="partition/4"><strong>partition</strong>(<var>:Pred,
279 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="partition/4"><strong>partition</strong>(<var>:Pred,
239280 +List, ?Included, ?Excluded</var>)</a></dt>
240281 <dd class="defbody">
241282 Filter elements of <var>List</var> according to <var>Pred</var>. True if <var>Included</var>
242283 contains all elements for which <code>call(Pred, X)</code> succeeds and
243284 <var>Excluded</var> contains the remaining elements.</dd>
244 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="partition/5"><strong>partition</strong>(<var>:Pred,
285 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="partition/5"><strong>partition</strong>(<var>:Pred,
245286 +List, ?Less, ?Equal, ?Greater</var>)</a></dt>
246287 <dd class="defbody">
247288 Filter <var>List</var> according to <var>Pred</var> in three sets. For
249290 where Place must be unified to one of <code>&lt;</code>, <code>=</code>
250291 or <code>&gt;</code>.
251292 <var>Pred</var> must be deterministic.</dd>
252 <dt class="pubdef"><a name="maplist/2"><strong>maplist</strong>(<var>:Goal,
293 <dt class="pubdef"><a id="maplist/2"><strong>maplist</strong>(<var>:Goal,
253294 ?List</var>)</a></dt>
254295 <dd class="defbody">
255296 True if <var>Goal</var> can successfully be applied on all elements of
256297 <var>List</var>. Arguments are reordered to gain performance as well as
257298 to make the predicate deterministic under normal circumstances.</dd>
258 <dt class="pubdef"><a name="maplist/3"><strong>maplist</strong>(<var>:Goal,
299 <dt class="pubdef"><a id="maplist/3"><strong>maplist</strong>(<var>:Goal,
259300 ?List1, ?List2</var>)</a></dt>
260301 <dd class="defbody">
261302 As <a class="pred" href="apply.html#maplist/2">maplist/2</a>, operating
262303 on pairs of elements from two lists.</dd>
263 <dt class="pubdef"><a name="maplist/4"><strong>maplist</strong>(<var>:Goal,
304 <dt class="pubdef"><a id="maplist/4"><strong>maplist</strong>(<var>:Goal,
264305 ?List1, ?List2, ?List3</var>)</a></dt>
265306 <dd class="defbody">
266307 As <a class="pred" href="apply.html#maplist/2">maplist/2</a>, operating
267308 on triples of elements from three lists.</dd>
268 <dt class="pubdef"><a name="maplist/5"><strong>maplist</strong>(<var>:Goal,
309 <dt class="pubdef"><a id="maplist/5"><strong>maplist</strong>(<var>:Goal,
269310 ?List1, ?List2, ?List3, ?List4</var>)</a></dt>
270311 <dd class="defbody">
271312 As <a class="pred" href="apply.html#maplist/2">maplist/2</a>, operating
272313 on quadruples of elements from four lists.</dd>
273 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="convlist/3"><strong>convlist</strong>(<var>:Goal,
314 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="convlist/3"><strong>convlist</strong>(<var>:Goal,
274315 +ListIn, -ListOut</var>)</a></dt>
275316 <dd class="defbody">
276317 Similar to <a class="pred" href="apply.html#maplist/3">maplist/3</a>,
292333 </dl>
293334
294335 </dd>
295 <dt class="pubdef"><a name="foldl/4"><strong>foldl</strong>(<var>:Goal,
336 <dt class="pubdef"><a id="foldl/4"><strong>foldl</strong>(<var>:Goal,
296337 +List, +V0, -V</var>)</a></dt>
297 <dt class="pubdef"><a name="foldl/5"><strong>foldl</strong>(<var>:Goal,
338 <dt class="pubdef"><a id="foldl/5"><strong>foldl</strong>(<var>:Goal,
298339 +List1, +List2, +V0, -V</var>)</a></dt>
299 <dt class="pubdef"><a name="foldl/6"><strong>foldl</strong>(<var>:Goal,
340 <dt class="pubdef"><a id="foldl/6"><strong>foldl</strong>(<var>:Goal,
300341 +List1, +List2, +List3, +V0, -V</var>)</a></dt>
301 <dt class="pubdef"><a name="foldl/7"><strong>foldl</strong>(<var>:Goal,
342 <dt class="pubdef"><a id="foldl/7"><strong>foldl</strong>(<var>:Goal,
302343 +List1, +List2, +List3, +List4, +V0, -V</var>)</a></dt>
303344 <dd class="defbody">
304345 Fold a list, using arguments of the list as left argument. The foldl
312353 </pre>
313354
314355 </dd>
315 <dt class="pubdef"><a name="scanl/4"><strong>scanl</strong>(<var>:Goal,
356 <dt class="pubdef"><a id="scanl/4"><strong>scanl</strong>(<var>:Goal,
316357 +List, +V0, -Values</var>)</a></dt>
317 <dt class="pubdef"><a name="scanl/5"><strong>scanl</strong>(<var>:Goal,
358 <dt class="pubdef"><a id="scanl/5"><strong>scanl</strong>(<var>:Goal,
318359 +List1, +List2, +V0, -Values</var>)</a></dt>
319 <dt class="pubdef"><a name="scanl/6"><strong>scanl</strong>(<var>:Goal,
360 <dt class="pubdef"><a id="scanl/6"><strong>scanl</strong>(<var>:Goal,
320361 +List1, +List2, +List3, +V0, -Values</var>)</a></dt>
321 <dt class="pubdef"><a name="scanl/7"><strong>scanl</strong>(<var>:Goal,
362 <dt class="pubdef"><a id="scanl/7"><strong>scanl</strong>(<var>:Goal,
322363 +List1, +List2, +List3, +List4, +V0, -Values</var>)</a></dt>
323364 <dd class="defbody">
324365 Left scan of list. The scanl family of higher order list operations is
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.27</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.27</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="charconv.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="miscarith.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:arith"><a name="sec:4.27"><span class="sec-nr">4.27</span> <span class="sec-title">Arithmetic</span></a></h2>
195
196 <a name="sec:arith"></a>
235 <h2 id="sec:arith"><a id="sec:4.27"><span class="sec-nr">4.27</span> <span class="sec-title">Arithmetic</span></a></h2>
236
237 <a id="sec:arith"></a>
197238
198239 <p>Arithmetic can be divided into some special purpose integer
199240 predicates and a series of general predicates for integer, floating
200241 point and rational arithmetic as appropriate. The general arithmetic
201242 predicates all handle <var>expressions</var>. An expression is either a
202243 simple number or a <var>function</var>. The arguments of a function are
203 expressions. The functions are described in <a class="sec" href="arith.html">section
244 expressions. The functions are described in <a class="sec" href="arith.html#sec:4.27.2.3">section
204245 4.27.2.3</a>.
205246
206 <p><h3 id="sec:logic-int-arith"><a name="sec:4.27.1"><span class="sec-nr">4.27.1</span> <span class="sec-title">Special
247 <p><h3 id="sec:logic-int-arith"><a id="sec:4.27.1"><span class="sec-nr">4.27.1</span> <span class="sec-title">Special
207248 purpose integer arithmetic</span></a></h3>
208249
209 <a name="sec:logic-int-arith"></a>
250 <a id="sec:logic-int-arith"></a>
210251
211252 <p>The predicates in this section provide more logical operations
212253 between integers. They are not covered by the ISO standard, although
214255 in many other Prolog systems.
215256
216257 <dl class="latex">
217 <dt class="pubdef"><a name="between/3"><strong>between</strong>(<var>+Low,
258 <dt class="pubdef"><a id="between/3"><strong>between</strong>(<var>+Low,
218259 +High, ?Value</var>)</a></dt>
219260 <dd class="defbody">
220261 <var>Low</var> and <var>High</var> are integers, <var><var>High</var> &gt;=<var>Low</var></var>.
226267 <code>infinite</code><sup class="fn">106<span class="fn-text">We prefer <code>infinite</code>,
227268 but some other Prolog systems already use <code>inf</code> for infinity;
228269 we accept both for the time being.</span></sup>
229 <a name="idx:between3:1321"></a><a class="pred" href="arith.html#between/3">between/3</a>
270 <a id="idx:between3:1321"></a><a class="pred" href="arith.html#between/3">between/3</a>
230271 is true iff <var><var>Value</var> &gt;=<var>Low</var></var>, a feature
231272 that is particularly interesting for generating integers from a certain
232273 value.</dd>
233 <dt class="pubdef"><a name="succ/2"><strong>succ</strong>(<var>?Int1,
274 <dt class="pubdef"><a id="succ/2"><strong>succ</strong>(<var>?Int1,
234275 ?Int2</var>)</a></dt>
235276 <dd class="defbody">
236277 True if <var><var>Int2</var> = <var>Int1</var> + 1</var> and <var><var>Int1</var>
240281 silently and <code>succ(X, -1)</code> raises a domain error.<sup class="fn">107<span class="fn-text">The
241282 behaviour to deal with natural numbers only was defined by Richard
242283 O'Keefe to support the common count-down-to-zero in a natural way. Up to
243 5.1.8, <a name="idx:succ2:1322"></a><a class="pred" href="arith.html#succ/2">succ/2</a>
284 5.1.8, <a id="idx:succ2:1322"></a><a class="pred" href="arith.html#succ/2">succ/2</a>
244285 also accepted negative integers.</span></sup></dd>
245 <dt class="pubdef"><a name="plus/3"><strong>plus</strong>(<var>?Int1,
286 <dt class="pubdef"><a id="plus/3"><strong>plus</strong>(<var>?Int1,
246287 ?Int2, ?Int3</var>)</a></dt>
247288 <dd class="defbody">
248289 True if <var><var>Int3</var> = <var>Int1</var> + <var>Int2</var></var>.
249290 At least two of the three arguments must be instantiated to integers.</dd>
250 <dt class="pubdef"><a name="divmod/4"><strong>divmod</strong>(<var>+Dividend,
291 <dt class="pubdef"><a id="divmod/4"><strong>divmod</strong>(<var>+Dividend,
251292 +Divisor, -Quotient, -Remainder</var>)</a></dt>
252293 <dd class="defbody">
253294 This predicate is a shorthand for computing both the <var>Quotient</var>
256297 for exploiting the fact that the low level implementation for computing
257298 the quotient also produces the remainder. Timing confirms that this
258299 predicate is almost twice as fast as performing the steps independently.
259 Semantically, <a name="idx:divmod4:1323"></a><a class="pred" href="arith.html#divmod/4">divmod/4</a>
300 Semantically, <a id="idx:divmod4:1323"></a><a class="pred" href="arith.html#divmod/4">divmod/4</a>
260301 is defined as below.
261302
262303 <pre class="code">
268309 <p>Note that this predicate is only available if SWI-Prolog is compiled
269310 with unbounded integer support. This is the case for all packaged
270311 versions.</dd>
271 <dt class="pubdef"><a name="nth_integer_root_and_remainder/4"><strong>nth_integer_root_and_remainder</strong>(<var>+N,
312 <dt class="pubdef"><a id="nth_integer_root_and_remainder/4"><strong>nth_integer_root_and_remainder</strong>(<var>+N,
272313 +I, -Root, -Remainder</var>)</a></dt>
273314 <dd class="defbody">
274315 True when <var>Root ** N + Remainder = I</var>. <var>N</var> and <var>I</var>
296337 <p></dd>
297338 </dl>
298339
299 <p><h3 id="sec:arithpreds"><a name="sec:4.27.2"><span class="sec-nr">4.27.2</span> <span class="sec-title">General
340 <p><h3 id="sec:arithpreds"><a id="sec:4.27.2"><span class="sec-nr">4.27.2</span> <span class="sec-title">General
300341 purpose arithmetic</span></a></h3>
301342
302 <a name="sec:arithpreds"></a>
343 <a id="sec:arithpreds"></a>
303344
304345 <p>The general arithmetic predicates are optionally compiled (see
305 <a name="idx:setprologflag2:1324"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
346 <a id="idx:setprologflag2:1324"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
306347 and the <strong>-O</strong> command line option). Compiled arithmetic
307348 reduces global stack requirements and improves performance.
308349 Unfortunately compiled arithmetic cannot be traced, which is why it is
309350 optional.
310351
311352 <dl class="latex">
312 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name=">/2"><var>+Expr1</var> <strong>&gt;</strong> <var>+Expr2</var></a></dt>
353 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id=">/2"><var>+Expr1</var> <strong>&gt;</strong> <var>+Expr2</var></a></dt>
313354 <dd class="defbody">
314355 True if expression <var>Expr1</var> evaluates to a larger number than <var>Expr2</var>.</dd>
315 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="</2"><var>+Expr1</var> <strong>&lt;</strong> <var>+Expr2</var></a></dt>
356 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="</2"><var>+Expr1</var> <strong>&lt;</strong> <var>+Expr2</var></a></dt>
316357 <dd class="defbody">
317358 True if expression <var>Expr1</var> evaluates to a smaller number than <var>Expr2</var>.</dd>
318 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=</2"><var>+Expr1</var> <strong>=&lt;</strong> <var>+Expr2</var></a></dt>
359 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=</2"><var>+Expr1</var> <strong>=&lt;</strong> <var>+Expr2</var></a></dt>
319360 <dd class="defbody">
320361 True if expression <var>Expr1</var> evaluates to a smaller or equal
321362 number to <var>Expr2</var>.</dd>
322 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name=">=/2"><var>+Expr1</var> <strong>&gt;=</strong> <var>+Expr2</var></a></dt>
363 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id=">=/2"><var>+Expr1</var> <strong>&gt;=</strong> <var>+Expr2</var></a></dt>
323364 <dd class="defbody">
324365 True if expression <var>Expr1</var> evaluates to a larger or equal
325366 number to <var>Expr2</var>.</dd>
326 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=\=/2"><var>+Expr1</var> <strong>=\=</strong> <var>+Expr2</var></a></dt>
367 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=\=/2"><var>+Expr1</var> <strong>=\=</strong> <var>+Expr2</var></a></dt>
327368 <dd class="defbody">
328369 True if expression <var>Expr1</var> evaluates to a number non-equal to
329370 <var>Expr2</var>.</dd>
330 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=:=/2"><var>+Expr1</var> <strong>=:=</strong> <var>+Expr2</var></a></dt>
371 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=:=/2"><var>+Expr1</var> <strong>=:=</strong> <var>+Expr2</var></a></dt>
331372 <dd class="defbody">
332373 True if expression <var>Expr1</var> evaluates to a number equal to <var>
333374 Expr2</var>.</dd>
334 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="is/2"><var>-Number</var> <strong>is</strong> <var>+Expr</var></a></dt>
375 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="is/2"><var>-Number</var> <strong>is</strong> <var>+Expr</var></a></dt>
335376 <dd class="defbody">
336377 True when <var>Number</var> is the value to which <var>Expr</var>
337 evaluates. Typically, <a name="idx:is2:1325"></a><a class="pred" href="arith.html#is/2">is/2</a>
378 evaluates. Typically, <a id="idx:is2:1325"></a><a class="pred" href="arith.html#is/2">is/2</a>
338379 should be used with unbound left operand. If equality is to be tested, <a class="pred" href="arith.html#=:=/2">=:=/2</a>
339380 should be used. For example:
340 <div style="text-align:center"><table border="0" frame="void" rules="groups">
341 <tr valign="top"><td><code>?- 1 is sin(pi/2).</code> </td><td>Fails!
342 sin(pi/2) evaluates to the float 1.0, which does not unify with the
343 integer 1. </td></tr>
344 <tr valign="top"><td><code>?- 1 =:= sin(pi/2).</code> </td><td>Succeeds
345 as expected.</td></tr>
381
382 <p><table class="latex frame-void center">
383 <tr><td><code>?- 1 is sin(pi/2).</code> </td><td>Fails! sin(pi/2)
384 evaluates to the float 1.0, which does not unify with the integer 1. </td></tr>
385 <tr><td><code>?- 1 =:= sin(pi/2).</code> </td><td>Succeeds as expected.</td></tr>
346386 </table>
347 </div>
348387 </dd>
349388 </dl>
350389
351 <p><h4 id="sec:artypes"><a name="sec:4.27.2.1"><span class="sec-nr">4.27.2.1</span> <span class="sec-title">Arithmetic
390 <p><h4 id="sec:artypes"><a id="sec:4.27.2.1"><span class="sec-nr">4.27.2.1</span> <span class="sec-title">Arithmetic
352391 types</span></a></h4>
353392
354 <a name="sec:artypes"></a>
355
356 <p><a name="idx:integerunbounded:1326"></a><a name="idx:rationalnumber:1327"></a><a name="idx:numberrational:1328"></a>SWI-Prolog
393 <a id="sec:artypes"></a>
394
395 <p><a id="idx:integerunbounded:1326"></a><a id="idx:rationalnumber:1327"></a><a id="idx:numberrational:1328"></a>SWI-Prolog
357396 defines the following numeric types:
358397
359398 <p>
360399 <ul class="latex">
361400 <li><i>integer</i><br>
362401 If SWI-Prolog is built using the <em>GNU multiple precision arithmetic
363 library</em> <a name="idx:GMP:1329"></a>(GMP), integer arithmetic is <em>unbounded</em>,
402 library</em> <a id="idx:GMP:1329"></a>(GMP), integer arithmetic is <em>unbounded</em>,
364403 which means that the size of integers is limited by available memory
365404 only. Without GMP, SWI-Prolog integers are 64-bits, regardless of the
366405 native integer size of the platform. The type of integer support can be
382421 arithmetic is only provided if GMP is used (see above). Rational numbers
383422 are currently not supported by a Prolog type. They are represented by
384423 the compound term <code>rdiv(N,M)</code>. Rational numbers that are
385 returned from <a name="idx:is2:1330"></a><a class="pred" href="arith.html#is/2">is/2</a>
424 returned from <a id="idx:is2:1330"></a><a class="pred" href="arith.html#is/2">is/2</a>
386425 are <em>canonical</em>, which means <var>M</var> is positive and <var>N</var>
387426 and
388427 <var>M</var> have no common divisors. Rational numbers are introduced in
390429 or the <a class="function" href="arith.html#f-rdiv/2">rdiv/2</a>
391430 (rational division) function. Using the same functor for rational
392431 division and for representing rational numbers allows for passing
393 rational numbers between computations as well as for using <a name="idx:format3:1331"></a><a class="pred" href="format.html#format/3">format/3</a>
432 rational numbers between computations as well as for using <a id="idx:format3:1331"></a><a class="pred" href="format.html#format/3">format/3</a>
394433 for printing.
395434
396435 <p>In the long term, it is likely that rational numbers will become
397436 <em>atomic</em> as well as a subtype of <em>number</em>. User code that
398437 creates or inspects the <code>rdiv(M,N)</code> terms will not be
399438 portable to future versions. Rationals are created using one of the
400 functions mentioned above and inspected using <a name="idx:rational3:1332"></a><a class="pred" href="typetest.html#rational/3">rational/3</a>.
439 functions mentioned above and inspected using <a id="idx:rational3:1332"></a><a class="pred" href="typetest.html#rational/3">rational/3</a>.
401440
402441 <p>
403442 <li><i>float</i><br>
416455 floating point number
417456 </blockquote>
418457
419 <p><h4 id="sec:rational"><a name="sec:4.27.2.2"><span class="sec-nr">4.27.2.2</span> <span class="sec-title">Rational
458 <p><h4 id="sec:rational"><a id="sec:4.27.2.2"><span class="sec-nr">4.27.2.2</span> <span class="sec-title">Rational
420459 number examples</span></a></h4>
421460
422 <a name="sec:rational"></a>
461 <a id="sec:rational"></a>
423462
424463 <p>The use of rational numbers with unbounded integers allows for exact
425464 integer or <em>fixed point</em> arithmetic under addition, subtraction,
430469 on floats will convert a rational operand to float and continue the
431470 arithmetic using floating point numbers. Here are some examples.
432471
433 <p><table border="0" frame="void" rules="groups" style="margin:auto">
434 <tr valign="top"><td>A is 2 rdiv 6</td><td>A = 1 rdiv 3 </td></tr>
435 <tr valign="top"><td>A is 4 rdiv 3 + 1</td><td>A = 7 rdiv 3 </td></tr>
436 <tr valign="top"><td>A is 4 rdiv 3 + 1.5</td><td>A = 2.83333 </td></tr>
437 <tr valign="top"><td>A is 4 rdiv 3 + rational(1.5)</td><td>A = 17 rdiv 6 </td></tr>
472 <p><table class="latex frame-void center">
473 <tr><td>A is 2 rdiv 6</td><td>A = 1 rdiv 3 </td></tr>
474 <tr><td>A is 4 rdiv 3 + 1</td><td>A = 7 rdiv 3 </td></tr>
475 <tr><td>A is 4 rdiv 3 + 1.5</td><td>A = 2.83333 </td></tr>
476 <tr><td>A is 4 rdiv 3 + rational(1.5)</td><td>A = 17 rdiv 6 </td></tr>
438477 </table>
439478
440479 <p>Note that floats cannot represent all decimal numbers exactly. The
445484 for details and examples.
446485
447486 <p>Rational numbers can be printed as decimal numbers with arbitrary
448 precision using the <a name="idx:format3:1333"></a><a class="pred" href="format.html#format/3">format/3</a>
487 precision using the <a id="idx:format3:1333"></a><a class="pred" href="format.html#format/3">format/3</a>
449488 floating point conversion:
450489
451490 <pre class="code">
456495 A = 17 rdiv 6
457496 </pre>
458497
459 <p><h4 id="sec:functions"><a name="sec:4.27.2.3"><span class="sec-nr">4.27.2.3</span> <span class="sec-title">Arithmetic
498 <p><h4 id="sec:functions"><a id="sec:4.27.2.3"><span class="sec-nr">4.27.2.3</span> <span class="sec-title">Arithmetic
460499 Functions</span></a></h4>
461500
462 <a name="sec:functions"></a>
501 <a id="sec:functions"></a>
463502
464503 <p>Arithmetic functions are terms which are evaluated by the arithmetic
465 predicates described in <a class="sec" href="arith.html">section 4.27.2</a>.
466 There are four types of arguments to functions:
467 <div style="text-align:center"><table border="0" frame="void" rules="groups">
468 <tr valign="top"><td><var>Expr</var> </td><td>Arbitrary expression,
469 returning either a floating point value or an integer. </td></tr>
470 <tr valign="top"><td><var>IntExpr</var> </td><td>Arbitrary expression
471 that must evaluate to an integer. </td></tr>
472 <tr valign="top"><td><var>RatExpr</var> </td><td>Arbitrary expression
473 that must evaluate to a rational number. </td></tr>
474 <tr valign="top"><td><var>FloatExpr</var> </td><td>Arbitrary expression
475 that must evaluate to a floating point.</td></tr>
504 predicates described in <a class="sec" href="arith.html#sec:4.27.2">section
505 4.27.2</a>. There are four types of arguments to functions:
506
507 <p><table class="latex frame-void center">
508 <tr><td><var>Expr</var> </td><td>Arbitrary expression, returning either
509 a floating point value or an integer. </td></tr>
510 <tr><td><var>IntExpr</var> </td><td>Arbitrary expression that must
511 evaluate to an integer. </td></tr>
512 <tr><td><var>RatExpr</var> </td><td>Arbitrary expression that must
513 evaluate to a rational number. </td></tr>
514 <tr><td><var>FloatExpr</var> </td><td>Arbitrary expression that must
515 evaluate to a floating point.</td></tr>
476516 </table>
477 </div>
478517
479518 <p>For systems using bounded integer arithmetic (default is unbounded,
480 see <a class="sec" href="arith.html">section 4.27.2.1</a> for details),
481 integer operations that would cause overflow automatically convert to
482 floating point arithmetic.
519 see <a class="sec" href="arith.html#sec:4.27.2.1">section 4.27.2.1</a>
520 for details), integer operations that would cause overflow automatically
521 convert to floating point arithmetic.
483522
484523 <p>SWI-Prolog provides many extensions to the set of floating point
485524 functions defined by the ISO standard. The current policy is to provide
486525 such functions on `as-needed' basis if the function is widely supported
487526 elsewhere and notably if it is part of the
488 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdfC99
489 mathematical library. In addition, we try to maintain compatibility with
490 http://www.dcc.fc.up.pt/&nbsp;vsc/Yap/YAP.
527 <a class="url" href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf">C99</a>
528 mathematical library. In addition, we try to maintain compatibility with <a class="url" href="http://www.dcc.fc.up.pt/~vsc/Yap/">YAP</a>.
491529
492530 <dl class="latex">
493 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f--/1"><strong>-</strong> <var>+Expr</var></a></dt>
531 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f--/1"><strong>-</strong> <var>+Expr</var></a></dt>
494532 <dd class="defbody">
495533 <var><var>Result</var> = -<var>Expr</var></var></dd>
496 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-+/1"><strong>+</strong> <var>+Expr</var></a></dt>
534 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-+/1"><strong>+</strong> <var>+Expr</var></a></dt>
497535 <dd class="defbody">
498536 <var><var>Result</var> = <var>Expr</var></var>. Note that if <code><code>+</code></code>
499537 is followed by a number, the parser discards the <code><code>+</code></code>.
500538 I.e. <code>?- integer(+1)</code> succeeds.</dd>
501 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-+/2"><var>+Expr1</var> <strong>+</strong> <var>+Expr2</var></a></dt>
539 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-+/2"><var>+Expr1</var> <strong>+</strong> <var>+Expr2</var></a></dt>
502540 <dd class="defbody">
503541 <var><var>Result</var> = <var>Expr1</var> + <var>Expr2</var></var></dd>
504 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f--/2"><var>+Expr1</var> <strong>-</strong> <var>+Expr2</var></a></dt>
542 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f--/2"><var>+Expr1</var> <strong>-</strong> <var>+Expr2</var></a></dt>
505543 <dd class="defbody">
506544 <var><var>Result</var> = <var>Expr1</var> - <var>Expr2</var></var></dd>
507 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-*/2"><var>+Expr1</var> <strong>*</strong> <var>+Expr2</var></a></dt>
545 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-*/2"><var>+Expr1</var> <strong>*</strong> <var>+Expr2</var></a></dt>
508546 <dd class="defbody">
509547 <var><var>Result</var> = <var>Expr1</var> &times; <var>Expr2</var></var></dd>
510 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-//2"><var>+Expr1</var> <strong>/</strong> <var>+Expr2</var></a></dt>
548 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-//2"><var>+Expr1</var> <strong>/</strong> <var>+Expr2</var></a></dt>
511549 <dd class="defbody">
512550 <var><var>Result</var> = <var>Expr1</var>/<var>Expr2</var></var>. If the
513551 flag <a class="flag" href="flags.html#flag:iso">iso</a> is <code>true</code>,
518556 returns a rational number. In all other cases the return value is a
519557 float. See also <a class="function" href="arith.html#f-///2">///2</a>
520558 and <a class="function" href="arith.html#f-rdiv/2">rdiv/2</a>.</dd>
521 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-mod/2"><var>+IntExpr1</var> <strong>mod</strong> <var>+IntExpr2</var></a></dt>
559 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-mod/2"><var>+IntExpr1</var> <strong>mod</strong> <var>+IntExpr2</var></a></dt>
522560 <dd class="defbody">
523561 Modulo, defined as <var>Result</var> = <var>IntExpr1</var> - (<var>IntExpr1</var>
524562 div <var>IntExpr2</var>) <var> &times; </var> <var>IntExpr2</var>, where <code>div</code>
525563 is
526564 <em>floored</em> division.</dd>
527 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-rem/2"><var>+IntExpr1</var> <strong>rem</strong> <var>+IntExpr2</var></a></dt>
565 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-rem/2"><var>+IntExpr1</var> <strong>rem</strong> <var>+IntExpr2</var></a></dt>
528566 <dd class="defbody">
529567 Remainder of integer division. Behaves as if defined by
530568 <var>Result</var> is <var>IntExpr1</var> - (<var>IntExpr1</var> // <var>IntExpr2</var>) <var> &times; </var> <var>IntExpr2</var></dd>
531 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-///2"><var>+IntExpr1</var> <strong>//</strong> <var>+IntExpr2</var></a></dt>
569 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-///2"><var>+IntExpr1</var> <strong>//</strong> <var>+IntExpr2</var></a></dt>
532570 <dd class="defbody">
533571 Integer division, defined as <var>Result</var> is <var>rnd_I</var>(<var>Expr1</var>/<var>Expr2</var>)
534572 . The function <var>rnd_I</var> is the default rounding used by the C
536574 <a class="flag" href="flags.html#flag:integer_rounding_function">integer_rounding_function</a>.
537575 In the C99 standard, C-rounding is defined as <code>towards_zero</code>.<sup class="fn">109<span class="fn-text">Future
538576 versions might guarantee rounding towards zero.</span></sup></dd>
539 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-div/2"><strong>div</strong>(<var>+IntExpr1,
577 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-div/2"><strong>div</strong>(<var>+IntExpr1,
540578 +IntExpr2</var>)</a></dt>
541579 <dd class="defbody">
542580 Integer division, defined as <var>Result</var> is (<var>IntExpr1</var> - <var>IntExpr1</var> <var>mod</var> <var>IntExpr2</var>)
554592 </pre>
555593
556594 </dd>
557 <dt class="pubdef"><a name="f-rdiv/2"><var>+RatExpr</var> <strong>rdiv</strong> <var>+RatExpr</var></a></dt>
595 <dt class="pubdef"><a id="f-rdiv/2"><var>+RatExpr</var> <strong>rdiv</strong> <var>+RatExpr</var></a></dt>
558596 <dd class="defbody">
559597 Rational number division. This function is only available if SWI-Prolog
560598 has been compiled with rational number support. See
561 <a class="sec" href="arith.html">section 4.27.2.2</a> for details.</dd>
562 <dt class="pubdef"><a name="f-gcd/2"><var>+IntExpr1</var> <strong>gcd</strong> <var>+IntExpr2</var></a></dt>
599 <a class="sec" href="arith.html#sec:4.27.2.2">section 4.27.2.2</a> for
600 details.</dd>
601 <dt class="pubdef"><a id="f-gcd/2"><var>+IntExpr1</var> <strong>gcd</strong> <var>+IntExpr2</var></a></dt>
563602 <dd class="defbody">
564603 Result is the greatest common divisor of <var>IntExpr1</var>, <var>IntExpr2</var>.</dd>
565 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-abs/1"><strong>abs</strong>(<var>+Expr</var>)</a></dt>
604 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-abs/1"><strong>abs</strong>(<var>+Expr</var>)</a></dt>
566605 <dd class="defbody">
567606 Evaluate <var>Expr</var> and return the absolute value of it.</dd>
568 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-sign/1"><strong>sign</strong>(<var>+Expr</var>)</a></dt>
607 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-sign/1"><strong>sign</strong>(<var>+Expr</var>)</a></dt>
569608 <dd class="defbody">
570609 Evaluate to -1 if <var><var>Expr</var> &lt; 0</var>, 1 if <var><var>Expr</var>
571610 &gt; 0</var> and 0 if
572611 <var><var>Expr</var> = 0</var>. If <var>Expr</var> evaluates to a float,
573612 the return value is a float (e.g., -1.0, 0.0 or 1.0). In particular,
574613 note that sign(-0.0) evaluates to 0.0. See also <a class="function" href="arith.html#f-copysign/2">copysign/2</a></dd>
575 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-copysign/2"><strong>copysign</strong>(<var>+Expr1,
614 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-copysign/2"><strong>copysign</strong>(<var>+Expr1,
576615 +Expr2</var>)</a></dt>
577616 <dd class="defbody">
578617 Evaluate to <var>X</var>, where the absolute value of <var>X</var>
585624 -<var>Expr1</var> if the signs do not match. Here, we use the extended
586625 notion of signs for floating point numbers, where the sign of -0.0 and
587626 other special floats is negative.</dd>
588 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-max/2"><strong>max</strong>(<var>+Expr1,
627 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-max/2"><strong>max</strong>(<var>+Expr1,
589628 +Expr2</var>)</a></dt>
590629 <dd class="defbody">
591630 Evaluate to the larger of <var>Expr1</var> and <var>Expr2</var>. Both
592631 arguments are compared after converting to the same type, but the return
593632 value is in the original type. For example, max(2.5, 3) compares the two
594633 values after converting to float, but returns the integer 3.</dd>
595 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-min/2"><strong>min</strong>(<var>+Expr1,
634 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-min/2"><strong>min</strong>(<var>+Expr1,
596635 +Expr2</var>)</a></dt>
597636 <dd class="defbody">
598637 Evaluate to the smaller of <var>Expr1</var> and <var>Expr2</var>. See
599638 <a class="function" href="arith.html#f-max/2">max/2</a> for a
600639 description of type handling.</dd>
601 <dt class="pubdef"><a name="f-./2"><strong>.</strong>(<var>+Int,[]</var>)</a></dt>
640 <dt class="pubdef"><a id="f-./2"><strong>.</strong>(<var>+Int,[]</var>)</a></dt>
602641 <dd class="defbody">
603642 A list of one element evaluates to the element. This implies <code>"a"</code>
604643 evaluates to the character code of the letter `a' (97) using the
605644 traditional mapping of double quoted string to a list of character
606645 codes. Arithmetic evaluation also translates a string object (see
607 <a class="sec" href="strings.html">section 5.2</a>) of one character
608 length into the character code for that character. This implies that
609 expression <code>"a"</code> also works of the Prolog flag <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>
646 <a class="sec" href="strings.html#sec:5.2">section 5.2</a>) of one
647 character length into the character code for that character. This
648 implies that expression <code>"a"</code> also works of the Prolog flag <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>
610649 is set to <code>string</code>. The recommended way to specify the
611650 character code of the letter `a' is
612651 <code>0'a</code>.</dd>
613 <dt class="pubdef"><a name="f-random/1"><strong>random</strong>(<var>+IntExpr</var>)</a></dt>
652 <dt class="pubdef"><a id="f-random/1"><strong>random</strong>(<var>+IntExpr</var>)</a></dt>
614653 <dd class="defbody">
615654 Evaluate to a random integer <var>i</var> for which <var>0 =&lt; i &lt; <var>IntExpr</var></var>.
616655 The system has two implementations. If it is compiled with support for
622661 Windows the state is initialised from CryptGenRandom().</span></sup>
623662 Otherwise it is set from the system clock. If unbounded arithmetic is
624663 not supported, random numbers are shared between threads and the seed is
625 initialised from the clock when SWI-Prolog was started. The predicate <a name="idx:setrandom1:1334"></a><a class="pred" href="miscarith.html#set_random/1">set_random/1</a>
664 initialised from the clock when SWI-Prolog was started. The predicate <a id="idx:setrandom1:1334"></a><a class="pred" href="miscarith.html#set_random/1">set_random/1</a>
626665 can be used to control the random number generator.
627666
628667 <p><b>Warning!</b> Although properly seeded (if supported on the OS),
629668 the Mersenne Twister algorithm does <em>not</em> produce
630669 cryptographically secure random numbers. To generate cryptographically
631 secure random numbers, use <a name="idx:cryptonrandombytes2:1335"></a><span class="pred-ext">crypto_n_random_bytes/2</span>
670 secure random numbers, use <a id="idx:cryptonrandombytes2:1335"></a><span class="pred-ext">crypto_n_random_bytes/2</span>
632671 from library <code>library(crypto)</code> provided by the <code>ssl</code>
633672 package.</dd>
634 <dt class="pubdef"><a name="f-random_float/0"><strong>random_float</strong></a></dt>
673 <dt class="pubdef"><a id="f-random_float/0"><strong>random_float</strong></a></dt>
635674 <dd class="defbody">
636675 Evaluate to a random float <var>I</var> for which <var>0.0 &lt; i &lt;
637676 1.0</var>. This function shares the random state with <a class="function" href="arith.html#f-random/1">random/1</a>.
647686 expects [0.0,1.0) is going to be surprised when 0.0 fails to turn up in
648687 a few millions of millions of trials, now is it? But a program that
649688 expects (0.0,1.0) could be devastated if 0.0 did turn up.''</span></sup></dd>
650 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-round/1"><strong>round</strong>(<var>+Expr</var>)</a></dt>
689 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-round/1"><strong>round</strong>(<var>+Expr</var>)</a></dt>
651690 <dd class="defbody">
652691 Evaluate <var>Expr</var> and round the result to the nearest integer.
653692 According to ISO, <a class="function" href="arith.html#f-round/1">round/1</a>
657696 <code>round(Expr) == -round(-Expr)</code> does not hold. SWI-Prolog
658697 rounds <em>outward</em>, e.g., <code>round(1.5) =:= 2</code> and round
659698 <code>round(-1.5) =:= -2</code>.</dd>
660 <dt class="pubdef"><a name="f-integer/1"><strong>integer</strong>(<var>+Expr</var>)</a></dt>
699 <dt class="pubdef"><a id="f-integer/1"><strong>integer</strong>(<var>+Expr</var>)</a></dt>
661700 <dd class="defbody">
662701 Same as <a class="function" href="arith.html#f-round/1">round/1</a>
663702 (backward compatibility).</dd>
664 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-float/1"><strong>float</strong>(<var>+Expr</var>)</a></dt>
703 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-float/1"><strong>float</strong>(<var>+Expr</var>)</a></dt>
665704 <dd class="defbody">
666705 Translate the result to a floating point number. Normally, Prolog will
667706 use integers whenever possible. When used around the 2nd argument of
668 <a name="idx:is2:1336"></a><a class="pred" href="arith.html#is/2">is/2</a>,
707 <a id="idx:is2:1336"></a><a class="pred" href="arith.html#is/2">is/2</a>,
669708 the result will be returned as a floating point number. In other
670709 contexts, the operation has no effect.</dd>
671 <dt class="pubdef"><a name="f-rational/1"><strong>rational</strong>(<var>+Expr</var>)</a></dt>
710 <dt class="pubdef"><a id="f-rational/1"><strong>rational</strong>(<var>+Expr</var>)</a></dt>
672711 <dd class="defbody">
673712 Convert the <var>Expr</var> to a rational number or integer. The
674713 function returns the input on integers and rational numbers. For
677716 numbers the results may be surprising. In the examples below, doubles
678717 can represent 0.25 and the result is as expected, in contrast to the
679718 result of <code>rational(0.1)</code>. The function <a class="function" href="arith.html#f-rationalize/1">rationalize/1</a>
680 remedies this. See <a class="sec" href="arith.html">section 4.27.2.2</a>
681 for more information on rational number support.
719 remedies this. See <a class="sec" href="arith.html#sec:4.27.2.2">section
720 4.27.2.2</a> for more information on rational number support.
682721
683722 <pre class="code">
684723 ?- A is rational(0.25).
689728 </pre>
690729
691730 </dd>
692 <dt class="pubdef"><a name="f-rationalize/1"><strong>rationalize</strong>(<var>+Expr</var>)</a></dt>
731 <dt class="pubdef"><a id="f-rationalize/1"><strong>rationalize</strong>(<var>+Expr</var>)</a></dt>
693732 <dd class="defbody">
694733 Convert the <var>Expr</var> to a rational number or integer. The
695734 function is similar to <a class="function" href="arith.html#f-rational/1">rational/1</a>,
709748 </pre>
710749
711750 </dd>
712 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-float_fractional_part/1"><strong>float_fractional_part</strong>(<var>+Expr</var>)</a></dt>
751 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-float_fractional_part/1"><strong>float_fractional_part</strong>(<var>+Expr</var>)</a></dt>
713752 <dd class="defbody">
714753 Fractional part of a floating point number. Negative if <var>Expr</var>
715754 is negative, rational if <var>Expr</var> is rational and 0 if <var>Expr</var>
716755 is integer. The following relation is always true:
717756 <var>X is float_fractional_part(X) + float_integer_part(X)</var>.</dd>
718 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-float_integer_part/1"><strong>float_integer_part</strong>(<var>+Expr</var>)</a></dt>
757 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-float_integer_part/1"><strong>float_integer_part</strong>(<var>+Expr</var>)</a></dt>
719758 <dd class="defbody">
720759 Integer part of floating point number. Negative if <var>Expr</var> is
721760 negative, <var>Expr</var> if <var>Expr</var> is integer.</dd>
722 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-truncate/1"><strong>truncate</strong>(<var>+Expr</var>)</a></dt>
761 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-truncate/1"><strong>truncate</strong>(<var>+Expr</var>)</a></dt>
723762 <dd class="defbody">
724763 Truncate <var>Expr</var> to an integer. If <var><var>Expr</var> &gt;= 0</var>
725764 this is the same as <code>floor(Expr)</code>. For <var><var>Expr</var> &lt;
726765 0</var> this is the same as
727 <code>ceil(Expr)</code>. That is, <a name="idx:truncate1:1337"></a><span class="pred-ext">truncate/1</span>
766 <code>ceil(Expr)</code>. That is, <a id="idx:truncate1:1337"></a><span class="pred-ext">truncate/1</span>
728767 rounds towards zero.</dd>
729 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-floor/1"><strong>floor</strong>(<var>+Expr</var>)</a></dt>
768 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-floor/1"><strong>floor</strong>(<var>+Expr</var>)</a></dt>
730769 <dd class="defbody">
731770 Evaluate <var>Expr</var> and return the largest integer smaller or equal
732771 to the result of the evaluation.</dd>
733 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-ceiling/1"><strong>ceiling</strong>(<var>+Expr</var>)</a></dt>
772 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-ceiling/1"><strong>ceiling</strong>(<var>+Expr</var>)</a></dt>
734773 <dd class="defbody">
735774 Evaluate <var>Expr</var> and return the smallest integer larger or equal
736775 to the result of the evaluation.</dd>
737 <dt class="pubdef"><a name="f-ceil/1"><strong>ceil</strong>(<var>+Expr</var>)</a></dt>
776 <dt class="pubdef"><a id="f-ceil/1"><strong>ceil</strong>(<var>+Expr</var>)</a></dt>
738777 <dd class="defbody">
739778 Same as <a class="function" href="arith.html#f-ceiling/1">ceiling/1</a>
740779 (backward compatibility).</dd>
741 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f->>/2"><var>+IntExpr1</var> <strong>&gt;&gt;</strong> <var>+IntExpr2</var></a></dt>
780 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f->>/2"><var>+IntExpr1</var> <strong>&gt;&gt;</strong> <var>+IntExpr2</var></a></dt>
742781 <dd class="defbody">
743782 Bitwise shift <var>IntExpr1</var> by <var>IntExpr2</var> bits to the
744783 right. The operation performs <em>arithmetic shift</em>, which implies
745784 that the inserted most significant bits are copies of the original most
746785 significant bits.</dd>
747 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-<</2"><var>+IntExpr1</var> <strong>&lt;&lt;</strong> <var>+IntExpr2</var></a></dt>
786 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-<</2"><var>+IntExpr1</var> <strong>&lt;&lt;</strong> <var>+IntExpr2</var></a></dt>
748787 <dd class="defbody">
749788 Bitwise shift <var>IntExpr1</var> by <var>IntExpr2</var> bits to the
750789 left.</dd>
751 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-\//2"><var>+IntExpr1</var> <strong>\/</strong> <var>+IntExpr2</var></a></dt>
790 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-\//2"><var>+IntExpr1</var> <strong>\/</strong> <var>+IntExpr2</var></a></dt>
752791 <dd class="defbody">
753792 Bitwise `or' <var>IntExpr1</var> and <var>IntExpr2</var>.</dd>
754 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-/\/2"><var>+IntExpr1</var> <strong>/\</strong> <var>+IntExpr2</var></a></dt>
793 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-/\/2"><var>+IntExpr1</var> <strong>/\</strong> <var>+IntExpr2</var></a></dt>
755794 <dd class="defbody">
756795 Bitwise `and' <var>IntExpr1</var> and <var>IntExpr2</var>.</dd>
757 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-xor/2"><var>+IntExpr1</var> <strong>xor</strong> <var>+IntExpr2</var></a></dt>
796 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-xor/2"><var>+IntExpr1</var> <strong>xor</strong> <var>+IntExpr2</var></a></dt>
758797 <dd class="defbody">
759798 Bitwise `exclusive or' <var>IntExpr1</var> and <var>IntExpr2</var>.</dd>
760 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-\/1"><strong>\</strong> <var>+IntExpr</var></a></dt>
799 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-\/1"><strong>\</strong> <var>+IntExpr</var></a></dt>
761800 <dd class="defbody">
762801 Bitwise negation. The returned value is the one's complement of
763802 <var>IntExpr</var>.</dd>
764 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-sqrt/1"><strong>sqrt</strong>(<var>+Expr</var>)</a></dt>
803 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-sqrt/1"><strong>sqrt</strong>(<var>+Expr</var>)</a></dt>
765804 <dd class="defbody">
766805 <var><var>Result</var> = sqrt(<var>Expr</var>)</var>
767806 </dd>
768 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-sin/1"><strong>sin</strong>(<var>+Expr</var>)</a></dt>
807 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-sin/1"><strong>sin</strong>(<var>+Expr</var>)</a></dt>
769808 <dd class="defbody">
770809 <var><var>Result</var> = sin(<var>Expr</var>)</var>. <var>Expr</var> is
771810 the angle in radians.
772811 </dd>
773 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-cos/1"><strong>cos</strong>(<var>+Expr</var>)</a></dt>
812 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-cos/1"><strong>cos</strong>(<var>+Expr</var>)</a></dt>
774813 <dd class="defbody">
775814 <var><var>Result</var> = cos(<var>Expr</var>)</var>. <var>Expr</var> is
776815 the angle in radians.
777816 </dd>
778 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-tan/1"><strong>tan</strong>(<var>+Expr</var>)</a></dt>
817 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-tan/1"><strong>tan</strong>(<var>+Expr</var>)</a></dt>
779818 <dd class="defbody">
780819 <var><var>Result</var> = tan(<var>Expr</var>)</var>. <var>Expr</var> is
781820 the angle in radians.
782821 </dd>
783 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-asin/1"><strong>asin</strong>(<var>+Expr</var>)</a></dt>
822 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-asin/1"><strong>asin</strong>(<var>+Expr</var>)</a></dt>
784823 <dd class="defbody">
785824 <var><var>Result</var> = arcsin(<var>Expr</var>)</var>. <var>Result</var>
786825 is the angle in radians.
787826 </dd>
788 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-acos/1"><strong>acos</strong>(<var>+Expr</var>)</a></dt>
827 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-acos/1"><strong>acos</strong>(<var>+Expr</var>)</a></dt>
789828 <dd class="defbody">
790829 <var><var>Result</var> = arccos(<var>Expr</var>)</var>. <var>Result</var>
791830 is the angle in radians.
792831 </dd>
793 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-atan/1"><strong>atan</strong>(<var>+Expr</var>)</a></dt>
832 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-atan/1"><strong>atan</strong>(<var>+Expr</var>)</a></dt>
794833 <dd class="defbody">
795834 <var><var>Result</var> = arctan(<var>Expr</var>)</var>. <var>Result</var>
796835 is the angle in radians.
797836 </dd>
798 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-atan2/2"><strong>atan2</strong>(<var>+YExpr,
837 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-atan2/2"><strong>atan2</strong>(<var>+YExpr,
799838 +XExpr</var>)</a></dt>
800839 <dd class="defbody">
801840 <var><var>Result</var> = arctan(<var>YExpr</var>/<var>XExpr</var>)</var>. <var>Result</var>
807846 to raise an evaluation error, whereas the C99 and POSIX standards demand
808847 this to evaluate to 0.0. SWI-Prolog follows C99 and POSIX.
809848 </dd>
810 <dt class="pubdef"><a name="f-atan/2"><strong>atan</strong>(<var>+YExpr,
849 <dt class="pubdef"><a id="f-atan/2"><strong>atan</strong>(<var>+YExpr,
811850 +XExpr</var>)</a></dt>
812851 <dd class="defbody">
813852 Same as <a class="function" href="arith.html#f-atan2/2">atan2/2</a>
814853 (backward compatibility).</dd>
815 <dt class="pubdef"><a name="f-sinh/1"><strong>sinh</strong>(<var>+Expr</var>)</a></dt>
854 <dt class="pubdef"><a id="f-sinh/1"><strong>sinh</strong>(<var>+Expr</var>)</a></dt>
816855 <dd class="defbody">
817856 <var><var>Result</var> = sinh(<var>Expr</var>)</var>. The hyperbolic
818857 sine of <var>X</var> is defined as <var>e ** X - e ** -X / 2</var>.
819858 </dd>
820 <dt class="pubdef"><a name="f-cosh/1"><strong>cosh</strong>(<var>+Expr</var>)</a></dt>
859 <dt class="pubdef"><a id="f-cosh/1"><strong>cosh</strong>(<var>+Expr</var>)</a></dt>
821860 <dd class="defbody">
822861 <var><var>Result</var> = cosh(<var>Expr</var>)</var>. The hyperbolic
823862 cosine of <var>X</var> is defined as <var>e ** X + e ** -X / 2</var>.
824863 </dd>
825 <dt class="pubdef"><a name="f-tanh/1"><strong>tanh</strong>(<var>+Expr</var>)</a></dt>
864 <dt class="pubdef"><a id="f-tanh/1"><strong>tanh</strong>(<var>+Expr</var>)</a></dt>
826865 <dd class="defbody">
827866 <var><var>Result</var> = tanh(<var>Expr</var>)</var>. The hyperbolic
828867 tangent of <var>X</var> is defined as <var>sinh( X ) / cosh( X )</var>.</dd>
829 <dt class="pubdef"><a name="f-asinh/1"><strong>asinh</strong>(<var>+Expr</var>)</a></dt>
868 <dt class="pubdef"><a id="f-asinh/1"><strong>asinh</strong>(<var>+Expr</var>)</a></dt>
830869 <dd class="defbody">
831870 <var><var>Result</var> = arcsinh(<var>Expr</var>)</var> (inverse
832871 hyperbolic sine).
833872 </dd>
834 <dt class="pubdef"><a name="f-acosh/1"><strong>acosh</strong>(<var>+Expr</var>)</a></dt>
873 <dt class="pubdef"><a id="f-acosh/1"><strong>acosh</strong>(<var>+Expr</var>)</a></dt>
835874 <dd class="defbody">
836875 <var><var>Result</var> = arccosh(<var>Expr</var>)</var> (inverse
837876 hyperbolic cosine).
838877 </dd>
839 <dt class="pubdef"><a name="f-atanh/1"><strong>atanh</strong>(<var>+Expr</var>)</a></dt>
878 <dt class="pubdef"><a id="f-atanh/1"><strong>atanh</strong>(<var>+Expr</var>)</a></dt>
840879 <dd class="defbody">
841880 <var><var>Result</var> = arctanh(<var>Expr</var>)</var>. (inverse
842881 hyperbolic tangent).</dd>
843 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-log/1"><strong>log</strong>(<var>+Expr</var>)</a></dt>
882 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-log/1"><strong>log</strong>(<var>+Expr</var>)</a></dt>
844883 <dd class="defbody">
845884 Natural logarithm. <var><var>Result</var> = ln(<var>Expr</var>)</var>
846885 </dd>
847 <dt class="pubdef"><a name="f-log10/1"><strong>log10</strong>(<var>+Expr</var>)</a></dt>
886 <dt class="pubdef"><a id="f-log10/1"><strong>log10</strong>(<var>+Expr</var>)</a></dt>
848887 <dd class="defbody">
849888 Base-10 logarithm. <var><var>Result</var> = log10(<var>Expr</var>)</var>
850889 </dd>
851 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-exp/1"><strong>exp</strong>(<var>+Expr</var>)</a></dt>
890 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-exp/1"><strong>exp</strong>(<var>+Expr</var>)</a></dt>
852891 <dd class="defbody">
853892 <var><var>Result</var> = e **<var>Expr</var></var></dd>
854 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-**/2"><var>+Expr1</var> <strong>**</strong> <var>+Expr2</var></a></dt>
893 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-**/2"><var>+Expr1</var> <strong>**</strong> <var>+Expr2</var></a></dt>
855894 <dd class="defbody">
856895 <var><var>Result</var> = <var>Expr1</var>**<var>Expr2</var></var>. The
857896 result is a float, unless SWI-Prolog is compiled with unbounded integer
869908 casting the <em>input</em> result in a floating point computation, while
870909 casting the <em>output</em> performs integer exponentiation followed by
871910 a conversion to float.</dd>
872 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-^/2"><var>+Expr1</var> <strong>^</strong> <var>+Expr2</var></a></dt>
911 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-^/2"><var>+Expr1</var> <strong>^</strong> <var>+Expr2</var></a></dt>
873912 <dd class="defbody">
874913 In SWI-Prolog, <a class="function" href="arith.html#f-^/2">^/2</a> is
875914 equivalent to <a class="function" href="arith.html#f-**/2">**/2</a>. The
879918 an integer. The table below illustrates the behaviour of the
880919 exponentiation functions in ISO and SWI.
881920
882 <p><table border="2" frame="box" rules="groups" style="margin:auto">
883 <tr valign="top"><td><var>Expr1</var> </td><td><var>Expr2</var> </td><td>Function</td><td>SWI</td><td>ISO </td></tr>
884 <tbody>
885 <tr valign="top"><td>Int</td><td>Int</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Int
921 <p><table class="latex frame-box center">
922 <tr><td><var>Expr1</var> </td><td><var>Expr2</var> </td><td>Function</td><td>SWI</td><td>ISO </td></tr>
923 <tr class="hline"><td>Int</td><td>Int</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Int
886924 or Float</td><td>Float </td></tr>
887 <tr valign="top"><td>Int</td><td>Float</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Float</td><td>Float </td></tr>
888 <tr valign="top"><td>Rational</td><td>Int</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Rational</td><td>- </td></tr>
889 <tr valign="top"><td>Float</td><td>Int</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Float</td><td>Float </td></tr>
890 <tr valign="top"><td>Float</td><td>Float</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Float</td><td>Float </td></tr>
891 <tbody>
892 <tr valign="top"><td>Int</td><td>Int</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Int
925 <tr><td>Int</td><td>Float</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Float</td><td>Float </td></tr>
926 <tr><td>Rational</td><td>Int</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Rational</td><td>- </td></tr>
927 <tr><td>Float</td><td>Int</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Float</td><td>Float </td></tr>
928 <tr><td>Float</td><td>Float</td><td><a class="function" href="arith.html#f-**/2">**/2</a> </td><td>Float</td><td>Float </td></tr>
929 <tr class="hline"><td>Int</td><td>Int</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Int
893930 or Float</td><td>Int or error </td></tr>
894 <tr valign="top"><td>Int</td><td>Float</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Float</td><td>Float </td></tr>
895 <tr valign="top"><td>Rational</td><td>Int</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Rational</td><td>- </td></tr>
896 <tr valign="top"><td>Float</td><td>Int</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Float</td><td>Float </td></tr>
897 <tr valign="top"><td>Float</td><td>Float</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Float</td><td>Float </td></tr>
931 <tr><td>Int</td><td>Float</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Float</td><td>Float </td></tr>
932 <tr><td>Rational</td><td>Int</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Rational</td><td>- </td></tr>
933 <tr><td>Float</td><td>Int</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Float</td><td>Float </td></tr>
934 <tr><td>Float</td><td>Float</td><td><a class="function" href="arith.html#f-^/2">^/2</a> </td><td>Float</td><td>Float </td></tr>
898935 </table>
899936 </dd>
900 <dt class="pubdef"><a name="f-powm/3"><strong>powm</strong>(<var>+IntExprBase,
937 <dt class="pubdef"><a id="f-powm/3"><strong>powm</strong>(<var>+IntExprBase,
901938 +IntExprExp, +IntExprMod</var>)</a></dt>
902939 <dd class="defbody">
903940 <var><var>Result</var> = (<var>IntExprBase</var>**<var>IntExprExp</var>)
911948 conditions. As the conditions are expensive to pre-compute, error
912949 handling from GMP is non-trivial and negative values are not needed for
913950 Diffie-Hellman key-exchange we do not support these.</span></sup></dd>
914 <dt class="pubdef"><a name="f-lgamma/1"><strong>lgamma</strong>(<var>+Expr</var>)</a></dt>
951 <dt class="pubdef"><a id="f-lgamma/1"><strong>lgamma</strong>(<var>+Expr</var>)</a></dt>
915952 <dd class="defbody">
916953 Return the natural logarithm of the absolute value of the Gamma
917954 function.<sup class="fn">114<span class="fn-text">Some interfaces also
918955 provide the sign of the Gamma function. We canot do that in an
919956 arithmetic function. Future versions may provide a <em>predicate</em>
920957 lgamma/3 that returns both the value and the sign.</span></sup></dd>
921 <dt class="pubdef"><a name="f-erf/1"><strong>erf</strong>(<var>+Expr</var>)</a></dt>
922 <dd class="defbody">
923 https://en.wikipedia.org/wiki/Error_functionWikipedia: ``In mathematics,
924 the error function (also called the Gauss error function) is a special
925 function (non-elementary) of sigmoid shape which occurs in probability,
926 statistics and partial differential equations.''</dd>
927 <dt class="pubdef"><a name="f-erfc/1"><strong>erfc</strong>(<var>+Expr</var>)</a></dt>
928 <dd class="defbody">
929 https://en.wikipedia.org/wiki/Error_functionWikipedia: ``The
930 complementary error function.''</dd>
931 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-pi/0"><strong>pi</strong></a></dt>
958 <dt class="pubdef"><a id="f-erf/1"><strong>erf</strong>(<var>+Expr</var>)</a></dt>
959 <dd class="defbody">
960 <a class="url" href="https://en.wikipedia.org/wiki/Error_function">Wikipedia</a>:
961 ``In mathematics, the error function (also called the Gauss error
962 function) is a special function (non-elementary) of sigmoid shape which
963 occurs in probability, statistics and partial differential equations.''</dd>
964 <dt class="pubdef"><a id="f-erfc/1"><strong>erfc</strong>(<var>+Expr</var>)</a></dt>
965 <dd class="defbody">
966 <a class="url" href="https://en.wikipedia.org/wiki/Error_function">Wikipedia</a>:
967 ``The complementary error function.''</dd>
968 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-pi/0"><strong>pi</strong></a></dt>
932969 <dd class="defbody">
933970 Evaluate to the mathematical constant <var>pi</var> (3.14159 ... ).
934971 </dd>
935 <dt class="pubdef"><a name="f-e/0"><strong>e</strong></a></dt>
972 <dt class="pubdef"><a id="f-e/0"><strong>e</strong></a></dt>
936973 <dd class="defbody">
937974 Evaluate to the mathematical constant <var>e</var> (2.71828 ... ).
938975 </dd>
939 <dt class="pubdef"><a name="f-epsilon/0"><strong>epsilon</strong></a></dt>
976 <dt class="pubdef"><a id="f-epsilon/0"><strong>epsilon</strong></a></dt>
940977 <dd class="defbody">
941978 Evaluate to the difference between the float 1.0 and the first larger
942979 floating point number.
943980 </dd>
944 <dt class="pubdef"><a name="f-inf/0"><strong>inf</strong></a></dt>
945 <dd class="defbody">
946 Evaluate to positive infinity. See <a class="sec" href="syntax.html">section
981 <dt class="pubdef"><a id="f-inf/0"><strong>inf</strong></a></dt>
982 <dd class="defbody">
983 Evaluate to positive infinity. See <a class="sec" href="syntax.html#sec:2.16.1.6">section
947984 2.16.1.6</a>. This value can be negated using <a class="function" href="arith.html#f--/1">-/1</a>.
948985 </dd>
949 <dt class="pubdef"><a name="f-nan/0"><strong>nan</strong></a></dt>
950 <dd class="defbody">
951 Evaluate to <em>Not a Number</em>. See <a class="sec" href="syntax.html">section
986 <dt class="pubdef"><a id="f-nan/0"><strong>nan</strong></a></dt>
987 <dd class="defbody">
988 Evaluate to <em>Not a Number</em>. See <a class="sec" href="syntax.html#sec:2.16.1.6">section
952989 2.16.1.6</a>.
953990 </dd>
954 <dt class="pubdef"><a name="f-cputime/0"><strong>cputime</strong></a></dt>
991 <dt class="pubdef"><a id="f-cputime/0"><strong>cputime</strong></a></dt>
955992 <dd class="defbody">
956993 Evaluate to a floating point number expressing the <span style="font-variant:small-caps">CPU</span>
957 time (in seconds) used by Prolog up till now. See also <a name="idx:statistics2:1338"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>
958 and <a name="idx:time1:1339"></a><a class="pred" href="statistics.html#time/1">time/1</a>.</dd>
959 <dt class="pubdef"><a name="f-eval/1"><strong>eval</strong>(<var>+Expr</var>)</a></dt>
994 time (in seconds) used by Prolog up till now. See also <a id="idx:statistics2:1338"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>
995 and <a id="idx:time1:1339"></a><a class="pred" href="statistics.html#time/1">time/1</a>.</dd>
996 <dt class="pubdef"><a id="f-eval/1"><strong>eval</strong>(<var>+Expr</var>)</a></dt>
960997 <dd class="defbody">
961998 Evaluate <var>Expr</var>. Although ISO standard dictates that `<var>A</var>=1+2, <var>B</var>
962999 is
9801017 bit-vectors.
9811018
9821019 <dl class="latex">
983 <dt class="pubdef"><a name="f-msb/1"><strong>msb</strong>(<var>+IntExpr</var>)</a></dt>
1020 <dt class="pubdef"><a id="f-msb/1"><strong>msb</strong>(<var>+IntExpr</var>)</a></dt>
9841021 <dd class="defbody">
9851022 Return the largest integer <var>N</var> such that <code>(IntExpr &gt;&gt; N) /\ 1 =:= 1</code>.
9861023 This is the (zero-origin) index of the most significant 1 bit in the
9871024 value of <var>IntExpr</var>, which must evaluate to a positive integer.
9881025 Errors for 0, negative integers, and non-integers.</dd>
989 <dt class="pubdef"><a name="f-lsb/1"><strong>lsb</strong>(<var>+IntExpr</var>)</a></dt>
1026 <dt class="pubdef"><a id="f-lsb/1"><strong>lsb</strong>(<var>+IntExpr</var>)</a></dt>
9901027 <dd class="defbody">
9911028 Return the smallest integer <var>N</var> such that <code>(IntExpr &gt;&gt; N) /\ 1 =:= 1</code>.
9921029 This is the (zero-origin) index of the least significant 1 bit in the
9931030 value of <var>IntExpr</var>, which must evaluate to a positive integer.
9941031 Errors for 0, negative integers, and non-integers.</dd>
995 <dt class="pubdef"><a name="f-popcount/1"><strong>popcount</strong>(<var>+IntExpr</var>)</a></dt>
1032 <dt class="pubdef"><a id="f-popcount/1"><strong>popcount</strong>(<var>+IntExpr</var>)</a></dt>
9961033 <dd class="defbody">
9971034 Return the number of 1s in the binary representation of the non-negative
9981035 integer <var>IntExpr</var>.</dd>
999 <dt class="pubdef"><a name="f-getbit/2"><strong>getbit</strong>(<var>+IntExprV,
1036 <dt class="pubdef"><a id="f-getbit/2"><strong>getbit</strong>(<var>+IntExprV,
10001037 +IntExprI</var>)</a></dt>
10011038 <dd class="defbody">
10021039 Evaluates to the bit value (0 or 1) of the <var>IntExprI</var>-th bit of
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="apply.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="broadcast.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:assoc"><a name="sec:A.3"><span class="sec-nr">A.3</span> <span class="sec-title">library(assoc):
235 <h2 id="sec:assoc"><a id="sec:A.3"><span class="sec-nr">A.3</span> <span class="sec-title">library(assoc):
195236 Association lists</span></a></h2>
196237
197 <a name="sec:assoc"></a>
198 <a name="sec:lib:assoc"></a>
199
200 <p>Authors: <em>Richard A. O'Keefe, L.Damas, V.S.Costa and https://www.metalevel.atMarkus
201 Triska</em>
202
203 <p><h3 id="sec:assoc-introduction"><a name="sec:A.3.1"><span class="sec-nr">A.3.1</span> <span class="sec-title">Introduction</span></a></h3>
204
205 <p><a name="sec:assoc-introduction"></a>
238 <a id="sec:assoc"></a>
239 <a id="sec:lib:assoc"></a>
240
241 <p>Authors: <em>Richard A. O'Keefe, L.Damas, V.S.Costa and <a class="url" href="https://www.metalevel.at">Markus
242 Triska</a></em>
243
244 <p><h3 id="sec:assoc-introduction"><a id="sec:A.3.1"><span class="sec-nr">A.3.1</span> <span class="sec-title">Introduction</span></a></h3>
245
246 <p><a id="sec:assoc-introduction"></a>
206247
207248 <p>An <i>association list</i> as implemented by this library is a
208249 collection of unique <i>keys</i> that are associated to <i>values</i>.
239280 arrays efficiently.
240281 </ul>
241282
242 <p><h3 id="sec:assoc-creation"><a name="sec:A.3.2"><span class="sec-nr">A.3.2</span> <span class="sec-title">Creating
283 <p><h3 id="sec:assoc-creation"><a id="sec:A.3.2"><span class="sec-nr">A.3.2</span> <span class="sec-title">Creating
243284 association lists</span></a></h3>
244285
245 <p><a name="sec:assoc-creation"></a>
286 <p><a id="sec:assoc-creation"></a>
246287
247288 <p>An assocation list is <i>created</i> with one of the following
248289 predicates:
249290
250291 <dl class="latex">
251 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="empty_assoc/1"><strong>empty_assoc</strong>(<var>?Assoc</var>)</a></dt>
292 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="empty_assoc/1"><strong>empty_assoc</strong>(<var>?Assoc</var>)</a></dt>
252293 <dd class="defbody">
253294 Is true if <var>Assoc</var> is the empty association list.</dd>
254 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_to_assoc/2"><strong>list_to_assoc</strong>(<var>+Pairs,
295 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_to_assoc/2"><strong>list_to_assoc</strong>(<var>+Pairs,
255296 -Assoc</var>)</a></dt>
256297 <dd class="defbody">
257298 Create an association from a list <var>Pairs</var> of Key-Value pairs.
266307 </dl>
267308
268309 </dd>
269 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_list_to_assoc/2"><strong>ord_list_to_assoc</strong>(<var>+Pairs,
310 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_list_to_assoc/2"><strong>ord_list_to_assoc</strong>(<var>+Pairs,
270311 -Assoc</var>)</a></dt>
271312 <dd class="defbody">
272313 <var>Assoc</var> is created from an ordered list <var>Pairs</var> of
284325 </dd>
285326 </dl>
286327
287 <p><h3 id="sec:assoc-querying"><a name="sec:A.3.3"><span class="sec-nr">A.3.3</span> <span class="sec-title">Querying
328 <p><h3 id="sec:assoc-querying"><a id="sec:A.3.3"><span class="sec-nr">A.3.3</span> <span class="sec-title">Querying
288329 association lists</span></a></h3>
289330
290 <p><a name="sec:assoc-querying"></a>
331 <p><a id="sec:assoc-querying"></a>
291332
292333 <p>An association list can be <i>queried</i> with:
293334
294335 <dl class="latex">
295 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="get_assoc/3"><strong>get_assoc</strong>(<var>+Key,
336 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="get_assoc/3"><strong>get_assoc</strong>(<var>+Key,
296337 +Assoc, -Value</var>)</a></dt>
297338 <dd class="defbody">
298339 True if <var>Key</var>-<var>Value</var> is an association in <var>Assoc</var>.
306347 </dl>
307348
308349 </dd>
309 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="get_assoc/5"><strong>get_assoc</strong>(<var>+Key,
350 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="get_assoc/5"><strong>get_assoc</strong>(<var>+Key,
310351 +Assoc0, ?Val0, ?Assoc, ?Val</var>)</a></dt>
311352 <dd class="defbody">
312353 True if <var>Key</var>-<var>Val0</var> is in <var>Assoc0</var> and <var>Key</var>-<var>Val</var>
313354 is in <var>Assoc</var>.</dd>
314 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="max_assoc/3"><strong>max_assoc</strong>(<var>+Assoc,
355 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="max_assoc/3"><strong>max_assoc</strong>(<var>+Assoc,
315356 -Key, -Value</var>)</a></dt>
316357 <dd class="defbody">
317358 True if <var>Key</var>-<var>Value</var> is in <var>Assoc</var> and <var>Key</var>
318359 is the largest key.</dd>
319 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="min_assoc/3"><strong>min_assoc</strong>(<var>+Assoc,
360 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="min_assoc/3"><strong>min_assoc</strong>(<var>+Assoc,
320361 -Key, -Value</var>)</a></dt>
321362 <dd class="defbody">
322363 True if <var>Key</var>-<var>Value</var> is in assoc and <var>Key</var>
323364 is the smallest key.</dd>
324 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="gen_assoc/3"><strong>gen_assoc</strong>(<var>?Key,
365 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="gen_assoc/3"><strong>gen_assoc</strong>(<var>?Key,
325366 +Assoc, ?Value</var>)</a></dt>
326367 <dd class="defbody">
327368 True if <var>Key</var>-<var>Value</var> is an association in <var>Assoc</var>.
337378 </dd>
338379 </dl>
339380
340 <p><h3 id="sec:assoc-modifications"><a name="sec:A.3.4"><span class="sec-nr">A.3.4</span> <span class="sec-title">Modifying
381 <p><h3 id="sec:assoc-modifications"><a id="sec:A.3.4"><span class="sec-nr">A.3.4</span> <span class="sec-title">Modifying
341382 association lists</span></a></h3>
342383
343 <p><a name="sec:assoc-modifications"></a>
384 <p><a id="sec:assoc-modifications"></a>
344385
345386 <p>Elements of an association list can be changed and inserted with:
346387
347388 <dl class="latex">
348 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="put_assoc/4"><strong>put_assoc</strong>(<var>+Key,
389 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="put_assoc/4"><strong>put_assoc</strong>(<var>+Key,
349390 +Assoc0, +Value, -Assoc</var>)</a></dt>
350391 <dd class="defbody">
351392 <var>Assoc</var> is <var>Assoc0</var>, except that <var>Key</var> is
352393 associated with
353394 <var>Value</var>. This can be used to insert and change associations.</dd>
354 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="del_assoc/4"><strong>del_assoc</strong>(<var>+Key,
395 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="del_assoc/4"><strong>del_assoc</strong>(<var>+Key,
355396 +Assoc0, ?Value, -Assoc</var>)</a></dt>
356397 <dd class="defbody">
357398 True if <var>Key</var>-<var>Value</var> is in <var>Assoc0</var>. <var>Assoc</var>
358399 is <var>Assoc0</var> with
359400 <var>Key</var>-<var>Value</var> removed.</dd>
360 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="del_min_assoc/4"><strong>del_min_assoc</strong>(<var>+Assoc0,
401 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="del_min_assoc/4"><strong>del_min_assoc</strong>(<var>+Assoc0,
361402 ?Key, ?Val, -Assoc</var>)</a></dt>
362403 <dd class="defbody">
363404 True if <var>Key</var>-Value is in <var>Assoc0</var> and <var>Key</var>
365406 <var>Assoc</var> is <var>Assoc0</var> with <var>Key</var>-Value removed.
366407 Warning: This will succeed with <i>no</i> bindings for <var>Key</var> or <var>Val</var>
367408 if <var>Assoc0</var> is empty.</dd>
368 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="del_max_assoc/4"><strong>del_max_assoc</strong>(<var>+Assoc0,
409 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="del_max_assoc/4"><strong>del_max_assoc</strong>(<var>+Assoc0,
369410 ?Key, ?Val, -Assoc</var>)</a></dt>
370411 <dd class="defbody">
371412 True if <var>Key</var>-Value is in <var>Assoc0</var> and <var>Key</var>
376417 </dd>
377418 </dl>
378419
379 <p><h3 id="sec:assoc-conversion"><a name="sec:A.3.5"><span class="sec-nr">A.3.5</span> <span class="sec-title">Conversion
420 <p><h3 id="sec:assoc-conversion"><a id="sec:A.3.5"><span class="sec-nr">A.3.5</span> <span class="sec-title">Conversion
380421 predicates</span></a></h3>
381422
382 <p><a name="sec:assoc-conversion"></a>
423 <p><a id="sec:assoc-conversion"></a>
383424
384425 <p>Conversion of (parts of) an association list to <i>lists</i> is
385426 possible with:
386427
387428 <dl class="latex">
388 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assoc_to_list/2"><strong>assoc_to_list</strong>(<var>+Assoc,
429 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assoc_to_list/2"><strong>assoc_to_list</strong>(<var>+Assoc,
389430 -Pairs</var>)</a></dt>
390431 <dd class="defbody">
391432 Translate <var>Assoc</var> to a list <var>Pairs</var> of Key-Value
392433 pairs. The keys in <var>Pairs</var> are sorted in ascending order.</dd>
393 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assoc_to_keys/2"><strong>assoc_to_keys</strong>(<var>+Assoc,
434 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assoc_to_keys/2"><strong>assoc_to_keys</strong>(<var>+Assoc,
394435 -Keys</var>)</a></dt>
395436 <dd class="defbody">
396437 True if <var>Keys</var> is the list of keys in <var>Assoc</var>. The
397438 keys are sorted in ascending order.</dd>
398 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assoc_to_values/2"><strong>assoc_to_values</strong>(<var>+Assoc,
439 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assoc_to_values/2"><strong>assoc_to_values</strong>(<var>+Assoc,
399440 -Values</var>)</a></dt>
400441 <dd class="defbody">
401442 True if <var>Values</var> is the list of values in <var>Assoc</var>. <var>Values</var>
404445 </dd>
405446 </dl>
406447
407 <p><h3 id="sec:assoc-reasoning"><a name="sec:A.3.6"><span class="sec-nr">A.3.6</span> <span class="sec-title">Reasoning
448 <p><h3 id="sec:assoc-reasoning"><a id="sec:A.3.6"><span class="sec-nr">A.3.6</span> <span class="sec-title">Reasoning
408449 about association lists and their elements</span></a></h3>
409450
410 <p><a name="sec:assoc-reasoning"></a>
451 <p><a id="sec:assoc-reasoning"></a>
411452
412453 <p>Further inspection predicates of an association list and its elements
413454 are:
414455
415456 <dl class="latex">
416 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_assoc/1"><strong>is_assoc</strong>(<var>+Assoc</var>)</a></dt>
457 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_assoc/1"><strong>is_assoc</strong>(<var>+Assoc</var>)</a></dt>
417458 <dd class="defbody">
418459 True if <var>Assoc</var> is an association list. This predicate checks
419460 that the structure is valid, elements are in order, and tree is balanced
420461 to the extent guaranteed by AVL trees. I.e., branches of each subtree
421462 differ in depth by at most 1.</dd>
422 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="map_assoc/2"><strong>map_assoc</strong>(<var>:Pred,
463 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="map_assoc/2"><strong>map_assoc</strong>(<var>:Pred,
423464 +Assoc</var>)</a></dt>
424465 <dd class="defbody">
425466 True if <var>Pred</var>(Value) is true for all values in <var>Assoc</var>.</dd>
426 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="map_assoc/3"><strong>map_assoc</strong>(<var>:Pred,
467 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="map_assoc/3"><strong>map_assoc</strong>(<var>:Pred,
427468 +Assoc0, ?Assoc</var>)</a></dt>
428469 <dd class="defbody">
429470 Map corresponding values. True if <var>Assoc</var> is <var>Assoc0</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 7.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 7.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="clp.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="coroutining.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:attvar"><a name="sec:7.1"><span class="sec-nr">7.1</span> <span class="sec-title">Attributed
235 <h2 id="sec:attvar"><a id="sec:7.1"><span class="sec-nr">7.1</span> <span class="sec-title">Attributed
195236 variables</span></a></h2>
196237
197 <a name="sec:attvar"></a>
238 <a id="sec:attvar"></a>
198239
199240 <p><em>Attributed variables</em> provide a technique for extending the
200241 Prolog unification algorithm <cite><a class="cite" href="Bibliography.html#holzbaur:1992">Holzbaur,
203244 interface to attributed variables. The SWI-Prolog interface is identical
204245 to the one realised by Bart Demoen for hProlog <cite><a class="cite" href="Bibliography.html#Demoen:CW350">Demoen,
205246 2002</a></cite>. This interface is simple and available on all Prolog
206 systems that can run the Leuven CHR system (see <a class="sec" href="chr.html">chapter
207 8</a> and the Leuven https://dtai.cs.kuleuven.be/CHR/CHR page ).
247 systems that can run the Leuven CHR system (see <a class="sec" href="chr.html#sec:8">chapter
248 8</a> and the Leuven <a class="url" href="https://dtai.cs.kuleuven.be/CHR/">CHR
249 page</a>).
208250
209251 <p>Binding an attributed variable schedules a goal to be executed at the
210252 first possible opportunity. In the current implementation the hooks are
211253 executed immediately after a successful unification of the clause-head
212254 or successful completion of a foreign language (built-in) predicate.
213 Each attribute is associated to a module, and the hook (<a name="idx:attrunifyhook2:1771"></a><a class="pred" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a>)
255 Each attribute is associated to a module, and the hook (<a id="idx:attrunifyhook2:1775"></a><a class="pred" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a>)
214256 is executed in this module. The example below realises a very simple and
215257 incomplete finite domain reasoner:
216258
254296
255297 <p>Before explaining the code we give some example queries:
256298 <blockquote>
257 <table border="0" frame="void" rules="groups">
258 <tr valign="top"><td><code>?- domain(X, [a,b]), X = c</code></td><td>fail </td></tr>
259 <tr valign="top"><td><code>?- domain(X, [a,b]), domain(X, [a,c]).</code></td><td>X
260 = a </td></tr>
261 <tr valign="top"><td><code>?- domain(X, [a,b,c]), domain(X, [a,c]).</code></td><td>domain(X,
299 <table class="latex frame-void">
300 <tr><td><code>?- domain(X, [a,b]), X = c</code></td><td>fail </td></tr>
301 <tr><td><code>?- domain(X, [a,b]), domain(X, [a,c]).</code></td><td>X =
302 a </td></tr>
303 <tr><td><code>?- domain(X, [a,b,c]), domain(X, [a,c]).</code></td><td>domain(X,
262304 [a, c]) </td></tr>
263305 </table>
264306 </blockquote>
265307
266308 <p>The predicate domain/2 fetches (first clause) or assigns (second
267309 clause) the variable a <em>domain</em>, a set of values the variable can
268 be unified with. In the second clause, <a name="idx:domain2:1772"></a><span class="pred-ext">domain/2</span>
310 be unified with. In the second clause, <a id="idx:domain2:1776"></a><span class="pred-ext">domain/2</span>
269311 first associates the domain with a fresh variable (Y) and then unifies X
270312 to this variable to deal with the possibility that X already has a
271 domain. The predicate <a name="idx:attrunifyhook2:1773"></a><a class="pred" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a>
313 domain. The predicate <a id="idx:attrunifyhook2:1777"></a><a class="pred" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a>
272314 (see below) is a hook called after a variable with a domain is assigned
273315 a value. In the simple case where the variable is bound to a concrete
274316 value, we simply check whether this value is in the domain. Otherwise we
276318 is empty (first example), assign the value if there is only one value in
277319 the intersection (second example), or assign the intersection as the new
278320 domain of the variable (third example). The nonterminal
279 <a name="idx:attributegoals1:1774"></a><span class="pred-ext">attribute_goals/3</span>
321 <a id="idx:attributegoals1:1778"></a><a class="pred" href="attvar.html#attribute_goals//1">attribute_goals//1</a>
280322 is used to translate remaining attributes to user-readable goals that,
281323 when called, reinstate these attributes or attributes that correspond to
282324 equivalent constraints.
283325
284 <p>Implementing constraint solvers (<a class="sec" href="clp.html">chapter
326 <p>Implementing constraint solvers (<a class="sec" href="clp.html#sec:7">chapter
285327 7</a>) is the most common, but not the only use case for attributed
286328 variables: If you implement algorithms that require efficient
287329 destructive modifications, then using attributed variables is often a
288 more convenient and somewhat more declarative alternative for <a name="idx:setarg3:1775"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
330 more convenient and somewhat more declarative alternative for <a id="idx:setarg3:1779"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
289331 and related predicates whose sharing semantics are harder to understand.
290332 In particular, attributed variables make it easy to express graph
291333 networks and graph-oriented algorithms, since each variable can store
293335 of attributed variables should be confined within a module that exposes
294336 its functionality via more declarative interface predicates.
295337
296 <p><h3 id="sec:attvar-predicates"><a name="sec:7.1.1"><span class="sec-nr">7.1.1</span> <span class="sec-title">Attribute
338 <p><h3 id="sec:attvar-predicates"><a id="sec:7.1.1"><span class="sec-nr">7.1.1</span> <span class="sec-title">Attribute
297339 manipulation predicates</span></a></h3>
298340
299 <a name="sec:attvar-predicates"></a>
341 <a id="sec:attvar-predicates"></a>
300342
301343 <dl class="latex">
302 <dt class="pubdef"><a name="attvar/1"><strong>attvar</strong>(<var>@Term</var>)</a></dt>
303 <dd class="defbody">
304 Succeeds if <var>Term</var> is an attributed variable. Note that <a name="idx:var1:1776"></a><a class="pred" href="typetest.html#var/1">var/1</a>
344 <dt class="pubdef"><a id="attvar/1"><strong>attvar</strong>(<var>@Term</var>)</a></dt>
345 <dd class="defbody">
346 Succeeds if <var>Term</var> is an attributed variable. Note that <a id="idx:var1:1780"></a><a class="pred" href="typetest.html#var/1">var/1</a>
305347 also succeeds on attributed variables. Attributed variables are created
306348 with
307 <a name="idx:putattr3:1777"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>.</dd>
308 <dt class="pubdef"><a name="put_attr/3"><strong>put_attr</strong>(<var>+Var,
349 <a id="idx:putattr3:1781"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>.</dd>
350 <dt class="pubdef"><a id="put_attr/3"><strong>put_attr</strong>(<var>+Var,
309351 +Module, +Value</var>)</a></dt>
310352 <dd class="defbody">
311353 If <var>Var</var> is a variable or attributed variable, set the value
312354 for the attribute named <var>Module</var> to <var>Value</var>. If an
313355 attribute with this name is already associated with <var>Var</var>, the
314356 old value is replaced. Backtracking will restore the old value (i.e., an
315 attribute is a mutable term; see also <a name="idx:setarg3:1778"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>).
357 attribute is a mutable term; see also <a id="idx:setarg3:1782"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>).
316358 This predicate raises an uninstantiation error if
317359 <var>Var</var> is not a variable, and a type error if <var>Module</var>
318360 is not an atom.</dd>
319 <dt class="pubdef"><a name="get_attr/3"><strong>get_attr</strong>(<var>+Var,
361 <dt class="pubdef"><a id="get_attr/3"><strong>get_attr</strong>(<var>+Var,
320362 +Module, -Value</var>)</a></dt>
321363 <dd class="defbody">
322364 Request the current <var>value</var> for the attribute named <var>Module</var>.
324366 <var>Var</var> is not an attributed variable or the named attribute is
325367 not associated to <var>Var</var> this predicate fails silently. If <var>Module</var>
326368 is not an atom, a type error is raised.</dd>
327 <dt class="pubdef"><a name="del_attr/2"><strong>del_attr</strong>(<var>+Var,
369 <dt class="pubdef"><a id="del_attr/2"><strong>del_attr</strong>(<var>+Var,
328370 +Module</var>)</a></dt>
329371 <dd class="defbody">
330372 Delete the named attribute. If <var>Var</var> loses its last attribute
335377 </dd>
336378 </dl>
337379
338 <p><h3 id="sec:attvar-hooks"><a name="sec:7.1.2"><span class="sec-nr">7.1.2</span> <span class="sec-title">Attributed
380 <p><h3 id="sec:attvar-hooks"><a id="sec:7.1.2"><span class="sec-nr">7.1.2</span> <span class="sec-title">Attributed
339381 variable hooks</span></a></h3>
340382
341 <a name="sec:attvar-hooks"></a>
383 <a id="sec:attvar-hooks"></a>
342384
343385 <p>Attribute names are linked to modules. This means that certain
344386 operations on attributed variables cause <em>hooks</em> to be called in
345387 the module whose name matches the attribute name.
346388
347389 <dl class="latex">
348 <dt class="pubdef"><a name="attr_unify_hook/2"><strong>attr_unify_hook</strong>(<var>+AttValue,
390 <dt class="pubdef"><a id="attr_unify_hook/2"><strong>attr_unify_hook</strong>(<var>+AttValue,
349391 +VarValue</var>)</a></dt>
350392 <dd class="defbody">
351393 A hook that must be defined in the module to which an attributed
357399 is another attributed variable the hook often combines the two
358400 attributes and associates the combined attribute with <var>VarValue</var>
359401 using
360 <a name="idx:putattr3:1779"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>.
402 <a id="idx:putattr3:1783"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>.
361403
362404 <dl class="tags">
363405 <dt class="tag">To be done</dt>
373415 </dl>
374416
375417 </dd>
376 <dt class="pubdef"><a name="attribute_goals/1"><strong>attribute_goals</strong>(<var>+Var</var>)</a><code>//</code></dt>
418 <dt class="pubdef"><a id="attribute_goals//1"><strong>attribute_goals</strong>(<var>+Var</var>)</a><code>//</code></dt>
377419 <dd class="defbody">
378420 This nonterminal is the main mechanism in which residual constraints are
379421 obtained. It is called in every module where it is defined, and
380422 <var>Var</var> has an attribute. Its argument is that variable. In each
381 module, <a name="idx:attributegoals1:1780"></a><span class="pred-ext">attribute_goals/3</span>
423 module, <a id="idx:attributegoals1:1784"></a><a class="pred" href="attvar.html#attribute_goals//1">attribute_goals//1</a>
382424 must describe a list of Prolog goals that are declaratively equivalent
383425 to the goals that caused the attributes of that module to be present and
384426 in their current state. It is always possible to do this (since these
404446 constraint solvers by contrasting obtained residual goals with expected
405447 answers.
406448
407 <p>This nonterminal is used by <a name="idx:copyterm3:1781"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>,
449 <p>This nonterminal is used by <a id="idx:copyterm3:1785"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>,
408450 on which the Prolog top level relies to ensure the basic invariant of
409451 pure Prolog programs: The answer is <i>declaratively equivalent</i> to
410452 the query.
413455 <i>list</i> is used to represent residual goals. This simplifies
414456 processing and reasoning about residual goals throughout all programs
415457 that need this functionality.</dd>
416 <dt class="pubdef"><a name="project_attributes/2"><strong>project_attributes</strong>(<var>+QueryVars,
458 <dt class="pubdef"><a id="project_attributes/2"><strong>project_attributes</strong>(<var>+QueryVars,
417459 +ResidualVars</var>)</a></dt>
418460 <dd class="defbody">
419461 A hook that can be defined in each module to project constraints on
420462 newly introduced variables back to the query variables.
421463 <var>QueryVars</var> is the list of variables occurring in the query and
422464 <var>ResidualVars</var> is a list of variables that have attributes
423 attached. There may be variables that occur in both lists. If possible, <a name="idx:projectattributes2:1782"></a><a class="pred" href="attvar.html#project_attributes/2">project_attributes/2</a>
465 attached. There may be variables that occur in both lists. If possible, <a id="idx:projectattributes2:1786"></a><a class="pred" href="attvar.html#project_attributes/2">project_attributes/2</a>
424466 should change the attributes so that all constraints are expressed as
425467 residual goals that refer only to
426468 <var>QueryVars</var>, while other variables are existentially
427469 quantified.</dd>
428 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="attr_portray_hook/2"><strong>attr_portray_hook</strong>(<var>+AttValue,
470 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="attr_portray_hook/2"><strong>attr_portray_hook</strong>(<var>+AttValue,
429471 +Var</var>)</a></dt>
430472 <dd class="defbody">
431 Called by <a name="idx:writeterm2:1783"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
473 Called by <a id="idx:writeterm2:1787"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
432474 and friends for each attribute if the option
433475 <code>attributes(portray)</code> is in effect. If the hook succeeds the
434476 attribute is considered printed. Otherwise <code>Module = ...</code> is
435477 printed to indicate the existence of a variable. This predicate is
436478 deprecated because it cannot work with pure interface predicates like
437 <a name="idx:copyterm3:1784"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>.
438 Use <a name="idx:attributegoals1:1785"></a><span class="pred-ext">attribute_goals/3</span>
479 <a id="idx:copyterm3:1788"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>.
480 Use <a id="idx:attributegoals1:1789"></a><a class="pred" href="attvar.html#attribute_goals//1">attribute_goals//1</a>
439481 instead to map attributes to residual goals.
440482 </dd>
441483 </dl>
442484
443 <p><h3 id="sec:terms-with-attvars"><a name="sec:7.1.3"><span class="sec-nr">7.1.3</span> <span class="sec-title">Operations
485 <p><h3 id="sec:terms-with-attvars"><a id="sec:7.1.3"><span class="sec-nr">7.1.3</span> <span class="sec-title">Operations
444486 on terms with attributed variables</span></a></h3>
445487
446 <a name="sec:terms-with-attvars"></a>
488 <a id="sec:terms-with-attvars"></a>
447489
448490 <dl class="latex">
449 <dt class="pubdef"><a name="copy_term/3"><strong>copy_term</strong>(<var>+Term,
491 <dt class="pubdef"><a id="copy_term/3"><strong>copy_term</strong>(<var>+Term,
450492 -Copy, -Gs</var>)</a></dt>
451493 <dd class="defbody">
452494 Create a regular term <var>Copy</var> as a copy of <var>Term</var>
453495 (without any attributes), and a list <var>Gs</var> of goals that
454496 represents the attributes. The goal <code>maplist(call, Gs)</code>
455 recreates the attributes for <var>Copy</var>. The nonterminal <a name="idx:attributegoals1:1786"></a><span class="pred-ext">attribute_goals/3</span>,
497 recreates the attributes for <var>Copy</var>. The nonterminal <a id="idx:attributegoals1:1790"></a><a class="pred" href="attvar.html#attribute_goals//1">attribute_goals//1</a>,
456498 as defined in the modules the attributes stem from, is used to convert
457499 attributes to lists of goals.
458500
463505
464506 <p>The form <code>copy_term(Term, Term, Gs)</code> can be used to reason
465507 about the constraints in which <code>Term</code> is involved.</dd>
466 <dt class="pubdef"><a name="copy_term_nat/2"><strong>copy_term_nat</strong>(<var>+Term,
508 <dt class="pubdef"><a id="copy_term_nat/2"><strong>copy_term_nat</strong>(<var>+Term,
467509 -Copy</var>)</a></dt>
468510 <dd class="defbody">
469 As <a name="idx:copyterm2:1787"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>.
511 As <a id="idx:copyterm2:1791"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>.
470512 Attributes, however, are <em>not</em> copied but replaced by fresh
471513 variables.</dd>
472 <dt class="pubdef"><a name="term_attvars/2"><strong>term_attvars</strong>(<var>+Term,
514 <dt class="pubdef"><a id="term_attvars/2"><strong>term_attvars</strong>(<var>+Term,
473515 -AttVars</var>)</a></dt>
474516 <dd class="defbody">
475517 <var>AttVars</var> is a list of all attributed variables in <var>Term</var>
476 and its attributes. That is, <a name="idx:termattvars2:1788"></a><a class="pred" href="attvar.html#term_attvars/2">term_attvars/2</a>
518 and its attributes. That is, <a id="idx:termattvars2:1792"></a><a class="pred" href="attvar.html#term_attvars/2">term_attvars/2</a>
477519 works recursively through attributes. This predicate is cycle-safe. The
478520 goal
479521 <code>term_attvars(Term,[])</code> in an efficient test that <var>Term</var>
483525 </dd>
484526 </dl>
485527
486 <p><h3 id="sec:attvar-low-level-preds"><a name="sec:7.1.4"><span class="sec-nr">7.1.4</span> <span class="sec-title">Special
528 <p><h3 id="sec:attvar-low-level-preds"><a id="sec:7.1.4"><span class="sec-nr">7.1.4</span> <span class="sec-title">Special
487529 purpose predicates for attributes</span></a></h3>
488530
489 <a name="sec:attvar-low-level-preds"></a>
490
491 <p>Normal user code should deal with <a name="idx:putattr3:1789"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>, <a name="idx:getattr3:1790"></a><a class="pred" href="attvar.html#get_attr/3">get_attr/3</a>
492 and <a name="idx:delattr2:1791"></a><a class="pred" href="attvar.html#del_attr/2">del_attr/2</a>.
531 <a id="sec:attvar-low-level-preds"></a>
532
533 <p>Normal user code should deal with <a id="idx:putattr3:1793"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>, <a id="idx:getattr3:1794"></a><a class="pred" href="attvar.html#get_attr/3">get_attr/3</a>
534 and <a id="idx:delattr2:1795"></a><a class="pred" href="attvar.html#del_attr/2">del_attr/2</a>.
493535 The routines in this section fetch or set the entire attribute list of a
494536 variable. Use of these predicates is anticipated to be restricted to
495537 printing and other special purpose operations.
496538
497539 <dl class="latex">
498 <dt class="pubdef"><a name="get_attrs/2"><strong>get_attrs</strong>(<var>+Var,
540 <dt class="pubdef"><a id="get_attrs/2"><strong>get_attrs</strong>(<var>+Var,
499541 -Attributes</var>)</a></dt>
500542 <dd class="defbody">
501543 Get all attributes of <var>Var</var>. <var>Attributes</var> is a term of
503545 <code>att(Module, Value, MoreAttributes)</code>, where <var>MoreAttributes</var>
504546 is
505547 <code>[]</code> for the last attribute.</dd>
506 <dt class="pubdef"><a name="put_attrs/2"><strong>put_attrs</strong>(<var>+Var,
548 <dt class="pubdef"><a id="put_attrs/2"><strong>put_attrs</strong>(<var>+Var,
507549 -Attributes</var>)</a></dt>
508550 <dd class="defbody">
509 Set all attributes of <var>Var</var>. See <a name="idx:getattrs2:1792"></a><a class="pred" href="attvar.html#get_attrs/2">get_attrs/2</a>
551 Set all attributes of <var>Var</var>. See <a id="idx:getattrs2:1796"></a><a class="pred" href="attvar.html#get_attrs/2">get_attrs/2</a>
510552 for a description of
511553 <var>Attributes</var>.</dd>
512 <dt class="pubdef"><a name="del_attrs/1"><strong>del_attrs</strong>(<var>+Var</var>)</a></dt>
554 <dt class="pubdef"><a id="del_attrs/1"><strong>del_attrs</strong>(<var>+Var</var>)</a></dt>
513555 <dd class="defbody">
514556 If <var>Var</var> is an attributed variable, delete <em>all</em> its
515557 attributes. In all other cases, this predicate succeeds without
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.13</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="hooks.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="packs.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:autoload"><a name="sec:2.13"><span class="sec-nr">2.13</span> <span class="sec-title">Automatic
235 <h2 id="sec:autoload"><a id="sec:2.13"><span class="sec-nr">2.13</span> <span class="sec-title">Automatic
195236 loading of libraries</span></a></h2>
196237
197 <a name="sec:autoload"></a>
238 <a id="sec:autoload"></a>
198239
199240 <p>If ---at runtime--- an undefined predicate is trapped, the system
200241 will first try to import the predicate from the module's default module
201242 (see
202 <a class="sec" href="importmodule.html">section 6.9</a>. If this fails
203 the <em>auto loader</em> is activated.<sup class="fn">23<span class="fn-text">Actually,
243 <a class="sec" href="importmodule.html#sec:6.9">section 6.9</a>. If this
244 fails the <em>auto loader</em> is activated.<sup class="fn">23<span class="fn-text">Actually,
204245 the hook user:exception/3 is called; only if this hook fails does it
205246 call the autoloader.</span></sup> On first activation an index to all
206 library files in all library directories is loaded in core (see <a name="idx:librarydirectory1:189"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>, <a name="idx:filesearchpath2:190"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
247 library files in all library directories is loaded in core (see <a id="idx:librarydirectory1:189"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>, <a id="idx:filesearchpath2:190"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
207248 and
208 <a name="idx:reloadlibraryindex0:191"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>).
249 <a id="idx:reloadlibraryindex0:191"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>).
209250 If the undefined predicate can be located in one of the libraries, that
210251 library file is automatically loaded and the call to the (previously
211252 undefined) predicate is restarted. By default this mechanism loads the
212 file silently. The <a name="idx:currentprologflag2:192"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
253 file silently. The <a id="idx:currentprologflag2:192"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
213254 key <a class="flag" href="flags.html#flag:verbose_autoload">verbose_autoload</a>
214255 is provided to get verbose loading. The Prolog flag <a class="flag" href="flags.html#flag:autoload">autoload</a>
215256 can be used to enable/disable the autoload system.
216257
217258 <p>Autoloading only handles (library) source files that use the module
218 mechanism described in <a class="sec" href="modules.html">chapter 6</a>.
219 The files are loaded with <a name="idx:usemodule2:193"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
259 mechanism described in <a class="sec" href="modules.html#sec:6">chapter
260 6</a>. The files are loaded with <a id="idx:usemodule2:193"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
220261 and only the trapped undefined predicate is imported into the module
221262 where the undefined predicate was called. Each library directory must
222263 hold a file <code>INDEX.pl</code> that contains an index to all library
227268 index(Name, Arity, Module, File).
228269 </pre>
229270
230 <p>The predicate <a name="idx:make0:194"></a><a class="pred" href="consulting.html#make/0">make/0</a>
231 updates the autoload index. It searches for all library directories (see <a name="idx:librarydirectory1:195"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>
232 and <a name="idx:filesearchpath2:196"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>)
271 <p>The predicate <a id="idx:make0:194"></a><a class="pred" href="consulting.html#make/0">make/0</a>
272 updates the autoload index. It searches for all library directories (see <a id="idx:librarydirectory1:195"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>
273 and <a id="idx:filesearchpath2:196"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>)
233274 holding the file <code>MKINDEX.pl</code> or <code>INDEX.pl</code>. If
234275 the current user can write or create the file <code>INDEX.pl</code> and
235276 it does not exist or is older than the directory or one of its files,
236277 the index for this directory is updated. If the file <code>MKINDEX.pl</code>
237278 exists, updating is achieved by loading this file, normally containing a
238279 directive calling
239 <a name="idx:makelibraryindex2:197"></a><a class="pred" href="autoload.html#make_library_index/2">make_library_index/2</a>.
240 Otherwise <a name="idx:makelibraryindex1:198"></a><a class="pred" href="autoload.html#make_library_index/1">make_library_index/1</a>
280 <a id="idx:makelibraryindex2:197"></a><a class="pred" href="autoload.html#make_library_index/2">make_library_index/2</a>.
281 Otherwise <a id="idx:makelibraryindex1:198"></a><a class="pred" href="autoload.html#make_library_index/1">make_library_index/1</a>
241282 is called, creating an index for all <code>*.pl</code> files containing
242283 a module.
243284
257298 <li>If there is a library file that defines the module in which the
258299 undefined predicate is trapped, this file is used.
259300 <li>Otherwise library files are considered in the order they appear in
260 the <a name="idx:librarydirectory1:199"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>
301 the <a id="idx:librarydirectory1:199"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>
261302 predicate and within the directory alphabetically.
262303 </ol>
263304
264305 <dl class="latex">
265 <dt class="pubdef"><a name="autoload_path/1"><strong>autoload_path</strong>(<var>+DirAlias</var>)</a></dt>
306 <dt class="pubdef"><a id="autoload_path/1"><strong>autoload_path</strong>(<var>+DirAlias</var>)</a></dt>
266307 <dd class="defbody">
267308 Add <var>DirAlias</var> to the libraries that are used by the
268309 autoloader. This extends the search path <code>autoload</code> and
274315
275316 <p>If this call appears as a directive, it is term-expanded into a
276317 clause for user:file_search_path/2 and a directive calling
277 <a name="idx:reloadlibraryindex0:200"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>.
318 <a id="idx:reloadlibraryindex0:200"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>.
278319 This keeps source information and allows for removing this directive.</dd>
279 <dt class="pubdef"><a name="make_library_index/1"><strong>make_library_index</strong>(<var>+Directory</var>)</a></dt>
320 <dt class="pubdef"><a id="make_library_index/1"><strong>make_library_index</strong>(<var>+Directory</var>)</a></dt>
280321 <dd class="defbody">
281322 Create an index for this directory. The index is written to the file
282323 'INDEX.pl' in the specified directory. Fails with a warning if the
283324 directory does not exist or is write protected.</dd>
284 <dt class="pubdef"><a name="make_library_index/2"><strong>make_library_index</strong>(<var>+Directory,
325 <dt class="pubdef"><a id="make_library_index/2"><strong>make_library_index</strong>(<var>+Directory,
285326 +ListOfPatterns</var>)</a></dt>
286327 <dd class="defbody">
287328 Normally used in <code>MKINDEX.pl</code>, this predicate creates <code>INDEX.pl</code>
305346 </pre>
306347
307348 </dd>
308 <dt class="pubdef"><a name="reload_library_index/0"><strong>reload_library_index</strong></a></dt>
349 <dt class="pubdef"><a id="reload_library_index/0"><strong>reload_library_index</strong></a></dt>
309350 <dd class="defbody">
310351 Force reloading the index after modifying the set of library directories
311 by changing the rules for <a name="idx:librarydirectory1:201"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>, <a name="idx:filesearchpath2:202"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>,
352 by changing the rules for <a id="idx:librarydirectory1:201"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>, <a id="idx:filesearchpath2:202"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>,
312353 adding or deleting <code>INDEX.pl</code> files. This predicate does <em>not</em>
313 update the <code>INDEX.pl</code> files. Check <a name="idx:makelibraryindex12:203"></a><a class="pred" href="autoload.html#make_library_index/1">make_library_index/[1,2]</a>
354 update the <code>INDEX.pl</code> files. Check <a id="idx:makelibraryindex12:203"></a><a class="pred" href="autoload.html#make_library_index/1">make_library_index/[1,2]</a>
314355 and
315 <a name="idx:make0:204"></a><a class="pred" href="consulting.html#make/0">make/0</a>
356 <a id="idx:make0:204"></a><a class="pred" href="consulting.html#make/0">make/0</a>
316357 for updating the index files.
317358
318359 <p>Normally, the index is reloaded automatically if a predicate cannot
319360 be found in the index and the set of library directories has changed.
320361 Using
321 <a name="idx:reloadlibraryindex0:205"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>
362 <a id="idx:reloadlibraryindex0:205"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>
322363 is necessary if directories are removed or the order of the library
323364 directories is changed.
324365 </dd>
325366 </dl>
326367
327 <p>When creating an executable using either <a name="idx:qsaveprogram2:206"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
368 <p>When creating an executable using either <a id="idx:qsaveprogram2:206"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
328369 or the
329370 <strong>-c</strong> command line options, it is necessarry to load all
330371 predicates that would normally be autoloaded explicitly. This is
331 discussed in <a class="sec" href="runtime.html">section 12</a>. See <a name="idx:autoload0:207"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>.
372 discussed in <a class="sec" href="runtime.html#sec:12">section 12</a>.
373 See <a id="idx:autoload0:207"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>.
332374
333375 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="tracehook.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="excepthook.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:breakpoint"><a name="sec:B.4"><span class="sec-nr">B.4</span> <span class="sec-title">Breakpoint
235 <h2 id="sec:breakpoint"><a id="sec:B.4"><span class="sec-nr">B.4</span> <span class="sec-title">Breakpoint
195236 and watchpoint handling</span></a></h2>
196237
197 <a name="sec:breakpoint"></a>
238 <a id="sec:breakpoint"></a>
198239
199240 <p>SWI-Prolog support <em>breakpoints</em>. Breakpoints can be
200241 manipulated with the library <code>library(prolog_breakpoints)</code>.
204245 describes this callback, called prolog:break_hook/6.
205246
206247 <dl class="latex">
207 <dt class="pubdef"><span class="pred-tag">[hook,semidet]</span><a name="prolog:break_hook/6"><strong>prolog:break_hook</strong>(<var>+Clause,
248 <dt class="pubdef"><span class="pred-tag">[hook,semidet]</span><a id="prolog:break_hook/6"><strong>prolog:break_hook</strong>(<var>+Clause,
208249 +PC, +FR, +BFR, +Expression, -Action</var>)</a></dt>
209250 <dd class="defbody">
210251 <em>Experimental</em> This hook is called if the virtual machine
211 executes a <code>D_BREAK</code>, set using <a name="idx:setbreakpoint4:2199"></a><span class="pred-ext">set_breakpoint/4</span>. <var>Clause</var>
252 executes a <code>D_BREAK</code>, set using <a id="idx:setbreakpoint4:2203"></a><span class="pred-ext">set_breakpoint/4</span>. <var>Clause</var>
212253 and <var>PC</var> identify the breakpoint. <var>FR</var> and <var>BFR</var>
213254 provide the environment frame and current choicepoint. <var>Expression</var>
214255 identifies the action that is interrupted, and is one of the following:
243284 <dd class="defbody">
244285 The breakpoint is on the completion of an in-lined unification while the
245286 system is not in debug mode. If the system is in debug mode, inlined
246 unification is returned as call(Var=Term).<sup class="fn">186<span class="fn-text">This
287 unification is returned as call(Var=Term).<sup class="fn">187<span class="fn-text">This
247288 hack will disappear if we find a good solution for applying D_BREAK to
248289 inlined unification. Only option might be to place the break on both the
249290 unification start and end instructions.</span></sup>
260301 Just continue as if no breakpoint was present.</dd>
261302 <dt><strong>debug</strong></dt>
262303 <dd class="defbody">
263 Continue in <em>debug mode</em>. See <a name="idx:debug0:2200"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
304 Continue in <em>debug mode</em>. See <a id="idx:debug0:2204"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
264305 <dt><strong>trace</strong></dt>
265306 <dd class="defbody">
266 Continue in <em>trace mode</em>. See <a name="idx:trace0:2201"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>.</dd>
307 Continue in <em>trace mode</em>. See <a id="idx:trace0:2205"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>.</dd>
267308 <dt><strong>call</strong>(<var>Goal</var>)</dt>
268309 <dd class="defbody">
269310 Execute <var>Goal</var> instead of the goal that would be executed.
270 <var>Goal</var> is executed as <a name="idx:call1:2202"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
311 <var>Goal</var> is executed as <a id="idx:call1:2206"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
271312 preserving (non-)determinism and exceptions.
272313 </dd>
273314 </dl>
289330 before deciding the return <code>trace</code>.
290331 <li>Watch variables at a specific point in the execution. Note that
291332 binding of these variables can be monitored using <em>attributed
292 variables</em>, see <a class="sec" href="attvar.html">section 7.1</a>.
293 <li>Dynamically add <em>assertions</em> on variables using <a name="idx:assertion1:2203"></a><a class="pred" href="debug.html#assertion/1">assertion/1</a>.
333 variables</em>, see <a class="sec" href="attvar.html#sec:7.1">section
334 7.1</a>.
335 <li>Dynamically add <em>assertions</em> on variables using <a id="idx:assertion1:2207"></a><a class="pred" href="debug.html#assertion/1">assertion/1</a>.
294336 <li>Wrap the <var>Goal</var> into a meta-call that traces progress of
295337 the <var>Goal</var>.
296338 </ul>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="assoc.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="charsio.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:broadcast"><a name="sec:A.4"><span class="sec-nr">A.4</span> <span class="sec-title">library(broadcast):
235 <h2 id="sec:broadcast"><a id="sec:A.4"><span class="sec-nr">A.4</span> <span class="sec-title">library(broadcast):
195236 Broadcast and receive event notifications</span></a></h2>
196237
197 <a name="sec:broadcast"></a>
198
199 <p><a name="idx:broadcast:2132"></a><a name="idx:messageservice:2133"></a><a name="idx:blackboard:2134"></a><a name="idx:agent:2135"></a><a name="idx:daemon:2136"></a>The <code>library(broadcast)</code>
238 <a id="sec:broadcast"></a>
239
240 <p><a id="idx:broadcast:2136"></a><a id="idx:messageservice:2137"></a><a id="idx:blackboard:2138"></a><a id="idx:agent:2139"></a><a id="idx:daemon:2140"></a>The <code>library(broadcast)</code>
200241 library was invented to realise GUI applications consisting of
201242 stand-alone components that use the Prolog database for storing the
202243 application data. <a class="fig" href="broadcast.html#fig:broadcast">Figure
203244 12</a> illustrates the flow of information using this design
204245
205 <p><a name="fig:broadcast"></a><div style="text-align:center"><img src="broadcast.gif"></div>
246 <p><a id="fig:broadcast"></a><div style="text-align:center"><img src="broadcast.gif"></div>
206247 <div class="caption"><b>Figure 12 : </b>Information-flow using
207248 broadcasting service</div>
208249
221262 showing <var>X</var>?''.
222263
223264 <dl class="latex">
224 <dt class="pubdef"><a name="broadcast/1"><strong>broadcast</strong>(<var>+Term</var>)</a></dt>
265 <dt class="pubdef"><a id="broadcast/1"><strong>broadcast</strong>(<var>+Term</var>)</a></dt>
225266 <dd class="defbody">
226267 Broadcast <var>Term</var>. There are no limitations to <var>Term</var>,
227268 though being a global service, it is good practice to use a descriptive
228269 and unique principal functor. All associated goals are started and
229 regardless of their success or failure, <a name="idx:broadcast1:2137"></a><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a>
270 regardless of their success or failure, <a id="idx:broadcast1:2141"></a><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a>
230271 always succeeds. Exceptions are passed.</dd>
231 <dt class="pubdef"><a name="broadcast_request/1"><strong>broadcast_request</strong>(<var>+Term</var>)</a></dt>
232 <dd class="defbody">
233 Unlike <a name="idx:broadcast1:2138"></a><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a>,
272 <dt class="pubdef"><a id="broadcast_request/1"><strong>broadcast_request</strong>(<var>+Term</var>)</a></dt>
273 <dd class="defbody">
274 Unlike <a id="idx:broadcast1:2142"></a><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a>,
234275 this predicate stops if an associated goal succeeds. Backtracking causes
235276 it to try other listeners. A broadcast request is used to fetch
236277 information without knowing the identity of the agent providing it. C.f. ``Is
244285 <p>If there is an agent (<em>listener</em>) that registered an `age-of'
245286 service and knows about the age of `John' this question will be
246287 answered.</dd>
247 <dt class="pubdef"><a name="listen/2"><strong>listen</strong>(<var>+Template,
288 <dt class="pubdef"><a id="listen/2"><strong>listen</strong>(<var>+Template,
248289 :Goal</var>)</a></dt>
249290 <dd class="defbody">
250291 Register a <em>listen</em> channel. Whenever a term unifying
260301 </pre>
261302
262303 </dd>
263 <dt class="pubdef"><a name="listen/3"><strong>listen</strong>(<var>+Listener,
304 <dt class="pubdef"><a id="listen/3"><strong>listen</strong>(<var>+Listener,
264305 +Template, :Goal</var>)</a></dt>
265306 <dd class="defbody">
266307 Declare <var>Listener</var> as the owner of the channel. Unlike a
267 channel opened using <a name="idx:listen2:2139"></a><a class="pred" href="broadcast.html#listen/2">listen/2</a>,
308 channel opened using <a id="idx:listen2:2143"></a><a class="pred" href="broadcast.html#listen/2">listen/2</a>,
268309 channels that have an owner can terminate the channel. This is commonly
269310 used if an object is listening to broadcast messages. In the example
270311 below we define a `name-item' displaying the name of an identifier
271 represented by the predicate <a name="idx:nameof2:2140"></a><span class="pred-ext">name_of/2</span>.
312 represented by the predicate <a id="idx:nameof2:2144"></a><span class="pred-ext">name_of/2</span>.
272313
273314 <pre class="code">
274315 :- pce_begin_class(name_item, text_item).
297338 </pre>
298339
299340 </dd>
300 <dt class="pubdef"><a name="unlisten/1"><strong>unlisten</strong>(<var>+Listener</var>)</a></dt>
301 <dd class="defbody">
302 Deregister all entries created with <a name="idx:listen3:2141"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
341 <dt class="pubdef"><a id="unlisten/1"><strong>unlisten</strong>(<var>+Listener</var>)</a></dt>
342 <dd class="defbody">
343 Deregister all entries created with <a id="idx:listen3:2145"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
303344 whose <var>Listener</var> unify.</dd>
304 <dt class="pubdef"><a name="unlisten/2"><strong>unlisten</strong>(<var>+Listener,
345 <dt class="pubdef"><a id="unlisten/2"><strong>unlisten</strong>(<var>+Listener,
305346 +Template</var>)</a></dt>
306347 <dd class="defbody">
307 Deregister all entries created with <a name="idx:listen3:2142"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
348 Deregister all entries created with <a id="idx:listen3:2146"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
308349 whose <var>Listener</var> and <var>Template</var> unify.</dd>
309 <dt class="pubdef"><a name="unlisten/3"><strong>unlisten</strong>(<var>+Listener,
350 <dt class="pubdef"><a id="unlisten/3"><strong>unlisten</strong>(<var>+Listener,
310351 +Template, :Goal</var>)</a></dt>
311352 <dd class="defbody">
312 Deregister all entries created with <a name="idx:listen3:2143"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
353 Deregister all entries created with <a id="idx:listen3:2147"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
313354 whose <var>Listener</var>,
314355 <var>Template</var> and <var>Goal</var> unify.</dd>
315 <dt class="pubdef"><a name="listening/3"><strong>listening</strong>(<var>?Listener,
356 <dt class="pubdef"><a id="listening/3"><strong>listening</strong>(<var>?Listener,
316357 ?Template, ?Goal</var>)</a></dt>
317358 <dd class="defbody">
318359 Examine the current listeners. This predicate is useful for debugging
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="idesummary.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="preddesc.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:builtin"><a name="sec:4"><span class="sec-nr">4</span> <span class="sec-title">Built-in
235 <h1 id="sec:builtin"><a id="sec:4"><span class="sec-nr">4</span> <span class="sec-title">Built-in
195236 Predicates</span></a></h1>
196237
197 <a name="sec:builtin"></a>
238 <a id="sec:builtin"></a>
198239
199240 <p>
200241 <hr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.29</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.29</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="miscarith.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="allsolutions.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:builtinlist"><a name="sec:4.29"><span class="sec-nr">4.29</span> <span class="sec-title">Built-in
235 <h2 id="sec:builtinlist"><a id="sec:4.29"><span class="sec-nr">4.29</span> <span class="sec-title">Built-in
195236 list operations</span></a></h2>
196237
197 <a name="sec:builtinlist"></a>
238 <a id="sec:builtinlist"></a>
198239
199240 <p>Most list operations are defined in the library <code>library(lists)</code>
200 described in <a class="sec" href="lists.html">section A.15</a>. Some
201 that are implemented with more low-level primitives are built-in and
202 described here.
241 described in <a class="sec" href="lists.html#sec:A.15">section A.15</a>.
242 Some that are implemented with more low-level primitives are built-in
243 and described here.
203244
204245 <dl class="latex">
205 <dt class="pubdef"><a name="is_list/1"><strong>is_list</strong>(<var>+Term</var>)</a></dt>
246 <dt class="pubdef"><a id="is_list/1"><strong>is_list</strong>(<var>+Term</var>)</a></dt>
206247 <dd class="defbody">
207248 True if <var>Term</var> is bound to the empty list (<code>[]</code>) or
208249 a term with functor `<code>'[|]'</code>'<sup class="fn">118<span class="fn-text">The
209250 traditional list functor is the dot (<code>'.'</code>). This is still
210251 the case of the command line option <strong>--traditional</strong> is
211 given. See also <a class="sec" href="ext-lists.html">section 5.1</a>.</span></sup>
252 given. See also <a class="sec" href="ext-lists.html#sec:5.1">section 5.1</a>.</span></sup>
212253 and arity&nbsp;2 and the second argument is a list.<sup class="fn">119<span class="fn-text">In
213 versions before 5.0.1, <a name="idx:islist1:1342"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>
254 versions before 5.0.1, <a id="idx:islist1:1342"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>
214255 just checked for <code>[]</code> or <code>[_|_]</code> and proper_list/1
215 had the role of the current <a name="idx:islist1:1343"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>.
256 had the role of the current <a id="idx:islist1:1343"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>.
216257 The current definition conforms to the de facto standard. Assuming
217258 proper coding standards, there should only be very few cases where a
218 quick-and-dirty <a name="idx:islist1:1344"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>
259 quick-and-dirty <a id="idx:islist1:1344"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>
219260 is a good choice. Richard O'Keefe pointed at this issue.</span></sup>
220261 This predicate acts as if defined by the definition below on
221262 <em>acyclic</em> terms. The implementation <em>fails</em> safely if
231272 </pre>
232273
233274 </dd>
234 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="memberchk/2"><strong>memberchk</strong>(<var>?Elem,
275 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="memberchk/2"><strong>memberchk</strong>(<var>?Elem,
235276 +List</var>)</a></dt>
236277 <dd class="defbody">
237278 True when <var>Elem</var> is an element of <var>List</var>. This `chk'
238279 variant of
239 <a name="idx:member2:1345"></a><a class="pred" href="lists.html#member/2">member/2</a>
280 <a id="idx:member2:1345"></a><a class="pred" href="lists.html#member/2">member/2</a>
240281 is semi deterministic and typically used to test membership of a list.
241282 Raises a <code>type</code> error if scanning <var>List</var> encounters
242 a non-list. Note that <a name="idx:memberchk2:1346"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
283 a non-list. Note that <a id="idx:memberchk2:1346"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
243284 does <em>not</em> perform a full list typecheck. For example, <code>memberchk(a,
244285 [a|b])</code> succeeds without error. If <var>List</var> is cyclic and <var>Elem</var>
245286 is not a member of
246 <var>List</var>, <a name="idx:memberchk2:1347"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
287 <var>List</var>, <a id="idx:memberchk2:1347"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
247288 eventually raises a <code>type</code> error.<sup class="fn">120<span class="fn-text"><i>Eventually</i>
248289 here means it will scan as many elements as the longest list that may
249290 exist given the current stack usage before raising the exception.</span></sup></dd>
250 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="length/2"><strong>length</strong>(<var>?List,
291 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="length/2"><strong>length</strong>(<var>?List,
251292 ?Int</var>)</a></dt>
252293 <dd class="defbody">
253294 True if <var>Int</var> represents the number of elements in <var>List</var>.
272313 is logically correct. An exception would be more appropriate, but to our
273314 best knowledge, current practice in Prolog does not describe a suitable
274315 candidate exception term.</span></sup></dd>
275 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="sort/2"><strong>sort</strong>(<var>+List,
316 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="sort/2"><strong>sort</strong>(<var>+List,
276317 -Sorted</var>)</a></dt>
277318 <dd class="defbody">
278319 True if <var>Sorted</var> can be unified with a list holding the
279320 elements of <var>List</var>, sorted to the standard order of terms (see
280 <a class="sec" href="compare.html">section 4.7</a>). Duplicates are
281 removed. The implementation is in C, using <em>natural merge sort</em>.<sup class="fn">123<span class="fn-text">Contributed
282 by Richard O'Keefe.</span></sup> The <a name="idx:sort2:1348"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
321 <a class="sec" href="compare.html#sec:4.7">section 4.7</a>). Duplicates
322 are removed. The implementation is in C, using <em>natural merge sort</em>.<sup class="fn">123<span class="fn-text">Contributed
323 by Richard O'Keefe.</span></sup> The <a id="idx:sort2:1348"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
283324 predicate can sort a cyclic list, returning a non-cyclic version with
284325 the same elements.
285326
289330 However, unifying a variable in <var>Sorted</var> may cause this
290331 relation to become invalid,
291332 <em>even</em> unifying a variable in <var>Sorted</var> with another
292 (older) variable. See also <a class="sec" href="compare.html">section
333 (older) variable. See also <a class="sec" href="compare.html#sec:4.7.1">section
293334 4.7.1</a>.</dd>
294 <dt class="pubdef"><a name="sort/4"><strong>sort</strong>(<var>+Key,
335 <dt class="pubdef"><a id="sort/4"><strong>sort</strong>(<var>+Key,
295336 +Order, +List, -Sorted</var>)</a></dt>
296337 <dd class="defbody">
297338 True when <var>Sorted</var> can be unified with a list holding the
309350 <p>If <var>Key</var> is the integer zero (0), the entire term is used to
310351 compare two elements. Using <var>Key</var>=0 can be used to sort
311352 arbitrary Prolog terms. Other values for <var>Key</var> can only be used
312 with compound terms or dicts (see <a class="sec" href="dicts.html">section
353 with compound terms or dicts (see <a class="sec" href="dicts.html#sec:5.4">section
313354 5.4</a>). An integer key extracts the <var>Key</var>-th argument from a
314355 compound term. An integer or atom key extracts the value from a dict
315356 that is associated with the given key. A type_error is raised if the
324365 compatibility with ECLiPSe, the values <code><code>&lt;</code></code>, <code><code>=&lt;</code></code>, <code><code>&gt;</code></code>
325366 and <code><code>&gt;=</code></code> are allowed as synonyms.</span></sup>
326367
327 <p><table border="0" frame="void" rules="groups" style="margin:auto">
328 <tr valign="top"><td>Order</td><td>Ordering</td><td>Duplicate handling </td></tr>
329 <tbody>
330 <tr valign="top"><td><code><code>@&lt;</code></code> </td><td>ascending</td><td>remove </td></tr>
331 <tr valign="top"><td><code><code>@=&lt;</code></code> </td><td>ascending</td><td>keep </td></tr>
332 <tr valign="top"><td><code><code>@&gt;</code></code> </td><td>descending</td><td>remove </td></tr>
333 <tr valign="top"><td><code><code>@&gt;=</code></code> </td><td>descending</td><td>keep </td></tr>
368 <p><table class="latex frame-void center">
369 <tr><td>Order</td><td>Ordering</td><td>Duplicate handling </td></tr>
370 <tr class="hline"><td><code><code>@&lt;</code></code> </td><td>ascending</td><td>remove </td></tr>
371 <tr><td><code><code>@=&lt;</code></code> </td><td>ascending</td><td>keep </td></tr>
372 <tr><td><code><code>@&gt;</code></code> </td><td>descending</td><td>remove </td></tr>
373 <tr><td><code><code>@&gt;=</code></code> </td><td>descending</td><td>keep </td></tr>
334374 </table>
335375
336376 <p>The sort is <em>stable</em>, which implies that, if duplicates are
348388
349389 <p>The following example sorts a list of rows, for example resulting
350390 from
351 <a name="idx:csvreadfile2:1349"></a><a class="pred" href="csv.html#csv_read_file/2">csv_read_file/2</a>)
391 <a id="idx:csvreadfile2:1349"></a><a class="pred" href="csv.html#csv_read_file/2">csv_read_file/2</a>)
352392 ascending on the 3th column and descending on the 4th column:
353393
354394 <pre class="code">
356396 sort(3, @=&lt;, Rows1, Sorted).
357397 </pre>
358398
359 <p>See also <a name="idx:sort2:1350"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
360 (ISO), <a name="idx:msort2:1351"></a><a class="pred" href="builtinlist.html#msort/2">msort/2</a>, <a name="idx:keysort2:1352"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>, <a name="idx:predsort3:1353"></a><a class="pred" href="builtinlist.html#predsort/3">predsort/3</a>
361 and <a name="idx:orderby2:1354"></a><a class="pred" href="solutionsequences.html#order_by/2">order_by/2</a>.</dd>
362 <dt class="pubdef"><a name="msort/2"><strong>msort</strong>(<var>+List,
399 <p>See also <a id="idx:sort2:1350"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
400 (ISO), <a id="idx:msort2:1351"></a><a class="pred" href="builtinlist.html#msort/2">msort/2</a>, <a id="idx:keysort2:1352"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>, <a id="idx:predsort3:1353"></a><a class="pred" href="builtinlist.html#predsort/3">predsort/3</a>
401 and <a id="idx:orderby2:1354"></a><a class="pred" href="solutionsequences.html#order_by/2">order_by/2</a>.</dd>
402 <dt class="pubdef"><a id="msort/2"><strong>msort</strong>(<var>+List,
363403 -Sorted</var>)</a></dt>
364404 <dd class="defbody">
365 Equivalent to <a name="idx:sort2:1355"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
405 Equivalent to <a id="idx:sort2:1355"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
366406 but does not remove duplicates. Raises a
367407 <code>type_error</code> if <var>List</var> is a cyclic list or not a
368408 list.</dd>
369 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="keysort/2"><strong>keysort</strong>(<var>+List,
409 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="keysort/2"><strong>keysort</strong>(<var>+List,
370410 -Sorted</var>)</a></dt>
371411 <dd class="defbody">
372412 Sort a list of <em>pairs</em>. <var>List</var> must be a list of
373413 <code><var>Key</var>-<var>Value</var></code> pairs, terms whose
374414 principal functor is (-)/2. <var>List</var> is sorted on <var>Key</var>
375 according to the standard order of terms (see <a class="sec" href="compare.html">section
415 according to the standard order of terms (see <a class="sec" href="compare.html#sec:4.7.1">section
376416 4.7.1</a>). Duplicates are <em>not</em> removed. Sorting is <em>stable</em>
377417 with regard to the order of the
378418 <var>Values</var>, i.e., the order of multiple elements that have the
379419 same
380420 <var>Key</var> is not changed.
381421
382 <p>The <a name="idx:keysort2:1356"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>
422 <p>The <a id="idx:keysort2:1356"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>
383423 predicate is often used together with library
384424 <code>library(pairs)</code>. It can be used to sort lists on different
385425 or multiple criteria. For example, the following predicates sorts a list
396436 </pre>
397437
398438 </dd>
399 <dt class="pubdef"><a name="predsort/3"><strong>predsort</strong>(<var>+Pred,
439 <dt class="pubdef"><a id="predsort/3"><strong>predsort</strong>(<var>+Pred,
400440 +List, -Sorted</var>)</a></dt>
401441 <dd class="defbody">
402 Sorts similar to <a name="idx:sort2:1357"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
442 Sorts similar to <a id="idx:sort2:1357"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
403443 but determines the order of two terms by calling <var>Pred</var>(-<var>Delta</var>,
404444 +<var>E1</var>, +<var>E2</var>) . This call must unify <var>Delta</var>
405445 with one of <code><code>&lt;</code></code>, <code><code>&gt;</code></code>
406446 or
407 <code><code>=</code></code>. If the built-in predicate <a name="idx:compare3:1358"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
408 is used, the result is the same as <a name="idx:sort2:1359"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>.
409 See also <a name="idx:keysort2:1360"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>.
447 <code><code>=</code></code>. If the built-in predicate <a id="idx:compare3:1358"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
448 is used, the result is the same as <a id="idx:sort2:1359"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>.
449 See also <a id="idx:keysort2:1360"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>.
410450 </dd>
411451 </dl>
412452
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.26</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.26</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="operators.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="arith.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:charconv"><a name="sec:4.26"><span class="sec-nr">4.26</span> <span class="sec-title">Character
235 <h2 id="sec:charconv"><a id="sec:4.26"><span class="sec-nr">4.26</span> <span class="sec-title">Character
195236 Conversion</span></a></h2>
196237
197 <a name="sec:charconv"></a>
238 <a id="sec:charconv"></a>
198239
199240 <p>Although I wouldn't really know why you would like to use these
200241 features, they are provided for ISO compliance.
201242
202243 <dl class="latex">
203 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="char_conversion/2"><strong>char_conversion</strong>(<var>+CharIn,
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="char_conversion/2"><strong>char_conversion</strong>(<var>+CharIn,
204245 +CharOut</var>)</a></dt>
205246 <dd class="defbody">
206 Define that term input (see <a name="idx:readterm3:1318"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>)
247 Define that term input (see <a id="idx:readterm3:1318"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>)
207248 maps each character read as
208249 <var>CharIn</var> to the character <var>CharOut</var>. Character
209250 conversion is only executed if the Prolog flag <a class="flag" href="flags.html#flag:char_conversion">char_conversion</a>
210251 is set to
211252 <code>true</code> and not inside quoted atoms or strings. The initial
212 table maps each character onto itself. See also <a name="idx:currentcharconversion2:1319"></a><a class="pred" href="charconv.html#current_char_conversion/2">current_char_conversion/2</a>.
253 table maps each character onto itself. See also <a id="idx:currentcharconversion2:1319"></a><a class="pred" href="charconv.html#current_char_conversion/2">current_char_conversion/2</a>.
213254 </dd>
214 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_char_conversion/2"><strong>current_char_conversion</strong>(<var>?CharIn,
255 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_char_conversion/2"><strong>current_char_conversion</strong>(<var>?CharIn,
215256 ?CharOut</var>)</a></dt>
216257 <dd class="defbody">
217 Queries the current character conversion table. See <a name="idx:charconversion2:1320"></a><a class="pred" href="charconv.html#char_conversion/2">char_conversion/2</a>
258 Queries the current character conversion table. See <a id="idx:charconversion2:1320"></a><a class="pred" href="charconv.html#char_conversion/2">char_conversion/2</a>
218259 for details.
219260 </dd>
220261 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.19</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.19</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="streamstat.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="termrw.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:chario"><a name="sec:4.19"><span class="sec-nr">4.19</span> <span class="sec-title">Primitive
235 <h2 id="sec:chario"><a id="sec:4.19"><span class="sec-nr">4.19</span> <span class="sec-title">Primitive
195236 character I/O</span></a></h2>
196237
197 <a name="sec:chario"></a>
198
199 <p>See <a class="sec" href="chars.html">section 4.2</a> for an overview
200 of supported character representations.
238 <a id="sec:chario"></a>
239
240 <p>See <a class="sec" href="chars.html#sec:4.2">section 4.2</a> for an
241 overview of supported character representations.
201242
202243 <dl class="latex">
203 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="nl/0"><strong>nl</strong></a></dt>
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="nl/0"><strong>nl</strong></a></dt>
204245 <dd class="defbody">
205246 Write a newline character to the current output stream. On Unix systems
206 <a name="idx:nl0:1074"></a><a class="pred" href="chario.html#nl/0">nl/0</a>
247 <a id="idx:nl0:1074"></a><a class="pred" href="chario.html#nl/0">nl/0</a>
207248 is equivalent to <code>put(10)</code>.</dd>
208 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="nl/1"><strong>nl</strong>(<var>+Stream</var>)</a></dt>
249 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="nl/1"><strong>nl</strong>(<var>+Stream</var>)</a></dt>
209250 <dd class="defbody">
210251 Write a newline to <var>Stream</var>.</dd>
211 <dt class="pubdef"><a name="put/1"><strong>put</strong>(<var>+Char</var>)</a></dt>
252 <dt class="pubdef"><a id="put/1"><strong>put</strong>(<var>+Char</var>)</a></dt>
212253 <dd class="defbody">
213254 Write <var>Char</var> to the current output stream. <var>Char</var> is
214255 either an integer expression evaluating to a character code or an atom
215 of one character. Deprecated. New code should use <a name="idx:putchar1:1075"></a><a class="pred" href="chario.html#put_char/1">put_char/1</a>
216 or <a name="idx:putcode1:1076"></a><a class="pred" href="chario.html#put_code/1">put_code/1</a>.</dd>
217 <dt class="pubdef"><a name="put/2"><strong>put</strong>(<var>+Stream,
256 of one character. Deprecated. New code should use <a id="idx:putchar1:1075"></a><a class="pred" href="chario.html#put_char/1">put_char/1</a>
257 or <a id="idx:putcode1:1076"></a><a class="pred" href="chario.html#put_code/1">put_code/1</a>.</dd>
258 <dt class="pubdef"><a id="put/2"><strong>put</strong>(<var>+Stream,
218259 +Char</var>)</a></dt>
219260 <dd class="defbody">
220 Write <var>Char</var> to <var>Stream</var>. See <a name="idx:put1:1077"></a><a class="pred" href="chario.html#put/1">put/1</a>
261 Write <var>Char</var> to <var>Stream</var>. See <a id="idx:put1:1077"></a><a class="pred" href="chario.html#put/1">put/1</a>
221262 for details.</dd>
222 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_byte/1"><strong>put_byte</strong>(<var>+Byte</var>)</a></dt>
263 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_byte/1"><strong>put_byte</strong>(<var>+Byte</var>)</a></dt>
223264 <dd class="defbody">
224265 Write a single byte to the output. <var>Byte</var> must be an integer
225266 between 0 and 255.</dd>
226 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_byte/2"><strong>put_byte</strong>(<var>+Stream,
267 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_byte/2"><strong>put_byte</strong>(<var>+Stream,
227268 +Byte</var>)</a></dt>
228269 <dd class="defbody">
229270 Write a single byte to <var>Stream</var>. <var>Byte</var> must be an
230271 integer between 0 and 255.</dd>
231 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_char/1"><strong>put_char</strong>(<var>+Char</var>)</a></dt>
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_char/1"><strong>put_char</strong>(<var>+Char</var>)</a></dt>
232273 <dd class="defbody">
233274 Write a character to the current output, obeying the encoding defined
234275 for the current output stream. Note that this may raise an exception if
235276 the encoding of the output stream cannot represent <var>Char</var>.</dd>
236 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_char/2"><strong>put_char</strong>(<var>+Stream,
277 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_char/2"><strong>put_char</strong>(<var>+Stream,
237278 +Char</var>)</a></dt>
238279 <dd class="defbody">
239280 Write a character to <var>Stream</var>, obeying the encoding defined for
240281 <var>Stream</var>. Note that this may raise an exception if the encoding
241282 of <var>Stream</var> cannot represent <var>Char</var>.</dd>
242 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_code/1"><strong>put_code</strong>(<var>+Code</var>)</a></dt>
243 <dd class="defbody">
244 Similar to <a name="idx:putchar1:1078"></a><a class="pred" href="chario.html#put_char/1">put_char/1</a>,
283 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_code/1"><strong>put_code</strong>(<var>+Code</var>)</a></dt>
284 <dd class="defbody">
285 Similar to <a id="idx:putchar1:1078"></a><a class="pred" href="chario.html#put_char/1">put_char/1</a>,
245286 but using a <em>character code</em>. <var>Code</var> is a non-negative
246287 integer. Note that this may raise an exception if the encoding of the
247288 output stream cannot represent <var>Code</var>.</dd>
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_code/2"><strong>put_code</strong>(<var>+Stream,
289 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_code/2"><strong>put_code</strong>(<var>+Stream,
249290 +Code</var>)</a></dt>
250291 <dd class="defbody">
251 Same as <a name="idx:putcode1:1079"></a><a class="pred" href="chario.html#put_code/1">put_code/1</a>
292 Same as <a id="idx:putcode1:1079"></a><a class="pred" href="chario.html#put_code/1">put_code/1</a>
252293 but directing <var>Code</var> to <var>Stream</var>.</dd>
253 <dt class="pubdef"><a name="tab/1"><strong>tab</strong>(<var>+Amount</var>)</a></dt>
294 <dt class="pubdef"><a id="tab/1"><strong>tab</strong>(<var>+Amount</var>)</a></dt>
254295 <dd class="defbody">
255296 Write <var>Amount</var> spaces on the current output stream. <var>Amount</var>
256297 should be an expression that evaluates to a positive integer (see
257 <a class="sec" href="arith.html">section 4.27</a>).</dd>
258 <dt class="pubdef"><a name="tab/2"><strong>tab</strong>(<var>+Stream,
298 <a class="sec" href="arith.html#sec:4.27">section 4.27</a>).</dd>
299 <dt class="pubdef"><a id="tab/2"><strong>tab</strong>(<var>+Stream,
259300 +Amount</var>)</a></dt>
260301 <dd class="defbody">
261302 Write <var>Amount</var> spaces to <var>Stream</var>.</dd>
262 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="flush_output/0"><strong>flush_output</strong></a></dt>
263 <dd class="defbody">
264 Flush pending output on current output stream. <a name="idx:flushoutput0:1080"></a><a class="pred" href="chario.html#flush_output/0">flush_output/0</a>
265 is automatically generated by <a name="idx:read1:1081"></a><a class="pred" href="termrw.html#read/1">read/1</a>
303 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="flush_output/0"><strong>flush_output</strong></a></dt>
304 <dd class="defbody">
305 Flush pending output on current output stream. <a id="idx:flushoutput0:1080"></a><a class="pred" href="chario.html#flush_output/0">flush_output/0</a>
306 is automatically generated by <a id="idx:read1:1081"></a><a class="pred" href="termrw.html#read/1">read/1</a>
266307 and derivatives if the current input stream is <code>user</code> and the
267308 cursor is not at the left margin.</dd>
268 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="flush_output/1"><strong>flush_output</strong>(<var>+Stream</var>)</a></dt>
309 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="flush_output/1"><strong>flush_output</strong>(<var>+Stream</var>)</a></dt>
269310 <dd class="defbody">
270311 Flush output on the specified stream. The stream must be open for
271312 writing.</dd>
272 <dt class="pubdef"><a name="ttyflush/0"><strong>ttyflush</strong></a></dt>
273 <dd class="defbody">
274 Flush pending output on stream <code>user</code>. See also <a name="idx:flushoutput01:1082"></a><a class="pred" href="chario.html#flush_output/0">flush_output/[0,1]</a>.
313 <dt class="pubdef"><a id="ttyflush/0"><strong>ttyflush</strong></a></dt>
314 <dd class="defbody">
315 Flush pending output on stream <code>user</code>. See also <a id="idx:flushoutput01:1082"></a><a class="pred" href="chario.html#flush_output/0">flush_output/[0,1]</a>.
275316 </dd>
276 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_byte/1"><strong>get_byte</strong>(<var>-Byte</var>)</a></dt>
317 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_byte/1"><strong>get_byte</strong>(<var>-Byte</var>)</a></dt>
277318 <dd class="defbody">
278319 Read the current input stream and unify the next byte with <var>Byte</var>
279320 (an integer between 0 and 255). <var>Byte</var> is unified with -1 on
280321 end of file.</dd>
281 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_byte/2"><strong>get_byte</strong>(<var>+Stream,
322 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_byte/2"><strong>get_byte</strong>(<var>+Stream,
282323 -Byte</var>)</a></dt>
283324 <dd class="defbody">
284325 Read the next byte from <var>Stream</var> and unify <var>Byte</var> with
285326 an integer between 0 and 255.</dd>
286 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_code/1"><strong>get_code</strong>(<var>-Code</var>)</a></dt>
327 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_code/1"><strong>get_code</strong>(<var>-Code</var>)</a></dt>
287328 <dd class="defbody">
288329 Read the current input stream and unify <var>Code</var> with the
289330 character code of the next character. <var>Code</var> is unified with -1
290 on end of file. See also <a name="idx:getchar1:1083"></a><a class="pred" href="chario.html#get_char/1">get_char/1</a>.</dd>
291 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_code/2"><strong>get_code</strong>(<var>+Stream,
331 on end of file. See also <a id="idx:getchar1:1083"></a><a class="pred" href="chario.html#get_char/1">get_char/1</a>.</dd>
332 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_code/2"><strong>get_code</strong>(<var>+Stream,
292333 -Code</var>)</a></dt>
293334 <dd class="defbody">
294335 Read the next character code from <var>Stream</var>.</dd>
295 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_char/1"><strong>get_char</strong>(<var>-Char</var>)</a></dt>
336 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_char/1"><strong>get_char</strong>(<var>-Char</var>)</a></dt>
296337 <dd class="defbody">
297338 Read the current input stream and unify <var>Char</var> with the next
298 character as a one-character atom. See also <a name="idx:atomchars2:1084"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>.
339 character as a one-character atom. See also <a id="idx:atomchars2:1084"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>.
299340 On end-of-file, <var>Char</var> is unified to the atom <code>end_of_file</code>.</dd>
300 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_char/2"><strong>get_char</strong>(<var>+Stream,
341 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_char/2"><strong>get_char</strong>(<var>+Stream,
301342 -Char</var>)</a></dt>
302343 <dd class="defbody">
303344 Unify <var>Char</var> with the next character from <var>Stream</var> as
304 a one-character atom. See also <a name="idx:getchar2:1085"></a><a class="pred" href="chario.html#get_char/2">get_char/2</a>, <a name="idx:getbyte2:1086"></a><a class="pred" href="chario.html#get_byte/2">get_byte/2</a>
305 and <a name="idx:getcode2:1087"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>.</dd>
306 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="get0/1"><strong>get0</strong>(<var>-Char</var>)</a></dt>
307 <dd class="defbody">
308 Edinburgh version of the ISO <a name="idx:getcode1:1088"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
345 a one-character atom. See also <a id="idx:getchar2:1085"></a><a class="pred" href="chario.html#get_char/2">get_char/2</a>, <a id="idx:getbyte2:1086"></a><a class="pred" href="chario.html#get_byte/2">get_byte/2</a>
346 and <a id="idx:getcode2:1087"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>.</dd>
347 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="get0/1"><strong>get0</strong>(<var>-Char</var>)</a></dt>
348 <dd class="defbody">
349 Edinburgh version of the ISO <a id="idx:getcode1:1088"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
309350 predicate. Note that Edinburgh Prolog didn't support wide characters and
310351 therefore technically speaking
311 <a name="idx:get01:1089"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
312 should have been mapped to <a name="idx:getbyte1:1090"></a><a class="pred" href="chario.html#get_byte/1">get_byte/1</a>.
313 The intention of <a name="idx:get01:1091"></a><a class="pred" href="chario.html#get0/1">get0/1</a>,
352 <a id="idx:get01:1089"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
353 should have been mapped to <a id="idx:getbyte1:1090"></a><a class="pred" href="chario.html#get_byte/1">get_byte/1</a>.
354 The intention of <a id="idx:get01:1091"></a><a class="pred" href="chario.html#get0/1">get0/1</a>,
314355 however, is to read character codes.</dd>
315 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="get0/2"><strong>get0</strong>(<var>+Stream,
356 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="get0/2"><strong>get0</strong>(<var>+Stream,
316357 -Char</var>)</a></dt>
317358 <dd class="defbody">
318 Edinburgh version of the ISO <a name="idx:getcode2:1092"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
319 predicate. See also <a name="idx:get01:1093"></a><a class="pred" href="chario.html#get0/1">get0/1</a>.</dd>
320 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="get/1"><strong>get</strong>(<var>-Char</var>)</a></dt>
359 Edinburgh version of the ISO <a id="idx:getcode2:1092"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
360 predicate. See also <a id="idx:get01:1093"></a><a class="pred" href="chario.html#get0/1">get0/1</a>.</dd>
361 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="get/1"><strong>get</strong>(<var>-Char</var>)</a></dt>
321362 <dd class="defbody">
322363 Read the current input stream and unify the next non-blank character
323364 with <var>Char</var>. <var>Char</var> is unified with -1 on end of file.
324 The predicate <a name="idx:get1:1094"></a><a class="pred" href="chario.html#get/1">get/1</a>
325 operates on character <em>codes</em>. See also <a name="idx:get01:1095"></a><a class="pred" href="chario.html#get0/1">get0/1</a>.</dd>
326 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="get/2"><strong>get</strong>(<var>+Stream,
365 The predicate <a id="idx:get1:1094"></a><a class="pred" href="chario.html#get/1">get/1</a>
366 operates on character <em>codes</em>. See also <a id="idx:get01:1095"></a><a class="pred" href="chario.html#get0/1">get0/1</a>.</dd>
367 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="get/2"><strong>get</strong>(<var>+Stream,
327368 -Char</var>)</a></dt>
328369 <dd class="defbody">
329370 Read the next non-blank character from <var>Stream</var>. See also
330 <a name="idx:get1:1096"></a><a class="pred" href="chario.html#get/1">get/1</a>, <a name="idx:get01:1097"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
331 and <a name="idx:get02:1098"></a><a class="pred" href="chario.html#get0/2">get0/2</a>.</dd>
332 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="peek_byte/1"><strong>peek_byte</strong>(<var>-Byte</var>)</a></dt>
333 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="peek_byte/2"><strong>peek_byte</strong>(<var>+Stream,
371 <a id="idx:get1:1096"></a><a class="pred" href="chario.html#get/1">get/1</a>, <a id="idx:get01:1097"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
372 and <a id="idx:get02:1098"></a><a class="pred" href="chario.html#get0/2">get0/2</a>.</dd>
373 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="peek_byte/1"><strong>peek_byte</strong>(<var>-Byte</var>)</a></dt>
374 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="peek_byte/2"><strong>peek_byte</strong>(<var>+Stream,
334375 -Byte</var>)</a></dt>
335 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="peek_code/1"><strong>peek_code</strong>(<var>-Code</var>)</a></dt>
336 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="peek_code/2"><strong>peek_code</strong>(<var>+Stream,
376 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="peek_code/1"><strong>peek_code</strong>(<var>-Code</var>)</a></dt>
377 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="peek_code/2"><strong>peek_code</strong>(<var>+Stream,
337378 -Code</var>)</a></dt>
338 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="peek_char/1"><strong>peek_char</strong>(<var>-Char</var>)</a></dt>
339 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="peek_char/2"><strong>peek_char</strong>(<var>+Stream,
379 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="peek_char/1"><strong>peek_char</strong>(<var>-Char</var>)</a></dt>
380 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="peek_char/2"><strong>peek_char</strong>(<var>+Stream,
340381 -Char</var>)</a></dt>
341382 <dd class="defbody">
342383 Read the next byte/code/char from the input without removing it. These
343384 predicates do not modify the stream's position or end-of-file status.
344 These predicates require a buffered stream (see <a name="idx:setstream2:1099"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>)
385 These predicates require a buffered stream (see <a id="idx:setstream2:1099"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>)
345386 and raise a permission error if the stream is unbuffered or the buffer
346387 is too small to hold the longest multi-byte sequence that might need to
347388 be buffered.</dd>
348 <dt class="pubdef"><a name="peek_string/3"><strong>peek_string</strong>(<var>+Stream,
389 <dt class="pubdef"><a id="peek_string/3"><strong>peek_string</strong>(<var>+Stream,
349390 +Len, -String</var>)</a></dt>
350391 <dd class="defbody">
351392 Read the next <var>Len</var> characters (if the stream is a text stream)
355396 shorter than <var>Len</var> if the stream contains less data. This
356397 predicate is intended to guess the content type of data read from
357398 non-repositionable streams.</dd>
358 <dt class="pubdef"><a name="skip/1"><strong>skip</strong>(<var>+Code</var>)</a></dt>
399 <dt class="pubdef"><a id="skip/1"><strong>skip</strong>(<var>+Code</var>)</a></dt>
359400 <dd class="defbody">
360401 Read the input until <var>Code</var> or the end of the file is
361 encountered. A subsequent call to <a name="idx:getcode1:1100"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
402 encountered. A subsequent call to <a id="idx:getcode1:1100"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
362403 will read the first character after
363404 <var>Code</var>.</dd>
364 <dt class="pubdef"><a name="skip/2"><strong>skip</strong>(<var>+Stream,
405 <dt class="pubdef"><a id="skip/2"><strong>skip</strong>(<var>+Stream,
365406 +Code</var>)</a></dt>
366407 <dd class="defbody">
367 Skip input (as <a name="idx:skip1:1101"></a><a class="pred" href="chario.html#skip/1">skip/1</a>)
408 Skip input (as <a id="idx:skip1:1101"></a><a class="pred" href="chario.html#skip/1">skip/1</a>)
368409 on <var>Stream</var>.</dd>
369 <dt class="pubdef"><a name="get_single_char/1"><strong>get_single_char</strong>(<var>-Code</var>)</a></dt>
410 <dt class="pubdef"><a id="get_single_char/1"><strong>get_single_char</strong>(<var>-Code</var>)</a></dt>
370411 <dd class="defbody">
371412 Get a single character from input stream `user' (regardless of the
372 current input stream). Unlike <a name="idx:getcode1:1102"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>,
413 current input stream). Unlike <a id="idx:getcode1:1102"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>,
373414 this predicate does not wait for a return. The character is not echoed
374415 to the user's terminal. This predicate is meant for keyboard menu
375416 selection, etc. If SWI-Prolog was started with the <strong>-tty</strong>
376417 option this predicate reads an entire line of input and returns the
377418 first non-blank character on this line, or the character code of the
378419 newline (10) if the entire line consisted of blank characters.</dd>
379 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="at_end_of_stream/0"><strong>at_end_of_stream</strong></a></dt>
420 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="at_end_of_stream/0"><strong>at_end_of_stream</strong></a></dt>
380421 <dd class="defbody">
381422 Succeeds after the last character of the current input stream has been
382423 read. Also succeeds if there is no valid current input stream.</dd>
383 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="at_end_of_stream/1"><strong>at_end_of_stream</strong>(<var>+Stream</var>)</a></dt>
424 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="at_end_of_stream/1"><strong>at_end_of_stream</strong>(<var>+Stream</var>)</a></dt>
384425 <dd class="defbody">
385426 Succeeds after the last character of the named stream is read, or
386427 <var>Stream</var> is not a valid input stream. The end-of-stream test is
387428 only available on buffered input streams (unbuffered input streams are
388 rarely used; see <a name="idx:open4:1103"></a><a class="pred" href="IO.html#open/4">open/4</a>).</dd>
389 <dt class="pubdef"><a name="set_end_of_stream/1"><strong>set_end_of_stream</strong>(<var>+Stream</var>)</a></dt>
429 rarely used; see <a id="idx:open4:1103"></a><a class="pred" href="IO.html#open/4">open/4</a>).</dd>
430 <dt class="pubdef"><a id="set_end_of_stream/1"><strong>set_end_of_stream</strong>(<var>+Stream</var>)</a></dt>
390431 <dd class="defbody">
391432 Set the size of the file opened as <var>Stream</var> to the current file
392433 position. This is typically used in combination with the open-mode <code>update</code>.</dd>
393 <dt class="pubdef"><a name="copy_stream_data/3"><strong>copy_stream_data</strong>(<var>+StreamIn,
434 <dt class="pubdef"><a id="copy_stream_data/3"><strong>copy_stream_data</strong>(<var>+StreamIn,
394435 +StreamOut, +Len</var>)</a></dt>
395436 <dd class="defbody">
396437 Copy <var>Len</var> codes from <var>StreamIn</var> to <var>StreamOut</var>.
397 Note that the copy is done using the semantics of <a name="idx:getcode2:1104"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
438 Note that the copy is done using the semantics of <a id="idx:getcode2:1104"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
398439 and
399 <a name="idx:putcode2:1105"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>,
440 <a id="idx:putcode2:1105"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>,
400441 taking care of possibly recoding that needs to take place between two
401 text files. See <a class="sec" href="widechars.html">section 2.19.1</a>.</dd>
402 <dt class="pubdef"><a name="copy_stream_data/2"><strong>copy_stream_data</strong>(<var>+StreamIn,
442 text files. See <a class="sec" href="widechars.html#sec:2.19.1">section
443 2.19.1</a>.</dd>
444 <dt class="pubdef"><a id="copy_stream_data/2"><strong>copy_stream_data</strong>(<var>+StreamIn,
403445 +StreamOut</var>)</a></dt>
404446 <dd class="defbody">
405447 Copy all (remaining) data from <var>StreamIn</var> to
406448 <var>StreamOut</var>.</dd>
407 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="fill_buffer/1"><strong>fill_buffer</strong>(<var>+Stream</var>)</a></dt>
449 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="fill_buffer/1"><strong>fill_buffer</strong>(<var>+Stream</var>)</a></dt>
408450 <dd class="defbody">
409451 Fill the <var>Stream</var>'s input buffer. Subsequent calls try to read
410452 more input until the buffer is completely filled. This predicate is used
411 together with <a name="idx:readpendingcodes3:1106"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>
453 together with <a id="idx:readpendingcodes3:1106"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>
412454 to process input with minimal buffering.</dd>
413 <dt class="pubdef"><a name="read_pending_codes/3"><strong>read_pending_codes</strong>(<var>+StreamIn,
455 <dt class="pubdef"><a id="read_pending_codes/3"><strong>read_pending_codes</strong>(<var>+StreamIn,
414456 -Codes, ?Tail</var>)</a></dt>
415457 <dd class="defbody">
416458 Read input pending in the input buffer of <var>StreamIn</var> and return
425467 input from files and streams using a DCG.
426468
427469 <p>The following code fragment realises efficient non-blocking copying
428 of data from an input to an output stream. The <a name="idx:atendofstream1:1107"></a><a class="pred" href="chario.html#at_end_of_stream/1">at_end_of_stream/1</a>
470 of data from an input to an output stream. The <a id="idx:atendofstream1:1107"></a><a class="pred" href="chario.html#at_end_of_stream/1">at_end_of_stream/1</a>
429471 call checks for end-of-stream and fills the input buffer. Note that the
430 use of a <a name="idx:getcode2:1108"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
431 and <a name="idx:putcode2:1109"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>
432 based loop requires a <a name="idx:flushoutput1:1110"></a><a class="pred" href="chario.html#flush_output/1">flush_output/1</a>
433 call after <em>each</em> <a name="idx:putcode2:1111"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>.
434 The <a name="idx:copystreamdata2:1112"></a><a class="pred" href="chario.html#copy_stream_data/2">copy_stream_data/2</a>
472 use of a <a id="idx:getcode2:1108"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
473 and <a id="idx:putcode2:1109"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>
474 based loop requires a <a id="idx:flushoutput1:1110"></a><a class="pred" href="chario.html#flush_output/1">flush_output/1</a>
475 call after <em>each</em> <a id="idx:putcode2:1111"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>.
476 The <a id="idx:copystreamdata2:1112"></a><a class="pred" href="chario.html#copy_stream_data/2">copy_stream_data/2</a>
435477 does not allow for inspection of the copied data and suffers from the
436478 same buffering issues.
437479
451493 </pre>
452494
453495 </dd>
454 <dt class="pubdef"><a name="read_pending_chars/3"><strong>read_pending_chars</strong>(<var>+StreamIn,
496 <dt class="pubdef"><a id="read_pending_chars/3"><strong>read_pending_chars</strong>(<var>+StreamIn,
455497 -Chars, ?Tail</var>)</a></dt>
456498 <dd class="defbody">
457 As <a name="idx:readpendingcodes3:1113"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>,
499 As <a id="idx:readpendingcodes3:1113"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>,
458500 but returns a difference list of one-character atoms.
459501 </dd>
460502 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="preddesc.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="consulting.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:chars"><a name="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">Character
235 <h2 id="sec:chars"><a id="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">Character
195236 representation</span></a></h2>
196237
197 <a name="sec:chars"></a>
238 <a id="sec:chars"></a>
198239
199240 <p>In traditional (Edinburgh) Prolog, characters are represented using
200241 <em>character codes</em>. Character codes are integer indices into a
204245 8859-1) is applicable to many Western languages.
205246
206247 <p>ISO Prolog introduces three types, two of which are used for
207 characters and one for accessing binary streams (see <a name="idx:open4:340"></a><a class="pred" href="IO.html#open/4">open/4</a>).
248 characters and one for accessing binary streams (see <a id="idx:open4:340"></a><a class="pred" href="IO.html#open/4">open/4</a>).
208249 These types are:
209250
210251 <p>
212253 <li><i>code</i><br>
213254 A <em>character code</em> is an integer representing a single character.
214255 As files may use multi-byte encoding for supporting different character
215 sets (<a name="idx:utf8:341">utf-8</a> encoding for example), reading a
256 sets (<a id="idx:utf8:341">utf-8</a> encoding for example), reading a
216257 code from a text file is in general not the same as reading a byte.
217258 <li><i>char</i><br>
218259 Alternatively, characters may be represented as
224265 </ul>
225266
226267 <p>In SWI-Prolog, character codes are <em>always</em> the Unicode
227 equivalent of the encoding. That is, if <a name="idx:getcode1:342"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
268 equivalent of the encoding. That is, if <a id="idx:getcode1:342"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
228269 reads from a stream encoded as
229270 <code>KOI8-R</code> (used for the Cyrillic alphabet), it returns the
230271 corresponding Unicode code points. Similarly, assembling or
231 disassembling atoms using <a name="idx:atomcodes2:343"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
272 disassembling atoms using <a id="idx:atomcodes2:343"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
232273 interprets the codes as Unicode points. See
233 <a class="sec" href="widechars.html">section 2.19.1</a> for details.
274 <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a> for
275 details.
234276
235277 <p>To ease the pain of the two character representations (code and
236278 char), SWI-Prolog's built-in predicates dealing with character data work
247289
248290 <p>The two character representations are handled by a large number of
249291 built-in predicates, all of which are ISO-compatible. For converting
250 between code and character there is <a name="idx:charcode2:344"></a><a class="pred" href="manipatom.html#char_code/2">char_code/2</a>.
251 For breaking atoms and numbers into characters there are <a name="idx:atomchars2:345"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>, <a name="idx:atomcodes2:346"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>,
252 <a name="idx:numberchars2:347"></a><a class="pred" href="manipatom.html#number_chars/2">number_chars/2</a>
253 and <a name="idx:numbercodes2:348"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>.
292 between code and character there is <a id="idx:charcode2:344"></a><a class="pred" href="manipatom.html#char_code/2">char_code/2</a>.
293 For breaking atoms and numbers into characters there are <a id="idx:atomchars2:345"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>, <a id="idx:atomcodes2:346"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>,
294 <a id="idx:numberchars2:347"></a><a class="pred" href="manipatom.html#number_chars/2">number_chars/2</a>
295 and <a id="idx:numbercodes2:348"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>.
254296 For character I/O on streams there are
255 <a name="idx:getchar12:349"></a><a class="pred" href="chario.html#get_char/1">get_char/[1,2]</a>, <a name="idx:getcode12:350"></a><a class="pred" href="chario.html#get_code/1">get_code/[1,2]</a>, <a name="idx:getbyte12:351"></a><a class="pred" href="chario.html#get_byte/1">get_byte/[1,2]</a>, <a name="idx:peekchar12:352"></a><a class="pred" href="chario.html#peek_char/1">peek_char/[1,2]</a>,
256 <a name="idx:peekcode12:353"></a><a class="pred" href="chario.html#peek_code/1">peek_code/[1,2]</a>, <a name="idx:peekbyte12:354"></a><a class="pred" href="chario.html#peek_byte/1">peek_byte/[1,2]</a>, <a name="idx:putcode12:355"></a><a class="pred" href="chario.html#put_code/1">put_code/[1,2]</a>, <a name="idx:putchar12:356"></a><a class="pred" href="chario.html#put_char/1">put_char/[1,2]</a>
297 <a id="idx:getchar12:349"></a><a class="pred" href="chario.html#get_char/1">get_char/[1,2]</a>, <a id="idx:getcode12:350"></a><a class="pred" href="chario.html#get_code/1">get_code/[1,2]</a>, <a id="idx:getbyte12:351"></a><a class="pred" href="chario.html#get_byte/1">get_byte/[1,2]</a>, <a id="idx:peekchar12:352"></a><a class="pred" href="chario.html#peek_char/1">peek_char/[1,2]</a>,
298 <a id="idx:peekcode12:353"></a><a class="pred" href="chario.html#peek_code/1">peek_code/[1,2]</a>, <a id="idx:peekbyte12:354"></a><a class="pred" href="chario.html#peek_byte/1">peek_byte/[1,2]</a>, <a id="idx:putcode12:355"></a><a class="pred" href="chario.html#put_code/1">put_code/[1,2]</a>, <a id="idx:putchar12:356"></a><a class="pred" href="chario.html#put_char/1">put_char/[1,2]</a>
257299 and
258 <a name="idx:putbyte12:357"></a><a class="pred" href="chario.html#put_byte/1">put_byte/[1,2]</a>.
300 <a id="idx:putbyte12:357"></a><a class="pred" href="chario.html#put_byte/1">put_byte/[1,2]</a>.
259301 The Prolog flag <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>
260302 controls how text between double quotes is interpreted.
261303
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="broadcast.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="check.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:charsio"><a name="sec:A.5"><span class="sec-nr">A.5</span> <span class="sec-title">library(charsio):
235 <h2 id="sec:charsio"><a id="sec:A.5"><span class="sec-nr">A.5</span> <span class="sec-title">library(charsio):
195236 I/O on Lists of Character Codes</span></a></h2>
196237
197 <p><a name="sec:charsio"></a>
238 <p><a id="sec:charsio"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">Compatibility</dt>
211252 can even be replaced by ISO standard predicates.
212253
213254 <dl class="latex">
214 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="format_to_chars/3"><strong>format_to_chars</strong>(<var>+Format,
255 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="format_to_chars/3"><strong>format_to_chars</strong>(<var>+Format,
215256 +Args, -Codes</var>)</a></dt>
216257 <dd class="defbody">
217258 Use <a class="pred" href="format.html#format/2">format/2</a> to write to
218259 a list of character codes.</dd>
219 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="format_to_chars/4"><strong>format_to_chars</strong>(<var>+Format,
260 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="format_to_chars/4"><strong>format_to_chars</strong>(<var>+Format,
220261 +Args, -Codes, ?Tail</var>)</a></dt>
221262 <dd class="defbody">
222263 Use <a class="pred" href="format.html#format/2">format/2</a> to write to
223264 a difference list of character codes.</dd>
224 <dt class="pubdef"><a name="write_to_chars/2"><strong>write_to_chars</strong>(<var>+Term,
265 <dt class="pubdef"><a id="write_to_chars/2"><strong>write_to_chars</strong>(<var>+Term,
225266 -Codes</var>)</a></dt>
226267 <dd class="defbody">
227268 Write a term to a code list. True when <var>Codes</var> is a list of
228269 character codes written by <a class="pred" href="termrw.html#write/1">write/1</a>
229270 on <var>Term</var>.</dd>
230 <dt class="pubdef"><a name="write_to_chars/3"><strong>write_to_chars</strong>(<var>+Term,
271 <dt class="pubdef"><a id="write_to_chars/3"><strong>write_to_chars</strong>(<var>+Term,
231272 -Codes, ?Tail</var>)</a></dt>
232273 <dd class="defbody">
233274 Write a term to a code list. <var>Codes</var><code>\</code><var>Tail</var>
234275 is a difference list of character codes produced by <a class="pred" href="termrw.html#write/1">write/1</a>
235276 on <var>Term</var>.</dd>
236 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="atom_to_chars/2"><strong>atom_to_chars</strong>(<var>+Atom,
277 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="atom_to_chars/2"><strong>atom_to_chars</strong>(<var>+Atom,
237278 -Codes</var>)</a></dt>
238279 <dd class="defbody">
239280 Convert <var>Atom</var> into a list of character codes.
246287 </dl>
247288
248289 </dd>
249 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="atom_to_chars/3"><strong>atom_to_chars</strong>(<var>+Atom,
290 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="atom_to_chars/3"><strong>atom_to_chars</strong>(<var>+Atom,
250291 -Codes, ?Tail</var>)</a></dt>
251292 <dd class="defbody">
252293 Convert <var>Atom</var> into a difference list of character codes.</dd>
253 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="number_to_chars/2"><strong>number_to_chars</strong>(<var>+Number,
294 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="number_to_chars/2"><strong>number_to_chars</strong>(<var>+Number,
254295 -Codes</var>)</a></dt>
255296 <dd class="defbody">
256297 Convert Atom into a list of character codes.
263304 </dl>
264305
265306 </dd>
266 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="number_to_chars/3"><strong>number_to_chars</strong>(<var>+Number,
307 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="number_to_chars/3"><strong>number_to_chars</strong>(<var>+Number,
267308 -Codes, ?Tail</var>)</a></dt>
268309 <dd class="defbody">
269310 Convert <var>Number</var> into a difference list of character codes.</dd>
270 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="read_from_chars/2"><strong>read_from_chars</strong>(<var>+Codes,
311 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="read_from_chars/2"><strong>read_from_chars</strong>(<var>+Codes,
271312 -Term</var>)</a></dt>
272313 <dd class="defbody">
273314 Read <var>Codes</var> into <var>Term</var>.
281322 </dl>
282323
283324 </dd>
284 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="read_term_from_chars/3"><strong>read_term_from_chars</strong>(<var>+Codes,
325 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="read_term_from_chars/3"><strong>read_term_from_chars</strong>(<var>+Codes,
285326 -Term, +Options</var>)</a></dt>
286327 <dd class="defbody">
287328 Read <var>Codes</var> into <var>Term</var>. <var>Options</var> are
295336 </dl>
296337
297338 </dd>
298 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="open_chars_stream/2"><strong>open_chars_stream</strong>(<var>+Codes,
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="open_chars_stream/2"><strong>open_chars_stream</strong>(<var>+Codes,
299340 -Stream</var>)</a></dt>
300341 <dd class="defbody">
301342 Open <var>Codes</var> as an input stream.
308349 </dl>
309350
310351 </dd>
311 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="with_output_to_chars/2"><strong>with_output_to_chars</strong>(<var>:Goal,
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="with_output_to_chars/2"><strong>with_output_to_chars</strong>(<var>:Goal,
312353 -Codes</var>)</a></dt>
313354 <dd class="defbody">
314355 Run <var>Goal</var> as with <a class="pred" href="metacall.html#once/1">once/1</a>.
315356 Output written to <code>current_output</code> is collected in <var>Codes</var>.</dd>
316 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="with_output_to_chars/3"><strong>with_output_to_chars</strong>(<var>:Goal,
357 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="with_output_to_chars/3"><strong>with_output_to_chars</strong>(<var>:Goal,
317358 -Codes, ?Tail</var>)</a></dt>
318359 <dd class="defbody">
319360 Run <var>Goal</var> as with <a class="pred" href="metacall.html#once/1">once/1</a>.
320361 Output written to <code>current_output</code> is collected in <var>Codes</var><code>\</code><var>Tail</var>.</dd>
321 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="with_output_to_chars/4"><strong>with_output_to_chars</strong>(<var>:Goal,
362 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="with_output_to_chars/4"><strong>with_output_to_chars</strong>(<var>:Goal,
322363 -Stream, -Codes, ?Tail</var>)</a></dt>
323364 <dd class="defbody">
324365 Same as <a class="pred" href="charsio.html#with_output_to_chars/3">with_output_to_chars/3</a>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.24</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.24</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="locale.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="operators.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:chartype"><a name="sec:4.24"><span class="sec-nr">4.24</span> <span class="sec-title">Character
235 <h2 id="sec:chartype"><a id="sec:4.24"><span class="sec-nr">4.24</span> <span class="sec-title">Character
195236 properties</span></a></h2>
196237
197 <a name="sec:chartype"></a>
238 <a id="sec:chartype"></a>
198239
199240 <p>SWI-Prolog offers two comprehensive predicates for classifying
200241 characters and character codes. These predicates are defined as built-in
204245
205246 <p>In addition, there is the library <code>library(ctypes)</code>
206247 providing compatibility with some other Prolog systems. The predicates
207 of this library are defined in terms of <a name="idx:codetype2:1292"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>.
248 of this library are defined in terms of <a id="idx:codetype2:1292"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>.
208249
209250 <dl class="latex">
210 <dt class="pubdef"><a name="char_type/2"><strong>char_type</strong>(<var>?Char,
251 <dt class="pubdef"><a id="char_type/2"><strong>char_type</strong>(<var>?Char,
211252 ?Type</var>)</a></dt>
212253 <dd class="defbody">
213254 Tests or generates alternative <var>Type</var>s or <var>Char</var>s. The
285326 <dd class="defbody">
286327 <var>Char</var> is a lowercase version of <var>Upper</var>. For
287328 non-letters, or letter without case, <var>Char</var> and <var>Lower</var>
288 are the same. See also <a name="idx:upcaseatom2:1293"></a><a class="pred" href="chartype.html#upcase_atom/2">upcase_atom/2</a>
289 and <a name="idx:downcaseatom2:1294"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>.
329 are the same. See also <a id="idx:upcaseatom2:1293"></a><a class="pred" href="chartype.html#upcase_atom/2">upcase_atom/2</a>
330 and <a id="idx:downcaseatom2:1294"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>.
290331 </dd>
291332 <dt><strong>upper</strong></dt>
292333 <dd class="defbody">
302343 <dd class="defbody">
303344 <var>Char</var> is an uppercase version of <var>Lower</var>. For
304345 non-letters, or letter without case, <var>Char</var> and <var>Lower</var>
305 are the same. See also <a name="idx:upcaseatom2:1295"></a><a class="pred" href="chartype.html#upcase_atom/2">upcase_atom/2</a>
306 and <a name="idx:downcaseatom2:1296"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>.
346 are the same. See also <a id="idx:upcaseatom2:1295"></a><a class="pred" href="chartype.html#upcase_atom/2">upcase_atom/2</a>
347 and <a id="idx:downcaseatom2:1296"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>.
307348 </dd>
308349 <dt><strong>punct</strong></dt>
309350 <dd class="defbody">
361402 </dl>
362403
363404 </dd>
364 <dt class="pubdef"><a name="code_type/2"><strong>code_type</strong>(<var>?Code,
405 <dt class="pubdef"><a id="code_type/2"><strong>code_type</strong>(<var>?Code,
365406 ?Type</var>)</a></dt>
366407 <dd class="defbody">
367 As <a name="idx:chartype2:1297"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>,
408 As <a id="idx:chartype2:1297"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>,
368409 but uses character codes rather than one-character atoms. Please note
369410 that both predicates are as flexible as possible. They handle either
370411 representation if the argument is instantiated and will instantiate only
371412 with an integer code or a one-character atom, depending of the version
372413 used. See also the Prolog flag
373 <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>, <a name="idx:atomchars2:1298"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
374 and <a name="idx:atomcodes2:1299"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.
414 <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>, <a id="idx:atomchars2:1298"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
415 and <a id="idx:atomcodes2:1299"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.
375416 </dd>
376417 </dl>
377418
378 <p><h3 id="sec:case"><a name="sec:4.24.1"><span class="sec-nr">4.24.1</span> <span class="sec-title">Case
419 <p><h3 id="sec:case"><a id="sec:4.24.1"><span class="sec-nr">4.24.1</span> <span class="sec-title">Case
379420 conversion</span></a></h3>
380421
381 <a name="sec:case"></a>
422 <a id="sec:case"></a>
382423
383424 <p>There is nothing in the Prolog standard for converting case in
384 textual data. The SWI-Prolog predicates <a name="idx:codetype2:1300"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>
385 and <a name="idx:chartype2:1301"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
425 textual data. The SWI-Prolog predicates <a id="idx:codetype2:1300"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>
426 and <a id="idx:chartype2:1301"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
386427 can be used to test and convert individual characters. We have started
387428 some additional support:
388429
389430 <dl class="latex">
390 <dt class="pubdef"><a name="downcase_atom/2"><strong>downcase_atom</strong>(<var>+AnyCase,
431 <dt class="pubdef"><a id="downcase_atom/2"><strong>downcase_atom</strong>(<var>+AnyCase,
391432 -LowerCase</var>)</a></dt>
392433 <dd class="defbody">
393 Converts the characters of <var>AnyCase</var> into lowercase as <a name="idx:chartype2:1302"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
434 Converts the characters of <var>AnyCase</var> into lowercase as <a id="idx:chartype2:1302"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
394435 does (i.e. based on the defined <em>locale</em> if Prolog provides
395436 locale support on the hosting platform) and unifies the lowercase atom
396437 with <var>LowerCase</var>.</dd>
397 <dt class="pubdef"><a name="upcase_atom/2"><strong>upcase_atom</strong>(<var>+AnyCase,
438 <dt class="pubdef"><a id="upcase_atom/2"><strong>upcase_atom</strong>(<var>+AnyCase,
398439 -UpperCase</var>)</a></dt>
399440 <dd class="defbody">
400 Converts, similar to <a name="idx:downcaseatom2:1303"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>,
441 Converts, similar to <a id="idx:downcaseatom2:1303"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>,
401442 an atom to uppercase.
402443 </dd>
403444 </dl>
404445
405 <p><h3 id="sec:whitespace"><a name="sec:4.24.2"><span class="sec-nr">4.24.2</span> <span class="sec-title">White
446 <p><h3 id="sec:whitespace"><a id="sec:4.24.2"><span class="sec-nr">4.24.2</span> <span class="sec-title">White
406447 space normalization</span></a></h3>
407448
408 <a name="sec:whitespace"></a>
449 <a id="sec:whitespace"></a>
409450
410451 <dl class="latex">
411 <dt class="pubdef"><a name="normalize_space/2"><strong>normalize_space</strong>(<var>-Out,
452 <dt class="pubdef"><a id="normalize_space/2"><strong>normalize_space</strong>(<var>-Out,
412453 +In</var>)</a></dt>
413454 <dd class="defbody">
414455 Normalize white space in <var>In</var>. All leading and trailing white
415456 space is removed. All non-empty sequences for Unicode white space
416457 characters are replaced by a single space (<code>\u0020</code>)
417 character. <var>Out</var> uses the same conventions as <a name="idx:withoutputto2:1304"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
418 and <a name="idx:format3:1305"></a><a class="pred" href="format.html#format/3">format/3</a>.
458 character. <var>Out</var> uses the same conventions as <a id="idx:withoutputto2:1304"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
459 and <a id="idx:format3:1305"></a><a class="pred" href="format.html#format/3">format/3</a>.
419460 </dd>
420461 </dl>
421462
422 <p><h3 id="sec:collate"><a name="sec:4.24.3"><span class="sec-nr">4.24.3</span> <span class="sec-title">Language-specific
463 <p><h3 id="sec:collate"><a id="sec:4.24.3"><span class="sec-nr">4.24.3</span> <span class="sec-title">Language-specific
423464 comparison</span></a></h3>
424465
425 <a name="sec:collate"></a>
426
427 <p><a name="idx:locale:1306"></a><a name="idx:collate:1307"></a><a name="idx:comparelanguagespecific:1308"></a>This
466 <a id="sec:collate"></a>
467
468 <p><a id="idx:locale:1306"></a><a id="idx:collate:1307"></a><a id="idx:comparelanguagespecific:1308"></a>This
428469 section deals with predicates for language-specific string comparison
429470 operations.
430471
431472 <dl class="latex">
432 <dt class="pubdef"><a name="collation_key/2"><strong>collation_key</strong>(<var>+Atom,
473 <dt class="pubdef"><a id="collation_key/2"><strong>collation_key</strong>(<var>+Atom,
433474 -Key</var>)</a></dt>
434475 <dd class="defbody">
435476 Create a <var>Key</var> from <var>Atom</var> for locale-specific
438479 is alphabetically smaller than <var>B</var> using the sort order of the
439480 current locale.
440481
441 <p>The predicate <a name="idx:collationkey2:1309"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
442 is used by <a name="idx:localesort2:1310"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
443 from library(sort). Please examine the implementation of <a name="idx:localesort2:1311"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
482 <p>The predicate <a id="idx:collationkey2:1309"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
483 is used by <a id="idx:localesort2:1310"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
484 from library(sort). Please examine the implementation of <a id="idx:localesort2:1311"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
444485 as an example of using this call.
445486
446487 <p>The <var>Key</var> is an implementation-defined and generally
447488 unreadable string. On systems that do not support locale handling, <var>Key</var>
448489 is simply unified with <var>Atom</var>.</dd>
449 <dt class="pubdef"><a name="locale_sort/2"><strong>locale_sort</strong>(<var>+List,
490 <dt class="pubdef"><a id="locale_sort/2"><strong>locale_sort</strong>(<var>+List,
450491 -Sorted</var>)</a></dt>
451492 <dd class="defbody">
452493 Sort a list of atoms using the current locale. <var>List</var> is a list
453 of atoms or string objects (see <a class="sec" href="strings.html">section
494 of atoms or string objects (see <a class="sec" href="strings.html#sec:5.2">section
454495 5.2</a>). <var>Sorted</var> is unified with a list containing all atoms
455 of <var>List</var>, sorted to the rules of the current locale. See also <a name="idx:collationkey2:1312"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
496 of <var>List</var>, sorted to the rules of the current locale. See also <a id="idx:collationkey2:1312"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
456497 and
457 <a name="idx:setlocale3:1313"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>.
498 <a id="idx:setlocale3:1313"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>.
458499 </dd>
459500 </dl>
460501
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="charsio.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="clpb.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:check"><a name="sec:A.6"><span class="sec-nr">A.6</span> <span class="sec-title">library(check):
235 <h2 id="sec:check"><a id="sec:A.6"><span class="sec-nr">A.6</span> <span class="sec-title">library(check):
195236 Consistency checking</span></a></h2>
196237
197 <p><a name="sec:check"></a>
238 <p><a id="sec:check"></a>
198239
199240 <dl class="tags">
200241 <dt class="mtag">See also</dt>
214255 to find undefined predicates in `user' modules.
215256
216257 <dl class="latex">
217 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="check/0"><strong>check</strong></a></dt>
258 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="check/0"><strong>check</strong></a></dt>
218259 <dd class="defbody">
219260 Run all consistency checks defined by <a class="pred" href="check.html#checker/2">checker/2</a>.
220261 Checks enabled by default are:
233274 lists predicates that will be defined at runtime using the autoloader.
234275 </ul>
235276 </dd>
236 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_undefined/0"><strong>list_undefined</strong></a></dt>
237 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_undefined/1"><strong>list_undefined</strong>(<var>+Options</var>)</a></dt>
277 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_undefined/0"><strong>list_undefined</strong></a></dt>
278 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_undefined/1"><strong>list_undefined</strong>(<var>+Options</var>)</a></dt>
238279 <dd class="defbody">
239280 Report undefined predicates. This predicate finds undefined predciates
240281 by decompiling and analyzing the body of all clauses.
259300 </dl>
260301
261302 </dd>
262 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_autoload/0"><strong>list_autoload</strong></a></dt>
303 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_autoload/0"><strong>list_autoload</strong></a></dt>
263304 <dd class="defbody">
264305 Report predicates that may be auto-loaded. These are predicates that are
265306 not defined, but will be loaded on demand if referenced.
277318 </dl>
278319
279320 </dd>
280 <dt class="pubdef"><a name="list_redefined/0"><strong>list_redefined</strong></a></dt>
321 <dt class="pubdef"><a id="list_redefined/0"><strong>list_redefined</strong></a></dt>
281322 <dd class="defbody">
282323 Lists predicates that are defined in the global module <code>user</code>
283324 as well as in a normal module; that is, predicates for which the local
284325 definition overrules the global default definition.</dd>
285 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_void_declarations/0"><strong>list_void_declarations</strong></a></dt>
326 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_void_declarations/0"><strong>list_void_declarations</strong></a></dt>
286327 <dd class="defbody">
287328 List predicates that have declared attributes, but no clauses.</dd>
288 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_trivial_fails/0"><strong>list_trivial_fails</strong></a></dt>
289 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_trivial_fails/1"><strong>list_trivial_fails</strong>(<var>+Options</var>)</a></dt>
329 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_trivial_fails/0"><strong>list_trivial_fails</strong></a></dt>
330 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_trivial_fails/1"><strong>list_trivial_fails</strong>(<var>+Options</var>)</a></dt>
290331 <dd class="defbody">
291332 List goals that trivially fail because there is no matching clause. <var>Options</var>:
292333
300341 </dl>
301342
302343 </dd>
303 <dt class="multidef"><span class="pred-tag">[multifile]</span><a name="trivial_fail_goal/1"><strong>trivial_fail_goal</strong>(<var>:Goal</var>)</a></dt>
344 <dt class="multidef"><span class="pred-tag">[multifile]</span><a id="trivial_fail_goal/1"><strong>trivial_fail_goal</strong>(<var>:Goal</var>)</a></dt>
304345 <dd class="defbody">
305346 Multifile hook that tells <a class="pred" href="check.html#list_trivial_fails/0">list_trivial_fails/0</a>
306347 to accept <var>Goal</var> as valid.</dd>
307 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_strings/0"><strong>list_strings</strong></a></dt>
308 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_strings/1"><strong>list_strings</strong>(<var>+Options</var>)</a></dt>
348 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_strings/0"><strong>list_strings</strong></a></dt>
349 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_strings/1"><strong>list_strings</strong>(<var>+Options</var>)</a></dt>
309350 <dd class="defbody">
310351 List strings that appear in clauses. This predicate is used to find
311352 portability issues for changing the Prolog flag
329370 </dl>
330371
331372 </dd>
332 <dt class="multidef"><span class="pred-tag">[multifile]</span><a name="string_predicate/1"><strong>string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
373 <dt class="multidef"><span class="pred-tag">[multifile]</span><a id="string_predicate/1"><strong>string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
333374 <dd class="defbody">
334375 Multifile hook to disable <a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
335376 on the given predicate. This is typically used for facts that store
336377 strings.</dd>
337 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="valid_string_goal/1"><strong>valid_string_goal</strong>(<var>+Goal</var>)</a></dt>
378 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="valid_string_goal/1"><strong>valid_string_goal</strong>(<var>+Goal</var>)</a></dt>
338379 <dd class="defbody">
339380 Multifile hook that qualifies <var>Goal</var> as valid for <a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
340381 For example, <code>format("Hello world~n")</code> is considered proper
341382 use of string constants.</dd>
342 <dt class="multidef"><span class="pred-tag">[multifile]</span><a name="checker/2"><strong>checker</strong>(<var>:Goal,
383 <dt class="multidef"><span class="pred-tag">[multifile]</span><a id="checker/2"><strong>checker</strong>(<var>:Goal,
343384 +Message:text</var>)</a></dt>
344385 <dd class="defbody">
345386 Register code validation routines. Each clause defines a <var>Goal</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="coroutining.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="chrintro.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:chr"><a name="sec:8"><span class="sec-nr">8</span> <span class="sec-title">CHR:
235 <h1 id="sec:chr"><a id="sec:8"><span class="sec-nr">8</span> <span class="sec-title">CHR:
195236 Constraint Handling Rules</span></a></h1>
196237
197 <a name="sec:chr"></a>
238 <a id="sec:chr"></a>
198239
199240 <p>This chapter is written by Tom Schrijvers, K.U. Leuven, and
200241 adjustments by Jan Wielemaker.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="chr.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="SyntaxAndSemantics.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:chrintro"><a name="sec:8.1"><span class="sec-nr">8.1</span> <span class="sec-title">Introduction</span></a></h2>
195
196 <a name="sec:chrintro"></a> Constraint Handling Rules (CHR) is a
235 <h2 id="sec:chrintro"><a id="sec:8.1"><span class="sec-nr">8.1</span> <span class="sec-title">Introduction</span></a></h2>
236
237 <a id="sec:chrintro"></a> Constraint Handling Rules (CHR) is a
197238 committed-choice rule-based language embedded in Prolog. It is designed
198239 for writing constraint solvers and is particularly useful for providing
199240 application-specific constraints. It has been used in many kinds of
211252 2009</a></cite>. More background on CHR can be found at
212253 <cite><a class="cite" href="Bibliography.html#chrSite">Fr&uuml;hwirth,</a></cite>.
213254
214 <p>In <a class="sec" href="SyntaxAndSemantics.html">section 8.2</a> we
215 present the syntax of CHR in Prolog and explain informally its
216 operational semantics. Next, <a class="sec" href="practical.html">section
255 <p>In <a class="sec" href="SyntaxAndSemantics.html#sec:8.2">section 8.2</a>
256 we present the syntax of CHR in Prolog and explain informally its
257 operational semantics. Next, <a class="sec" href="practical.html#sec:8.3">section
217258 8.3</a> deals with practical issues of writing and compiling Prolog
218 programs containing CHR. <a class="sec" href="debugging.html">Section
219 8.4</a> explains the (currently primitive) CHR debugging facilities. <a class="sec" href="debugging.html">Section
259 programs containing CHR. <a class="sec" href="debugging.html#sec:8.4">Section
260 8.4</a> explains the (currently primitive) CHR debugging facilities. <a class="sec" href="debugging.html#sec:8.4.3">Section
220261 8.4.3</a> provides a few useful predicates to inspect the constraint
221 store, and <a class="sec" href="examples.html">section 8.5</a>
222 illustrates CHR with two example programs. <a class="sec" href="sicstus-chr.html">Section
262 store, and <a class="sec" href="examples.html#sec:8.5">section 8.5</a>
263 illustrates CHR with two example programs. <a class="sec" href="sicstus-chr.html#sec:8.6">Section
223264 8.6</a> describes some compatibility issues with older versions of this
224 system and SICStus' CHR system. Finally, <a class="sec" href="guidelines.html">section
265 system and SICStus' CHR system. Finally, <a class="sec" href="guidelines.html#sec:8.7">section
225266 8.7</a> concludes with a few practical guidelines for using CHR.
226267
227268 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="modulecompat.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="attvar.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:clp"><a name="sec:7"><span class="sec-nr">7</span> <span class="sec-title">Constraint
235 <h1 id="sec:clp"><a id="sec:7"><span class="sec-nr">7</span> <span class="sec-title">Constraint
195236 Logic Programming</span></a></h1>
196237
197 <a name="sec:clp"></a>
198 <a name="idx:CLP:1759"></a><a name="idx:constraintprogramming:1760"></a>This
238 <a id="sec:clp"></a>
239 <a id="idx:CLP:1763"></a><a id="idx:constraintprogramming:1764"></a>This
199240 chapter describes the extensions primarily designed to support
200241 <b>constraint logic programming</b>&nbsp;(CLP), an important declarative
201242 programming paradigm with countless practical applications.
203244 <p>CLP(<var>X</var>) stands for constraint logic programming over the
204245 domain&nbsp;<var>X</var>. Plain Prolog can be regarded as&nbsp;CLP(<var>H</var>),
205246 where <var>H</var> stands for
206 <i>Herbrand&nbsp;terms</i><a name="idx:Herbrandterm:1761"></a>. Over
207 this domain,
208 <a class="pred" href="compare.html#=/2">=/2</a> and <a name="idx:dif2:1762"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
247 <i>Herbrand&nbsp;terms</i><a id="idx:Herbrandterm:1765"></a>. Over this
248 domain,
249 <a class="pred" href="compare.html#=/2">=/2</a> and <a id="idx:dif2:1766"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
209250 are the most important constraints that express, respectively, equality
210251 and disequality of&nbsp;terms. Plain Prolog can thus be regarded as a
211252 special&nbsp;case of&nbsp;CLP.
214255
215256 <p>
216257 <ul class="latex">
217 <li>CLP(FD) for <b>integers</b> (<a class="sec" href="clpfd.html">section
258 <li>CLP(FD) for <b>integers</b> (<a class="sec" href="clpfd.html#sec:A.8">section
218259 A.8</a>)
219 <li>CLP(B) for <b>Boolean</b> variables (<a class="sec" href="clpb.html">section
260 <li>CLP(B) for <b>Boolean</b> variables (<a class="sec" href="clpb.html#sec:A.7">section
220261 A.7</a>)
221 <li>CLP(Q) for <b>rational</b> numbers (<a class="sec" href="clpqr.html">section
262 <li>CLP(Q) for <b>rational</b> numbers (<a class="sec" href="clpqr.html#sec:A.9">section
222263 A.9</a>)
223 <li>CLP(R) for <b>floating point</b> numbers (<a class="sec" href="clpqr.html">section
264 <li>CLP(R) for <b>floating point</b> numbers (<a class="sec" href="clpqr.html#sec:A.9">section
224265 A.9</a>).
225266 </ul>
226267
227 <p>In addition, CHR (<a class="sec" href="chr.html">chapter 8</a>)
268 <p>In addition, CHR (<a class="sec" href="chr.html#sec:8">chapter 8</a>)
228269 provides a general purpose constraint handling language to reason over
229270 user-defined constraints.
230271
246287 it, both <i>before</i> and also <i>during</i> any search for concrete
247288 solutions. Using available information to prune parts of the search
248289 space is called constraint
249 <em>propagation</em><a name="idx:propagation:1763"></a>, and it is
290 <em>propagation</em><a id="idx:propagation:1767"></a>, and it is
250291 performed automatically by the available constraint solvers for their
251292 respective domains. This feature can significantly increase the
252293 <i>performance</i> of your programs.
264305 the constraint solver combines the existing knowledge to infer that <var>X</var>
265306 is either 1 or&nbsp;2 (see below). To obtain concrete values for&nbsp;<var>X</var>,
266307 you can ask the solver to <em>label</em>&nbsp;<var>X</var> and produce 1
267 and 2 on backtracking. See&nbsp;<a class="sec" href="clpfd.html">section
308 and 2 on backtracking. See&nbsp;<a class="sec" href="clpfd.html#sec:A.8">section
268309 A.8</a>.
269310
270311 <pre class="code">
288329 two-dimensional space.
289330
290331 <p>Using constraints therefore makes your program more
291 <em>declarative</em><a name="idx:declarative:1764"></a> in that it frees
332 <em>declarative</em><a id="idx:declarative:1768"></a> in that it frees
292333 you from some procedural aspects and limitations of Prolog.
293334
294335 <p>When working with constraints, keep in mind the following:
300341 goal that is delayed may prematurely prune the search space, because the
301342 truth of delayed goals is not yet established. There are several ways to
302343 avoid cuts in constraint logic programs, retaining both generality and
303 determinism of your programs. See for example <a name="idx:zcompare3:1765"></a><a class="pred" href="clpfd.html#zcompare/3">zcompare/3</a>.
304 <li>Term-copying operations (<a name="idx:assertz1:1766"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:retract1:1767"></a><a class="pred" href="db.html#retract/1">retract/1</a>, <a name="idx:findall3:1768"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
305 <a name="idx:copyterm2:1769"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
344 determinism of your programs. See for example <a id="idx:zcompare3:1769"></a><a class="pred" href="clpfd.html#zcompare/3">zcompare/3</a>.
345 <li>Term-copying operations (<a id="idx:assertz1:1770"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a id="idx:retract1:1771"></a><a class="pred" href="db.html#retract/1">retract/1</a>, <a id="idx:findall3:1772"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
346 <a id="idx:copyterm2:1773"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
306347 etc.) generally also copy constraints. The effect varies from ok, silent
307348 copying of huge constraint networks to violations of the internal
308349 consistency of constraint networks. As a rule of thumb, copying terms
309350 holding attributes must be deprecated. If you need to reason about a
310 term that is involved in constraints, use <a name="idx:copyterm3:1770"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>
351 term that is involved in constraints, use <a id="idx:copyterm3:1774"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>
311352 to obtain the constraints as Prolog goals, and use these goals for
312353 further processing.
313354 </ul>
314355
315356 <p>All of the mentioned constraint solvers are implemented using the
316 attributed variables interface described in&nbsp;<a class="sec" href="attvar.html">section
357 attributed variables interface described in&nbsp;<a class="sec" href="attvar.html#sec:7.1">section
317358 7.1</a>. These are lower-level predicates that are mainly intended for
318359 library authors, not for typical Prolog programmers.
319360
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="check.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="clpfd.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:clpb"><a name="sec:A.7"><span class="sec-nr">A.7</span> <span class="sec-title">library(clpb):
235 <h2 id="sec:clpb"><a id="sec:A.7"><span class="sec-nr">A.7</span> <span class="sec-title">library(clpb):
195236 CLP(B): Constraint Logic Programming over Boolean Variables</span></a></h2>
196237
197 <a name="sec:clpb"></a>
198
199 <p><a name="sec:clpb"></a>
238 <a id="sec:clpb"></a>
239
240 <p><a id="sec:clpb"></a>
200241
201242 <dl class="tags">
202243 <dt class="tag">author</dt>
203244 <dd>
204 https://www.metalevel.atMarkus Triska
245 <a class="url" href="https://www.metalevel.at">Markus Triska</a>
205246 </dd>
206247 </dl>
207248
208 <p><h3 id="sec:clpb-intro"><a name="sec:A.7.1"><span class="sec-nr">A.7.1</span> <span class="sec-title">Introduction</span></a></h3>
209
210 <p><a name="sec:clpb-intro"></a>
249 <p><h3 id="sec:clpb-intro"><a id="sec:A.7.1"><span class="sec-nr">A.7.1</span> <span class="sec-title">Introduction</span></a></h3>
250
251 <p><a id="sec:clpb-intro"></a>
211252
212253 <p>This library provides CLP(B), Constraint Logic Programming over
213254 Boolean variables. It can be used to model and solve combinatorial
214255 problems such as verification, allocation and covering tasks.
215256
216 <p>CLP(B) is an instance of the general CLP(<i>X</i>) scheme (<a class="sec" href="clp.html">section
257 <p>CLP(B) is an instance of the general CLP(<i>X</i>) scheme (<a class="sec" href="clp.html#sec:7">section
217258 7</a>), extending logic programming with reasoning over specialised
218259 domains.
219260
221262 Diagrams (BDDs).
222263
223264 <p>Benchmarks and usage examples of this library are available from:
224 https://www.metalevel.at/clpb/<b>https:<code>//</code>www.metalevel.at/clpb/</b>
265 <a class="url" href="https://www.metalevel.at/clpb/"><b>https:<code>//</code>www.metalevel.at/clpb/</b></a>
225266
226267 <p>We recommend the following reference for citing this library in
227268 scientific publications:
240281 </pre>
241282
242283 <p>The paper is available from
243 https://www.metalevel.at/swiclpb.pdfhttps:<code>//</code>www.metalevel.at/swiclpb.pdf
244
245 <p><h3 id="sec:clpb-exprs"><a name="sec:A.7.2"><span class="sec-nr">A.7.2</span> <span class="sec-title">Boolean
284 <a class="url" href="https://www.metalevel.at/swiclpb.pdf">https:<code>//</code>www.metalevel.at/swiclpb.pdf</a>
285
286 <p><h3 id="sec:clpb-exprs"><a id="sec:A.7.2"><span class="sec-nr">A.7.2</span> <span class="sec-title">Boolean
246287 expressions</span></a></h3>
247288
248 <p><a name="sec:clpb-exprs"></a>
289 <p><a id="sec:clpb-exprs"></a>
249290
250291 <p>A <i>Boolean expression</i> is one of:
251292 <blockquote>
252 <table border="2" frame="box" rules="groups">
253 <tr valign="top"><td><code>0</code> </td><td>false </td></tr>
254 <tr valign="top"><td><code>1</code> </td><td>true </td></tr>
255 <tr valign="top"><td><i>variable</i> </td><td>unknown truth value </td></tr>
256 <tr valign="top"><td><i>atom</i> </td><td>universally quantified
257 variable </td></tr>
258 <tr valign="top"><td><code>~</code> <i>Expr</i> </td><td>logical NOT </td></tr>
259 <tr valign="top"><td><i>Expr</i> + <i>Expr</i> </td><td>logical OR </td></tr>
260 <tr valign="top"><td><i>Expr</i> * <i>Expr</i> </td><td>logical AND </td></tr>
261 <tr valign="top"><td><i>Expr</i> # <i>Expr</i> </td><td>exclusive OR </td></tr>
262 <tr valign="top"><td><i>Var</i> <code>^</code> <i>Expr</i> </td><td>existential
293 <table class="latex frame-box">
294 <tr><td><code>0</code> </td><td>false </td></tr>
295 <tr><td><code>1</code> </td><td>true </td></tr>
296 <tr><td><i>variable</i> </td><td>unknown truth value </td></tr>
297 <tr><td><i>atom</i> </td><td>universally quantified variable </td></tr>
298 <tr><td><code>~</code> <i>Expr</i> </td><td>logical NOT </td></tr>
299 <tr><td><i>Expr</i> + <i>Expr</i> </td><td>logical OR </td></tr>
300 <tr><td><i>Expr</i> * <i>Expr</i> </td><td>logical AND </td></tr>
301 <tr><td><i>Expr</i> # <i>Expr</i> </td><td>exclusive OR </td></tr>
302 <tr><td><i>Var</i> <code>^</code> <i>Expr</i> </td><td>existential
263303 quantification </td></tr>
264 <tr valign="top"><td><i>Expr</i> <code>=:=</code> <i>Expr</i> </td><td>equality </td></tr>
265 <tr valign="top"><td><i>Expr</i> <code>=\=</code> <i>Expr</i> </td><td>disequality
304 <tr><td><i>Expr</i> <code>=:=</code> <i>Expr</i> </td><td>equality </td></tr>
305 <tr><td><i>Expr</i> <code>=\=</code> <i>Expr</i> </td><td>disequality
266306 (same as #) </td></tr>
267 <tr valign="top"><td><i>Expr</i> <code>=&lt;</code> <i>Expr</i> </td><td>less
268 or equal (implication) </td></tr>
269 <tr valign="top"><td><i>Expr</i> <code>&gt;=</code> <i>Expr</i> </td><td>greater
270 or equal </td></tr>
271 <tr valign="top"><td><i>Expr</i> <var>&lt;</var> <i>Expr</i> </td><td>less
272 than </td></tr>
273 <tr valign="top"><td><i>Expr</i> <var>&gt;</var> <i>Expr</i> </td><td>greater
274 than </td></tr>
275 <tr valign="top"><td><code>card(Is,Exprs)</code> </td><td><i>see below</i> </td></tr>
276 <tr valign="top"><td><code>+(Exprs)</code> </td><td><i>see below</i> </td></tr>
277 <tr valign="top"><td><code>*(Exprs)</code> </td><td><i>see below</i> </td></tr>
307 <tr><td><i>Expr</i> <code>=&lt;</code> <i>Expr</i> </td><td>less or
308 equal (implication) </td></tr>
309 <tr><td><i>Expr</i> <code>&gt;=</code> <i>Expr</i> </td><td>greater or
310 equal </td></tr>
311 <tr><td><i>Expr</i> <var>&lt;</var> <i>Expr</i> </td><td>less than </td></tr>
312 <tr><td><i>Expr</i> <var>&gt;</var> <i>Expr</i> </td><td>greater than </td></tr>
313 <tr><td><code>card(Is,Exprs)</code> </td><td><i>see below</i> </td></tr>
314 <tr><td><code>+(Exprs)</code> </td><td><i>see below</i> </td></tr>
315 <tr><td><code>*(Exprs)</code> </td><td><i>see below</i> </td></tr>
278316 </table>
279317 </blockquote>
280318
294332 appear on the right-hand side of equations. Therefore, they can be used
295333 to express functional dependencies on input variables.
296334
297 <p><h3 id="sec:clpb-interface"><a name="sec:A.7.3"><span class="sec-nr">A.7.3</span> <span class="sec-title">Interface
335 <p><h3 id="sec:clpb-interface"><a id="sec:A.7.3"><span class="sec-nr">A.7.3</span> <span class="sec-title">Interface
298336 predicates</span></a></h3>
299337
300 <p><a name="sec:clpb-interface"></a>
338 <p><a id="sec:clpb-interface"></a>
301339
302340 <p>The most frequently used CLP(B) predicates are:
303341
323361 <p>The unification of a CLP(B) variable <i>X</i> with a term <i>T</i> is
324362 equivalent to posting the constraint <code>sat(X=:=T)</code>.
325363
326 <p><h3 id="sec:clpb-examples"><a name="sec:A.7.4"><span class="sec-nr">A.7.4</span> <span class="sec-title">Examples</span></a></h3>
327
328 <p><a name="sec:clpb-examples"></a>
364 <p><h3 id="sec:clpb-examples"><a id="sec:A.7.4"><span class="sec-nr">A.7.4</span> <span class="sec-title">Examples</span></a></h3>
365
366 <p><a id="sec:clpb-examples"></a>
329367
330368 <p>Here is an example session with a few queries and their answers:
331369
366404 last example illustrates that when applicable, remaining variables are
367405 expressed as functions of universally quantified variables.
368406
369 <p><h3 id="sec:clpb-residual-goals"><a name="sec:A.7.5"><span class="sec-nr">A.7.5</span> <span class="sec-title">Obtaining
407 <p><h3 id="sec:clpb-residual-goals"><a id="sec:A.7.5"><span class="sec-nr">A.7.5</span> <span class="sec-title">Obtaining
370408 BDDs</span></a></h3>
371409
372 <p><a name="sec:clpb-residual-goals"></a>
410 <p><a id="sec:clpb-residual-goals"></a>
373411
374412 <p>By default, CLP(B) residual goals appear in (approximately) algebraic
375413 normal form (ANF). This projection is often computationally expensive.
403441 node(2)- (v(X, 1)-&gt;false;true).
404442 </pre>
405443
406 <p><h3 id="sec:clpb-monotonic"><a name="sec:A.7.6"><span class="sec-nr">A.7.6</span> <span class="sec-title">Enabling
444 <p><h3 id="sec:clpb-monotonic"><a id="sec:A.7.6"><span class="sec-nr">A.7.6</span> <span class="sec-title">Enabling
407445 monotonic CLP(B)</span></a></h3>
408446
409 <p><a name="sec:clpb-monotonic"></a>
447 <p><a id="sec:clpb-monotonic"></a>
410448
411449 <p>In the default execution mode, CLP(B) constraints are <i>not</i>
412450 monotonic. This means that <i>adding</i> constraints can yield new
421459 </pre>
422460
423461 <p>This behaviour is highly problematic from a logical point of view,
424 and it may render https://www.metalevel.at/prolog/debugging<b>declarative
425 debugging</b> techniques inapplicable.
462 and it may render <a class="url" href="https://www.metalevel.at/prolog/debugging"><b>declarative
463 debugging</b></a> techniques inapplicable.
426464
427465 <p>Set the flag <code>clpb_monotonic</code> to <code>true</code> to make
428466 CLP(B) <b>monotonic</b>. If this mode is enabled, then you must wrap
436474 X = 0.
437475 </pre>
438476
439 <p><h3 id="sec:clpb-pigeons"><a name="sec:A.7.7"><span class="sec-nr">A.7.7</span> <span class="sec-title">Example:
477 <p><h3 id="sec:clpb-pigeons"><a id="sec:A.7.7"><span class="sec-nr">A.7.7</span> <span class="sec-title">Example:
440478 Pigeons</span></a></h3>
441479
442 <p><a name="sec:clpb-pigeons"></a>
480 <p><a id="sec:clpb-pigeons"></a>
443481
444482 <p>In this example, we are attempting to place <i>I</i> pigeons into <i>J</i>
445483 holes in such a way that each hole contains at most one pigeon. One
448486 interesting aspect is that this task has no short resolution refutations
449487 in general.
450488
451 <p>In the following, we use https://www.metalevel.at/prolog/dcg<b>Prolog
452 DCG notation</b> to describe a list <var>Cs</var> of CLP(B) constraints
453 that must all be satisfied.
489 <p>In the following, we use <a class="url" href="https://www.metalevel.at/prolog/dcg"><b>Prolog
490 DCG notation</b></a> to describe a list <var>Cs</var> of CLP(B)
491 constraints that must all be satisfied.
454492
455493 <pre class="code">
456494 :- use_module(library(clpb)).
482520 [0, 1, 0].
483521 </pre>
484522
485 <p><h3 id="sec:clpb-circuit"><a name="sec:A.7.8"><span class="sec-nr">A.7.8</span> <span class="sec-title">Example:
523 <p><h3 id="sec:clpb-circuit"><a id="sec:A.7.8"><span class="sec-nr">A.7.8</span> <span class="sec-title">Example:
486524 Boolean circuit</span></a></h3>
487525
488 <p><a name="sec:clpb-circuit"></a>
526 <p><a id="sec:clpb-circuit"></a>
489527
490528 <p>Consider a Boolean circuit that express the Boolean function <code>XOR</code>
491529 with 4 <code>NAND</code> gates. We can model such a circuit with CLP(B)
511549 sat(Z=:=x#y).
512550 </pre>
513551
514 <p><h3 id="sec:clpb-acknowledgments"><a name="sec:A.7.9"><span class="sec-nr">A.7.9</span> <span class="sec-title">Acknowledgments</span></a></h3>
515
516 <p><a name="sec:clpb-acknowledgments"></a>
552 <p><h3 id="sec:clpb-acknowledgments"><a id="sec:A.7.9"><span class="sec-nr">A.7.9</span> <span class="sec-title">Acknowledgments</span></a></h3>
553
554 <p><a id="sec:clpb-acknowledgments"></a>
517555
518556 <p>The interface predicates of this library follow the example of
519 https://sicstus.sics.se<b>SICStus Prolog</b>.
557 <a class="url" href="https://sicstus.sics.se"><b>SICStus Prolog</b></a>.
520558
521559 <p>Use SICStus Prolog for higher performance in many cases.
522560
523 <p><h3 id="sec:clpb-predicates"><a name="sec:A.7.10"><span class="sec-nr">A.7.10</span> <span class="sec-title">CLP(B)
561 <p><h3 id="sec:clpb-predicates"><a id="sec:A.7.10"><span class="sec-nr">A.7.10</span> <span class="sec-title">CLP(B)
524562 predicate index</span></a></h3>
525563
526 <p><a name="sec:clpb-predicates"></a>
564 <p><a id="sec:clpb-predicates"></a>
527565
528566 <p>In the following, each CLP(B) predicate is described in more detail.
529567
532570 <p><a class="url" href="http://eu.swi-prolog.org/man/clpb.html">http://eu.swi-prolog.org/man/clpb.html</a>
533571
534572 <dl class="latex">
535 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="sat/1"><strong>sat</strong>(<var>+Expr</var>)</a></dt>
573 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="sat/1"><strong>sat</strong>(<var>+Expr</var>)</a></dt>
536574 <dd class="defbody">
537575 True iff <var>Expr</var> is a satisfiable Boolean expression.</dd>
538 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="taut/2"><strong>taut</strong>(<var>+Expr,
576 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="taut/2"><strong>taut</strong>(<var>+Expr,
539577 -T</var>)</a></dt>
540578 <dd class="defbody">
541579 Tautology check. Succeeds with <var>T</var> = 0 if the Boolean
542580 expression <var>Expr</var> cannot be satisfied, and with <var>T</var> =
543581 1 if <var>Expr</var> is always true with respect to the current
544582 constraints. Fails otherwise.</dd>
545 <dt class="pubdef"><span class="pred-tag">[multi]</span><a name="labeling/1"><strong>labeling</strong>(<var>+Vs</var>)</a></dt>
583 <dt class="pubdef"><span class="pred-tag">[multi]</span><a id="labeling/1"><strong>labeling</strong>(<var>+Vs</var>)</a></dt>
546584 <dd class="defbody">
547585 Enumerate concrete solutions. Assigns truth values to the Boolean
548586 variables <var>Vs</var> such that all stated constraints are satisfied.</dd>
549 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="sat_count/2"><strong>sat_count</strong>(<var>+Expr,
587 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="sat_count/2"><strong>sat_count</strong>(<var>+Expr,
550588 -Count</var>)</a></dt>
551589 <dd class="defbody">
552590 <var>Count</var> the number of admissible assignments. <var>Count</var>
575613 </pre>
576614
577615 </dd>
578 <dt class="pubdef"><span class="pred-tag">[multi]</span><a name="weighted_maximum/3"><strong>weighted_maximum</strong>(<var>+Weights,
616 <dt class="pubdef"><span class="pred-tag">[multi]</span><a id="weighted_maximum/3"><strong>weighted_maximum</strong>(<var>+Weights,
579617 +Vs, -Maximum</var>)</a></dt>
580618 <dd class="defbody">
581619 Enumerate weighted optima over admissible assignments. Maximize a linear
598636 </pre>
599637
600638 </dd>
601 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_labeling/2"><strong>random_labeling</strong>(<var>+Seed,
639 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_labeling/2"><strong>random_labeling</strong>(<var>+Seed,
602640 +Vs</var>)</a></dt>
603641 <dd class="defbody">
604642 Select a single random solution. An admissible assignment of truth
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="clpb.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="clpqr.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:clpfd"><a name="sec:A.8"><span class="sec-nr">A.8</span> <span class="sec-title">library(clpfd):
235 <h2 id="sec:clpfd"><a id="sec:A.8"><span class="sec-nr">A.8</span> <span class="sec-title">library(clpfd):
195236 CLP(FD): Constraint Logic Programming over Finite Domains</span></a></h2>
196237
197 <a name="sec:clpfd"></a>
198
199 <p><a name="sec:clpfd"></a>
238 <a id="sec:clpfd"></a>
239
240 <p><a id="sec:clpfd"></a>
200241
201242 <dl class="tags">
202243 <dt class="tag">author</dt>
203244 <dd>
204 https://www.metalevel.atMarkus Triska
245 <a class="url" href="https://www.metalevel.at">Markus Triska</a>
205246 </dd>
206247 </dl>
207248
208249 <p><b>Development of this library has moved to SICStus Prolog.</b><br>
209250 Please see
210 https://github.com/triska/clpz<b>CLP(Z)</b> for more information.
211
212 <p><h3 id="sec:clpfd-intro"><a name="sec:A.8.1"><span class="sec-nr">A.8.1</span> <span class="sec-title">Introduction</span></a></h3>
213
214 <p><a name="sec:clpfd-intro"></a>
251 <a class="url" href="https://github.com/triska/clpz"><b>CLP(Z)</b></a>
252 for more information.
253
254 <p><h3 id="sec:clpfd-intro"><a id="sec:A.8.1"><span class="sec-nr">A.8.1</span> <span class="sec-title">Introduction</span></a></h3>
255
256 <p><a id="sec:clpfd-intro"></a>
215257
216258 <p>This library provides CLP(FD): Constraint Logic Programming over
217259 Finite Domains. This is an instance of the general CLP(<i>X</i>) scheme
218 (<a class="sec" href="clp.html">section 7</a>), extending logic
260 (<a class="sec" href="clp.html#sec:7">section 7</a>), extending logic
219261 programming with reasoning over specialised domains. CLP(FD) lets us
220262 reason about <b>integers</b> in a way that honors the relational nature
221263 of Prolog.
222264
223 <p>Read https://www.metalevel.at/prolog<b>The Power of Prolog</b> to
224 understand how this library is meant to be used in practice.
265 <p>Read <a class="url" href="https://www.metalevel.at/prolog"><b>The
266 Power of Prolog</b></a> to understand how this library is meant to be
267 used in practice.
225268
226269 <p>There are two major use cases of CLP(FD) constraints:
227270
228271 <p>
229272 <ol class="latex">
230 <li><b>declarative integer arithmetic</b> (<a class="sec" href="clpfd.html">section
273 <li><b>declarative integer arithmetic</b> (<a class="sec" href="clpfd.html#sec:A.8.3">section
231274 A.8.3</a>)
232275 <li>solving <b>combinatorial problems</b> such as planning, scheduling
233276 and allocation tasks.
238281 <p>
239282 <ul class="latex">
240283 <li><i>arithmetic</i> constraints like <a class="pred" href="clpfd.html##=/2">#=/2</a>, <a class="pred" href="clpfd.html##>/2">#&gt;/2</a>
241 and <a class="pred" href="clpfd.html##\=/2">#\=/2</a> (<a class="sec" href="clpfd.html">section
284 and <a class="pred" href="clpfd.html##\=/2">#\=/2</a> (<a class="sec" href="clpfd.html#sec:A.8.17.1">section
242285 A.8.17.1</a>)
243286 <li>the <i>membership</i> constraints <a class="pred" href="clpfd.html#in/2">in/2</a>
244 and <a class="pred" href="clpfd.html#ins/2">ins/2</a> (<a class="sec" href="clpfd.html">section
287 and <a class="pred" href="clpfd.html#ins/2">ins/2</a> (<a class="sec" href="clpfd.html#sec:A.8.17.2">section
245288 A.8.17.2</a>)
246289 <li>the <i>enumeration</i> predicates <a class="pred" href="clpfd.html#indomain/1">indomain/1</a>, <a class="pred" href="clpfd.html#label/1">label/1</a>
247 and <a class="pred" href="clpfd.html#labeling/2">labeling/2</a> (<a class="sec" href="clpfd.html">section
290 and <a class="pred" href="clpfd.html#labeling/2">labeling/2</a> (<a class="sec" href="clpfd.html#sec:A.8.17.3">section
248291 A.8.17.3</a>)
249292 <li><i>combinatorial</i> constraints like <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
250293 and <a class="pred" href="clpfd.html#global_cardinality/2">global_cardinality/2</a>
251 (<a class="sec" href="clpfd.html">section A.8.17.4</a>)
294 (<a class="sec" href="clpfd.html#sec:A.8.17.4">section A.8.17.4</a>)
252295 <li><i>reification</i> predicates such as <a class="pred" href="clpfd.html##<==>/2">#&lt;==&gt;/2</a>
253 (<a class="sec" href="clpfd.html">section A.8.17.5</a>)
296 (<a class="sec" href="clpfd.html#sec:A.8.17.5">section A.8.17.5</a>)
254297 <li><i>reflection</i> predicates such as <a class="pred" href="clpfd.html#fd_dom/2">fd_dom/2</a>
255 (<a class="sec" href="clpfd.html">section A.8.17.6</a>)
298 (<a class="sec" href="clpfd.html#sec:A.8.17.6">section A.8.17.6</a>)
256299 </ul>
257300
258 <p>In most cases, <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html">section
301 <p>In most cases, <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html#sec:A.8.2">section
259302 A.8.2</a>) are the only predicates you will ever need from this library.
260303 When reasoning over integers, simply replace low-level arithmetic
261304 predicates like <code>(is)/2</code> and <code>(&gt;)/2</code> by the
280323
281324 <p>Important concepts and principles of this library are illustrated by
282325 means of usage examples that are available in a public git repository:
283 https://github.com/triska/clpfd<b>github.com/triska/clpfd</b>
326 <a class="url" href="https://github.com/triska/clpfd"><b>github.com/triska/clpfd</b></a>
284327
285328 <p>If you are used to the complicated operational considerations that
286329 low-level arithmetic primitives necessitate, then moving to CLP(FD)
300343 advanced lectures.
301344
302345 <p>We recommend the following reference (PDF:
303 https://www.metalevel.at/swiclpfd.pdfmetalevel.at/swiclpfd.pdf) for
304 citing this library in scientific publications:
346 <a class="url" href="https://www.metalevel.at/swiclpfd.pdf">metalevel.at/swiclpfd.pdf</a>)
347 for citing this library in scientific publications:
305348
306349 <pre class="code">
307350 @inproceedings{Triska12,
316359 </pre>
317360
318361 <p>More information about CLP(FD) constraints and their implementation
319 is contained in: https://www.metalevel.at/drt.pdf<b>metalevel.at/drt.pdf</b>
362 is contained in: <a class="url" href="https://www.metalevel.at/drt.pdf"><b>metalevel.at/drt.pdf</b></a>
320363
321364 <p>The best way to discuss applying, improving and extending CLP(FD)
322365 constraints is to use the dedicated <code>clpfd</code> tag on
323 http://stackoverflow.comstackoverflow.com. Several of the world's
324 foremost CLP(FD) experts regularly participate in these discussions and
325 will help you for free on this platform.
326
327 <p><h3 id="sec:clpfd-arith-constraints"><a name="sec:A.8.2"><span class="sec-nr">A.8.2</span> <span class="sec-title">Arithmetic
366 <a class="url" href="http://stackoverflow.com">stackoverflow.com</a>.
367 Several of the world's foremost CLP(FD) experts regularly participate in
368 these discussions and will help you for free on this platform.
369
370 <p><h3 id="sec:clpfd-arith-constraints"><a id="sec:A.8.2"><span class="sec-nr">A.8.2</span> <span class="sec-title">Arithmetic
328371 constraints</span></a></h3>
329372
330 <p><a name="sec:clpfd-arith-constraints"></a>
373 <p><a id="sec:clpfd-arith-constraints"></a>
331374
332375 <p>In modern Prolog systems, <b>arithmetic constraints</b> subsume and
333376 supersede low-level predicates over integers. The main advantage of
338381 <p>The most important arithmetic constraint is <a class="pred" href="clpfd.html##=/2">#=/2</a>,
339382 which subsumes both
340383 <code>(is)/2</code> and <code>(=:=)/2</code> over integers. Use <a class="pred" href="clpfd.html##=/2">#=/2</a>
341 to make your programs more general. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
384 to make your programs more general. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
342385 A.8.3</a>).
343386
344387 <p>In total, the arithmetic constraints are:
345388 <blockquote>
346 <table border="2" frame="box" rules="groups">
347 <tr valign="top"><td>Expr1 <code>#=</code> Expr2</td><td>Expr1 equals
389 <table class="latex frame-box">
390 <tr><td>Expr1 <code>#=</code> Expr2</td><td>Expr1 equals Expr2 </td></tr>
391 <tr><td>Expr1 <code>#\=</code> Expr2</td><td>Expr1 is not equal to Expr2 </td></tr>
392 <tr><td>Expr1 <code>#&gt;=</code> Expr2</td><td>Expr1 is greater than or
393 equal to Expr2 </td></tr>
394 <tr><td>Expr1 <code>#=&lt;</code> Expr2</td><td>Expr1 is less than or
395 equal to Expr2 </td></tr>
396 <tr><td>Expr1 <code>#&gt;</code> Expr2</td><td>Expr1 is greater than
348397 Expr2 </td></tr>
349 <tr valign="top"><td>Expr1 <code>#\=</code> Expr2</td><td>Expr1 is not
350 equal to Expr2 </td></tr>
351 <tr valign="top"><td>Expr1 <code>#&gt;=</code> Expr2</td><td>Expr1 is
352 greater than or equal to Expr2 </td></tr>
353 <tr valign="top"><td>Expr1 <code>#=&lt;</code> Expr2</td><td>Expr1 is
354 less than or equal to Expr2 </td></tr>
355 <tr valign="top"><td>Expr1 <code>#&gt;</code> Expr2</td><td>Expr1 is
356 greater than Expr2 </td></tr>
357 <tr valign="top"><td>Expr1 <code>#&lt;</code> Expr2</td><td>Expr1 is
358 less than Expr2 </td></tr>
398 <tr><td>Expr1 <code>#&lt;</code> Expr2</td><td>Expr1 is less than Expr2 </td></tr>
359399 </table>
360400 </blockquote>
361401
362402 <p><var>Expr1</var> and <var>Expr2</var> denote <b>arithmetic
363403 expressions</b>, which are:
364404 <blockquote>
365 <table border="2" frame="box" rules="groups">
366 <tr valign="top"><td><i>integer</i> </td><td>Given value </td></tr>
367 <tr valign="top"><td><i>variable</i> </td><td>Unknown integer </td></tr>
368 <tr valign="top"><td>?(<i>variable</i>)</td><td>Unknown integer </td></tr>
369 <tr valign="top"><td>-Expr</td><td>Unary minus </td></tr>
370 <tr valign="top"><td>Expr + Expr</td><td>Addition </td></tr>
371 <tr valign="top"><td>Expr * Expr</td><td>Multiplication </td></tr>
372 <tr valign="top"><td>Expr - Expr</td><td>Subtraction </td></tr>
373 <tr valign="top"><td>Expr <code>^</code> Expr</td><td>Exponentiation </td></tr>
374 <tr valign="top"><td><code>min(Expr,Expr)</code> </td><td>Minimum of two
375 expressions </td></tr>
376 <tr valign="top"><td><code>max(Expr,Expr)</code> </td><td>Maximum of two
377 expressions </td></tr>
378 <tr valign="top"><td>Expr <code>mod</code> Expr</td><td>Modulo induced
379 by floored division </td></tr>
380 <tr valign="top"><td>Expr <code>rem</code> Expr</td><td>Modulo induced
381 by truncated division </td></tr>
382 <tr valign="top"><td><code>abs(Expr)</code> </td><td>Absolute value </td></tr>
383 <tr valign="top"><td>Expr <code>//</code> Expr</td><td>Truncated integer
405 <table class="latex frame-box">
406 <tr><td><i>integer</i> </td><td>Given value </td></tr>
407 <tr><td><i>variable</i> </td><td>Unknown integer </td></tr>
408 <tr><td>?(<i>variable</i>)</td><td>Unknown integer </td></tr>
409 <tr><td>-Expr</td><td>Unary minus </td></tr>
410 <tr><td>Expr + Expr</td><td>Addition </td></tr>
411 <tr><td>Expr * Expr</td><td>Multiplication </td></tr>
412 <tr><td>Expr - Expr</td><td>Subtraction </td></tr>
413 <tr><td>Expr <code>^</code> Expr</td><td>Exponentiation </td></tr>
414 <tr><td><code>min(Expr,Expr)</code> </td><td>Minimum of two expressions </td></tr>
415 <tr><td><code>max(Expr,Expr)</code> </td><td>Maximum of two expressions </td></tr>
416 <tr><td>Expr <code>mod</code> Expr</td><td>Modulo induced by floored
384417 division </td></tr>
385 <tr valign="top"><td>Expr div Expr</td><td>Floored integer division </td></tr>
418 <tr><td>Expr <code>rem</code> Expr</td><td>Modulo induced by truncated
419 division </td></tr>
420 <tr><td><code>abs(Expr)</code> </td><td>Absolute value </td></tr>
421 <tr><td>Expr <code>//</code> Expr</td><td>Truncated integer division </td></tr>
422 <tr><td>Expr div Expr</td><td>Floored integer division </td></tr>
386423 </table>
387424 </blockquote>
388425
392429 <code>(&lt;&lt;)/2</code>, <code>lsb/1</code>, <code>msb/1</code>, <code>popcount/1</code>
393430 and <code>(xor)/2</code> are also supported.
394431
395 <p><h3 id="sec:clpfd-integer-arith"><a name="sec:A.8.3"><span class="sec-nr">A.8.3</span> <span class="sec-title">Declarative
432 <p><h3 id="sec:clpfd-integer-arith"><a id="sec:A.8.3"><span class="sec-nr">A.8.3</span> <span class="sec-title">Declarative
396433 integer arithmetic</span></a></h3>
397434
398 <p><a name="sec:clpfd-integer-arith"></a>
399
400 <p>The <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html">section
435 <p><a id="sec:clpfd-integer-arith"></a>
436
437 <p>The <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html#sec:A.8.2">section
401438 A.8.2</a>) <a class="pred" href="clpfd.html##=/2">#=/2</a>, <a class="pred" href="clpfd.html##>/2">#&gt;/2</a>
402439 etc. are meant to be used <i>instead</i> of the primitives <code>(is)/2</code>,
403440 <code>(=:=)/2</code>, <code>(&gt;)/2</code> etc. over integers. Almost
449486
450487 <p>For supported expressions, CLP(FD) constraints are drop-in
451488 replacements of these low-level arithmetic predicates, often yielding
452 more general programs. See <code>n_factorial/2</code> (<a class="sec" href="clpfd.html">section
489 more general programs. See <code>n_factorial/2</code> (<a class="sec" href="clpfd.html#sec:A.8.4">section
453490 A.8.4</a>) for an example.
454491
455492 <p>This library uses <a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
485522 primitives by providing declarative alternatives that are meant to be
486523 used instead.
487524
488 <p><h3 id="sec:clpfd-factorial"><a name="sec:A.8.4"><span class="sec-nr">A.8.4</span> <span class="sec-title">Example:
525 <p><h3 id="sec:clpfd-factorial"><a id="sec:A.8.4"><span class="sec-nr">A.8.4</span> <span class="sec-title">Example:
489526 Factorial relation</span></a></h3>
490527
491 <p><a name="sec:clpfd-factorial"></a>
528 <p><a id="sec:clpfd-factorial"></a>
492529
493530 <p>We illustrate the benefit of using <a class="pred" href="clpfd.html##=/2">#=/2</a>
494531 for more generality with a simple example.
550587 freeing us from <i>all</i> procedural phenomena. For example, the two
551588 programs do not even have the same <i>termination properties</i> in all
552589 cases. Instead, the primary benefit of CLP(FD) constraints is that they
553 allow you to try different execution orders and apply https://www.metalevel.at/prolog/debugging<b>declarative
554 debugging</b> techniques <i>at all</i>! Reordering goals (and clauses)
555 can significantly impact the performance of Prolog programs, and you are
556 free to try different variants if you use declarative approaches.
557 Moreover, since all CLP(FD) constraints <i>always terminate</i>, placing
558 them earlier can at most <i>improve</i>, never worsen, the termination
559 properties of your programs. An additional benefit of CLP(FD)
560 constraints is that they eliminate the complexity of introducing <code>(is)/2</code>
590 allow you to try different execution orders and apply <a class="url" href="https://www.metalevel.at/prolog/debugging"><b>declarative
591 debugging</b></a> techniques <i>at all</i>! Reordering goals (and
592 clauses) can significantly impact the performance of Prolog programs,
593 and you are free to try different variants if you use declarative
594 approaches. Moreover, since all CLP(FD) constraints <i>always terminate</i>,
595 placing them earlier can at most <i>improve</i>, never worsen, the
596 termination properties of your programs. An additional benefit of
597 CLP(FD) constraints is that they eliminate the complexity of introducing <code>(is)/2</code>
561598 and <code>(=:=)/2</code> to beginners, since <i>both</i> predicates are
562599 subsumed by <a class="pred" href="clpfd.html##=/2">#=/2</a> when
563600 reasoning over integers.
571608 the symbolic outcome (<code>&lt;</code>, <code>=</code>, <code>&gt;</code>)
572609 of 0 compared to N.
573610
574 <p><h3 id="sec:clpfd-combinatorial"><a name="sec:A.8.5"><span class="sec-nr">A.8.5</span> <span class="sec-title">Combinatorial
611 <p><h3 id="sec:clpfd-combinatorial"><a id="sec:A.8.5"><span class="sec-nr">A.8.5</span> <span class="sec-title">Combinatorial
575612 constraints</span></a></h3>
576613
577 <p><a name="sec:clpfd-combinatorial"></a>
614 <p><a id="sec:clpfd-combinatorial"></a>
578615
579616 <p>In addition to subsuming and replacing low-level arithmetic
580617 predicates, CLP(FD) constraints are often used to solve combinatorial
586623 and <a class="pred" href="clpfd.html#automaton/8">automaton/8</a>, which
587624 are useful in more specialized applications.
588625
589 <p><h3 id="sec:clpfd-domains"><a name="sec:A.8.6"><span class="sec-nr">A.8.6</span> <span class="sec-title">Domains</span></a></h3>
590
591 <p><a name="sec:clpfd-domains"></a>
626 <p><h3 id="sec:clpfd-domains"><a id="sec:A.8.6"><span class="sec-nr">A.8.6</span> <span class="sec-title">Domains</span></a></h3>
627
628 <p><a id="sec:clpfd-domains"></a>
592629
593630 <p>Each CLP(FD) variable has an associated set of admissible integers,
594631 which we call the variable's <b>domain</b>. Initially, the domain of
606643 <p>Domains are taken into account when further constraints are stated,
607644 and by enumeration predicates like <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>.
608645
609 <p><h3 id="sec:clpfd-sudoku"><a name="sec:A.8.7"><span class="sec-nr">A.8.7</span> <span class="sec-title">Example:
646 <p><h3 id="sec:clpfd-sudoku"><a id="sec:A.8.7"><span class="sec-nr">A.8.7</span> <span class="sec-title">Example:
610647 Sudoku</span></a></h3>
611648
612 <p><a name="sec:clpfd-sudoku"></a>
649 <p><a id="sec:clpfd-sudoku"></a>
613650
614651 <p>As another example, consider <i>Sudoku</i>: It is a popular puzzle
615652 over integers that can be easily solved with CLP(FD) constraints.
661698 <p>In this concrete case, the constraint solver is strong enough to find
662699 the unique solution without any search.
663700
664 <p><h3 id="sec:clpfd-residual-goals"><a name="sec:A.8.8"><span class="sec-nr">A.8.8</span> <span class="sec-title">Residual
701 <p><h3 id="sec:clpfd-residual-goals"><a id="sec:A.8.8"><span class="sec-nr">A.8.8</span> <span class="sec-title">Residual
665702 goals</span></a></h3>
666703
667 <p><a name="sec:clpfd-residual-goals"></a>
704 <p><a id="sec:clpfd-residual-goals"></a>
668705
669706 <p>Here is an example session with a few queries and their answers:
670707
717754 which we can inspect a variable's current domain. These predicates can
718755 be useful if you want to implement your own labeling strategies.
719756
720 <p><h3 id="sec:clpfd-search"><a name="sec:A.8.9"><span class="sec-nr">A.8.9</span> <span class="sec-title">Core
757 <p><h3 id="sec:clpfd-search"><a id="sec:A.8.9"><span class="sec-nr">A.8.9</span> <span class="sec-title">Core
721758 relations and search</span></a></h3>
722759
723 <p><a name="sec:clpfd-search"></a>
760 <p><a id="sec:clpfd-search"></a>
724761
725762 <p>Using CLP(FD) constraints to solve combinatorial tasks typically
726763 consists of two phases:
797834 general though, it is necessary to label all variables to obtain ground
798835 solutions.
799836
800 <p><h3 id="sec:clpfd-n-queens"><a name="sec:A.8.10"><span class="sec-nr">A.8.10</span> <span class="sec-title">Example:
837 <p><h3 id="sec:clpfd-n-queens"><a id="sec:A.8.10"><span class="sec-nr">A.8.10</span> <span class="sec-title">Example:
801838 Eight queens puzzle</span></a></h3>
802839
803 <p><a name="sec:clpfd-n-queens"></a>
840 <p><a id="sec:clpfd-n-queens"></a>
804841
805842 <p>We illustrate the concepts of the preceding sections by means of the
806843 so-called <i>eight queens puzzle</i>. The task is to place 8 queens on
876913 <p>Experimenting with different search strategies is easy because we
877914 have separated the core relation from the actual search.
878915
879 <p><h3 id="sec:clpfd-optimisation"><a name="sec:A.8.11"><span class="sec-nr">A.8.11</span> <span class="sec-title">Optimisation</span></a></h3>
880
881 <p><a name="sec:clpfd-optimisation"></a>
916 <p><h3 id="sec:clpfd-optimisation"><a id="sec:A.8.11"><span class="sec-nr">A.8.11</span> <span class="sec-title">Optimisation</span></a></h3>
917
918 <p><a id="sec:clpfd-optimisation"></a>
882919
883920 <p>We can use <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>
884921 to minimize or maximize the value of a CLP(FD) expression, and generate
897934 optimal solution. However, it is often very valuable to see alternative
898935 solutions that are <i>also</i> optimal, so that we can choose among
899936 optimal solutions by other criteria. For the sake of
900 https://www.metalevel.at/prolog/purity<b>purity</b> and completeness, we
901 recommend to avoid <code>once/1</code> and other constructs that lead to
902 impurities in CLP(FD) programs.
937 <a class="url" href="https://www.metalevel.at/prolog/purity"><b>purity</b></a>
938 and completeness, we recommend to avoid <code>once/1</code> and other
939 constructs that lead to impurities in CLP(FD) programs.
903940
904941 <p>Related to optimisation with CLP(FD) constraints are
905 http://eu.swi-prolog.org/man/simplex.html<code>library(simplex)</code>
942 <a class="url" href="http://eu.swi-prolog.org/man/simplex.html"><code>library(simplex)</code></a>
906943 and CLP(Q) which reason about <i>linear</i> constraints over rational
907944 numbers.
908945
909 <p><h3 id="sec:clpfd-reification"><a name="sec:A.8.12"><span class="sec-nr">A.8.12</span> <span class="sec-title">Reification</span></a></h3>
910
911 <p><a name="sec:clpfd-reification"></a>
946 <p><h3 id="sec:clpfd-reification"><a id="sec:A.8.12"><span class="sec-nr">A.8.12</span> <span class="sec-title">Reification</span></a></h3>
947
948 <p><a id="sec:clpfd-reification"></a>
912949
913950 <p>The constraints <a class="pred" href="clpfd.html#in/2">in/2</a>, <a class="pred" href="clpfd.html##=/2">#=/2</a>, <a class="pred" href="clpfd.html##\=/2">#\=/2</a>, <a class="pred" href="clpfd.html##</2">#&lt;/2</a>, <a class="pred" href="clpfd.html##>/2">#&gt;/2</a>, <a class="pred" href="clpfd.html##=</2">#=&lt;/2</a>,
914951 and <a class="pred" href="clpfd.html##>=/2">#&gt;=/2</a> can be
916953 values represented by the integers 0 and 1. Let P and Q denote reifiable
917954 constraints or Boolean variables, then:
918955 <blockquote>
919 <table border="2" frame="box" rules="groups">
920 <tr valign="top"><td><code>#\</code> Q</td><td>True iff Q is false </td></tr>
921 <tr valign="top"><td>P <code>#\/</code> Q</td><td>True iff either P or Q </td></tr>
922 <tr valign="top"><td>P <code>#/\</code> Q</td><td>True iff both P and Q </td></tr>
923 <tr valign="top"><td>P <code>#\</code> Q</td><td>True iff either P or Q,
924 but not both </td></tr>
925 <tr valign="top"><td>P <code>#&lt;==&gt;</code> Q</td><td>True iff P and
926 Q are equivalent </td></tr>
927 <tr valign="top"><td>P <code>#==&gt;</code> Q</td><td>True iff P implies
928 Q </td></tr>
929 <tr valign="top"><td>P <code>#&lt;==</code> Q</td><td>True iff Q implies
930 P </td></tr>
956 <table class="latex frame-box">
957 <tr><td><code>#\</code> Q</td><td>True iff Q is false </td></tr>
958 <tr><td>P <code>#\/</code> Q</td><td>True iff either P or Q </td></tr>
959 <tr><td>P <code>#/\</code> Q</td><td>True iff both P and Q </td></tr>
960 <tr><td>P <code>#\</code> Q</td><td>True iff either P or Q, but not both </td></tr>
961 <tr><td>P <code>#&lt;==&gt;</code> Q</td><td>True iff P and Q are
962 equivalent </td></tr>
963 <tr><td>P <code>#==&gt;</code> Q</td><td>True iff P implies Q </td></tr>
964 <tr><td>P <code>#&lt;==</code> Q</td><td>True iff Q implies P </td></tr>
931965 </table>
932966 </blockquote>
933967
935969
936970 <p>When reasoning over Boolean variables, also consider using CLP(B)
937971 constraints as provided by
938 http://eu.swi-prolog.org/man/clpb.html<code>library(clpb)</code>.
939
940 <p><h3 id="sec:clpfd-monotonicity"><a name="sec:A.8.13"><span class="sec-nr">A.8.13</span> <span class="sec-title">Enabling
972 <a class="url" href="http://eu.swi-prolog.org/man/clpb.html"><code>library(clpb)</code></a>.
973
974 <p><h3 id="sec:clpfd-monotonicity"><a id="sec:A.8.13"><span class="sec-nr">A.8.13</span> <span class="sec-title">Enabling
941975 monotonic CLP(FD)</span></a></h3>
942976
943 <p><a name="sec:clpfd-monotonicity"></a>
977 <p><a id="sec:clpfd-monotonicity"></a>
944978
945979 <p>In the default execution mode, CLP(FD) constraints still exhibit some
946980 non-relational properties. For example, <i>adding</i> constraints can
9781012 <p>The wrapper can be omitted for variables that are already constrained
9791013 to integers.
9801014
981 <p><h3 id="sec:clpfd-custom-constraints"><a name="sec:A.8.14"><span class="sec-nr">A.8.14</span> <span class="sec-title">Custom
1015 <p><h3 id="sec:clpfd-custom-constraints"><a id="sec:A.8.14"><span class="sec-nr">A.8.14</span> <span class="sec-title">Custom
9821016 constraints</span></a></h3>
9831017
984 <p><a name="sec:clpfd-custom-constraints"></a>
1018 <p><a id="sec:clpfd-custom-constraints"></a>
9851019
9861020 <p>We can define custom constraints. The mechanism to do this is not yet
9871021 finalised, and we welcome suggestions and descriptions of use cases that
10311065 X in inf..sup.
10321066 </pre>
10331067
1034 <p><h3 id="sec:clpfd-applications"><a name="sec:A.8.15"><span class="sec-nr">A.8.15</span> <span class="sec-title">Applications</span></a></h3>
1035
1036 <p><a name="sec:clpfd-applications"></a>
1068 <p><h3 id="sec:clpfd-applications"><a id="sec:A.8.15"><span class="sec-nr">A.8.15</span> <span class="sec-title">Applications</span></a></h3>
1069
1070 <p><a id="sec:clpfd-applications"></a>
10371071
10381072 <p>CLP(FD) applications that we find particularly impressive and worth
10391073 studying include:
10421076 <ul class="latex">
10431077 <li>Michael Hendricks uses CLP(FD) constraints for flexible reasoning
10441078 about <i>dates</i> and <i>times</i> in the
1045 http://www.swi-prolog.org/pack/list?p=julian<code>julian</code> package.
1079 <a class="url" href="http://www.swi-prolog.org/pack/list?p=julian"><code>julian</code></a>
1080 package.
10461081 <li>Julien Cumin uses CLP(FD) constraints for integer arithmetic in
1047 https://github.com/JCumin/Brachylog<code>Brachylog</code>.
1082 <a class="url" href="https://github.com/JCumin/Brachylog"><code>Brachylog</code></a>.
10481083 </ul>
10491084
1050 <p><h3 id="sec:clpfd-acknowledgments"><a name="sec:A.8.16"><span class="sec-nr">A.8.16</span> <span class="sec-title">Acknowledgments</span></a></h3>
1051
1052 <p><a name="sec:clpfd-acknowledgments"></a>
1053
1054 <p>This library gives you a glimpse of what https://sicstus.sics.se/<b>SICStus
1055 Prolog</b> can do. The API is intentionally mostly compatible with that
1056 of SICStus Prolog, so that you can easily switch to a much more
1057 feature-rich and much faster CLP(FD) system when you need it. I thank
1058 https://www.sics.se/&nbsp;matsc/ Mats Carlsson , the designer and main
1059 implementor of SICStus Prolog, for his elegant example. I first
1060 encountered his system as part of the excellent
1061 http://www.complang.tuwien.ac.at/ulrich/gupu/<b>GUPU</b> teaching
1062 environment by http://www.complang.tuwien.ac.at/ulrich/Ulrich Neumerkel
1063 . Ulrich was also the first and most determined tester of the present
1064 system, filing hundreds of comments and suggestions for improvement.
1065 https://people.cs.kuleuven.be/&nbsp;tom.schrijvers/ Tom Schrijvers has
1066 contributed several constraint libraries to SWI-Prolog, and I learned a
1067 lot from his coding style and implementation examples.
1068 https://people.cs.kuleuven.be/&nbsp;bart.demoen/ Bart Demoen was a
1069 driving force behind the implementation of attributed variables in
1070 SWI-Prolog, and this library could not even have started without his
1071 prior work and contributions. Thank you all!
1072
1073 <p><h3 id="sec:clpfd-predicate-index"><a name="sec:A.8.17"><span class="sec-nr">A.8.17</span> <span class="sec-title">CLP(FD)
1085 <p><h3 id="sec:clpfd-acknowledgments"><a id="sec:A.8.16"><span class="sec-nr">A.8.16</span> <span class="sec-title">Acknowledgments</span></a></h3>
1086
1087 <p><a id="sec:clpfd-acknowledgments"></a>
1088
1089 <p>This library gives you a glimpse of what <a class="url" href="https://sicstus.sics.se/"><b>SICStus
1090 Prolog</b></a> can do. The API is intentionally mostly compatible with
1091 that of SICStus Prolog, so that you can easily switch to a much more
1092 feature-rich and much faster CLP(FD) system when you need it. I thank <a class="url" href="https://www.sics.se/~matsc/">Mats
1093 Carlsson</a>, the designer and main implementor of SICStus Prolog, for
1094 his elegant example. I first encountered his system as part of the
1095 excellent
1096 <a class="url" href="http://www.complang.tuwien.ac.at/ulrich/gupu/"><b>GUPU</b></a>
1097 teaching environment by <a class="url" href="http://www.complang.tuwien.ac.at/ulrich/">Ulrich
1098 Neumerkel</a>. Ulrich was also the first and most determined tester of
1099 the present system, filing hundreds of comments and suggestions for
1100 improvement. <a class="url" href="https://people.cs.kuleuven.be/~tom.schrijvers/">Tom
1101 Schrijvers</a> has contributed several constraint libraries to
1102 SWI-Prolog, and I learned a lot from his coding style and implementation
1103 examples. <a class="url" href="https://people.cs.kuleuven.be/~bart.demoen/">Bart
1104 Demoen</a> was a driving force behind the implementation of attributed
1105 variables in SWI-Prolog, and this library could not even have started
1106 without his prior work and contributions. Thank you all!
1107
1108 <p><h3 id="sec:clpfd-predicate-index"><a id="sec:A.8.17"><span class="sec-nr">A.8.17</span> <span class="sec-title">CLP(FD)
10741109 predicate index</span></a></h3>
10751110
1076 <p><a name="sec:clpfd-predicate-index"></a>
1111 <p><a id="sec:clpfd-predicate-index"></a>
10771112
10781113 <p>In the following, each CLP(FD) predicate is described in more detail.
10791114
10811116
10821117 <p><a class="url" href="http://eu.swi-prolog.org/man/clpfd.html">http://eu.swi-prolog.org/man/clpfd.html</a>
10831118
1084 <p><h4 id="sec:clpfd-arithmetic"><a name="sec:A.8.17.1"><span class="sec-nr">A.8.17.1</span> <span class="sec-title">Arithmetic
1119 <p><h4 id="sec:clpfd-arithmetic"><a id="sec:A.8.17.1"><span class="sec-nr">A.8.17.1</span> <span class="sec-title">Arithmetic
10851120 constraints</span></a></h4>
10861121
1087 <p><a name="sec:clpfd-arithmetic"></a>
1122 <p><a id="sec:clpfd-arithmetic"></a>
10881123
10891124 <p><i>Arithmetic</i> constraints are the most basic use of CLP(FD).
10901125 Every time you use <code>(is)/2</code> or one of the low-level
10911126 arithmetic comparisons (<code>(&lt;)/2</code>, <code>(&gt;)/2</code>
10921127 etc.) over integers, consider using CLP(FD) constraints <i>instead</i>.
10931128 This can at most <i>increase</i> the generality of your programs. See
1094 declarative integer arithmetic (<a class="sec" href="clpfd.html">section
1129 declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
10951130 A.8.3</a>).
10961131
10971132 <dl class="latex">
1098 <dt class="pubdef"><a name="#=/2"><var>?X</var> <strong>#=</strong> <var>?Y</var></a></dt>
1133 <dt class="pubdef"><a id="#=/2"><var>?X</var> <strong>#=</strong> <var>?Y</var></a></dt>
10991134 <dd class="defbody">
11001135 The arithmetic expression <var>X</var> equals <var>Y</var>. This is the
1101 most important arithmetic constraint (<a class="sec" href="clpfd.html">section
1136 most important arithmetic constraint (<a class="sec" href="clpfd.html#sec:A.8.2">section
11021137 A.8.2</a>), subsuming and replacing both <code>(is)/2</code> <i>and</i> <code>(=:=)/2</code>
1103 over integers. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
1138 over integers. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
11041139 A.8.3</a>).</dd>
1105 <dt class="pubdef"><a name="#\=/2"><var>?X</var> <strong>#\=</strong> <var>?Y</var></a></dt>
1140 <dt class="pubdef"><a id="#\=/2"><var>?X</var> <strong>#\=</strong> <var>?Y</var></a></dt>
11061141 <dd class="defbody">
11071142 The arithmetic expressions <var>X</var> and <var>Y</var> evaluate to
11081143 distinct integers. When reasoning over integers, replace <code>(=\=)/2</code>
11091144 by <a class="pred" href="clpfd.html##\=/2">#\=/2</a> to obtain more
1110 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
1145 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
11111146 A.8.3</a>).</dd>
1112 <dt class="pubdef"><a name="#>=/2"><var>?X</var> <strong>#&gt;=</strong> <var>?Y</var></a></dt>
1147 <dt class="pubdef"><a id="#>=/2"><var>?X</var> <strong>#&gt;=</strong> <var>?Y</var></a></dt>
11131148 <dd class="defbody">
11141149 Same as <var>Y</var> <code>#=&lt;</code> <var>X</var>. When reasoning
11151150 over integers, replace <code>(&gt;=)/2</code> by
11161151 <a class="pred" href="clpfd.html##>=/2">#&gt;=/2</a> to obtain more
1117 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
1152 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
11181153 A.8.3</a>).</dd>
1119 <dt class="pubdef"><a name="#=</2"><var>?X</var> <strong>#=&lt;</strong> <var>?Y</var></a></dt>
1154 <dt class="pubdef"><a id="#=</2"><var>?X</var> <strong>#=&lt;</strong> <var>?Y</var></a></dt>
11201155 <dd class="defbody">
11211156 The arithmetic expression <var>X</var> is less than or equal to <var>Y</var>.
11221157 When reasoning over integers, replace <code>(=&lt;)/2</code> by <a class="pred" href="clpfd.html##=</2">#=&lt;/2</a>
1123 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
1158 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
11241159 A.8.3</a>).</dd>
1125 <dt class="pubdef"><a name="#>/2"><var>?X</var> <strong>#&gt;</strong> <var>?Y</var></a></dt>
1160 <dt class="pubdef"><a id="#>/2"><var>?X</var> <strong>#&gt;</strong> <var>?Y</var></a></dt>
11261161 <dd class="defbody">
11271162 Same as <var>Y</var> <code>#&lt;</code> <var>X</var>. When reasoning
11281163 over integers, replace <code>(&gt;)/2</code> by
11291164 <a class="pred" href="clpfd.html##>/2">#&gt;/2</a> to obtain more
1130 general relations See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
1165 general relations See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
11311166 A.8.3</a>).</dd>
1132 <dt class="pubdef"><a name="#</2"><var>?X</var> <strong>#&lt;</strong> <var>?Y</var></a></dt>
1167 <dt class="pubdef"><a id="#</2"><var>?X</var> <strong>#&lt;</strong> <var>?Y</var></a></dt>
11331168 <dd class="defbody">
11341169 The arithmetic expression <var>X</var> is less than <var>Y</var>. When
11351170 reasoning over integers, replace <code>(&lt;)/2</code> by <a class="pred" href="clpfd.html##</2">#&lt;/2</a>
1136 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
1171 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
11371172 A.8.3</a>).
11381173
11391174 <p>In addition to its regular use in tasks that require it, this
11541189 <p></dd>
11551190 </dl>
11561191
1157 <p><h4 id="sec:clpfd-membership"><a name="sec:A.8.17.2"><span class="sec-nr">A.8.17.2</span> <span class="sec-title">Membership
1192 <p><h4 id="sec:clpfd-membership"><a id="sec:A.8.17.2"><span class="sec-nr">A.8.17.2</span> <span class="sec-title">Membership
11581193 constraints</span></a></h4>
11591194
1160 <p><a name="sec:clpfd-membership"></a>
1195 <p><a id="sec:clpfd-membership"></a>
11611196
11621197 <p>If you are using CLP(FD) to model and solve combinatorial tasks, then
11631198 you typically need to specify the admissible domains of variables. The <i>membership
11651200 are useful in such cases.
11661201
11671202 <dl class="latex">
1168 <dt class="pubdef"><a name="in/2"><var>?Var</var> <strong>in</strong> <var>+Domain</var></a></dt>
1203 <dt class="pubdef"><a id="in/2"><var>?Var</var> <strong>in</strong> <var>+Domain</var></a></dt>
11691204 <dd class="defbody">
11701205 <var>Var</var> is an element of <var>Domain</var>. <var>Domain</var> is
11711206 one of:
11891224 </dl>
11901225
11911226 </dd>
1192 <dt class="pubdef"><a name="ins/2"><var>+Vars</var> <strong>ins</strong> <var>+Domain</var></a></dt>
1227 <dt class="pubdef"><a id="ins/2"><var>+Vars</var> <strong>ins</strong> <var>+Domain</var></a></dt>
11931228 <dd class="defbody">
11941229 The variables in the list <var>Vars</var> are elements of <var>Domain</var>.
11951230 See <a class="pred" href="clpfd.html#in/2">in/2</a> for the syntax of <var>Domain</var>.
11961231 </dd>
11971232 </dl>
11981233
1199 <p><h4 id="sec:clpfd-enumeration"><a name="sec:A.8.17.3"><span class="sec-nr">A.8.17.3</span> <span class="sec-title">Enumeration
1234 <p><h4 id="sec:clpfd-enumeration"><a id="sec:A.8.17.3"><span class="sec-nr">A.8.17.3</span> <span class="sec-title">Enumeration
12001235 predicates</span></a></h4>
12011236
1202 <p><a name="sec:clpfd-enumeration"></a>
1237 <p><a id="sec:clpfd-enumeration"></a>
12031238
12041239 <p>When modeling combinatorial tasks, the actual search for solutions is
12051240 typically performed by <i>enumeration predicates</i> like <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>.
12071242 information.
12081243
12091244 <dl class="latex">
1210 <dt class="pubdef"><a name="indomain/1"><strong>indomain</strong>(<var>?Var</var>)</a></dt>
1245 <dt class="pubdef"><a id="indomain/1"><strong>indomain</strong>(<var>?Var</var>)</a></dt>
12111246 <dd class="defbody">
12121247 Bind <var>Var</var> to all feasible values of its domain on
12131248 backtracking. The domain of <var>Var</var> must be finite.</dd>
1214 <dt class="pubdef"><a name="label/1"><strong>label</strong>(<var>+Vars</var>)</a></dt>
1249 <dt class="pubdef"><a id="label/1"><strong>label</strong>(<var>+Vars</var>)</a></dt>
12151250 <dd class="defbody">
12161251 Equivalent to <code>labeling([], Vars)</code>. See <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>.</dd>
1217 <dt class="pubdef"><a name="labeling/2"><strong>labeling</strong>(<var>+Options,
1252 <dt class="pubdef"><a id="labeling/2"><strong>labeling</strong>(<var>+Options,
12181253 +Vars</var>)</a></dt>
12191254 <dd class="defbody">
12201255 Assign a value to each variable in <var>Vars</var>. Labeling means
13211356 </pre>
13221357
13231358 <p>Labeling is always complete, always terminates, and yields no
1324 redundant solutions. See core relations and search (<a class="sec" href="clpfd.html">section
1359 redundant solutions. See core relations and search (<a class="sec" href="clpfd.html#sec:A.8.9">section
13251360 A.8.9</a>) for usage advice.
13261361 </dd>
13271362 </dl>
13281363
1329 <p><h4 id="sec:clpfd-global"><a name="sec:A.8.17.4"><span class="sec-nr">A.8.17.4</span> <span class="sec-title">Global
1364 <p><h4 id="sec:clpfd-global"><a id="sec:A.8.17.4"><span class="sec-nr">A.8.17.4</span> <span class="sec-title">Global
13301365 constraints</span></a></h4>
13311366
1332 <p><a name="sec:clpfd-global"></a>
1367 <p><a id="sec:clpfd-global"></a>
13331368
13341369 <p>A <i>global constraint</i> expresses a relation that involves many
13351370 variables at once. The most frequently used global constraints of this
13381373 and <a class="pred" href="clpfd.html#cumulative/2">cumulative/2</a>.
13391374
13401375 <dl class="latex">
1341 <dt class="pubdef"><a name="all_distinct/1"><strong>all_distinct</strong>(<var>+Vars</var>)</a></dt>
1376 <dt class="pubdef"><a id="all_distinct/1"><strong>all_distinct</strong>(<var>+Vars</var>)</a></dt>
13421377 <dd class="defbody">
13431378 True iff <var>Vars</var> are pairwise distinct. For example, <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
13441379 can detect that not all variables can assume distinct values given the
13521387 </pre>
13531388
13541389 </dd>
1355 <dt class="pubdef"><a name="all_different/1"><strong>all_different</strong>(<var>+Vars</var>)</a></dt>
1390 <dt class="pubdef"><a id="all_different/1"><strong>all_different</strong>(<var>+Vars</var>)</a></dt>
13561391 <dd class="defbody">
13571392 Like <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>,
13581393 but with weaker propagation. Consider using
13591394 <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
13601395 instead, since <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
13611396 is typically acceptably efficient and propagates much more strongly.</dd>
1362 <dt class="pubdef"><a name="sum/3"><strong>sum</strong>(<var>+Vars,
1363 +Rel, ?Expr</var>)</a></dt>
1397 <dt class="pubdef"><a id="sum/3"><strong>sum</strong>(<var>+Vars, +Rel,
1398 ?Expr</var>)</a></dt>
13641399 <dd class="defbody">
13651400 The sum of elements of the list <var>Vars</var> is in relation <var>Rel</var>
13661401 to <var>Expr</var>.
13761411 </pre>
13771412
13781413 </dd>
1379 <dt class="pubdef"><a name="scalar_product/4"><strong>scalar_product</strong>(<var>+Cs,
1414 <dt class="pubdef"><a id="scalar_product/4"><strong>scalar_product</strong>(<var>+Cs,
13801415 +Vs, +Rel, ?Expr</var>)</a></dt>
13811416 <dd class="defbody">
13821417 True iff the scalar product of <var>Cs</var> and <var>Vs</var> is in
13851420 variables and integers.
13861421 <var>Rel</var> is #=, #<code>\</code>=, #<var>&lt;</var>, #<var>&gt;</var>, <code>#=&lt;</code>
13871422 or #<var>&gt;</var>=.</dd>
1388 <dt class="pubdef"><a name="lex_chain/1"><strong>lex_chain</strong>(<var>+Lists</var>)</a></dt>
1423 <dt class="pubdef"><a id="lex_chain/1"><strong>lex_chain</strong>(<var>+Lists</var>)</a></dt>
13891424 <dd class="defbody">
13901425 <var>Lists</var> are lexicographically non-decreasing.</dd>
1391 <dt class="pubdef"><a name="tuples_in/2"><strong>tuples_in</strong>(<var>+Tuples,
1426 <dt class="pubdef"><a id="tuples_in/2"><strong>tuples_in</strong>(<var>+Tuples,
13921427 +Relation</var>)</a></dt>
13931428 <dd class="defbody">
13941429 True iff all <var>Tuples</var> are elements of <var>Relation</var>. Each
14341469 </pre>
14351470
14361471 </dd>
1437 <dt class="pubdef"><a name="serialized/2"><strong>serialized</strong>(<var>+Starts,
1472 <dt class="pubdef"><a id="serialized/2"><strong>serialized</strong>(<var>+Starts,
14381473 +Durations</var>)</a></dt>
14391474 <dd class="defbody">
14401475 Describes a set of non-overlapping tasks.
14641499 </dl>
14651500
14661501 </dd>
1467 <dt class="pubdef"><a name="element/3"><strong>element</strong>(<var>?N,
1502 <dt class="pubdef"><a id="element/3"><strong>element</strong>(<var>?N,
14681503 +Vs, ?V</var>)</a></dt>
14691504 <dd class="defbody">
14701505 The <var>N</var>-th element of the list of finite domain variables <var>Vs</var>
14711506 is <var>V</var>. Analogous to <a class="pred" href="lists.html#nth1/3">nth1/3</a>.</dd>
1472 <dt class="pubdef"><a name="global_cardinality/2"><strong>global_cardinality</strong>(<var>+Vs,
1507 <dt class="pubdef"><a id="global_cardinality/2"><strong>global_cardinality</strong>(<var>+Vs,
14731508 +Pairs</var>)</a></dt>
14741509 <dd class="defbody">
14751510 Global Cardinality constraint. Equivalent to
14851520 </pre>
14861521
14871522 </dd>
1488 <dt class="pubdef"><a name="global_cardinality/3"><strong>global_cardinality</strong>(<var>+Vs,
1523 <dt class="pubdef"><a id="global_cardinality/3"><strong>global_cardinality</strong>(<var>+Vs,
14891524 +Pairs, +Options</var>)</a></dt>
14901525 <dd class="defbody">
14911526 Global Cardinality constraint. <var>Vs</var> is a list of finite domain
15111546 </dl>
15121547
15131548 </dd>
1514 <dt class="pubdef"><a name="circuit/1"><strong>circuit</strong>(<var>+Vs</var>)</a></dt>
1549 <dt class="pubdef"><a id="circuit/1"><strong>circuit</strong>(<var>+Vs</var>)</a></dt>
15151550 <dd class="defbody">
15161551 True iff the list <var>Vs</var> of finite domain variables induces a
15171552 Hamiltonian circuit. The k-th element of <var>Vs</var> denotes the
15281563 </pre>
15291564
15301565 </dd>
1531 <dt class="pubdef"><a name="cumulative/1"><strong>cumulative</strong>(<var>+Tasks</var>)</a></dt>
1566 <dt class="pubdef"><a id="cumulative/1"><strong>cumulative</strong>(<var>+Tasks</var>)</a></dt>
15321567 <dd class="defbody">
15331568 Equivalent to <code>cumulative(Tasks, [limit(1)])</code>. See <a class="pred" href="clpfd.html#cumulative/2">cumulative/2</a>.</dd>
1534 <dt class="pubdef"><a name="cumulative/2"><strong>cumulative</strong>(<var>+Tasks,
1569 <dt class="pubdef"><a id="cumulative/2"><strong>cumulative</strong>(<var>+Tasks,
15351570 +Options</var>)</a></dt>
15361571 <dd class="defbody">
15371572 Schedule with a limited resource. <var>Tasks</var> is a list of tasks,
15721607 </pre>
15731608
15741609 </dd>
1575 <dt class="pubdef"><a name="disjoint2/1"><strong>disjoint2</strong>(<var>+Rectangles</var>)</a></dt>
1610 <dt class="pubdef"><a id="disjoint2/1"><strong>disjoint2</strong>(<var>+Rectangles</var>)</a></dt>
15761611 <dd class="defbody">
15771612 True iff <var>Rectangles</var> are not overlapping. <var>Rectangles</var>
15781613 is a list of terms of the form F(X_i, W_i, Y_i, H_i), where F is any
15791614 functor, and the arguments are finite domain variables or integers that
15801615 denote, respectively, the X coordinate, width, Y coordinate and height
15811616 of each rectangle.</dd>
1582 <dt class="pubdef"><a name="automaton/3"><strong>automaton</strong>(<var>+Vs,
1617 <dt class="pubdef"><a id="automaton/3"><strong>automaton</strong>(<var>+Vs,
15831618 +Nodes, +Arcs</var>)</a></dt>
15841619 <dd class="defbody">
15851620 Describes a list of finite domain variables with a finite automaton.
16061641 </pre>
16071642
16081643 </dd>
1609 <dt class="pubdef"><a name="automaton/8"><strong>automaton</strong>(<var>+Sequence,
1644 <dt class="pubdef"><a id="automaton/8"><strong>automaton</strong>(<var>+Sequence,
16101645 ?Template, +Signature, +Nodes, +Arcs, +Counters, +Initials, ?Finals</var>)</a></dt>
16111646 <dd class="defbody">
16121647 Describes a list of finite domain variables with a finite automaton.
16781713 </pre>
16791714
16801715 </dd>
1681 <dt class="pubdef"><a name="chain/2"><strong>chain</strong>(<var>+Zs,
1716 <dt class="pubdef"><a id="chain/2"><strong>chain</strong>(<var>+Zs,
16821717 +Relation</var>)</a></dt>
16831718 <dd class="defbody">
16841719 <var>Zs</var> form a chain with respect to <var>Relation</var>. <var>Zs</var>
16981733 <p></dd>
16991734 </dl>
17001735
1701 <p><h4 id="sec:clpfd-reification-predicates"><a name="sec:A.8.17.5"><span class="sec-nr">A.8.17.5</span> <span class="sec-title">Reification
1736 <p><h4 id="sec:clpfd-reification-predicates"><a id="sec:A.8.17.5"><span class="sec-nr">A.8.17.5</span> <span class="sec-title">Reification
17021737 predicates</span></a></h4>
17031738
1704 <p><a name="sec:clpfd-reification-predicates"></a>
1739 <p><a id="sec:clpfd-reification-predicates"></a>
17051740
17061741 <p>Many CLP(FD) constraints can be <i>reified</i>. This means that their
17071742 truth value is itself turned into a CLP(FD) variable, so that we can
17081743 explicitly reason about whether a constraint holds or not. See
1709 reification (<a class="sec" href="clpfd.html">section A.8.12</a>).
1744 reification (<a class="sec" href="clpfd.html#sec:A.8.12">section A.8.12</a>).
17101745
17111746 <dl class="latex">
1712 <dt class="pubdef"><a name="#\/1"><strong>#\</strong> <var>+Q</var></a></dt>
1713 <dd class="defbody">
1714 <var>Q</var> does <i>not</i> hold. See reification (<a class="sec" href="clpfd.html">section
1747 <dt class="pubdef"><a id="#\/1"><strong>#\</strong> <var>+Q</var></a></dt>
1748 <dd class="defbody">
1749 <var>Q</var> does <i>not</i> hold. See reification (<a class="sec" href="clpfd.html#sec:A.8.12">section
17151750 A.8.12</a>).
17161751
17171752 <p>For example, to obtain the complement of a domain:
17221757 </pre>
17231758
17241759 </dd>
1725 <dt class="pubdef"><a name="#<==>/2"><var>?P</var> <strong>#&lt;==&gt;</strong> <var>?Q</var></a></dt>
1726 <dd class="defbody">
1727 <var>P</var> and <var>Q</var> are equivalent. See reification (<a class="sec" href="clpfd.html">section
1760 <dt class="pubdef"><a id="#<==>/2"><var>?P</var> <strong>#&lt;==&gt;</strong> <var>?Q</var></a></dt>
1761 <dd class="defbody">
1762 <var>P</var> and <var>Q</var> are equivalent. See reification (<a class="sec" href="clpfd.html#sec:A.8.12">section
17281763 A.8.12</a>).
17291764
17301765 <p>For example:
17631798 </pre>
17641799
17651800 </dd>
1766 <dt class="pubdef"><a name="#==>/2"><var>?P</var> <strong>#==&gt;</strong> <var>?Q</var></a></dt>
1767 <dd class="defbody">
1768 <var>P</var> implies <var>Q</var>. See reification (<a class="sec" href="clpfd.html">section
1801 <dt class="pubdef"><a id="#==>/2"><var>?P</var> <strong>#==&gt;</strong> <var>?Q</var></a></dt>
1802 <dd class="defbody">
1803 <var>P</var> implies <var>Q</var>. See reification (<a class="sec" href="clpfd.html#sec:A.8.12">section
17691804 A.8.12</a>).</dd>
1770 <dt class="pubdef"><a name="#<==/2"><var>?P</var> <strong>#&lt;==</strong> <var>?Q</var></a></dt>
1771 <dd class="defbody">
1772 <var>Q</var> implies <var>P</var>. See reification (<a class="sec" href="clpfd.html">section
1805 <dt class="pubdef"><a id="#<==/2"><var>?P</var> <strong>#&lt;==</strong> <var>?Q</var></a></dt>
1806 <dd class="defbody">
1807 <var>Q</var> implies <var>P</var>. See reification (<a class="sec" href="clpfd.html#sec:A.8.12">section
17731808 A.8.12</a>).</dd>
1774 <dt class="pubdef"><a name="#/\/2"><var>?P</var> <strong>#/\</strong> <var>?Q</var></a></dt>
1775 <dd class="defbody">
1776 <var>P</var> and <var>Q</var> hold. See reification (<a class="sec" href="clpfd.html">section
1809 <dt class="pubdef"><a id="#/\/2"><var>?P</var> <strong>#/\</strong> <var>?Q</var></a></dt>
1810 <dd class="defbody">
1811 <var>P</var> and <var>Q</var> hold. See reification (<a class="sec" href="clpfd.html#sec:A.8.12">section
17771812 A.8.12</a>).</dd>
1778 <dt class="pubdef"><a name="#\//2"><var>?P</var> <strong>#\/</strong> <var>?Q</var></a></dt>
1779 <dd class="defbody">
1780 <var>P</var> or <var>Q</var> holds. See reification (<a class="sec" href="clpfd.html">section
1813 <dt class="pubdef"><a id="#\//2"><var>?P</var> <strong>#\/</strong> <var>?Q</var></a></dt>
1814 <dd class="defbody">
1815 <var>P</var> or <var>Q</var> holds. See reification (<a class="sec" href="clpfd.html#sec:A.8.12">section
17811816 A.8.12</a>).
17821817
17831818 <p>For example, the sum of natural numbers below 1000 that are multiples
17931828 </pre>
17941829
17951830 </dd>
1796 <dt class="pubdef"><a name="#\/2"><var>?P</var> <strong>#\</strong> <var>?Q</var></a></dt>
1831 <dt class="pubdef"><a id="#\/2"><var>?P</var> <strong>#\</strong> <var>?Q</var></a></dt>
17971832 <dd class="defbody">
17981833 Either <var>P</var> holds or <var>Q</var> holds, but not both. See
1799 reification (<a class="sec" href="clpfd.html">section A.8.12</a>).</dd>
1800 <dt class="pubdef"><a name="zcompare/3"><strong>zcompare</strong>(<var>?Order,
1834 reification (<a class="sec" href="clpfd.html#sec:A.8.12">section A.8.12</a>).</dd>
1835 <dt class="pubdef"><a id="zcompare/3"><strong>zcompare</strong>(<var>?Order,
18011836 ?A, ?B</var>)</a></dt>
18021837 <dd class="defbody">
18031838 Analogous to <a class="pred" href="compare.html#compare/3">compare/3</a>,
18561891 ensures that the respective ordering between N and 0 holds in each case.
18571892
18581893 <p>The truth value of a comparison can also be reified with (<code>#&lt;==&gt;</code>)/2
1859 in combination with one of the <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html">section
1860 A.8.2</a>). See reification (<a class="sec" href="clpfd.html">section
1894 in combination with one of the <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html#sec:A.8.2">section
1895 A.8.2</a>). See reification (<a class="sec" href="clpfd.html#sec:A.8.12">section
18611896 A.8.12</a>). However, <a class="pred" href="clpfd.html#zcompare/3">zcompare/3</a>
18621897 lets you more conveniently distinguish the cases.
18631898 </dd>
18641899 </dl>
18651900
1866 <p><h4 id="sec:clpfd-reflection-predicates"><a name="sec:A.8.17.6"><span class="sec-nr">A.8.17.6</span> <span class="sec-title">Reflection
1901 <p><h4 id="sec:clpfd-reflection-predicates"><a id="sec:A.8.17.6"><span class="sec-nr">A.8.17.6</span> <span class="sec-title">Reflection
18671902 predicates</span></a></h4>
18681903
1869 <p><a name="sec:clpfd-reflection-predicates"></a>
1904 <p><a id="sec:clpfd-reflection-predicates"></a>
18701905
18711906 <p>Reflection predicates let us obtain, in a well-defined way,
18721907 information that is normally internal to this library. In addition to
18771912 useful in program analyzers and declarative debuggers.
18781913
18791914 <dl class="latex">
1880 <dt class="pubdef"><a name="fd_var/1"><strong>fd_var</strong>(<var>+Var</var>)</a></dt>
1915 <dt class="pubdef"><a id="fd_var/1"><strong>fd_var</strong>(<var>+Var</var>)</a></dt>
18811916 <dd class="defbody">
18821917 True iff <var>Var</var> is a CLP(FD) variable.</dd>
1883 <dt class="pubdef"><a name="fd_inf/2"><strong>fd_inf</strong>(<var>+Var,
1918 <dt class="pubdef"><a id="fd_inf/2"><strong>fd_inf</strong>(<var>+Var,
18841919 -Inf</var>)</a></dt>
18851920 <dd class="defbody">
18861921 <var>Inf</var> is the infimum of the current domain of <var>Var</var>.</dd>
1887 <dt class="pubdef"><a name="fd_sup/2"><strong>fd_sup</strong>(<var>+Var,
1922 <dt class="pubdef"><a id="fd_sup/2"><strong>fd_sup</strong>(<var>+Var,
18881923 -Sup</var>)</a></dt>
18891924 <dd class="defbody">
18901925 <var>Sup</var> is the supremum of the current domain of <var>Var</var>.</dd>
1891 <dt class="pubdef"><a name="fd_size/2"><strong>fd_size</strong>(<var>+Var,
1926 <dt class="pubdef"><a id="fd_size/2"><strong>fd_size</strong>(<var>+Var,
18921927 -Size</var>)</a></dt>
18931928 <dd class="defbody">
18941929 Reflect the current size of a domain. <var>Size</var> is the number of
18951930 elements of the current domain of <var>Var</var>, or the atom <b>sup</b>
18961931 if the domain is unbounded.</dd>
1897 <dt class="pubdef"><a name="fd_dom/2"><strong>fd_dom</strong>(<var>+Var,
1932 <dt class="pubdef"><a id="fd_dom/2"><strong>fd_dom</strong>(<var>+Var,
18981933 -Dom</var>)</a></dt>
18991934 <dd class="defbody">
19001935 <var>Dom</var> is the current domain (see <a class="pred" href="clpfd.html#in/2">in/2</a>)
19281963 <p></dd>
19291964 </dl>
19301965
1931 <p><h3 id="sec:clpfd-closing-opening"><a name="sec:A.8.18"><span class="sec-nr">A.8.18</span> <span class="sec-title">Closing
1966 <p><h3 id="sec:clpfd-closing-opening"><a id="sec:A.8.18"><span class="sec-nr">A.8.18</span> <span class="sec-title">Closing
19321967 and opening words about CLP(FD)</span></a></h3>
19331968
1934 <p><a name="sec:clpfd-closing-opening"></a>
1969 <p><a id="sec:clpfd-closing-opening"></a>
19351970
19361971 <p>CLP(FD) constraints are one of the main reasons why logic programming
19371972 approaches are picked over other paradigms for solving many tasks of
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.9</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="clpfd.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="csv.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:clpqr"><a name="sec:A.9"><span class="sec-nr">A.9</span> <span class="sec-title">library(clpqr):
235 <h2 id="sec:clpqr"><a id="sec:A.9"><span class="sec-nr">A.9</span> <span class="sec-title">library(clpqr):
195236 Constraint Logic Programming over Rationals and Reals</span></a></h2>
196237
197 <a name="sec:clpqr"></a>
198 <a name="sec:lib:clpqr"></a>
238 <a id="sec:clpqr"></a>
239 <a id="sec:lib:clpqr"></a>
199240 <blockquote> Author: <em>Christian Holzbaur</em>, ported to SWI-Prolog
200241 by <em>Leslie De Koninck</em>, K.U. Leuven
201242 </blockquote>
203244 <p>This CLP(Q,R) system is a port of the CLP(Q,R) system of Sicstus
204245 Prolog by Christian Holzbaur: Holzbaur C.: OFAI clp(q,r) Manual, Edition
205246 1.3.3, Austrian Research Institute for Artificial Intelligence, Vienna,
206 TR-95-09, 1995.<sup class="fn">181<span class="fn-text">http://www.ai.univie.ac.at/cgi-bin/tr-online?number+95-09</span></sup>
247 TR-95-09, 1995.<sup class="fn">182<span class="fn-text">http://www.ai.univie.ac.at/cgi-bin/tr-online?number+95-09</span></sup>
207248 This manual is roughly based on the manual of the above mentioned
208249 CLP(Q,R) implementation.
209250
232273 :- use_module(library(clpr)).
233274 </pre>
234275
235 <p><h3 id="sec:clpqr-predicates"><a name="sec:A.9.1"><span class="sec-nr">A.9.1</span> <span class="sec-title">Solver
276 <p><h3 id="sec:clpqr-predicates"><a id="sec:A.9.1"><span class="sec-nr">A.9.1</span> <span class="sec-title">Solver
236277 predicates</span></a></h3>
237278
238 <a name="sec:clpqr-predicates"></a> The following predicates are
239 provided to work with constraints:
279 <a id="sec:clpqr-predicates"></a> The following predicates are provided
280 to work with constraints:
240281
241282 <dl class="latex">
242 <dt class="pubdef"><a name="{}/1"><strong>{}</strong>(<var>+Constraints</var>)</a></dt>
283 <dt class="pubdef"><a id="{}/1"><strong>{}</strong>(<var>+Constraints</var>)</a></dt>
243284 <dd class="defbody">
244285 Adds the constraints given by <var>Constraints</var> to the constraint
245286 store.</dd>
246 <dt class="pubdef"><a name="entailed/1"><strong>entailed</strong>(<var>+Constraint</var>)</a></dt>
287 <dt class="pubdef"><a id="entailed/1"><strong>entailed</strong>(<var>+Constraint</var>)</a></dt>
247288 <dd class="defbody">
248289 Succeeds if <var>Constraint</var> is necessarily true within the current
249290 constraint store. This means that adding the negation of the constraint
250291 to the store results in failure.</dd>
251 <dt class="pubdef"><a name="inf/2"><strong>inf</strong>(<var>+Expression,
292 <dt class="pubdef"><a id="inf/2"><strong>inf</strong>(<var>+Expression,
252293 -Inf</var>)</a></dt>
253294 <dd class="defbody">
254295 Computes the infimum of <var>Expression</var> within the current state
255296 of the constraint store and returns that infimum in <var>Inf</var>. This
256297 predicate does not change the constraint store.</dd>
257 <dt class="pubdef"><a name="sup/2"><strong>sup</strong>(<var>+Expression,
298 <dt class="pubdef"><a id="sup/2"><strong>sup</strong>(<var>+Expression,
258299 -Sup</var>)</a></dt>
259300 <dd class="defbody">
260301 Computes the supremum of <var>Expression</var> within the current state
261302 of the constraint store and returns that supremum in <var>Sup</var>.
262303 This predicate does not change the constraint store.</dd>
263 <dt class="pubdef"><a name="minimize/1"><strong>minimize</strong>(<var>+Expression</var>)</a></dt>
304 <dt class="pubdef"><a id="minimize/1"><strong>minimize</strong>(<var>+Expression</var>)</a></dt>
264305 <dd class="defbody">
265306 Minimizes <var>Expression</var> within the current constraint store.
266307 This is the same as computing the infimum and equating the expression to
267308 that infimum.</dd>
268 <dt class="pubdef"><a name="maximize/1"><strong>maximize</strong>(<var>+Expression</var>)</a></dt>
309 <dt class="pubdef"><a id="maximize/1"><strong>maximize</strong>(<var>+Expression</var>)</a></dt>
269310 <dd class="defbody">
270311 Maximizes <var>Expression</var> within the current constraint store.
271312 This is the same as computing the supremum and equating the expression
272313 to that supremum.</dd>
273 <dt class="pubdef"><a name="bb_inf/5"><strong>bb_inf</strong>(<var>+Ints,
314 <dt class="pubdef"><a id="bb_inf/5"><strong>bb_inf</strong>(<var>+Ints,
274315 +Expression, -Inf, -Vertex, +Eps</var>)</a></dt>
275316 <dd class="defbody">
276317 This predicate is offered in CLP(R) only. It computes the infimum of
281322 an integer to be considered an integer. E.g. when
282323 <var>Eps</var> = 0.001, then X = 4.999 will be considered as an integer
283324 (5 in this case). <var>Eps</var> should be between 0 and 0.5.</dd>
284 <dt class="pubdef"><a name="bb_inf/4"><strong>bb_inf</strong>(<var>+Ints,
325 <dt class="pubdef"><a id="bb_inf/4"><strong>bb_inf</strong>(<var>+Ints,
285326 +Expression, -Inf, -Vertex</var>)</a></dt>
286327 <dd class="defbody">
287328 This predicate is offered in CLP(Q) only. It behaves the same as
288329 <a class="pred" href="clpqr.html#bb_inf/5">bb_inf/5</a> but does not use
289330 an error margin.</dd>
290 <dt class="pubdef"><a name="bb_inf/3"><strong>bb_inf</strong>(<var>+Ints,
331 <dt class="pubdef"><a id="bb_inf/3"><strong>bb_inf</strong>(<var>+Ints,
291332 +Expression, -Inf</var>)</a></dt>
292333 <dd class="defbody">
293334 The same as <a class="pred" href="clpqr.html#bb_inf/5">bb_inf/5</a> or <a class="pred" href="clpqr.html#bb_inf/4">bb_inf/4</a>
294335 but without returning the values of the integers. In CLP(R), an error
295336 margin of 0.001 is used.</dd>
296 <dt class="pubdef"><a name="dump/3"><strong>dump</strong>(<var>+Target,
337 <dt class="pubdef"><a id="dump/3"><strong>dump</strong>(<var>+Target,
297338 +Newvars, -CodedAnswer</var>)</a></dt>
298339 <dd class="defbody">
299340 Returns the constraints on <var>Target</var> in the list <var>CodedAnswer</var>
310351 <p></dd>
311352 </dl>
312353
313 <p><h3 id="sec:clpqr-arg-syntax"><a name="sec:A.9.2"><span class="sec-nr">A.9.2</span> <span class="sec-title">Syntax
354 <p><h3 id="sec:clpqr-arg-syntax"><a id="sec:A.9.2"><span class="sec-nr">A.9.2</span> <span class="sec-title">Syntax
314355 of the predicate arguments</span></a></h3>
315356
316 <a name="sec:clpqr-arg-syntax"></a> The arguments of the predicates
357 <a id="sec:clpqr-arg-syntax"></a> The arguments of the predicates
317358 defined in the subsection above are defined in <a class="tab" href="clpqr.html#tab:clpqrbnf">table
318359 10</a>. Failing to meet the syntax rules will result in an exception.
319360 <div style="text-align:center">
320 <table border="2" frame="box" rules="groups">
321 <tr valign="top"><td>&lt;<var>Constraints</var>&gt; </td><td align=right>::=</td><td>&lt;<var>Constraint</var>&gt; </td><td>single
361 <table class="latex frame-box">
362 <tr><td>&lt;<var>Constraints</var>&gt; </td><td align=right>::=</td><td>&lt;<var>Constraint</var>&gt; </td><td>single
322363 constraint </td></tr>
323 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Constraint</var>&gt;
324 , &lt;<var>Constraints</var>&gt; </td><td>conjunction </td></tr>
325 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Constraint</var>&gt;
326 ; &lt;<var>Constraints</var>&gt; </td><td>disjunction </td></tr>
327 <tr valign="top"><td>
364 <tr><td></td><td align=right>|</td><td>&lt;<var>Constraint</var>&gt; , &lt;<var>Constraints</var>&gt; </td><td>conjunction </td></tr>
365 <tr><td></td><td align=right>|</td><td>&lt;<var>Constraint</var>&gt; ; &lt;<var>Constraints</var>&gt; </td><td>disjunction </td></tr>
366 <tr><td>
328367
329368 <p>&lt;<var>Constraint</var>&gt; </td><td align=right>::=</td><td>&lt;<var>Expression</var>&gt; <code>&lt;</code> &lt;<var>Expression</var>&gt; </td><td>less
330369 than </td></tr>
331 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>&gt;</code> &lt;<var>Expression</var>&gt; </td><td>greater
370 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>&gt;</code> &lt;<var>Expression</var>&gt; </td><td>greater
332371 than </td></tr>
333 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>=&lt;</code> &lt;<var>Expression</var>&gt; </td><td>less
372 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>=&lt;</code> &lt;<var>Expression</var>&gt; </td><td>less
334373 or equal </td></tr>
335 <tr valign="top"><td></td><td align=right>|</td><td><code>&lt;=</code>(&lt;<var>Expression</var>&gt;, &lt;<var>Expression</var>&gt;)</td><td>less
374 <tr><td></td><td align=right>|</td><td><code>&lt;=</code>(&lt;<var>Expression</var>&gt;, &lt;<var>Expression</var>&gt;)</td><td>less
336375 or equal </td></tr>
337 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>&gt;=</code> &lt;<var>Expression</var>&gt; </td><td>greater
376 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>&gt;=</code> &lt;<var>Expression</var>&gt; </td><td>greater
338377 or equal </td></tr>
339 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>=\=</code> &lt;<var>Expression</var>&gt; </td><td>not
378 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>=\=</code> &lt;<var>Expression</var>&gt; </td><td>not
340379 equal </td></tr>
341 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt;
342 =:= &lt;<var>Expression</var>&gt; </td><td>equal </td></tr>
343 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt;
344 = &lt;<var>Expression</var>&gt; </td><td>equal </td></tr>
345 <tr valign="top"><td>
380 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; =:= &lt;<var>Expression</var>&gt; </td><td>equal </td></tr>
381 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; = &lt;<var>Expression</var>&gt; </td><td>equal </td></tr>
382 <tr><td>
346383
347384 <p>&lt;<var>Expression</var>&gt; </td><td align=right>::=</td><td>&lt;<var>Variable</var>&gt; </td><td>Prolog
348385 variable </td></tr>
349 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Number</var>&gt; </td><td>Prolog
386 <tr><td></td><td align=right>|</td><td>&lt;<var>Number</var>&gt; </td><td>Prolog
350387 number </td></tr>
351 <tr valign="top"><td></td><td align=right>|</td><td>+&lt;<var>Expression</var>&gt; </td><td>unary
388 <tr><td></td><td align=right>|</td><td>+&lt;<var>Expression</var>&gt; </td><td>unary
352389 plus </td></tr>
353 <tr valign="top"><td></td><td align=right>|</td><td>-&lt;<var>Expression</var>&gt; </td><td>unary
390 <tr><td></td><td align=right>|</td><td>-&lt;<var>Expression</var>&gt; </td><td>unary
354391 minus </td></tr>
355 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt;
356 + &lt;<var>Expression</var>&gt; </td><td>addition </td></tr>
357 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt;
358 - &lt;<var>Expression</var>&gt; </td><td>substraction </td></tr>
359 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt;
360 * &lt;<var>Expression</var>&gt; </td><td>multiplication </td></tr>
361 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt;
362 / &lt;<var>Expression</var>&gt; </td><td>division </td></tr>
363 <tr valign="top"><td></td><td align=right>|</td><td>abs(&lt;<var>Expression</var>&gt;)</td><td>absolute
392 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; + &lt;<var>Expression</var>&gt; </td><td>addition </td></tr>
393 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; - &lt;<var>Expression</var>&gt; </td><td>substraction </td></tr>
394 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; * &lt;<var>Expression</var>&gt; </td><td>multiplication </td></tr>
395 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; / &lt;<var>Expression</var>&gt; </td><td>division </td></tr>
396 <tr><td></td><td align=right>|</td><td>abs(&lt;<var>Expression</var>&gt;)</td><td>absolute
364397 value </td></tr>
365 <tr valign="top"><td></td><td align=right>|</td><td>sin(&lt;<var>Expression</var>&gt;)</td><td>sine </td></tr>
366 <tr valign="top"><td></td><td align=right>|</td><td>cos(&lt;<var>Expression</var>&gt;)</td><td>cosine </td></tr>
367 <tr valign="top"><td></td><td align=right>|</td><td>tan(&lt;<var>Expression</var>&gt;)</td><td>tangent </td></tr>
368 <tr valign="top"><td></td><td align=right>|</td><td>exp(&lt;<var>Expression</var>&gt;)</td><td>exponent </td></tr>
369 <tr valign="top"><td></td><td align=right>|</td><td>pow(&lt;<var>Expression</var>&gt;)</td><td>exponent </td></tr>
370 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>^</code> &lt;<var>Expression</var>&gt; </td><td>exponent </td></tr>
371 <tr valign="top"><td></td><td align=right>|</td><td>min(&lt;<var>Expression</var>&gt;, &lt;<var>Expression</var>&gt;)</td><td>minimum </td></tr>
372 <tr valign="top"><td></td><td align=right>|</td><td>max(&lt;<var>Expression</var>&gt;, &lt;<var>Expression</var>&gt;)</td><td>maximum </td></tr>
398 <tr><td></td><td align=right>|</td><td>sin(&lt;<var>Expression</var>&gt;)</td><td>sine </td></tr>
399 <tr><td></td><td align=right>|</td><td>cos(&lt;<var>Expression</var>&gt;)</td><td>cosine </td></tr>
400 <tr><td></td><td align=right>|</td><td>tan(&lt;<var>Expression</var>&gt;)</td><td>tangent </td></tr>
401 <tr><td></td><td align=right>|</td><td>exp(&lt;<var>Expression</var>&gt;)</td><td>exponent </td></tr>
402 <tr><td></td><td align=right>|</td><td>pow(&lt;<var>Expression</var>&gt;)</td><td>exponent </td></tr>
403 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>^</code> &lt;<var>Expression</var>&gt; </td><td>exponent </td></tr>
404 <tr><td></td><td align=right>|</td><td>min(&lt;<var>Expression</var>&gt;, &lt;<var>Expression</var>&gt;)</td><td>minimum </td></tr>
405 <tr><td></td><td align=right>|</td><td>max(&lt;<var>Expression</var>&gt;, &lt;<var>Expression</var>&gt;)</td><td>maximum </td></tr>
373406 </table>
374407 <div class="caption"><b>Table 10 : </b>CLP(Q,R) constraint BNF</div>
375 <a name="tab:clpqrbnf"></a>
408 <a id="tab:clpqrbnf"></a>
376409 </div>
377410
378 <p><h3 id="sec:clpqr-unification"><a name="sec:A.9.3"><span class="sec-nr">A.9.3</span> <span class="sec-title">Use
411 <p><h3 id="sec:clpqr-unification"><a id="sec:A.9.3"><span class="sec-nr">A.9.3</span> <span class="sec-title">Use
379412 of unification</span></a></h3>
380413
381 <a name="sec:clpqr-unification"></a>
414 <a id="sec:clpqr-unification"></a>
382415
383416 <p>Instead of using the <a class="pred" href="clpqr.html#{}/1">{}/1</a>
384417 predicate, you can also use the standard unification mechanism to store
406439 <p>
407440 </ul>
408441
409 <p><h3 id="sec:clpqr-non-linear"><a name="sec:A.9.4"><span class="sec-nr">A.9.4</span> <span class="sec-title">Non-linear
442 <p><h3 id="sec:clpqr-non-linear"><a id="sec:A.9.4"><span class="sec-nr">A.9.4</span> <span class="sec-title">Non-linear
410443 constraints</span></a></h3>
411444
412 <a name="sec:clpqr-non-linear"></a> The CLP(Q,R) system deals only
445 <a id="sec:clpqr-non-linear"></a> The CLP(Q,R) system deals only
413446 passively with non-linear constraints. They remain in a passive state
414447 until certain conditions are satisfied. These conditions, which are
415448 called the isolation axioms, are given in
416449 <a class="tab" href="clpqr.html#tab:clpqraxioms">table 11</a>.
417450 <div style="text-align:center">
418 <table border="2" frame="box" rules="groups">
419 <tr valign="top"><td><var>A = B * C</var> </td><td>B or C is ground</td><td>A
420 = 5 * C or A = B * 4 </td></tr>
421 <tr valign="top"><td></td><td>A and (B or C) are ground</td><td>20 = 5 *
422 C or 20 = B * 4 </td></tr>
423 <tbody>
424 <tr valign="top"><td><var>A = B / C</var> </td><td>C is ground</td><td>A
451 <table class="latex frame-box">
452 <tr><td><var>A = B * C</var> </td><td>B or C is ground</td><td>A = 5 * C
453 or A = B * 4 </td></tr>
454 <tr><td></td><td>A and (B or C) are ground</td><td>20 = 5 * C or 20 = B
455 * 4 </td></tr>
456 <tr class="hline"><td><var>A = B / C</var> </td><td>C is ground</td><td>A
425457 = B / 3 </td></tr>
426 <tr valign="top"><td></td><td>A and B are ground</td><td>4 = 12 / C </td></tr>
427 <tbody>
428 <tr valign="top"><td><var>X = min(Y,Z)</var> </td><td>Y and Z are ground</td><td>X
429 = min(4,3) </td></tr>
430 <tr valign="top"><td><var>X = max(Y,Z)</var> </td><td>Y and Z are ground</td><td>X
431 = max(4,3) </td></tr>
432 <tr valign="top"><td><var>X = abs(Y)</var> </td><td>Y is ground</td><td>X
433 = abs(-7) </td></tr>
434 <tbody>
435 <tr valign="top"><td><var>X = pow(Y,Z)</var> </td><td>X and Y are ground</td><td>8
436 = 2 <code>^</code> Z </td></tr>
437 <tr valign="top"><td><var>X = exp(Y,Z)</var> </td><td>X and Z are ground</td><td>8
438 = Y <code>^</code> 3 </td></tr>
439 <tr valign="top"><td><var>X = Y</var> <code>^</code> <var>Z</var> </td><td>Y
440 and Z are ground</td><td>X = 2 <code>^</code> 3 </td></tr>
441 <tbody>
442 <tr valign="top"><td><var>X = sin(Y)</var> </td><td>X is ground</td><td>1
458 <tr><td></td><td>A and B are ground</td><td>4 = 12 / C </td></tr>
459 <tr class="hline"><td><var>X = min(Y,Z)</var> </td><td>Y and Z are
460 ground</td><td>X = min(4,3) </td></tr>
461 <tr><td><var>X = max(Y,Z)</var> </td><td>Y and Z are ground</td><td>X =
462 max(4,3) </td></tr>
463 <tr><td><var>X = abs(Y)</var> </td><td>Y is ground</td><td>X = abs(-7) </td></tr>
464 <tr class="hline"><td><var>X = pow(Y,Z)</var> </td><td>X and Y are
465 ground</td><td>8 = 2 <code>^</code> Z </td></tr>
466 <tr><td><var>X = exp(Y,Z)</var> </td><td>X and Z are ground</td><td>8 =
467 Y <code>^</code> 3 </td></tr>
468 <tr><td><var>X = Y</var> <code>^</code> <var>Z</var> </td><td>Y and Z
469 are ground</td><td>X = 2 <code>^</code> 3 </td></tr>
470 <tr class="hline"><td><var>X = sin(Y)</var> </td><td>X is ground</td><td>1
443471 = sin(Y) </td></tr>
444 <tr valign="top"><td><var>X = cos(Y)</var> </td><td>Y is ground</td><td>X
445 = sin(1.5707) </td></tr>
446 <tr valign="top"><td><var>X = tan(Y)</var> </td><td></td></tr>
472 <tr><td><var>X = cos(Y)</var> </td><td>Y is ground</td><td>X =
473 sin(1.5707) </td></tr>
474 <tr><td><var>X = tan(Y)</var> </td><td></td></tr>
447475 </table>
448476 <div class="caption"><b>Table 11 : </b>CLP(Q,R) isolating axioms</div>
449 <a name="tab:clpqraxioms"></a>
477 <a id="tab:clpqraxioms"></a>
450478 </div>
451479
452 <p><h3 id="sec:clpqr-status"><a name="sec:A.9.5"><span class="sec-nr">A.9.5</span> <span class="sec-title">Status
480 <p><h3 id="sec:clpqr-status"><a id="sec:A.9.5"><span class="sec-nr">A.9.5</span> <span class="sec-title">Status
453481 and known problems</span></a></h3>
454482
455 <a name="sec:clpqr-status"></a>
483 <a id="sec:clpqr-status"></a>
456484
457485 <p>The clpq and clpr libraries are `orphaned', i.e., they currently have
458486 no maintainer.
475503
476504 <p>
477505 <li><i>Dumping constraints</i><br>
478 The first argument of <a name="idx:dump3:2144"></a><a class="pred" href="clpqr.html#dump/3">dump/3</a>
506 The first argument of <a id="idx:dump3:2148"></a><a class="pred" href="clpqr.html#dump/3">dump/3</a>
479507 has to be a list of free variables at call-time:
480508
481509 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="initgoal.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="gemacs.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:cmdline"><a name="sec:2.4"><span class="sec-nr">2.4</span> <span class="sec-title">Command
235 <h2 id="sec:cmdline"><a id="sec:2.4"><span class="sec-nr">2.4</span> <span class="sec-title">Command
195236 line options</span></a></h2>
196237
197 <a name="sec:cmdline"></a>
238 <a id="sec:cmdline"></a>
198239
199240 <p>SWI-Prolog can be executed in one of the following modes:
200241
205246 <dt><b><code>swipl --dump-runtime-variables</code></b></dt>
206247 <dd class="defbody">
207248 These options must appear as only option. They cause Prolog to print an
208 informational message and exit. See <a class="sec" href="cmdline.html">section
249 informational message and exit. See <a class="sec" href="cmdline.html#sec:2.4.1">section
209250 2.4.1</a>.</dd>
210251 <dt><b><code>swipl</code> [<var>option</var> ...] <var>script-file</var>
211252 [<var>arg</var> ...]</b></dt>
217258 ... [[<code>--</code>] <var>arg</var> ...]</b></dt>
218259 <dd class="defbody">
219260 This is the normal way to start Prolog. The options are described in
220 <a class="sec" href="cmdline.html">section 2.4.2</a>, <a class="sec" href="cmdline.html">section
221 2.4.3</a> and <a class="sec" href="cmdline.html">section 2.4.4</a>. The
222 Prolog flag <a class="flag" href="flags.html#flag:argv">argv</a>
261 <a class="sec" href="cmdline.html#sec:2.4.2">section 2.4.2</a>, <a class="sec" href="cmdline.html#sec:2.4.3">section
262 2.4.3</a> and <a class="sec" href="cmdline.html#sec:2.4.4">section 2.4.4</a>.
263 The Prolog flag <a class="flag" href="flags.html#flag:argv">argv</a>
223264 provides access to <var>arg</var> ... If the <var>options</var> are
224265 followed by one or more Prolog file names (i.e., names with extension <code>.pl</code>, <code>.prolog</code>
225266 or (on Windows) the user preferred extension registered during
227268 the Prolog flag
228269 <a class="flag" href="flags.html#flag:associated_file">associated_file</a>.
229270 In addition, <b>pl-win[.exe]</b> switches to the directory in which this
230 primary source file is located using <a name="idx:workingdirectory2:24"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.</dd>
271 primary source file is located using <a id="idx:workingdirectory2:24"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.</dd>
231272 <dt><b><code>swipl</code> -o <var>output</var> -c <var>prolog-file</var>
232273 ...</b></dt>
233274 <dd class="defbody">
234275 The <strong>-c</strong> option is used to compile a set of Prolog files
235 into an executable. See <a class="sec" href="cmdline.html">section 2.4.5</a>.</dd>
276 into an executable. See <a class="sec" href="cmdline.html#sec:2.4.5">section
277 2.4.5</a>.</dd>
236278 <dt><b><code>swipl</code> -o <var>output</var> -b <var>bootfile</var> <var>prolog-file</var>
237279 ...</b></dt>
238280 <dd class="defbody">
239 Bootstrap compilation. See <a class="sec" href="cmdline.html">section
281 Bootstrap compilation. See <a class="sec" href="cmdline.html#sec:2.4.6">section
240282 2.4.6</a>.
241283 </dd>
242284 </dl>
243285
244 <p><h3 id="sec:info-options"><a name="sec:2.4.1"><span class="sec-nr">2.4.1</span> <span class="sec-title">Informational
286 <p><h3 id="sec:info-options"><a id="sec:2.4.1"><span class="sec-nr">2.4.1</span> <span class="sec-title">Informational
245287 command line options</span></a></h3>
246288
247 <a name="sec:info-options"></a>
289 <a id="sec:info-options"></a>
248290
249291 <dl class="latex">
250292 <dt><strong>--arch</strong> <var></var></dt>
258300 <dd class="defbody">
259301 When given as the only option, it prints a sequence of variable settings
260302 that can be used in shell scripts to deal with Prolog parameters. This
261 feature is also used by <b>swipl-ld</b> (see <a class="sec" href="plld.html">section
303 feature is also used by <b>swipl-ld</b> (see <a class="sec" href="plld.html#sec:11.5">section
262304 11.5</a>). Below is a typical example of using this feature.
263305
264306 <pre class="code">
280322 </dd>
281323 </dl>
282324
283 <p><h3 id="sec:running-options"><a name="sec:2.4.2"><span class="sec-nr">2.4.2</span> <span class="sec-title">Command
325 <p><h3 id="sec:running-options"><a id="sec:2.4.2"><span class="sec-nr">2.4.2</span> <span class="sec-title">Command
284326 line options for running Prolog</span></a></h3>
285327
286 <a name="sec:running-options"></a>
328 <a id="sec:running-options"></a>
287329
288330 <dl class="latex">
289331 <dt><strong>--home=DIR</strong> <var></var></dt>
290332 <dd class="defbody">
291 Use DIR as home directory. See <a class="sec" href="findhome.html">section
333 Use DIR as home directory. See <a class="sec" href="findhome.html#sec:11.6">section
292334 11.6</a> for details.</dd>
293335 <dt><strong>--quiet</strong> <var></var></dt>
294336 <dd class="defbody">
295 <a name="idx:verbose:25"></a><a name="idx:quiet:26"></a>Set the Prolog
296 flag <a class="flag" href="flags.html#flag:verbose">verbose</a> to <code>silent</code>,
297 suppressing informational and banner messages. Also available as <strong>-q</strong>.</dd>
337 <a id="idx:verbose:25"></a><a id="idx:quiet:26"></a>Set the Prolog flag <a class="flag" href="flags.html#flag:verbose">verbose</a>
338 to <code>silent</code>, suppressing informational and banner messages.
339 Also available as <strong>-q</strong>.</dd>
298340 <dt><strong>--nodebug</strong> <var></var></dt>
299341 <dd class="defbody">
300 Disable debugging. See the <a name="idx:currentprologflag2:27"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
342 Disable debugging. See the <a id="idx:currentprologflag2:27"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
301343 flag
302344 <a class="flag" href="flags.html#flag:generate_debug_info">generate_debug_info</a>
303345 for details.</dd>
306348 Inhibit any signal handling by Prolog, a property that is sometimes
307349 desirable for embedded applications. This option sets the flag
308350 <a class="flag" href="flags.html#flag:signals">signals</a> to <code>false</code>.
309 See <a class="sec" href="foreigninclude.html">section 11.4.21.1</a> for
310 details. Note that the handler to unblock system calls is still
311 installed. This can be prevented using <code>--sigalert=0</code>
351 See <a class="sec" href="foreigninclude.html#sec:11.4.21.1">section
352 11.4.21.1</a> for details. Note that the handler to unblock system calls
353 is still installed. This can be prevented using <code>--sigalert=0</code>
312354 additionally. See <strong>--sigalert</strong>. This flag also sets
313355 <b>gc_thread</b> to <code>false</code> as synchronization with the
314356 garbage collect thread is based on signals.</dd>
321363 <dt><strong>--sigalert=NUM</strong> <var></var></dt>
322364 <dd class="defbody">
323365 Use signal <var>NUM</var> (1 ... 31) for alerting a thread. This is
324 needed to make <a name="idx:threadsignal2:28"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>,
366 needed to make <a id="idx:threadsignal2:28"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>,
325367 and derived Prolog signal handling act immediately when the target
326 thread is blocked on an interruptable system call (e.g., <a name="idx:sleep1:29"></a><a class="pred" href="miscpreds.html#sleep/1">sleep/1</a>,
368 thread is blocked on an interruptable system call (e.g., <a id="idx:sleep1:29"></a><a class="pred" href="miscpreds.html#sleep/1">sleep/1</a>,
327369 read/write to most devices). The default is to use <code>SIGUSR2</code>.
328370 If <var>NUM</var> is 0 (zero), this handler is not installed.</dd>
329371 <dt><strong>-tty</strong> <var></var></dt>
330372 <dd class="defbody">
331373 Unix only. Switches controlling the terminal for allowing
332 single-character commands to the tracer and <a name="idx:getsinglechar1:30"></a><a class="pred" href="chario.html#get_single_char/1">get_single_char/1</a>.
374 single-character commands to the tracer and <a id="idx:getsinglechar1:30"></a><a class="pred" href="chario.html#get_single_char/1">get_single_char/1</a>.
333375 By default, manipulating the terminal is enabled unless the system
334376 detects it is not connected to a terminal or it is running as a
335377 GNU-Emacs inferior process. See also <a class="flag" href="flags.html#flag:tty_control">tty_control</a>.</dd>
338380 This option is available only in <b>swipl-win.exe</b> and is used for
339381 the start-menu item. If causes <b>plwin</b> to start in the folder
340382 <code>...\My Documents\Prolog</code> or local equivalent thereof (see
341 <a name="idx:winfolder2:31"></a><a class="pred" href="system.html#win_folder/2">win_folder/2</a>).
383 <a id="idx:winfolder2:31"></a><a class="pred" href="system.html#win_folder/2">win_folder/2</a>).
342384 The <code>Prolog</code> subdirectory is created if it does not exist.</dd>
343385 <dt><strong>-O</strong> <var></var></dt>
344386 <dd class="defbody">
345 Optimised compilation. See <a name="idx:currentprologflag2:32"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
387 Optimised compilation. See <a id="idx:currentprologflag2:32"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
346388 flag
347389 <a class="flag" href="flags.html#flag:optimise">optimise</a> for
348390 details.</dd>
351393 Load <var>file</var>. This flag provides compatibility with some other
352394 Prolog systems.<sup class="fn">10<span class="fn-text">YAP, SICStus</span></sup>
353395 It is used in SWI-Prolog to skip the program initialization specified
354 using <a name="idx:initialization2:33"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
355 directives. See also <a class="sec" href="compilation.html">section
356 2.10.2.1</a>, and <a name="idx:initialize0:34"></a><span class="pred-ext">initialize/0</span>.</dd>
396 using <a id="idx:initialization2:33"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
397 directives. See also <a class="sec" href="compilation.html#sec:2.10.2.1">section
398 2.10.2.1</a>, and <a id="idx:initialize0:34"></a><span class="pred-ext">initialize/0</span>.</dd>
357399 <dt><strong>-s</strong> <var>file</var></dt>
358400 <dd class="defbody">
359401 Use <var>file</var> as a script file. The script file is loaded after
366408 <code>.swiplrc</code> (Unix) or <code>swipl.ini</code> (Windows). `<strong>-f</strong> <var>none</var>'
367409 stops SWI-Prolog from searching for a startup file. This option can be
368410 used as an alternative to <strong>-s</strong> <var>file</var> that stops
369 Prolog from loading the personal initialisation file. See also <a class="sec" href="initfile.html">section
411 Prolog from loading the personal initialisation file. See also <a class="sec" href="initfile.html#sec:2.2">section
370412 2.2</a>.</dd>
371413 <dt><strong>-F</strong> <var>script</var></dt>
372414 <dd class="defbody">
386428 A boot file is a file resulting from a Prolog compilation using the
387429 <strong>-b</strong> or <strong>-c</strong> option or a program saved
388430 using
389 <a name="idx:qsaveprogram12:35"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.</dd>
431 <a id="idx:qsaveprogram12:35"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.</dd>
390432 <dt><strong>-p</strong> <var>alias=path1[:path2 ... ]</var></dt>
391433 <dd class="defbody">
392434 Define a path alias for file_search_path. <var>alias</var> is the name
393435 of the alias, and arg path1 ... is a list of values for the alias. On
394436 Windows the list separator is <code><code>;</code></code>. On other
395437 systems it is <code><code>:</code></code>. A value is either a term of
396 the form alias(value) or pathname. The computed aliases are added to <a name="idx:filesearchpath2:36"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
397 using <a name="idx:asserta1:37"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>,
398 so they precede predefined values for the alias. See <a name="idx:filesearchpath2:38"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
438 the form alias(value) or pathname. The computed aliases are added to <a id="idx:filesearchpath2:36"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
439 using <a id="idx:asserta1:37"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>,
440 so they precede predefined values for the alias. See <a id="idx:filesearchpath2:38"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
399441 for details on using this file location mechanism.</dd>
400442 <dt><strong>--traditional</strong> <var></var></dt>
401443 <dd class="defbody">
402444 This flag disables the most important extensions of SWI-Prolog version&nbsp;7
403 (see <a class="sec" href="extensions.html">section 5</a>) that introduce
404 incompatibilities with earlier versions. In particular, lists are
405 represented in the traditional way, double quoted text is represented by
406 a list of character codes and the functional notation on dicts is not
407 supported. Dicts as a syntactic entity, and the predicates that act on
408 them, are still supported if this flag is present.</dd>
445 (see <a class="sec" href="extensions.html#sec:5">section 5</a>) that
446 introduce incompatibilities with earlier versions. In particular, lists
447 are represented in the traditional way, double quoted text is
448 represented by a list of character codes and the functional notation on
449 dicts is not supported. Dicts as a syntactic entity, and the predicates
450 that act on them, are still supported if this flag is present.</dd>
409451 <dt><strong>--</strong> <var></var></dt>
410452 <dd class="defbody">
411 <a name="idx:commandlinearguments:39"></a>Stops scanning for more
453 <a id="idx:commandlinearguments:39"></a>Stops scanning for more
412454 arguments, so you can pass arguments for your application after this
413 one. See <a name="idx:currentprologflag2:40"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
455 one. See <a id="idx:currentprologflag2:40"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
414456 using the flag <a class="flag" href="flags.html#flag:argv">argv</a> for
415457 obtaining the command line arguments.
416458 </dd>
417459 </dl>
418460
419 <p><h3 id="sec:stacksizes"><a name="sec:2.4.3"><span class="sec-nr">2.4.3</span> <span class="sec-title">Controlling
461 <p><h3 id="sec:stacksizes"><a id="sec:2.4.3"><span class="sec-nr">2.4.3</span> <span class="sec-title">Controlling
420462 the stack sizes</span></a></h3>
421463
422 <a name="sec:stacksizes"></a>
464 <a id="sec:stacksizes"></a>
423465
424466 <p>The default limit for the Prolog stacks is 128&nbsp;MB on 32-bit and
425467 256&nbsp;MB on 64-bit hardware. The 128&nbsp;MB limit on 32-bit systems
426468 is the highest possible value and the command line options can thus only
427469 be used to lower the limit. On 64-bit systems, the limit can both be
428 reduced and enlarged. See <a class="sec" href="limits.html">section 2.20</a>.
429 Below are two examples, the first reducing the local stack limit to
430 catch unbounded recursion quickly and the second using a big (32&nbsp;GB)
431 global limit, which is only possible on 64-bit hardware. Note that
432 setting the limit using the command line only sets a <em>soft</em>
470 reduced and enlarged. See <a class="sec" href="limits.html#sec:2.20">section
471 2.20</a>. Below are two examples, the first reducing the local stack
472 limit to catch unbounded recursion quickly and the second using a big
473 (32&nbsp;GB) global limit, which is only possible on 64-bit hardware.
474 Note that setting the limit using the command line only sets a <em>soft</em>
433475 limit. Stack parameters can be changed (both reduced and enlarged) at
434 any time using the predicate <a name="idx:setprologstack2:41"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
476 any time using the predicate <a id="idx:setprologstack2:41"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
435477
436478 <pre class="code">
437479 $ swipl -L8m
464506 </dd>
465507 </dl>
466508
467 <p><h3 id="sec:runoptions"><a name="sec:2.4.4"><span class="sec-nr">2.4.4</span> <span class="sec-title">Running
509 <p><h3 id="sec:runoptions"><a id="sec:2.4.4"><span class="sec-nr">2.4.4</span> <span class="sec-title">Running
468510 goals from the command line</span></a></h3>
469511
470 <a name="sec:runoptions"></a>
512 <a id="sec:runoptions"></a>
471513
472514 <dl class="latex">
473515 <dt><strong>-g</strong> <var>goal</var></dt>
474516 <dd class="defbody">
475517 <var>Goal</var> is executed just before entering the top level. This
476 option may appear multiple times. See <a class="sec" href="initgoal.html">section
518 option may appear multiple times. See <a class="sec" href="initgoal.html#sec:2.3">section
477519 2.3</a> for details. If no initialization goal is present the system
478 calls <a name="idx:version0:42"></a><a class="pred" href="exception.html#version/0">version/0</a>
520 calls <a id="idx:version0:42"></a><a class="pred" href="exception.html#version/0">version/0</a>
479521 to print the welcome message. The welcome message can be suppressed with
480522 <strong>--quiet</strong>, but also with <strong>-g</strong> <var>true</var>. <var>goal</var>
481523 can be a complex term. In this case quotes are normally needed to
493535 <dt><strong>-t</strong> <var>goal</var></dt>
494536 <dd class="defbody">
495537 Use <var>goal</var> as interactive top level instead of the default goal
496 <a name="idx:prolog0:43"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>.
538 <a id="idx:prolog0:43"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>.
497539 The <var>goal</var> can be a complex term. If the top-level goal
498540 succeeds SWI-Prolog exits with status 0. If it fails the exit status is
499541 1. If the top level raises an exception, this is printed as an uncaught
500542 error and the top level is <em>restarted</em>. This flag also determines
501 the goal started by <a name="idx:break0:44"></a><a class="pred" href="toplevel.html#break/0">break/0</a>
502 and <a name="idx:abort0:45"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
543 the goal started by <a id="idx:break0:44"></a><a class="pred" href="toplevel.html#break/0">break/0</a>
544 and <a id="idx:abort0:45"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
503545 If you want to prevent the user from entering interactive mode, start
504546 the application with `<strong>-g</strong> <var>goal</var> <strong>-t</strong> <var>halt</var>'.
505547 </dd>
506548 </dl>
507549
508 <p><h3 id="sec:compoptions"><a name="sec:2.4.5"><span class="sec-nr">2.4.5</span> <span class="sec-title">Compilation
550 <p><h3 id="sec:compoptions"><a id="sec:2.4.5"><span class="sec-nr">2.4.5</span> <span class="sec-title">Compilation
509551 options</span></a></h3>
510552
511 <a name="sec:compoptions"></a>
553 <a id="sec:compoptions"></a>
512554
513555 <dl class="latex">
514556 <dt><strong>-c</strong> <var>file ...</var></dt>
515557 <dd class="defbody">
516 Compile files into an `intermediate code file'. See <a class="sec" href="compilation.html">section
558 Compile files into an `intermediate code file'. See <a class="sec" href="compilation.html#sec:2.10">section
517559 2.10</a>.</dd>
518560 <dt><strong>-o</strong> <var>output</var></dt>
519561 <dd class="defbody">
522564 </dd>
523565 </dl>
524566
525 <p><h3 id="sec:maintoptions"><a name="sec:2.4.6"><span class="sec-nr">2.4.6</span> <span class="sec-title">Maintenance
567 <p><h3 id="sec:maintoptions"><a id="sec:2.4.6"><span class="sec-nr">2.4.6</span> <span class="sec-title">Maintenance
526568 options</span></a></h3>
527569
528 <a name="sec:maintoptions"></a>
570 <a id="sec:maintoptions"></a>
529571
530572 <p>The following options are for system maintenance. They are given for
531573 reference only.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="typetest.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="control.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:compare"><a name="sec:4.7"><span class="sec-nr">4.7</span> <span class="sec-title">Comparison
235 <h2 id="sec:compare"><a id="sec:4.7"><span class="sec-nr">4.7</span> <span class="sec-title">Comparison
195236 and Unification of Terms</span></a></h2>
196237
197 <a name="sec:compare"></a>
238 <a id="sec:compare"></a>
198239
199240 <p>Although unification is mostly done implicitly while matching the
200241 head of a predicate, it is also provided by the predicate =/2.
201242
202243 <dl class="latex">
203 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=/2"><var>?Term1</var> <strong>=</strong> <var>?Term2</var></a></dt>
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=/2"><var>?Term1</var> <strong>=</strong> <var>?Term2</var></a></dt>
204245 <dd class="defbody">
205246 Unify <var>Term1</var> with <var>Term2</var>. True if the unification
206247 succeeds. For behaviour on cyclic terms see the Prolog flag
212253 </pre>
213254
214255 </dd>
215 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="\=/2"><var>@Term1</var> <strong>\=</strong> <var>@Term2</var></a></dt>
256 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="\=/2"><var>@Term1</var> <strong>\=</strong> <var>@Term2</var></a></dt>
216257 <dd class="defbody">
217258 Equivalent to <code><code>\+</code>Term1 = Term2</code>.
218259
222263 incomplete nature of&nbsp;<a class="pred" href="control.html#\+/1">\+/1</a>.
223264
224265 <p>To make your programs work correctly also in situations where the
225 arguments are not yet sufficiently instantiated, use <a name="idx:dif2:624"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
266 arguments are not yet sufficiently instantiated, use <a id="idx:dif2:624"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
226267 instead.
227268 </dd>
228269 </dl>
229270
230 <p><h3 id="sec:standardorder"><a name="sec:4.7.1"><span class="sec-nr">4.7.1</span> <span class="sec-title">Standard
271 <p><h3 id="sec:standardorder"><a id="sec:4.7.1"><span class="sec-nr">4.7.1</span> <span class="sec-title">Standard
231272 Order of Terms</span></a></h3>
232273
233 <a name="sec:standardorder"></a>
274 <a id="sec:standardorder"></a>
234275
235276 <p>Comparison and unification of arbitrary terms. Terms are ordered in
236277 the so-called ``standard order''. This order is defined as follows:
253294
254295 <p>Although variables are ordered, there are some unexpected properties
255296 one should keep in mind when relying on variable ordering. This applies
256 to the predicates below as to predicate such as <a name="idx:sort2:625"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
297 to the predicates below as to predicate such as <a id="idx:sort2:625"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
257298 as well as libraries that reply on ordering such as library <code>library(assoc)</code>
258299 and library
259300 <code>library(ordsets)</code>. Obviously, an established relation <var>A</var> <code><code>@&lt;</code></code> <var>B</var>
266307 `newer' variables. If two variables are unified their `shared' age is
267308 the age of oldest variable. This implies we can examine a list of sorted
268309 variables with `newer' (fresh) variables without invalidating the order.
269 Attaching an <em>attribute</em>, see <a class="sec" href="attvar.html">section
310 Attaching an <em>attribute</em>, see <a class="sec" href="attvar.html#sec:7.1">section
270311 7.1</a>, turns an `old' variable into a `new' one as illustrated below.
271312 Note that the first always succeeds as the first argument of a term is
272313 always the oldest. This only applies for the <em>first</em> attribute,
288329 attributes to register information about variables.
289330
290331 <dl class="latex">
291 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="==/2"><var>@Term1</var> <strong>==</strong> <var>@Term2</var></a></dt>
332 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="==/2"><var>@Term1</var> <strong>==</strong> <var>@Term2</var></a></dt>
292333 <dd class="defbody">
293334 True if <var>Term1</var> is equivalent to <var>Term2</var>. A variable
294335 is only identical to a sharing variable.</dd>
295 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="\==/2"><var>@Term1</var> <strong>\==</strong> <var>@Term2</var></a></dt>
336 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="\==/2"><var>@Term1</var> <strong>\==</strong> <var>@Term2</var></a></dt>
296337 <dd class="defbody">
297338 Equivalent to <code><code>\+</code>Term1 == Term2</code>.</dd>
298 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@</2"><var>@Term1</var> <strong>@&lt;</strong> <var>@Term2</var></a></dt>
339 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@</2"><var>@Term1</var> <strong>@&lt;</strong> <var>@Term2</var></a></dt>
299340 <dd class="defbody">
300341 True if <var>Term1</var> is before <var>Term2</var> in the standard
301342 order of terms.</dd>
302 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@=</2"><var>@Term1</var> <strong>@=&lt;</strong> <var>@Term2</var></a></dt>
343 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@=</2"><var>@Term1</var> <strong>@=&lt;</strong> <var>@Term2</var></a></dt>
303344 <dd class="defbody">
304345 True if both terms are equal (<a class="pred" href="compare.html#==/2">==/2</a>)
305346 or <var>Term1</var> is before <var>Term2</var> in the standard order of
306347 terms.</dd>
307 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@>/2"><var>@Term1</var> <strong>@&gt;</strong> <var>@Term2</var></a></dt>
348 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@>/2"><var>@Term1</var> <strong>@&gt;</strong> <var>@Term2</var></a></dt>
308349 <dd class="defbody">
309350 True if <var>Term1</var> is after <var>Term2</var> in the standard order
310351 of terms.</dd>
311 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@>=/2"><var>@Term1</var> <strong>@&gt;=</strong> <var>@Term2</var></a></dt>
352 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@>=/2"><var>@Term1</var> <strong>@&gt;=</strong> <var>@Term2</var></a></dt>
312353 <dd class="defbody">
313354 True if both terms are equal (<a class="pred" href="compare.html#==/2">==/2</a>)
314355 or <var>Term1</var> is after <var>Term2</var> in the standard order of
315356 terms.</dd>
316 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="compare/3"><strong>compare</strong>(<var>?Order,
357 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="compare/3"><strong>compare</strong>(<var>?Order,
317358 @Term1, @Term2</var>)</a></dt>
318359 <dd class="defbody">
319360 Determine or test the <var>Order</var> between two terms in the standard
322363 </dd>
323364 </dl>
324365
325 <p><h3 id="sec:unifyspecial"><a name="sec:4.7.2"><span class="sec-nr">4.7.2</span> <span class="sec-title">Special
366 <p><h3 id="sec:unifyspecial"><a id="sec:4.7.2"><span class="sec-nr">4.7.2</span> <span class="sec-title">Special
326367 unification and comparison predicates</span></a></h3>
327368
328 <a name="sec:unifyspecial"></a>
369 <a id="sec:unifyspecial"></a>
329370
330371 <p>This section describes special purpose variations on Prolog
331 unification. The predicate <a name="idx:unifywithoccurscheck2:626"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
372 unification. The predicate <a id="idx:unifywithoccurscheck2:626"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
332373 provides sound unification and is part of the ISO standard. The
333 predicate <a name="idx:subsumesterm2:627"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>
374 predicate <a id="idx:subsumesterm2:627"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>
334375 defines `one-sided unification' and is part of the ISO proposal
335 established in Edinburgh (2010). Finally, <a name="idx:unifiable3:628"></a><a class="pred" href="compare.html#unifiable/3">unifiable/3</a>
376 established in Edinburgh (2010). Finally, <a id="idx:unifiable3:628"></a><a class="pred" href="compare.html#unifiable/3">unifiable/3</a>
336377 is a `what-if' version of unification that is often used as a building
337378 block in constraint reasoners.
338379
339380 <dl class="latex">
340 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="unify_with_occurs_check/2"><strong>unify_with_occurs_check</strong>(<var>+Term1,
381 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="unify_with_occurs_check/2"><strong>unify_with_occurs_check</strong>(<var>+Term1,
341382 +Term2</var>)</a></dt>
342383 <dd class="defbody">
343384 As <a class="pred" href="compare.html#=/2">=/2</a>, but using <em>sound
352393 false.
353394 </pre>
354395
355 <p><a name="idx:occurscheck:629"></a>The first statement creates a <em>cyclic
396 <p><a id="idx:occurscheck:629"></a>The first statement creates a <em>cyclic
356397 term</em>, also called a
357398 <em>rational tree</em>. The second executes logically sound unification
358399 and thus fails. Note that the behaviour of unification through
359400 <a class="pred" href="compare.html#=/2">=/2</a> as well as implicit
360401 unification in the head can be changed using the Prolog flag <a class="flag" href="flags.html#flag:occurs_check">occurs_check</a>.
361402
362 <p>The SWI-Prolog implementation of <a name="idx:unifywithoccurscheck2:630"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
403 <p>The SWI-Prolog implementation of <a id="idx:unifywithoccurscheck2:630"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
363404 is cycle-safe and only guards against <em>creating</em> cycles, not
364405 against cycles that may already be present in one of the arguments. This
365406 is illustrated in the following two queries:
371412 X = Y, Y = f(Y).
372413 </pre>
373414
374 <p>Some other Prolog systems interpret <a name="idx:unifywithoccurscheck2:631"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
415 <p>Some other Prolog systems interpret <a id="idx:unifywithoccurscheck2:631"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
375416 as if defined by the clause below, causing failure on the above two
376 queries. Direct use of <a name="idx:acyclicterm1:632"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
417 queries. Direct use of <a id="idx:acyclicterm1:632"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
377418 is portable and more appropriate for such applications.
378419
379420 <pre class="code">
381422 </pre>
382423
383424 </dd>
384 <dt class="pubdef"><a name="=@=/2"><var>+Term1</var> <strong>=@=</strong> <var>+Term2</var></a></dt>
385 <dd class="defbody">
386 <a name="idx:variant:633"></a>True if <var>Term1</var> is a <em>variant</em>
425 <dt class="pubdef"><a id="=@=/2"><var>+Term1</var> <strong>=@=</strong> <var>+Term2</var></a></dt>
426 <dd class="defbody">
427 <a id="idx:variant:633"></a>True if <var>Term1</var> is a <em>variant</em>
387428 of (or <em>structurally equivalent</em> to) <var>Term2</var>. Testing
388429 for a variant is weaker than equivalence (<a class="pred" href="compare.html#==/2">==/2</a>),
389430 but stronger than unification (<a class="pred" href="compare.html#=/2">=/2</a>).
398439 E.g., after binding the first argument in row&nbsp;8 to a value, both
399440 terms are no longer variant.</span></sup> Examples:
400441 <blockquote>
401 <table border="0" frame="void" rules="groups">
402 <tr valign="top"><td align=right>1</td><td align=center><code>a =@= A</code></td><td align=center>false </td></tr>
403 <tr valign="top"><td align=right>2</td><td align=center><code>A =@= B</code></td><td align=center>true </td></tr>
404 <tr valign="top"><td align=right>3</td><td align=center><code>x(A,A) =@=
405 x(B,C)</code></td><td align=center>false </td></tr>
406 <tr valign="top"><td align=right>4</td><td align=center><code>x(A,A) =@=
407 x(B,B)</code></td><td align=center>true </td></tr>
408 <tr valign="top"><td align=right>5</td><td align=center><code>x(A,A) =@=
409 x(A,B)</code></td><td align=center>false </td></tr>
410 <tr valign="top"><td align=right>6</td><td align=center><code>x(A,B) =@=
411 x(C,D)</code></td><td align=center>true </td></tr>
412 <tr valign="top"><td align=right>7</td><td align=center><code>x(A,B) =@=
413 x(B,A)</code></td><td align=center>true </td></tr>
414 <tr valign="top"><td align=right>8</td><td align=center><code>x(A,B) =@=
415 x(C,A)</code></td><td align=center>true </td></tr>
442 <table class="latex frame-void">
443 <tr><td align=right>1</td><td align=center><code>a =@= A</code></td><td align=center>false </td></tr>
444 <tr><td align=right>2</td><td align=center><code>A =@= B</code></td><td align=center>true </td></tr>
445 <tr><td align=right>3</td><td align=center><code>x(A,A) =@= x(B,C)</code></td><td align=center>false </td></tr>
446 <tr><td align=right>4</td><td align=center><code>x(A,A) =@= x(B,B)</code></td><td align=center>true </td></tr>
447 <tr><td align=right>5</td><td align=center><code>x(A,A) =@= x(A,B)</code></td><td align=center>false </td></tr>
448 <tr><td align=right>6</td><td align=center><code>x(A,B) =@= x(C,D)</code></td><td align=center>true </td></tr>
449 <tr><td align=right>7</td><td align=center><code>x(A,B) =@= x(B,A)</code></td><td align=center>true </td></tr>
450 <tr><td align=right>8</td><td align=center><code>x(A,B) =@= x(C,A)</code></td><td align=center>true </td></tr>
416451 </table>
417452 </blockquote>
418453
419454 <p>A term is always a variant of a copy of itself. Term copying takes
420 place in, e.g., <a name="idx:copyterm2:634"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>, <a name="idx:findall3:635"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
455 place in, e.g., <a id="idx:copyterm2:634"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>, <a id="idx:findall3:635"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
421456 or proving a clause added with
422 <a name="idx:asserta1:636"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>.
457 <a id="idx:asserta1:636"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>.
423458 In the pure Prolog world (i.e., without attributed variables), <a class="pred" href="compare.html#=@=/2">=@=/2</a>
424459 behaves as if defined below. With attributed variables, variant of the
425460 attributes is tested rather than trying to satisfy the constraints.
444479 in some other Prolog systems. Be aware of possible differences in
445480 semantics if the arguments contain attributed variables or share
446481 variables.<sup class="fn">61<span class="fn-text">In many systems
447 variant is implemented using two calls to <a name="idx:subsumesterm2:637"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>.</span></sup></dd>
448 <dt class="pubdef"><a name="\=@=/2"><var>+Term1</var> <strong>\=@=</strong> <var>+Term2</var></a></dt>
482 variant is implemented using two calls to <a id="idx:subsumesterm2:637"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>.</span></sup></dd>
483 <dt class="pubdef"><a id="\=@=/2"><var>+Term1</var> <strong>\=@=</strong> <var>+Term2</var></a></dt>
449484 <dd class="defbody">
450485 Equivalent to <code>`<code>\+</code>Term1 =@= Term2'</code>. See <a class="pred" href="compare.html#=@=/2">=@=/2</a>
451486 for details.</dd>
452 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="subsumes_term/2"><strong>subsumes_term</strong>(<var>@Generic, @Specific</var>)</a></dt>
487 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="subsumes_term/2"><strong>subsumes_term</strong>(<var>@Generic, @Specific</var>)</a></dt>
453488 <dd class="defbody">
454489 True if <var>Generic</var> can be made equivalent to <var>Specific</var>
455490 by only binding variables in <var>Generic</var>. The current
456491 implementation performs the unification and ensures that the variable
457492 set of <var>Specific</var> is not changed by the unification. On
458493 success, the bindings are undone.<sup class="fn">62<span class="fn-text">This
459 predicate is often named <a name="idx:subsumeschk2:638"></a><span class="pred-ext">subsumes_chk/2</span>
494 predicate is often named <a id="idx:subsumeschk2:638"></a><span class="pred-ext">subsumes_chk/2</span>
460495 in older Prolog dialects. The current name was established in the ISO
461496 WG17 meeting in Edinburgh (2010). The <code>chk</code> postfix was
462 considered to refer to determinism as in e.g., <a name="idx:memberchk2:639"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>.</span></sup>
497 considered to refer to determinism as in e.g., <a id="idx:memberchk2:639"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>.</span></sup>
463498 This predicate respects constraints.</dd>
464 <dt class="pubdef"><a name="term_subsumer/3"><strong>term_subsumer</strong>(<var>+Special1,
499 <dt class="pubdef"><a id="term_subsumer/3"><strong>term_subsumer</strong>(<var>+Special1,
465500 +Special2, -General</var>)</a></dt>
466501 <dd class="defbody">
467502 <var>General</var> is the most specific term that is a generalisation of
468503 <var>Special1</var> and <var>Special2</var>. The implementation can
469504 handle cyclic terms.</dd>
470 <dt class="pubdef"><a name="unifiable/3"><strong>unifiable</strong>(<var>@X, @Y,
505 <dt class="pubdef"><a id="unifiable/3"><strong>unifiable</strong>(<var>@X, @Y,
471506 -Unifier</var>)</a></dt>
472507 <dd class="defbody">
473508 If <var>X</var> and <var>Y</var> can unify, unify <var>Unifier</var>
474509 with a list of
475510 <var>Var</var> = <var>Value</var>, representing the bindings required to
476511 make <var>X</var> and <var>Y</var> equivalent.<sup class="fn">63<span class="fn-text">This
477 predicate was introduced for the implementation of <a name="idx:dif2:640"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
478 and <a name="idx:when2:641"></a><a class="pred" href="coroutining.html#when/2">when/2</a>
512 predicate was introduced for the implementation of <a id="idx:dif2:640"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
513 and <a id="idx:when2:641"></a><a class="pred" href="coroutining.html#when/2">when/2</a>
479514 after discussion with Tom Schrijvers and Bart Demoen. None of us is
480515 really happy with the name and therefore suggestions for a new name are
481516 welcome.</span></sup> This predicate can handle cyclic terms. Attributed
482517 variables are handled as normal variables. Associated hooks are <em>not</em>
483518 executed.</dd>
484 <dt class="pubdef"><a name="?=/2"><strong>?=</strong>(<var>@Term1, @Term2</var>)</a></dt>
519 <dt class="pubdef"><a id="?=/2"><strong>?=</strong>(<var>@Term1, @Term2</var>)</a></dt>
485520 <dd class="defbody">
486521 Succeeds if the syntactic equality of <var>Term1</var> and <var>Term2</var>
487522 can be decided safely, i.e. if the result of <code>Term1 == Term2</code>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.10</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="debugoverview.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="flags.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:compilation"><a name="sec:2.10"><span class="sec-nr">2.10</span> <span class="sec-title">Compilation</span></a></h2>
195
196 <a name="sec:compilation"></a>
197
198 <p><h3 id="sec:develcomp"><a name="sec:2.10.1"><span class="sec-nr">2.10.1</span> <span class="sec-title">During
235 <h2 id="sec:compilation"><a id="sec:2.10"><span class="sec-nr">2.10</span> <span class="sec-title">Compilation</span></a></h2>
236
237 <a id="sec:compilation"></a>
238
239 <p><h3 id="sec:develcomp"><a id="sec:2.10.1"><span class="sec-nr">2.10.1</span> <span class="sec-title">During
199240 program development</span></a></h3>
200241
201 <a name="sec:develcomp"></a>
242 <a id="sec:develcomp"></a>
202243
203244 <p>During program development, programs are normally loaded using the
204245 list abbreviation (<code>?- [load].</code>). It is common practice to
205246 organise a project as a collection of source files and a <em>load file</em>,
206 a Prolog file containing only <a name="idx:usemodule12:71"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>
207 or <a name="idx:ensureloaded1:72"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>
247 a Prolog file containing only <a id="idx:usemodule12:71"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>
248 or <a id="idx:ensureloaded1:72"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>
208249 directives, possibly with a definition of the <em>entry point</em> of
209250 the program, the predicate that is normally used to start the program.
210251 This file is often called <code>load.pl</code>. If the entry point is
229270 before entering the top level. If Prolog is started from an interactive
230271 shell, one may choose the type <code>swipl -s load.pl</code>.
231272
232 <p><h3 id="sec:runcomp"><a name="sec:2.10.2"><span class="sec-nr">2.10.2</span> <span class="sec-title">For
273 <p><h3 id="sec:runcomp"><a id="sec:2.10.2"><span class="sec-nr">2.10.2</span> <span class="sec-title">For
233274 running the result</span></a></h3>
234275
235 <a name="sec:runcomp"></a>
276 <a id="sec:runcomp"></a>
236277
237278 <p>There are various options if you want to make your program ready for
238279 real usage. The best choice depends on whether the program is to be used
239280 only on machines holding the SWI-Prolog development system, the size of
240281 the program, and the operating system (Unix vs. Windows).
241282
242 <p><h4 id="sec:plscript"><a name="sec:2.10.2.1"><span class="sec-nr">2.10.2.1</span> <span class="sec-title">Using
283 <p><h4 id="sec:plscript"><a id="sec:2.10.2.1"><span class="sec-nr">2.10.2.1</span> <span class="sec-title">Using
243284 PrologScript</span></a></h4>
244285
245 <a name="sec:plscript"></a>
286 <a id="sec:plscript"></a>
246287
247288 <p>A Prolog source file can be used directly as a Unix program using the
248289 Unix <code>#!</code> magic start. The Unix <code>#!</code> magic is
267308 spaces. When started this way, the Prolog flag <a class="flag" href="flags.html#flag:argv">argv</a>
268309 contains the command line arguments that follow the script invocation.
269310
270 <p>Starting with version 7.5.8, <a name="idx:initialization2:73"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
311 <p>Starting with version 7.5.8, <a id="idx:initialization2:73"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
271312 support the <var>When</var> options <code>program</code> and <code>main</code>,
272313 allowing for the following definition of a Prolog script that evaluates
273 an arithmetic expression on the command line. Note that <a name="idx:main0:74"></a><a class="pred" href="main.html#main/0">main/0</a>
314 an arithmetic expression on the command line. Note that <a id="idx:main0:74"></a><a class="pred" href="main.html#main/0">main/0</a>
274315 is defined lib the library
275 <code>library(main)</code>. It calls <a name="idx:main1:75"></a><span class="pred-ext">main/1</span>
316 <code>library(main)</code>. It calls <a id="idx:main1:75"></a><span class="pred-ext">main/1</span>
276317 with the command line arguments after disabling signal handling.
277318
278319 <pre class="code">
328369 Due to the compatibility issues around <em>HashBang</em> line
329370 processing, we decided to remove it completely.</span></sup>
330371
331 <p><h4 id="sec:shellscript"><a name="sec:2.10.2.2"><span class="sec-nr">2.10.2.2</span> <span class="sec-title">Creating
372 <p><h4 id="sec:shellscript"><a id="sec:2.10.2.2"><span class="sec-nr">2.10.2.2</span> <span class="sec-title">Creating
332373 a shell script</span></a></h4>
333374
334 <a name="sec:shellscript"></a>
335
336 <p>With the introduction of <em>PrologScript</em> (see <a class="sec" href="compilation.html">section
375 <a id="sec:shellscript"></a>
376
377 <p>With the introduction of <em>PrologScript</em> (see <a class="sec" href="compilation.html#sec:2.10.2.1">section
337378 2.10.2.1</a>), using shell scripts as explained in this section has
338379 become redundant for most applications.
339380
366407 shortcut to Prolog, passing the proper options or writing a <code>.bat</code>
367408 file.
368409
369 <p><h4 id="sec:makestate"><a name="sec:2.10.2.3"><span class="sec-nr">2.10.2.3</span> <span class="sec-title">Creating
410 <p><h4 id="sec:makestate"><a id="sec:2.10.2.3"><span class="sec-nr">2.10.2.3</span> <span class="sec-title">Creating
370411 a saved state</span></a></h4>
371412
372 <a name="sec:makestate"></a>
413 <a id="sec:makestate"></a>
373414
374415 <p>For larger programs, as well as for programs that are required to run
375416 on systems that do not have the SWI-Prolog development system installed,
376417 creating a saved state is the best solution. A saved state is created
377 using <a name="idx:qsaveprogram12:76"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
418 using <a id="idx:qsaveprogram12:76"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
378419 or the <strong>-c</strong> command line option. A saved state is a file
379420 containing machine-independent<sup class="fn">16<span class="fn-text">The
380421 saved state does not depend on the CPU instruction set or endianness.
383424 created.</span></sup> intermediate code in a format dedicated for fast
384425 loading. Optionally, the emulator may be integrated in the saved state,
385426 creating a single file, but machine-dependent, executable. This process
386 is described in <a class="sec" href="runtime.html">chapter 12</a>.
387
388 <p><h4 id="sec:cmdlinecomp"><a name="sec:2.10.2.4"><span class="sec-nr">2.10.2.4</span> <span class="sec-title">Compilation
427 is described in <a class="sec" href="runtime.html#sec:12">chapter 12</a>.
428
429 <p><h4 id="sec:cmdlinecomp"><a id="sec:2.10.2.4"><span class="sec-nr">2.10.2.4</span> <span class="sec-title">Compilation
389430 using the -c command line option</span></a></h4>
390431
391 <a name="sec:cmdlinecomp"></a>
432 <a id="sec:cmdlinecomp"></a>
392433
393434 <p>This mechanism loads a series of Prolog source files and then creates
394 a saved state as <a name="idx:qsaveprogram2:77"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
435 a saved state as <a id="idx:qsaveprogram2:77"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
395436 does. The command syntax is:
396437
397438 <pre class="code">
398439 % swipl [option ...] [-o output] -c file.pl ...
399440 </pre>
400441
401 <p>The <var>options</var> argument are options to <a name="idx:qsaveprogram2:78"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
442 <p>The <var>options</var> argument are options to <a id="idx:qsaveprogram2:78"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
402443 written in the format below. The option names and their values are
403444 described with
404 <a name="idx:qsaveprogram2:79"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
445 <a id="idx:qsaveprogram2:79"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
405446 <blockquote>
406447 <code>--</code><em>option-name</em><code>=</code><em>option-value
407448 </em></blockquote>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="chars.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="edit.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:consulting"><a name="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Loading
235 <h2 id="sec:consulting"><a id="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Loading
195236 Prolog source files</span></a></h2>
196237
197 <a name="sec:consulting"></a>
238 <a id="sec:consulting"></a>
198239
199240 <p>This section deals with loading Prolog source files. A Prolog source
200241 file is a plain text file containing a Prolog program or part thereof.
205246 <dd>
206247 Prolog source file contains Prolog clauses and directives, but no <em>module
207248 declaration</em> (see
208 <a name="idx:module1:358"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>).
209 They are normally loaded using <a name="idx:consult1:359"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
210 or <a name="idx:ensureloaded1:360"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>.
249 <a id="idx:module1:358"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>).
250 They are normally loaded using <a id="idx:consult1:359"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
251 or <a id="idx:ensureloaded1:360"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>.
211252 Currently, a non-module file can only be loaded into a single module.<sup class="fn">45<span class="fn-text">This
212253 limitation may be lifted in the future. Existing limitations in
213254 SWI-Prolog's source code administration make this non-trivial.</span></sup></dd>
216257 Prolog source file starts with a module declaration. The subsequent
217258 Prolog code is loaded into the specified module, and only the <em>exported</em>
218259 predicates are made available to the context loading the module. Module
219 files are normally loaded with <a name="idx:usemodule12:361"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
220 See <a class="sec" href="modules.html">chapter 6</a> for details.</dd>
260 files are normally loaded with <a id="idx:usemodule12:361"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
261 See <a class="sec" href="modules.html#sec:6">chapter 6</a> for details.</dd>
221262 <dt><b> An include</b></dt>
222263 <dd>
223 Prolog source file is loaded using the <a name="idx:include1:362"></a><a class="pred" href="consulting.html#include/1">include/1</a>
264 Prolog source file is loaded using the <a id="idx:include1:362"></a><a class="pred" href="consulting.html#include/1">include/1</a>
224265 directive, textually including Prolog text into another Prolog source. A
225266 file may be included into multiple source files and is typically used to
226267 share <em>declarations</em> such as multifile or dynamic between source
228269 </dd>
229270 </dl>
230271
231 <p>Prolog source files are located using <a name="idx:absolutefilename3:363"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
272 <p>Prolog source files are located using <a id="idx:absolutefilename3:363"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
232273 with the following options:
233274
234275 <pre class="code">
241282 </pre>
242283
243284 <p>The <code>file_type(prolog)</code> option is used to determine the
244 extension of the file using <a name="idx:prologfiletype2:364"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>.
285 extension of the file using <a id="idx:prologfiletype2:364"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>.
245286 The default extension is
246287 <code>.pl</code>. <var>Spec</var> allows for the <em>path alias</em>
247 construct defined by <a name="idx:absolutefilename3:365"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
288 construct defined by <a id="idx:absolutefilename3:365"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
248289 The most commonly used path alias is <code>library(LibraryFile)</code>.
249290 The example below loads the library file <code>ordsets.pl</code>
250291 (containing predicates for manipulating ordered sets).
253294 :- use_module(library(ordsets)).
254295 </pre>
255296
256 <p>SWI-Prolog recognises grammar rules (<a name="idx:DCG:366">DCG</a>)
257 as defined in
297 <p>SWI-Prolog recognises grammar rules (<a id="idx:DCG:366">DCG</a>) as
298 defined in
258299 <cite><a class="cite" href="Bibliography.html#Clocksin:87">Clocksin &amp;
259300 Melish, 1987</a></cite>. The user may define additional compilation of
260301 the source file by defining the dynamic multifile predicates
261 <a name="idx:termexpansion2:367"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a name="idx:termexpansion4:368"></a><a class="pred" href="consulting.html#term_expansion/4">term_expansion/4</a>, <a name="idx:goalexpansion2:369"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
302 <a id="idx:termexpansion2:367"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a id="idx:termexpansion4:368"></a><a class="pred" href="consulting.html#term_expansion/4">term_expansion/4</a>, <a id="idx:goalexpansion2:369"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
262303 and
263 <a name="idx:goalexpansion4:370"></a><a class="pred" href="consulting.html#goal_expansion/4">goal_expansion/4</a>.
264 It is not allowed to use <a name="idx:assert1:371"></a><a class="pred" href="db.html#assert/1">assert/1</a>, <a name="idx:retract1:372"></a><a class="pred" href="db.html#retract/1">retract/1</a>
265 or any other database predicate in <a name="idx:termexpansion2:373"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
304 <a id="idx:goalexpansion4:370"></a><a class="pred" href="consulting.html#goal_expansion/4">goal_expansion/4</a>.
305 It is not allowed to use <a id="idx:assert1:371"></a><a class="pred" href="db.html#assert/1">assert/1</a>, <a id="idx:retract1:372"></a><a class="pred" href="db.html#retract/1">retract/1</a>
306 or any other database predicate in <a id="idx:termexpansion2:373"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
266307 other than for local computational purposes.<sup class="fn">46<span class="fn-text">It
267 does work for normal loading, but not for <a name="idx:qcompile1:374"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.</span></sup>
268 Code that needs to create additional clauses must use <a name="idx:compileauxclauses1:375"></a><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a>.
308 does work for normal loading, but not for <a id="idx:qcompile1:374"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.</span></sup>
309 Code that needs to create additional clauses must use <a id="idx:compileauxclauses1:375"></a><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a>.
269310 See <code>library(library(apply_macros))</code> for an example.
270311
271312 <p>A <em>directive</em> is an instruction to the compiler. Directives
272 are used to set (predicate) properties (see <a class="sec" href="dynamic.html">section
273 4.15</a>), set flags (see <a name="idx:setprologflag2:376"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>)
313 are used to set (predicate) properties (see <a class="sec" href="dynamic.html#sec:4.15">section
314 4.15</a>), set flags (see <a id="idx:setprologflag2:376"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>)
274315 and load files (this section). Directives are terms of the form <code><code>:-</code></code> &lt;<var>term</var>&gt;.
275316 . Here are some examples:
276317
280321 store/2. % Name, Value
281322 </pre>
282323
283 <p>The directive <a name="idx:initialization1:377"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
324 <p>The directive <a id="idx:initialization1:377"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
284325 can be used to run arbitrary Prolog goals. The specified goal is started <em>after</em>
285326 loading the file in which it appears has completed.
286327
290331 appears. It also accepts <code><code>?-</code></code> &lt;<var>term</var>&gt;.
291332 as a synonym.
292333
293 <p><a name="idx:reconsult:378"></a>SWI-Prolog does not have a separate
334 <p><a id="idx:reconsult:378"></a>SWI-Prolog does not have a separate
294335 reconsult/1 predicate. Reconsulting is implied automatically by the fact
295336 that a file is consulted which is already loaded.
296337
297338 <p>Advanced topics are handled in subsequent sections: mutually
298 dependent files (<a class="sec" href="consulting.html">section 4.3.2.1</a>),
299 multithreaded loading (<a class="sec" href="consulting.html">section
300 4.3.2.2</a>) and reloading running code (<a class="sec" href="consulting.html">section
339 dependent files (<a class="sec" href="consulting.html#sec:4.3.2.1">section
340 4.3.2.1</a>), multithreaded loading (<a class="sec" href="consulting.html#sec:4.3.2.2">section
341 4.3.2.2</a>) and reloading running code (<a class="sec" href="consulting.html#sec:4.3.2">section
301342 4.3.2</a>).
302343
303 <p>The core of the family of loading predicates is <a name="idx:loadfiles2:379"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
344 <p>The core of the family of loading predicates is <a id="idx:loadfiles2:379"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
304345 The predicates
305 <a name="idx:consult1:380"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>, <a name="idx:ensureloaded1:381"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>, <a name="idx:usemodule1:382"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>, <a name="idx:usemodule2:383"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
306 and <a name="idx:reexport1:384"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
307 pass the file argument directly to <a name="idx:loadfiles2:385"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
346 <a id="idx:consult1:380"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>, <a id="idx:ensureloaded1:381"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>, <a id="idx:usemodule1:382"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>, <a id="idx:usemodule2:383"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
347 and <a id="idx:reexport1:384"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
348 pass the file argument directly to <a id="idx:loadfiles2:385"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
308349 and pass additional options as expressed in the <a class="tab" href="consulting.html#tab:loadpreds">table
309350 4</a>:
310351
311 <p><table border="2" frame="hsides" rules="groups" style="margin:auto">
312 <tr valign="top"><td><b>Predicate</b></td><td align=center><b>if</b></td><td align=center><b>must_be_module</b></td><td align=center><b>import </b></td></tr>
313 <tbody>
314 <tr valign="top"><td><a name="idx:consult1:386"></a><a class="pred" href="consulting.html#consult/1">consult/1</a> </td><td align=center><code>true</code> </td><td align=center><code>false</code> </td><td align=center>all </td></tr>
315 <tr valign="top"><td><a name="idx:ensureloaded1:387"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>false</code> </td><td align=center>all </td></tr>
316 <tr valign="top"><td><a name="idx:usemodule1:388"></a><a class="pred" href="import.html#use_module/1">use_module/1</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>all</td></tr>
317 <tr valign="top"><td><a name="idx:usemodule2:389"></a><a class="pred" href="import.html#use_module/2">use_module/2</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>specified </td></tr>
318 <tr valign="top"><td><a name="idx:reexport1:390"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>all </td></tr>
319 <tr valign="top"><td><a name="idx:reexport2:391"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>specified </td></tr>
352 <p><table class="latex frame-hsides center">
353 <tr><td><b>Predicate</b></td><td align=center><b>if</b></td><td align=center><b>must_be_module</b></td><td align=center><b>import </b></td></tr>
354 <tr class="hline"><td><a id="idx:consult1:386"></a><a class="pred" href="consulting.html#consult/1">consult/1</a> </td><td align=center><code>true</code> </td><td align=center><code>false</code> </td><td align=center>all </td></tr>
355 <tr><td><a id="idx:ensureloaded1:387"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>false</code> </td><td align=center>all </td></tr>
356 <tr><td><a id="idx:usemodule1:388"></a><a class="pred" href="import.html#use_module/1">use_module/1</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>all</td></tr>
357 <tr><td><a id="idx:usemodule2:389"></a><a class="pred" href="import.html#use_module/2">use_module/2</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>specified </td></tr>
358 <tr><td><a id="idx:reexport1:390"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>all </td></tr>
359 <tr><td><a id="idx:reexport2:391"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a> </td><td align=center><code>not_loaded</code> </td><td align=center><code>true</code> </td><td align=center>specified </td></tr>
320360 </table>
321361 <div class="caption"><b>Table 4 : </b>Properties of the file-loading
322362 predicates. The <i>import</i> column specifies what is imported if the
323363 loaded file is a module file.</div>
324 <a name="tab:loadpreds"></a>
364 <a id="tab:loadpreds"></a>
325365
326366 <dl class="latex">
327 <dt class="pubdef"><a name="load_files/1"><strong>load_files</strong>(<var>:Files</var>)</a></dt>
328 <dd class="defbody">
329 Equivalent to <code>load_files(Files,[])</code>. Same as <a name="idx:consult1:392"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
330 See <a name="idx:loadfiles2:393"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
367 <dt class="pubdef"><a id="load_files/1"><strong>load_files</strong>(<var>:Files</var>)</a></dt>
368 <dd class="defbody">
369 Equivalent to <code>load_files(Files,[])</code>. Same as <a id="idx:consult1:392"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
370 See <a id="idx:loadfiles2:393"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
331371 for supported options.
332372 </dd>
333 <dt class="pubdef"><a name="load_files/2"><strong>load_files</strong>(<var>:Files,
373 <dt class="pubdef"><a id="load_files/2"><strong>load_files</strong>(<var>:Files,
334374 +Options</var>)</a></dt>
335375 <dd class="defbody">
336 The predicate <a name="idx:loadfiles2:394"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
337 is the parent of all the other loading predicates except for <a name="idx:include1:395"></a><a class="pred" href="consulting.html#include/1">include/1</a>.
338 It currently supports a subset of the options of Quintus <a name="idx:loadfiles2:396"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>. <var>Files</var>
376 The predicate <a id="idx:loadfiles2:394"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
377 is the parent of all the other loading predicates except for <a id="idx:include1:395"></a><a class="pred" href="consulting.html#include/1">include/1</a>.
378 It currently supports a subset of the options of Quintus <a id="idx:loadfiles2:396"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>. <var>Files</var>
339379 is either a single source file or a list of source files. The
340 specification for a source file is handed to <a name="idx:absolutefilename2:397"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>.
380 specification for a source file is handed to <a id="idx:absolutefilename2:397"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>.
341381 See this predicate for the supported expansions. <var>Options</var> is a
342382 list of options using the format <var>OptionName</var>(<var>OptionValue</var>).
343383
351391 <em>demand</em> load. This implies that, depending on the setting of the
352392 Prolog flag <a class="flag" href="flags.html#flag:verbose_autoload">verbose_autoload</a>,
353393 the load action is printed at level <code>informational</code> or <code>silent</code>.
354 See also <a name="idx:printmessage2:398"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
355 and <a name="idx:currentprologflag2:399"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.</dd>
394 See also <a id="idx:printmessage2:398"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
395 and <a id="idx:currentprologflag2:399"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.</dd>
356396 <dt><strong>check_script</strong>(<var>Bool</var>)</dt>
357397 <dd class="defbody">
358398 If <code>false</code> (default <code>true</code>), do not check the
361401 <dt><strong>derived_from</strong>(<var>File</var>)</dt>
362402 <dd class="defbody">
363403 Indicate that the loaded file is derived from <var>File</var>. Used by
364 <a name="idx:make0:400"></a><a class="pred" href="consulting.html#make/0">make/0</a>
404 <a id="idx:make0:400"></a><a class="pred" href="consulting.html#make/0">make/0</a>
365405 to time-check and load the original file rather than the derived file.</dd>
366406 <dt><strong>dialect</strong>(<var>+Dialect</var>)</dt>
367407 <dd class="defbody">
368408 Load <var>Files</var> with enhanced compatibility with the target Prolog
369 system identified by <var>Dialect</var>. See <a name="idx:expectsdialect1:401"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
409 system identified by <var>Dialect</var>. See <a id="idx:expectsdialect1:401"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
370410 and
371 <a class="sec" href="dialect.html">section C</a> for details.</dd>
411 <a class="sec" href="dialect.html#sec:C">section C</a> for details.</dd>
372412 <dt><strong>encoding</strong>(<var>Encoding</var>)</dt>
373413 <dd class="defbody">
374414 Specify the way characters are encoded in the file. Default is taken
375415 from the Prolog flag <a class="flag" href="flags.html#flag:encoding">encoding</a>.
376 See <a class="sec" href="widechars.html">section 2.19.1</a> for details.</dd>
416 See <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a>
417 for details.</dd>
377418 <dt><strong>expand</strong>(<var>Bool</var>)</dt>
378419 <dd class="defbody">
379 If <code>true</code>, run the filenames through <a name="idx:expandfilename2:402"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
380 and load the returned files. Default is <code>false</code>, except for <a name="idx:consult1:403"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
420 If <code>true</code>, run the filenames through <a id="idx:expandfilename2:402"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
421 and load the returned files. Default is <code>false</code>, except for <a id="idx:consult1:403"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
381422 which is intended for interactive use. Flexible location of files is
382 defined by <a name="idx:filesearchpath2:404"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
423 defined by <a id="idx:filesearchpath2:404"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
383424 <dt><strong>format</strong>(<var>+Format</var>)</dt>
384425 <dd class="defbody">
385426 Used to specify the file format if data is loaded from a stream using
386427 the <code>stream(Stream)</code> option. Default is <code>source</code>,
387 loading Prolog source text. If <code>qlf</code>, load QLF data (see <a name="idx:qcompile1:405"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>).</dd>
428 loading Prolog source text. If <code>qlf</code>, load QLF data (see <a id="idx:qcompile1:405"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>).</dd>
388429 <dt><strong>if</strong>(<var>Condition</var>)</dt>
389430 <dd class="defbody">
390431 Load the file only if the specified condition is satisfied. The value
395436 <dt><strong>imports</strong>(<var>Import</var>)</dt>
396437 <dd class="defbody">
397438 Specify what to import from the loaded module. The default for
398 <a name="idx:usemodule1:406"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
439 <a id="idx:usemodule1:406"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
399440 is <code>all</code>. <var>Import</var> is passed from the second
400 argument of <a name="idx:usemodule2:407"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.
441 argument of <a id="idx:usemodule2:407"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.
401442 Traditionally it is a list of predicate indicators to import. As part of
402443 the SWI-Prolog/YAP integration, we also support <var>Pred</var> as <var>Name</var>
403444 to import a predicate under another name. Finally, <var>Import</var> can
404445 be the term <code>except(Exceptions)</code>, where <var>Exceptions</var>
405446 is a list of predicate indicators that specify predicates that are <em>not</em>
406447 imported or <var>Pred</var> as <var>Name</var> terms to denote renamed
407 predicates. See also <a name="idx:reexport2:408"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>
448 predicates. See also <a id="idx:reexport2:408"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>
408449 and
409 <a name="idx:usemodule2:409"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.<sup class="fn">bug<span class="fn-text"><var>Name</var>/<var>Arity</var>
450 <a id="idx:usemodule2:409"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.<sup class="fn">bug<span class="fn-text"><var>Name</var>/<var>Arity</var>
410451 as <var>NewName</var> is currently implemented using a <em>link clause</em>.
411452 This harms efficiency and does not allow for querying the relation
412 through <a name="idx:predicateproperty2:410"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.</span></sup>
453 through <a id="idx:predicateproperty2:410"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.</span></sup>
413454
414455 <p>If <var>Import</var> equals <code>all</code>, all operators are
415456 imported as well. Otherwise, operators are <em>not</em> imported.
438479 <dd class="defbody">
439480 If <code>true</code>, raise an error if the file is not a module file.
440481 Used by
441 <a name="idx:usemodule12:411"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.</dd>
482 <a id="idx:usemodule12:411"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.</dd>
442483 <dt><strong>qcompile</strong>(<var>Atom</var>)</dt>
443484 <dd class="defbody">
444 How to deal with quick-load-file compilation by <a name="idx:qcompile1:412"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.
485 How to deal with quick-load-file compilation by <a id="idx:qcompile1:412"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.
445486 Values are:
446487
447488 <dl class="latex">
460501 </dd>
461502 <dt><strong>part</strong></dt>
462503 <dd class="defbody">
463 If <a name="idx:loadfiles2:413"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
504 If <a id="idx:loadfiles2:413"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
464505 appears in a directive of a file that is compiled into Quick Load Format
465 using <a name="idx:qcompile1:414"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
506 using <a id="idx:qcompile1:414"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
466507 the contents of the argument files are included in the <code>.qlf</code>
467508 file instead of the loading directive.
468509 </dd>
475516 Defines what to do if a file is loaded that provides a module that is
476517 already loaded from another file. <var>Action</var> is one of <code>false</code>
477518 (default), which prints an error and refuses to load the file, or
478 <code>true</code>, which uses <a name="idx:unloadfile1:415"></a><a class="pred" href="consulting.html#unload_file/1">unload_file/1</a>
519 <code>true</code>, which uses <a id="idx:unloadfile1:415"></a><a class="pred" href="consulting.html#unload_file/1">unload_file/1</a>
479520 on the old file and then proceeds loading the new file. Finally, there
480521 is <code>ask</code>, which starts interaction with the user. <code>ask</code>
481522 is only provided if the stream <code>user_input</code> is associated
482523 with a terminal.</dd>
483524 <dt><strong>reexport</strong>(<var>Bool</var>)</dt>
484525 <dd class="defbody">
485 If <code>true</code> re-export the imported predicate. Used by <a name="idx:reexport1:416"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
486 and <a name="idx:reexport2:417"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>.</dd>
526 If <code>true</code> re-export the imported predicate. Used by <a id="idx:reexport1:416"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
527 and <a id="idx:reexport2:417"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>.</dd>
487528 <dt><strong>register</strong>(<var>Bool</var>)</dt>
488529 <dd class="defbody">
489530 If <code>false</code>, do not register the load location and options.
490 This option is used by <a name="idx:make0:418"></a><a class="pred" href="consulting.html#make/0">make/0</a>
491 and load_hotfixes1 to avoid polluting the load-context database. See <a name="idx:sourcefileproperty2:419"></a><a class="pred" href="consulting.html#source_file_property/2">source_file_property/2</a>.</dd>
531 This option is used by <a id="idx:make0:418"></a><a class="pred" href="consulting.html#make/0">make/0</a>
532 and load_hotfixes/1 to avoid polluting the load-context database. See <a id="idx:sourcefileproperty2:419"></a><a class="pred" href="consulting.html#source_file_property/2">source_file_property/2</a>.</dd>
492533 <dt><strong>sandboxed</strong>(<var>Bool</var>)</dt>
493534 <dd class="defbody">
494535 Load the file in <em>sandboxed</em> mode. This option controls the flag <a class="flag" href="flags.html#flag:sandboxed_load">sandboxed_load</a>.
497538 Prolog flag is set to <code>true</code> raises a permission error.</dd>
498539 <dt><strong>scope_settings</strong>(<var>Bool</var>)</dt>
499540 <dd class="defbody">
500 Scope <a name="idx:stylecheck1:420"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>
501 and <a name="idx:expectsdialect1:421"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
541 Scope <a id="idx:stylecheck1:420"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>
542 and <a id="idx:expectsdialect1:421"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
502543 to the file and files loaded from the file after the directive. Default
503544 is <code>true</code>. The system and user initialization files (see <strong>-f</strong>
504545 and
518559 clauses as well as to remove all clauses if the data is reconsulted.
519560
520561 <p>This option is added to allow compiling from non-file locations such
521 as databases, the web, the <em>user</em> (see <a name="idx:consult1:422"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
562 as databases, the web, the <em>user</em> (see <a id="idx:consult1:422"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
522563 or other servers. It can be combined with <code>format(qlf)</code> to
523564 load QLF data from a stream.
524565 </dd>
525566 </dl>
526567
527 <p>The <a name="idx:loadfiles2:423"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
568 <p>The <a id="idx:loadfiles2:423"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
528569 predicate can be hooked to load other data or data from objects other
529 than files. See <a name="idx:prologloadfile2:424"></a><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a>
570 than files. See <a id="idx:prologloadfile2:424"></a><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a>
530571 for a description and
531 <code>library(http/http_load)</code> for an example. All hooks for <a name="idx:loadfiles2:425"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
532 are documented in <a class="sec" href="loadfilehook.html">section B.8</a>.</dd>
533 <dt class="pubdef"><a name="consult/1"><strong>consult</strong>(<var>:File</var>)</a></dt>
534 <dd class="defbody">
535 Read <var>File</var> as a Prolog source file. Calls to <a name="idx:consult1:426"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
572 <code>library(http/http_load)</code> for an example. All hooks for <a id="idx:loadfiles2:425"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
573 are documented in <a class="sec" href="loadfilehook.html#sec:B.8">section
574 B.8</a>.</dd>
575 <dt class="pubdef"><a id="consult/1"><strong>consult</strong>(<var>:File</var>)</a></dt>
576 <dd class="defbody">
577 Read <var>File</var> as a Prolog source file. Calls to <a id="idx:consult1:426"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
536578 may be abbreviated by just typing a number of filenames in a list.
537579 Examples:
538 <div style="text-align:center"><table border="0" frame="void" rules="groups">
539 <tr valign="top"><td><code>?- consult(load).</code> </td><td>% consult <code>load</code>
580
581 <p><table class="latex frame-void center">
582 <tr><td><code>?- consult(load).</code> </td><td>% consult <code>load</code>
540583 or <code>load.pl</code> </td></tr>
541 <tr valign="top"><td><code>?- [library(lists)].</code> </td><td>% load
542 library lists </td></tr>
543 <tr valign="top"><td><code>?- [user].</code> </td><td>% Type program on
544 the terminal </td></tr>
584 <tr><td><code>?- [library(lists)].</code> </td><td>% load library lists </td></tr>
585 <tr><td><code>?- [user].</code> </td><td>% Type program on the terminal </td></tr>
545586 </table>
546 </div>
547
548 <p>The predicate <a name="idx:consult1:427"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
587
588 <p>The predicate <a id="idx:consult1:427"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
549589 is equivalent to <code>load_files(File, [])</code>, except for handling
550590 the special file <code>user</code>, which reads clauses from the
551591 terminal. See also the <code>stream(Input)</code> option of
552 <a name="idx:loadfiles2:428"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
592 <a id="idx:loadfiles2:428"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
553593 Abbreviation using <code>?- [file1,file2].</code> does
554594 <em>not</em> work for the empty list (<code>[]</code>). This facility is
555595 implemented by defining the list as a predicate. Applications may only
556596 rely on using the list abbreviation at the Prolog toplevel and in
557597 directives.</dd>
558 <dt class="pubdef"><a name="ensure_loaded/1"><strong>ensure_loaded</strong>(<var>:File</var>)</a></dt>
559 <dd class="defbody">
560 If the file is not already loaded, this is equivalent to <a name="idx:consult1:429"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>.
598 <dt class="pubdef"><a id="ensure_loaded/1"><strong>ensure_loaded</strong>(<var>:File</var>)</a></dt>
599 <dd class="defbody">
600 If the file is not already loaded, this is equivalent to <a id="idx:consult1:429"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>.
561601 Otherwise, if the file defines a module, import all public predicates.
562602 Finally, if the file is already loaded, is not a module file, and the
563 context module is not the global user module, <a name="idx:ensureloaded1:430"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>
564 will call <a name="idx:consult1:431"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>.
603 context module is not the global user module, <a id="idx:ensureloaded1:430"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>
604 will call <a id="idx:consult1:431"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>.
565605
566606 <p>With this semantics, we hope to get as close as possible to the clear
567607 semantics without the presence of a module system. Applications using
568 modules should consider using <a name="idx:usemodule12:432"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
608 modules should consider using <a id="idx:usemodule12:432"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
569609
570610 <p>Equivalent to <code>load_files(Files, [if(not_loaded)]).</code><sup class="fn">47<span class="fn-text">On
571611 older versions the condition used to be <code>if(changed)</code>. Poor
572 time management on some machines or copying often caused problems. The <a name="idx:make0:433"></a><a class="pred" href="consulting.html#make/0">make/0</a>
612 time management on some machines or copying often caused problems. The <a id="idx:make0:433"></a><a class="pred" href="consulting.html#make/0">make/0</a>
573613 predicate deals with updating the running system after changing the
574614 source code.</span></sup></dd>
575 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="include/1"><strong>include</strong>(<var>+File</var>)</a></dt>
615 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="include/1"><strong>include</strong>(<var>+File</var>)</a></dt>
576616 <dd class="defbody">
577617 Textually include the content of <var>File</var> at the position where
578618 the
579619 <em>directive</em> <code>:- include(File).</code> appears. The include
580620 construct is only honoured if it appears as a directive in a source
581621 file. <em>Textual</em> include (similar to C/C++ #include) is obviously
582 useful for sharing declarations such as <a name="idx:dynamic1:434"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
622 useful for sharing declarations such as <a id="idx:dynamic1:434"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
583623 or
584 <a name="idx:multifile1:435"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>
624 <a id="idx:multifile1:435"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>
585625 by including a file with directives from multiple files that use these
586626 predicates.
587627
590630 in which they are defined. This information is used to <em>replace</em>
591631 the old definition after the file has been modified and is reloaded by,
592632 e.g.,
593 <a name="idx:make0:436"></a><a class="pred" href="consulting.html#make/0">make/0</a>.
594 As we understand it, <a name="idx:include1:437"></a><a class="pred" href="consulting.html#include/1">include/1</a>
633 <a id="idx:make0:436"></a><a class="pred" href="consulting.html#make/0">make/0</a>.
634 As we understand it, <a id="idx:include1:437"></a><a class="pred" href="consulting.html#include/1">include/1</a>
595635 is intended to include the same file multiple times. Including a file
596636 holding clauses multiple times into the same module is rather
597637 meaningless as it just duplicates the same clauses. Including a file
598638 holding clauses in multiple modules does not suffer from this problem,
599639 but leads to multiple equivalent
600 <em>copies</em> of predicates. Using <a name="idx:usemodule1:438"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
640 <em>copies</em> of predicates. Using <a id="idx:usemodule1:438"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
601641 can achieve the same result while <em>sharing</em> the predicates.
602642
603 <p>If <a name="idx:include1:439"></a><a class="pred" href="consulting.html#include/1">include/1</a>
643 <p>If <a id="idx:include1:439"></a><a class="pred" href="consulting.html#include/1">include/1</a>
604644 is used to load files holding clauses, and if these files are loaded
605 only once, then these <a name="idx:include1:440"></a><a class="pred" href="consulting.html#include/1">include/1</a>
606 directives can be replaced by other predicates (such as <a name="idx:consult1:441"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>).
607 However, there are several cases where either <a name="idx:include1:442"></a><a class="pred" href="consulting.html#include/1">include/1</a>
645 only once, then these <a id="idx:include1:440"></a><a class="pred" href="consulting.html#include/1">include/1</a>
646 directives can be replaced by other predicates (such as <a id="idx:consult1:441"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>).
647 However, there are several cases where either <a id="idx:include1:442"></a><a class="pred" href="consulting.html#include/1">include/1</a>
608648 has no alternative, or using any alternative also requires other
609 changes. An example of the former is using <a name="idx:include1:443"></a><a class="pred" href="consulting.html#include/1">include/1</a>
649 changes. An example of the former is using <a id="idx:include1:443"></a><a class="pred" href="consulting.html#include/1">include/1</a>
610650 to share directives. An example of the latter are cases where clauses of
611651 different predicates are distributed over multiple files: If these files
612 are loaded with <a name="idx:include1:444"></a><a class="pred" href="consulting.html#include/1">include/1</a>,
613 the directive <a name="idx:discontiguous1:445"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
652 are loaded with <a id="idx:include1:444"></a><a class="pred" href="consulting.html#include/1">include/1</a>,
653 the directive <a id="idx:discontiguous1:445"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
614654 is appropriate, whereas if they are consulted, one must use the
615 directive <a name="idx:multifile1:446"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.
655 directive <a id="idx:multifile1:446"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.
616656
617657 <p>To accommodate included files holding clauses, SWI-Prolog
618658 distinguishes between the source location of a clause (in this case the
619659 included file) and the <em>owner</em> of a clause (the file that
620660 includes the file holding the clause). The source location is used by,
621 e.g., <a name="idx:edit1:447"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
661 e.g., <a id="idx:edit1:447"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
622662 the graphical tracer, etc., while the owner is used to determine which
623663 clauses are removed if the file is modified. Relevant information is
624664 found with the following predicates:
625665
626666 <p>
627667 <ul class="latex">
628 <li><a name="idx:sourcefile2:448"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>
668 <li><a id="idx:sourcefile2:448"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>
629669 describes the owner relation.
630 <li><a name="idx:predicateproperty2:449"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
670 <li><a id="idx:predicateproperty2:449"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
631671 describes the source location (of the first clause).
632 <li><a name="idx:clauseproperty2:450"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>
672 <li><a id="idx:clauseproperty2:450"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>
633673 provides access to both source and ownership.
634 <li><a name="idx:sourcefileproperty2:451"></a><a class="pred" href="consulting.html#source_file_property/2">source_file_property/2</a>
674 <li><a id="idx:sourcefileproperty2:451"></a><a class="pred" href="consulting.html#source_file_property/2">source_file_property/2</a>
635675 can be used to query include relationships between files.
636676 </ul>
637677 </dd>
638 <dt class="pubdef"><a name="require/1"><strong>require</strong>(<var>+ListOfNameAndArity</var>)</a></dt>
678 <dt class="pubdef"><a id="require/1"><strong>require</strong>(<var>+ListOfNameAndArity</var>)</a></dt>
639679 <dd class="defbody">
640680 Declare that this file/module requires the specified predicates to be
641681 defined ``with their commonly accepted definition''. This predicate
649689
650690 <p>SWI-Prolog, having autoloading, does <b>not</b> load the library.
651691 Instead it creates a procedure header for the predicate if it does not
652 exist. This will flag the predicate as `undefined'. See also <a name="idx:check0:452"></a><a class="pred" href="check.html#check/0">check/0</a>
692 exist. This will flag the predicate as `undefined'. See also <a id="idx:check0:452"></a><a class="pred" href="check.html#check/0">check/0</a>
653693 and
654 <a name="idx:autoload0:453"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>.</dd>
655 <dt class="pubdef"><a name="encoding/1"><strong>encoding</strong>(<var>+Encoding</var>)</a></dt>
694 <a id="idx:autoload0:453"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>.</dd>
695 <dt class="pubdef"><a id="encoding/1"><strong>encoding</strong>(<var>+Encoding</var>)</a></dt>
656696 <dd class="defbody">
657697 This directive can appear anywhere in a source file to define how
658698 characters are encoded in the remainder of the file. It can be used in
659699 files that are encoded with a superset of US-ASCII, currently UTF-8 and
660 ISO Latin-1. See also <a class="sec" href="widechars.html">section
700 ISO Latin-1. See also <a class="sec" href="widechars.html#sec:2.19.1">section
661701 2.19.1</a>.</dd>
662 <dt class="pubdef"><a name="make/0"><strong>make</strong></a></dt>
702 <dt class="pubdef"><a id="make/0"><strong>make</strong></a></dt>
663703 <dd class="defbody">
664704 Consult all source files that have been changed since they were
665705 consulted. It checks <var>all</var> loaded source files: files loaded
666706 into a compiled state using <code>pl -c ...</code> and files loaded
667 using <a name="idx:consult1:454"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
668 or one of its derivatives. The predicate <a name="idx:make0:455"></a><a class="pred" href="consulting.html#make/0">make/0</a>
707 using <a id="idx:consult1:454"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
708 or one of its derivatives. The predicate <a id="idx:make0:455"></a><a class="pred" href="consulting.html#make/0">make/0</a>
669709 is called after
670 <a name="idx:edit1:456"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
710 <a id="idx:edit1:456"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
671711 automatically reloading all modified files. If the user uses an external
672 editor (in a separate window), <a name="idx:make0:457"></a><a class="pred" href="consulting.html#make/0">make/0</a>
673 is normally used to update the program after editing. In addition, <a name="idx:make0:458"></a><a class="pred" href="consulting.html#make/0">make/0</a>
674 updates the autoload indices (see <a class="sec" href="autoload.html">section
675 2.13</a>) and runs <a name="idx:listundefined0:459"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>
712 editor (in a separate window), <a id="idx:make0:457"></a><a class="pred" href="consulting.html#make/0">make/0</a>
713 is normally used to update the program after editing. In addition, <a id="idx:make0:458"></a><a class="pred" href="consulting.html#make/0">make/0</a>
714 updates the autoload indices (see <a class="sec" href="autoload.html#sec:2.13">section
715 2.13</a>) and runs <a id="idx:listundefined0:459"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>
676716 from the <code>library(check)</code> library to report on undefined
677717 predicates.</dd>
678 <dt class="pubdef"><a name="library_directory/1"><strong>library_directory</strong>(<var>?Atom</var>)</a></dt>
718 <dt class="pubdef"><a id="library_directory/1"><strong>library_directory</strong>(<var>?Atom</var>)</a></dt>
679719 <dd class="defbody">
680720 Dynamic predicate used to specify library directories. Default
681721 <code>./lib</code>, <code> /lib/prolog</code> and the system's library
682722 (in this order) are defined. The user may add library directories using
683 <a name="idx:assertz1:460"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:asserta1:461"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
684 or remove system defaults using <a name="idx:retract1:462"></a><a class="pred" href="db.html#retract/1">retract/1</a>.
685 Deprecated. New code should use <a name="idx:filesearchpath2:463"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
686 <dt class="pubdef"><a name="file_search_path/2"><strong>file_search_path</strong>(<var>+Alias,
723 <a id="idx:assertz1:460"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a id="idx:asserta1:461"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
724 or remove system defaults using <a id="idx:retract1:462"></a><a class="pred" href="db.html#retract/1">retract/1</a>.
725 Deprecated. New code should use <a id="idx:filesearchpath2:463"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
726 <dt class="pubdef"><a id="file_search_path/2"><strong>file_search_path</strong>(<var>+Alias,
687727 -Path</var>)</a></dt>
688728 <dd class="defbody">
689729 Dynamic multifile hook predicate used to specify `path aliases'. This
690 hook is called by <a name="idx:absolutefilename3:464"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
730 hook is called by <a id="idx:absolutefilename3:464"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
691731 to search files specified as
692732 <code>Alias(Name)</code>, e.g., <code>library(lists)</code>. This
693733 feature is best described using an example. Given the definition:
698738
699739 <p>the file specification <code>demo(myfile)</code> will be expanded to
700740 <code>/usr/lib/prolog/demo/myfile</code>. The second argument of
701 <a name="idx:filesearchpath2:465"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
741 <a id="idx:filesearchpath2:465"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
702742 may be another alias.
703743
704744 <p>Below is the initial definition of the file search path. This path
706746 in the SWI-Prolog home directory. The alias <code>foreign(&lt;<var>Path</var>&gt;)</code>
707747 is intended for storing shared libraries (<code>.so</code> or <code>.DLL</code>
708748 files). See also
709 <a name="idx:useforeignlibrary1:466"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>.
749 <a id="idx:useforeignlibrary1:466"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>.
710750
711751 <pre class="code">
712752 user:file_search_path(library, X) :-
726766 member(Dir, Dirs).
727767 </pre>
728768
729 <p>The <a name="idx:filesearchpath2:467"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
730 expansion is used by all loading predicates as well as by <a name="idx:absolutefilename23:468"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>.
769 <p>The <a id="idx:filesearchpath2:467"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
770 expansion is used by all loading predicates as well as by <a id="idx:absolutefilename23:468"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>.
731771
732772 <p>The Prolog flag <a class="flag" href="flags.html#flag:verbose_file_search">verbose_file_search</a>
733773 can be set to <code>true</code> to help debugging Prolog's search for
734774 files.</dd>
735 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="expand_file_search_path/2"><strong>expand_file_search_path</strong>(<var>+Spec,
775 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="expand_file_search_path/2"><strong>expand_file_search_path</strong>(<var>+Spec,
736776 -Path</var>)</a></dt>
737777 <dd class="defbody">
738778 Unifies <var>Path</var> with all possible expansions of the filename
739 specification <var>Spec</var>. See also <a name="idx:absolutefilename3:469"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
740 <dt class="pubdef"><a name="prolog_file_type/2"><strong>prolog_file_type</strong>(<var>?Extension,
779 specification <var>Spec</var>. See also <a id="idx:absolutefilename3:469"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
780 <dt class="pubdef"><a id="prolog_file_type/2"><strong>prolog_file_type</strong>(<var>?Extension,
741781 ?Type</var>)</a></dt>
742782 <dd class="defbody">
743783 This dynamic multifile predicate defined in module <code>user</code>
744 determines the extensions considered by <a name="idx:filesearchpath2:470"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
784 determines the extensions considered by <a id="idx:filesearchpath2:470"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
745785 <var>Extension</var> is the filename extension without the leading dot,
746786 and
747787 <var>Type</var> denotes the type as used by the <code>file_type(Type)</code>
748 option of <a name="idx:filesearchpath2:471"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
788 option of <a id="idx:filesearchpath2:471"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
749789 Here is the initial definition of
750 <a name="idx:prologfiletype2:472"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>:
790 <a id="idx:prologfiletype2:472"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>:
751791
752792 <pre class="code">
753793 user:prolog_file_type(pl, prolog).
764804 Prolog implementation. We suggest using <code>.pro</code> for avoiding
765805 conflicts with <b>perl</b>. Overriding the system definitions can stop
766806 the system from finding libraries.</dd>
767 <dt class="pubdef"><a name="source_file/1"><strong>source_file</strong>(<var>?File</var>)</a></dt>
807 <dt class="pubdef"><a id="source_file/1"><strong>source_file</strong>(<var>?File</var>)</a></dt>
768808 <dd class="defbody">
769809 True if <var>File</var> is a loaded Prolog source file. <var>File</var>
770810 is the absolute and canonical path to the source file.</dd>
771 <dt class="pubdef"><a name="source_file/2"><strong>source_file</strong>(<var>:Pred,
811 <dt class="pubdef"><a id="source_file/2"><strong>source_file</strong>(<var>:Pred,
772812 ?File</var>)</a></dt>
773813 <dd class="defbody">
774814 True if the predicate specified by <var>Pred</var> is owned by file
775815 <var>File</var>, where <var>File</var> is an absolute path name (see
776 <a name="idx:absolutefilename2:473"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
816 <a id="idx:absolutefilename2:473"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
777817 Can be used with any instantiation pattern, but the database only
778818 maintains the source file for each predicate. If
779819 <var>Pred</var> is a <em>multifile</em> predicate this predicate
780820 succeeds for all files that contribute clauses to <var>Pred</var>.<sup class="fn">48<span class="fn-text">The
781821 current implementation performs a linear scan through all clauses to
782 establish this set of files.</span></sup> See also <a name="idx:clauseproperty2:474"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.
822 establish this set of files.</span></sup> See also <a id="idx:clauseproperty2:474"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.
783823 Note that the relation between files and predicates is more complicated
784 if <a name="idx:include1:475"></a><a class="pred" href="consulting.html#include/1">include/1</a>
824 if <a id="idx:include1:475"></a><a class="pred" href="consulting.html#include/1">include/1</a>
785825 is used. The predicate describes the <em>owner</em> of the predicate.
786826 See
787 <a name="idx:include1:476"></a><a class="pred" href="consulting.html#include/1">include/1</a>
827 <a id="idx:include1:476"></a><a class="pred" href="consulting.html#include/1">include/1</a>
788828 for details.</dd>
789 <dt class="pubdef"><a name="source_file_property/2"><strong>source_file_property</strong>(<var>?File,
829 <dt class="pubdef"><a id="source_file_property/2"><strong>source_file_property</strong>(<var>?File,
790830 ?Property</var>)</a></dt>
791831 <dd class="defbody">
792832 True when <var>Property</var> is a property of the loaded file <var>File</var>.
793833 If <var>File</var> is non-var, it can be a file specification that is
794 valid for <a name="idx:loadfiles2:477"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
834 valid for <a id="idx:loadfiles2:477"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
795835 Defined properties are:
796836
797837 <dl class="latex">
801841 was last modified at time <var>OriginalModified</var> at the time it was
802842 loaded. This property is available if <var>File</var> was loaded using
803843 the
804 <code>derived_from(Original)</code> option to <a name="idx:loadfiles2:478"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
844 <code>derived_from(Original)</code> option to <a id="idx:loadfiles2:478"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
805845 <dt><strong>includes</strong>(<var>IncludedFile, IncludedFileModified</var>)</dt>
806846 <dd class="defbody">
807 <var>File</var> used <a name="idx:include1:479"></a><a class="pred" href="consulting.html#include/1">include/1</a>
847 <var>File</var> used <a id="idx:include1:479"></a><a class="pred" href="consulting.html#include/1">include/1</a>
808848 to include <var>IncludedFile</var>. The last modified time of <var>IncludedFile</var>
809849 was <var>IncludedFileModified</var> at the time it was included.</dd>
810850 <dt><strong>included_in</strong>(<var>MasterFile, Line</var>)</dt>
820860 the file was loaded. It is either a term &lt;<var>file</var>&gt;:&lt;<var>line</var>&gt;
821861 or the atom
822862 <code>user</code> if the file was loaded from the terminal or another
823 unknown source. <var>Options</var> are the options passed to <a name="idx:loadfiles2:480"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
824 Note that all predicates to load files are mapped to <a name="idx:loadfiles2:481"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>,
863 unknown source. <var>Options</var> are the options passed to <a id="idx:loadfiles2:480"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
864 Note that all predicates to load files are mapped to <a id="idx:loadfiles2:481"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>,
825865 using the option argument to specify the exact behaviour.</dd>
826866 <dt><strong>load_count</strong>(<var>-Count</var>)</dt>
827867 <dd class="defbody">
830870 <dt><strong>modified</strong>(<var>Stamp</var>)</dt>
831871 <dd class="defbody">
832872 File modification time when <var>File</var> was loaded. This is used by
833 <a name="idx:make0:482"></a><a class="pred" href="consulting.html#make/0">make/0</a>
873 <a id="idx:make0:482"></a><a class="pred" href="consulting.html#make/0">make/0</a>
834874 to find files whose modification time is different from when it was
835875 loaded.</dd>
836876 <dt><strong>module</strong>(<var>Module</var>)</dt>
848888 </dl>
849889
850890 </dd>
851 <dt class="pubdef"><a name="unload_file/1"><strong>unload_file</strong>(<var>+File</var>)</a></dt>
891 <dt class="pubdef"><a id="unload_file/1"><strong>unload_file</strong>(<var>+File</var>)</a></dt>
852892 <dd class="defbody">
853893 Remove all clauses loaded from <var>File</var>. If <var>File</var>
854894 loaded a module, clear the module's export list and disassociate it from
855895 the file. <var>File</var> is a canonical filename or a file indicator
856 that is valid for <a name="idx:loadfiles2:483"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
896 that is valid for <a id="idx:loadfiles2:483"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
857897
858898 <p>This predicate should be used with care. The multithreaded nature of
859899 SWI-Prolog makes removing static code unsafe. Attempts to do this should
860900 be reserved for development or situations where the application can
861901 guarantee that none of the clauses associated to <var>File</var> are
862902 active.</dd>
863 <dt class="pubdef"><a name="prolog_load_context/2"><strong>prolog_load_context</strong>(<var>?Key,
903 <dt class="pubdef"><a id="prolog_load_context/2"><strong>prolog_load_context</strong>(<var>?Key,
864904 ?Value</var>)</a></dt>
865905 <dd class="defbody">
866906 Obtain context information during compilation. This predicate can be
867907 used from directives appearing in a source file to get information about
868 the file being loaded as well as by the <a name="idx:termexpansion2:484"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
908 the file being loaded as well as by the <a id="idx:termexpansion2:484"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
869909 and
870 <a name="idx:goalexpansion2:485"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
871 hooks. See also <a name="idx:sourcelocation2:486"></a><a class="pred" href="consulting.html#source_location/2">source_location/2</a>
872 and <a name="idx:if1:487"></a><a class="pred" href="consulting.html#if/1">if/1</a>.
910 <a id="idx:goalexpansion2:485"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
911 hooks. See also <a id="idx:sourcelocation2:486"></a><a class="pred" href="consulting.html#source_location/2">source_location/2</a>
912 and <a id="idx:if1:487"></a><a class="pred" href="consulting.html#if/1">if/1</a>.
873913 The following keys are defined:
874914
875 <p><table border="2" frame="box" rules="groups" style="margin:auto">
876 <tr valign="top"><td><b>Key</b></td><td><b>Description </b></td></tr>
877 <tbody>
878 <tr valign="top"><td><code>directory</code> </td><td>Directory in which <code>source</code>
915 <p><table class="latex frame-box center">
916 <tr><td><b>Key</b></td><td><b>Description </b></td></tr>
917 <tr class="hline"><td><code>directory</code> </td><td>Directory in which <code>source</code>
879918 lives </td></tr>
880 <tr valign="top"><td><code>dialect</code> </td><td>Compatibility mode.
881 See <a name="idx:expectsdialect1:488"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>. </td></tr>
882 <tr valign="top"><td><code>file</code> </td><td>Similar to <code>source</code>,
883 but returns the file being included when called while an include file is
919 <tr><td><code>dialect</code> </td><td>Compatibility mode. See <a id="idx:expectsdialect1:488"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>. </td></tr>
920 <tr><td><code>file</code> </td><td>Similar to <code>source</code>, but
921 returns the file being included when called while an include file is
884922 being processed </td></tr>
885 <tr valign="top"><td><code>module</code> </td><td>Module into which file
886 is loaded </td></tr>
887 <tr valign="top"><td><code>reload</code> </td><td><code>true</code> if
888 the file is being
923 <tr><td><code>module</code> </td><td>Module into which file is loaded </td></tr>
924 <tr><td><code>reload</code> </td><td><code>true</code> if the file is
925 being
889926 <b>re</b>loaded. Not present on first load </td></tr>
890 <tr valign="top"><td><code>script</code> </td><td>Boolean that indicates
891 whether the file is loaded as a script file (see
927 <tr><td><code>script</code> </td><td>Boolean that indicates whether the
928 file is loaded as a script file (see
892929 <strong>-s</strong>) </td></tr>
893 <tr valign="top"><td><code>source</code> </td><td>File being loaded. If
894 the system is processing an included file, the value is the <em>main</em>
895 file. Returns the original Prolog file when loading a
930 <tr><td><code>source</code> </td><td>File being loaded. If the system is
931 processing an included file, the value is the <em>main</em> file.
932 Returns the original Prolog file when loading a
896933 <code>.qlf</code> file. </td></tr>
897 <tr valign="top"><td><code>stream</code> </td><td>Stream identifier (see <a name="idx:currentinput1:489"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>) </td></tr>
898 <tr valign="top"><td><code>term_position</code> </td><td>Start position
899 of last term read. See also
900 <a name="idx:streamproperty2:490"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
934 <tr><td><code>stream</code> </td><td>Stream identifier (see <a id="idx:currentinput1:489"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>) </td></tr>
935 <tr><td><code>term_position</code> </td><td>Start position of last term
936 read. See also
937 <a id="idx:streamproperty2:490"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
901938 (<code>position</code> property and
902 <a name="idx:streampositiondata3:491"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.<sup class="fn">49<span class="fn-text">Up
939 <a id="idx:streampositiondata3:491"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.<sup class="fn">49<span class="fn-text">Up
903940 to version 7.1.22, the position term carried fake data except for the <code>line_count</code>
904941 and had <b>five</b> arguments, where the position property of a stream
905942 only has <b>four</b>.</span></sup> </td></tr>
906 <tr valign="top"><td><code>term</code> </td><td>Term being expanded by <a name="idx:expandterm2:492"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>. </td></tr>
907 <tr valign="top"><td><code>variable_names</code></td><td>A list of `<var>Name</var>
908 = <var>Var</var>' of the last term read. See <a name="idx:readterm2:493"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
943 <tr><td><code>term</code> </td><td>Term being expanded by <a id="idx:expandterm2:492"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>. </td></tr>
944 <tr><td><code>variable_names</code></td><td>A list of `<var>Name</var> = <var>Var</var>'
945 of the last term read. See <a id="idx:readterm2:493"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
909946 for details. </td></tr>
910947 </table>
911948
912 <p>The <code>directory</code> is commonly used to add rules to <a name="idx:filesearchpath2:494"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>,
913 setting up a search path for finding files with <a name="idx:absolutefilename3:495"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
949 <p>The <code>directory</code> is commonly used to add rules to <a id="idx:filesearchpath2:494"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>,
950 setting up a search path for finding files with <a id="idx:absolutefilename3:495"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
914951 For example:
915952
916953 <pre class="code">
927964 </pre>
928965
929966 </dd>
930 <dt class="pubdef"><a name="source_location/2"><strong>source_location</strong>(<var>-File,
967 <dt class="pubdef"><a id="source_location/2"><strong>source_location</strong>(<var>-File,
931968 -Line</var>)</a></dt>
932969 <dd class="defbody">
933970 If the last term has been read from a physical file (i.e., not from the
934971 file <code>user</code> or a string), unify <var>File</var> with an
935972 absolute path to the file and <var>Line</var> with the line number in
936 the file. New code should use <a name="idx:prologloadcontext2:496"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>.</dd>
937 <dt class="pubdef"><a name="at_halt/1"><strong>at_halt</strong>(<var>:Goal</var>)</a></dt>
973 the file. New code should use <a id="idx:prologloadcontext2:496"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>.</dd>
974 <dt class="pubdef"><a id="at_halt/1"><strong>at_halt</strong>(<var>:Goal</var>)</a></dt>
938975 <dd class="defbody">
939976 Register <var>Goal</var> to be run from <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</a>,
940977 which is called when the system halts. The hooks are run in the reverse
941978 order they were registered (FIFO). Success or failure executing a hook
942 is ignored. If the hook raises an exception this is printed using <a name="idx:printmessage2:497"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
943 An attempt to call <a name="idx:halt01:498"></a><a class="pred" href="toplevel.html#halt/0">halt/[0,1]</a>
979 is ignored. If the hook raises an exception this is printed using <a id="idx:printmessage2:497"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
980 An attempt to call <a id="idx:halt01:498"></a><a class="pred" href="toplevel.html#halt/0">halt/[0,1]</a>
944981 from a hook is ignored. Hooks may call
945 <a name="idx:cancelhalt1:499"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>,
946 causing <a name="idx:halt0:500"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
982 <a id="idx:cancelhalt1:499"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>,
983 causing <a id="idx:halt0:500"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
947984 and <a class="func" href="foreigninclude.html#PL_halt()">PL_halt(0)</a>
948985 to print a message indicating that halting the system has been
949986 cancelled.</dd>
950 <dt class="pubdef"><a name="cancel_halt/1"><strong>cancel_halt</strong>(<var>+Reason</var>)</a></dt>
951 <dd class="defbody">
952 If this predicate is called from a hook registered with <a name="idx:athalt1:501"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>,
987 <dt class="pubdef"><a id="cancel_halt/1"><strong>cancel_halt</strong>(<var>+Reason</var>)</a></dt>
988 <dd class="defbody">
989 If this predicate is called from a hook registered with <a id="idx:athalt1:501"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>,
953990 halting Prolog is cancelled and an informational message is printed that
954991 includes <var>Reason</var>. This is used by the development tools to
955992 cancel halting the system if the editor has unsafed data and the user
956993 decides to cancel.</dd>
957 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="initialization/1">:- <strong>initialization</strong>(<var>:Goal</var>)</a></dt>
994 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="initialization/1">:- <strong>initialization</strong>(<var>:Goal</var>)</a></dt>
958995 <dd class="defbody">
959996 Call <var>Goal</var> <em>after</em> loading the source file in which
960997 this directive appears has been completed. In addition, <var>Goal</var>
961 is executed if a saved state created using <a name="idx:qsaveprogram1:502"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>
998 is executed if a saved state created using <a id="idx:qsaveprogram1:502"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>
962999 is restored.
9631000
9641001 <p>The ISO standard only allows for using <code>:- Term</code> if <var>Term</var>
9651002 is a
9661003 <em>directive</em>. This means that arbitrary goals can only be called
967 from a directive by means of the <a name="idx:initialization1:503"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1004 from a directive by means of the <a id="idx:initialization1:503"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
9681005 directive. SWI-Prolog does not enforce this rule.
9691006
970 <p>The <a name="idx:initialization1:504"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
971 directive must be used to do program initialization in saved states (see <a name="idx:qsaveprogram1:505"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>).
1007 <p>The <a id="idx:initialization1:504"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1008 directive must be used to do program initialization in saved states (see <a id="idx:qsaveprogram1:505"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>).
9721009 A saved state contains the predicates, Prolog flags and operators
9731010 present at the moment the state was created. Other resources (records,
974 foreign resources, etc.) must be recreated using <a name="idx:initialization1:506"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1011 foreign resources, etc.) must be recreated using <a id="idx:initialization1:506"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
9751012 directives or from the entry goal of the saved state.
9761013
9771014 <p>Up to SWI-Prolog 5.7.11, <var>Goal</var> was executed immediately
9781015 rather than after loading the program text in which the directive
9791016 appears as dictated by the ISO standard. In many cases the exact moment
9801017 of execution is irrelevant, but there are exceptions. For example,
981 <a name="idx:loadforeignlibrary1:507"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
1018 <a id="idx:loadforeignlibrary1:507"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
9821019 must be executed immediately to make the loaded foreign predicates
983 available for exporting. SWI-Prolog now provides the directive <a name="idx:useforeignlibrary1:508"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
1020 available for exporting. SWI-Prolog now provides the directive <a id="idx:useforeignlibrary1:508"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
9841021 to ensure immediate loading as well as loading after restoring a saved
9851022 state. If the system encounters a directive <code>:-
9861023 initialization(load_foreign_library(...))</code>, it will load the
9881025 This behaviour can be extended by providing clauses for the multifile
9891026 hook predicate <code>prolog:initialize_now(Term, Advice)</code>, where <var>Advice</var>
9901027 is an atom that gives advice on how to resolve the compatibility issue.</dd>
991 <dt class="pubdef"><a name="initialization/2"><strong>initialization</strong>(<var>:Goal,
1028 <dt class="pubdef"><a id="initialization/2"><strong>initialization</strong>(<var>:Goal,
9921029 +When</var>)</a></dt>
9931030 <dd class="defbody">
994 Similar to <a name="idx:initialization1:509"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
1031 Similar to <a id="idx:initialization1:509"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
9951032 but allows for specifying when <var>Goal</var> is executed while loading
9961033 the program text:
9971034
10031040 <dd class="defbody">
10041041 Execute <var>Goal</var> after loading the program text in which the
10051042 directive appears. This is the same as
1006 <a name="idx:initialization1:510"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.</dd>
1043 <a id="idx:initialization1:510"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.</dd>
10071044 <dt><strong>restore</strong></dt>
10081045 <dd class="defbody">
10091046 Do not execute <var>Goal</var> while loading the program, but <em>only</em>
10151052 encountered and a failure or exception causes the Prolog to exit with
10161053 non-zero exit status. These goals are <em>not</em> executed if the
10171054 <strong>-l</strong> is given to merely <em>load</em> files. In that case
1018 they may be executed explicitly using <a name="idx:initialize0:511"></a><span class="pred-ext">initialize/0</span>.
1055 they may be executed explicitly using <a id="idx:initialize0:511"></a><span class="pred-ext">initialize/0</span>.
10191056 See also
1020 <a class="sec" href="compilation.html">section 2.10.2.1</a>.</dd>
1057 <a class="sec" href="compilation.html#sec:2.10.2.1">section 2.10.2.1</a>.</dd>
10211058 <dt><strong>main</strong></dt>
10221059 <dd class="defbody">
10231060 When Prolog starts, the last goal registered using
10241061 <code>initialization(Goal, main)</code> is executed as main goal. If
10251062 <var>Goal</var> fails or raises an exception, the process terminates
10261063 with non-zero exit code. If not explicitly specified using the
1027 <strong>-t</strong> the <em>toplevel goal</em> is set to <a name="idx:halt0:512"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>,
1064 <strong>-t</strong> the <em>toplevel goal</em> is set to <a id="idx:halt0:512"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>,
10281065 causing the process to exit with status 0. An explicitly specified
10291066 toplevel is executed normally. This implies that <code>-t prolog</code>
10301067 causes the application to start the normal interactive toplevel after
10311068 completing
10321069 <var>Goal</var>. See also the Prolog flag <a class="flag" href="flags.html#flag:toplevel_goal">toplevel_goal</a>
10331070 and
1034 <a class="sec" href="compilation.html">section 2.10.2.1</a>.
1071 <a class="sec" href="compilation.html#sec:2.10.2.1">section 2.10.2.1</a>.
10351072 </dd>
10361073 </dl>
10371074
10381075 </dd>
1039 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="initialization/0"><strong>initialization</strong></a></dt>
1076 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="initialization/0"><strong>initialization</strong></a></dt>
10401077 <dd class="defbody">
10411078 Run all initialization goals registered using
10421079 <code>initialization(Goal, program)</code>. Raises an error
10431080 <code>initialization_error(Reason, Goal, File:Line)</code> if <var>Goal</var>
10441081 fails or raises an exception. <var>Reason</var> is <code>failed</code>
10451082 or the exception raised.</dd>
1046 <dt class="pubdef"><a name="compiling/0"><strong>compiling</strong></a></dt>
1083 <dt class="pubdef"><a id="compiling/0"><strong>compiling</strong></a></dt>
10471084 <dd class="defbody">
10481085 True if the system is compiling source files with the <strong>-c</strong>
1049 option or <a name="idx:qcompile1:513"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
1086 option or <a id="idx:qcompile1:513"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
10501087 into an intermediate code file. Can be used to perform conditional code
1051 optimisations in <a name="idx:termexpansion2:514"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1088 optimisations in <a id="idx:termexpansion2:514"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
10521089 (see also the
10531090 <strong>-O</strong> option) or to omit execution of directives during
10541091 compilation.
10551092 </dd>
10561093 </dl>
10571094
1058 <p><h3 id="sec:progtransform"><a name="sec:4.3.1"><span class="sec-nr">4.3.1</span> <span class="sec-title">Conditional
1095 <p><h3 id="sec:progtransform"><a id="sec:4.3.1"><span class="sec-nr">4.3.1</span> <span class="sec-title">Conditional
10591096 compilation and program transformation</span></a></h3>
10601097
1061 <a name="sec:progtransform"></a>
1062
1063 <p><a name="idx:transformationofprogram:515"></a>ISO Prolog defines no
1064 way for program transformations such as macro expansion or conditional
1065 compilation. Expansion through <a name="idx:termexpansion2:516"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1066 and <a name="idx:expandterm2:517"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1098 <a id="sec:progtransform"></a>
1099
1100 <p><a id="idx:transformationofprogram:515"></a>ISO Prolog defines no way
1101 for program transformations such as macro expansion or conditional
1102 compilation. Expansion through <a id="idx:termexpansion2:516"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1103 and <a id="idx:expandterm2:517"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
10671104 can be seen as part of the de-facto standard. This mechanism can do
10681105 arbitrary translation between valid Prolog terms read from the source
10691106 file to Prolog terms handed to the compiler. As
1070 <a name="idx:termexpansion2:518"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1107 <a id="idx:termexpansion2:518"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
10711108 can return a list, the transformation does not need to be term-to-term.
10721109
1073 <p>Various Prolog dialects provide the analogous <a name="idx:goalexpansion2:519"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1110 <p>Various Prolog dialects provide the analogous <a id="idx:goalexpansion2:519"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
10741111 and
1075 <a name="idx:expandgoal2:520"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
1112 <a id="idx:expandgoal2:520"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
10761113 that allow for translation of individual body terms, freeing the user of
10771114 the task to disassemble each clause.
10781115
10791116 <dl class="latex">
1080 <dt class="pubdef"><a name="term_expansion/2"><strong>term_expansion</strong>(<var>+Term1,
1117 <dt class="pubdef"><a id="term_expansion/2"><strong>term_expansion</strong>(<var>+Term1,
10811118 -Term2</var>)</a></dt>
10821119 <dd class="defbody">
10831120 Dynamic and multifile predicate, normally not defined. When defined by
10931130 <code>'$source_location'(&lt;<var>File</var>&gt;, &lt;<var>Line</var>&gt;):&lt;<var>Clause</var>&gt;</code>
10941131 </blockquote>
10951132
1096 <p>When compiling a module (see <a class="sec" href="modules.html">chapter
1097 6</a> and the directive <a name="idx:module2:521"></a><a class="pred" href="defmodule.html#module/2">module/2</a>),
1098 <a name="idx:expandterm2:522"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1099 will first try <a name="idx:termexpansion2:523"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1133 <p>When compiling a module (see <a class="sec" href="modules.html#sec:6">chapter
1134 6</a> and the directive <a id="idx:module2:521"></a><a class="pred" href="defmodule.html#module/2">module/2</a>),
1135 <a id="idx:expandterm2:522"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1136 will first try <a id="idx:termexpansion2:523"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
11001137 in the module being compiled to allow for term expansion rules that are
11011138 local to a module. If there is no local definition, or the local
1102 definition fails to translate the term, <a name="idx:expandterm2:524"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1103 will try <a name="idx:termexpansion2:525"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1139 definition fails to translate the term, <a id="idx:expandterm2:524"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1140 will try <a id="idx:termexpansion2:525"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
11041141 in module
11051142 <code>user</code>. For compatibility with SICStus and Quintus Prolog,
1106 this feature should not be used. See also <a name="idx:expandterm2:526"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>, <a name="idx:goalexpansion2:527"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1143 this feature should not be used. See also <a id="idx:expandterm2:526"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>, <a id="idx:goalexpansion2:527"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11071144 and
1108 <a name="idx:expandgoal2:528"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>.</dd>
1109 <dt class="pubdef"><a name="expand_term/2"><strong>expand_term</strong>(<var>+Term1,
1145 <a id="idx:expandgoal2:528"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>.</dd>
1146 <dt class="pubdef"><a id="expand_term/2"><strong>expand_term</strong>(<var>+Term1,
11101147 -Term2</var>)</a></dt>
11111148 <dd class="defbody">
11121149 This predicate is normally called by the compiler on terms read from the
11161153 <p>
11171154 <ol class="latex">
11181155 <li>Test conditional compilation directives and translate all input to <code>[]</code>
1119 if we are in a `false branch' of the conditional compilation. See <a class="sec" href="consulting.html">section
1156 if we are in a `false branch' of the conditional compilation. See <a class="sec" href="consulting.html#sec:4.3.1.2">section
11201157 4.3.1.2</a>.
11211158
11221159 <p>
1123 <li>Call <a name="idx:termexpansion2:529"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>.
1160 <li>Call <a id="idx:termexpansion2:529"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>.
11241161 This predicate is first tried in the module that is being compiled and
11251162 then in the module
11261163 <code>user</code>.
11271164
11281165 <p>
1129 <li>Call DCG expansion (<a name="idx:dcgtranslaterule2:530"></a><a class="pred" href="consulting.html#dcg_translate_rule/2">dcg_translate_rule/2</a>).
1166 <li>Call DCG expansion (<a id="idx:dcgtranslaterule2:530"></a><a class="pred" href="consulting.html#dcg_translate_rule/2">dcg_translate_rule/2</a>).
11301167
11311168 <p>
1132 <li>Call <a name="idx:expandgoal2:531"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
1169 <li>Call <a id="idx:expandgoal2:531"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
11331170 on each body term that appears in the output of the previous steps.
11341171 </ol>
11351172 </dd>
1136 <dt class="pubdef"><a name="goal_expansion/2"><strong>goal_expansion</strong>(<var>+Goal1,
1173 <dt class="pubdef"><a id="goal_expansion/2"><strong>goal_expansion</strong>(<var>+Goal1,
11371174 -Goal2</var>)</a></dt>
11381175 <dd class="defbody">
1139 Like <a name="idx:termexpansion2:532"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a name="idx:goalexpansion2:533"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1140 provides for macro expansion of Prolog source code. Between <a name="idx:expandterm2:534"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1176 Like <a id="idx:termexpansion2:532"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a id="idx:goalexpansion2:533"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1177 provides for macro expansion of Prolog source code. Between <a id="idx:expandterm2:534"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
11411178 and the actual compilation, the body of clauses analysed and the goals
1142 are handed to <a name="idx:expandgoal2:535"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>,
1143 which uses the <a name="idx:goalexpansion2:536"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1179 are handed to <a id="idx:expandgoal2:535"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>,
1180 which uses the <a id="idx:goalexpansion2:536"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11441181 hook to do user-defined expansion.
11451182
1146 <p>The predicate <a name="idx:goalexpansion2:537"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1183 <p>The predicate <a id="idx:goalexpansion2:537"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11471184 is first called in the module that is being compiled, and then follows
1148 the module inheritance path as defined by <a name="idx:defaultmodule2:538"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>,
1185 the module inheritance path as defined by <a id="idx:defaultmodule2:538"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>,
11491186 i.e., by default <code>user</code> and <code>system</code>. If <var>Goal</var>
11501187 is of the form <var>Module</var>:<var>Goal</var> where <var>Module</var>
1151 is instantiated, <a name="idx:goalexpansion2:539"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1188 is instantiated, <a id="idx:goalexpansion2:539"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11521189 is called on <var>Goal</var> using rules from module <var>Module</var>
11531190 followed by default modules for <var>Module</var>.
11541191
11551192 <p>Only goals appearing in the body of clauses when reading a source
11561193 file are expanded using this mechanism, and only if they appear
11571194 literally in the clause, or as an argument to a defined meta-predicate
1158 that is annotated using `0' (see <a name="idx:metapredicate1:540"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>).
1195 that is annotated using `0' (see <a id="idx:metapredicate1:540"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>).
11591196 Other cases need a real predicate definition.
11601197
1161 <p>The expansion hook can use <a name="idx:prologloadcontext2:541"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>
1198 <p>The expansion hook can use <a id="idx:prologloadcontext2:541"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>
11621199 to obtain information about the context in which the goal is exanded
11631200 such as the module, variable names or the encapsulating term.</dd>
1164 <dt class="pubdef"><a name="expand_goal/2"><strong>expand_goal</strong>(<var>+Goal1,
1201 <dt class="pubdef"><a id="expand_goal/2"><strong>expand_goal</strong>(<var>+Goal1,
11651202 -Goal2</var>)</a></dt>
11661203 <dd class="defbody">
11671204 This predicate is normally called by the compiler to perform
1168 preprocessing using <a name="idx:goalexpansion2:542"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
1205 preprocessing using <a id="idx:goalexpansion2:542"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
11691206 The predicate computes a fixed-point by applying transformations until
11701207 there are no more changes. If optimisation is enabled (see <strong>-O</strong>
11711208 and
1172 <a class="flag" href="flags.html#flag:optimise">optimise</a>), <a name="idx:expandgoal2:543"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
1173 simplifies the result by removing unneeded calls to <a name="idx:true0:544"></a><a class="pred" href="control.html#true/0">true/0</a>
1174 and <a name="idx:fail0:545"></a><a class="pred" href="control.html#fail/0">fail/0</a>
1209 <a class="flag" href="flags.html#flag:optimise">optimise</a>), <a id="idx:expandgoal2:543"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
1210 simplifies the result by removing unneeded calls to <a id="idx:true0:544"></a><a class="pred" href="control.html#true/0">true/0</a>
1211 and <a id="idx:fail0:545"></a><a class="pred" href="control.html#fail/0">fail/0</a>
11751212 as well as unreachable branches.</dd>
1176 <dt class="pubdef"><a name="compile_aux_clauses/1"><strong>compile_aux_clauses</strong>(<var>+Clauses</var>)</a></dt>
1177 <dd class="defbody">
1178 Compile clauses on behalf of <a name="idx:goalexpansion2:546"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
1213 <dt class="pubdef"><a id="compile_aux_clauses/1"><strong>compile_aux_clauses</strong>(<var>+Clauses</var>)</a></dt>
1214 <dd class="defbody">
1215 Compile clauses on behalf of <a id="idx:goalexpansion2:546"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
11791216 This predicate compiles the argument clauses into static predicates,
11801217 associating the predicates with the current file but avoids changing the
11811218 notion of current predicate and therefore discontiguous warnings.
11821219
11831220 <p>Note that in some cases multiple expansions of similar goals can
11841221 share the same compiled auxiliary predicate. In such cases, the
1185 implementation of <a name="idx:goalexpansion2:547"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1186 can use <a name="idx:predicateproperty2:548"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
1222 implementation of <a id="idx:goalexpansion2:547"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1223 can use <a id="idx:predicateproperty2:548"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
11871224 using the property
11881225 <code>defined</code> to test whether the predicate is already defined in
11891226 the current context.</dd>
1190 <dt class="pubdef"><a name="dcg_translate_rule/2"><strong>dcg_translate_rule</strong>(<var>+In,
1227 <dt class="pubdef"><a id="dcg_translate_rule/2"><strong>dcg_translate_rule</strong>(<var>+In,
11911228 -Out</var>)</a></dt>
11921229 <dd class="defbody">
11931230 This predicate performs the translation of a term <code>Head--&gt;Body</code>
11941231 into a normal Prolog clause. Normally this functionality should be
1195 accessed using <a name="idx:expandterm2:549"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>.</dd>
1196 <dt class="pubdef"><a name="var_property/2"><strong>var_property</strong>(<var>+Var,
1232 accessed using <a id="idx:expandterm2:549"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>.</dd>
1233 <dt class="pubdef"><a id="var_property/2"><strong>var_property</strong>(<var>+Var,
11971234 ?Property</var>)</a></dt>
11981235 <dd class="defbody">
11991236 True when <var>Property</var> is a property of <var>Var</var>. These
12001237 properties are available during goal- and term-expansion. Defined
12011238 properties are below. Future versions are likely to provide more
12021239 properties, such as whether the variable is a singleton or whether the
1203 variable is referenced in the remainder of the term. See also <a name="idx:goalexpansion2:550"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
1240 variable is referenced in the remainder of the term. See also <a id="idx:goalexpansion2:550"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
12041241
12051242 <dl class="latex">
12061243 <dt><strong>fresh</strong>(<var>Bool</var>)</dt>
12191256 </dd>
12201257 </dl>
12211258
1222 <p><h4 id="sec:progtransform-layout"><a name="sec:4.3.1.1"><span class="sec-nr">4.3.1.1</span> <span class="sec-title">Program
1259 <p><h4 id="sec:progtransform-layout"><a id="sec:4.3.1.1"><span class="sec-nr">4.3.1.1</span> <span class="sec-title">Program
12231260 transformation with source layout info</span></a></h4>
12241261
1225 <a name="sec:progtransform-layout"></a>
1262 <a id="sec:progtransform-layout"></a>
12261263
12271264 <p>This sections documents extended versions of the program
12281265 transformation predicates that also transform the source layout
12371274 </ul>
12381275
12391276 <dl class="latex">
1240 <dt class="pubdef"><a name="expand_goal/4"><strong>expand_goal</strong>(<var>+Goal1,
1277 <dt class="pubdef"><a id="expand_goal/4"><strong>expand_goal</strong>(<var>+Goal1,
12411278 ?Layout1, -Goal2, -Layout2</var>)</a></dt>
1242 <dt class="pubdef"><a name="goal_expansion/4"><strong>goal_expansion</strong>(<var>+Goal1,
1279 <dt class="pubdef"><a id="goal_expansion/4"><strong>goal_expansion</strong>(<var>+Goal1,
12431280 ?Layout1, -Goal2, -Layout2</var>)</a></dt>
1244 <dt class="pubdef"><a name="expand_term/4"><strong>expand_term</strong>(<var>+Term1,
1281 <dt class="pubdef"><a id="expand_term/4"><strong>expand_term</strong>(<var>+Term1,
12451282 ?Layout1, -Term2, -Layout2</var>)</a></dt>
1246 <dt class="pubdef"><a name="term_expansion/4"><strong>term_expansion</strong>(<var>+Term1,
1283 <dt class="pubdef"><a id="term_expansion/4"><strong>term_expansion</strong>(<var>+Term1,
12471284 ?Layout1, -Term2, -Layout2</var>)</a></dt>
1248 <dt class="pubdef"><a name="dcg_translate_rule/4"><strong>dcg_translate_rule</strong>(<var>+In,
1285 <dt class="pubdef"><a id="dcg_translate_rule/4"><strong>dcg_translate_rule</strong>(<var>+In,
12491286 ?LayoutIn, -Out, -LayoutOut</var>)</a></dt>
12501287 <dd class="defbody">
12511288 These versions are called <em>before</em> their 2-argument counterparts.
12521289 The input layout term is either a variable (if no layout information is
12531290 available) or a term carrying detailed layout information as returned by
1254 the <code>subterm_positions</code> of <a name="idx:readterm2:551"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
1291 the <code>subterm_positions</code> of <a id="idx:readterm2:551"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
12551292 </dd>
12561293 </dl>
12571294
1258 <p><h4 id="sec:conditionalcompilation"><a name="sec:4.3.1.2"><span class="sec-nr">4.3.1.2</span> <span class="sec-title">Conditional
1295 <p><h4 id="sec:conditionalcompilation"><a id="sec:4.3.1.2"><span class="sec-nr">4.3.1.2</span> <span class="sec-title">Conditional
12591296 compilation</span></a></h4>
12601297
1261 <a name="sec:conditionalcompilation"></a>
1262
1263 <p><a name="idx:ifdirective:552"></a>Conditional compilation builds on
1264 the same principle as
1265 <a name="idx:termexpansion2:553"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a name="idx:goalexpansion2:554"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1298 <a id="sec:conditionalcompilation"></a>
1299
1300 <p><a id="idx:ifdirective:552"></a>Conditional compilation builds on the
1301 same principle as
1302 <a id="idx:termexpansion2:553"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a id="idx:goalexpansion2:554"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
12661303 and the expansion of grammar rules to compile sections of the source
12671304 code conditionally. One of the reasons for introducing conditional
1268 compilation is to simplify writing portable code. See <a class="sec" href="dialect.html">section
1305 compilation is to simplify writing portable code. See <a class="sec" href="dialect.html#sec:C">section
12691306 C</a> for more information. Here is a simple example:
12701307
12711308 <pre class="code">
12901327 </ul>
12911328
12921329 <dl class="latex">
1293 <dt class="pubdef"><a name="if/1">:- <strong>if</strong>(<var>:Goal</var>)</a></dt>
1330 <dt class="pubdef"><a id="if/1">:- <strong>if</strong>(<var>:Goal</var>)</a></dt>
12941331 <dd class="defbody">
12951332 Compile subsequent code only if <var>Goal</var> succeeds. For enhanced
1296 portability, <var>Goal</var> is processed by <a name="idx:expandgoal2:555"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
1333 portability, <var>Goal</var> is processed by <a id="idx:expandgoal2:555"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
12971334 before execution. If an error occurs, the error is printed and
12981335 processing proceeds as if
12991336 <var>Goal</var> has failed.</dd>
1300 <dt class="pubdef"><a name="elif/1">:- <strong>elif</strong>(<var>:Goal</var>)</a></dt>
1337 <dt class="pubdef"><a id="elif/1">:- <strong>elif</strong>(<var>:Goal</var>)</a></dt>
13011338 <dd class="defbody">
13021339 Equivalent to <code>:- else. :-if(Goal).</code> ... <code>:- endif.</code>
13031340 In a sequence as below, the section below the first matching <code>elif</code>
13161353 </pre>
13171354
13181355 </dd>
1319 <dt class="pubdef"><a name="else/0">:- <strong>else</strong></a></dt>
1356 <dt class="pubdef"><a id="else/0">:- <strong>else</strong></a></dt>
13201357 <dd class="defbody">
13211358 Start `else' branch.</dd>
1322 <dt class="pubdef"><a name="endif/0">:- <strong>endif</strong></a></dt>
1359 <dt class="pubdef"><a id="endif/0">:- <strong>endif</strong></a></dt>
13231360 <dd class="defbody">
13241361 End of conditional compilation.
13251362 </dd>
13261363 </dl>
13271364
1328 <p><h3 id="sec:loadrunningcode"><a name="sec:4.3.2"><span class="sec-nr">4.3.2</span> <span class="sec-title">Reloading
1365 <p><h3 id="sec:loadrunningcode"><a id="sec:4.3.2"><span class="sec-nr">4.3.2</span> <span class="sec-title">Reloading
13291366 files, active code and threads</span></a></h3>
13301367
1331 <a name="sec:loadrunningcode"></a>
1368 <a id="sec:loadrunningcode"></a>
13321369
13331370 <p>Traditionally, Prolog environments allow for reloading files holding
13341371 currently active code. In particular, the following sequence is a valid
13391376 <li>Trace a goal
13401377 <li>Find unexpected behaviour of a predicate
13411378 <li>Enter a <em>break</em> using the <b>b</b> command
1342 <li>Fix the sources and reload them using <a name="idx:make0:556"></a><a class="pred" href="consulting.html#make/0">make/0</a>
1379 <li>Fix the sources and reload them using <a id="idx:make0:556"></a><a class="pred" href="consulting.html#make/0">make/0</a>
13431380 <li>Exit the break, <em>retry</em> executing the now fixed predicate
13441381 using the <b>r</b> command
13451382 </ul>
13491386 <em>thread</em>. Executing threads switch atomically to the new
13501387 definition of modified predicates, while clauses that belong to the old
13511388 definition are (eventually) reclaimed by
1352 <a name="idx:garbagecollectclauses0:557"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.<sup class="fn">50<span class="fn-text">As
1389 <a id="idx:garbagecollectclauses0:557"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.<sup class="fn">50<span class="fn-text">As
13531390 of version 7.3.12. Older versions wipe all clauses originating from the
13541391 file before loading the new clauses. This causes threads that executes
13551392 the code to (typically) die with an <em>undefined predicate</em>
13881425 after the file completes loading. Currently, <code>dynamic</code> and
13891426 <code>thread_local</code> are applied immediately.
13901427 <li>New modules are recorded in the reload context. Export declarations
1391 (the module's public list and <a name="idx:export1:558"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
1428 (the module's public list and <a id="idx:export1:558"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
13921429 calls) are both applied and recorded.
13931430 <li>When the end-of-file is reached, the following fixup steps are taken
13941431 <ol class="latex">
14001437 by changing their `erased' or `created'
14011438 <em>generation</em>. Erased clauses are (eventually) reclaimed by the <em>clause
14021439 garbage collector</em>, see
1403 <a name="idx:garbagecollectclauses0:559"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
1440 <a id="idx:garbagecollectclauses0:559"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
14041441 <li>Pending predicate property changes are applied.
14051442 </ol>
14061443 <li>For each module
14121449 </ol>
14131450
14141451 <p>The above generally ensures that changes to the <em>content</em> of
1415 source files can typically be activated safely using <a name="idx:make0:560"></a><a class="pred" href="consulting.html#make/0">make/0</a>.
1452 source files can typically be activated safely using <a id="idx:make0:560"></a><a class="pred" href="consulting.html#make/0">make/0</a>.
14161453 Global changes such as operator changes, changes of module names,
14171454 changes to multi-file predicates, etc. sometimes require a restart. In
14181455 almost all cases, the need for restart is indicated by permission or
14201457 program.
14211458
14221459 <p>In some cases the content of a source file refers `to itself'. This
1423 is notably the case if local rules for <a name="idx:goalexpansion2:561"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1424 or <a name="idx:termexpansion2:562"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1460 is notably the case if local rules for <a id="idx:goalexpansion2:561"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1461 or <a id="idx:termexpansion2:562"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
14251462 are defined or goals are executed using
1426 <em>directives</em>.<sup class="fn">51<span class="fn-text">Note that <a name="idx:initialization1:563"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1463 <em>directives</em>.<sup class="fn">51<span class="fn-text">Note that <a id="idx:initialization1:563"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
14271464 directives are executed <em>after</em> loading the file. SWI-Prolog
14281465 allows for directives that are executed <em>while</em> loading the file
1429 using <code>:- Goal.</code> or <a name="idx:initialization2:564"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a></span></sup>.
1466 using <code>:- Goal.</code> or <a id="idx:initialization2:564"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a></span></sup>.
14301467 Up to version 7.5.12 it was typically needed to reload the file <em>twice</em>,
14311468 once for updating the code that was used for compiling the remainder of
14321469 the file and once to effectuate this. As of version 7.5.13, conventional <em>transaction
14371474 implemented by Keri Harris.</span></sup>
14381475
14391476 <dl class="latex">
1440 <dt class="pubdef"><a name="garbage_collect_clauses/0"><strong>garbage_collect_clauses</strong></a></dt>
1477 <dt class="pubdef"><a id="garbage_collect_clauses/0"><strong>garbage_collect_clauses</strong></a></dt>
14411478 <dd class="defbody">
14421479 Reclaim retracted clauses. During normal operation, retracting a clause
14431480 implies setting the <em>erased generation</em> to the current
14671504 </dd>
14681505 </dl>
14691506
1470 <p><h4 id="sec:depload"><a name="sec:4.3.2.1"><span class="sec-nr">4.3.2.1</span> <span class="sec-title">Compilation
1507 <p><h4 id="sec:depload"><a id="sec:4.3.2.1"><span class="sec-nr">4.3.2.1</span> <span class="sec-title">Compilation
14711508 of mutually dependent code</span></a></h4>
14721509
1473 <a name="sec:depload"></a>
1510 <a id="sec:depload"></a>
14741511
14751512 <p>Large programs are generally split into multiple files. If file <var>A</var>
14761513 accesses predicates from file <var>B</var> which accesses predicates
14771514 from file
14781515 <var>A</var>, we consider this a mutual or circular dependency. If
1479 traditional load predicates (e.g., <a name="idx:consult1:565"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
1516 traditional load predicates (e.g., <a id="idx:consult1:565"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
14801517 are used to include file <var>B</var> from <var>A</var> and <var>A</var>
14811518 from <var>B</var>, loading either file results in a loop. This is
14821519 because
1483 <a name="idx:consult1:566"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
1484 is mapped to <a name="idx:loadfiles2:567"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
1520 <a id="idx:consult1:566"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
1521 is mapped to <a id="idx:loadfiles2:567"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
14851522 using the option <code>if(true)(if(true))</code> Such programs are
14861523 typically loaded using a <em>load file</em> that consults all required
14871524 (non-module) files. If modules are used, the dependencies are made
1488 explicit using <a name="idx:usemodule1:568"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1525 explicit using <a id="idx:usemodule1:568"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
14891526 statements. The
1490 <a name="idx:usemodule1:569"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1491 predicate, however, maps to <a name="idx:loadfiles2:570"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
1527 <a id="idx:usemodule1:569"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1528 predicate, however, maps to <a id="idx:loadfiles2:570"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
14921529 with the option
1493 <code>if(not_loaded)(if(not_loaded))</code> A <a name="idx:usemodule1:571"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1530 <code>if(not_loaded)(if(not_loaded))</code> A <a id="idx:usemodule1:571"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
14941531 on an already loaded file merely makes the public predicates of the used
14951532 module available.
14961533
14971534 <p>Summarizing, mutual dependency of source files is fully supported
14981535 with no precautions when using modules. Modules can use each other in an
1499 arbitrary dependency graph. When using <a name="idx:consult1:572"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
1536 arbitrary dependency graph. When using <a id="idx:consult1:572"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
15001537 predicate dependencies between loaded files can still be arbitrary, but
15011538 the consult relations between files must be a proper tree.
15021539
1503 <p><h4 id="sec:mtload"><a name="sec:4.3.2.2"><span class="sec-nr">4.3.2.2</span> <span class="sec-title">Compilation
1540 <p><h4 id="sec:mtload"><a id="sec:4.3.2.2"><span class="sec-nr">4.3.2.2</span> <span class="sec-title">Compilation
15041541 with multiple threads</span></a></h4>
15051542
1506 <a name="sec:mtload"></a>
1543 <a id="sec:mtload"></a>
15071544
15081545 <p>This section discusses compiling files for the first time. For
1509 reloading, see <a class="sec" href="consulting.html">section 4.3.2</a>.
1546 reloading, see <a class="sec" href="consulting.html#sec:4.3.2">section
1547 4.3.2</a>.
15101548
15111549 <p>In older versions, compilation was thread-safe due to a global
1512 <em>lock</em> in <a name="idx:loadfiles2:573"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
1550 <em>lock</em> in <a id="idx:loadfiles2:573"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
15131551 and the code dealing with
1514 <em>autoloading</em> (see <a class="sec" href="autoload.html">section
1552 <em>autoloading</em> (see <a class="sec" href="autoload.html#sec:2.13">section
15151553 2.13</a>). Besides unnecessary stalling when multiple threads trap
15161554 unrelated undefined predicates, this easily leads to deadlocks, notably
15171555 if threads are started from an
1518 <a name="idx:initialization1:574"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1556 <a id="idx:initialization1:574"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
15191557 directive.<sup class="fn">54<span class="fn-text">Although such goals
15201558 are started after loading the file in which they appear, the calling
15211559 thread is still likely to hold the `load' lock because it is compiling
15241562 <p>Starting with version 5.11.27, the autoloader is no longer locked and
15251563 multiple threads can compile files concurrently. This requires special
15261564 precautions only if multiple threads wish to load the same file at the
1527 same time. Therefore, <a name="idx:loadfiles2:575"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
1565 same time. Therefore, <a id="idx:loadfiles2:575"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
15281566 checks automatically whether some other thread is already loading the
15291567 file. If not, it starts loading the file. If another thread is already
15301568 loading the file, the thread blocks until the other thread finishes
15321570 will make the public predicates available.
15331571
15341572 <p>Note that this schema does not prevent deadlocks under all
1535 situations. Consider two mutually dependent (see <a class="sec" href="consulting.html">section
1573 situations. Consider two mutually dependent (see <a class="sec" href="consulting.html#sec:4.3.2.1">section
15361574 4.3.2.1</a>) module files <var>A</var> and <var>B</var>, where thread&nbsp;1
15371575 starts loading <var>A</var> and thread&nbsp;2 starts loading
15381576 <var>B</var> at the same time. Both threads will deadlock when trying to
15421580 involved threads will freeze. This problem can be avoided if a mutually
15431581 dependent collection of files is always loaded from the same start file.
15441582
1545 <p><h3 id="sec:qlf"><a name="sec:4.3.3"><span class="sec-nr">4.3.3</span> <span class="sec-title">Quick
1583 <p><h3 id="sec:qlf"><a id="sec:4.3.3"><span class="sec-nr">4.3.3</span> <span class="sec-title">Quick
15461584 load files</span></a></h3>
15471585
1548 <a name="sec:qlf"></a>
1586 <a id="sec:qlf"></a>
15491587
15501588 <p>SWI-Prolog supports compilation of individual or multiple Prolog
15511589 source files into `Quick Load Files'. A `Quick Load File' (<code>.qlf</code>
15571595 are stored as virtual machine instructions. Changes to the compiler will
15581596 generally make old compiled files unusable.
15591597
1560 <p>Quick Load Files are created using <a name="idx:qcompile1:576"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.
1598 <p>Quick Load Files are created using <a id="idx:qcompile1:576"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.
15611599 They are loaded using
1562 <a name="idx:consult1:577"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
1600 <a id="idx:consult1:577"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
15631601 or one of the other file-loading predicates described in
1564 <a class="sec" href="consulting.html">section 4.3</a>. If <a name="idx:consult1:578"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
1602 <a class="sec" href="consulting.html#sec:4.3">section 4.3</a>. If <a id="idx:consult1:578"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
15651603 is given an explicit <code>.pl</code> file, it will load the Prolog
15661604 source. When given a <code>.qlf</code> file, it will load the file. When
15671605 no extension is specified, it will load the
15691607 otherwise.
15701608
15711609 <dl class="latex">
1572 <dt class="pubdef"><a name="qcompile/1"><strong>qcompile</strong>(<var>:File</var>)</a></dt>
1573 <dd class="defbody">
1574 Takes a file specification as <a name="idx:consult1:579"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
1610 <dt class="pubdef"><a id="qcompile/1"><strong>qcompile</strong>(<var>:File</var>)</a></dt>
1611 <dd class="defbody">
1612 Takes a file specification as <a id="idx:consult1:579"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
15751613 etc., and, in addition to the normal compilation, creates a <em>Quick
15761614 Load File</em> from <var>File</var>. The file extension of this file is <code>.qlf</code>.
15771615 The basename of the Quick Load File is the same as the input file.
15851623 the
15861624 <code>.pl</code> file.
15871625
1588 <p>For <a name="idx:termexpansion2:580"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>,
1626 <p>For <a id="idx:termexpansion2:580"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>,
15891627 the same rules as described in
1590 <a class="sec" href="compilation.html">section 2.10</a> apply.
1628 <a class="sec" href="compilation.html#sec:2.10">section 2.10</a> apply.
15911629
15921630 <p>Conditional execution or optimisation may test the predicate
1593 <a name="idx:compiling0:581"></a><a class="pred" href="consulting.html#compiling/0">compiling/0</a>.
1594
1595 <p>Source references (<a name="idx:sourcefile2:582"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>)
1631 <a id="idx:compiling0:581"></a><a class="pred" href="consulting.html#compiling/0">compiling/0</a>.
1632
1633 <p>Source references (<a id="idx:sourcefile2:582"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>)
15961634 in the Quick Load File refer to the Prolog source file from which the
15971635 compiled code originates.</dd>
1598 <dt class="pubdef"><a name="qcompile/2"><strong>qcompile</strong>(<var>:File,
1636 <dt class="pubdef"><a id="qcompile/2"><strong>qcompile</strong>(<var>:File,
15991637 +Options</var>)</a></dt>
16001638 <dd class="defbody">
1601 As <a name="idx:qcompile1:583"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
1639 As <a id="idx:qcompile1:583"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
16021640 but processes additional options as defined by
1603 <a name="idx:loadfiles2:584"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.<sup class="fn">bug<span class="fn-text">Option
1641 <a id="idx:loadfiles2:584"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.<sup class="fn">bug<span class="fn-text">Option
16041642 processing is currently incomplete.</span></sup>
16051643 </dd>
16061644 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section E.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section E.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="license.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="softlicense.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:contrib"><a name="sec:E.1"><span class="sec-nr">E.1</span> <span class="sec-title">Contributing
235 <h2 id="sec:contrib"><a id="sec:E.1"><span class="sec-nr">E.1</span> <span class="sec-title">Contributing
195236 to the SWI-Prolog project</span></a></h2>
196237
197 <a name="sec:contrib"></a>
238 <a id="sec:contrib"></a>
198239
199240 <p>To reach maximal coherence we will, as a rule of thumb, only accept
200241 new code that has the Simplified BSD license and existing code with a
201242 <em>permissive</em> license such as MIT, Apache, BSD-3, etc. In
202243 exceptional cases we may accept code with GPL or LGPL conditions. Such
203 code must be tagged using a <a name="idx:license1:2339"></a><a class="pred" href="softlicense.html#license/1">license/1</a>
244 code must be tagged using a <a id="idx:license1:2343"></a><a class="pred" href="softlicense.html#license/1">license/1</a>
204245 directive (Prolog) or a call to
205246 <a class="func" href="softlicense.html#PL_license()">PL_license()</a>
206247 for foreign code and, if they are part of the core, the code must be
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="compare.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="metacall.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:control"><a name="sec:4.8"><span class="sec-nr">4.8</span> <span class="sec-title">Control
235 <h2 id="sec:control"><a id="sec:4.8"><span class="sec-nr">4.8</span> <span class="sec-title">Control
195236 Predicates</span></a></h2>
196237
197 <a name="sec:control"></a>
238 <a id="sec:control"></a>
198239
199240 <p>The predicates of this section implement control structures. Normally
200 the constructs in this section, except for <a name="idx:repeat0:642"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>,
241 the constructs in this section, except for <a id="idx:repeat0:642"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>,
201242 are translated by the compiler. Please note that complex goals passed as
202 arguments to meta-predicates such as <a name="idx:findall3:643"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
243 arguments to meta-predicates such as <a id="idx:findall3:643"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
203244 below cause the goal to be compiled to a temporary location before
204245 execution. It is faster to define a sub-predicate (i.e. one_character_atoms/1
205246 in the example below) and make a call to this simple predicate.
210251 </pre>
211252
212253 <dl class="latex">
213 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="fail/0"><strong>fail</strong></a></dt>
214 <dd class="defbody">
215 Always fail. The predicate <a name="idx:fail0:644"></a><a class="pred" href="control.html#fail/0">fail/0</a>
254 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="fail/0"><strong>fail</strong></a></dt>
255 <dd class="defbody">
256 Always fail. The predicate <a id="idx:fail0:644"></a><a class="pred" href="control.html#fail/0">fail/0</a>
216257 is translated into a single virtual machine instruction.
217258 </dd>
218 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="false/0"><strong>false</strong></a></dt>
259 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="false/0"><strong>false</strong></a></dt>
219260 <dd class="defbody">
220261 Same as fail, but the name has a more declarative connotation.
221262 </dd>
222 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="true/0"><strong>true</strong></a></dt>
223 <dd class="defbody">
224 Always succeed. The predicate <a name="idx:true0:645"></a><a class="pred" href="control.html#true/0">true/0</a>
263 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="true/0"><strong>true</strong></a></dt>
264 <dd class="defbody">
265 Always succeed. The predicate <a id="idx:true0:645"></a><a class="pred" href="control.html#true/0">true/0</a>
225266 is translated into a single virtual machine instruction.
226267 </dd>
227 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="repeat/0"><strong>repeat</strong></a></dt>
268 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="repeat/0"><strong>repeat</strong></a></dt>
228269 <dd class="defbody">
229270 Always succeed, provide an infinite number of choice points.</dd>
230 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="!/0"><strong>!</strong></a></dt>
271 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="!/0"><strong>!</strong></a></dt>
231272 <dd class="defbody">
232273 Cut. Discard all choice points created since entering the predicate in
233274 which the cut appears. In other words, <em>commit</em> to the clause in
234275 which the cut appears <em>and</em> discard choice points that have been
235276 created by goals to the left of the cut in the current clause. Meta
236277 calling is opaque to the cut. This implies that cuts that appear in a
237 term that is subject to meta-calling (<a name="idx:call1:646"></a><a class="pred" href="metacall.html#call/1">call/1</a>)
278 term that is subject to meta-calling (<a id="idx:call1:646"></a><a class="pred" href="metacall.html#call/1">call/1</a>)
238279 only affect choice points created by the meta-called term. The following
239 control structures are transparent to the cut: <a class="pred" href="control.html#;/2">;/2</a>, <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a>
280 control structures are transparent to the cut: <a class="pred" href="control.html#;/2">;/2</a>, <a class="pred" href="control.html#->/2">-&gt;/2</a>
240281 and
241282 <a class="pred" href="control.html#*->/2">*-&gt;/2</a>. Cuts appearing
242283 in the <em>condition</em> part of
243 <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a> and <a class="pred" href="control.html#*->/2">*-&gt;/2</a>
284 <a class="pred" href="control.html#->/2">-&gt;/2</a> and <a class="pred" href="control.html#*->/2">*-&gt;/2</a>
244285 are opaque to the cut. The table below explains the scope of the cut
245286 with examples. <i>Prunes</i> here means ``prunes <var>X</var> choice
246287 point created by <var>X</var>''.
247 <div style="text-align:center"><table border="0" frame="void" rules="groups">
248 <tr valign="top"><td><code>t0 :- (a, !, b).</code> </td><td>% prunes a/0
249 and t0/0 </td></tr>
250 <tr valign="top"><td><code>t1 :- (a, !, fail ; b).</code> </td><td>%
251 prunes a/0 and t1/0 </td></tr>
252 <tr valign="top"><td><code>t2 :- (a -&gt; b, ! ; c).</code> </td><td>%
253 prunes b/0 and t2/0 </td></tr>
254 <tr valign="top"><td><code>t3 :- call((a, !, fail ; b)).</code> </td><td>%
255 prunes a/0 </td></tr>
256 <tr valign="top"><td><code>t4 :- <code>\+</code>(a, !, fail).</code> </td><td>%
288
289 <p><table class="latex frame-void center">
290 <tr><td><code>t0 :- (a, !, b).</code> </td><td>% prunes a/0 and t0/0 </td></tr>
291 <tr><td><code>t1 :- (a, !, fail ; b).</code> </td><td>% prunes a/0 and t1/0 </td></tr>
292 <tr><td><code>t2 :- (a -&gt; b, ! ; c).</code> </td><td>% prunes b/0 and t2/0 </td></tr>
293 <tr><td><code>t3 :- call((a, !, fail ; b)).</code> </td><td>% prunes a/0 </td></tr>
294 <tr><td><code>t4 :- <code>\+</code>(a, !, fail).</code> </td><td>%
257295 prunes a/0 </td></tr>
258296 </table>
259 </div>
260 </dd>
261 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name=",/2"><var>:Goal1</var> <strong>,</strong> <var>:Goal2</var></a></dt>
297 </dd>
298 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id=",/2"><var>:Goal1</var> <strong>,</strong> <var>:Goal2</var></a></dt>
262299 <dd class="defbody">
263300 Conjunction. True if both `Goal1' and `Goal2' can be proved. It is
264301 defined as follows (this definition does not lead to a loop as the
269306 </pre>
270307
271308 </dd>
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name=";/2"><var>:Goal1</var> <strong>;</strong> <var>:Goal2</var></a></dt>
309 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id=";/2"><var>:Goal1</var> <strong>;</strong> <var>:Goal2</var></a></dt>
273310 <dd class="defbody">
274311 The `or' predicate is defined as:
275312
279316 </pre>
280317
281318 </dd>
282 <dt class="pubdef"><a name="|/2"><var>:Goal1</var> <strong>|</strong> <var>:Goal2</var></a></dt>
319 <dt class="pubdef"><a id="|/2"><var>:Goal1</var> <strong>|</strong> <var>:Goal2</var></a></dt>
283320 <dd class="defbody">
284321 Equivalent to <a class="pred" href="control.html#;/2">;/2</a>. Retained
285322 for compatibility only. New code should use <a class="pred" href="control.html#;/2">;/2</a>.</dd>
286 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="send_arrow/2"><var>:Condition</var> <strong>-&gt;</strong> <var>:Action</var></a></dt>
287 <dd class="defbody">
288 If-then and If-Then-Else. The <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a>
323 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="->/2"><var>:Condition</var> <strong>-&gt;</strong> <var>:Action</var></a></dt>
324 <dd class="defbody">
325 If-then and If-Then-Else. The <a class="pred" href="control.html#->/2">-&gt;/2</a>
289326 construct commits to the choices made at its left-hand side, destroying
290327 choice points created inside the clause (by <a class="pred" href="control.html#;/2">;/2</a>),
291328 or by goals called by this clause. Unlike <a class="pred" href="control.html#!/0">!/0</a>,
292329 the choice point of the predicate as a whole (due to multiple clauses)
293330 is <strong>not</strong> destroyed. The combination <a class="pred" href="control.html#;/2">;/2</a>
294 and <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a> acts as
295 if defined as:
331 and <a class="pred" href="control.html#->/2">-&gt;/2</a> acts as if
332 defined as:
296333
297334 <pre class="code">
298335 If -&gt; Then; _Else :- If, !, Then.
310347 and that the <em>combined</em> semantics of this syntactic construct as
311348 defined above is <em>different</em> from the simple nesting of the two
312349 individual constructs, i.e., the semantics of
313 <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a> <em>changes</em>
350 <a class="pred" href="control.html#->/2">-&gt;/2</a> <em>changes</em>
314351 when embedded in <a class="pred" href="control.html#;/2">;/2</a>. See
315352 also
316 <a name="idx:once1:647"></a><a class="pred" href="metacall.html#once/1">once/1</a>.</dd>
317 <dt class="pubdef"><a name="*->/2"><var>:Condition</var> <strong>*-&gt;</strong> <var>:Action
353 <a id="idx:once1:647"></a><a class="pred" href="metacall.html#once/1">once/1</a>.</dd>
354 <dt class="pubdef"><a id="*->/2"><var>:Condition</var> <strong>*-&gt;</strong> <var>:Action
318355 ; :Else</var></a></dt>
319356 <dd class="defbody">
320357 This construct implements the so-called `soft-cut'. The control is
331368 without an
332369 <var>Else</var> branch, is translated as the normal conjunction <var>A</var>,
333370 <var>B</var>.<sup class="fn">bug<span class="fn-text">The decompiler
334 implemented by <a name="idx:clause2:648"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
371 implemented by <a id="idx:clause2:648"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
335372 returns this construct as a normal conjunction too.</span></sup>
336373
337374 <p>This construct is rarely used. An example use case is the
352389 solutions
353390 <var>X=a</var> and <var>X=b</var>, while <code>optional(member(X,[]))</code>
354391 succeeds without binding <var>X</var>.</dd>
355 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="\+/1"><strong>\+</strong> <var>:Goal</var></a></dt>
392 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="\+/1"><strong>\+</strong> <var>:Goal</var></a></dt>
356393 <dd class="defbody">
357394 True if `Goal' cannot be proven (mnemonic: <code><code>+</code></code>
358395 refers to <em>provable</em> and the backslash (<code><code>\</code></code>)
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 7.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 7.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="attvar.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="chr.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:coroutining"><a name="sec:7.2"><span class="sec-nr">7.2</span> <span class="sec-title">Coroutining</span></a></h2>
195
196 <a name="sec:coroutining"></a>
235 <h2 id="sec:coroutining"><a id="sec:7.2"><span class="sec-nr">7.2</span> <span class="sec-title">Coroutining</span></a></h2>
236
237 <a id="sec:coroutining"></a>
197238
198239 <p>Coroutining allows us to delay the execution of Prolog goals until
199240 their truth can be safely decided.
200241
201 <p>Among the most important coroutining predicates is <a name="idx:dif2:1793"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>,
242 <p>Among the most important coroutining predicates is <a id="idx:dif2:1797"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>,
202243 which expresses <i>disequality</i> of terms in a sound way. The actual
203244 test is delayed until the terms are sufficiently different, or have
204245 become identical. For example:
214255
215256 <p>There are also lower-level coroutining predicates that are intended
216257 as building blocks for higher-level constraints. For example, we can use
217 <a name="idx:freeze2:1794"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
258 <a id="idx:freeze2:1798"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
218259 to define a variable that can only be assigned an atom:
219260
220261 <pre class="code">
222263 X = a.
223264 </pre>
224265
225 <p>In this case, calling <a name="idx:atom1:1795"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>
266 <p>In this case, calling <a id="idx:atom1:1799"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>
226267 earlier causes the whole query to fail:
227268
228269 <pre class="code">
249290 </pre>
250291
251292 <p>Remaining constraints, such as <code>X mod 2#=0</code> in the example
252 above, are called <em>residual</em><a name="idx:residual:1796"></a>
253 goals. They are said to
254 <em>flounder</em><a name="idx:flounder:1797"></a>, because their truth
255 is not yet decided. Declaratively, the query is only true if all
256 residual goals are satisfiable. Use <a name="idx:callresiduevars2:1798"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
293 above, are called <em>residual</em><a id="idx:residual:1800"></a> goals.
294 They are said to
295 <em>flounder</em><a id="idx:flounder:1801"></a>, because their truth is
296 not yet decided. Declaratively, the query is only true if all residual
297 goals are satisfiable. Use <a id="idx:callresiduevars2:1802"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
257298 to collect all variables that are involved in constraints.
258299
259300 <dl class="latex">
260 <dt class="pubdef"><a name="dif/2"><strong>dif</strong>(<var>@A, @B</var>)</a></dt>
261 <dd class="defbody">
262 The <a name="idx:dif2:1799"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
301 <dt class="pubdef"><a id="dif/2"><strong>dif</strong>(<var>@A, @B</var>)</a></dt>
302 <dd class="defbody">
303 The <a id="idx:dif2:1803"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
263304 predicate is a <i>constraint</i> that is true if and only if <var>A</var>
264305 and <var>B</var> are different terms. If <var>A</var> and <var>B</var>
265 can never unify, <a name="idx:dif2:1800"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
306 can never unify, <a id="idx:dif2:1804"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
266307 succeeds deterministically. If <var>A</var> and <var>B</var> are
267308 identical, it fails immediately. Finally, if <var>A</var> and <var>B</var>
268309 can unify, goals are delayed that prevent <var>A</var> and <var>B</var>
269 to become equal. It is this last property that makes <a name="idx:dif2:1801"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
310 to become equal. It is this last property that makes <a id="idx:dif2:1805"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
270311 a more general and more declarative alternative for <a class="pred" href="compare.html#\=/2">\=/2</a>
271312 and related predicates.
272313
274315 <code>dif(X, Y) :- when(?=(X,Y), X \== Y)</code>. See also <a class="pred" href="compare.html#?=/2">?=/2</a>.
275316 The implementation can deal with cyclic terms.
276317
277 <p>The <a name="idx:dif2:1802"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
318 <p>The <a id="idx:dif2:1806"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
278319 predicate is realised using attributed variables associated with the
279320 module <code>dif</code>. It is an autoloaded predicate that is defined
280321 in the library <code>library(dif)</code>.</dd>
281 <dt class="pubdef"><a name="freeze/2"><strong>freeze</strong>(<var>+Var,
322 <dt class="pubdef"><a id="freeze/2"><strong>freeze</strong>(<var>+Var,
282323 :Goal</var>)</a></dt>
283324 <dd class="defbody">
284325 Delay the execution of <var>Goal</var> until <var>Var</var> is bound
285326 (i.e. is not a variable or attributed variable). If <var>Var</var> is
286327 bound on entry
287 <a name="idx:freeze2:1803"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
288 is equivalent to <a name="idx:call1:1804"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
289 The <a name="idx:freeze2:1805"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
328 <a id="idx:freeze2:1807"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
329 is equivalent to <a id="idx:call1:1808"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
330 The <a id="idx:freeze2:1809"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
290331 predicate is realised using an attributed variable associated with the
291332 module <code>freeze</code>. Use <code>frozen(Var, Goal)</code> to find
292333 out whether and which goals are delayed on <var>Var</var>.</dd>
293 <dt class="pubdef"><a name="frozen/2"><strong>frozen</strong>(<var>@Var,
334 <dt class="pubdef"><a id="frozen/2"><strong>frozen</strong>(<var>@Var,
294335 -Goal</var>)</a></dt>
295336 <dd class="defbody">
296337 Unify <var>Goal</var> with the goal or conjunction of goals delayed on
297338 <var>Var</var>. If no goals are frozen on <var>Var</var>, <var>Goal</var>
298339 is unified to <code>true</code>.</dd>
299 <dt class="pubdef"><a name="when/2"><strong>when</strong>(<var>@Condition,
340 <dt class="pubdef"><a id="when/2"><strong>when</strong>(<var>@Condition,
300341 :Goal</var>)</a></dt>
301342 <dd class="defbody">
302343 Execute <var>Goal</var> when <var>Condition</var> becomes true. <var>Condition</var>
303344 is one of <code>?=(X, Y)</code>, <code>nonvar(X)</code>, <code>ground(X)</code>,
304345 <code><code>,</code>(Cond1, Cond2)</code> or <code><code>;</code>(Cond1,
305 Cond2)</code>. See also <a name="idx:freeze2:1806"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
306 and <a name="idx:dif2:1807"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>.
346 Cond2)</code>. See also <a id="idx:freeze2:1810"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
347 and <a id="idx:dif2:1811"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>.
307348 The implementation can deal with cyclic terms in <var>X</var> and <var>Y</var>.
308349
309 <p>The <a name="idx:when2:1808"></a><a class="pred" href="coroutining.html#when/2">when/2</a>
350 <p>The <a id="idx:when2:1812"></a><a class="pred" href="coroutining.html#when/2">when/2</a>
310351 predicate is realised using attributed variables associated with the
311352 module <code>when</code>. It is defined in the autoload library
312353 <code>library(when)</code>.</dd>
313 <dt class="pubdef"><a name="call_residue_vars/2"><strong>call_residue_vars</strong>(<var>:Goal,
354 <dt class="pubdef"><a id="call_residue_vars/2"><strong>call_residue_vars</strong>(<var>:Goal,
314355 -Vars</var>)</a></dt>
315356 <dd class="defbody">
316357 Find residual attributed variables left by <var>Goal</var>. This
323364 because the constraint solver is too weak to detect the contradiction.
324365 Ideally, delayed goals and constraints are all executed at the end of
325366 the computation. The meta predicate
326 <a name="idx:callresiduevars2:1809"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
367 <a id="idx:callresiduevars2:1813"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
327368 finds variables that are given attributes or whose attributes are
328369 modified by <var>Goal</var>, regardless of whether or not these
329370 variables are reachable from the arguments of
330 <var>Goal</var>.<sup class="fn">153<span class="fn-text">The
331 implementation of <a name="idx:callresiduevars2:1810"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
371 <var>Goal</var>.<sup class="fn">154<span class="fn-text">The
372 implementation of <a id="idx:callresiduevars2:1814"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
332373 is completely redone in version 7.3.2 (7.2.1) after discussion with Bart
333374 Demoen. The current implementation no longer performs full scans of the
334375 stacks. The overhead is proportional to the number of attributed
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.10</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="clpqr.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="debug.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:csv"><a name="sec:A.10"><span class="sec-nr">A.10</span> <span class="sec-title">library(csv):
235 <h2 id="sec:csv"><a id="sec:A.10"><span class="sec-nr">A.10</span> <span class="sec-title">library(csv):
195236 Process CSV (Comma-Separated Values) data</span></a></h2>
196237
197 <p><a name="sec:csv"></a>
238 <p><a id="sec:csv"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">See also</dt>
214255 have the same name and arity.
215256
216257 <dl class="latex">
217 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_read_file/2"><strong>csv_read_file</strong>(<var>+File,
258 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_read_file/2"><strong>csv_read_file</strong>(<var>+File,
218259 -Rows</var>)</a></dt>
219 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_read_file/3"><strong>csv_read_file</strong>(<var>+File,
260 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_read_file/3"><strong>csv_read_file</strong>(<var>+File,
220261 -Rows, +Options</var>)</a></dt>
221262 <dd class="defbody">
222263 Read a CSV file into a list of rows. Each row is a Prolog term with the
223 same arity. <var>Options</var> is handed to <span class="pred-ext">csv/4</span>.
264 same arity. <var>Options</var> is handed to <a class="pred" href="csv.html#csv//2">csv//2</a>.
224265 Remaining options are processed by <a class="pred" href="pio.html#phrase_from_file/3">phrase_from_file/3</a>.
225266 The default separator depends on the file name extension and is <code>\t</code>
226267 for
238279 </pre>
239280
240281 </dd>
241 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv/1"><strong>csv</strong>(<var>?Rows</var>)</a><code>//</code></dt>
242 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv/2"><strong>csv</strong>(<var>?Rows,
282 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv//1"><strong>csv</strong>(<var>?Rows</var>)</a><code>//</code></dt>
283 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv//2"><strong>csv</strong>(<var>?Rows,
243284 +Options</var>)</a><code>//</code></dt>
244285 <dd class="defbody">
245286 Prolog DCG to `read/write' CSV data. <var>Options</var>:
289330 </dl>
290331
291332 </dd>
292 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="csv_read_file_row/3"><strong>csv_read_file_row</strong>(<var>+File,
333 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="csv_read_file_row/3"><strong>csv_read_file_row</strong>(<var>+File,
293334 -Row, +Options</var>)</a></dt>
294335 <dd class="defbody">
295336 True when <var>Row</var> is a row in <var>File</var>. First unifies <var>Row</var>
322363 </dl>
323364
324365 </dd>
325 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_read_row/3"><strong>csv_read_row</strong>(<var>+Stream,
366 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_read_row/3"><strong>csv_read_row</strong>(<var>+Stream,
326367 -Row, +CompiledOptions</var>)</a></dt>
327368 <dd class="defbody">
328369 Read the next CSV record from <var>Stream</var> and unify the result
329370 with <var>Row</var>.
330 <var>CompiledOptions</var> is created from options defined for <span class="pred-ext">csv/4</span>
371 <var>CompiledOptions</var> is created from options defined for <a class="pred" href="csv.html#csv//2">csv//2</a>
331372 using
332373 <a class="pred" href="csv.html#csv_options/2">csv_options/2</a>. <var>Row</var>
333374 is unified with <code>end_of_file</code> upon reaching the end of the
334375 input.</dd>
335 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_options/2"><strong>csv_options</strong>(<var>-Compiled,
376 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_options/2"><strong>csv_options</strong>(<var>-Compiled,
336377 +Options</var>)</a></dt>
337378 <dd class="defbody">
338379 <var>Compiled</var> is the compiled representation of the CSV processing
339 options as they may be passed into <span class="pred-ext">csv/4</span>,
380 options as they may be passed into <a class="pred" href="csv.html#csv//2">csv//2</a>,
340381 etc. This predicate is used in combination with <a class="pred" href="csv.html#csv_read_row/3">csv_read_row/3</a>
341382 to avoid repeated processing of the options.</dd>
342 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_write_file/2"><strong>csv_write_file</strong>(<var>+File,
383 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_write_file/2"><strong>csv_write_file</strong>(<var>+File,
343384 +Data</var>)</a></dt>
344 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_write_file/3"><strong>csv_write_file</strong>(<var>+File,
385 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_write_file/3"><strong>csv_write_file</strong>(<var>+File,
345386 +Data, +Options</var>)</a></dt>
346387 <dd class="defbody">
347388 Write a list of Prolog terms to a CSV file. <var>Options</var> are given
348 to <span class="pred-ext">csv/4</span>. Remaining options are given to <a class="pred" href="IO.html#open/4">open/4</a>.
349 The default separator depends on the file name extension and is <code>\t</code>
389 to <a class="pred" href="csv.html#csv//2">csv//2</a>. Remaining options
390 are given to <a class="pred" href="IO.html#open/4">open/4</a>. The
391 default separator depends on the file name extension and is <code>\t</code>
350392 for
351393 <code>.tsv</code> files and <code>,</code> otherwise.</dd>
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_write_stream/3"><strong>csv_write_stream</strong>(<var>+Stream,
394 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_write_stream/3"><strong>csv_write_stream</strong>(<var>+Stream,
353395 +Data, +Options</var>)</a></dt>
354396 <dd class="defbody">
355397 Write the rows in <var>Data</var> to <var>Stream</var>. This is similar
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.13</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="dynamic-modules.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="manipmodule.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ctxmodule"><a name="sec:6.13"><span class="sec-nr">6.13</span> <span class="sec-title">Transparent
235 <h2 id="sec:ctxmodule"><a id="sec:6.13"><span class="sec-nr">6.13</span> <span class="sec-title">Transparent
195236 predicates: definition and context module</span></a></h2>
196237
197 <a name="sec:ctxmodule"></a>
238 <a id="sec:ctxmodule"></a>
198239
199240 <p><i>The `module-transparent' mechanism is still underlying the actual
200 implementation. Direct usage by programmers is deprecated. Please use <a name="idx:metapredicate1:1736"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
241 implementation. Direct usage by programmers is deprecated. Please use <a id="idx:metapredicate1:1740"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
201242 to deal with meta-predicates.</i>
202243
203 <p>The qualification of module-sensitive arguments described in <a class="sec" href="metapred.html">section
244 <p>The qualification of module-sensitive arguments described in <a class="sec" href="metapred.html#sec:6.4">section
204245 6.4</a> is realised using <em>transparent</em> predicates. It is now
205246 deprecated to use this mechanism directly. However, studying the
206247 underlying mechanism helps to understand SWI-Prolog's modules. In some
217258 default, the context module is the definition module of the predicate
218259 running the goal. For transparent predicates, however, this is the
219260 context module of the goal inherited from the parent goal. Below, we
220 implement <a name="idx:maplist3:1737"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
261 implement <a id="idx:maplist3:1741"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
221262 using the transparent mechanism. The code of
222 <a name="idx:maplist3:1738"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
223 and <a name="idx:maplist3:1739"></a><span class="pred-ext">maplist_/3</span>
224 is the same as in <a class="sec" href="metapred.html">section 6.4</a>,
225 but now we must declare both the main predicate and the helper as
226 transparent to avoid changing the context module when calling the
263 <a id="idx:maplist3:1742"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
264 and <a id="idx:maplist3:1743"></a><span class="pred-ext">maplist_/3</span>
265 is the same as in <a class="sec" href="metapred.html#sec:6.4">section
266 6.4</a>, but now we must declare both the main predicate and the helper
267 as transparent to avoid changing the context module when calling the
227268 helper.
228269
229270 <pre class="code">
247288 module-sensitive arguments. For example, the module below counts the
248289 number of unique atoms returned as bindings for a variable. It works as
249290 expected. If we use the directive
250 <code>:- module_transparent <a name="idx:countatomresults3:1740"></a><span class="pred-ext">count_atom_results/3</span>.</code>
291 <code>:- module_transparent <a id="idx:countatomresults3:1744"></a><span class="pred-ext">count_atom_results/3</span>.</code>
251292 instead,
252 <a name="idx:atomresult2:1741"></a><span class="pred-ext">atom_result/2</span>
293 <a id="idx:atomresult2:1745"></a><span class="pred-ext">atom_result/2</span>
253294 is called wrongly in the module <em>calling</em>
254 <a name="idx:countatomresults3:1742"></a><span class="pred-ext">count_atom_results/3</span>.
255 This can be solved using <a name="idx:stripmodule3:1743"></a><a class="pred" href="ctxmodule.html#strip_module/3">strip_module/3</a>
295 <a id="idx:countatomresults3:1746"></a><span class="pred-ext">count_atom_results/3</span>.
296 This can be solved using <a id="idx:stripmodule3:1747"></a><a class="pred" href="ctxmodule.html#strip_module/3">strip_module/3</a>
256297 to create a qualified goal and a non-transparent helper predicate that
257298 is defined in the same module.
258299
275316 <p>The following predicates support the module-transparent interface:
276317
277318 <dl class="latex">
278 <dt class="pubdef"><a name="module_transparent/1">:- <strong>module_transparent</strong>(<var>+Preds</var>)</a></dt>
319 <dt class="pubdef"><a id="module_transparent/1">:- <strong>module_transparent</strong>(<var>+Preds</var>)</a></dt>
279320 <dd class="defbody">
280321 <var>Preds</var> is a comma-separated list of name/arity pairs (like
281 <a name="idx:dynamic1:1744"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>).
322 <a id="idx:dynamic1:1748"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>).
282323 Each goal associated with a transparent-declared predicate will inherit
283324 the <em>context module</em> from its parent goal.</dd>
284 <dt class="pubdef"><a name="context_module/1"><strong>context_module</strong>(<var>-Module</var>)</a></dt>
325 <dt class="pubdef"><a id="context_module/1"><strong>context_module</strong>(<var>-Module</var>)</a></dt>
285326 <dd class="defbody">
286327 Unify <var>Module</var> with the context module of the current goal.
287 <a name="idx:contextmodule1:1745"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
328 <a id="idx:contextmodule1:1749"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
288329 itself is, of course, transparent.</dd>
289 <dt class="pubdef"><a name="strip_module/3"><strong>strip_module</strong>(<var>+Term,
330 <dt class="pubdef"><a id="strip_module/3"><strong>strip_module</strong>(<var>+Term,
290331 -Module, -Plain</var>)</a></dt>
291332 <dd class="defbody">
292333 Used in module-transparent predicates or meta-predicates to extract the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.17</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.17</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="syntax.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="jitindex.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:cyclic"><a name="sec:2.17"><span class="sec-nr">2.17</span> <span class="sec-title">Rational
235 <h2 id="sec:cyclic"><a id="sec:2.17"><span class="sec-nr">2.17</span> <span class="sec-title">Rational
195236 trees (cyclic terms)</span></a></h2>
196237
197 <a name="sec:cyclic"></a>
198
199 <p><a name="idx:rationaltrees:228"></a><a name="idx:infinitetrees:229"></a><a name="idx:cyclicterms:230"></a><a name="idx:termscyclic:231"></a>SWI-Prolog
238 <a id="sec:cyclic"></a>
239
240 <p><a id="idx:rationaltrees:228"></a><a id="idx:infinitetrees:229"></a><a id="idx:cyclicterms:230"></a><a id="idx:termscyclic:231"></a>SWI-Prolog
200241 supports rational trees, also known as cyclic terms. `Supports' is so
201242 defined that most relevant built-in predicates terminate when faced with
202243 rational trees. Almost all SWI-Prolog's built-in term manipulation
214255 <a class="pred" href="compare.html#\==/2">\==/2</a>,
215256 <a class="pred" href="compare.html#\=@=/2">\=@=/2</a>,
216257 <a class="pred" href="compare.html#\=/2">\=/2</a>,
217 <a name="idx:acyclicterm1:232"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>,
218 <a name="idx:bagof3:233"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
219 <a name="idx:compare3:234"></a><a class="pred" href="compare.html#compare/3">compare/3</a>,
220 <a name="idx:copyterm2:235"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
221 <a name="idx:cyclicterm1:236"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>,
222 <a name="idx:dif2:237"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>,
223 <a name="idx:duplicateterm2:238"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>,
224 <a name="idx:findall3:239"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
225 <a name="idx:ground1:240"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>,
226 <a name="idx:termhash2:241"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>,
227 <a name="idx:numbervars3:242"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>,
228 <a name="idx:numbervars4:243"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>,
229 <a name="idx:recorda3:244"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
230 <a name="idx:recordz3:245"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>,
231 <a name="idx:setof3:246"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>,
232 <a name="idx:subsumesterm2:247"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>,
233 <a name="idx:termvariables2:248"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>,
234 <a name="idx:throw1:249"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
235 <a name="idx:unifywithoccurscheck2:250"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>,
236 <a name="idx:unifiable3:251"></a><a class="pred" href="compare.html#unifiable/3">unifiable/3</a>,
237 <a name="idx:when2:252"></a><a class="pred" href="coroutining.html#when/2">when/2</a>,
238 <a name="idx:write1:253"></a><a class="pred" href="termrw.html#write/1">write/1</a>
258 <a id="idx:acyclicterm1:232"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>,
259 <a id="idx:bagof3:233"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
260 <a id="idx:compare3:234"></a><a class="pred" href="compare.html#compare/3">compare/3</a>,
261 <a id="idx:copyterm2:235"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
262 <a id="idx:cyclicterm1:236"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>,
263 <a id="idx:dif2:237"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>,
264 <a id="idx:duplicateterm2:238"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>,
265 <a id="idx:findall3:239"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
266 <a id="idx:ground1:240"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>,
267 <a id="idx:termhash2:241"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>,
268 <a id="idx:numbervars3:242"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>,
269 <a id="idx:numbervars4:243"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>,
270 <a id="idx:recorda3:244"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
271 <a id="idx:recordz3:245"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>,
272 <a id="idx:setof3:246"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>,
273 <a id="idx:subsumesterm2:247"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>,
274 <a id="idx:termvariables2:248"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>,
275 <a id="idx:throw1:249"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
276 <a id="idx:unifywithoccurscheck2:250"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>,
277 <a id="idx:unifiable3:251"></a><a class="pred" href="compare.html#unifiable/3">unifiable/3</a>,
278 <a id="idx:when2:252"></a><a class="pred" href="coroutining.html#when/2">when/2</a>,
279 <a id="idx:write1:253"></a><a class="pred" href="termrw.html#write/1">write/1</a>
239280 (and related predicates) .
240281
241282 <p>In addition, some built-ins recognise rational trees and raise an
242283 appropriate exception. Arithmetic evaluation belongs to this group. The
243 compiler (<a name="idx:asserta1:254"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>,
284 compiler (<a id="idx:asserta1:254"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>,
244285 etc.) also raises an exception. Future versions may support rational
245286 trees. Predicates that could provide meaningful processing of rational
246287 trees raise a <code>representation_error</code>. Predicates for which
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.14</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="DCG.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="dynamic.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:db"><a name="sec:4.14"><span class="sec-nr">4.14</span> <span class="sec-title">Database</span></a></h2>
195
196 <a name="sec:db"></a>
235 <h2 id="sec:db"><a id="sec:4.14"><span class="sec-nr">4.14</span> <span class="sec-title">Database</span></a></h2>
236
237 <a id="sec:db"></a>
197238
198239 <p>SWI-Prolog offers several ways to store data in globally accessible
199240 memory, i.e., outside the Prolog <em>stacks</em>. Data stored this way
202243 variables that can be assigned to. Typically, first consider
203244 representing data processed by your program as terms passed around as
204245 predicate arguments. If you need to reason over multiple solutions to a
205 goal, consider <a name="idx:findall3:792"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a name="idx:aggregate3:793"></a><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
246 goal, consider <a id="idx:findall3:792"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a id="idx:aggregate3:793"></a><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
206247 and related predicates.
207248
208249 <p>Nevertheless, there are scenarios where storing data outside the
213254 <dt><b>Using dynamic predicates</b></dt>
214255 <dd>
215256 Dynamic predicates are predicates for which the list of clauses is
216 modified at runtime using <a name="idx:asserta1:794"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>, <a name="idx:assertz1:795"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:retract1:796"></a><a class="pred" href="db.html#retract/1">retract/1</a>
257 modified at runtime using <a id="idx:asserta1:794"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>, <a id="idx:assertz1:795"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a id="idx:retract1:796"></a><a class="pred" href="db.html#retract/1">retract/1</a>
217258 or
218 <a name="idx:retractall1:797"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>.
259 <a id="idx:retractall1:797"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>.
219260 Following the ISO standard, predicates that are modified this way need
220 to be declared using the <a name="idx:dynamic1:798"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a> <em>directive</em>.
261 to be declared using the <a id="idx:dynamic1:798"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a> <em>directive</em>.
221262 These facilities are defined by the ISO standard and widely supported.
222263 The mechanism is often considered slow in the literature. Performance
223264 depends on the Prolog implementation. In SWI-Prolog, querying dynamic
224265 predicates has the same performance as static ones. The manipulation
225 predicates are fast. Using <a name="idx:retract1:799"></a><a class="pred" href="db.html#retract/1">retract/1</a>
226 or <a name="idx:retractall1:800"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>
266 predicates are fast. Using <a id="idx:retract1:799"></a><a class="pred" href="db.html#retract/1">retract/1</a>
267 or <a id="idx:retractall1:800"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>
227268 on a predicate registers the predicate as `dirty'. Dirty predicates are
228269 cleaned by
229 <a name="idx:garbagecollectclauses0:801"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>,
270 <a id="idx:garbagecollectclauses0:801"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>,
230271 which is normally automatically invoked. Some workloads may result in
231272 significant performance reduction due to skipping retracted clauses
232273 and/or clause garbage collection.
235276 to maintain a backup of the data on disk. Dynamic predicates come in two
236277 flavours, <em>shared</em> between threads and <em>local</em> to each
237278 thread. The latter version is created using the directive
238 <a name="idx:threadlocal1:802"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
279 <a id="idx:threadlocal1:802"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
239280 <dt><b>The recorded database</b></dt>
240281 <dd>
241282 The `recorded database' registers a list of terms with a <em>key</em>,
242 an atom or compound term. The list is managed using <a name="idx:recorda3:803"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>, <a name="idx:recordz3:804"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>
243 and <a name="idx:erase1:805"></a><a class="pred" href="db.html#erase/1">erase/1</a>.
244 It is queried using <a name="idx:recorded3:806"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>.
283 an atom or compound term. The list is managed using <a id="idx:recorda3:803"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>, <a id="idx:recordz3:804"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>
284 and <a id="idx:erase1:805"></a><a class="pred" href="db.html#erase/1">erase/1</a>.
285 It is queried using <a id="idx:recorded3:806"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>.
245286 The recorded database is not part of the ISO standard but fairly widely
246287 supported, notably in implementations building on the `Edinburgh
247288 tradition'. There are few reasons to use this database in SWI-Prolog due
248289 to the good performance of dynamic predicates. Advantages are (1) the
249290 handle provides a direct reference to a term, (2) cyclic terms can be
250 stored and (3) attributes (<a class="sec" href="attvar.html">section 7.1</a>)
251 are preserved. Disadvantages are (1) the terms in a list associated with
252 a key are not indexed, (2) the poorly specified
253 <em>immediate update semantics</em> (see <a class="sec" href="db.html">section
291 stored and (3) attributes (<a class="sec" href="attvar.html#sec:7.1">section
292 7.1</a>) are preserved. Disadvantages are (1) the terms in a list
293 associated with a key are not indexed, (2) the poorly specified
294 <em>immediate update semantics</em> (see <a class="sec" href="db.html#sec:4.14.5">section
254295 4.14.5</a> applies to the recorded database and (3) reduced portability.</dd>
255 <dt><b>The <a name="idx:flag3:807"></a><a class="pred" href="db.html#flag/3">flag/3</a>
296 <dt><b>The <a id="idx:flag3:807"></a><a class="pred" href="db.html#flag/3">flag/3</a>
256297 predicate</b></dt>
257298 <dd>
258 The predicate <a name="idx:flag3:808"></a><a class="pred" href="db.html#flag/3">flag/3</a>
299 The predicate <a id="idx:flag3:808"></a><a class="pred" href="db.html#flag/3">flag/3</a>
259300 associates one simple value (number or atom) with a key (atom, integer
260301 or compound). It is an old SWI-Prolog specific predicate that should be
261302 considered deprecated, although there is no plan to remove it.</dd>
262303 <dt><b>Using global variables</b></dt>
263304 <dd>
264 The predicates <a name="idx:bsetval2:809"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
265 and <a name="idx:nbsetval2:810"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
305 The predicates <a id="idx:bsetval2:809"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
306 and <a id="idx:nbsetval2:810"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
266307 associate a term living on the Prolog stack with a name, either
267308 backtrackable or non-backtrackable. Backtrackable and non-backtrackable
268 assignment without using a global name can be realised with <a name="idx:setarg3:811"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
269 and <a name="idx:nbsetarg3:812"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
270 Notably the latter are used to realise aggregation as e.g., <a name="idx:aggregateall3:813"></a><a class="pred" href="aggregate.html#aggregate_all/3">aggregate_all/3</a>
309 assignment without using a global name can be realised with <a id="idx:setarg3:811"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
310 and <a id="idx:nbsetarg3:812"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
311 Notably the latter are used to realise aggregation as e.g., <a id="idx:aggregateall3:813"></a><a class="pred" href="aggregate.html#aggregate_all/3">aggregate_all/3</a>
271312 performs.</dd>
272313 <dt><b>Tries</b></dt>
273314 <dd>
274315 As of version 7.3.21, SWI-Prolog provides <em>tries</em> (prefix trees)
275316 to associate a term <em>variant</em> with a value. Tries have been
276 introduced to support <var>tabling</var> and are described in <a class="sec" href="db.html">section
317 introduced to support <var>tabling</var> and are described in <a class="sec" href="db.html#sec:4.14.4">section
277318 4.14.4</a>.
278319 </dd>
279320 </dl>
280321
281 <p><h3 id="sec:dynpreds"><a name="sec:4.14.1"><span class="sec-nr">4.14.1</span> <span class="sec-title">Managing
322 <p><h3 id="sec:dynpreds"><a id="sec:4.14.1"><span class="sec-nr">4.14.1</span> <span class="sec-title">Managing
282323 (dynamic) predicates</span></a></h3>
283324
284 <a name="sec:dynpreds"></a>
325 <a id="sec:dynpreds"></a>
285326
286327 <dl class="latex">
287 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="abolish/1"><strong>abolish</strong>(<var>:PredicateIndicator</var>)</a></dt>
328 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="abolish/1"><strong>abolish</strong>(<var>:PredicateIndicator</var>)</a></dt>
288329 <dd class="defbody">
289330 Removes all clauses of a predicate with functor <var>Functor</var> and
290331 arity
293334 imported predicate only removes the import link; the predicate will keep
294335 its old definition in its definition module.
295336
296 <p>According to the ISO standard, <a name="idx:abolish1:814"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
337 <p>According to the ISO standard, <a id="idx:abolish1:814"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
297338 can only be applied to dynamic procedures. This is odd, as for dealing
298 with dynamic procedures there is already <a name="idx:retract1:815"></a><a class="pred" href="db.html#retract/1">retract/1</a>
299 and <a name="idx:retractall1:816"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>.
300 The <a name="idx:abolish1:817"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
339 with dynamic procedures there is already <a id="idx:retract1:815"></a><a class="pred" href="db.html#retract/1">retract/1</a>
340 and <a id="idx:retractall1:816"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>.
341 The <a id="idx:abolish1:817"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
301342 predicate was introduced in DEC-10 Prolog precisely for dealing with
302 static procedures. In SWI-Prolog, <a name="idx:abolish1:818"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
343 static procedures. In SWI-Prolog, <a id="idx:abolish1:818"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
303344 works on static procedures, unless the Prolog flag <a class="flag" href="flags.html#flag:iso">iso</a>
304345 is set to <code>true</code>.
305346
306 <p>It is advised to use <a name="idx:retractall1:819"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>
347 <p>It is advised to use <a id="idx:retractall1:819"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>
307348 for erasing all clauses of a dynamic predicate.</dd>
308 <dt class="pubdef"><a name="abolish/2"><strong>abolish</strong>(<var>+Name,
349 <dt class="pubdef"><a id="abolish/2"><strong>abolish</strong>(<var>+Name,
309350 +Arity</var>)</a></dt>
310351 <dd class="defbody">
311 Same as <code>abolish(Name/Arity)</code>. The predicate <a name="idx:abolish2:820"></a><a class="pred" href="db.html#abolish/2">abolish/2</a>
312 conforms to the Edinburgh standard, while <a name="idx:abolish1:821"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
352 Same as <code>abolish(Name/Arity)</code>. The predicate <a id="idx:abolish2:820"></a><a class="pred" href="db.html#abolish/2">abolish/2</a>
353 conforms to the Edinburgh standard, while <a id="idx:abolish1:821"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
313354 is ISO compliant.</dd>
314 <dt class="pubdef"><a name="copy_predicate_clauses/2"><strong>copy_predicate_clauses</strong>(<var>:From,
355 <dt class="pubdef"><a id="copy_predicate_clauses/2"><strong>copy_predicate_clauses</strong>(<var>:From,
315356 :To</var>)</a></dt>
316357 <dd class="defbody">
317358 Copy all clauses of predicate <var>From</var> to <var>To</var>. The
320361 undefined, it is created as a dynamic predicate holding a copy of the
321362 clauses of
322363 <var>From</var>. If <var>To</var> is a dynamic predicate, the clauses of
323 <var>From</var> are added (as in <a name="idx:assertz1:822"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>)
364 <var>From</var> are added (as in <a id="idx:assertz1:822"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>)
324365 to the clauses of <var>To</var>.
325366 <var>To</var> and <var>From</var> must have the same arity. Acts as if
326367 defined by the program below, but at a much better performance by
341382 </pre>
342383
343384 </dd>
344 <dt class="pubdef"><a name="redefine_system_predicate/1"><strong>redefine_system_predicate</strong>(<var>+Head</var>)</a></dt>
385 <dt class="pubdef"><a id="redefine_system_predicate/1"><strong>redefine_system_predicate</strong>(<var>+Head</var>)</a></dt>
345386 <dd class="defbody">
346387 This directive may be used both in module <code>user</code> and in
347388 normal modules to redefine any system predicate. If the system
352393
353394 <p>Redefining system predicate facilitates the definition of
354395 compatibility packages. Use in other contexts is discouraged.</dd>
355 <dt class="pubdef"><span class="pred-tag">[ISO,nondet]</span><a name="retract/1"><strong>retract</strong>(<var>+Term</var>)</a></dt>
396 <dt class="pubdef"><span class="pred-tag">[ISO,nondet]</span><a id="retract/1"><strong>retract</strong>(<var>+Term</var>)</a></dt>
356397 <dd class="defbody">
357398 When <var>Term</var> is an atom or a term it is unified with the first
358399 unifying fact or clause in the database. The fact or clause is removed
359 from the database. The <a name="idx:retract1:823"></a><a class="pred" href="db.html#retract/1">retract/1</a>
360 predicate respects the <em>logical update view</em>. This implies that <a name="idx:retract1:824"></a><a class="pred" href="db.html#retract/1">retract/1</a>
400 from the database. The <a id="idx:retract1:823"></a><a class="pred" href="db.html#retract/1">retract/1</a>
401 predicate respects the <em>logical update view</em>. This implies that <a id="idx:retract1:824"></a><a class="pred" href="db.html#retract/1">retract/1</a>
361402 succeeds for all clauses that match <var>Term</var> when the predicate
362403 was <em>called</em>. The example below illustrates that the first call
363 to <a name="idx:retract1:825"></a><a class="pred" href="db.html#retract/1">retract/1</a>
404 to <a id="idx:retract1:825"></a><a class="pred" href="db.html#retract/1">retract/1</a>
364405 succeeds on <code>bee</code> on backtracking despite the fact that <code>bee</code>
365406 is already retracted.<sup class="fn">74<span class="fn-text">Example by
366407 Jan Burse</span></sup>.
384425 time their notion of the <em>entry generation</em> is adjusted such that
385426 they do not retract the same first clause. This implies that, if
386427 multiple threads use <code>once(retract(Term))</code>, no two threads
387 will retract the same clause. Note that on backtracking over <a name="idx:retract1:826"></a><a class="pred" href="db.html#retract/1">retract/1</a>,
428 will retract the same clause. Note that on backtracking over <a id="idx:retract1:826"></a><a class="pred" href="db.html#retract/1">retract/1</a>,
388429 multiple threads may retract the same clause as both threads respect the
389430 logical update view.</dd>
390 <dt class="pubdef"><span class="pred-tag">[ISO,det]</span><a name="retractall/1"><strong>retractall</strong>(<var>+Head</var>)</a></dt>
431 <dt class="pubdef"><span class="pred-tag">[ISO,det]</span><a id="retractall/1"><strong>retractall</strong>(<var>+Head</var>)</a></dt>
391432 <dd class="defbody">
392433 All facts or clauses in the database for which the <var>head</var>
393434 unifies with <var>Head</var> are removed. If <var>Head</var> refers to a
394435 predicate that is not defined, it is implicitly created as a dynamic
395 predicate. See also <a name="idx:dynamic1:827"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.<sup class="fn">75<span class="fn-text">The
396 ISO standard only allows using <a name="idx:dynamic1:828"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
436 predicate. See also <a id="idx:dynamic1:827"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.<sup class="fn">75<span class="fn-text">The
437 ISO standard only allows using <a id="idx:dynamic1:828"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
397438 as a <em>directive</em>.</span></sup></dd>
398 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="asserta/1"><strong>asserta</strong>(<var>+Term</var>)</a></dt>
399 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="assertz/1"><strong>assertz</strong>(<var>+Term</var>)</a></dt>
400 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="assert/1"><strong>assert</strong>(<var>+Term</var>)</a></dt>
439 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="asserta/1"><strong>asserta</strong>(<var>+Term</var>)</a></dt>
440 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="assertz/1"><strong>assertz</strong>(<var>+Term</var>)</a></dt>
441 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="assert/1"><strong>assert</strong>(<var>+Term</var>)</a></dt>
401442 <dd class="defbody">
402443 Assert a clause (fact or rule) into the database. The predicate
403 <a name="idx:asserta1:829"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
444 <a id="idx:asserta1:829"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
404445 asserts the clause as first clause of the predicate while
405 <a name="idx:assertz1:830"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
406 assert the clause as last clause. The deprecated <a name="idx:assert1:831"></a><a class="pred" href="db.html#assert/1">assert/1</a>
407 is equivalent to <a name="idx:assertz1:832"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>.
408 If the program space for the target module is limited (see <a name="idx:setmodule1:833"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>), <a name="idx:asserta1:834"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
446 <a id="idx:assertz1:830"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
447 assert the clause as last clause. The deprecated <a id="idx:assert1:831"></a><a class="pred" href="db.html#assert/1">assert/1</a>
448 is equivalent to <a id="idx:assertz1:832"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>.
449 If the program space for the target module is limited (see <a id="idx:setmodule1:833"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>), <a id="idx:asserta1:834"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
409450 can raise a
410451 <code>resource_error(program_space)</code> exception. The example below
411452 adds two facts and a rule. Note the double parentheses around the rule.
419460 </pre>
420461
421462 </dd>
422 <dt class="pubdef"><a name="asserta/2"><strong>asserta</strong>(<var>+Term,
463 <dt class="pubdef"><a id="asserta/2"><strong>asserta</strong>(<var>+Term,
423464 -Reference</var>)</a></dt>
424 <dt class="pubdef"><a name="assertz/2"><strong>assertz</strong>(<var>+Term,
465 <dt class="pubdef"><a id="assertz/2"><strong>assertz</strong>(<var>+Term,
425466 -Reference</var>)</a></dt>
426 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="assert/2"><strong>assert</strong>(<var>+Term,
467 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="assert/2"><strong>assert</strong>(<var>+Term,
427468 -Reference</var>)</a></dt>
428469 <dd class="defbody">
429 Equivalent to <a name="idx:asserta1:835"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>, <a name="idx:assertz1:836"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:assert1:837"></a><a class="pred" href="db.html#assert/1">assert/1</a>,
470 Equivalent to <a id="idx:asserta1:835"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>, <a id="idx:assertz1:836"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a id="idx:assert1:837"></a><a class="pred" href="db.html#assert/1">assert/1</a>,
430471 but in addition unifies
431472 <var>Reference</var> with a handle to the asserted clauses. The handle
432 can be used to access this clause with <a name="idx:clause3:838"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>
433 and <a name="idx:erase1:839"></a><a class="pred" href="db.html#erase/1">erase/1</a>.
473 can be used to access this clause with <a id="idx:clause3:838"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>
474 and <a id="idx:erase1:839"></a><a class="pred" href="db.html#erase/1">erase/1</a>.
434475 </dd>
435476 </dl>
436477
437 <p><h3 id="sec:recdb"><a name="sec:4.14.2"><span class="sec-nr">4.14.2</span> <span class="sec-title">The
478 <p><h3 id="sec:recdb"><a id="sec:4.14.2"><span class="sec-nr">4.14.2</span> <span class="sec-title">The
438479 recorded database</span></a></h3>
439480
440 <a name="sec:recdb"></a>
481 <a id="sec:recdb"></a>
441482
442483 <dl class="latex">
443 <dt class="pubdef"><a name="recorda/3"><strong>recorda</strong>(<var>+Key,
484 <dt class="pubdef"><a id="recorda/3"><strong>recorda</strong>(<var>+Key,
444485 +Term, -Reference</var>)</a></dt>
445486 <dd class="defbody">
446487 Assert <var>Term</var> in the recorded database under key <var>Key</var>.
449490 atom or compound term. If the key is a compound term, only the name and
450491 arity define the key.
451492 <var>Reference</var> is unified with an opaque handle to the record (see
452 <a name="idx:erase1:840"></a><a class="pred" href="db.html#erase/1">erase/1</a>).</dd>
453 <dt class="pubdef"><a name="recorda/2"><strong>recorda</strong>(<var>+Key,
493 <a id="idx:erase1:840"></a><a class="pred" href="db.html#erase/1">erase/1</a>).</dd>
494 <dt class="pubdef"><a id="recorda/2"><strong>recorda</strong>(<var>+Key,
454495 +Term</var>)</a></dt>
455496 <dd class="defbody">
456497 Equivalent to <code>recorda(<var>Key</var>, <var>Term</var>, _)</code>.</dd>
457 <dt class="pubdef"><a name="recordz/3"><strong>recordz</strong>(<var>+Key,
498 <dt class="pubdef"><a id="recordz/3"><strong>recordz</strong>(<var>+Key,
458499 +Term, -Reference</var>)</a></dt>
459500 <dd class="defbody">
460 Equivalent to <a name="idx:recorda3:841"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
501 Equivalent to <a id="idx:recorda3:841"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
461502 but puts the <var>Term</var> at the tail of the terms recorded under <var>Key</var>.</dd>
462 <dt class="pubdef"><a name="recordz/2"><strong>recordz</strong>(<var>+Key,
503 <dt class="pubdef"><a id="recordz/2"><strong>recordz</strong>(<var>+Key,
463504 +Term</var>)</a></dt>
464505 <dd class="defbody">
465506 Equivalent to <code>recordz(<var>Key</var>, <var>Term</var>, _)</code>.</dd>
466 <dt class="pubdef"><a name="recorded/3"><strong>recorded</strong>(<var>?Key,
507 <dt class="pubdef"><a id="recorded/3"><strong>recorded</strong>(<var>?Key,
467508 ?Value, ?Reference</var>)</a></dt>
468509 <dd class="defbody">
469510 True if <var>Value</var> is recorded under <var>Key</var> and has the
472513 non-deterministic. If neither <var>Reference</var> nor <var>Key</var> is
473514 given, the triples are generated as in the code snippet below.<sup class="fn">76<span class="fn-text">Note
474515 that, without a given <var>Key</var>, some implementations return
475 triples in the order defined by <a name="idx:recorda2:842"></a><a class="pred" href="db.html#recorda/2">recorda/2</a>
476 and <a name="idx:recordz2:843"></a><a class="pred" href="db.html#recordz/2">recordz/2</a>.</span></sup>
477 See also <a name="idx:currentkey1:844"></a><a class="pred" href="examineprog.html#current_key/1">current_key/1</a>.
516 triples in the order defined by <a id="idx:recorda2:842"></a><a class="pred" href="db.html#recorda/2">recorda/2</a>
517 and <a id="idx:recordz2:843"></a><a class="pred" href="db.html#recordz/2">recordz/2</a>.</span></sup>
518 See also <a id="idx:currentkey1:844"></a><a class="pred" href="examineprog.html#current_key/1">current_key/1</a>.
478519
479520 <pre class="code">
480521 current_key(Key),
482523 </pre>
483524
484525 </dd>
485 <dt class="pubdef"><a name="recorded/2"><strong>recorded</strong>(<var>+Key,
526 <dt class="pubdef"><a id="recorded/2"><strong>recorded</strong>(<var>+Key,
486527 -Value</var>)</a></dt>
487528 <dd class="defbody">
488529 Equivalent to <code>recorded(<var>Key</var>, <var>Value</var>, _)</code>.</dd>
489 <dt class="pubdef"><a name="erase/1"><strong>erase</strong>(<var>+Reference</var>)</a></dt>
530 <dt class="pubdef"><a id="erase/1"><strong>erase</strong>(<var>+Reference</var>)</a></dt>
490531 <dd class="defbody">
491532 Erase a record or clause from the database. <var>Reference</var> is a
492 db-reference returned by <a name="idx:recorda3:845"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>, <a name="idx:recordz3:846"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>
493 or <a name="idx:recorded3:847"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>, <a name="idx:clause3:848"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>,
494 <a name="idx:assert2:849"></a><a class="pred" href="db.html#assert/2">assert/2</a>, <a name="idx:asserta2:850"></a><a class="pred" href="db.html#asserta/2">asserta/2</a>
495 or <a name="idx:assertz2:851"></a><a class="pred" href="db.html#assertz/2">assertz/2</a>.
533 db-reference returned by <a id="idx:recorda3:845"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>, <a id="idx:recordz3:846"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>
534 or <a id="idx:recorded3:847"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>, <a id="idx:clause3:848"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>,
535 <a id="idx:assert2:849"></a><a class="pred" href="db.html#assert/2">assert/2</a>, <a id="idx:asserta2:850"></a><a class="pred" href="db.html#asserta/2">asserta/2</a>
536 or <a id="idx:assertz2:851"></a><a class="pred" href="db.html#assertz/2">assertz/2</a>.
496537 Fail silently if the referenced object no longer exists. Notably, if
497538 multiple threads attempt to erase the same clause one will succeed and
498539 the others will fail.</dd>
499 <dt class="pubdef"><a name="instance/2"><strong>instance</strong>(<var>+Reference,
540 <dt class="pubdef"><a id="instance/2"><strong>instance</strong>(<var>+Reference,
500541 -Term</var>)</a></dt>
501542 <dd class="defbody">
502543 Unify <var>Term</var> with the referenced clause or database record.
504545 </dd>
505546 </dl>
506547
507 <p><h3 id="sec:flag"><a name="sec:4.14.3"><span class="sec-nr">4.14.3</span> <span class="sec-title">Flags</span></a></h3>
508
509 <a name="sec:flag"></a>
510
511 <p>The predicate <a name="idx:flag3:852"></a><a class="pred" href="db.html#flag/3">flag/3</a>
548 <p><h3 id="sec:flag"><a id="sec:4.14.3"><span class="sec-nr">4.14.3</span> <span class="sec-title">Flags</span></a></h3>
549
550 <a id="sec:flag"></a>
551
552 <p>The predicate <a id="idx:flag3:852"></a><a class="pred" href="db.html#flag/3">flag/3</a>
512553 is the oldest way to store global non-backtrackable data in SWI-Prolog.
513554 Flags are global and shared by all threads. Their value is limited to
514555 atoms, small (64-bit) integers and floating point numbers. Flags are
515556 thread-safe. The flags described in this section must not be confused
516557 with <em>Prolog flags</em> described in
517 <a class="sec" href="flags.html">section 2.11</a>.
558 <a class="sec" href="flags.html#sec:2.11">section 2.11</a>.
518559
519560 <dl class="latex">
520 <dt class="pubdef"><a name="get_flag/2"><strong>get_flag</strong>(<var>+Key,
561 <dt class="pubdef"><a id="get_flag/2"><strong>get_flag</strong>(<var>+Key,
521562 -Value</var>)</a></dt>
522563 <dd class="defbody">
523564 True when <var>Value</var> is the value currently associated with <var>Key</var>.
524565 If <var>Key</var> does not exist, a new flag with value `0' (zero) is
525566 created.
526567 </dd>
527 <dt class="pubdef"><a name="set_flag/2"><strong>set_flag</strong>(<var>+Key,
568 <dt class="pubdef"><a id="set_flag/2"><strong>set_flag</strong>(<var>+Key,
528569 Value</var>)</a></dt>
529570 <dd class="defbody">
530571 Set flag <var>Key</var> to <var>Value</var>. Value must be an atom,
531572 small (64-bit) integer or float.
532573 </dd>
533 <dt class="pubdef"><a name="flag/3"><strong>flag</strong>(<var>+Key,
534 -Old, +New</var>)</a></dt>
574 <dt class="pubdef"><a id="flag/3"><strong>flag</strong>(<var>+Key, -Old,
575 +New</var>)</a></dt>
535576 <dd class="defbody">
536577 True when <var>Old</var> is the current value of the flag <var>Key</var>
537578 and the flag has been set to <var>New</var>. <var>New</var> can be an
547588 <p></dd>
548589 </dl>
549590
550 <p><h3 id="sec:trie"><a name="sec:4.14.4"><span class="sec-nr">4.14.4</span> <span class="sec-title">Tries</span></a></h3>
551
552 <a name="sec:trie"></a>
591 <p><h3 id="sec:trie"><a id="sec:4.14.4"><span class="sec-nr">4.14.4</span> <span class="sec-title">Tries</span></a></h3>
592
593 <a id="sec:trie"></a>
553594
554595 <p>Tries (also called <em>digital tree</em>, <em>radix tree</em> or
555596 <em>prefix tree</em> maintain a mapping between a variant of a term (see
562603 <ul class="compact">
563604 <li>Tries are not thread-safe.
564605 <li>Tries should not be modified while non-deterministic predicates such
565 as <a name="idx:triegen3:853"></a><a class="pred" href="db.html#trie_gen/3">trie_gen/3</a>
606 as <a id="idx:triegen3:853"></a><a class="pred" href="db.html#trie_gen/3">trie_gen/3</a>
566607 are running on the trie.
567608 <li>Terms cannot have <em>attributed variables</em>.
568609 <li>Terms cannot be <em>cyclic</em>. Possibly this will not change
576617 considered stable.</b>
577618
578619 <dl class="latex">
579 <dt class="pubdef"><a name="trie_new/1"><strong>trie_new</strong>(<var>-Trie</var>)</a></dt>
620 <dt class="pubdef"><a id="trie_new/1"><strong>trie_new</strong>(<var>-Trie</var>)</a></dt>
580621 <dd class="defbody">
581622 Create a new trie and unify <var>Trie</var> with a handle to the trie.
582623 The trie handle is a <em>blob</em>. Tries are subject to atom garbage
583624 collection.</dd>
584 <dt class="pubdef"><a name="trie_destroy/1"><strong>trie_destroy</strong>(<var>+Trie</var>)</a></dt>
625 <dt class="pubdef"><a id="trie_destroy/1"><strong>trie_destroy</strong>(<var>+Trie</var>)</a></dt>
585626 <dd class="defbody">
586627 Destroy <var>Trie</var>. This removes all nodes from the trie and causes
587628 further access to <var>Trie</var> to raise an existence_error exception.
588629 The handle itself is reclaimed by atom garbage collection.</dd>
589 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_trie/1"><strong>is_trie</strong>(<var>@Trie</var>)</a></dt>
590 <dd class="defbody">
591 True when <var>Trie</var> is a trie object. See also <a name="idx:currenttrie1:854"></a><a class="pred" href="db.html#current_trie/1">current_trie/1</a>.</dd>
592 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_trie/1"><strong>current_trie</strong>(<var>-Trie</var>)</a></dt>
630 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_trie/1"><strong>is_trie</strong>(<var>@Trie</var>)</a></dt>
631 <dd class="defbody">
632 True when <var>Trie</var> is a trie object. See also <a id="idx:currenttrie1:854"></a><a class="pred" href="db.html#current_trie/1">current_trie/1</a>.</dd>
633 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_trie/1"><strong>current_trie</strong>(<var>-Trie</var>)</a></dt>
593634 <dd class="defbody">
594635 True if <var>Trie</var> is a currently existing trie. As this enumerates
595636 and then filters all known atoms this predicate is slow and should only
596 be used for debugging purposes. See also <a name="idx:istrie1:855"></a><a class="pred" href="db.html#is_trie/1">is_trie/1</a>.</dd>
597 <dt class="pubdef"><a name="trie_insert/3"><strong>trie_insert</strong>(<var>+Trie,
637 be used for debugging purposes. See also <a id="idx:istrie1:855"></a><a class="pred" href="db.html#is_trie/1">is_trie/1</a>.</dd>
638 <dt class="pubdef"><a id="trie_insert/3"><strong>trie_insert</strong>(<var>+Trie,
598639 +Key, +Value</var>)</a></dt>
599640 <dd class="defbody">
600641 Insert the term <var>Key</var> into <var>Trie</var> and associate it
604645 silently. If <var>Key</var> is in <var>Trie</var> associated with a
605646 different value, a
606647 <code>permission_error</code> is raised.</dd>
607 <dt class="pubdef"><a name="trie_update/3"><strong>trie_update</strong>(<var>+Trie,
648 <dt class="pubdef"><a id="trie_update/3"><strong>trie_update</strong>(<var>+Trie,
608649 +Key, +Value</var>)</a></dt>
609650 <dd class="defbody">
610 As <a name="idx:trieinsert3:856"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
651 As <a id="idx:trieinsert3:856"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
611652 but if <var>Key</var> is in <var>Trie</var>, its associated value is <em>updated</em>.</dd>
612 <dt class="pubdef"><a name="trie_insert/4"><strong>trie_insert</strong>(<var>+Trie,
653 <dt class="pubdef"><a id="trie_insert/4"><strong>trie_insert</strong>(<var>+Trie,
613654 +Term, +Value, -Handle</var>)</a></dt>
614655 <dd class="defbody">
615 As <a name="idx:trieinsert3:857"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
656 As <a id="idx:trieinsert3:857"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
616657 returning a handle to the trie node. This predicate is currently unsafe
617658 as <var>Handle</var> is an integer used to encode a pointer. It was used
618659 to implement a pure Prolog version of the <code>library(tabling)</code>
619660 library.</dd>
620 <dt class="pubdef"><a name="trie_delete/3"><strong>trie_delete</strong>(<var>+Trie,
661 <dt class="pubdef"><a id="trie_delete/3"><strong>trie_delete</strong>(<var>+Trie,
621662 +Key, ?Value</var>)</a></dt>
622663 <dd class="defbody">
623664 Delete <var>Key</var> from <var>Trie</var> if the value associated with <var>Key</var>
624665 unifies with <var>Value</var>.</dd>
625 <dt class="pubdef"><a name="trie_lookup/3"><strong>trie_lookup</strong>(<var>+Trie,
666 <dt class="pubdef"><a id="trie_lookup/3"><strong>trie_lookup</strong>(<var>+Trie,
626667 +Key, -Value</var>)</a></dt>
627668 <dd class="defbody">
628669 True if the term <var>Key</var> is in <var>Trie</var> and associated
629670 with
630671 <var>Value</var>.</dd>
631 <dt class="pubdef"><a name="trie_term/2"><strong>trie_term</strong>(<var>+Handle,
672 <dt class="pubdef"><a id="trie_term/2"><strong>trie_term</strong>(<var>+Handle,
632673 -Term</var>)</a></dt>
633674 <dd class="defbody">
634675 True when <var>Term</var> is a copy of the term associated with <var>Handle</var>.
635676 The result is undefined (including crashes) if <var>Handle</var> is not
636 a handle returned by <a name="idx:trieinsertnew3:858"></a><span class="pred-ext">trie_insert_new/3</span>
677 a handle returned by <a id="idx:trieinsertnew3:858"></a><span class="pred-ext">trie_insert_new/3</span>
637678 or the node has been removed afterwards.</dd>
638 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="trie_gen/3"><strong>trie_gen</strong>(<var>+Trie,
679 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="trie_gen/3"><strong>trie_gen</strong>(<var>+Trie,
639680 ?Key, -Value</var>)</a></dt>
640681 <dd class="defbody">
641682 True when <var>Key</var> is associated with <var>Value</var> in <var>Trie</var>.
642683 Backtracking retrieves all pairs. Currently scans the entire trie, even
643684 if <var>Key</var> is partly known. Currently unsafe if <var>Trie</var>
644685 is modified while the values are being enumerated.</dd>
645 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="trie_property/2"><strong>trie_property</strong>(<var>?Trie,
686 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="trie_property/2"><strong>trie_property</strong>(<var>?Trie,
646687 ?Property</var>)</a></dt>
647688 <dd class="defbody">
648689 True if <var>Trie</var> exists with <var>Property</var>. Intended for
671712 </dd>
672713 </dl>
673714
674 <p><h3 id="sec:update"><a name="sec:4.14.5"><span class="sec-nr">4.14.5</span> <span class="sec-title">Update
715 <p><h3 id="sec:update"><a id="sec:4.14.5"><span class="sec-nr">4.14.5</span> <span class="sec-title">Update
675716 view</span></a></h3>
676717
677 <a name="sec:update"></a>
678
679 <p><a name="idx:logicalupdateview:859"></a><a name="idx:immediateupdateview:860"></a><a name="idx:updateview:861"></a>Traditionally,
718 <a id="sec:update"></a>
719
720 <p><a id="idx:logicalupdateview:859"></a><a id="idx:immediateupdateview:860"></a><a id="idx:updateview:861"></a>Traditionally,
680721 Prolog systems used the <em>immediate update view</em>: new clauses
681722 became visible to predicates backtracking over dynamic predicates
682723 immediately, and retracted clauses became invisible immediately.
683724
684725 <p>Starting with SWI-Prolog 3.3.0 we adhere to the <em>logical update
685726 view</em>, where backtrackable predicates that enter the definition of a
686 predicate will not see any changes (either caused by <a name="idx:assert1:862"></a><a class="pred" href="db.html#assert/1">assert/1</a>
727 predicate will not see any changes (either caused by <a id="idx:assert1:862"></a><a class="pred" href="db.html#assert/1">assert/1</a>
687728 or
688 <a name="idx:retract1:863"></a><a class="pred" href="db.html#retract/1">retract/1</a>)
729 <a id="idx:retract1:863"></a><a class="pred" href="db.html#retract/1">retract/1</a>)
689730 to the predicate. This view is the ISO standard, the most commonly used
690731 and the most `safe'.<sup class="fn">77<span class="fn-text">For example,
691732 using the immediate update view, no call to a dynamic predicate is
698739 with a `created' ... `erased' interval that encloses the generation of
699740 the current goal are considered visible.
700741
701 <p><h3 id="sec:hashterm"><a name="sec:4.14.6"><span class="sec-nr">4.14.6</span> <span class="sec-title">Indexing
742 <p><h3 id="sec:hashterm"><a id="sec:4.14.6"><span class="sec-nr">4.14.6</span> <span class="sec-title">Indexing
702743 databases</span></a></h3>
703744
704 <a name="sec:hashterm"></a>
705
706 <p><a name="idx:indexingtermhashes:864"></a>The indexing capabilities of
745 <a id="sec:hashterm"></a>
746
747 <p><a id="idx:indexingtermhashes:864"></a>The indexing capabilities of
707748 SWI-Prolog are described in
708 <a class="sec" href="jitindex.html">section 2.18</a>. Summarizing,
709 SWI-Prolog creates indexes for any applicable argument, but only on one
710 argument, and does not index on arguments of compound terms. The
711 predicates below provide building blocks to circumvent the limitations
712 of the current indexing system.
713
714 <p>Programs that aim at portability should consider using <a name="idx:termhash2:865"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
749 <a class="sec" href="jitindex.html#sec:2.18">section 2.18</a>.
750 Summarizing, SWI-Prolog creates indexes for any applicable argument, but
751 only on one argument, and does not index on arguments of compound terms.
752 The predicates below provide building blocks to circumvent the
753 limitations of the current indexing system.
754
755 <p>Programs that aim at portability should consider using <a id="idx:termhash2:865"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
715756 and
716 <a name="idx:termhash4:866"></a><a class="pred" href="db.html#term_hash/4">term_hash/4</a>
757 <a id="idx:termhash4:866"></a><a class="pred" href="db.html#term_hash/4">term_hash/4</a>
717758 to design their database such that indexing on constant or functor
718759 (name/arity reference) on the first argument is sufficient.
719760
720761 <dl class="latex">
721 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="term_hash/2"><strong>term_hash</strong>(<var>+Term,
762 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="term_hash/2"><strong>term_hash</strong>(<var>+Term,
722763 -HashKey</var>)</a></dt>
723764 <dd class="defbody">
724 If <var>Term</var> is a ground term (see <a name="idx:ground1:867"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>), <var>HashKey</var>
765 If <var>Term</var> is a ground term (see <a id="idx:ground1:867"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>), <var>HashKey</var>
725766 is unified with a positive integer value that may be used as a hash key
726767 to the value. If <var>Term</var> is not ground, the predicate leaves <var>HashKey</var>
727768 an unbound variable. Hash keys are in the range <var>0 ... 16,777,215</var>,
735776 atoms and may be assumed constant over different invocations and
736777 versions of SWI-Prolog.<sup class="fn">78<span class="fn-text">Last
737778 change: version 5.10.4</span></sup> Hashes differ between big and little
738 endian machines. The <a name="idx:termhash2:868"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
779 endian machines. The <a id="idx:termhash2:868"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
739780 predicate is cycle-safe.<sup class="fn">bug<span class="fn-text">All
740781 arguments that (indirectly) lead to a cycle have the same hash key.</span></sup></dd>
741 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="term_hash/4"><strong>term_hash</strong>(<var>+Term,
782 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="term_hash/4"><strong>term_hash</strong>(<var>+Term,
742783 +Depth, +Range, -HashKey</var>)</a></dt>
743784 <dd class="defbody">
744 As <a name="idx:termhash2:869"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>,
785 As <a id="idx:termhash2:869"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>,
745786 but only considers <var>Term</var> to the specified
746787 <var>Depth</var>. The top-level term has depth 1, its arguments have
747788 depth 2, etc. That is, <var><var>Depth</var> = 0</var> hashes nothing; <var><var>Depth</var>
751792
752793 <p><var>HashKey</var> is in the range <var>[0 ...<var>Range</var>-1]</var>. <var>Range</var>
753794 must be in the range <var>[1 ... 2147483647]</var></dd>
754 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="variant_sha1/2"><strong>variant_sha1</strong>(<var>+Term,
795 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="variant_sha1/2"><strong>variant_sha1</strong>(<var>+Term,
755796 -SHA1</var>)</a></dt>
756797 <dd class="defbody">
757798 Compute a SHA1-hash from <var>Term</var>. The hash is represented as a
758 40-byte hexadecimal atom. Unlike <a name="idx:termhash2:870"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
799 40-byte hexadecimal atom. Unlike <a id="idx:termhash2:870"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
759800 and friends, this predicate produces a hash key for non-ground terms.
760801 The hash is invariant over variable-renaming (see <a class="pred" href="compare.html#=@=/2">=@=/2</a>)
761802 and constants over different invocations of Prolog.<sup class="fn">bug<span class="fn-text">The
764805
765806 <p>This predicate raises an exception when trying to compute the hash on
766807 a cyclic term or attributed term. Attributed terms are not handled
767 because <a name="idx:subsumeschk2:871"></a><span class="pred-ext">subsumes_chk/2</span>
808 because <a id="idx:subsumeschk2:871"></a><span class="pred-ext">subsumes_chk/2</span>
768809 is not considered well defined for attributed terms. Cyclic terms are
769810 not supported because this would require establishing a canonical cycle.
770811 That is, given A=[a|A] and B=[a,a|B],
775816 table. By using a cryptographic hash, heuristic algorithms can often
776817 ignore the possibility of hash collisions and thus avoid storing the
777818 goal term itself as well as testing using <a class="pred" href="compare.html#=@=/2">=@=/2</a>.</dd>
778 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="variant_hash/2"><strong>variant_hash</strong>(<var>+Term,
819 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="variant_hash/2"><strong>variant_hash</strong>(<var>+Term,
779820 -HashKey</var>)</a></dt>
780821 <dd class="defbody">
781 Similar to <a name="idx:variantsha12:872"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>,
782 but using a non-cryptographic hash and produces an integer result like <a name="idx:termhash2:873"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>.
822 Similar to <a id="idx:variantsha12:872"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>,
823 but using a non-cryptographic hash and produces an integer result like <a id="idx:termhash2:873"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>.
783824 This version does deal with attributed variables, processing them as
784825 normal variables. This hash is primarily intended to speedup finding
785826 variant terms in a set of terms.
786 <sup class="fn">bug<span class="fn-text">As <a name="idx:variantsha12:874"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>,
827 <sup class="fn">bug<span class="fn-text">As <a id="idx:variantsha12:874"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>,
787828 cyclic terms result in an exception.</span></sup>
788829 </dd>
789830 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.11</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="csv.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="error.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:debug"><a name="sec:A.11"><span class="sec-nr">A.11</span> <span class="sec-title">library(debug):
235 <h2 id="sec:debug"><a id="sec:A.11"><span class="sec-nr">A.11</span> <span class="sec-title">library(debug):
195236 Print debug messages and test assertions</span></a></h2>
196237
197 <p><a name="sec:debug"></a>
238 <p><a id="sec:debug"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">author</dt>
221262 debugger if the condition does not hold.
222263
223264 <dl class="latex">
224 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="debugging/1"><strong>debugging</strong>(<var>+Topic</var>)</a></dt>
225 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="debugging/1"><strong>debugging</strong>(<var>-Topic</var>)</a></dt>
226 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="debugging/2"><strong>debugging</strong>(<var>?Topic,
265 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="debugging/1"><strong>debugging</strong>(<var>+Topic</var>)</a></dt>
266 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="debugging/1"><strong>debugging</strong>(<var>-Topic</var>)</a></dt>
267 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="debugging/2"><strong>debugging</strong>(<var>?Topic,
227268 ?Bool</var>)</a></dt>
228269 <dd class="defbody">
229270 Examine debug topics. The form <code>debugging(+Topic)</code> may be
240281
241282 <p>The other two calls are intended to examine existing and enabled
242283 debugging tokens and are typically not used in user programs.</dd>
243 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="debug/1"><strong>debug</strong>(<var>+Topic</var>)</a></dt>
244 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="nodebug/1"><strong>nodebug</strong>(<var>+Topic</var>)</a></dt>
284 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="debug/1"><strong>debug</strong>(<var>+Topic</var>)</a></dt>
285 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="nodebug/1"><strong>nodebug</strong>(<var>+Topic</var>)</a></dt>
245286 <dd class="defbody">
246287 Add/remove a topic from being printed. <code>nodebug(_)</code> removes
247288 all topics. Gives a warning if the topic is not defined unless it is
252293 can be a term <var>Topic</var> <var>&gt;</var> Out, where Out is either
253294 a stream or stream-alias or a filename (atom). This redirects debug
254295 information on this topic to the given output.</dd>
255 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_debug_topics/0"><strong>list_debug_topics</strong></a></dt>
296 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_debug_topics/0"><strong>list_debug_topics</strong></a></dt>
256297 <dd class="defbody">
257298 List currently known debug topics and their setting.</dd>
258 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="debug_message_context/1"><strong>debug_message_context</strong>(<var>+What</var>)</a></dt>
299 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="debug_message_context/1"><strong>debug_message_context</strong>(<var>+What</var>)</a></dt>
259300 <dd class="defbody">
260301 Specify additional context for debug messages. <var>What</var> is one of
261302 +Context or -Context, and Context is one of <code>thread</code>, <code>time</code>
264305 <a class="pred" href="system.html#format_time/3">format_time/3</a>
265306 (default is <code>%T.%3f</code>). Initially, <a class="pred" href="debug.html#debug/3">debug/3</a>
266307 shows only thread information.</dd>
267 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="debug/3"><strong>debug</strong>(<var>+Topic,
308 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="debug/3"><strong>debug</strong>(<var>+Topic,
268309 +Format, :Args</var>)</a></dt>
269310 <dd class="defbody">
270311 <var>Format</var> a message if debug topic is enabled. Similar to <a class="pred" href="format.html#format/3">format/3</a>
291332 </dl>
292333
293334 </dd>
294 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="prolog:debug_print_hook/3"><span class="module">prolog</span>:<strong>debug_print_hook</strong>(<var>+Topic,
335 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="prolog:debug_print_hook/3"><span class="module">prolog</span>:<strong>debug_print_hook</strong>(<var>+Topic,
295336 +Format, +Args</var>)</a></dt>
296337 <dd class="defbody">
297338 Hook called by <a class="pred" href="debug.html#debug/3">debug/3</a>.
302343 </pre>
303344
304345 </dd>
305 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assertion/1"><strong>assertion</strong>(<var>:Goal</var>)</a></dt>
346 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assertion/1"><strong>assertion</strong>(<var>:Goal</var>)</a></dt>
306347 <dd class="defbody">
307348 Acts similar to C <code>assert()</code> macro. It has no effect if <var>Goal</var>
308349 succeeds. If <var>Goal</var> fails or throws an exception, the following
323364 </ul>
324365 </ul>
325366 </dd>
326 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="prolog:assertion_failed/2"><span class="module">prolog</span>:<strong>assertion_failed</strong>(<var>+Reason,
367 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="prolog:assertion_failed/2"><span class="module">prolog</span>:<strong>assertion_failed</strong>(<var>+Reason,
327368 +Goal</var>)</a></dt>
328369 <dd class="defbody">
329370 This hook is called if the <var>Goal</var> of <a class="pred" href="debug.html#assertion/1">assertion/1</a>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.39</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.39</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="protocol.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="statistics.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:debugger"><a name="sec:4.39"><span class="sec-nr">4.39</span> <span class="sec-title">Debugging
235 <h2 id="sec:debugger"><a id="sec:4.39"><span class="sec-nr">4.39</span> <span class="sec-title">Debugging
195236 and Tracing Programs</span></a></h2>
196237
197 <a name="sec:debugger"></a>
238 <a id="sec:debugger"></a>
198239
199240 <p>This section is a reference to the debugger interaction predicates. A
200 more use-oriented overview of the debugger is in <a class="sec" href="debugoverview.html">section
241 more use-oriented overview of the debugger is in <a class="sec" href="debugoverview.html#sec:2.9">section
201242 2.9</a>.
202243
203244 <p>If you have installed XPCE, you can use the graphical front-end of
204 the tracer. This front-end is installed using the predicate <a name="idx:guitracer0:1541"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>.
245 the tracer. This front-end is installed using the predicate <a id="idx:guitracer0:1541"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>.
205246
206247 <dl class="latex">
207 <dt class="pubdef"><a name="trace/0"><strong>trace</strong></a></dt>
208 <dd class="defbody">
209 Start the tracer. <a name="idx:trace0:1542"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
248 <dt class="pubdef"><a id="trace/0"><strong>trace</strong></a></dt>
249 <dd class="defbody">
250 Start the tracer. <a id="idx:trace0:1542"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
210251 itself cannot be seen in the tracer. Note that the Prolog top level
211 treats <a name="idx:trace0:1543"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
252 treats <a id="idx:trace0:1543"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
212253 special; it means `trace the next goal'.
213254 </dd>
214 <dt class="pubdef"><a name="tracing/0"><strong>tracing</strong></a></dt>
215 <dd class="defbody">
216 True if the tracer is currently switched on. <a name="idx:tracing0:1544"></a><a class="pred" href="debugger.html#tracing/0">tracing/0</a>
255 <dt class="pubdef"><a id="tracing/0"><strong>tracing</strong></a></dt>
256 <dd class="defbody">
257 True if the tracer is currently switched on. <a id="idx:tracing0:1544"></a><a class="pred" href="debugger.html#tracing/0">tracing/0</a>
217258 itself cannot be seen in the tracer.
218259 </dd>
219 <dt class="pubdef"><a name="notrace/0"><strong>notrace</strong></a></dt>
220 <dd class="defbody">
221 Stop the tracer. <a name="idx:notrace0:1545"></a><a class="pred" href="debugger.html#notrace/0">notrace/0</a>
260 <dt class="pubdef"><a id="notrace/0"><strong>notrace</strong></a></dt>
261 <dd class="defbody">
262 Stop the tracer. <a id="idx:notrace0:1545"></a><a class="pred" href="debugger.html#notrace/0">notrace/0</a>
222263 itself cannot be seen in the tracer.
223264 </dd>
224 <dt class="pubdef"><a name="guitracer/0"><strong>guitracer</strong></a></dt>
225 <dd class="defbody">
226 Installs hooks (see <a name="idx:prologtraceinterception4:1546"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>)
265 <dt class="pubdef"><a id="guitracer/0"><strong>guitracer</strong></a></dt>
266 <dd class="defbody">
267 Installs hooks (see <a id="idx:prologtraceinterception4:1546"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>)
227268 into the system that redirect tracing information to a GUI front-end
228269 providing structured access to variable bindings, graphical overview of
229270 the stack and highlighting of relevant source code.
230271 </dd>
231 <dt class="pubdef"><a name="noguitracer/0"><strong>noguitracer</strong></a></dt>
272 <dt class="pubdef"><a id="noguitracer/0"><strong>noguitracer</strong></a></dt>
232273 <dd class="defbody">
233274 Revert back to the textual tracer.
234275 </dd>
235 <dt class="pubdef"><a name="trace/1"><strong>trace</strong>(<var>+Pred</var>)</a></dt>
276 <dt class="pubdef"><a id="trace/1"><strong>trace</strong>(<var>+Pred</var>)</a></dt>
236277 <dd class="defbody">
237278 Equivalent to <code>trace(<var>Pred</var>, +all)</code>.
238279 </dd>
239 <dt class="pubdef"><a name="trace/2"><strong>trace</strong>(<var>+Pred,
280 <dt class="pubdef"><a id="trace/2"><strong>trace</strong>(<var>+Pred,
240281 +Ports</var>)</a></dt>
241282 <dd class="defbody">
242283 Put a trace point on all predicates satisfying the predicate
247288 sign, the trace point is cleared for the port. If it is preceded by a <code><code>+</code></code>,
248289 the trace point is set.
249290
250 <p>The predicate <a name="idx:trace2:1547"></a><a class="pred" href="debugger.html#trace/2">trace/2</a>
251 activates debug mode (see <a name="idx:debug0:1548"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>).
291 <p>The predicate <a id="idx:trace2:1547"></a><a class="pred" href="debugger.html#trace/2">trace/2</a>
292 activates debug mode (see <a id="idx:debug0:1548"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>).
252293 Each time a port (of the 4-port model) is passed that has a trace point
253 set, the goal is printed as with <a name="idx:trace0:1549"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>.
254 Unlike <a name="idx:trace0:1550"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>,
294 set, the goal is printed as with <a id="idx:trace0:1549"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>.
295 Unlike <a id="idx:trace0:1550"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>,
255296 however, the execution is continued without asking for further
256297 information. Examples:
257298
258 <p><table border="0" frame="void" rules="groups" style="margin:auto">
259 <tr valign="top"><td><code>?- trace(hello).</code> </td><td>Trace all
260 ports of hello with any arity in any module. </td></tr>
261 <tr valign="top"><td><code>?- trace(foo/2, +fail).</code> </td><td>Trace
262 failures of foo/2 in any module. </td></tr>
263 <tr valign="top"><td><code>?- trace(bar/1, -all).</code> </td><td>Stop
264 tracing bar/1.</td></tr>
299 <p><table class="latex frame-void center">
300 <tr><td><code>?- trace(hello).</code> </td><td>Trace all ports of hello
301 with any arity in any module. </td></tr>
302 <tr><td><code>?- trace(foo/2, +fail).</code> </td><td>Trace failures of foo/2
303 in any module. </td></tr>
304 <tr><td><code>?- trace(bar/1, -all).</code> </td><td>Stop tracing bar/1.</td></tr>
265305 </table>
266306
267 <p>The predicate <a name="idx:debugging0:1551"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>
307 <p>The predicate <a id="idx:debugging0:1551"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>
268308 shows all currently defined trace points.</dd>
269 <dt class="pubdef"><a name="notrace/1"><strong>notrace</strong>(<var>:Goal</var>)</a></dt>
309 <dt class="pubdef"><a id="notrace/1"><strong>notrace</strong>(<var>:Goal</var>)</a></dt>
270310 <dd class="defbody">
271311 Call <var>Goal</var>, but suspend the debugger while <var>Goal</var> is
272312 executing. The current implementation cuts the choice points of <var>Goal</var>
273 after successful completion. See <a name="idx:once1:1552"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
274 Later implementations may have the same semantics as <a name="idx:call1:1553"></a><a class="pred" href="metacall.html#call/1">call/1</a>.</dd>
275 <dt class="pubdef"><a name="debug/0"><strong>debug</strong></a></dt>
313 after successful completion. See <a id="idx:once1:1552"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
314 Later implementations may have the same semantics as <a id="idx:call1:1553"></a><a class="pred" href="metacall.html#call/1">call/1</a>.</dd>
315 <dt class="pubdef"><a id="debug/0"><strong>debug</strong></a></dt>
276316 <dd class="defbody">
277317 Start debugger. In debug mode, Prolog stops at spy and trace points,
278318 disables last-call optimisation and aggressive destruction of choice
283323 enlarged to 8&nbsp;K cells if debugging is switched off in order to
284324 avoid excessive GC. GC complicates tracing because it renames the <i>_G&lt;NNN&gt;</i>
285325 variables and replaces unreachable variables with the atom
286 <code>&lt;garbage_collected&gt;</code>. Calling <a name="idx:nodebug0:1554"></a><a class="pred" href="debugger.html#nodebug/0">nodebug/0</a>
326 <code>&lt;garbage_collected&gt;</code>. Calling <a id="idx:nodebug0:1554"></a><a class="pred" href="debugger.html#nodebug/0">nodebug/0</a>
287327 does <em>not</em> reset the initial free-margin because several parts of
288328 the top level and debugger disable debugging of system code regions. See
289 also <a name="idx:setprologstack2:1555"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.</dd>
290 <dt class="pubdef"><a name="nodebug/0"><strong>nodebug</strong></a></dt>
329 also <a id="idx:setprologstack2:1555"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.</dd>
330 <dt class="pubdef"><a id="nodebug/0"><strong>nodebug</strong></a></dt>
291331 <dd class="defbody">
292332 Stop debugger. Implemented by the Prolog flag <a class="flag" href="flags.html#flag:debug">debug</a>.
293 See also <a name="idx:debug0:1556"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
294 <dt class="pubdef"><a name="debugging/0"><strong>debugging</strong></a></dt>
333 See also <a id="idx:debug0:1556"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
334 <dt class="pubdef"><a id="debugging/0"><strong>debugging</strong></a></dt>
295335 <dd class="defbody">
296336 Print debug status and spy points on current output stream. See also the
297337 Prolog flag <a class="flag" href="flags.html#flag:debug">debug</a>.
298338 </dd>
299 <dt class="pubdef"><a name="spy/1"><strong>spy</strong>(<var>+Pred</var>)</a></dt>
339 <dt class="pubdef"><a id="spy/1"><strong>spy</strong>(<var>+Pred</var>)</a></dt>
300340 <dd class="defbody">
301341 Put a spy point on all predicates meeting the predicate specification
302 <var>Pred</var>. See <a class="sec" href="listing.html">section 4.5</a>.
303 </dd>
304 <dt class="pubdef"><a name="nospy/1"><strong>nospy</strong>(<var>+Pred</var>)</a></dt>
342 <var>Pred</var>. See <a class="sec" href="listing.html#sec:4.5">section
343 4.5</a>.
344 </dd>
345 <dt class="pubdef"><a id="nospy/1"><strong>nospy</strong>(<var>+Pred</var>)</a></dt>
305346 <dd class="defbody">
306347 Remove spy point from all predicates meeting the predicate specification
307348 <var>Pred</var>.
308349 </dd>
309 <dt class="pubdef"><a name="nospyall/0"><strong>nospyall</strong></a></dt>
350 <dt class="pubdef"><a id="nospyall/0"><strong>nospyall</strong></a></dt>
310351 <dd class="defbody">
311352 Remove all spy points from the entire program.
312353 </dd>
313 <dt class="pubdef"><a name="leash/1"><strong>leash</strong>(<var>?Ports</var>)</a></dt>
354 <dt class="pubdef"><a id="leash/1"><strong>leash</strong>(<var>?Ports</var>)</a></dt>
314355 <dd class="defbody">
315356 Set/query leashing (ports which allow for user interaction). <var>Ports</var>
316357 is one of <var>+Name</var>, <var>-Name</var>, <var>?Name</var> or a list
326367 (default).
327368 <code>half</code> refers to the <code>call</code>, <code>redo</code> and <code>fail</code>
328369 port.</dd>
329 <dt class="pubdef"><a name="visible/1"><strong>visible</strong>(<var>+Ports</var>)</a></dt>
330 <dd class="defbody">
331 Set the ports shown by the debugger. See <a name="idx:leash1:1557"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>
370 <dt class="pubdef"><a id="visible/1"><strong>visible</strong>(<var>+Ports</var>)</a></dt>
371 <dd class="defbody">
372 Set the ports shown by the debugger. See <a id="idx:leash1:1557"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>
332373 for a description of the <var>Ports</var> specification. Default is <code>full</code>.</dd>
333 <dt class="pubdef"><a name="unknown/2"><strong>unknown</strong>(<var>-Old,
374 <dt class="pubdef"><a id="unknown/2"><strong>unknown</strong>(<var>-Old,
334375 +New</var>)</a></dt>
335376 <dd class="defbody">
336377 Edinburgh-Prolog compatibility predicate, interfacing to the ISO Prolog
338379 are <code>trace</code> (meaning <code>error</code>) and <code>fail</code>.
339380 If the <a class="flag" href="flags.html#flag:unknown">unknown</a> flag
340381 is set to
341 <code>warning</code>, <a name="idx:unknown2:1558"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
382 <code>warning</code>, <a id="idx:unknown2:1558"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
342383 reports the value as <code>trace</code>.</dd>
343 <dt class="pubdef"><a name="style_check/1"><strong>style_check</strong>(<var>+Spec</var>)</a></dt>
384 <dt class="pubdef"><a id="style_check/1"><strong>style_check</strong>(<var>+Spec</var>)</a></dt>
344385 <dd class="defbody">
345386 Modify/query style checking options. <var>Spec</var> is one of the terms
346387 below or a list of these.
353394 is unbound, all active style check options are returned on backtracking.
354395 </ul>
355396
356 <p>Loading a file using <a name="idx:loadfiles2:1559"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
397 <p>Loading a file using <a id="idx:loadfiles2:1559"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
357398 or one of its derived predicates reset the style checking options to
358399 their value before loading the file, scoping the option to the remainder
359400 of the file and all files loaded
362403 <dl class="latex">
363404 <dt><strong>singleton</strong>(<var>true</var>)</dt>
364405 <dd class="defbody">
365 The predicate <a name="idx:readclause3:1560"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a>
406 The predicate <a id="idx:readclause3:1560"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a>
366407 (used by the compiler to read source code) warns on variables appearing
367408 only once in a term (clause) which have a name not starting with an
368 underscore. See <a class="sec" href="syntax.html">section 2.16.1.9</a>
369 for details on variable handling and warnings.</dd>
409 underscore. See <a class="sec" href="syntax.html#sec:2.16.1.9">section
410 2.16.1.9</a> for details on variable handling and warnings.</dd>
370411 <dt><strong>no_effect</strong>(<var>true</var>)</dt>
371412 <dd class="defbody">
372413 This warning is generated by the compiler for BIPs (built-in predicates)
415456 <dd class="defbody">
416457 Warn if the clauses for a predicate are not together in the same source
417458 file. It is advised to disable the warning for discontiguous predicates
418 using the <a name="idx:discontiguous1:1561"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
459 using the <a id="idx:discontiguous1:1561"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
419460 directive.</dd>
420461 <dt><strong>charset</strong>(<var>false</var>)</dt>
421462 <dd class="defbody">
422463 Warn on atoms and variable names holding non-ASCII characters that are
423 not quoted. See also <a class="sec" href="syntax.html">section 2.16.1.1</a>.
464 not quoted. See also <a class="sec" href="syntax.html#sec:2.16.1.1">section
465 2.16.1.1</a>.
424466 </dd>
425467 </dl>
426468
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="practical.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="examples.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:debugging"><a name="sec:8.4"><span class="sec-nr">8.4</span> <span class="sec-title">Debugging</span></a></h2>
195
196 <a name="sec:debugging"></a> The CHR debugging facilities are currently
235 <h2 id="sec:debugging"><a id="sec:8.4"><span class="sec-nr">8.4</span> <span class="sec-title">Debugging</span></a></h2>
236
237 <a id="sec:debugging"></a> The CHR debugging facilities are currently
197238 rather limited. Only tracing is currently available. To use the CHR
198239 debugging facilities for a CHR file it must be compiled for debugging.
199240 Generating debug info is controlled by the CHR option <a class="flag" href="flags.html#flag:debug">debug</a>,
201242 Therefore debug info is provided unless the <strong>-nodebug</strong> is
202243 used.
203244
204 <p><h3 id="sec:chrports"><a name="sec:8.4.1"><span class="sec-nr">8.4.1</span> <span class="sec-title">Ports</span></a></h3>
205
206 <a name="sec:chrports"></a> For CHR constraints the four standard ports
245 <p><h3 id="sec:chrports"><a id="sec:8.4.1"><span class="sec-nr">8.4.1</span> <span class="sec-title">Ports</span></a></h3>
246
247 <a id="sec:chrports"></a> For CHR constraints the four standard ports
207248 are defined:
208249
209250 <dl class="latex">
256297 </dd>
257298 </dl>
258299
259 <p><h3 id="sec:chr-tracing"><a name="sec:8.4.2"><span class="sec-nr">8.4.2</span> <span class="sec-title">Tracing</span></a></h3>
260
261 <a name="sec:chr-tracing"></a> Tracing is enabled with the <a name="idx:chrtrace0:1814"></a><a class="pred" href="debugging.html#chr_trace/0">chr_trace/0</a>
262 predicate and disabled with the <a name="idx:chrnotrace0:1815"></a><a class="pred" href="debugging.html#chr_notrace/0">chr_notrace/0</a>
300 <p><h3 id="sec:chr-tracing"><a id="sec:8.4.2"><span class="sec-nr">8.4.2</span> <span class="sec-title">Tracing</span></a></h3>
301
302 <a id="sec:chr-tracing"></a> Tracing is enabled with the <a id="idx:chrtrace0:1818"></a><a class="pred" href="debugging.html#chr_trace/0">chr_trace/0</a>
303 predicate and disabled with the <a id="idx:chrnotrace0:1819"></a><a class="pred" href="debugging.html#chr_notrace/0">chr_notrace/0</a>
263304 predicate.
264305
265306 <p>When enabled the tracer will step through the <code>call</code>,
302343 </dd>
303344 <dt><strong>break</strong></dt>
304345 <dd class="defbody">
305 Enter a recursive Prolog top level. See <a name="idx:break0:1816"></a><a class="pred" href="toplevel.html#break/0">break/0</a>.
346 Enter a recursive Prolog top level. See <a id="idx:break0:1820"></a><a class="pred" href="toplevel.html#break/0">break/0</a>.
306347 </dd>
307348 <dt><strong>abort</strong></dt>
308349 <dd class="defbody">
309 Exit to the top level. See <a name="idx:abort0:1817"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
350 Exit to the top level. See <a id="idx:abort0:1821"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
310351 </dd>
311352 <dt><strong>fail</strong></dt>
312353 <dd class="defbody">
318359 </dd>
319360 </dl>
320361
321 <p><h3 id="sec:predicates"><a name="sec:8.4.3"><span class="sec-nr">8.4.3</span> <span class="sec-title">CHR
362 <p><h3 id="sec:predicates"><a id="sec:8.4.3"><span class="sec-nr">8.4.3</span> <span class="sec-title">CHR
322363 Debugging Predicates</span></a></h3>
323364
324 <a name="sec:predicates"></a> The <code>library(chr)</code> module
365 <a id="sec:predicates"></a> The <code>library(chr)</code> module
325366 contains several predicates that allow inspecting and printing the
326367 content of the constraint store.
327368
328369 <dl class="latex">
329 <dt class="pubdef"><a name="chr_trace/0"><strong>chr_trace</strong></a></dt>
370 <dt class="pubdef"><a id="chr_trace/0"><strong>chr_trace</strong></a></dt>
330371 <dd class="defbody">
331372 Activate the CHR tracer. By default the CHR tracer is activated and
332 deactivated automatically by the Prolog predicates <a name="idx:trace0:1818"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
373 deactivated automatically by the Prolog predicates <a id="idx:trace0:1822"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
333374 and
334 <a name="idx:notrace0:1819"></a><a class="pred" href="debugger.html#notrace/0">notrace/0</a>.</dd>
335 <dt class="pubdef"><a name="chr_notrace/0"><strong>chr_notrace</strong></a></dt>
375 <a id="idx:notrace0:1823"></a><a class="pred" href="debugger.html#notrace/0">notrace/0</a>.</dd>
376 <dt class="pubdef"><a id="chr_notrace/0"><strong>chr_notrace</strong></a></dt>
336377 <dd class="defbody">
337378 Deactivate the CHR tracer. By default the CHR tracer is activated and
338 deactivated automatically by the Prolog predicates <a name="idx:trace0:1820"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
379 deactivated automatically by the Prolog predicates <a id="idx:trace0:1824"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
339380 and
340 <a name="idx:notrace0:1821"></a><a class="pred" href="debugger.html#notrace/0">notrace/0</a>.</dd>
341 <dt class="pubdef"><a name="chr_leash/1"><strong>chr_leash</strong>(<var>+Spec</var>)</a></dt>
381 <a id="idx:notrace0:1825"></a><a class="pred" href="debugger.html#notrace/0">notrace/0</a>.</dd>
382 <dt class="pubdef"><a id="chr_leash/1"><strong>chr_leash</strong>(<var>+Spec</var>)</a></dt>
342383 <dd class="defbody">
343384 Define the set of CHR ports on which the CHR tracer asks for user
344385 intervention (i.e. stops). <var>Spec</var> is either a list of ports as
345 defined in <a class="sec" href="debugging.html">section 8.4.1</a> or a
346 predefined `alias'. Defined aliases are: <code>full</code> to stop at
347 all ports, <code>none</code> or <code>off</code> to never stop, and <code>default</code>
386 defined in <a class="sec" href="debugging.html#sec:8.4.1">section 8.4.1</a>
387 or a predefined `alias'. Defined aliases are: <code>full</code> to stop
388 at all ports, <code>none</code> or <code>off</code> to never stop, and <code>default</code>
348389 to stop at the <code>call</code>,
349390 <code>exit</code>, <code>fail</code>, <code>wake</code> and <code>apply</code>
350 ports. See also <a name="idx:leash1:1822"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>.</dd>
351 <dt class="pubdef"><a name="chr_show_store/1"><strong>chr_show_store</strong>(<var>+Mod</var>)</a></dt>
391 ports. See also <a id="idx:leash1:1826"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>.</dd>
392 <dt class="pubdef"><a id="chr_show_store/1"><strong>chr_show_store</strong>(<var>+Mod</var>)</a></dt>
352393 <dd class="defbody">
353394 Prints all suspended constraints of module <var>Mod</var> to the
354395 standard output. This predicate is automatically called by the
357398 <code>chr_toplevel_show_store</code> controls whether the top level
358399 shows the constraint stores. The value <code>true</code> enables it. Any
359400 other value disables it.</dd>
360 <dt class="pubdef"><a name="find_chr_constraint/1"><strong>find_chr_constraint</strong>(<var>-Constraint</var>)</a></dt>
401 <dt class="pubdef"><a id="find_chr_constraint/1"><strong>find_chr_constraint</strong>(<var>-Constraint</var>)</a></dt>
361402 <dd class="defbody">
362403 Returns a constraint in the constraint store. Via backtracking, all
363404 constraints in the store can be enumerated.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.9</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="topvars.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="compilation.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:debugoverview"><a name="sec:2.9"><span class="sec-nr">2.9</span> <span class="sec-title">Overview
235 <h2 id="sec:debugoverview"><a id="sec:2.9"><span class="sec-nr">2.9</span> <span class="sec-title">Overview
195236 of the Debugger</span></a></h2>
196237
197 <a name="sec:debugoverview"></a>
238 <a id="sec:debugoverview"></a>
198239
199240 <p>SWI-Prolog has a 6-port tracer, extending the standard 4-port tracer
200241 <cite><a class="cite" href="Bibliography.html#Byrd:80">Byrd, 1980</a>, <a class="cite" href="Bibliography.html#Clocksin:87">Clocksin &amp;
201242 Melish, 1987</a></cite> with two additional ports. The optional
202243 <var>unify</var> port allows the user to inspect the result after
203244 unification of the head. The <var>exception</var> port shows exceptions
204 raised by <a name="idx:throw1:54"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
205 or one of the built-in predicates. See <a class="sec" href="exception.html">section
245 raised by <a id="idx:throw1:54"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
246 or one of the built-in predicates. See <a class="sec" href="exception.html#sec:4.11">section
206247 4.11</a>.
207248
208249 <p>The standard ports are called <code>call</code>, <code>exit</code>, <code>redo</code>,
209 <code>fail</code> and <code>unify</code>. The tracer is started by the <a name="idx:trace0:55"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
250 <code>fail</code> and <code>unify</code>. The tracer is started by the <a id="idx:trace0:55"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
210251 command, when a spy point is reached and the system is in debugging mode
211 (see <a name="idx:spy1:56"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
212 and <a name="idx:debug0:57"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>),
252 (see <a id="idx:spy1:56"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
253 and <a id="idx:debug0:57"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>),
213254 or when an exception is raised that is not caught.
214255
215 <p>The interactive top-level goal <a name="idx:trace0:58"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
256 <p>The interactive top-level goal <a id="idx:trace0:58"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
216257 means ``trace the next query''. The tracer shows the port, displaying
217258 the port name, the current depth of the recursion and the goal. The goal
218 is printed using the Prolog predicate <a name="idx:writeterm2:59"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
259 is printed using the Prolog predicate <a id="idx:writeterm2:59"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
219260 The style is defined by the Prolog flag
220261 <a class="flag" href="flags.html#flag:debugger_write_options">debugger_write_options</a>
221262 and can be modified using this flag or using the <code>w</code>, <code>p</code>
252293
253294 <div class="caption"><b>Figure 2 : </b>Example trace of the program
254295 above showing all ports. The lines marked <code><code>^</code></code>
255 indicate calls to <em>transparent</em> predicates. See <a class="sec" href="modules.html">section
296 indicate calls to <em>transparent</em> predicates. See <a class="sec" href="modules.html#sec:6">section
256297 6</a>.</div>
257 <a name="fig:tracer"></a>
258
259 <p>On <em>leashed ports</em> (set with the predicate <a name="idx:leash1:60"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>,
298 <a id="fig:tracer"></a>
299
300 <p>On <em>leashed ports</em> (set with the predicate <a id="idx:leash1:60"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>,
260301 default are
261302 <code>call</code>, <code>exit</code>, <code>redo</code> and <code>fail</code>)
262303 the user is prompted for an action. All actions are single-character
266307 <dl class="latex">
267308 <dt><strong>Spy</strong> (<code>+</code>)</dt>
268309 <dd class="defbody">
269 Set a spy point (see <a name="idx:spy1:61"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
310 Set a spy point (see <a id="idx:spy1:61"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
270311 on the current predicate.
271312 </dd>
272313 <dt><strong>No spy</strong> (<code>-</code>)</dt>
273314 <dd class="defbody">
274 Remove the spy point (see <a name="idx:nospy1:62"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>)
315 Remove the spy point (see <a id="idx:nospy1:62"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>)
275316 from the current predicate.
276317 </dd>
277318 <dt><strong>Find</strong> (<code>/</code>)</dt>
282323 unify with the goal run by the port. If no term is specified it is taken
283324 as a variable, searching for any port of the specified type. If an atom
284325 is given, any goal whose functor has a name equal to that atom matches.
285 Examples:
286 <div style="text-align:center"><table border="0" frame="void" rules="groups">
287 <tr valign="top"><td><code>/f</code></td><td>Search for any fail port </td></tr>
288 <tr valign="top"><td><code>/fe solve</code></td><td>Search for a fail or
289 exit port of any goal with name <code>solve</code> </td></tr>
290 <tr valign="top"><td><code>/c solve(a, _)</code></td><td>Search for a
291 call to solve/2 whose first argument is a variable or the atom <code>a</code> </td></tr>
292 <tr valign="top"><td><code>/a member(_, _)</code></td><td>Search for any
293 port on <a name="idx:member2:63"></a><a class="pred" href="lists.html#member/2">member/2</a>.
294 This is equivalent to setting a spy point on <a name="idx:member2:64"></a><a class="pred" href="lists.html#member/2">member/2</a>. </td></tr>
326 Examples: <table class="latex frame-void center">
327 <tr><td><code>/f</code></td><td>Search for any fail port </td></tr>
328 <tr><td><code>/fe solve</code></td><td>Search for a fail or exit port of
329 any goal with name <code>solve</code> </td></tr>
330 <tr><td><code>/c solve(a, _)</code></td><td>Search for a call to solve/2
331 whose first argument is a variable or the atom <code>a</code> </td></tr>
332 <tr><td><code>/a member(_, _)</code></td><td>Search for any port on <a id="idx:member2:63"></a><a class="pred" href="lists.html#member/2">member/2</a>.
333 This is equivalent to setting a spy point on <a id="idx:member2:64"></a><a class="pred" href="lists.html#member/2">member/2</a>. </td></tr>
295334 </table>
296 </div>
297335 </dd>
298336 <dt><strong>Repeat find</strong> (<code>.</code>)</dt>
299337 <dd class="defbody">
306344 <dt><strong>Context</strong> (<code>C</code>)</dt>
307345 <dd class="defbody">
308346 Toggle `Show Context'. If <code>on</code>, the context module of the
309 goal is displayed between square brackets (see <a class="sec" href="modules.html">section
347 goal is displayed between square brackets (see <a class="sec" href="modules.html#sec:6">section
310348 6</a>). Default is <code>off</code>.
311349 </dd>
312350 <dt><strong>Listing</strong> (<code>L</code>)</dt>
313351 <dd class="defbody">
314 List the current predicate with <a name="idx:listing1:65"></a><a class="pred" href="listing.html#listing/1">listing/1</a>.
352 List the current predicate with <a id="idx:listing1:65"></a><a class="pred" href="listing.html#listing/1">listing/1</a>.
315353 </dd>
316354 <dt><strong>Abort</strong> (<code>a</code>)</dt>
317355 <dd class="defbody">
318 Abort Prolog execution (see <a name="idx:abort0:66"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
356 Abort Prolog execution (see <a id="idx:abort0:66"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
319357 </dd>
320358 <dt><strong>Break</strong> (<code>b</code>)</dt>
321359 <dd class="defbody">
322 Enter a Prolog break environment (see <a name="idx:break0:67"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
360 Enter a Prolog break environment (see <a id="idx:break0:67"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
323361 </dd>
324362 <dt><strong>Creep</strong> (<code>c</code>)</dt>
325363 <dd class="defbody">
333371 </dd>
334372 <dt><strong>Exit</strong> (<code>e</code>)</dt>
335373 <dd class="defbody">
336 Terminate Prolog (see <a name="idx:halt0:68"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>).
374 Terminate Prolog (see <a id="idx:halt0:68"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>).
337375 </dd>
338376 <dt><strong>Fail</strong> (<code>f</code>)</dt>
339377 <dd class="defbody">
387425 <dd class="defbody">
388426 Set the Prolog flag <a class="flag" href="flags.html#flag:debugger_write_options">debugger_write_options</a>
389427 to <code>[quoted(true), attributes(write), priority(699)]</code>,
390 bypassing <a name="idx:portray1:69"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>,
428 bypassing <a id="idx:portray1:69"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>,
391429 etc.
392430 </dd>
393431 </dl>
399437 because code optimisation removes part of the choice and exit points.
400438 Backtrack points are not shown if either the goal succeeded
401439 deterministically or its alternatives were removed using the cut. When
402 running in debug mode (<a name="idx:debug0:70"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>)
440 running in debug mode (<a id="idx:debug0:70"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>)
403441 choice points are only destroyed when removed by the cut. In debug mode,
404442 last call optimisation is switched off.<sup class="fn">13<span class="fn-text">This
405443 implies the system can run out of stack in debug mode, while no problems
406444 arise when running in non-debug mode.</span></sup>
407445
408446 <p>Reference information to all predicates available for manipulating
409 the debugger is in <a class="sec" href="debugger.html">section 4.39</a>.
447 the debugger is in <a class="sec" href="debugger.html#sec:4.39">section
448 4.39</a>.
410449
411450 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="whymodules.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="import.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:defmodule"><a name="sec:6.2"><span class="sec-nr">6.2</span> <span class="sec-title">Defining
235 <h2 id="sec:defmodule"><a id="sec:6.2"><span class="sec-nr">6.2</span> <span class="sec-title">Defining
195236 a Module</span></a></h2>
196237
197 <a name="sec:defmodule"></a>
238 <a id="sec:defmodule"></a>
198239
199240 <p>Modules are normally created by loading a <em>module file</em>. A
200 module file is a file holding a <a name="idx:module2:1660"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
241 module file is a file holding a <a id="idx:module2:1664"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
201242 directive as its first term. The
202 <a name="idx:module2:1661"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
243 <a id="idx:module2:1665"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
203244 directive declares the name and the public (i.e., externally visible)
204245 predicates of the module. The rest of the file is loaded into the
205 module. Below is an example of a module file, defining <a name="idx:reverse2:1662"></a><a class="pred" href="lists.html#reverse/2">reverse/2</a>
206 and hiding the helper predicate <a name="idx:rev3:1663"></a><span class="pred-ext">rev/3</span>.
246 module. Below is an example of a module file, defining <a id="idx:reverse2:1666"></a><a class="pred" href="lists.html#reverse/2">reverse/2</a>
247 and hiding the helper predicate <a id="idx:rev3:1667"></a><span class="pred-ext">rev/3</span>.
207248 A module can use all built-in predicates and, by default, cannot
208249 redefine system predicates.
209250
227268 module explicitly in the source text.
228269
229270 <dl class="latex">
230 <dt class="pubdef"><a name="module/2">:- <strong>module</strong>(<var>+Module,
271 <dt class="pubdef"><a id="module/2">:- <strong>module</strong>(<var>+Module,
231272 +PublicList</var>)</a></dt>
232273 <dd class="defbody">
233274 This directive can only be used as the first term of a source file. It
237278 is a list of predicate indicators (name/arity or name//arity pairs) or
238279 operator declarations using the format <code>op(Precedence, Type, Name)</code>.
239280 Operators defined in the export list are available inside the module as
240 well as to modules importing this module. See also <a class="sec" href="operators.html">section
281 well as to modules importing this module. See also <a class="sec" href="operators.html#sec:4.25">section
241282 4.25</a>.
242283
243284 <p>Compatible to Ciao Prolog, if <var>Module</var> is unbound, it is
244285 unified with the basename without extension of the file being loaded.</dd>
245 <dt class="pubdef"><a name="module/3">:- <strong>module</strong>(<var>+Module,
286 <dt class="pubdef"><a id="module/3">:- <strong>module</strong>(<var>+Module,
246287 +PublicList, +Dialect</var>)</a></dt>
247288 <dd class="defbody">
248 Same as <a name="idx:module2:1664"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
289 Same as <a id="idx:module2:1668"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
249290 The additional <var>Dialect</var> argument provides a list of <em>language
250 options</em>. Each atom in the list <var>Dialect</var> is mapped to a <a name="idx:usemodule1:1665"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
251 goal as given below. See also <a class="sec" href="dialect.html">section
291 options</em>. Each atom in the list <var>Dialect</var> is mapped to a <a id="idx:usemodule1:1669"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
292 goal as given below. See also <a class="sec" href="dialect.html#sec:C">section
252293 C</a>. The third argument is supported for compatibility with the
253 http://prolog-commons.org/Prolog Commons project .
294 <a class="url" href="http://prolog-commons.org/">Prolog Commons project</a>.
254295
255296 <pre class="code">
256297 :- use_module(library(dialect/LangOption)).
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.10</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="metacall.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="exception.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:delcont"><a name="sec:4.10"><span class="sec-nr">4.10</span> <span class="sec-title">Delimited
235 <h2 id="sec:delcont"><a id="sec:4.10"><span class="sec-nr">4.10</span> <span class="sec-title">Delimited
195236 continuations</span></a></h2>
196237
197 <a name="sec:delcont"></a>
198
199 <p>The predicates <a name="idx:reset3:678"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
200 and <a name="idx:shift1:679"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
238 <a id="sec:delcont"></a>
239
240 <p>The predicates <a id="idx:reset3:678"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
241 and <a id="idx:shift1:679"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
201242 implement <em>delimited continuations</em> for Prolog. Delimited
202243 continuation for Prolog is described in <cite><a class="cite" href="Bibliography.html#DBLP:journals/tplp/SchrijversDDW13">Schrijvers <em>et
203244 al.</em>, 2013</a></cite>. The mechanism allows for proper <em>coroutines</em>,
204245 two or more routines whose execution is interleaved, while they exchange
205246 data. Note that coroutines in this sense differ from coroutines realised
206 using attributed variables as described in&nbsp;<a class="sec" href="clp.html">chapter
247 using attributed variables as described in&nbsp;<a class="sec" href="clp.html#sec:7">chapter
207248 7</a>.
208249
209250 <p>The suspension mechanism provided by delimited continuations is
212253 al.</em>, 2015</a></cite>, see library <code>library(tabling)</code>.
213254
214255 <dl class="latex">
215 <dt class="pubdef"><a name="reset/3"><strong>reset</strong>(<var>:Goal,
256 <dt class="pubdef"><a id="reset/3"><strong>reset</strong>(<var>:Goal,
216257 ?Ball, -Continuation</var>)</a></dt>
217258 <dd class="defbody">
218 Call <var>Goal</var>. If <var>Goal</var> calls <a name="idx:shift1:680"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
219 and the argument of <a name="idx:shift1:681"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
259 Call <var>Goal</var>. If <var>Goal</var> calls <a id="idx:shift1:680"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
260 and the argument of <a id="idx:shift1:681"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
220261 can be unified with <var>Ball</var>,<sup class="fn">67<span class="fn-text">The
221262 argument order described in <cite><a class="cite" href="Bibliography.html#DBLP:journals/tplp/SchrijversDDW13">Schrijvers <em>et
222263 al.</em>, 2013</a></cite> is <code>reset(Goal,Continuation,Ball)</code>.
223 We swapped the argument order for compatibility with <a name="idx:catch3:682"></a><a class="pred" href="exception.html#catch/3">catch/3</a></span></sup> <a name="idx:shift1:683"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
224 causes <a name="idx:reset3:684"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
264 We swapped the argument order for compatibility with <a id="idx:catch3:682"></a><a class="pred" href="exception.html#catch/3">catch/3</a></span></sup> <a id="idx:shift1:683"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
265 causes <a id="idx:reset3:684"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
225266 to return, unifying
226267 <var>Continuation</var> with a goal that represents the <em>continuation</em>
227 after <a name="idx:shift1:685"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>.
268 after <a id="idx:shift1:685"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>.
228269 In other words, meta-calling <var>Continuation</var> completes the
229 execution where shift left it. If <var>Goal</var> does not call <a name="idx:shift1:686"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>,
270 execution where shift left it. If <var>Goal</var> does not call <a id="idx:shift1:686"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>,
230271 <var>Continuation</var> are unified with the integer <code>0</code>
231272 (zero).<sup class="fn">68<span class="fn-text">Note that older versions
232273 also unify <var>Ball</var> with <code>0</code>. Testing whether or not
233274 shift happened on <var>Ball</var> however is <em>always</em> ambiguous.</span></sup></dd>
234 <dt class="pubdef"><a name="shift/1"><strong>shift</strong>(<var>+Ball</var>)</a></dt>
275 <dt class="pubdef"><a id="shift/1"><strong>shift</strong>(<var>+Ball</var>)</a></dt>
235276 <dd class="defbody">
236277 Abandon the execution of the current goal, returning control to just
237 <em>after</em> the matching <a name="idx:reset3:687"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
238 call. This is similar to <a name="idx:throw1:688"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
278 <em>after</em> the matching <a id="idx:reset3:687"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
279 call. This is similar to <a id="idx:throw1:688"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
239280 except that (1) nothing is `undone' and (2) the 3th argument of
240 <a name="idx:reset3:689"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
241 is unified with the <em>continuation</em>, which allows the code calling <a name="idx:reset3:690"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
281 <a id="idx:reset3:689"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
282 is unified with the <em>continuation</em>, which allows the code calling <a id="idx:reset3:690"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
242283 to <em>resume</em> the current goal.
243284 </dd>
244285 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="loadfilehook.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="portabilitystrategies.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:dialect"><a name="sec:C"><span class="sec-nr">C</span> <span class="sec-title">Compatibility
235 <h1 id="sec:dialect"><a id="sec:C"><span class="sec-nr">C</span> <span class="sec-title">Compatibility
195236 with other Prolog dialects</span></a></h1>
196237
197 <a name="sec:dialect"></a>
198
199 <p><a name="idx:YAPprolog:2243"></a><a name="idx:portableprologcode:2244"></a>This
238 <a id="sec:dialect"></a>
239
240 <p><a id="idx:YAPprolog:2247"></a><a id="idx:portableprologcode:2248"></a>This
200241 chapter explains issues for writing portable Prolog programs. It was
201242 started after discussion with Vitor Santos Costa, the leading developer
202 of YAP Prolog<sup class="fn">187<span class="fn-text"><a class="url" href="http://yap.sourceforge.net/">http://yap.sourceforge.net/</a></span></sup>
243 of YAP Prolog<sup class="fn">188<span class="fn-text"><a class="url" href="http://yap.sourceforge.net/">http://yap.sourceforge.net/</a></span></sup>
203244 YAP and SWI-Prolog have expressed the ambition to enhance the
204245 portability beyond the trivial Prolog examples, including complex
205246 libraries involving foreign code.
225266
226267 <p>
227268 <li>Conditional compilation using <code>:- if(Condition)</code> ...<code>:-
228 endif</code> is supported. See <a class="sec" href="consulting.html">section
269 endif</code> is supported. See <a class="sec" href="consulting.html#sec:4.3.1.2">section
229270 4.3.1.2</a>.
230271
231272 <p>
232 <li>The predicate <a name="idx:expectsdialect1:2245"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
273 <li>The predicate <a id="idx:expectsdialect1:2249"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
233274 allows for specifying for which Prolog system the code was written.
234275
235276 <p>
236 <li>The predicates <a name="idx:existssource1:2246"></a><a class="pred" href="dialect.html#exists_source/1">exists_source/1</a>
237 and <a name="idx:sourceexports2:2247"></a><a class="pred" href="dialect.html#source_exports/2">source_exports/2</a>
238 can be used to query the library content. The <a name="idx:require1:2248"></a><a class="pred" href="consulting.html#require/1">require/1</a>
277 <li>The predicates <a id="idx:existssource1:2250"></a><a class="pred" href="dialect.html#exists_source/1">exists_source/1</a>
278 and <a id="idx:sourceexports2:2251"></a><a class="pred" href="dialect.html#source_exports/2">source_exports/2</a>
279 can be used to query the library content. The <a id="idx:require1:2252"></a><a class="pred" href="consulting.html#require/1">require/1</a>
239280 directive can be used to get access to predicates without knowing their
240281 location.
241282
242283 <p>
243 <li>The module predicates <a name="idx:usemodule1:2249"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>, <a name="idx:usemodule2:2250"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
284 <li>The module predicates <a id="idx:usemodule1:2253"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>, <a id="idx:usemodule2:2254"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
244285 have been extended with a notion for `import-except' and `import-as'.
245 This is particularly useful together with <a name="idx:reexport1:2251"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
246 and <a name="idx:reexport2:2252"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>
286 This is particularly useful together with <a id="idx:reexport1:2255"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
287 and <a id="idx:reexport2:2256"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>
247288 to compose modules from other modules and mapping names.
248289
249290 <p>
252293 </ul>
253294
254295 <dl class="latex">
255 <dt class="pubdef"><a name="expects_dialect/1">:- <strong>expects_dialect</strong>(<var>+Dialect</var>)</a></dt>
296 <dt class="pubdef"><a id="expects_dialect/1">:- <strong>expects_dialect</strong>(<var>+Dialect</var>)</a></dt>
256297 <dd class="defbody">
257298 This directive states that the code following the directive is written
258299 for the given Prolog <var>Dialect</var>. See also <a class="flag" href="flags.html#flag:dialect">dialect</a>.
259300 The declaration holds until the end of the file in which it appears. The
260 current dialect is available using <a name="idx:prologloadcontext2:2253"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>.
301 current dialect is available using <a id="idx:prologloadcontext2:2257"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>.
261302
262303 <p>The exact behaviour of this predicate is still subject to discussion.
263304 Of course, if <var>Dialect</var> matches the running dialect the
270311 <li>Define system predicates of the requested dialect we do not have.
271312
272313 <p>
273 <li>Apply <a name="idx:goalexpansion2:2254"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
314 <li>Apply <a id="idx:goalexpansion2:2258"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
274315 rules that map conflicting predicates to versions emulating the
275316 requested dialect. These expansion rules reside in the dialect
276317 compatibility module, but are applied if prolog_load_context(dialect,
284325 <li>Setup support for the default filename extension of the dialect.
285326 </ul>
286327 </dd>
287 <dt class="pubdef"><a name="exists_source/1"><strong>exists_source</strong>(<var>+Spec</var>)</a></dt>
328 <dt class="pubdef"><a id="exists_source/1"><strong>exists_source</strong>(<var>+Spec</var>)</a></dt>
288329 <dd class="defbody">
289330 Is true if <var>Spec</var> exists as a Prolog source. <var>Spec</var>
290 uses the same conventions as <a name="idx:loadfiles2:2255"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
331 uses the same conventions as <a id="idx:loadfiles2:2259"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
291332 Fails without error if <var>Spec</var> cannot be found.</dd>
292 <dt class="pubdef"><a name="source_exports/2"><strong>source_exports</strong>(<var>+Spec,
333 <dt class="pubdef"><a id="source_exports/2"><strong>source_exports</strong>(<var>+Spec,
293334 +Export</var>)</a></dt>
294335 <dd class="defbody">
295336 Is true if source <var>Spec</var> exports <var>Export</var>, a predicate
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 5.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ext-syntax.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ext-integration.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:dicts"><a name="sec:5.4"><span class="sec-nr">5.4</span> <span class="sec-title">Dicts:
235 <h2 id="sec:dicts"><a id="sec:5.4"><span class="sec-nr">5.4</span> <span class="sec-title">Dicts:
195236 structures with named arguments</span></a></h2>
196237
197 <a name="sec:dicts"></a>
238 <a id="sec:dicts"></a>
198239
199240 <p>SWI-Prolog version&nbsp;7 introduces dicts as an abstract object with
200241 a concrete modern syntax and functional notation for accessing members
213254 into an opaque internal representation that does <em>not</em> respect
214255 the order in which the key-value pairs appear in the input text. If a
215256 dict is written, the keys are written according to the standard order of
216 terms (see <a class="sec" href="compare.html">section 4.7.1</a>). Here
217 are some examples, where the second example illustrates that the order
218 is not maintained and the third illustrates an anonymous dict.
257 terms (see <a class="sec" href="compare.html#sec:4.7.1">section 4.7.1</a>).
258 Here are some examples, where the second example illustrates that the
259 order is not maintained and the third illustrates an anonymous dict.
219260
220261 <pre class="code">
221262 ?- A = point{x:1, y:2}.
247288 into a new dict that has the union of the keys of the two original
248289 dicts.
249290
250 <p><h3 id="sec:ext-dict-functions"><a name="sec:5.4.1"><span class="sec-nr">5.4.1</span> <span class="sec-title">Functions
291 <p><h3 id="sec:ext-dict-functions"><a id="sec:5.4.1"><span class="sec-nr">5.4.1</span> <span class="sec-title">Functions
251292 on dicts</span></a></h3>
252293
253 <a name="sec:ext-dict-functions"></a>
294 <a id="sec:ext-dict-functions"></a>
254295
255296 <p>The infix operator dot (<code>op(100, yfx, .)</code> is used to
256297 extract values and evaluate functions on dicts. Functions are recognised
295336
296337 <p>Note that expansion of <code><code>.</code>/2</code> terms implies
297338 that such terms cannot be created by writing them explicitly in your
298 source code. Such terms can still be created with <a name="idx:functor3:1631"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>, <a class="pred" href="manipterm.html#=../2">=../2</a>,
299 <a name="idx:compoundnamearity3:1632"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
339 source code. Such terms can still be created with <a id="idx:functor3:1631"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>, <a class="pred" href="manipterm.html#=../2">=../2</a>,
340 <a id="idx:compoundnamearity3:1632"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
300341 and
301 <a name="idx:compoundnamearguments3:1633"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.<sup class="fn">149<span class="fn-text">Traditional
342 <a id="idx:compoundnamearguments3:1633"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.<sup class="fn">149<span class="fn-text">Traditional
302343 code is unlikely to use <code><code>.</code>/2</code> terms because they
303344 were practically reserved for usage in lists. We do not provide a
304345 quoting mechanism as found in functional languages because it would only
306347 rare and term manipulation provides an escape route.</span></sup>
307348
308349 <dl class="latex">
309 <dt class="pubdef"><a name="./3"><strong>.</strong>(<var>+Dict,
310 +Function, -Result</var>)</a></dt>
350 <dt class="pubdef"><a id="./3"><strong>.</strong>(<var>+Dict, +Function,
351 -Result</var>)</a></dt>
311352 <dd class="defbody">
312353 This predicate is called to evaluate <code><code>.</code>/2</code> terms
313354 found in the arguments of a goal. This predicate evaluates the field
314 extraction described above, which is mapped to <a name="idx:getdictex3:1634"></a><span class="pred-ext">get_dict_ex/3</span>.
355 extraction described above, which is mapped to <a id="idx:getdictex3:1634"></a><span class="pred-ext">get_dict_ex/3</span>.
315356 If <var>Function</var> is a compound term, it checks for the predefined
316 functions on dicts described in <a class="sec" href="dicts.html">section
317 5.4.1.2</a> or executes a user defined function as described in <a class="sec" href="dicts.html">section
357 functions on dicts described in <a class="sec" href="dicts.html#sec:5.4.1.2">section
358 5.4.1.2</a> or executes a user defined function as described in <a class="sec" href="dicts.html#sec:5.4.1.1">section
318359 5.4.1.1</a>.
319360 </dd>
320361 </dl>
321362
322 <p><h4 id="sec:ext-dict-user-functions"><a name="sec:5.4.1.1"><span class="sec-nr">5.4.1.1</span> <span class="sec-title">User
363 <p><h4 id="sec:ext-dict-user-functions"><a id="sec:5.4.1.1"><span class="sec-nr">5.4.1.1</span> <span class="sec-title">User
323364 defined functions on dicts</span></a></h4>
324365
325 <a name="sec:ext-dict-user-functions"></a>
366 <a id="sec:ext-dict-user-functions"></a>
326367
327368 <p>The tag of a dict associates the dict to a module. If the dot
328369 notation uses a compound term, this calls the goal below.
336377 predicates without worrying about the argument calling conventions. The
337378 code below defines a function <code>multiply(Times)</code> on a point
338379 that creates a new point by multiplying both coordinates. and <code>len()</code><sup class="fn">150<span class="fn-text">as <code>length()</code>
339 would result in a predicate <a name="idx:length2:1635"></a><a class="pred" href="builtinlist.html#length/2">length/2</a>,
380 would result in a predicate <a id="idx:length2:1635"></a><a class="pred" href="builtinlist.html#length/2">length/2</a>,
340381 this name cannot be used. This might change in future versions.</span></sup>
341382 to compute the length from the origin. The . and <code>:=</code>
342383 operators are used to abstract the location of the predicate arguments.
364405 X = 4.47213595499958.
365406 </pre>
366407
367 <p><h4 id="sec:ext-dicts-predefined"><a name="sec:5.4.1.2"><span class="sec-nr">5.4.1.2</span> <span class="sec-title">Predefined
408 <p><h4 id="sec:ext-dicts-predefined"><a id="sec:5.4.1.2"><span class="sec-nr">5.4.1.2</span> <span class="sec-title">Predefined
368409 functions on dicts</span></a></h4>
369410
370 <a name="sec:ext-dicts-predefined"></a>
411 <a id="sec:ext-dicts-predefined"></a>
371412
372413 <p>Dicts currently define the following reserved functions:
373414
374415 <dl class="latex">
416 <dt class="pubdef"><a id="m-get-1"><strong>get</strong>(<var>?Key</var>)</a></dt>
417 <dd class="defbody">
418 Same as <var>Dict</var>.<var>Key</var>, but maps to <a id="idx:getdict3:1636"></a><a class="pred" href="dicts.html#get_dict/3">get_dict/3</a>
419 instead of
420 <a id="idx:getdictex3:1637"></a><span class="pred-ext">get_dict_ex/3</span>.
421 This implies that the function evaluation fails silently if <var>Key</var>
422 does not appear in <var>Dict</var>. See also
423 <a class="pred" href="dicts.html#:</2">:&lt;/2</a>, which can be used to
424 test for existence and unify multiple key values from a dict. For
425 example:
426
427 <pre class="code">
428 ?- write(t{a:x}.get(a)).
429 x
430 ?- write(t{a:x}.get(b)).
431 false.
432 </pre>
433
434 </dd>
435 <dt class="pubdef"><a id="m-put-1"><strong>put</strong>(<var>+New</var>)</a></dt>
436 <dd class="defbody">
437 Evaluates to a new dict where the key-values in <var>New</var> replace
438 or extend the key-values in the original dict. See <a id="idx:putdict3:1638"></a><a class="pred" href="dicts.html#put_dict/3">put_dict/3</a>.</dd>
439 <dt class="pubdef"><a id="m-put-2"><strong>put</strong>(<var>+KeyPath,
440 +Value</var>)</a></dt>
441 <dd class="defbody">
442 Evaluates to a new dict where the <var>KeyPath</var>-<var>Value</var>
443 replaces or extends the key-values in the original dict. <var>KeyPath</var>
444 is either a key or a term <var>KeyPath</var>/<var>Key</var>,<sup class="fn">151<span class="fn-text">Note
445 that we do not use the '.' functor here, because the <code><code>.</code>/2</code>
446 would <em>evaluate</em>.</span></sup> replacing the value associated
447 with <var>Key</var> in a sub-dict of the dict on which the function
448 operates. See <a id="idx:putdict4:1639"></a><a class="pred" href="dicts.html#put_dict/4">put_dict/4</a>.
449 Below are some examples:
450
451 <pre class="code">
452 ?- A = _{}.put(a, 1).
453 A = _G7359{a:1}.
454
455 ?- A = _{a:1}.put(a, 2).
456 A = _G7377{a:2}.
457
458 ?- A = _{a:1}.put(b/c, 2).
459 A = _G1395{a:1, b:_G1584{c:2}}.
460
461 ?- A = _{a:_{b:1}}.put(a/b, 2).
462 A = _G1429{a:_G1425{b:2}}.
463
464 ?- A = _{a:1}.put(a/b, 2).
465 A = _G1395{a:_G1578{b:2}}.
466 </pre>
467
468 <p></dd>
375469 </dl>
376470
377 <p><h3 id="sec:ext-dict-predicates"><a name="sec:5.4.2"><span class="sec-nr">5.4.2</span> <span class="sec-title">Predicates
471 <p><h3 id="sec:ext-dict-predicates"><a id="sec:5.4.2"><span class="sec-nr">5.4.2</span> <span class="sec-title">Predicates
378472 for managing dicts</span></a></h3>
379473
380 <a name="sec:ext-dict-predicates"></a>
474 <a id="sec:ext-dict-predicates"></a>
381475
382476 <p>This section documents the predicates that are defined on dicts. We
383477 use the naming and argument conventions of the traditional <code>library(assoc)</code>.
384478
385479 <dl class="latex">
386 <dt class="pubdef"><a name="is_dict/1"><strong>is_dict</strong>(<var>@Term</var>)</a></dt>
480 <dt class="pubdef"><a id="is_dict/1"><strong>is_dict</strong>(<var>@Term</var>)</a></dt>
387481 <dd class="defbody">
388482 True if <var>Term</var> is a dict. This is the same as <code>is_dict(Term,_)</code>.</dd>
389 <dt class="pubdef"><a name="is_dict/2"><strong>is_dict</strong>(<var>@Term,
483 <dt class="pubdef"><a id="is_dict/2"><strong>is_dict</strong>(<var>@Term,
390484 -Tag</var>)</a></dt>
391485 <dd class="defbody">
392486 True if <var>Term</var> is a dict of <var>Tag</var>.</dd>
393 <dt class="pubdef"><a name="get_dict/3"><strong>get_dict</strong>(<var>?Key,
487 <dt class="pubdef"><a id="get_dict/3"><strong>get_dict</strong>(<var>?Key,
394488 +Dict, -Value</var>)</a></dt>
395489 <dd class="defbody">
396490 Unify the value associated with <var>Key</var> in dict with <var>Value</var>.
398492 <var>Key</var> is unbound, all associations in <var>Dict</var> are
399493 returned on backtracking. The order in which the associations are
400494 returned is undefined. This predicate is normally accessed using the
401 functional notation <code>Dict.Key</code>. See <a class="sec" href="dicts.html">section
495 functional notation <code>Dict.Key</code>. See <a class="sec" href="dicts.html#sec:5.4.1">section
402496 5.4.1</a>.
403497
404498 <p>Fails silently if Key does not appear in Dict. This is different from
405499 the behavior of the functional `.`-notation, which throws an existence
406500 error in that case.</dd>
407 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="get_dict/5"><strong>get_dict</strong>(<var>+Key,
501 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="get_dict/5"><strong>get_dict</strong>(<var>+Key,
408502 +Dict, -Value, -NewDict, +NewValue</var>)</a></dt>
409503 <dd class="defbody">
410504 Create a new dict after updating the value for <var>Key</var>. Fails if
421515 </pre>
422516
423517 </dd>
424 <dt class="pubdef"><a name="dict_create/3"><strong>dict_create</strong>(<var>-Dict,
518 <dt class="pubdef"><a id="dict_create/3"><strong>dict_create</strong>(<var>-Dict,
425519 +Tag, +Data</var>)</a></dt>
426520 <dd class="defbody">
427521 Create a dict in <var>Tag</var> from <var>Data</var>. <var>Data</var> is
430524 An exception is raised if <var>Data</var> is not a proper list, one of
431525 the elements is not of the shape above, a key is neither an atom nor a
432526 small integer or there is a duplicate key.</dd>
433 <dt class="pubdef"><a name="dict_pairs/3"><strong>dict_pairs</strong>(<var>?Dict,
527 <dt class="pubdef"><a id="dict_pairs/3"><strong>dict_pairs</strong>(<var>?Dict,
434528 ?Tag, ?Pairs</var>)</a></dt>
435529 <dd class="defbody">
436 Bi-directional mapping between a dict and an ordered list of pairs (see <a class="sec" href="pairs.html">section
530 Bi-directional mapping between a dict and an ordered list of pairs (see <a class="sec" href="pairs.html#sec:A.22">section
437531 A.22</a>).</dd>
438 <dt class="pubdef"><a name="put_dict/3"><strong>put_dict</strong>(<var>+New,
532 <dt class="pubdef"><a id="put_dict/3"><strong>put_dict</strong>(<var>+New,
439533 +DictIn, -DictOut</var>)</a></dt>
440534 <dd class="defbody">
441535 <var>DictOut</var> is a new dict created by replacing or adding
442536 key-value pairs from <var>New</var> to <var>Dict</var>. <var>New</var>
443 is either a dict or a valid input for <a name="idx:dictcreate3:1636"></a><a class="pred" href="dicts.html#dict_create/3">dict_create/3</a>.
537 is either a dict or a valid input for <a id="idx:dictcreate3:1640"></a><a class="pred" href="dicts.html#dict_create/3">dict_create/3</a>.
444538 This predicate is normally accessed using the functional notation. Below
445539 are some examples:
446540
456550 </pre>
457551
458552 </dd>
459 <dt class="pubdef"><a name="put_dict/4"><strong>put_dict</strong>(<var>+Key,
553 <dt class="pubdef"><a id="put_dict/4"><strong>put_dict</strong>(<var>+Key,
460554 +DictIn, +Value, -DictOut</var>)</a></dt>
461555 <dd class="defbody">
462556 <var>DictOut</var> is a new dict created by replacing or adding
476570 </pre>
477571
478572 </dd>
479 <dt class="pubdef"><a name="del_dict/4"><strong>del_dict</strong>(<var>+Key,
573 <dt class="pubdef"><a id="del_dict/4"><strong>del_dict</strong>(<var>+Key,
480574 +DictIn, ?Value, -DictOut</var>)</a></dt>
481575 <dd class="defbody">
482576 True when <var>Key</var>-<var>Value</var> is in <var>DictIn</var> and <var>DictOut</var>
483577 contains all associations of <var>DictIn</var> except for <var>Key</var>.</dd>
484 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name=":</2"><var>+Select</var> <strong>:&lt;</strong> <var>+From</var></a></dt>
578 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id=":</2"><var>+Select</var> <strong>:&lt;</strong> <var>+From</var></a></dt>
485579 <dd class="defbody">
486580 True when <var>Select</var> is a `sub dict' of <var>From</var>: the
487581 tages must unify and all keys in <var>Select</var> must appear with
501595
502596 <p>The goal <code>Select :&lt; From</code> is equivalent to
503597 <code>select_dict(Select, From, _)</code>.</dd>
504 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="select_dict/3"><strong>select_dict</strong>(<var>+Select,
598 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="select_dict/3"><strong>select_dict</strong>(<var>+Select,
505599 +From, -Rest</var>)</a></dt>
506600 <dd class="defbody">
507601 True when the tags of <var>Select</var> and <var>From</var> have been
517611 R = _G1705{z:2}.
518612 </pre>
519613
520 <p>See also <a name="idx:selectdict2:1637"></a><span class="pred-ext">select_dict/2</span>
614 <p>See also <a id="idx:selectdict2:1641"></a><span class="pred-ext">select_dict/2</span>
521615 to ignore <var>Rest</var> and <a class="pred" href="dicts.html#>:</2">&gt;:&lt;/2</a>
522616 for a symmetric partial unification of two dicts.</dd>
523 <dt class="pubdef"><a name=">:</2"><var>+Dict1</var> <strong>&gt;:&lt;</strong> <var>+Dict2</var></a></dt>
617 <dt class="pubdef"><a id=">:</2"><var>+Dict1</var> <strong>&gt;:&lt;</strong> <var>+Dict2</var></a></dt>
524618 <dd class="defbody">
525619 This operator specifies a <em>partial unification</em> between
526620 <var>Dict1</var> and <var>Dict2</var>. It is true when the tags and the
534628 Dict &gt;:&lt; point{x:0, y:Y}.
535629 </pre>
536630
537 <p>See also <a class="pred" href="dicts.html#:</2">:&lt;/2</a> and <a name="idx:selectdict3:1638"></a><a class="pred" href="dicts.html#select_dict/3">select_dict/3</a>.
631 <p>See also <a class="pred" href="dicts.html#:</2">:&lt;/2</a> and <a id="idx:selectdict3:1642"></a><a class="pred" href="dicts.html#select_dict/3">select_dict/3</a>.
538632 </dd>
539633 </dl>
540634
541 <p><h4 id="sec:ext-dict-assignment"><a name="sec:5.4.2.1"><span class="sec-nr">5.4.2.1</span> <span class="sec-title">Destructive
635 <p><h4 id="sec:ext-dict-assignment"><a id="sec:5.4.2.1"><span class="sec-nr">5.4.2.1</span> <span class="sec-title">Destructive
542636 assignment in dicts</span></a></h4>
543637
544 <a name="sec:ext-dict-assignment"></a>
638 <a id="sec:ext-dict-assignment"></a>
545639
546640 <p>This section describes the destructive update operations defined on
547641 dicts. These actions can only <em>update</em> keys and not add or remove
553647 with care because the system may copy or share identical Prolog terms at
554648 any time. Some of this behaviour can be avoided by adding an additional
555649 unbound value to the dict. This prevents unwanted sharing and ensures
556 that <a name="idx:copyterm2:1639"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
650 that <a id="idx:copyterm2:1643"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
557651 actually copies the dict. This pitfall is demonstrated in the example
558652 below:
559653
567661 </pre>
568662
569663 <dl class="latex">
570 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="b_set_dict/3"><strong>b_set_dict</strong>(<var>+Key,
664 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="b_set_dict/3"><strong>b_set_dict</strong>(<var>+Key,
571665 !Dict, +Value</var>)</a></dt>
572666 <dd class="defbody">
573667 Destructively update the value associated with <var>Key</var> in <var>Dict</var>
574668 to
575669 <var>Value</var>. The update is trailed and undone on backtracking. This
576670 predicate raises an existence error if <var>Key</var> does not appear in
577 <var>Dict</var>. The update semantics are equivalent to <a name="idx:setarg3:1640"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
671 <var>Dict</var>. The update semantics are equivalent to <a id="idx:setarg3:1644"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
578672 and
579 <a name="idx:bsetval2:1641"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>.</dd>
580 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="nb_set_dict/3"><strong>nb_set_dict</strong>(<var>+Key,
673 <a id="idx:bsetval2:1645"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>.</dd>
674 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="nb_set_dict/3"><strong>nb_set_dict</strong>(<var>+Key,
581675 !Dict, +Value</var>)</a></dt>
582676 <dd class="defbody">
583677 Destructively update the value associated with <var>Key</var> in <var>Dict</var>
584678 to a copy of <var>Value</var>. The update is <em>not</em> undone on
585679 backtracking. This predicate raises an existence error if <var>Key</var>
586680 does not appear in
587 <var>Dict</var>. The update semantics are equivalent to <a name="idx:nbsetarg3:1642"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>
681 <var>Dict</var>. The update semantics are equivalent to <a id="idx:nbsetarg3:1646"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>
588682 and
589 <a name="idx:nbsetval2:1643"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>.</dd>
590 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="nb_link_dict/3"><strong>nb_link_dict</strong>(<var>+Key,
683 <a id="idx:nbsetval2:1647"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>.</dd>
684 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="nb_link_dict/3"><strong>nb_link_dict</strong>(<var>+Key,
591685 !Dict, +Value</var>)</a></dt>
592686 <dd class="defbody">
593687 Destructively update the value associated with <var>Key</var> in <var>Dict</var>
595689 <var>Value</var>. The update is <em>not</em> undone on backtracking.
596690 This predicate raises an existence error if <var>Key</var> does not
597691 appear in
598 <var>Dict</var>. The update semantics are equivalent to <a name="idx:nblinkarg3:1644"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>
692 <var>Dict</var>. The update semantics are equivalent to <a id="idx:nblinkarg3:1648"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>
599693 and
600 <a name="idx:nblinkval2:1645"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>.
694 <a id="idx:nblinkval2:1649"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>.
601695 Use with extreme care and consult the documentation of
602 <a name="idx:nblinkval2:1646"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
696 <a id="idx:nblinkval2:1650"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
603697 before use.
604698 </dd>
605699 </dl>
606700
607 <p><h3 id="sec:ext-dicts-usage"><a name="sec:5.4.3"><span class="sec-nr">5.4.3</span> <span class="sec-title">When
701 <p><h3 id="sec:ext-dicts-usage"><a id="sec:5.4.3"><span class="sec-nr">5.4.3</span> <span class="sec-title">When
608702 to use dicts?</span></a></h3>
609703
610 <a name="sec:ext-dicts-usage"></a>
704 <a id="sec:ext-dicts-usage"></a>
611705
612706 <p>Dicts are a new type in the Prolog world. They compete with several
613707 other types and libraries. In the list below we have a closer look at
691785 code does not rely on ordered operations.</dd>
692786 <dt><b>Library <code>library(option)</code></b></dt>
693787 <dd>
694 Option lists are introduced by ISO Prolog, for example for <a name="idx:readterm3:1647"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
695 <a name="idx:open4:1648"></a><a class="pred" href="IO.html#open/4">open/4</a>,
788 Option lists are introduced by ISO Prolog, for example for <a id="idx:readterm3:1651"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
789 <a id="idx:open4:1652"></a><a class="pred" href="IO.html#open/4">open/4</a>,
696790 etc. The <code>library(option)</code> library provides operations to
697791 extract options, merge options lists, etc. Dicts are well suited to
698792 replace option lists because they are cheaper, can be processed faster
701795 <dd>
702796 This library is commonly used to process large name-value associations.
703797 In many cases this concerns short-lived datastructures that result from
704 <a name="idx:findall3:1649"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a name="idx:maplist3:1650"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
798 <a id="idx:findall3:1653"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a id="idx:maplist3:1654"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
705799 and similar list processing predicates. Dicts may play a role if
706800 frequent random key lookups are needed on the resulting association. For
707801 example, the skeleton `create a pairs list', `use
708 <a name="idx:listtoassoc2:1651"></a><a class="pred" href="assoc.html#list_to_assoc/2">list_to_assoc/2</a>
802 <a id="idx:listtoassoc2:1655"></a><a class="pred" href="assoc.html#list_to_assoc/2">list_to_assoc/2</a>
709803 to create an assoc', followed by frequent usage of
710 <a name="idx:getassoc3:1652"></a><a class="pred" href="assoc.html#get_assoc/3">get_assoc/3</a>
711 to extract key values can be replaced using <a name="idx:dictpairs3:1653"></a><a class="pred" href="dicts.html#dict_pairs/3">dict_pairs/3</a>
804 <a id="idx:getassoc3:1656"></a><a class="pred" href="assoc.html#get_assoc/3">get_assoc/3</a>
805 to extract key values can be replaced using <a id="idx:dictpairs3:1657"></a><a class="pred" href="dicts.html#dict_pairs/3">dict_pairs/3</a>
712806 and the dict access functions. Using dicts in this scenario is more
713807 efficient and provides a more pleasant access syntax.
714808 </dd>
715809 </dl>
716810
717 <p><h3 id="sec:ext-dicts-motivation"><a name="sec:5.4.4"><span class="sec-nr">5.4.4</span> <span class="sec-title">A
811 <p><h3 id="sec:ext-dicts-motivation"><a id="sec:5.4.4"><span class="sec-nr">5.4.4</span> <span class="sec-title">A
718812 motivation for dicts as primary citizens</span></a></h3>
719813
720 <a name="sec:ext-dicts-motivation"></a>
814 <a id="sec:ext-dicts-motivation"></a>
721815
722816 <p>Dicts, or key-value associations, are a common data structure. A good
723817 old example are <em>property lists</em> as found in Lisp, while a good
748842 <code>library(assoc)</code> allows for efficient manipulation of
749843 changing associations, but the syntactical representation of an assoc is
750844 complex, which makes them unsuitable for e.g., <em>options lists</em> as
751 seen in predicates such as <a name="idx:open4:1654"></a><a class="pred" href="IO.html#open/4">open/4</a>.
752
753 <p><h3 id="sec:ext-dicts-implementation"><a name="sec:5.4.5"><span class="sec-nr">5.4.5</span> <span class="sec-title">Implementation
845 seen in predicates such as <a id="idx:open4:1658"></a><a class="pred" href="IO.html#open/4">open/4</a>.
846
847 <p><h3 id="sec:ext-dicts-implementation"><a id="sec:5.4.5"><span class="sec-nr">5.4.5</span> <span class="sec-title">Implementation
754848 notes about dicts</span></a></h3>
755849
756 <a name="sec:ext-dicts-implementation"></a>
850 <a id="sec:ext-dicts-implementation"></a>
757851
758852 <p>Although dicts are designed as an abstract data type and we
759853 deliberately reserve the possibility to change the representation and
763857 <p>Dicts are currently represented as a compound term using the functor
764858 <code>`dict`</code>. The first argument is the tag. The remaining
765859 arguments create an array of sorted key-value pairs. This representation
766 is compact and guarantees good locality. Lookup is order <var>N</var>,
860 is compact and guarantees good locality. Lookup is order <var>log( N )</var>,
767861 while adding values, deleting values and merging with other dicts has
768862 order
769863 <var>N</var>. The main disadvantage is that changing values in large
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.12</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="altmoduleapi.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ctxmodule.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:dynamic-modules"><a name="sec:6.12"><span class="sec-nr">6.12</span> <span class="sec-title">Dynamic
235 <h2 id="sec:dynamic-modules"><a id="sec:6.12"><span class="sec-nr">6.12</span> <span class="sec-title">Dynamic
195236 Modules</span></a></h2>
196237
197 <a name="sec:dynamic-modules"></a>
238 <a id="sec:dynamic-modules"></a>
198239
199240 <p>So far, we discussed modules that were created by loading a module
200241 file. These modules have been introduced to facilitate the development
221262
222263 <p>Import and export from a dynamically created world can be achieved
223264 using
224 <a name="idx:import1:1734"></a><a class="pred" href="altmoduleapi.html#import/1">import/1</a>
225 and <a name="idx:export1:1735"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
265 <a id="idx:import1:1738"></a><a class="pred" href="altmoduleapi.html#import/1">import/1</a>
266 and <a id="idx:export1:1739"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
226267 or by specifying the import module as described in
227 <a class="sec" href="importmodule.html">section 6.9</a>.
268 <a class="sec" href="importmodule.html#sec:6.9">section 6.9</a>.
228269
229270 <pre class="code">
230271 ?- world_b:export(solve/2). % exports solve/2 from world_b
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.15</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="db.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="examineprog.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:declare"><a name="sec:4.15"><span class="sec-nr">4.15</span> <span class="sec-title">Declaring
235 <h2 id="sec:declare"><a id="sec:4.15"><span class="sec-nr">4.15</span> <span class="sec-title">Declaring
195236 predicate properties</span></a></h2>
196237
197 <a name="ch:dynamic"></a>
198 <a name="sec:declare"></a>
238 <a id="ch:dynamic"></a>
239 <a id="sec:declare"></a>
199240
200241 <p>This section describes directives which manipulate attributes of
201 predicate definitions. The functors <a name="idx:dynamic1:875"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>, <a name="idx:multifile1:876"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>,
202 <a name="idx:discontiguous1:877"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
203 and <a name="idx:public1:878"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
204 are operators of priority 1150 (see <a name="idx:op3:879"></a><a class="pred" href="operators.html#op/3">op/3</a>),
242 predicate definitions. The functors <a id="idx:dynamic1:875"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>, <a id="idx:multifile1:876"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>,
243 <a id="idx:discontiguous1:877"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
244 and <a id="idx:public1:878"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
245 are operators of priority 1150 (see <a id="idx:op3:879"></a><a class="pred" href="operators.html#op/3">op/3</a>),
205246 which implies that the list of predicates they involve can just be a
206247 comma-separated list:
207248
216257 want to maintain portability to other Prolog implementations.
217258
218259 <dl class="latex">
219 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="dynamic/1"><strong>dynamic</strong> <var>:PredicateIndicator,
260 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="dynamic/1"><strong>dynamic</strong> <var>:PredicateIndicator,
220261 ...</var></a></dt>
221262 <dd class="defbody">
222263 Informs the interpreter that the definition of the predicate(s) may
223 change during execution (using <a name="idx:assert1:880"></a><a class="pred" href="db.html#assert/1">assert/1</a>
224 and/or <a name="idx:retract1:881"></a><a class="pred" href="db.html#retract/1">retract/1</a>).
264 change during execution (using <a id="idx:assert1:880"></a><a class="pred" href="db.html#assert/1">assert/1</a>
265 and/or <a id="idx:retract1:881"></a><a class="pred" href="db.html#retract/1">retract/1</a>).
225266 In the multithreaded version, the clauses of dynamic predicates are
226 shared between the threads. The directive <a name="idx:threadlocal1:882"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>
267 shared between the threads. The directive <a id="idx:threadlocal1:882"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>
227268 provides an alternative where each thread has its own clause list for
228269 the predicate. Dynamic predicates can be turned into static ones using
229 <a name="idx:compilepredicates1:883"></a><a class="pred" href="dynamic.html#compile_predicates/1">compile_predicates/1</a>.</dd>
230 <dt class="pubdef"><a name="compile_predicates/1"><strong>compile_predicates</strong>(<var>:ListOfPredicateIndicators</var>)</a></dt>
231 <dd class="defbody">
232 Compile a list of specified dynamic predicates (see <a name="idx:dynamic1:884"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
270 <a id="idx:compilepredicates1:883"></a><a class="pred" href="dynamic.html#compile_predicates/1">compile_predicates/1</a>.</dd>
271 <dt class="pubdef"><a id="compile_predicates/1"><strong>compile_predicates</strong>(<var>:ListOfPredicateIndicators</var>)</a></dt>
272 <dd class="defbody">
273 Compile a list of specified dynamic predicates (see <a id="idx:dynamic1:884"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
233274 and
234 <a name="idx:assert1:885"></a><a class="pred" href="db.html#assert/1">assert/1</a>)
275 <a id="idx:assert1:885"></a><a class="pred" href="db.html#assert/1">assert/1</a>)
235276 into normal static predicates. This call tells the Prolog environment
236 the definition will not change anymore and further calls to <a name="idx:assert1:886"></a><a class="pred" href="db.html#assert/1">assert/1</a>
237 or <a name="idx:retract1:887"></a><a class="pred" href="db.html#retract/1">retract/1</a>
277 the definition will not change anymore and further calls to <a id="idx:assert1:886"></a><a class="pred" href="db.html#assert/1">assert/1</a>
278 or <a id="idx:retract1:887"></a><a class="pred" href="db.html#retract/1">retract/1</a>
238279 on the named predicates raise a permission error. This predicate is
239280 designed to deal with parts of the program that are generated at runtime
240281 but do not change during the remainder of the program execution.<sup class="fn">79<span class="fn-text">The
243284 implemented. In multithreaded Prolog, however, static code runs faster
244285 as it does not require synchronisation. This is particularly true on SMP
245286 hardware.</span></sup></dd>
246 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="multifile/1"><strong>multifile</strong> <var>:PredicateIndicator,
287 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="multifile/1"><strong>multifile</strong> <var>:PredicateIndicator,
247288 ...</var></a></dt>
248289 <dd class="defbody">
249290 Informs the system that the specified predicate(s) may be defined over
250 more than one file. This stops <a name="idx:consult1:888"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
291 more than one file. This stops <a id="idx:consult1:888"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
251292 from redefining a predicate when a new definition is found.</dd>
252 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="discontiguous/1"><strong>discontiguous</strong> <var>:PredicateIndicator,
293 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="discontiguous/1"><strong>discontiguous</strong> <var>:PredicateIndicator,
253294 ...</var></a></dt>
254295 <dd class="defbody">
255296 Informs the system that the clauses of the specified predicate(s) might
256 not be together in the source file. See also <a name="idx:stylecheck1:889"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>.</dd>
257 <dt class="pubdef"><a name="public/1"><strong>public</strong> <var>:PredicateIndicator,
297 not be together in the source file. See also <a id="idx:stylecheck1:889"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>.</dd>
298 <dt class="pubdef"><a id="public/1"><strong>public</strong> <var>:PredicateIndicator,
258299 ...</var></a></dt>
259300 <dd class="defbody">
260301 Instructs the cross-referencer that the predicate can be called. It has
261302 no semantics.<sup class="fn">80<span class="fn-text">This declaration is
262 compatible with SICStus. In YAP, <a name="idx:public1:890"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
303 compatible with SICStus. In YAP, <a id="idx:public1:890"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
263304 instructs the compiler to keep the source. As the source is always
264305 available in SWI-Prolog, our current interpretation also enhances the
265306 compatibility with YAP.</span></sup> The public declaration can be
266 queried using <a name="idx:predicateproperty2:891"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
267 The <a name="idx:public1:892"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
307 queried using <a id="idx:predicateproperty2:891"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
308 The <a id="idx:public1:892"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
268309 directive does
269 <em>not</em> export the predicate (see <a name="idx:module1:893"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>
270 and <a name="idx:export1:894"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>).
310 <em>not</em> export the predicate (see <a id="idx:module1:893"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>
311 and <a id="idx:export1:894"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>).
271312 The public directive is used for (1) direct calls into the module from,
272313 e.g., foreign code, (2) direct calls into the module from other modules,
273314 or (3) flag a predicate as being called if the call is generated by
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="consulting.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="listing.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:edit"><a name="sec:4.4"><span class="sec-nr">4.4</span> <span class="sec-title">Editor
235 <h2 id="sec:edit"><a id="sec:4.4"><span class="sec-nr">4.4</span> <span class="sec-title">Editor
195236 Interface</span></a></h2>
196237
197 <a name="sec:edit"></a>
238 <a id="sec:edit"></a>
198239
199240 <p>SWI-Prolog offers an extensible interface which allows the user to
200241 edit objects of the program: predicates, modules, files, etc. The editor
201 interface is implemented by <a name="idx:edit1:585"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
242 interface is implemented by <a id="idx:edit1:585"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
202243 and consists of three parts:
203244 <em>locating</em>, <em>selecting</em> and <em>starting</em> the editor.
204 Any of these parts may be customized. See <a class="sec" href="edit.html">section
245 Any of these parts may be customized. See <a class="sec" href="edit.html#sec:4.4.1">section
205246 4.4.1</a>.
206247
207 <p>The built-in edit specifications for <a name="idx:edit1:586"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
248 <p>The built-in edit specifications for <a id="idx:edit1:586"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
208249 (see prolog_edit:locate/3) are described in the table below:
209250
210 <p><table border="2" frame="box" rules="groups" style="margin:auto">
211 <tr valign="top"><td colspan=2 align=center><b>Fully specified objects</b></tr>
212 <tbody>
213 <tr valign="top"><td>&lt;<var>Module</var>&gt;:&lt;<var>Name</var>&gt;/&lt;<var>Arity</var>&gt; </td><td>Refers
251 <p><table class="latex frame-box center">
252 <tr><td colspan=2 align=center><b>Fully specified objects</b></tr>
253 <tr class="hline"><td>&lt;<var>Module</var>&gt;:&lt;<var>Name</var>&gt;/&lt;<var>Arity</var>&gt; </td><td>Refers
214254 to a predicate </td></tr>
215 <tr valign="top"><td>module(&lt;<var>Module</var>&gt;)</td><td>Refers to
216 a module </td></tr>
217 <tr valign="top"><td>file(&lt;<var>Path</var>&gt;)</td><td>Refers to a
218 file </td></tr>
219 <tr valign="top"><td>source_file(&lt;<var>Path</var>&gt;)</td><td>Refers
220 to a loaded source file </td></tr>
221 <tbody>
222 <tr valign="top"><td colspan=2 align=center><b>Ambiguous specifications</b></tr>
223 <tbody>
224 <tr valign="top"><td>&lt;<var>Name</var>&gt;/&lt;<var>Arity</var>&gt; </td><td>Refers
255 <tr><td>module(&lt;<var>Module</var>&gt;)</td><td>Refers to a module </td></tr>
256 <tr><td>file(&lt;<var>Path</var>&gt;)</td><td>Refers to a file </td></tr>
257 <tr><td>source_file(&lt;<var>Path</var>&gt;)</td><td>Refers to a loaded
258 source file </td></tr>
259 <tr class="hline"><td colspan=2 align=center><b>Ambiguous specifications</b></tr>
260 <tr class="hline"><td>&lt;<var>Name</var>&gt;/&lt;<var>Arity</var>&gt; </td><td>Refers
225261 to this predicate in any module </td></tr>
226 <tr valign="top"><td>&lt;<var>Name</var>&gt; </td><td>Refers to (1) the
227 named predicate in any module with any arity, (2) a (source) file, or
228 (3) a module. </td></tr>
262 <tr><td>&lt;<var>Name</var>&gt; </td><td>Refers to (1) the named
263 predicate in any module with any arity, (2) a (source) file, or (3) a
264 module. </td></tr>
229265 </table>
230266
231267 <dl class="latex">
232 <dt class="pubdef"><a name="edit/1"><strong>edit</strong>(<var>+Specification</var>)</a></dt>
268 <dt class="pubdef"><a id="edit/1"><strong>edit</strong>(<var>+Specification</var>)</a></dt>
233269 <dd class="defbody">
234270 First, exploit <a class="pred" href="edit.html#prolog_edit:locate/3">prolog_edit:locate/3</a>
235271 to translate
236272 <var>Specification</var> into a list of <em>Locations</em>. If there is
237273 more than one `hit', the user is asked to select from the locations
238274 found. Finally, <a class="pred" href="edit.html#prolog_edit:edit_source/1">prolog_edit:edit_source/1</a>
239 is used to invoke the user's preferred editor. Typically, <a name="idx:edit1:587"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
275 is used to invoke the user's preferred editor. Typically, <a id="idx:edit1:587"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
240276 can be handed the name of a predicate, module, basename of a file, XPCE
241277 class, XPCE method, etc.</dd>
242 <dt class="pubdef"><a name="edit/0"><strong>edit</strong></a></dt>
243 <dd class="defbody">
244 Edit the `default' file using <a name="idx:edit1:588"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
278 <dt class="pubdef"><a id="edit/0"><strong>edit</strong></a></dt>
279 <dd class="defbody">
280 Edit the `default' file using <a id="idx:edit1:588"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
245281 The default file is the file loaded with the command line option <strong>-s</strong>
246282 or, in Windows, the file loaded by double-clicking from the Windows
247283 shell.
248284 </dd>
249285 </dl>
250286
251 <p><h3 id="sec:customedit"><a name="sec:4.4.1"><span class="sec-nr">4.4.1</span> <span class="sec-title">Customizing
287 <p><h3 id="sec:customedit"><a id="sec:4.4.1"><span class="sec-nr">4.4.1</span> <span class="sec-title">Customizing
252288 the editor interface</span></a></h3>
253289
254 <a name="sec:customedit"></a>
290 <a id="sec:customedit"></a>
255291
256292 <p>The predicates described in this section are <em>hooks</em> that can
257 be defined to disambiguate specifications given to <a name="idx:edit1:589"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
293 be defined to disambiguate specifications given to <a id="idx:edit1:589"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
258294 find the related source, and open an editor at the given source
259295 location.
260296
261297 <dl class="latex">
262 <dt class="pubdef"><a name="prolog_edit:locate/3"><strong>prolog_edit:locate</strong>(<var>+Spec,
298 <dt class="pubdef"><a id="prolog_edit:locate/3"><strong>prolog_edit:locate</strong>(<var>+Spec,
263299 -FullSpec, -Location</var>)</a></dt>
264300 <dd class="defbody">
265 Where <var>Spec</var> is the specification provided through <a name="idx:edit1:590"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
301 Where <var>Spec</var> is the specification provided through <a id="idx:edit1:590"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
266302 This multifile predicate is used to enumerate locations where an object
267303 satisfying the given <var>Spec</var> can be found. <var>FullSpec</var>
268304 is unified with the complete specification for the object. This
274310 <p><var>Location</var> is a list of attributes of the location.
275311 Normally, this list will contain the term <code>file(File)</code> and,
276312 if available, the term <code>line(Line)</code>.</dd>
277 <dt class="pubdef"><a name="prolog_edit:locate/2"><strong>prolog_edit:locate</strong>(<var>+Spec,
313 <dt class="pubdef"><a id="prolog_edit:locate/2"><strong>prolog_edit:locate</strong>(<var>+Spec,
278314 -Location</var>)</a></dt>
279315 <dd class="defbody">
280316 Same as prolog_edit:locate/3, but only deals with fully specified
281317 objects.</dd>
282 <dt class="pubdef"><a name="prolog_edit:edit_source/1"><strong>prolog_edit:edit_source</strong>(<var>+Location</var>)</a></dt>
318 <dt class="pubdef"><a id="prolog_edit:edit_source/1"><strong>prolog_edit:edit_source</strong>(<var>+Location</var>)</a></dt>
283319 <dd class="defbody">
284320 Start editor on <var>Location</var>. See prolog_edit:locate/3 for the
285321 format of a location term. This multifile predicate is normally not
286 defined. If it succeeds, <a name="idx:edit1:591"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
322 defined. If it succeeds, <a id="idx:edit1:591"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
287323 assumes the editor is started.
288324
289 <p>If it fails, <a name="idx:edit1:592"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
325 <p>If it fails, <a id="idx:edit1:592"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
290326 uses its internal defaults, which are defined by the Prolog flag <a class="flag" href="flags.html#flag:editor">editor</a>
291327 and/or the environment variable
292328 <code>EDITOR</code>. The following rules apply. If the Prolog flag <a class="flag" href="flags.html#flag:editor">editor</a>
301337
302338 <p>See the default user preferences file <code>dotfiles/dotswiplrc</code>
303339 for examples.</dd>
304 <dt class="pubdef"><a name="prolog_edit:edit_command/2"><strong>prolog_edit:edit_command</strong>(<var>+Editor,
340 <dt class="pubdef"><a id="prolog_edit:edit_command/2"><strong>prolog_edit:edit_command</strong>(<var>+Editor,
305341 -Command</var>)</a></dt>
306342 <dd class="defbody">
307 Determines how <var>Editor</var> is to be invoked using <a name="idx:shell1:593"></a><a class="pred" href="system.html#shell/1">shell/1</a>. <var>Editor</var>
343 Determines how <var>Editor</var> is to be invoked using <a id="idx:shell1:593"></a><a class="pred" href="system.html#shell/1">shell/1</a>. <var>Editor</var>
308344 is the determined editor (see qpredrefprolog_editedit_source1), without
309345 the full path specification, and without a possible (<code>.exe</code>)
310346 extension. <var>Command</var> is an atom describing the command. The
311347 following %-sequences are replaced in <var>Command</var> before the
312 result is handed to <a name="idx:shell1:594"></a><a class="pred" href="system.html#shell/1">shell/1</a>:
313
314 <p><table border="2" frame="box" rules="groups" style="margin:auto">
315 <tr valign="top"><td>%e</td><td>Replaced by the (OS) command name of the
316 editor </td></tr>
317 <tr valign="top"><td>%f</td><td>Replaced by the (OS) full path name of
318 the file </td></tr>
319 <tr valign="top"><td>%d</td><td>Replaced by the line number </td></tr>
348 result is handed to <a id="idx:shell1:594"></a><a class="pred" href="system.html#shell/1">shell/1</a>:
349
350 <p><table class="latex frame-box center">
351 <tr><td>%e</td><td>Replaced by the (OS) command name of the editor </td></tr>
352 <tr><td>%f</td><td>Replaced by the (OS) full path name of the file </td></tr>
353 <tr><td>%d</td><td>Replaced by the line number </td></tr>
320354 </table>
321355
322356 <p>If the editor can deal with starting at a specified line, two clauses
329363 a given line number.
330364
331365 <p>Please contribute your specifications to <a class="url" href="mailto:bugs@swi-prolog.org">bugs@swi-prolog.org</a>.</dd>
332 <dt class="pubdef"><a name="prolog_edit:load/0"><strong>prolog_edit:load</strong></a></dt>
366 <dt class="pubdef"><a id="prolog_edit:load/0"><strong>prolog_edit:load</strong></a></dt>
333367 <dd class="defbody">
334368 Normally an undefined multifile predicate. This predicate may be defined
335369 to provide loading hooks for user extensions to the edit module. For
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="usingmodules.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="pceemacs.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:editreload"><a name="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">The
235 <h2 id="sec:editreload"><a id="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">The
195236 test-edit-reload cycle</span></a></h2>
196237
197 <a name="sec:editreload"></a>
238 <a id="sec:editreload"></a>
198239
199240 <p>SWI-Prolog does not enforce the use of a particular editor for
200241 writing Prolog source code. Editors are complicated programs that must
206247
207248 <p>The use of a built-in editor, which is selected by setting the Prolog
208249 flag <a class="flag" href="flags.html#flag:editor">editor</a> to <code>pce_emacs</code>,
209 has advantages. The XPCE object, around which the built-in PceEmacs is
210 built, can be opened as a Prolog stream allowing analysis of your source
211 by the real Prolog system.
212
213 <p><h3 id="sec:editfind"><a name="sec:3.3.1"><span class="sec-nr">3.3.1</span> <span class="sec-title">Locating
250 has advantages. The XPCE <i>editor</i> object, around which the built-in
251 PceEmacs is built, can be opened as a Prolog stream allowing analysis of
252 your source by the real Prolog system.
253
254 <p><h3 id="sec:editfind"><a id="sec:3.3.1"><span class="sec-nr">3.3.1</span> <span class="sec-title">Locating
214255 things to edit</span></a></h3>
215256
216 <a name="sec:editfind"></a>
217
218 <p><a name="idx:TABcompletion:304"></a><a name="idx:completionTAB:305"></a>The
219 central predicate for editing something is <a name="idx:edit1:306"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
257 <a id="sec:editfind"></a>
258
259 <p><a id="idx:TABcompletion:304"></a><a id="idx:completionTAB:305"></a>The
260 central predicate for editing something is <a id="idx:edit1:306"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
220261 an extensible front-end that searches for objects (files, predicates,
221262 modules, as well as XPCE classes and methods) in the Prolog database. If
222263 multiple matches are found it provides a choice. Together with the
233274 Your choice?
234275 </pre>
235276
236 <p><h3 id="sec:editcompile"><a name="sec:3.3.2"><span class="sec-nr">3.3.2</span> <span class="sec-title">Editing
277 <p><h3 id="sec:editcompile"><a id="sec:3.3.2"><span class="sec-nr">3.3.2</span> <span class="sec-title">Editing
237278 and incremental compilation</span></a></h3>
238279
239 <a name="sec:editcompile"></a>
280 <a id="sec:editcompile"></a>
240281
241282 <p>One of the nice features of Prolog is that the code can be modified
242283 while the program is running. Using pure Prolog you can trace a program,
247288 understanding the misbehaviour, edit the source, reload it and try
248289 again.
249290
250 <p>One of the nice features of SWI-Prolog is the availability of <a name="idx:make0:307"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
291 <p>One of the nice features of SWI-Prolog is the availability of <a id="idx:make0:307"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
251292 a simple predicate that checks all loaded source files to see which ones
252293 you have modified. It then reloads these files, considering the module
253294 from which the file was loaded originally. This greatly simplifies the
259300 </pre>
260301
261302 <p>Now edit the source, possibly switching to other files and making
262 multiple changes. After finishing, invoke <a name="idx:make0:308"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
303 multiple changes. After finishing, invoke <a id="idx:make0:308"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
263304 either through the editor UI (<strong>Compile/Make</strong> (<code>Control-C
264305 Control-M</code>)) or on the top level, and watch the files being
265306 reloaded.<sup class="fn">37<span class="fn-text">Watching these files is
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 10.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 10.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="engines.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="engine-resources.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:engine-examples"><a name="sec:10.1"><span class="sec-nr">10.1</span> <span class="sec-title">Examples
235 <h2 id="sec:engine-examples"><a id="sec:10.1"><span class="sec-nr">10.1</span> <span class="sec-title">Examples
195236 using engines</span></a></h2>
196237
197 <a name="sec:engine-examples"></a>
238 <a id="sec:engine-examples"></a>
198239
199240 <p>We introduce engines by describing application areas and providing
200241 simple example programs. The predicates are defined in
201 <a class="sec" href="engine-predicates.html">section 10.3</a>. We
202 identify the following application areas for engines.
242 <a class="sec" href="engine-predicates.html#sec:10.3">section 10.3</a>.
243 We identify the following application areas for engines.
203244
204245 <p>
205246 <ol class="latex">
206247 <li>Aggregating solutions from one or more goals. See
207 <a class="sec" href="engine-examples.html">section 10.1.1</a>.
248 <a class="sec" href="engine-examples.html#sec:10.1.1">section 10.1.1</a>.
208249 <li>Access the terms produced in <em>forward execution</em> through
209 backtracking without collecting all of them first. <a class="sec" href="engine-examples.html">Section
250 backtracking without collecting all of them first. <a class="sec" href="engine-examples.html#sec:10.1.1">Section
210251 10.1.1</a> illustrates this as well.
211 <li>State accumulation and sharing. See <a class="sec" href="engine-examples.html">section
252 <li>State accumulation and sharing. See <a class="sec" href="engine-examples.html#sec:10.1.2">section
212253 10.1.2</a>.
213 <li>Scalable many-agent applications. See <a class="sec" href="engine-examples.html">section
254 <li>Scalable many-agent applications. See <a class="sec" href="engine-examples.html#sec:10.1.3">section
214255 10.1.3</a>.
215256 </ol>
216257
217 <p><h3 id="sec:engine-aggregation"><a name="sec:10.1.1"><span class="sec-nr">10.1.1</span> <span class="sec-title">Aggregation
258 <p><h3 id="sec:engine-aggregation"><a id="sec:10.1.1"><span class="sec-nr">10.1.1</span> <span class="sec-title">Aggregation
218259 using engines</span></a></h3>
219260
220 <a name="sec:engine-aggregation"></a>
261 <a id="sec:engine-aggregation"></a>
221262
222263 <p>Engines can be used to reason about solutions produced by a goal
223264 through backtracking. In this scenario we create an engine with the goal
224 we wish to backtrack over and we enumerate all its solution using <a name="idx:enginenext1:1965"></a><span class="pred-ext">engine_next/1</span>.
225 This usage scenario competes with the all solution predicates (<a name="idx:findall3:1966"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a name="idx:bagof3:1967"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
265 we wish to backtrack over and we enumerate all its solution using <a id="idx:enginenext1:1969"></a><span class="pred-ext">engine_next/1</span>.
266 This usage scenario competes with the all solution predicates (<a id="idx:findall3:1970"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a id="idx:bagof3:1971"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
226267 etc.) and the predicates from library
227 <code>library(aggregate)</code>. Below we implement <a name="idx:findall3:1968"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
268 <code>library(aggregate)</code>. Below we implement <a id="idx:findall3:1972"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
228269 using engines.
229270
230271 <pre class="code">
242283
243284 <p>The above is not a particularly attractive alternative for the
244285 built-in
245 <a name="idx:findall3:1969"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
286 <a id="idx:findall3:1973"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
246287 It is mostly slower due to time required to create and destroy the
247 engine as well as the (currently<sup class="fn">165<span class="fn-text">The
288 engine as well as the (currently<sup class="fn">166<span class="fn-text">The
248289 current implementation of engines is built on top of primitives that are
249290 not optimal for the engine use case. There is considerable opportunity
250291 to reduce the overhead.</span></sup>) higher overhead of copying terms
251292 between engines than the overhead required by the dedicated
252293 representation used by
253 <a name="idx:findall3:1970"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
294 <a id="idx:findall3:1974"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
254295
255296 <p>It gets more interesting if we wish to combine answers from multiple
256297 backtracking predicates. Assume we have two predicates that, on
331372 yield_remaining(S1, E).
332373 </pre>
333374
334 <p><h3 id="sec:engine-state"><a name="sec:10.1.2"><span class="sec-nr">10.1.2</span> <span class="sec-title">State
375 <p><h3 id="sec:engine-state"><a id="sec:10.1.2"><span class="sec-nr">10.1.2</span> <span class="sec-title">State
335376 accumulation using engines</span></a></h3>
336377
337 <a name="sec:engine-state"></a>
378 <a id="sec:engine-state"></a>
338379
339380 <p>Applications that need to manage a state can do so by passing the
340381 state around in an additional argument, storing it in a global variable
341 or update it in the dynamic database using <a name="idx:assertz1:1971"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
342 and <a name="idx:retract1:1972"></a><a class="pred" href="db.html#retract/1">retract/1</a>.
343 Both using an additional argument and a global variable (see <a name="idx:bsetval2:1973"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>),
382 or update it in the dynamic database using <a id="idx:assertz1:1975"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
383 and <a id="idx:retract1:1976"></a><a class="pred" href="db.html#retract/1">retract/1</a>.
384 Both using an additional argument and a global variable (see <a id="idx:bsetval2:1977"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>),
344385 make the state subject to backtracking. This may or may not be
345386 desirable. If having a state is that subject to backtracking is
346387 required, using an additional argument or backtrackable global variable
347 is the right approach. Otherwise, non-backtrackable global variables (<a name="idx:nbsetval2:1974"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>)
388 is the right approach. Otherwise, non-backtrackable global variables (<a id="idx:nbsetval2:1978"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>)
348389 and dynamic database come into the picture, where global variables are
349390 always local to a thread and the dynamic database may or may not be
350 shared between threads (see <a name="idx:threadlocal1:1975"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>).
391 shared between threads (see <a id="idx:threadlocal1:1979"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>).
351392
352393 <p>Engines bring an alternative that packages a state inside the engine
353394 where it is typically represented in a (threaded) Prolog variable. The
359400 <p>
360401 <ul class="latex">
361402 <li>The programming style needed inside the engine is much more `Prolog
362 friendly', using <a name="idx:enginefetch1:1976"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>
403 friendly', using <a id="idx:enginefetch1:1980"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>
363404 to read a request and
364 <a name="idx:engineyield1:1977"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
405 <a id="idx:engineyield1:1981"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
365406 to reply to it.
366407 <li>The state is packaged and subject to (atom) garbage collection.
367408 <li>The state may be accessed from multiple threads. Access to the state
373414 typical update loop for maintaining state inside an engine: fetch a
374415 command, update the state, yield with the reply and call the updater
375416 recursively. The update step is guarded against failure. For robustness
376 one may also guard it against exceptions using <a name="idx:catch3:1978"></a><a class="pred" href="exception.html#catch/3">catch/3</a>.
417 one may also guard it against exceptions using <a id="idx:catch3:1982"></a><a class="pred" href="exception.html#catch/3">catch/3</a>.
377418 Note that heap_get/2 passes the <var>Priority</var> and <var>Key</var>
378419 it wishes to delete from the heap such that if the unification fails,
379420 the heap remains unchanged.
412453 engine_post(E, get(Priority, Key), Priority-Key).
413454 </pre>
414455
415 <p><h3 id="sec:engine-agents"><a name="sec:10.1.3"><span class="sec-nr">10.1.3</span> <span class="sec-title">Scalable
456 <p><h3 id="sec:engine-agents"><a id="sec:10.1.3"><span class="sec-nr">10.1.3</span> <span class="sec-title">Scalable
416457 many-agent applications</span></a></h3>
417458
418 <a name="sec:engine-agents"></a>
459 <a id="sec:engine-agents"></a>
419460
420461 <p>The final application area we touch are agent systems were we wish to
421462 capture an agent in a Prolog goal. Such systems can be implemented using
422 threads (see <a class="sec" href="threads.html">section 9</a>) that use <a name="idx:threadsendmessage2:1979"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
463 threads (see <a class="sec" href="threads.html#sec:9">section 9</a>)
464 that use <a id="idx:threadsendmessage2:1983"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
423465 and
424 <a name="idx:threadgetmessage1:1980"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>
466 <a id="idx:threadgetmessage1:1984"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>
425467 to communicate. The main problem is that each thread is associated by an
426468 operating system thread. OS threads are, depending on the OS, relatively
427469 expensive. Scalability of this design typically ends, depending on OS
430472 <p>Engines provide an alternative. A detached Prolog engine currently
431473 requires approximately 20&nbsp;Kbytes memory on 64&nbsp;bit hardware,
432474 growing with the size of the Prolog stacks. The Prolog stacks may be
433 minimised by calling <a name="idx:garbagecollect0:1981"></a><a class="pred" href="memory.html#garbage_collect/0">garbage_collect/0</a>
434 followed by <a name="idx:trimstacks0:1982"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>,
475 minimised by calling <a id="idx:garbagecollect0:1985"></a><a class="pred" href="memory.html#garbage_collect/0">garbage_collect/0</a>
476 followed by <a id="idx:trimstacks0:1986"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>,
435477 providing a
436478 <em>deep sleep</em> mode. The set of agents, each represented by an
437479 engine can be controlled by a static or dynamic pool of threads.
441483 <blockquote> This section needs an example. Preferably something that
442484 fits on one page and would not scale using threads. Engines might work
443485 nice to implement <i>Antrank: An ant colony algorithm for ranking web
444 pages</i>.<sup class="fn">166<span class="fn-text"><a class="url" href="http://www.ijettcs.org/Volume3Issue2/IJETTCS-2014-04-23-113.pdf">http://www.ijettcs.org/Volume3Issue2/IJETTCS-2014-04-23-113.pdf</a></span></sup>
486 pages</i>.<sup class="fn">167<span class="fn-text"><a class="url" href="http://www.ijettcs.org/Volume3Issue2/IJETTCS-2014-04-23-113.pdf">http://www.ijettcs.org/Volume3Issue2/IJETTCS-2014-04-23-113.pdf</a></span></sup>
445487 </blockquote>
446488
447489 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 10.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 10.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="engine-resources.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreign.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:engine-predicates"><a name="sec:10.3"><span class="sec-nr">10.3</span> <span class="sec-title">Engine
235 <h2 id="sec:engine-predicates"><a id="sec:10.3"><span class="sec-nr">10.3</span> <span class="sec-title">Engine
195236 predicate reference</span></a></h2>
196237
197 <a name="sec:engine-predicates"></a>
238 <a id="sec:engine-predicates"></a>
198239
199240 <p>This section documents the built-in predicates that deal with
200241 engines. In addition to these, most predicates dealing with threads and
201242 message queue can be used to access engines.
202243
203244 <dl class="latex">
204 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_create/3"><strong>engine_create</strong>(<var>+Template,
245 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_create/3"><strong>engine_create</strong>(<var>+Template,
205246 :Goal, ?Engine</var>)</a></dt>
206 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_create/4"><strong>engine_create</strong>(<var>+Template,
247 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_create/4"><strong>engine_create</strong>(<var>+Template,
207248 :Goal, -Engine, +Options</var>)</a></dt>
208249 <dd class="defbody">
209250 Create a new engine and unify <var>Engine</var> with a handle to it.
210 <var>Template</var> and <var>Goal</var> form a pair similar to <a name="idx:findall3:1990"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>:
211 the instantiation of <var>Template</var> becomes available though <a name="idx:enginenext2:1991"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
251 <var>Template</var> and <var>Goal</var> form a pair similar to <a id="idx:findall3:1994"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>:
252 the instantiation of <var>Template</var> becomes available though <a id="idx:enginenext2:1995"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
212253 after <var>Goal</var> succeeds. <var>Options</var> is a list of the
213 following options. See <a name="idx:threadcreate3:1992"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
254 following options. See <a id="idx:threadcreate3:1996"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
214255 for details.
215256
216257 <dl class="latex">
234275 </dd>
235276 </dl>
236277
237 The <var>Engine</var> argument of <a name="idx:enginecreate3:1993"></a><a class="pred" href="engine-predicates.html#engine_create/3">engine_create/3</a>
278 The <var>Engine</var> argument of <a id="idx:enginecreate3:1997"></a><a class="pred" href="engine-predicates.html#engine_create/3">engine_create/3</a>
238279 may be instantiated to an atom, creating an engine with the given alias.</dd>
239 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_destroy/1"><strong>engine_destroy</strong>(<var>+Engine</var>)</a></dt>
280 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_destroy/1"><strong>engine_destroy</strong>(<var>+Engine</var>)</a></dt>
240281 <dd class="defbody">
241282 Destroy <var>Engine</var>.</dd>
242 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="engine_next/2"><strong>engine_next</strong>(<var>+Engine,
283 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="engine_next/2"><strong>engine_next</strong>(<var>+Engine,
243284 -Term</var>)</a></dt>
244285 <dd class="defbody">
245286 Ask the engine <var>Engine</var> to produce a next answer. On this first
246287 call on a specific engine, the <var>Goal</var> of the engine is started.
247288 If a previous call returned an answer through completion, this causes
248289 the engine to backtrack and finally, if the engine produces a previous
249 result using <a name="idx:engineyield1:1994"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>,
250 execution proceeds after the <a name="idx:engineyield1:1995"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
290 result using <a id="idx:engineyield1:1998"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>,
291 execution proceeds after the <a id="idx:engineyield1:1999"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
251292 call.</dd>
252 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_next_reified/2"><strong>engine_next_reified</strong>(<var>+Engine,
293 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_next_reified/2"><strong>engine_next_reified</strong>(<var>+Engine,
253294 -Term</var>)</a></dt>
254295 <dd class="defbody">
255 Similar to <a name="idx:enginenext2:1996"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>,
296 Similar to <a id="idx:enginenext2:2000"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>,
256297 but instead of success, failure or or raising an exception, <var>Term</var>
257298 is unified with one of terms below. This predicate is provided primarily
258299 for compatibility with Lean&nbsp;Prolog.
274315 </dl>
275316
276317 </dd>
277 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_post/2"><strong>engine_post</strong>(<var>+Engine,
318 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_post/2"><strong>engine_post</strong>(<var>+Engine,
278319 +Term</var>)</a></dt>
279320 <dd class="defbody">
280 Make <var>Term</var> available to <a name="idx:enginefetch1:1997"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>
281 inside the <var>Engine</var>. This call must be followed by a call to <a name="idx:enginenext2:1998"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
282 and the engine must call <a name="idx:enginefetch1:1999"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>.</dd>
283 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_post/3"><strong>engine_post</strong>(<var>+Engine,
321 Make <var>Term</var> available to <a id="idx:enginefetch1:2001"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>
322 inside the <var>Engine</var>. This call must be followed by a call to <a id="idx:enginenext2:2002"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
323 and the engine must call <a id="idx:enginefetch1:2003"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>.</dd>
324 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_post/3"><strong>engine_post</strong>(<var>+Engine,
284325 +Term, -Reply</var>)</a></dt>
285326 <dd class="defbody">
286 Combines <a name="idx:enginepost2:2000"></a><a class="pred" href="engine-predicates.html#engine_post/2">engine_post/2</a>
287 and <a name="idx:enginenext2:2001"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>.</dd>
288 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_yield/1"><strong>engine_yield</strong>(<var>+Term</var>)</a></dt>
289 <dd class="defbody">
290 Called from within the engine, causing <a name="idx:enginenext2:2002"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
291 in the caller to return with <var>Term</var>. A subsequent call to <a name="idx:enginenext2:2003"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
327 Combines <a id="idx:enginepost2:2004"></a><a class="pred" href="engine-predicates.html#engine_post/2">engine_post/2</a>
328 and <a id="idx:enginenext2:2005"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>.</dd>
329 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_yield/1"><strong>engine_yield</strong>(<var>+Term</var>)</a></dt>
330 <dd class="defbody">
331 Called from within the engine, causing <a id="idx:enginenext2:2006"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
332 in the caller to return with <var>Term</var>. A subsequent call to <a id="idx:enginenext2:2007"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
292333 causes
293 <a name="idx:engineyield1:2004"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
334 <a id="idx:engineyield1:2008"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
294335 to `return'. This predicate can only be called if the engine is not
295336 involved in a callback from C, i.e., when the engine calls a predicate
296337 defined in C that calls back Prolog it is not possible to use this
297338 predicate. Trying to do so results in a
298339 <code>permission_error</code> exception.</dd>
299 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_fetch/1"><strong>engine_fetch</strong>(<var>-Term</var>)</a></dt>
340 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_fetch/1"><strong>engine_fetch</strong>(<var>-Term</var>)</a></dt>
300341 <dd class="defbody">
301342 Called from within the engine to fetch the term made available through
302 <a name="idx:enginepost2:2005"></a><a class="pred" href="engine-predicates.html#engine_post/2">engine_post/2</a>
303 or <a name="idx:enginepost3:2006"></a><a class="pred" href="engine-predicates.html#engine_post/3">engine_post/3</a>.
343 <a id="idx:enginepost2:2009"></a><a class="pred" href="engine-predicates.html#engine_post/2">engine_post/2</a>
344 or <a id="idx:enginepost3:2010"></a><a class="pred" href="engine-predicates.html#engine_post/3">engine_post/3</a>.
304345 If no term is available an existence_error exception is raised.</dd>
305 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_self/1"><strong>engine_self</strong>(<var>-Engine</var>)</a></dt>
346 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_self/1"><strong>engine_self</strong>(<var>-Engine</var>)</a></dt>
306347 <dd class="defbody">
307348 Called from within the engine to get access to the handle to the engine
308349 itself.</dd>
309 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_engine/1"><strong>is_engine</strong>(<var>@Term</var>)</a></dt>
350 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_engine/1"><strong>is_engine</strong>(<var>@Term</var>)</a></dt>
310351 <dd class="defbody">
311352 True if <var>Term</var> is a reference to or the alias name of an
312353 existing engine.</dd>
313 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_engine/1"><strong>current_engine</strong>(<var>-Engine</var>)</a></dt>
354 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_engine/1"><strong>current_engine</strong>(<var>-Engine</var>)</a></dt>
314355 <dd class="defbody">
315356 True when <var>Engine</var> is an existing engine.
316357 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 10.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 10.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="engine-examples.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="engine-predicates.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:engine-resources"><a name="sec:10.2"><span class="sec-nr">10.2</span> <span class="sec-title">Engine
235 <h2 id="sec:engine-resources"><a id="sec:10.2"><span class="sec-nr">10.2</span> <span class="sec-title">Engine
195236 resource usage</span></a></h2>
196237
197 <a name="sec:engine-resources"></a>
238 <a id="sec:engine-resources"></a>
198239
199240 <p>A Prolog engine consists of a virtual machine state that includes the
200241 Prolog stacks. An `empty' engine requires aout 20&nbsp;KBytes of memory.
201242 This grows when the engine requires additional stack space. Anonymous
202 engines are subject to atom garbage collection (see <a name="idx:garbagecollectatoms0:1983"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>).
203 Engines may be reclaimed immediately using <a name="idx:enginedestroy1:1984"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>.
243 engines are subject to atom garbage collection (see <a id="idx:garbagecollectatoms0:1987"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>).
244 Engines may be reclaimed immediately using <a id="idx:enginedestroy1:1988"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>.
204245 Calling
205 <a name="idx:enginedestroy1:1985"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
246 <a id="idx:enginedestroy1:1989"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
206247 destroys the virtual machine state, while the handle itself is left to
207248 atom garbage collection. The virtual machine is reclaimed as soon as an
208249 engine produced its last result, failed or raised an exception. This
209250 implies that it is only advantageous to call
210 <a name="idx:enginedestroy1:1986"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
251 <a id="idx:enginedestroy1:1990"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
211252 explicitly if you are not interested in further answers.
212253
213254 <p>Engines that are expected to be left in inactive state for a
214 prelonged time can be minimized by calling <a name="idx:garbagecollect0:1987"></a><a class="pred" href="memory.html#garbage_collect/0">garbage_collect/0</a>
215 and <a name="idx:trimmstacks0:1988"></a><span class="pred-ext">trimm_stacks/0</span>
216 (in that order) before calling <a name="idx:engineyield1:1989"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
255 prelonged time can be minimized by calling <a id="idx:garbagecollect0:1991"></a><a class="pred" href="memory.html#garbage_collect/0">garbage_collect/0</a>
256 and <a id="idx:trimmstacks0:1992"></a><span class="pred-ext">trimm_stacks/0</span>
257 (in that order) before calling <a id="idx:engineyield1:1993"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
217258 or succeeding.
218259
219260 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="mt-xpce.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="engine-examples.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:engines"><a name="sec:10"><span class="sec-nr">10</span> <span class="sec-title">Coroutining
235 <h1 id="sec:engines"><a id="sec:10"><span class="sec-nr">10</span> <span class="sec-title">Coroutining
195236 using Prolog engines</span></a></h1>
196237
197 <a name="sec:engines"></a>
238 <a id="sec:engines"></a>
198239
199240 <p>Where the term <em>coroutine</em> in Prolog typically refer to hooks
200 triggered by <em>attributed variables</em> (<a class="sec" href="attvar.html">section
241 triggered by <em>attributed variables</em> (<a class="sec" href="attvar.html#sec:7.1">section
201242 7.1</a>), SWI-Prolog provides two other forms of coroutines. Delimited
202243 continuations (see
203 <a class="sec" href="delcont.html">section 4.10</a>) allow creating
204 coroutines that run in the same Prolog engine by capturing and
244 <a class="sec" href="delcont.html#sec:4.10">section 4.10</a>) allow
245 creating coroutines that run in the same Prolog engine by capturing and
205246 restarting the <em>continuation</em>. This section discusses <em>engines</em>,
206247 also known as <em>interactors</em>. The idea was pinned by Paul Tarau <cite><a class="cite" href="Bibliography.html#DBLP:conf/coordination/Tarau11">Tarau,
207248 2011</a></cite>. The API described in this chapter has been established
208249 together with Paul Tarau and Paulo Moura.
209250
210 <p>Engines are closely related to <em>threads</em> (<a class="sec" href="threads.html">section
251 <p>Engines are closely related to <em>threads</em> (<a class="sec" href="threads.html#sec:9">section
211252 9</a>). An engine is a Prolog virtual machine that has its own stacks
212253 and (virtual) machine state. Unlike normal Prolog threads though, they
213254 are not associated with an operating system thread. Instead, you <em>ask</em>
214 an engine for a next answer (<a name="idx:enginenext2:1963"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>).
255 an engine for a next answer (<a id="idx:enginenext2:1967"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>).
215256 Asking an engine for the next answer attaches the engine to the calling
216 operating system thread and cause it to run until the engine calls <a name="idx:engineyield1:1964"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
257 operating system thread and cause it to run until the engine calls <a id="idx:engineyield1:1968"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
217258 or its associated goal completes with an answer, failure or an
218259 exception. After the engine yields or completes, it is detached from the
219260 operating system thread and the answer term is made available to the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.12</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="debug.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="gensym.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:error"><a name="sec:A.12"><span class="sec-nr">A.12</span> <span class="sec-title">library(error):
235 <h2 id="sec:error"><a id="sec:A.12"><span class="sec-nr">A.12</span> <span class="sec-title">library(error):
195236 Error generating support</span></a></h2>
196237
197 <p><a name="sec:error"></a>
238 <p><a id="sec:error"></a>
198239
199240 <dl class="tags">
200241 <dt class="mtag">author</dt>
219260 to simplify throwing the most common ISO error terms.
220261
221262 <dl class="latex">
222 <dt class="pubdef"><a name="type_error/2"><strong>type_error</strong>(<var>+Type,
263 <dt class="pubdef"><a id="type_error/2"><strong>type_error</strong>(<var>+Type,
223264 +Term</var>)</a></dt>
224265 <dd class="defbody">
225266 Tell the user that <var>Term</var> is not of the expected <var>Type</var>.
236277 compound-term and any other compound term is a domain error. Most Prolog
237278 programmers consider each compound as a type and would consider a
238279 compoint that is not <code>point(_,_)</code> a <i>type_error</i>.</dd>
239 <dt class="pubdef"><a name="domain_error/2"><strong>domain_error</strong>(<var>+Type,
280 <dt class="pubdef"><a id="domain_error/2"><strong>domain_error</strong>(<var>+Type,
240281 +Term</var>)</a></dt>
241282 <dd class="defbody">
242283 The argument is of the proper type, but has a value that is outside the
243284 supported values. See <a class="pred" href="error.html#type_error/2">type_error/2</a>
244285 for a more elaborate discussion of the distinction between type- and
245286 domain-errors.</dd>
246 <dt class="pubdef"><a name="existence_error/2"><strong>existence_error</strong>(<var>+Type,
287 <dt class="pubdef"><a id="existence_error/2"><strong>existence_error</strong>(<var>+Type,
247288 +Term</var>)</a></dt>
248289 <dd class="defbody">
249290 <var>Term</var> is of the correct type and correct domain, but there is
250291 no existing (external) resource that is represented by it.</dd>
251 <dt class="pubdef"><a name="permission_error/3"><strong>permission_error</strong>(<var>+Action,
292 <dt class="pubdef"><a id="permission_error/3"><strong>permission_error</strong>(<var>+Action,
252293 +Type, +Term</var>)</a></dt>
253294 <dd class="defbody">
254295 It is not allowed to perform <var>Action</var> on the object <var>Term</var>
255296 that is of the given <var>Type</var>.</dd>
256 <dt class="pubdef"><a name="instantiation_error/1"><strong>instantiation_error</strong>(<var>+Term</var>)</a></dt>
297 <dt class="pubdef"><a id="instantiation_error/1"><strong>instantiation_error</strong>(<var>+Term</var>)</a></dt>
257298 <dd class="defbody">
258299 An argument is under-instantiated. I.e. it is not acceptable as it is,
259300 but if some variables are bound to appropriate values it would be
260301 acceptable.
261302 <table class="arglist">
262 <tr valign="top"><td><var>Term</var> </td><td>is the term that needs
263 (further) instantiation. Unfortunately, the ISO error does not allow for
264 passing this term along with the error, but we pass it to this predicate
265 for documentation purposes and to allow for future enhancement. </td></tr>
303 <tr><td><var>Term</var> </td><td>is the term that needs (further)
304 instantiation. Unfortunately, the ISO error does not allow for passing
305 this term along with the error, but we pass it to this predicate for
306 documentation purposes and to allow for future enhancement. </td></tr>
266307 </table>
267308 </dd>
268 <dt class="pubdef"><a name="uninstantiation_error/1"><strong>uninstantiation_error</strong>(<var>+Term</var>)</a></dt>
309 <dt class="pubdef"><a id="uninstantiation_error/1"><strong>uninstantiation_error</strong>(<var>+Term</var>)</a></dt>
269310 <dd class="defbody">
270311 An argument is over-instantiated. This error is used for output
271312 arguments whose value cannot be known upfront. For example, the goal <code>open(File, read, input)</code>
272313 cannot succeed because the system will allocate a new unique stream
273314 handle that will never unify with <code>input</code>.</dd>
274 <dt class="pubdef"><a name="representation_error/1"><strong>representation_error</strong>(<var>+Reason</var>)</a></dt>
315 <dt class="pubdef"><a id="representation_error/1"><strong>representation_error</strong>(<var>+Reason</var>)</a></dt>
275316 <dd class="defbody">
276317 A representation error indicates a limitation of the implementation.
277318 SWI-Prolog has no such limits that are not covered by other errors, but
278319 an example of a representation error in another Prolog implementation
279320 could be an attempt to create a term with an arity higher than supported
280321 by the system.</dd>
281 <dt class="pubdef"><a name="syntax_error/1"><strong>syntax_error</strong>(<var>+Culprit</var>)</a></dt>
322 <dt class="pubdef"><a id="syntax_error/1"><strong>syntax_error</strong>(<var>+Culprit</var>)</a></dt>
282323 <dd class="defbody">
283324 A text has invalid syntax. The error is described by <var>Culprit</var>.
284325
292333 </dl>
293334
294335 </dd>
295 <dt class="pubdef"><a name="resource_error/1"><strong>resource_error</strong>(<var>+Culprit</var>)</a></dt>
336 <dt class="pubdef"><a id="resource_error/1"><strong>resource_error</strong>(<var>+Culprit</var>)</a></dt>
296337 <dd class="defbody">
297338 A goal cannot be completed due to lack of resources.</dd>
298 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="must_be/2"><strong>must_be</strong>(<var>+Type,
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="must_be/2"><strong>must_be</strong>(<var>+Type,
299340 @Term</var>)</a></dt>
300341 <dd class="defbody">
301342 True if <var>Term</var> satisfies the type constraints for <var>Type</var>.
309350 <p>Most of these types are defined by an arity-1 built-in predicate of
310351 the same name. Below is a brief definition of the other types.
311352 <blockquote>
312 <table border="2" frame="box" rules="groups">
313 <tr valign="top"><td>acyclic</td><td>Acyclic term (tree); see <a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a> </td></tr>
314 <tr valign="top"><td>any</td></tr>
315 <tr valign="top"><td><code>between(FloatL,FloatU)</code> </td><td>Number
353 <table class="latex frame-box">
354 <tr><td>acyclic</td><td>Acyclic term (tree); see <a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a> </td></tr>
355 <tr><td>any</td></tr>
356 <tr><td><code>between(FloatL,FloatU)</code> </td><td>Number
316357 [FloatL..FloatU] </td></tr>
317 <tr valign="top"><td><code>between(IntL,IntU)</code> </td><td>Integer
318 [IntL..IntU] </td></tr>
319 <tr valign="top"><td>boolean</td><td>One of <code>true</code> or <code>false</code> </td></tr>
320 <tr valign="top"><td>char</td><td>Atom of length 1 </td></tr>
321 <tr valign="top"><td>chars</td><td>Proper list of 1-character atoms </td></tr>
322 <tr valign="top"><td>code</td><td>Representation Unicode code point </td></tr>
323 <tr valign="top"><td>codes</td><td>Proper list of Unicode character
324 codes </td></tr>
325 <tr valign="top"><td>constant</td><td>Same as <code>atomic</code> </td></tr>
326 <tr valign="top"><td>cyclic</td><td>Cyclic term (rational tree); see <a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a> </td></tr>
327 <tr valign="top"><td>dict</td><td>A dictionary term; see <a class="pred" href="dicts.html#is_dict/1">is_dict/1</a> </td></tr>
328 <tr valign="top"><td>encoding</td><td>Valid name for a character
329 encoding; see <span class="pred-ext">current_encoding/1</span> </td></tr>
330 <tr valign="top"><td>list</td><td>A (non-open) list; see <a class="pred" href="builtinlist.html#is_list/1">is_list/1</a> </td></tr>
331 <tr valign="top"><td>negative_integer</td><td>Integer <var>&lt;</var> 0 </td></tr>
332 <tr valign="top"><td>nonneg</td><td>Integer <code>&gt;=</code> 0 </td></tr>
333 <tr valign="top"><td><code>oneof(L)</code> </td><td>Ground term that is
334 member of L </td></tr>
335 <tr valign="top"><td>positive_integer</td><td>Integer <var>&gt;</var> 0 </td></tr>
336 <tr valign="top"><td>proper_list</td><td>Same as list </td></tr>
337 <tr valign="top"><td><code>list(Type)</code> </td><td>Proper list with
338 elements of <var>Type</var> </td></tr>
339 <tr valign="top"><td>list_or_partial_list</td><td>A list or an open list
340 (ending in a variable); see <span class="pred-ext">is_list_or_partial_list/1</span> </td></tr>
341 <tr valign="top"><td>stream</td><td>A stream name or valid stream
342 handle; see <a class="pred" href="IO.html#is_stream/1">is_stream/1</a> </td></tr>
343 <tr valign="top"><td>symbol</td><td>Same as <code>atom</code> </td></tr>
344 <tr valign="top"><td>text</td><td>One of <code>atom</code>, <code>string</code>, <code>chars</code>
358 <tr><td><code>between(IntL,IntU)</code> </td><td>Integer [IntL..IntU] </td></tr>
359 <tr><td>boolean</td><td>One of <code>true</code> or <code>false</code> </td></tr>
360 <tr><td>char</td><td>Atom of length 1 </td></tr>
361 <tr><td>chars</td><td>Proper list of 1-character atoms </td></tr>
362 <tr><td>code</td><td>Representation Unicode code point </td></tr>
363 <tr><td>codes</td><td>Proper list of Unicode character codes </td></tr>
364 <tr><td>constant</td><td>Same as <code>atomic</code> </td></tr>
365 <tr><td>cyclic</td><td>Cyclic term (rational tree); see <a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a> </td></tr>
366 <tr><td>dict</td><td>A dictionary term; see <a class="pred" href="dicts.html#is_dict/1">is_dict/1</a> </td></tr>
367 <tr><td>encoding</td><td>Valid name for a character encoding; see <span class="pred-ext">current_encoding/1</span> </td></tr>
368 <tr><td>list</td><td>A (non-open) list; see <a class="pred" href="builtinlist.html#is_list/1">is_list/1</a> </td></tr>
369 <tr><td>negative_integer</td><td>Integer <var>&lt;</var> 0 </td></tr>
370 <tr><td>nonneg</td><td>Integer <code>&gt;=</code> 0 </td></tr>
371 <tr><td><code>oneof(L)</code> </td><td>Ground term that is member of L </td></tr>
372 <tr><td>positive_integer</td><td>Integer <var>&gt;</var> 0 </td></tr>
373 <tr><td>proper_list</td><td>Same as list </td></tr>
374 <tr><td><code>list(Type)</code> </td><td>Proper list with elements of <var>Type</var> </td></tr>
375 <tr><td>list_or_partial_list</td><td>A list or an open list (ending in a
376 variable); see <span class="pred-ext">is_list_or_partial_list/1</span> </td></tr>
377 <tr><td>stream</td><td>A stream name or valid stream handle; see <a class="pred" href="IO.html#is_stream/1">is_stream/1</a> </td></tr>
378 <tr><td>symbol</td><td>Same as <code>atom</code> </td></tr>
379 <tr><td>text</td><td>One of <code>atom</code>, <code>string</code>, <code>chars</code>
345380 or <code>codes</code> </td></tr>
346381 </table>
347382 </blockquote>
359394 </dl>
360395
361396 </dd>
362 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_of_type/2"><strong>is_of_type</strong>(<var>+Type,
397 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_of_type/2"><strong>is_of_type</strong>(<var>+Type,
363398 @Term</var>)</a></dt>
364399 <dd class="defbody">
365400 True if <var>Term</var> satisfies <var>Type</var>.</dd>
366 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="has_type/2"><strong>has_type</strong>(<var>+Type,
401 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="has_type/2"><strong>has_type</strong>(<var>+Type,
367402 @Term</var>)</a></dt>
368403 <dd class="defbody">
369404 True if <var>Term</var> satisfies <var>Type</var>.</dd>
370 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_type/3"><strong>current_type</strong>(<var>?Type,
405 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_type/3"><strong>current_type</strong>(<var>?Type,
371406 @Var, -Body</var>)</a></dt>
372407 <dd class="defbody">
373408 True when <var>Type</var> is a currently defined type and <var>Var</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="guidelines.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="threads.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:errors"><a name="sec:8.8"><span class="sec-nr">8.8</span> <span class="sec-title">Compiler
235 <h2 id="sec:errors"><a id="sec:8.8"><span class="sec-nr">8.8</span> <span class="sec-title">Compiler
195236 Errors and Warnings</span></a></h2>
196237
197 <a name="sec:errors"></a> In this section we summarize the most
198 important error and warning messages of the CHR compiler.
199
200 <p><h3 id="sec:chr-errors"><a name="sec:8.8.1"><span class="sec-nr">8.8.1</span> <span class="sec-title">CHR
238 <a id="sec:errors"></a> In this section we summarize the most important
239 error and warning messages of the CHR compiler.
240
241 <p><h3 id="sec:chr-errors"><a id="sec:8.8.1"><span class="sec-nr">8.8.1</span> <span class="sec-title">CHR
201242 Compiler Errors</span></a></h3>
202243
203 <a name="sec:chr-errors"></a>
244 <a id="sec:chr-errors"></a>
204245
205246 <dl class="latex">
206247 <dt><b>Type clash</b></dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.16</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.16</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="dynamic.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="IO.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:examineprog"><a name="sec:4.16"><span class="sec-nr">4.16</span> <span class="sec-title">Examining
235 <h2 id="sec:examineprog"><a id="sec:4.16"><span class="sec-nr">4.16</span> <span class="sec-title">Examining
195236 the program</span></a></h2>
196237
197 <a name="sec:examineprog"></a>
238 <a id="sec:examineprog"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="current_atom/1"><strong>current_atom</strong>(<var>-Atom</var>)</a></dt>
241 <dt class="pubdef"><a id="current_atom/1"><strong>current_atom</strong>(<var>-Atom</var>)</a></dt>
201242 <dd class="defbody">
202243 Successively unifies <var>Atom</var> with all atoms known to the system.
203 Note that <a name="idx:currentatom1:895"></a><a class="pred" href="examineprog.html#current_atom/1">current_atom/1</a>
244 Note that <a id="idx:currentatom1:895"></a><a class="pred" href="examineprog.html#current_atom/1">current_atom/1</a>
204245 always succeeds if <var>Atom</var> is instantiated to an atom.</dd>
205 <dt class="pubdef"><a name="current_blob/2"><strong>current_blob</strong>(<var>?Blob,
246 <dt class="pubdef"><a id="current_blob/2"><strong>current_blob</strong>(<var>?Blob,
206247 ?Type</var>)</a></dt>
207248 <dd class="defbody">
208249 Examine the type or enumerate blobs of the given <var>Type</var>. Typed
209250 blobs are supported through the foreign language interface for storing
210251 arbitrary BLOBs (Binary Large Object) or handles to external entities.
211 See <a class="sec" href="foreigninclude.html">section 11.4.7</a> for
212 details.</dd>
213 <dt class="pubdef"><a name="current_functor/2"><strong>current_functor</strong>(<var>?Name,
252 See <a class="sec" href="foreigninclude.html#sec:11.4.7">section 11.4.7</a>
253 for details.</dd>
254 <dt class="pubdef"><a id="current_functor/2"><strong>current_functor</strong>(<var>?Name,
214255 ?Arity</var>)</a></dt>
215256 <dd class="defbody">
216257 True when <var>Name</var>/<var>Arity</var> is a known functor. This
219260 garbage collection. Due to timing, t/2 below with instantiated
220261 <var>Name</var> and <var>Arity</var> can theoretically fail, i.e., a
221262 functor may be visible in instantiated mode while it is not yet visible
222 in unbound mode. Considering that the only practical value of <a name="idx:currentfunctor2:896"></a><a class="pred" href="examineprog.html#current_functor/2">current_functor/2</a>
263 in unbound mode. Considering that the only practical value of <a id="idx:currentfunctor2:896"></a><a class="pred" href="examineprog.html#current_functor/2">current_functor/2</a>
223264 we are aware of is to analyse resource usage we accept this impure
224265 behaviour.
225266
232273 </pre>
233274
234275 </dd>
235 <dt class="pubdef"><a name="current_flag/1"><strong>current_flag</strong>(<var>-FlagKey</var>)</a></dt>
276 <dt class="pubdef"><a id="current_flag/1"><strong>current_flag</strong>(<var>-FlagKey</var>)</a></dt>
236277 <dd class="defbody">
237278 Successively unifies <var>FlagKey</var> with all keys used for flags
238279 (see
239 <a name="idx:flag3:897"></a><a class="pred" href="db.html#flag/3">flag/3</a>).</dd>
240 <dt class="pubdef"><a name="current_key/1"><strong>current_key</strong>(<var>-Key</var>)</a></dt>
280 <a id="idx:flag3:897"></a><a class="pred" href="db.html#flag/3">flag/3</a>).</dd>
281 <dt class="pubdef"><a id="current_key/1"><strong>current_key</strong>(<var>-Key</var>)</a></dt>
241282 <dd class="defbody">
242283 Successively unifies <var>Key</var> with all keys used for records (see
243 <a name="idx:recorda3:898"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
284 <a id="idx:recorda3:898"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
244285 etc.).</dd>
245 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_predicate/1"><strong>current_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
286 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_predicate/1"><strong>current_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
246287 <dd class="defbody">
247288 True if <var>PredicateIndicator</var> is a currently defined predicate.
248289 A predicate is considered defined if it exists in the specified module,
249290 is imported into the module or is defined in one of the modules from
250291 which the predicate will be imported if it is called (see
251 <a class="sec" href="importmodule.html">section 6.9</a>). Note that <a name="idx:currentpredicate1:899"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>
292 <a class="sec" href="importmodule.html#sec:6.9">section 6.9</a>). Note
293 that <a id="idx:currentpredicate1:899"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>
252294 does <em>not</em> succeed for predicates that can be <em>autoloaded</em>.
253295 See also
254 <a name="idx:currentpredicate2:900"></a><a class="pred" href="examineprog.html#current_predicate/2">current_predicate/2</a>
255 and <a name="idx:predicateproperty2:901"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
296 <a id="idx:currentpredicate2:900"></a><a class="pred" href="examineprog.html#current_predicate/2">current_predicate/2</a>
297 and <a id="idx:predicateproperty2:901"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
256298
257299 <p>If <var>PredicateIndicator</var> is not fully specified, the
258300 predicate only generates values that are defined in or already imported
259301 into the target module. Generating all callable predicates therefore
260 requires enumerating modules using <a name="idx:currentmodule1:902"></a><a class="pred" href="manipmodule.html#current_module/1">current_module/1</a>.
302 requires enumerating modules using <a id="idx:currentmodule1:902"></a><a class="pred" href="manipmodule.html#current_module/1">current_module/1</a>.
261303 Generating predicates callable in a given module requires enumerating
262 the import modules using <a name="idx:importmodule2:903"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>
304 the import modules using <a id="idx:importmodule2:903"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>
263305 and the autoloadable predicates using the
264 <a name="idx:predicateproperty2:904"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a> <code>autoload</code>.</dd>
265 <dt class="pubdef"><a name="current_predicate/2"><strong>current_predicate</strong>(<var>?Name,
306 <a id="idx:predicateproperty2:904"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a> <code>autoload</code>.</dd>
307 <dt class="pubdef"><a id="current_predicate/2"><strong>current_predicate</strong>(<var>?Name,
266308 :Head</var>)</a></dt>
267309 <dd class="defbody">
268 Classical pre-ISO implementation of <a name="idx:currentpredicate1:905"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>,
310 Classical pre-ISO implementation of <a id="idx:currentpredicate1:905"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>,
269311 where the predicate is represented by the head term. The advantage is
270312 that this can be used for checking the existence of a predicate before
271 calling it without the need for <a name="idx:functor3:906"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>:
313 calling it without the need for <a id="idx:functor3:906"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>:
272314
273315 <pre class="code">
274316 call_if_exists(G) :-
276318 call(G).
277319 </pre>
278320
279 <p>Because of this intended usage, <a name="idx:currentpredicate2:907"></a><a class="pred" href="examineprog.html#current_predicate/2">current_predicate/2</a>
321 <p>Because of this intended usage, <a id="idx:currentpredicate2:907"></a><a class="pred" href="examineprog.html#current_predicate/2">current_predicate/2</a>
280322 also succeeds if the predicate can be autoloaded. Unfortunately,
281323 checking the autoloader makes this predicate relatively slow, in
282324 particular because a failed lookup of the autoloader will cause the
283325 autoloader to verify that its index is up-to-date.</dd>
284 <dt class="pubdef"><a name="predicate_property/2"><strong>predicate_property</strong>(<var>:Head,
326 <dt class="pubdef"><a id="predicate_property/2"><strong>predicate_property</strong>(<var>:Head,
285327 ?Property</var>)</a></dt>
286328 <dd class="defbody">
287329 True when <var>Head</var> refers to a predicate that has property
288330 <var>Property</var>. With sufficiently instantiated <var>Head</var>,
289 <a name="idx:predicateproperty2:908"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
331 <a id="idx:predicateproperty2:908"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
290332 tries to resolve the predicate the same way as calling it would do: if
291 the predicate is not defined it scans the default modules (see <a name="idx:defaultmodule2:909"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
333 the predicate is not defined it scans the default modules (see <a id="idx:defaultmodule2:909"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
292334 and finally tries the autoloader. Unlike calling, failure to find the
293335 target predicate causes
294 <a name="idx:predicateproperty2:910"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
336 <a id="idx:predicateproperty2:910"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
295337 to fail silently. If <var>Head</var> is not sufficiently bound, only
296338 currently locally defined and already imported predicates are
297 enumerated. See <a name="idx:currentpredicate1:911"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>
339 enumerated. See <a id="idx:currentpredicate1:911"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>
298340 for enumerating all predicates. A common issue concerns <em>generating</em>
299341 all built-in predicates. This can be achieved using the code below:
300342
322364 True if the predicate is defined. This property is aware of sources
323365 being <em>reloaded</em>, in which case it claims the predicate defined
324366 only if it is defined in another source or it has seen a definition in
325 the current source. See <a name="idx:compileauxclauses1:912"></a><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a>.</dd>
367 the current source. See <a id="idx:compileauxclauses1:912"></a><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a>.</dd>
326368 <dt><strong>dynamic</strong></dt>
327369 <dd class="defbody">
328 True if <a name="idx:assert1:913"></a><a class="pred" href="db.html#assert/1">assert/1</a>
329 and <a name="idx:retract1:914"></a><a class="pred" href="db.html#retract/1">retract/1</a>
330 may be used to modify the predicate. This property is set using <a name="idx:dynamic1:915"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.</dd>
370 True if <a id="idx:assert1:913"></a><a class="pred" href="db.html#assert/1">assert/1</a>
371 and <a id="idx:retract1:914"></a><a class="pred" href="db.html#retract/1">retract/1</a>
372 may be used to modify the predicate. This property is set using <a id="idx:dynamic1:915"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.</dd>
331373 <dt><strong>exported</strong></dt>
332374 <dd class="defbody">
333375 True if the predicate is in the public list of the context module.</dd>
337379 <dt><strong>file</strong>(<var>FileName</var>)</dt>
338380 <dd class="defbody">
339381 Unify <var>FileName</var> with the name of the source file in which the
340 predicate is defined. See also <a name="idx:sourcefile2:916"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>
382 predicate is defined. See also <a id="idx:sourcefile2:916"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>
341383 and the property
342384 <code>line_count</code>. Note that this reports the file of the first
343 clause of a predicate. A more robust interface can be achieved using <a name="idx:nthclause3:917"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
344 and <a name="idx:clauseproperty2:918"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
385 clause of a predicate. A more robust interface can be achieved using <a id="idx:nthclause3:917"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
386 and <a id="idx:clauseproperty2:918"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
345387 <dt><strong>foreign</strong></dt>
346388 <dd class="defbody">
347389 True if the predicate is defined in the C language.</dd>
352394 mechanism as when the an undefined predicate is encountered, but does
353395 not perform any loading. It searches (1) the module inheritence
354396 hierarchy (see
355 <a name="idx:defaultmodule2:919"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
397 <a id="idx:defaultmodule2:919"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
356398 and (2) the autoload index if the <a class="flag" href="flags.html#flag:unknown">unknown</a>
357399 flag is not set to <code>fail</code> in the target module.</dd>
358400 <dt><strong>indexed</strong>(<var>Indexes</var>)</dt>
381423 <dd class="defbody">
382424 Unify <var>LineNumber</var> with the line number of the first clause of
383425 the predicate. Fails if the predicate is not associated with a file. See
384 also <a name="idx:sourcefile2:920"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>.
385 See also the <code>file</code> property above, notably the reference to <a name="idx:clauseproperty2:921"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
426 also <a id="idx:sourcefile2:920"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>.
427 See also the <code>file</code> property above, notably the reference to <a id="idx:clauseproperty2:921"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
386428 <dt><strong>multifile</strong></dt>
387429 <dd class="defbody">
388430 True if there may be multiple (or no) files providing clauses for the
389 predicate. This property is set using <a name="idx:multifile1:922"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.</dd>
431 predicate. This property is set using <a id="idx:multifile1:922"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.</dd>
390432 <dt><strong>meta_predicate</strong>(<var>Head</var>)</dt>
391433 <dd class="defbody">
392 If the predicate is declared as a meta-predicate using <a name="idx:metapredicate1:923"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>,
434 If the predicate is declared as a meta-predicate using <a id="idx:metapredicate1:923"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>,
393435 unify <var>Head</var> with the head-pattern. The head-pattern is a
394436 compound term with the same name and arity as the predicate where each
395 argument of the term is a meta-predicate specifier. See <a name="idx:metapredicate1:924"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
437 argument of the term is a meta-predicate specifier. See <a id="idx:metapredicate1:924"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
396438 for details.</dd>
397439 <dt><strong>nodebug</strong></dt>
398440 <dd class="defbody">
419461 time. Intended to quickly assesses the validity of caches.</dd>
420462 <dt><strong>public</strong></dt>
421463 <dd class="defbody">
422 Predicate is declared public using <a name="idx:public1:925"></a><a class="pred" href="dynamic.html#public/1">public/1</a>.
464 Predicate is declared public using <a id="idx:public1:925"></a><a class="pred" href="dynamic.html#public/1">public/1</a>.
423465 Note that without further definition, public predicates are considered
424466 undefined and this property is <em>not</em> reported.</dd>
425467 <dt><strong>quasi_quotation_syntax</strong></dt>
426468 <dd class="defbody">
427469 The predicate (with arity&nbsp;4) is declared to provide quasi quotation
428 syntax with <a name="idx:quasiquotationsyntax1:926"></a><a class="pred" href="quasiquotations.html#quasi_quotation_syntax/1">quasi_quotation_syntax/1</a>.</dd>
470 syntax with <a id="idx:quasiquotationsyntax1:926"></a><a class="pred" href="quasiquotations.html#quasi_quotation_syntax/1">quasi_quotation_syntax/1</a>.</dd>
429471 <dt><strong>static</strong></dt>
430472 <dd class="defbody">
431 The definition can <em>not</em> be modified using <a name="idx:assertz1:927"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
473 The definition can <em>not</em> be modified using <a id="idx:assertz1:927"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
432474 and friends. This property is the opposite from <code>dynamic</code>,
433475 i.e., for each defined predicate, either <code>static</code> or <code>dynamic</code>
434476 is true but never both.</dd>
436478 <dd class="defbody">
437479 If true (only possible on the multithreaded version) each thread has its
438480 own clauses for the predicate. This property is set using
439 <a name="idx:threadlocal1:928"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
481 <a id="idx:threadlocal1:928"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
440482 <dt><strong>transparent</strong></dt>
441483 <dd class="defbody">
442484 True if the predicate is declared transparent using the
443 <a name="idx:moduletransparent1:929"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
444 or <a name="idx:metapredicate1:930"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
485 <a id="idx:moduletransparent1:929"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
486 or <a id="idx:metapredicate1:930"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
445487 declaration. In the latter case the property <code>meta_predicate(Head)</code>
446 is also provided. See <a class="sec" href="modules.html">chapter 6</a>
488 is also provided. See <a class="sec" href="modules.html#sec:6">chapter 6</a>
447489 for details.</dd>
448490 <dt><strong>undefined</strong></dt>
449491 <dd class="defbody">
453495 attempt to call it has been made via one of the meta-call predicates,
454496 the predicate has been declared as e.g., a meta-predicate or the
455497 predicate had a definition in the past. Originally used to find missing
456 predicate definitions. The current implementation of <a name="idx:listundefined0:931"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>
498 predicate definitions. The current implementation of <a id="idx:listundefined0:931"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>
457499 used cross-referencing. Deprecated.</dd>
458500 <dt><strong>visible</strong></dt>
459501 <dd class="defbody">
460502 True when predicate can be called without raising a predicate existence
461503 error. This means that the predicate is (1) defined, (2) can be
462 inherited from one of the default modules (see <a name="idx:defaultmodule2:932"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
504 inherited from one of the default modules (see <a id="idx:defaultmodule2:932"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
463505 or (3) can be autoloaded. The behaviour is logically consistent iff the
464506 property
465507 <code>visible</code> is provided explicitly. If the property is left
466508 unbound, only defined predicates are enumerated.</dd>
467509 <dt><strong>volatile</strong></dt>
468510 <dd class="defbody">
469 If true, the clauses are not saved into a saved state by <a name="idx:qsaveprogram12:933"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.
470 This property is set using <a name="idx:volatile1:934"></a><a class="pred" href="runtime.html#volatile/1">volatile/1</a>.
511 If true, the clauses are not saved into a saved state by <a id="idx:qsaveprogram12:933"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.
512 This property is set using <a id="idx:volatile1:934"></a><a class="pred" href="runtime.html#volatile/1">volatile/1</a>.
471513 </dd>
472514 </dl>
473515
474516 </dd>
475 <dt class="pubdef"><a name="dwim_predicate/2"><strong>dwim_predicate</strong>(<var>+Term,
517 <dt class="pubdef"><a id="dwim_predicate/2"><strong>dwim_predicate</strong>(<var>+Term,
476518 -Dwim</var>)</a></dt>
477519 <dd class="defbody">
478520 `Do What I Mean' (`dwim') support predicate. <var>Term</var> is a term,
480522 is instantiated with the most general term built from <var>Name</var>
481523 and the arity of a defined predicate that matches the predicate
482524 specified by
483 <var>Term</var> in the `Do What I Mean' sense. See <a name="idx:dwimmatch2:935"></a><a class="pred" href="miscpreds.html#dwim_match/2">dwim_match/2</a>
525 <var>Term</var> in the `Do What I Mean' sense. See <a id="idx:dwimmatch2:935"></a><a class="pred" href="miscpreds.html#dwim_match/2">dwim_match/2</a>
484526 for `Do What I Mean' string matching. Internal system predicates are not
485527 generated, unless the access level is <code>system</code> (see
486528 <a class="flag" href="flags.html#flag:access_level">access_level</a>).
487529 Backtracking provides all alternative matches.</dd>
488 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="clause/2"><strong>clause</strong>(<var>:Head,
530 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="clause/2"><strong>clause</strong>(<var>:Head,
489531 ?Body</var>)</a></dt>
490532 <dd class="defbody">
491533 True if <var>Head</var> can be unified with a clause head and <var>Body</var>
492534 with the corresponding clause body. Gives alternative clauses on
493535 backtracking. For facts, <var>Body</var> is unified with the atom <var>true</var>.</dd>
494 <dt class="pubdef"><a name="clause/3"><strong>clause</strong>(<var>:Head,
536 <dt class="pubdef"><a id="clause/3"><strong>clause</strong>(<var>:Head,
495537 ?Body, ?Reference</var>)</a></dt>
496538 <dd class="defbody">
497 Equivalent to <a name="idx:clause2:936"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>,
539 Equivalent to <a id="idx:clause2:936"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>,
498540 but unifies <var>Reference</var> with a unique reference to the clause
499 (see also <a name="idx:assert2:937"></a><a class="pred" href="db.html#assert/2">assert/2</a>, <a name="idx:erase1:938"></a><a class="pred" href="db.html#erase/1">erase/1</a>).
541 (see also <a id="idx:assert2:937"></a><a class="pred" href="db.html#assert/2">assert/2</a>, <a id="idx:erase1:938"></a><a class="pred" href="db.html#erase/1">erase/1</a>).
500542 If <var>Reference</var> is instantiated to a reference the clause's head
501543 and body will be unified with <var>Head</var> and <var>Body</var>.</dd>
502 <dt class="pubdef"><a name="nth_clause/3"><strong>nth_clause</strong>(<var>?Pred,
544 <dt class="pubdef"><a id="nth_clause/3"><strong>nth_clause</strong>(<var>?Pred,
503545 ?Index, ?Reference</var>)</a></dt>
504546 <dd class="defbody">
505547 Provides access to the clauses of a predicate using their index number.
510552 is provided, <var>Reference</var> will be unified with the clause
511553 reference. If <var>Index</var> is unbound, backtracking will yield both
512554 the indexes and the references of all clauses of the predicate. The
513 following example finds the 2nd clause of <a name="idx:append3:939"></a><a class="pred" href="lists.html#append/3">append/3</a>:
555 following example finds the 2nd clause of <a id="idx:append3:939"></a><a class="pred" href="lists.html#append/3">append/3</a>:
514556
515557 <pre class="code">
516558 ?- use_module(library(lists)).
522564 </pre>
523565
524566 </dd>
525 <dt class="pubdef"><a name="clause_property/2"><strong>clause_property</strong>(<var>+ClauseRef,
567 <dt class="pubdef"><a id="clause_property/2"><strong>clause_property</strong>(<var>+ClauseRef,
526568 -Property</var>)</a></dt>
527569 <dd class="defbody">
528570 Queries properties of a clause. <var>ClauseRef</var> is a reference to a
529 clause as produced by <a name="idx:clause3:940"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>, <a name="idx:nthclause3:941"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
571 clause as produced by <a id="idx:clause3:940"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>, <a id="idx:nthclause3:941"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
530572 or
531 <a name="idx:prologframeattribute3:942"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>.
532 Unlike most other predicates that access clause references, <a name="idx:clauseproperty2:943"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>
573 <a id="idx:prologframeattribute3:942"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>.
574 Unlike most other predicates that access clause references, <a id="idx:clauseproperty2:943"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>
533575 may be used to get information about erased clauses that have not yet
534576 been reclaimed. <var>Property</var> is one of the following:
535577
538580 <dd class="defbody">
539581 Unify <var>FileName</var> with the name of the file from which the
540582 clause is loaded. Fails if the clause was not created by loading a file
541 (e.g., clauses added using <a name="idx:assertz1:944"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>).
583 (e.g., clauses added using <a id="idx:assertz1:944"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>).
542584 See also <code>source</code>.
543585 </dd>
544586 <dt><strong>line_count</strong>(<var>LineNumber</var>)</dt>
559601 the clause. This is the same as the <code>file</code> property, unless
560602 the file is loaded from a file that is textually included into source
561603 using
562 <a name="idx:include1:945"></a><a class="pred" href="consulting.html#include/1">include/1</a>.
604 <a id="idx:include1:945"></a><a class="pred" href="consulting.html#include/1">include/1</a>.
563605 In this scenario, <code>file</code> is the included file, while the <code>source</code>
564606 property refers to the <em>main</em> file.
565607 </dd>
576618 <dd class="defbody">
577619 <var>PredicateIndicator</var> denotes the predicate to which this clause
578620 belongs. This is needed to obtain information on erased clauses because
579 the usual way to obtain this information using <a name="idx:clause3:946"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>
621 the usual way to obtain this information using <a id="idx:clause3:946"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>
580622 fails for erased clauses.
581623 </dd>
582624 <dt><strong>module</strong>(<var>Module</var>)</dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="debugging.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="sicstus-chr.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:examples"><a name="sec:8.5"><span class="sec-nr">8.5</span> <span class="sec-title">Examples</span></a></h2>
195
196 <a name="sec:examples"></a> Here are two example constraint solvers
235 <h2 id="sec:examples"><a id="sec:8.5"><span class="sec-nr">8.5</span> <span class="sec-title">Examples</span></a></h2>
236
237 <a id="sec:examples"></a> Here are two example constraint solvers
197238 written in CHR.
198239
199240 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="breakpoint.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="exception3.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:excepthook"><a name="sec:B.5"><span class="sec-nr">B.5</span> <span class="sec-title">Adding
235 <h2 id="sec:excepthook"><a id="sec:B.5"><span class="sec-nr">B.5</span> <span class="sec-title">Adding
195236 context to errors: prolog_exception_hook</span></a></h2>
196237
197 <a name="sec:excepthook"></a>
198
199 <p>The hook <a name="idx:prologexceptionhook4:2204"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
238 <a id="sec:excepthook"></a>
239
240 <p>The hook <a id="idx:prologexceptionhook4:2208"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
200241 has been introduced in SWI-Prolog 5.6.5 to provide dedicated exception
201242 handling facilities for application frameworks, for example
202243 non-interactive server applications that wish to provide extensive
203244 context for exceptions for offline debugging.
204245
205246 <dl class="latex">
206 <dt class="pubdef"><a name="prolog_exception_hook/4"><strong>prolog_exception_hook</strong>(<var>+ExceptionIn,
247 <dt class="pubdef"><a id="prolog_exception_hook/4"><strong>prolog_exception_hook</strong>(<var>+ExceptionIn,
207248 -ExceptionOut, +Frame, +CatcherFrame</var>)</a></dt>
208249 <dd class="defbody">
209250 This hook predicate, if defined in the module <code>user</code>, is
210251 between raising an exception and handling it. It is intended to allow a
211252 program adding additional context to an exception to simplify diagnosing
212 the problem. <var>ExceptionIn</var> is the exception term as raised by <a name="idx:throw1:2205"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
253 the problem. <var>ExceptionIn</var> is the exception term as raised by <a id="idx:throw1:2209"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
213254 or one of the built-in predicates. The output argument <var>ExceptionOut</var>
214255 describes the exception that is actually raised. <var>Frame</var> is the
215 innermost frame. See <a name="idx:prologframeattribute3:2206"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>
256 innermost frame. See <a id="idx:prologframeattribute3:2210"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>
216257 and the library
217258 <code>library(prolog_stack)</code> for getting information from this.
218259 <var>CatcherFrame</var> is a reference to the frame calling the matching
219 <a name="idx:catch3:2207"></a><a class="pred" href="exception.html#catch/3">catch/3</a>, <code>none</code>
260 <a id="idx:catch3:2211"></a><a class="pred" href="exception.html#catch/3">catch/3</a>, <code>none</code>
220261 if the exception is not caught or <code>'C'</code> if the exception is
221262 caught in C calling Prolog using the flag
222263 <code>PL_Q_CATCH_EXCEPTION</code>.
227268 recursively. The hook is <em>not</em> allowed to modify <var>ExceptionOut</var>
228269 in such a way that it no longer unifies with the catching frame.
229270
230 <p>Typically, <a name="idx:prologexceptionhook4:2208"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
271 <p>Typically, <a id="idx:prologexceptionhook4:2212"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
231272 is used to fill the second argument of <code>error(Formal, Context)</code>
232273 exceptions. <var>Formal</var> is defined by the ISO standard, while
233274 SWI-Prolog defines <var>Context</var> as a term <code>context(Location,
239280 a quick test of the environment before starting expensive gathering
240281 information on the state of the program.
241282
242 <p>The hook can call <a name="idx:trace0:2209"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
283 <p>The hook can call <a id="idx:trace0:2213"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
243284 to enter trace mode immediately. For example, imagine an application
244285 performing an unwanted division by zero while all other errors are
245286 expected and handled. We can force the debugger using the hook
246 definition below. Run the program in debug mode (see <a name="idx:debug0:2210"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>)
287 definition below. Run the program in debug mode (see <a id="idx:debug0:2214"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>)
247288 to preserve as much as possible of the error context.
248289
249290 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.11</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="delcont.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="signal.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:exception"><a name="sec:4.11"><span class="sec-nr">4.11</span> <span class="sec-title">Exception
235 <h2 id="sec:exception"><a id="sec:4.11"><span class="sec-nr">4.11</span> <span class="sec-title">Exception
195236 handling</span></a></h2>
196237
197 <a name="sec:exception"></a>
198
199 <p>The predicates <a name="idx:catch3:691"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
200 and <a name="idx:throw1:692"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
238 <a id="sec:exception"></a>
239
240 <p>The predicates <a id="idx:catch3:691"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
241 and <a id="idx:throw1:692"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
201242 provide ISO compliant raising and catching of exceptions.
202243
203244 <dl class="latex">
204 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="catch/3"><strong>catch</strong>(<var>:Goal,
245 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="catch/3"><strong>catch</strong>(<var>:Goal,
205246 +Catcher, :Recover</var>)</a></dt>
206247 <dd class="defbody">
207 Behaves as <a name="idx:call1:693"></a><a class="pred" href="metacall.html#call/1">call/1</a>
248 Behaves as <a id="idx:call1:693"></a><a class="pred" href="metacall.html#call/1">call/1</a>
208249 if no exception is raised when executing <var>Goal</var>. If an
209 exception is raised using <a name="idx:throw1:694"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
250 exception is raised using <a id="idx:throw1:694"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
210251 while <var>Goal</var> executes, and the <var>Goal</var> is the innermost
211 goal for which <var>Catcher</var> unifies with the argument of <a name="idx:throw1:695"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
252 goal for which <var>Catcher</var> unifies with the argument of <a id="idx:throw1:695"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
212253 all choice points generated by <var>Goal</var> are cut, the system
213 backtracks to the start of <a name="idx:catch3:696"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
254 backtracks to the start of <a id="idx:catch3:696"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
214255 while preserving the thrown exception term, and <var>Recover</var> is
215 called as in <a name="idx:call1:697"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
216
217 <p>The overhead of calling a goal through <a name="idx:catch3:698"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
256 called as in <a id="idx:call1:697"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
257
258 <p>The overhead of calling a goal through <a id="idx:catch3:698"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
218259 is comparable to
219 <a name="idx:call1:699"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
260 <a id="idx:call1:699"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
220261 Recovery from an exception is much slower, especially if the exception
221262 term is large due to the copying thereof or is decorated with a stack
222263 trace using, e.g., the library <code>library(prolog_stack)</code> based
223264 on the
224 <a name="idx:prologexceptionhook4:700"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
265 <a id="idx:prologexceptionhook4:700"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
225266 hook predicate to rewrite exceptions.</dd>
226 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="throw/1"><strong>throw</strong>(<var>+Exception</var>)</a></dt>
227 <dd class="defbody">
228 Raise an exception. The system looks for the innermost <a name="idx:catch3:701"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
267 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="throw/1"><strong>throw</strong>(<var>+Exception</var>)</a></dt>
268 <dd class="defbody">
269 Raise an exception. The system looks for the innermost <a id="idx:catch3:701"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
229270 ancestor for which <var>Exception</var> unifies with the <var>Catcher</var>
230 argument of the <a name="idx:catch3:702"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
231 call. See <a name="idx:catch3:703"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
271 argument of the <a id="idx:catch3:702"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
272 call. See <a id="idx:catch3:703"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
232273 for details.
233274
234 <p>ISO demands that <a name="idx:throw1:704"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
235 make a copy of <var>Exception</var>, walk up the stack to a <a name="idx:catch3:705"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
275 <p>ISO demands that <a id="idx:throw1:704"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
276 make a copy of <var>Exception</var>, walk up the stack to a <a id="idx:catch3:705"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
236277 call, backtrack and try to unify the copy of
237278 <var>Exception</var> with <var>Catcher</var>. SWI-Prolog delays
238 backtracking until it actually finds a matching <a name="idx:catch3:706"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
279 backtracking until it actually finds a matching <a id="idx:catch3:706"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
239280 goal. The advantage is that we can start the debugger at the first
240281 possible location while preserving the entire exception context if there
241 is no matching <a name="idx:catch3:707"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
282 is no matching <a id="idx:catch3:707"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
242283 goal. This approach can lead to different behaviour if <var>Goal</var>
243 and <var>Catcher</var> of <a name="idx:catch3:708"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
284 and <var>Catcher</var> of <a id="idx:catch3:708"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
244285 call shared variables. We assume this to be highly unlikely and could
245286 not think of a scenario where this is useful.<sup class="fn">69<span class="fn-text">I'd
246287 like to acknowledge Bart Demoen for his clarifications on these matters.</span></sup>
247288
248 <p>In addition to explicit calls to <a name="idx:throw1:709"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
289 <p>In addition to explicit calls to <a id="idx:throw1:709"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
249290 many built-in predicates throw exceptions directly from C. If the <var>Exception</var>
250291 term cannot be copied due to lack of stack space, the following actions
251292 are tried in order:
256297 ImplementationDefined)</code>, try to raise the exception without the <var>ImplementationDefined</var>
257298 part.
258299 <li>Try to raise <code>error(<code>resource_error(stack)</code>, global)</code>.
259 <li>Abort (see <a name="idx:abort0:710"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
300 <li>Abort (see <a id="idx:abort0:710"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
260301 </ol>
261302
262 <p>If an exception is raised in a call-back from C (see <a class="sec" href="foreign.html">chapter
303 <p>If an exception is raised in a call-back from C (see <a class="sec" href="foreign.html#sec:11">chapter
263304 11</a>) and not caught in the same call-back, <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>
264305 fails and the exception context can be retrieved using <a class="func" href="foreigninclude.html#PL_exception()">PL_exception()</a>.
265306 </dd>
266307 </dl>
267308
268 <p><h3 id="sec:urgentexceptions"><a name="sec:4.11.1"><span class="sec-nr">4.11.1</span> <span class="sec-title">Urgency
309 <p><h3 id="sec:urgentexceptions"><a id="sec:4.11.1"><span class="sec-nr">4.11.1</span> <span class="sec-title">Urgency
269310 of exceptions</span></a></h3>
270311
271 <a name="sec:urgentexceptions"></a>
312 <a id="sec:urgentexceptions"></a>
272313
273314 <p>Under some conditions an exception may be raised as a result of
274315 handling another exception. Below are some of the scenarios:
275316
276317 <p>
277318 <ul class="latex">
278 <li>The predicate <a name="idx:setupcallcleanup3:711"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
319 <li>The predicate <a id="idx:setupcallcleanup3:711"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
279320 calls the cleanup handler as a result of an exception and the cleanup
280321 handler raises an exception itself. In this case the most <em>urgent</em>
281322 exception is propagated into the environment.
283324 stack space to store the exception. In this case a resource exception is
284325 raised. If that too fails the system tries to raise a resource exception
285326 without (stack) context. If that fails it will raise the exception
286 <code>'$aborted'</code>, also raised by <a name="idx:abort0:712"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
327 <code>'$aborted'</code>, also raised by <a id="idx:abort0:712"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
287328 As no stack space is required for processing this atomic exception, this
288329 should always succeed.
289330 <li>Certain <em>callback</em> operations raise an exception while
290331 processing another exception or a previous callback already raised an
291332 exception before there was an opportunity to process the exception. The
292 most notable <em>callback</em> subject to this issue are <a name="idx:prologeventhook1:713"></a><span class="pred-ext">prolog_event_hook/1</span>
293 (supporting e.g., the graphical debugger), <a name="idx:prologexceptionhook4:714"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
294 (rewriting exceptions, e.g., by adding context) and <a name="idx:printmessage2:715"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
333 most notable <em>callback</em> subject to this issue are <a id="idx:prologeventhook1:713"></a><span class="pred-ext">prolog_event_hook/1</span>
334 (supporting e.g., the graphical debugger), <a id="idx:prologexceptionhook4:714"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
335 (rewriting exceptions, e.g., by adding context) and <a id="idx:printmessage2:715"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
295336 when called from the core facilities such as the internal debugger. As
296337 with
297 <a name="idx:setupcallcleanup3:716"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>,
338 <a id="idx:setupcallcleanup3:716"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>,
298339 the most <em>urgent</em> exception is preserved.
299340 </ul>
300341
303344
304345 <p>
305346 <ol class="latex">
306 <li><code>'$aborted'</code> (<a name="idx:abort0:717"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>)
307 <li><code>time_limit_exceeded</code> (<a name="idx:callwithtimelimit2:718"></a><span class="pred-ext">call_with_time_limit/2</span>)
347 <li><code>'$aborted'</code> (<a id="idx:abort0:717"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>)
348 <li><code>time_limit_exceeded</code> (<a id="idx:callwithtimelimit2:718"></a><span class="pred-ext">call_with_time_limit/2</span>)
308349 <li><code>error(<code>resource_error(Resource)</code>, Context)</code>
309350 <li><code>error(Formal, Context)</code>
310351 <li>All other exceptions
312353
313354 <p><b>Note</b> The above resolution is not described in the ISO
314355 standard. This is not needed either because ISO does not specify
315 <a name="idx:setupcallcleanup3:719"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
356 <a id="idx:setupcallcleanup3:719"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
316357 and does not deal with environment management issues such as (debugger)
317 callbacks. Neither does it define <a name="idx:abort0:720"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
318 or timeout handling. Notably <a name="idx:abort0:721"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
358 callbacks. Neither does it define <a id="idx:abort0:720"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
359 or timeout handling. Notably <a id="idx:abort0:721"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
319360 and timeout are non-logical control structures. They are implemented on
320361 top of exceptions as they need to unwind the stack, destroy choice
321362 points and call cleanup handlers in the same way. However, the pending
322363 exception should not be replaced by another one before the intended
323364 handler is reached. The abort exception cannot be caught, something
324 which is achieved by wrapping the <em>cleanup handler</em> of <a name="idx:catch3:722"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
365 which is achieved by wrapping the <em>cleanup handler</em> of <a id="idx:catch3:722"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
325366 into
326367 <code>call_cleanup(Handler, abort)</code>.
327368
328 <p><h3 id="sec:debugexceptions"><a name="sec:4.11.2"><span class="sec-nr">4.11.2</span> <span class="sec-title">Debugging
369 <p><h3 id="sec:debugexceptions"><a id="sec:4.11.2"><span class="sec-nr">4.11.2</span> <span class="sec-title">Debugging
329370 and exceptions</span></a></h3>
330371
331 <a name="sec:debugexceptions"></a>
332
333 <p><a name="idx:exceptionsdebugging:723"></a><a name="idx:debuggingexceptions:724"></a>Before
372 <a id="sec:debugexceptions"></a>
373
374 <p><a id="idx:exceptionsdebugging:723"></a><a id="idx:debuggingexceptions:724"></a>Before
334375 the introduction of exceptions in SWI-Prolog a runtime error was handled
335376 by printing an error message, after which the predicate failed. If the
336377 Prolog flag <a class="flag" href="flags.html#flag:debug_on_error">debug_on_error</a>
339380 locate the error.
340381
341382 <p>With exception handling, things are different. A programmer may wish
342 to trap an exception using <a name="idx:catch3:725"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
383 to trap an exception using <a id="idx:catch3:725"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
343384 to avoid it reaching the user. If the exception is not handled by user
344385 code, the interactive top level will trap it to prevent termination.
345386
346387 <p>If we do not take special precautions, the context information
347388 associated with an unexpected exception (i.e., a programming error) is
348389 lost. Therefore, if an exception is raised which is not caught using
349 <a name="idx:catch3:726"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
390 <a id="idx:catch3:726"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
350391 and the top level is running, the error will be printed, and the system
351392 will enter trace mode.
352393
353394 <p>If the system is in a non-interactive call-back from foreign code and
354 there is no <a name="idx:catch3:727"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
395 there is no <a id="idx:catch3:727"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
355396 active in the current context, it cannot determine whether or not the
356397 exception will be caught by the external routine calling Prolog. It will
357398 then base its behaviour on the Prolog flag
369410 </ul>
370411
371412 <p>While looking for the context in which an exception takes place, it
372 is advised to switch on debug mode using the predicate <a name="idx:debug0:728"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.
413 is advised to switch on debug mode using the predicate <a id="idx:debug0:728"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.
373414 The hook
374 <a name="idx:prologexceptionhook4:729"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
415 <a id="idx:prologexceptionhook4:729"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
375416 can be used to add more debugging facilities to exceptions. An example
376417 is the library <code>library(http/http_error)</code>, generating a full
377418 stack trace on errors in the HTTP server library.
378419
379 <p><h3 id="sec:exceptterm"><a name="sec:4.11.3"><span class="sec-nr">4.11.3</span> <span class="sec-title">The
420 <p><h3 id="sec:exceptterm"><a id="sec:4.11.3"><span class="sec-nr">4.11.3</span> <span class="sec-title">The
380421 exception term</span></a></h3>
381422
382 <a name="sec:exceptterm"></a>
423 <a id="sec:exceptterm"></a>
383424
384425 <p>Built-in predicates generate exceptions using a term
385426 <code>error(Formal, Context)</code>. The first argument is the `formal'
393434 description of the error. Any part of this structure may be a variable
394435 if no information was present.
395436
396 <p><h3 id="sec:printmsg"><a name="sec:4.11.4"><span class="sec-nr">4.11.4</span> <span class="sec-title">Printing
437 <p><h3 id="sec:printmsg"><a id="sec:4.11.4"><span class="sec-nr">4.11.4</span> <span class="sec-title">Printing
397438 messages</span></a></h3>
398439
399 <a name="sec:printmsg"></a>
400
401 <p>The predicate <a name="idx:printmessage2:730"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
440 <a id="sec:printmsg"></a>
441
442 <p>The predicate <a id="idx:printmessage2:730"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
402443 is used to print a message term in a human-readable format. The other
403444 predicates from this section allow the user to refine and extend the
404445 message system. A common usage of
405 <a name="idx:printmessage2:731"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
446 <a id="idx:printmessage2:731"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
406447 is to print error messages from exceptions. The code below prints errors
407448 encountered during the execution of <var>Goal</var>, without further
408449 propagating the exception and without starting the debugger.
416457 ...
417458 </pre>
418459
419 <p>Another common use is to define <a name="idx:messagehook3:732"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
460 <p>Another common use is to define <a id="idx:messagehook3:732"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
420461 for printing messages that are normally <em>silent</em>, suppressing
421462 messages, redirecting messages or make something happen in addition to
422463 printing the message.
423464
424465 <dl class="latex">
425 <dt class="pubdef"><a name="print_message/2"><strong>print_message</strong>(<var>+Kind,
466 <dt class="pubdef"><a id="print_message/2"><strong>print_message</strong>(<var>+Kind,
426467 +Term</var>)</a></dt>
427468 <dd class="defbody">
428 The predicate <a name="idx:printmessage2:733"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
469 The predicate <a id="idx:printmessage2:733"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
429470 is used by the system and libraries to print messages. <var>Kind</var>
430471 describes the nature of the message, while
431472 <var>Term</var> is a Prolog term that describes the content. Printing
432 messages through this indirection instead of using <a name="idx:format3:734"></a><a class="pred" href="format.html#format/3">format/3</a>
473 messages through this indirection instead of using <a id="idx:format3:734"></a><a class="pred" href="format.html#format/3">format/3</a>
433474 to the stream <code>user_error</code> allows displaying the message
434475 appropriate to the application (terminal, logfile, graphics), acting on
435 messages based on their content instead of a string (see <a name="idx:messagehook3:735"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>)
476 messages based on their content instead of a string (see <a id="idx:messagehook3:735"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>)
436477 and creating language specific versions of the messages. See also
437 <a class="sec" href="exception.html">section 4.11.4.1</a>. The following
438 message kinds are known:
478 <a class="sec" href="exception.html#sec:4.11.4.1">section 4.11.4.1</a>.
479 The following message kinds are known:
439480
440481 <dl class="latex">
441482 <dt><strong>banner</strong></dt>
445486 to <code>silent</code>.</dd>
446487 <dt><strong>debug</strong>(<var>Topic</var>)</dt>
447488 <dd class="defbody">
448 Message from library(debug). See <a name="idx:debug3:736"></a><a class="pred" href="debug.html#debug/3">debug/3</a>.</dd>
489 Message from library(debug). See <a id="idx:debug3:736"></a><a class="pred" href="debug.html#debug/3">debug/3</a>.</dd>
449490 <dt><strong>error</strong></dt>
450491 <dd class="defbody">
451492 The message indicates an erroneous situation. This kind is used to print
452493 uncaught exceptions of type <code>error(Formal, Context)</code>. See
453 section introduction (<a class="sec" href="exception.html">section
494 section introduction (<a class="sec" href="exception.html#sec:4.11.4">section
454495 4.11.4</a>).</dd>
455496 <dt><strong>help</strong></dt>
456497 <dd class="defbody">
458499 prompt.</dd>
459500 <dt><strong>information</strong></dt>
460501 <dd class="defbody">
461 Information that is requested by the user. An example is <a name="idx:statistics0:737"></a><a class="pred" href="statistics.html#statistics/0">statistics/0</a>.</dd>
502 Information that is requested by the user. An example is <a id="idx:statistics0:737"></a><a class="pred" href="statistics.html#statistics/0">statistics/0</a>.</dd>
462503 <dt><strong>informational</strong></dt>
463504 <dd class="defbody">
464505 Typically messages of events are progres that are considered useful to a
467508 <dt><strong>silent</strong></dt>
468509 <dd class="defbody">
469510 Message that is normally not printed. Applications may define
470 <a name="idx:messagehook3:738"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
511 <a id="idx:messagehook3:738"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
471512 to act upon such messages.</dd>
472513 <dt><strong>trace</strong></dt>
473514 <dd class="defbody">
475516 <dt><strong>warning</strong></dt>
476517 <dd class="defbody">
477518 The message indicates something dubious that is not considered fatal.
478 For example, discontiguous predicates (see <a name="idx:discontiguous1:739"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>).
519 For example, discontiguous predicates (see <a id="idx:discontiguous1:739"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>).
479520 </dd>
480521 </dl>
481522
482 <p>The predicate <a name="idx:printmessage2:740"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
483 first translates the <var>Term</var> into a list of `message lines' (see <a name="idx:printmessagelines3:741"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>
484 for details). Next, it calls the hook <a name="idx:messagehook3:742"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
485 to allow the user to intercept the message. If <a name="idx:messagehook3:743"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
523 <p>The predicate <a id="idx:printmessage2:740"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
524 first translates the <var>Term</var> into a list of `message lines' (see <a id="idx:printmessagelines3:741"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>
525 for details). Next, it calls the hook <a id="idx:messagehook3:742"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
526 to allow the user to intercept the message. If <a id="idx:messagehook3:743"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
486527 fails it prints the message unless <var>Kind</var> is silent.
487528
488 <p>The <a name="idx:printmessage2:744"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
529 <p>The <a id="idx:printmessage2:744"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
489530 predicate and its rules are in the file
490531 <code>&lt;<var>plhome</var>&gt;/boot/messages.pl</code>, which may be
491532 inspected for more information on the error messages and related error
494535 existing message term is applicable, invent a fairly unique term that
495536 represents the event and define a rule for the multifile predicate
496537 prolog:message//1. See
497 <a class="sec" href="exception.html">section 4.11.4.1</a> for a deeper
498 discussion and examples.
499
500 <p>See also <a name="idx:messagetostring2:745"></a><a class="pred" href="exception.html#message_to_string/2">message_to_string/2</a>.</dd>
501 <dt class="pubdef"><a name="print_message_lines/3"><strong>print_message_lines</strong>(<var>+Stream,
538 <a class="sec" href="exception.html#sec:4.11.4.1">section 4.11.4.1</a>
539 for a deeper discussion and examples.
540
541 <p>See also <a id="idx:messagetostring2:745"></a><a class="pred" href="exception.html#message_to_string/2">message_to_string/2</a>.</dd>
542 <dt class="pubdef"><a id="print_message_lines/3"><strong>print_message_lines</strong>(<var>+Stream,
502543 +Prefix, +Lines</var>)</a></dt>
503544 <dd class="defbody">
504 Print a message (see <a name="idx:printmessage2:746"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>)
545 Print a message (see <a id="idx:printmessage2:746"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>)
505546 that has been translated to a list of message elements. The elements of
506547 this list are:
507548
509550 <dt><strong>&lt;<var>Format</var>&gt;-&lt;<var>Args</var>&gt;</strong></dt>
510551 <dd class="defbody">
511552 Where <var>Format</var> is an atom and <var>Args</var> is a list of
512 format arguments. Handed to <a name="idx:format3:747"></a><a class="pred" href="format.html#format/3">format/3</a>.
553 format arguments. Handed to <a id="idx:format3:747"></a><a class="pred" href="format.html#format/3">format/3</a>.
513554 </dd>
514555 <dt><strong>flush</strong></dt>
515556 <dd class="defbody">
516 If this appears as the last element, <var>Stream</var> is flushed (see <a name="idx:flushoutput1:748"></a><a class="pred" href="chario.html#flush_output/1">flush_output/1</a>)
557 If this appears as the last element, <var>Stream</var> is flushed (see <a id="idx:flushoutput1:748"></a><a class="pred" href="chario.html#flush_output/1">flush_output/1</a>)
517558 and no final newline is generated. This is combined with a subsequent
518559 message that starts with
519560 <code>at_same_line</code> to complete the line.
521562 <dt><strong>at_same_line</strong></dt>
522563 <dd class="defbody">
523564 If this appears as first element, no prefix is printed for the first
524 line and the line position is not forced to 0 (see <a name="idx:format1:749"></a><a class="pred" href="format.html#format/1">format/1</a>, <code>~N</code>).
565 line and the line position is not forced to 0 (see <a id="idx:format1:749"></a><a class="pred" href="format.html#format/1">format/1</a>, <code>~N</code>).
525566 </dd>
526567 <dt><strong>ansi</strong>(<var>+Attributes, +Format, +Args</var>)</dt>
527568 <dd class="defbody">
544585 </dd>
545586 <dt><strong>&lt;<var>Format</var>&gt;</strong></dt>
546587 <dd class="defbody">
547 Handed to <a name="idx:format3:750"></a><a class="pred" href="format.html#format/3">format/3</a>
588 Handed to <a id="idx:format3:750"></a><a class="pred" href="format.html#format/3">format/3</a>
548589 as <code>format(Stream, Format,[])</code>. Deprecated because it is
549590 ambiguous if <var>Format</var> collides with one of the atomic commands.
550591 </dd>
551592 </dl>
552593
553 <p>See also <a name="idx:printmessage2:751"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
554 and <a name="idx:messagehook3:752"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.</dd>
555 <dt class="pubdef"><a name="message_hook/3"><strong>message_hook</strong>(<var>+Term,
594 <p>See also <a id="idx:printmessage2:751"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
595 and <a id="idx:messagehook3:752"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.</dd>
596 <dt class="pubdef"><a id="message_hook/3"><strong>message_hook</strong>(<var>+Term,
556597 +Kind, +Lines</var>)</a></dt>
557598 <dd class="defbody">
558599 Hook predicate that may be defined in the module <code>user</code> to
559 intercept messages from <a name="idx:printmessage2:753"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>. <var>Term</var>
560 and <var>Kind</var> are the same as passed to <a name="idx:printmessage2:754"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>. <var>Lines</var>
561 is a list of format statements as described with <a name="idx:printmessagelines3:755"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>.
600 intercept messages from <a id="idx:printmessage2:753"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>. <var>Term</var>
601 and <var>Kind</var> are the same as passed to <a id="idx:printmessage2:754"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>. <var>Lines</var>
602 is a list of format statements as described with <a id="idx:printmessagelines3:755"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>.
562603 See also
563 <a name="idx:messagetostring2:756"></a><a class="pred" href="exception.html#message_to_string/2">message_to_string/2</a>.
604 <a id="idx:messagetostring2:756"></a><a class="pred" href="exception.html#message_to_string/2">message_to_string/2</a>.
564605
565606 <p>This predicate must be defined dynamic and multifile to allow other
566607 modules defining clauses for it too.</dd>
567 <dt class="pubdef"><a name="thread_message_hook/3"><strong>thread_message_hook</strong>(<var>+Term,
608 <dt class="pubdef"><a id="thread_message_hook/3"><strong>thread_message_hook</strong>(<var>+Term,
568609 +Kind, +Lines</var>)</a></dt>
569610 <dd class="defbody">
570 As <a name="idx:messagehook3:757"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>,
571 but this predicate is local to the calling thread (see <a name="idx:threadlocal1:758"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>).
572 This hook is called <em>before</em> <a name="idx:messagehook3:759"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.
611 As <a id="idx:messagehook3:757"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>,
612 but this predicate is local to the calling thread (see <a id="idx:threadlocal1:758"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>).
613 This hook is called <em>before</em> <a id="idx:messagehook3:759"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.
573614 The `pre-hook' is indented to catch messages they may be produced by
574615 calling some goal without affecting other threads.</dd>
575 <dt class="pubdef"><a name="message_property/2"><strong>message_property</strong>(<var>+Kind,
616 <dt class="pubdef"><a id="message_property/2"><strong>message_property</strong>(<var>+Kind,
576617 ?Property</var>)</a></dt>
577618 <dd class="defbody">
578619 This hook can be used to define additional message kinds and the way
581622 <dl class="latex">
582623 <dt><strong>color</strong>(<var>-Attributes</var>)</dt>
583624 <dd class="defbody">
584 Print message using ANSI terminal attributes. See <a name="idx:ansiformat3:760"></a><span class="pred-ext">ansi_format/3</span>
625 Print message using ANSI terminal attributes. See <a id="idx:ansiformat3:760"></a><span class="pred-ext">ansi_format/3</span>
585626 for details. Here is an example, printing help messages in blue:
586627
587628 <pre class="code">
593634 </dd>
594635 <dt><strong>prefix</strong>(<var>-Prefix</var>)</dt>
595636 <dd class="defbody">
596 Prefix printed before each line. This argument is handed to <a name="idx:format3:761"></a><a class="pred" href="format.html#format/3">format/3</a>.
637 Prefix printed before each line. This argument is handed to <a id="idx:format3:761"></a><a class="pred" href="format.html#format/3">format/3</a>.
597638 The default is <code>'~N'</code>. For example, messages of kind
598639 <code>warning</code> use <code>'~NWarning: '</code>.</dd>
599640 <dt><strong>location_prefix</strong>(<var>+Location, -FirstPrefix,
622663 </dl>
623664
624665 </dd>
625 <dt class="pubdef"><a name="prolog:message_line_element/2"><strong>prolog:message_line_element</strong>(<var>+Stream,
666 <dt class="pubdef"><a id="prolog:message_line_element/2"><strong>prolog:message_line_element</strong>(<var>+Stream,
626667 +Term</var>)</a></dt>
627668 <dd class="defbody">
628669 This hook is called to print the individual elements of a message from
629 <a name="idx:printmessagelines3:762"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>.
670 <a id="idx:printmessagelines3:762"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>.
630671 This hook is used by e.g., library
631672 <code>library(ansi_term)</code> to colour messages on ANSI-capable
632673 terminals.</dd>
633 <dt class="pubdef"><a name="message_to_string/2"><strong>message_to_string</strong>(<var>+Term,
674 <dt class="pubdef"><a id="message_to_string/2"><strong>message_to_string</strong>(<var>+Term,
634675 -String</var>)</a></dt>
635676 <dd class="defbody">
636 Translates a message term into a string object (see <a class="sec" href="strings.html">section
677 Translates a message term into a string object (see <a class="sec" href="strings.html#sec:5.2">section
637678 5.2</a>).</dd>
638 <dt class="pubdef"><a name="version/0"><strong>version</strong></a></dt>
679 <dt class="pubdef"><a id="version/0"><strong>version</strong></a></dt>
639680 <dd class="defbody">
640681 Write the SWI-Prolog banner message as well as additional messages
641 registered using <a name="idx:version1:763"></a><a class="pred" href="exception.html#version/1">version/1</a>.
682 registered using <a id="idx:version1:763"></a><a class="pred" href="exception.html#version/1">version/1</a>.
642683 This is the default <em>initialization goal</em> which can be modified
643684 using <strong>-g</strong>.</dd>
644 <dt class="pubdef"><a name="version/1"><strong>version</strong>(<var>+Message</var>)</a></dt>
645 <dd class="defbody">
646 Register additional messages to be printed by <a name="idx:version0:764"></a><a class="pred" href="exception.html#version/0">version/0</a>.
685 <dt class="pubdef"><a id="version/1"><strong>version</strong>(<var>+Message</var>)</a></dt>
686 <dd class="defbody">
687 Register additional messages to be printed by <a id="idx:version0:764"></a><a class="pred" href="exception.html#version/0">version/0</a>.
647688 Each registered message is handed to the message translation DCG and can
648689 thus be defined using the hook prolog:message//1. If not defined, it is
649690 simply printed.
650691 </dd>
651692 </dl>
652693
653 <p><h4 id="sec:libprintmsg"><a name="sec:4.11.4.1"><span class="sec-nr">4.11.4.1</span> <span class="sec-title">Printing
694 <p><h4 id="sec:libprintmsg"><a id="sec:4.11.4.1"><span class="sec-nr">4.11.4.1</span> <span class="sec-title">Printing
654695 from libraries</span></a></h4>
655696
656 <a name="sec:libprintmsg"></a>
657
658 <p>Libraries should <em>not</em> use <a name="idx:format3:765"></a><a class="pred" href="format.html#format/3">format/3</a>
697 <a id="sec:libprintmsg"></a>
698
699 <p>Libraries should <em>not</em> use <a id="idx:format3:765"></a><a class="pred" href="format.html#format/3">format/3</a>
659700 or other output predicates directly. Libraries that print informational
660701 output directly to the console are hard to use from code that depend on
661 your textual output, such as a CGI script. The predicates in <a class="sec" href="exception.html">section
702 your textual output, such as a CGI script. The predicates in <a class="sec" href="exception.html#sec:4.11.4">section
662703 4.11.4</a> define the API for dealing with messages. The idea behind
663704 this is that a library that wants to provide information about its
664 status, progress, events or problems calls <a name="idx:printmessage2:766"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
705 status, progress, events or problems calls <a id="idx:printmessage2:766"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
665706 The first argument is the
666 <em>level</em>. The supported levels are described with <a name="idx:printmessage2:767"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
707 <em>level</em>. The supported levels are described with <a id="idx:printmessage2:767"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
667708 Libraries typically use <code>informational</code> and <code>warning</code>,
668 while libraries should use exceptions for errors (see <a name="idx:throw1:768"></a><a class="pred" href="exception.html#throw/1">throw/1</a>, <a name="idx:typeerror2:769"></a><a class="pred" href="error.html#type_error/2">type_error/2</a>,
709 while libraries should use exceptions for errors (see <a id="idx:throw1:768"></a><a class="pred" href="exception.html#throw/1">throw/1</a>, <a id="idx:typeerror2:769"></a><a class="pred" href="error.html#type_error/2">type_error/2</a>,
669710 etc.).
670711
671712 <p>The second argument is an arbitrary Prolog term that carries the
676717 into a progress bar).
677718
678719 <p>For example, suppose we have a library that must download data from
679 the Internet (e.g., based on <a name="idx:httpopen3:770"></a><span class="pred-ext">http_open/3</span>).
720 the Internet (e.g., based on <a id="idx:httpopen3:770"></a><span class="pred-ext">http_open/3</span>).
680721 The library wants to print the progress after each downloaded file. The
681722 code below is a good skeleton:
682723
695736 different languages. This, and the user-hook example below are the
696737 reason to represent the message as a compound term rather than a string.
697738 This is similar to using message numbers in non-symbolic languages. The
698 documentation of <a name="idx:printmessagelines3:771"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>
739 documentation of <a id="idx:printmessagelines3:771"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>
699740 describes the elements that may appear in the output list.
700741
701742 <pre class="code">
707748 [ 'Downloaded ~w; ~D from ~D (~d%)'-[URL, I, Total, Perc] ].
708749 </pre>
709750
710 <p>A <em>user</em> of the library may define rules for <a name="idx:messagehook3:772"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.
751 <p>A <em>user</em> of the library may define rules for <a id="idx:messagehook3:772"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.
711752 The rule below acts on the message content. Other applications can act
712753 on the message level and, for example, popup a message box for warnings
713754 and errors.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="excepthook.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="intlibs.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:exception3"><a name="sec:B.6"><span class="sec-nr">B.6</span> <span class="sec-title">Hooks
235 <h2 id="sec:exception3"><a id="sec:B.6"><span class="sec-nr">B.6</span> <span class="sec-title">Hooks
195236 using the exception predicate</span></a></h2>
196237
197 <a name="sec:exception3"></a>
198
199 <p>This section describes the predicate <a name="idx:exception3:2211"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>,
238 <a id="sec:exception3"></a>
239
240 <p>This section describes the predicate <a id="idx:exception3:2215"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>,
200241 which can be defined by the user in the module <code>user</code> as a
201242 multifile predicate. Unlike the name suggests, this is actually a <em>hook</em>
202243 predicate that has no relation to Prolog exceptions as defined by the
203244 ISO predicates
204 <a name="idx:catch3:2212"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
205 and <a name="idx:throw1:2213"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
206
207 <p>The predicate <a name="idx:exception3:2214"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>
245 <a id="idx:catch3:2216"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
246 and <a id="idx:throw1:2217"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
247
248 <p>The predicate <a id="idx:exception3:2218"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>
208249 is called by the kernel on a couple of events, allowing the user to
209250 `fix' errors just-in-time. The mechanism allows for
210251 <em>lazy</em> creation of objects such as predicates.
211252
212253 <dl class="latex">
213 <dt class="pubdef"><a name="exception/3"><strong>exception</strong>(<var>+Exception,
254 <dt class="pubdef"><a id="exception/3"><strong>exception</strong>(<var>+Exception,
214255 +Context, -Action</var>)</a></dt>
215256 <dd class="defbody">
216257 Dynamic predicate, normally not defined. Called by the Prolog system on
217258 run-time exceptions that can be repaired `just-in-time'. The values for <var>Exception</var>
218 are described below. See also <a name="idx:catch3:2215"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
219 and <a name="idx:throw1:2216"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
259 are described below. See also <a id="idx:catch3:2219"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
260 and <a id="idx:throw1:2220"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
220261
221262 <p>If this hook predicate succeeds it must instantiate the <var>Action</var>
222263 argument to the atom <code>fail</code> to make the operation fail
234275 exception. The hook is intended to implement alternatives to the
235276 built-in autoloader, such as autoloading code from a database. Do <em>not</em>
236277 use this hook to suppress existence errors on predicates. See also <a class="flag" href="flags.html#flag:unknown">unknown</a>
237 and <a class="sec" href="autoload.html">section 2.13</a>.</dd>
278 and <a class="sec" href="autoload.html#sec:2.13">section 2.13</a>.</dd>
238279 <dt><strong>undefined_global_variable</strong></dt>
239280 <dd class="defbody">
240281 <var>Context</var> is instantiated to the name of the missing global
241 variable. The hook must call <a name="idx:nbsetval2:2217"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
242 or <a name="idx:bsetval2:2218"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
282 variable. The hook must call <a id="idx:nbsetval2:2221"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
283 or <a id="idx:bsetval2:2222"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
243284 before returning with the action <code>retry</code>.
244285 </dd>
245286 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 5.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="dicts.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ext-issues.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ext-integration"><a name="sec:5.5"><span class="sec-nr">5.5</span> <span class="sec-title">Integration
235 <h2 id="sec:ext-integration"><a id="sec:5.5"><span class="sec-nr">5.5</span> <span class="sec-title">Integration
195236 of strings and dicts in the libraries</span></a></h2>
196237
197 <a name="sec:ext-integration"></a>
238 <a id="sec:ext-integration"></a>
198239
199240 <p>While lacking proper string support and dicts when designed, many
200241 predicates and libraries use interfaces that must be classified as
207248 must make a choice. We plan to resolve that using either options that
208249 specify the desired output or provide an alternative library.
209250
210 <p><h3 id="sec:ext-dict-options"><a name="sec:5.5.1"><span class="sec-nr">5.5.1</span> <span class="sec-title">Dicts
251 <p><h3 id="sec:ext-dict-options"><a id="sec:5.5.1"><span class="sec-nr">5.5.1</span> <span class="sec-title">Dicts
211252 and option processing</span></a></h3>
212253
213 <a name="sec:ext-dict-options"></a>
254 <a id="sec:ext-dict-options"></a>
214255
215256 <p>System predicates and predicates based on library <code>library(options)</code>
216257 process dicts as an alternative to traditional option lists.
217258
218 <p><h3 id="sec:ext-dict-in-core-data"><a name="sec:5.5.2"><span class="sec-nr">5.5.2</span> <span class="sec-title">Dicts
259 <p><h3 id="sec:ext-dict-in-core-data"><a id="sec:5.5.2"><span class="sec-nr">5.5.2</span> <span class="sec-title">Dicts
219260 in core data structures</span></a></h3>
220261
221 <a name="sec:ext-dict-in-core-data"></a>
262 <a id="sec:ext-dict-in-core-data"></a>
222263
223264 <p>Some predicates now produce structured data using compound terms and
224265 access predicates. We consider migrating these to dicts. Below is a
231272 <li>Date and time records
232273 </ul>
233274
234 <p><h3 id="sec:ext-xml"><a name="sec:5.5.3"><span class="sec-nr">5.5.3</span> <span class="sec-title">Dicts,
275 <p><h3 id="sec:ext-xml"><a id="sec:5.5.3"><span class="sec-nr">5.5.3</span> <span class="sec-title">Dicts,
235276 strings and XML</span></a></h3>
236277
237 <a name="sec:ext-xml"></a>
278 <a id="sec:ext-xml"></a>
238279
239280 <p>The XML representation could benefit significantly from the new
240281 features. In due time we plan to provide an set of alternative
250291 <li>CDATA in element content will be represented as strings
251292 </ul>
252293
253 <p><h3 id="sec:ext-json"><a name="sec:5.5.4"><span class="sec-nr">5.5.4</span> <span class="sec-title">Dicts,
294 <p><h3 id="sec:ext-json"><a id="sec:5.5.4"><span class="sec-nr">5.5.4</span> <span class="sec-title">Dicts,
254295 strings and JSON</span></a></h3>
255296
256 <a name="sec:ext-json"></a>
297 <a id="sec:ext-json"></a>
257298
258299 <p>The JSON representation could benefit significantly from the new
259300 features. In due time we plan to provide an set of alternative
274315 will be represented as atoms.
275316 </ul>
276317
277 <p><h3 id="sec:ext-http"><a name="sec:5.5.5"><span class="sec-nr">5.5.5</span> <span class="sec-title">Dicts,
318 <p><h3 id="sec:ext-http"><a id="sec:5.5.5"><span class="sec-nr">5.5.5</span> <span class="sec-title">Dicts,
278319 strings and HTTP</span></a></h3>
279320
280 <a name="sec:ext-http"></a>
321 <a id="sec:ext-http"></a>
281322
282323 <p>The HTTP library and related data structures would profit from
283324 exploiting dicts. Below is a list of data structures that might be
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 5.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ext-integration.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="modules.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ext-issues"><a name="sec:5.6"><span class="sec-nr">5.6</span> <span class="sec-title">Remaining
235 <h2 id="sec:ext-issues"><a id="sec:5.6"><span class="sec-nr">5.6</span> <span class="sec-title">Remaining
195236 issues</span></a></h2>
196237
197 <a name="sec:ext-issues"></a>
238 <a id="sec:ext-issues"></a>
198239
199240 <p>The changes and extensions described in this chapter resolve a many
200241 limitations of the Prolog language we have encountered. Still, there are
208249 representations, a list of <em>character codes</em> (`codes' for short)
209250 and a list of <em>one-character atoms</em> (`chars' for short). There
210251 are two sets of predicates, named *_code(s) and *_char(s) that provide
211 the same functionality (e.g., <a name="idx:atomcodes2:1655"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
212 and <a name="idx:atomchars2:1656"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>)
252 the same functionality (e.g., <a id="idx:atomcodes2:1659"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
253 and <a id="idx:atomchars2:1660"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>)
213254 using their own representation of characters. Codes can be used in
214255 arithmetic expressions, while chars are more readable. Neither can
215256 unambiguously be interpreted as a representation for text because codes
229270 that involve arrays require <em>mutable</em> arrays, while Prolog data
230271 is immutable by design. Second, standard Prolog has no good syntax
231272 support for arrays. SWI-Prolog version&nbsp;7 has `block operators' (see
232 <a class="sec" href="ext-syntax.html">section 5.3.3</a>) which can
233 resolve the syntactic issues. Block operators have been adopted by YAP.
273 <a class="sec" href="ext-syntax.html#sec:5.3.3">section 5.3.3</a>) which
274 can resolve the syntactic issues. Block operators have been adopted by
275 YAP.
234276
235277 <p><b>Lambda expressions</b>
236278
237 <p>Although many alternatives<sup class="fn">151<span class="fn-text">See
279 <p>Although many alternatives<sup class="fn">152<span class="fn-text">See
238280 e.g., <a class="url" href="http://www.complang.tuwien.ac.at/ulrich/Prolog-inedit/ISO-Hiord">http://www.complang.tuwien.ac.at/ulrich/Prolog-inedit/ISO-Hiord</a></span></sup>
239281 have been proposed, we still feel uneasy with them.
240282
244286 Prolog for simple iterations over data. ECLiPSe have proposed
245287 <em>logical loops</em> <cite><a class="cite" href="Bibliography.html#logicalloops:2002">Schimpf,
246288 2002</a></cite>, while B-Prolog introduced <em>declarative loops</em>
247 and <em>list comprehension</em><sup class="fn">152<span class="fn-text"><a class="url" href="http://www.probp.com/download/loops.pdf">http://www.probp.com/download/loops.pdf</a></span></sup>.
248 The above mentioned lambda expressions, combined with <a name="idx:maplist2:1657"></a><a class="pred" href="apply.html#maplist/2">maplist/2</a>
289 and <em>list comprehension</em><sup class="fn">153<span class="fn-text"><a class="url" href="http://www.probp.com/download/loops.pdf">http://www.probp.com/download/loops.pdf</a></span></sup>.
290 The above mentioned lambda expressions, combined with <a id="idx:maplist2:1661"></a><a class="pred" href="apply.html#maplist/2">maplist/2</a>
249291 can achieve similar results.
250292 </body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 5.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="extensions.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="strings.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ext-lists"><a name="sec:5.1"><span class="sec-nr">5.1</span> <span class="sec-title">Lists
235 <h2 id="sec:ext-lists"><a id="sec:5.1"><span class="sec-nr">5.1</span> <span class="sec-title">Lists
195236 are special</span></a></h2>
196237
197 <a name="sec:ext-lists"></a>
238 <a id="sec:ext-lists"></a>
198239
199240 <p>As of version&nbsp;7, SWI-Prolog lists can be distinguished
200241 unambiguously at runtime from <code><code>.</code>/2</code> terms and
215256 <p>The `cons' operator for creating list cells has changed from the
216257 pretty atom <code>'.'</code> to the ugly atom <code>'[|]'</code>, so we
217258 can use the
218 <code>'.'</code> for other purposes. See <a class="sec" href="dicts.html">section
259 <code>'.'</code> for other purposes. See <a class="sec" href="dicts.html#sec:5.4.1">section
219260 5.4.1</a>.
220261
221262 <p>This modification has minimal impact on typical Prolog code. It does
222 affect foreign code (see <a class="sec" href="foreign.html">section 11</a>)
223 that uses the normal atom and compound term interface for manipulation
224 lists. In most cases this can be avoided by using the dedicated list
225 functions. For convenience, the macros <code>ATOM_nil</code> and <code>ATOM_dot</code>
226 are provided by
263 affect foreign code (see <a class="sec" href="foreign.html#sec:11">section
264 11</a>) that uses the normal atom and compound term interface for
265 manipulation lists. In most cases this can be avoided by using the
266 dedicated list functions. For convenience, the macros <code>ATOM_nil</code>
267 and <code>ATOM_dot</code> are provided by
227268 <code>SWI-Prolog.h</code>.
228269
229 <p>Another place that is affected is <a name="idx:writecanonical1:1589"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>.
230 Impact is minimized by using the list syntax for lists. The predicates <a name="idx:readterm2:1590"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
270 <p>Another place that is affected is <a id="idx:writecanonical1:1589"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>.
271 Impact is minimized by using the list syntax for lists. The predicates <a id="idx:readterm2:1590"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
231272 and
232 <a name="idx:writeterm2:1591"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
273 <a id="idx:writeterm2:1591"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
233274 support the option <code>dotlists(true)</code>, which causes
234 <a name="idx:readterm2:1592"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
235 to read <code>.(a,[])</code> as <code>[a]</code> and <a name="idx:writeterm2:1593"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
275 <a id="idx:readterm2:1592"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
276 to read <code>.(a,[])</code> as <code>[a]</code> and <a id="idx:writeterm2:1593"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
236277 to write <code>[a]</code> as <code>.(a,[])</code>.
237278
238 <p><h3 id="sec:ext-list-motivation"><a name="sec:5.1.1"><span class="sec-nr">5.1.1</span> <span class="sec-title">Motivating
279 <p><h3 id="sec:ext-list-motivation"><a id="sec:5.1.1"><span class="sec-nr">5.1.1</span> <span class="sec-title">Motivating
239280 '<code>[|]</code>' and <code>[]</code> for lists</span></a></h3>
240281
241 <a name="sec:ext-list-motivation"></a>
282 <a id="sec:ext-list-motivation"></a>
242283
243284 <p>Representing lists the conventional way using <code><code>.</code>/2</code>
244285 as cons-cell and '[]' as list terminator both (independently) poses
251292 distinguished from <code>[a|B]</code>. Freeing <code><code>.</code>/2</code>
252293 provides us with a unique term that we can use for functional notation
253294 on dicts as described in
254 <a class="sec" href="dicts.html">section 5.4.1</a>.
295 <a class="sec" href="dicts.html#sec:5.4.1">section 5.4.1</a>.
255296
256297 <p>
257298 <li>Using <code>'[]'</code> as list terminator prevents dynamic
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 5.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="strings.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="dicts.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ext-syntax"><a name="sec:5.3"><span class="sec-nr">5.3</span> <span class="sec-title">Syntax
235 <h2 id="sec:ext-syntax"><a id="sec:5.3"><span class="sec-nr">5.3</span> <span class="sec-title">Syntax
195236 changes</span></a></h2>
196237
197 <a name="sec:ext-syntax"></a>
198
199 <p><h3 id="sec:ext-syntax-op"><a name="sec:5.3.1"><span class="sec-nr">5.3.1</span> <span class="sec-title">Operators
238 <a id="sec:ext-syntax"></a>
239
240 <p><h3 id="sec:ext-syntax-op"><a id="sec:5.3.1"><span class="sec-nr">5.3.1</span> <span class="sec-title">Operators
200241 and quoted atoms</span></a></h3>
201242
202 <a name="sec:ext-syntax-op"></a>
243 <a id="sec:ext-syntax-op"></a>
203244
204245 <p>As of SWI-Prolog version&nbsp;7, quoted atoms loose their operator
205246 property. This means that expressions such as <code>A = 'dynamic'/1</code>
222263 Y = 1790400.0'J'.
223264 </pre>
224265
225 <p><h3 id="sec:ext-compound-zero"><a name="sec:5.3.2"><span class="sec-nr">5.3.2</span> <span class="sec-title">Compound
266 <p><h3 id="sec:ext-compound-zero"><a id="sec:5.3.2"><span class="sec-nr">5.3.2</span> <span class="sec-title">Compound
226267 terms with zero arguments</span></a></h3>
227268
228 <a name="sec:ext-compound-zero"></a>
269 <a id="sec:ext-compound-zero"></a>
229270
230271 <p>As of SWI-Prolog version&nbsp;7, the system supports compound terms
231272 that have no arguments. This implies that e.g., <code>name()</code> is
232 valid syntax. This extension aims at functions on dicts (see <a class="sec" href="dicts.html">section
273 valid syntax. This extension aims at functions on dicts (see <a class="sec" href="dicts.html#sec:5.4">section
233274 5.4</a>) as well as the implementation of domain specific languages
234 (DSLs). To minimise the consequences, the classic predicates <a name="idx:functor3:1625"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
275 (DSLs). To minimise the consequences, the classic predicates <a id="idx:functor3:1625"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
235276 and <a class="pred" href="manipterm.html#=../2">=../2</a> have not been
236 modified. The predicates <a name="idx:compoundnamearity3:1626"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
277 modified. The predicates <a id="idx:compoundnamearity3:1626"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
237278 and
238 <a name="idx:compoundnamearguments3:1627"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
279 <a id="idx:compoundnamearguments3:1627"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
239280 have been added. These predicates operate only on compound terms and
240281 behave consistently for compounds with zero arguments. Code that <em>generalises</em>
241 a term using the sequence below should generally be changed to use <a name="idx:compoundnamearity3:1628"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.
282 a term using the sequence below should generally be changed to use <a id="idx:compoundnamearity3:1628"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.
242283
243284 <pre class="code">
244285 ...,
248289 </pre>
249290
250291 <p>Replacement of <a class="pred" href="manipterm.html#=../2">=../2</a>
251 by <a name="idx:compoundnamearguments3:1629"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
292 by <a id="idx:compoundnamearguments3:1629"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
252293 is typically needed to deal with code that follow the skeleton below.
253294
254295 <pre class="code">
281322
282323 <p>Note that the <em>cannonical</em> representation of predicate heads
283324 and functions without arguments is an atom. Thus, <code>clause(go(),
284 Body)</code> returns the clauses for <a name="idx:go0:1630"></a><span class="pred-ext">go/0</span>,
325 Body)</code> returns the clauses for <a id="idx:go0:1630"></a><span class="pred-ext">go/0</span>,
285326 but <code>clause(-Head, -Body, +Ref)</code> unifies <var>Head</var> with
286327 an atom if the clause specified by <var>Ref</var> is part of a predicate
287328 with zero arguments.
288329
289 <p><h3 id="sec:ext-blockop"><a name="sec:5.3.3"><span class="sec-nr">5.3.3</span> <span class="sec-title">Block
330 <p><h3 id="sec:ext-blockop"><a id="sec:5.3.3"><span class="sec-nr">5.3.3</span> <span class="sec-title">Block
290331 operators</span></a></h3>
291332
292 <a name="sec:ext-blockop"></a>
333 <a id="sec:ext-blockop"></a>
293334
294335 <p>Introducing curly bracket and array subscripting.<sup class="fn">148<span class="fn-text">Introducing
295336 block operators was proposed by Jose Morales. It was discussed in the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="miscpreds.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ext-lists.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:extensions"><a name="sec:5"><span class="sec-nr">5</span> <span class="sec-title">SWI-Prolog
235 <h1 id="sec:extensions"><a id="sec:5"><span class="sec-nr">5</span> <span class="sec-title">SWI-Prolog
195236 extensions</span></a></h1>
196237
197 <a name="sec:extensions"></a>
238 <a id="sec:extensions"></a>
198239
199240 <p>This chapter describes extensions to the Prolog language introduced
200241 with SWI-Prolog version&nbsp;7. The changes bring more modern
211252
212253 <p>While many programs run unmodified in SWI-Prolog version&nbsp;7,
213254 especially those that pass double quoted strings to general purpose list
214 processing predicates require modifications. We provide a tool (<a name="idx:liststrings0:1588"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>)
255 processing predicates require modifications. We provide a tool (<a id="idx:liststrings0:1588"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>)
215256 that we used to port a huge code base in half a day.
216257
217258 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.36</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.36</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="system.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="toplevel.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:files"><a name="sec:4.36"><span class="sec-nr">4.36</span> <span class="sec-title">File
235 <h2 id="sec:files"><a id="sec:4.36"><span class="sec-nr">4.36</span> <span class="sec-title">File
195236 System Interaction</span></a></h2>
196237
197 <a name="sec:files"></a>
238 <a id="sec:files"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="access_file/2"><strong>access_file</strong>(<var>+File,
241 <dt class="pubdef"><a id="access_file/2"><strong>access_file</strong>(<var>+File,
201242 +Mode</var>)</a></dt>
202243 <dd class="defbody">
203244 True if <var>File</var> exists and can be accessed by this Prolog
220261 note that checking access never provides a guarantee that a subsequent
221262 open succeeds without errors due to inherent concurrency in file
222263 operations. It is generally more robust to try and open the file and
223 handle possible exceptions. See <a name="idx:open4:1493"></a><a class="pred" href="IO.html#open/4">open/4</a>
264 handle possible exceptions. See <a id="idx:open4:1493"></a><a class="pred" href="IO.html#open/4">open/4</a>
224265 and
225 <a name="idx:catch3:1494"></a><a class="pred" href="exception.html#catch/3">catch/3</a>.</dd>
226 <dt class="pubdef"><a name="exists_file/1"><strong>exists_file</strong>(<var>+File</var>)</a></dt>
266 <a id="idx:catch3:1494"></a><a class="pred" href="exception.html#catch/3">catch/3</a>.</dd>
267 <dt class="pubdef"><a id="exists_file/1"><strong>exists_file</strong>(<var>+File</var>)</a></dt>
227268 <dd class="defbody">
228269 True if <var>File</var> exists and is a regular file. This does not
229270 imply the user has read and/or write permission for the file. This is
230271 the same as <code>access_file(File, exist)</code>.</dd>
231 <dt class="pubdef"><a name="file_directory_name/2"><strong>file_directory_name</strong>(<var>+File,
272 <dt class="pubdef"><a id="file_directory_name/2"><strong>file_directory_name</strong>(<var>+File,
232273 -Directory</var>)</a></dt>
233274 <dd class="defbody">
234275 Extracts the directory part of <var>File</var>. The returned <var>Directory</var>
240281 it is not a valid file name. In this case the final <code><code>/</code></code>
241282 is removed from <var>File</var>, e.g., <code>'/hello'</code>.
242283
243 <p>See also <a name="idx:directoryfilepath3:1495"></a><span class="pred-ext">directory_file_path/3</span>
284 <p>See also <a id="idx:directoryfilepath3:1495"></a><span class="pred-ext">directory_file_path/3</span>
244285 from <code>library(filesex)</code>. The system ensures that for every
245286 valid <var>Path</var> using the Prolog (POSIX) directory separators,
246287 following is true on systems with a sound implementation of
247 <a name="idx:samefile2:1496"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>.<sup class="fn">134<span class="fn-text">On
288 <a id="idx:samefile2:1496"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>.<sup class="fn">134<span class="fn-text">On
248289 some systems, <var>Path</var> and <var>Path2</var> refer to the same
249 entry in the file system, but <a name="idx:samefile2:1497"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
250 may fail.</span></sup> See also <a name="idx:prologtoosfilename2:1498"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.
290 entry in the file system, but <a id="idx:samefile2:1497"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
291 may fail.</span></sup> See also <a id="idx:prologtoosfilename2:1498"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.
251292
252293 <pre class="code">
253294 ...,
258299 </pre>
259300
260301 </dd>
261 <dt class="pubdef"><a name="file_base_name/2"><strong>file_base_name</strong>(<var>+File,
302 <dt class="pubdef"><a id="file_base_name/2"><strong>file_base_name</strong>(<var>+File,
262303 -BaseName</var>)</a></dt>
263304 <dd class="defbody">
264305 Extracts the filename part from a path specification. If <var>File</var>
265306 does not contain any directory separators, <var>File</var> is returned
266307 in
267 <var>BaseName</var>. See also <a name="idx:filedirectoryname2:1499"></a><a class="pred" href="files.html#file_directory_name/2">file_directory_name/2</a>.
308 <var>BaseName</var>. See also <a id="idx:filedirectoryname2:1499"></a><a class="pred" href="files.html#file_directory_name/2">file_directory_name/2</a>.
268309 If the <var>File</var> arguments ends with a <code><code>/</code></code>,
269310 e.g., <code>'/hello/'</code>, <var>BaseName</var> is unified with the
270311 empty atom (<code>''</code>).</dd>
271 <dt class="pubdef"><a name="same_file/2"><strong>same_file</strong>(<var>+File1,
312 <dt class="pubdef"><a id="same_file/2"><strong>same_file</strong>(<var>+File1,
272313 +File2</var>)</a></dt>
273314 <dd class="defbody">
274315 True if both filenames refer to the same physical file. That is, if
275316 <var>File1</var> and <var>File2</var> are the same string or both names
276317 exist and point to the same file (due to hard or symbolic links and/or
277318 relative vs. absolute paths). On systems that provide stat() with
278 meaningful values for <code>st_dev</code> and <code>st_inode</code>, <a name="idx:samefile2:1500"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
319 meaningful values for <code>st_dev</code> and <code>st_inode</code>, <a id="idx:samefile2:1500"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
279320 is implemented by comparing the device and inode identifiers. On
280321 Windows,
281 <a name="idx:samefile2:1501"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
322 <a id="idx:samefile2:1501"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
282323 compares the strings returned by the GetFullPathName() system call.</dd>
283 <dt class="pubdef"><a name="exists_directory/1"><strong>exists_directory</strong>(<var>+Directory</var>)</a></dt>
324 <dt class="pubdef"><a id="exists_directory/1"><strong>exists_directory</strong>(<var>+Directory</var>)</a></dt>
284325 <dd class="defbody">
285326 True if <var>Directory</var> exists and is a directory. This does not
286327 imply the user has read, search or write permission for the directory.</dd>
287 <dt class="pubdef"><a name="delete_file/1"><strong>delete_file</strong>(<var>+File</var>)</a></dt>
328 <dt class="pubdef"><a id="delete_file/1"><strong>delete_file</strong>(<var>+File</var>)</a></dt>
288329 <dd class="defbody">
289330 Remove <var>File</var> from the file system.</dd>
290 <dt class="pubdef"><a name="rename_file/2"><strong>rename_file</strong>(<var>+File1,
331 <dt class="pubdef"><a id="rename_file/2"><strong>rename_file</strong>(<var>+File1,
291332 +File2</var>)</a></dt>
292333 <dd class="defbody">
293334 Rename <var>File1</var> as <var>File2</var>. The semantics is compatible
295336 operating system allows. Notably, if <var>File2</var> exists, the
296337 operation succeeds (except for possible permission errors) and is <em>atomic</em>
297338 (meaning there is no window where <var>File2</var> does not exist).</dd>
298 <dt class="pubdef"><a name="size_file/2"><strong>size_file</strong>(<var>+File,
339 <dt class="pubdef"><a id="size_file/2"><strong>size_file</strong>(<var>+File,
299340 -Size</var>)</a></dt>
300341 <dd class="defbody">
301342 Unify <var>Size</var> with the size of <var>File</var> in bytes.</dd>
302 <dt class="pubdef"><a name="time_file/2"><strong>time_file</strong>(<var>+File,
343 <dt class="pubdef"><a id="time_file/2"><strong>time_file</strong>(<var>+File,
303344 -Time</var>)</a></dt>
304345 <dd class="defbody">
305346 Unify the last modification time of <var>File</var> with <var>Time</var>.
306347 <var>Time</var> is a floating point number expressing the seconds
307 elapsed since Jan&nbsp;1, 1970. See also <a name="idx:converttime28:1502"></a><span class="pred-ext">convert_time/[2,8]</span>
308 and <a name="idx:gettime1:1503"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>.</dd>
309 <dt class="pubdef"><a name="absolute_file_name/2"><strong>absolute_file_name</strong>(<var>+File,
348 elapsed since Jan&nbsp;1, 1970. See also <a id="idx:converttime28:1502"></a><span class="pred-ext">convert_time/[2,8]</span>
349 and <a id="idx:gettime1:1503"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>.</dd>
350 <dt class="pubdef"><a id="absolute_file_name/2"><strong>absolute_file_name</strong>(<var>+File,
310351 -Absolute</var>)</a></dt>
311352 <dd class="defbody">
312353 Expand a local filename into an absolute path. The absolute path is
314355 deleted. This predicate ensures that expanding a filename returns the
315356 same absolute path regardless of how the file is addressed. SWI-Prolog
316357 uses absolute filenames to register source files independent of the
317 current working directory. See also <a name="idx:absolutefilename3:1504"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
318 and <a name="idx:expandfilename2:1505"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.</dd>
319 <dt class="pubdef"><a name="absolute_file_name/3"><strong>absolute_file_name</strong>(<var>+Spec,
358 current working directory. See also <a id="idx:absolutefilename3:1504"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
359 and <a id="idx:expandfilename2:1505"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.</dd>
360 <dt class="pubdef"><a id="absolute_file_name/3"><strong>absolute_file_name</strong>(<var>+Spec,
320361 -Absolute, +Options</var>)</a></dt>
321362 <dd class="defbody">
322363 Convert the given file specification into an absolute path. <var>Spec</var>
329370 <dt><strong>extensions</strong>(<var>ListOfExtensions</var>)</dt>
330371 <dd class="defbody">
331372 List of file extensions to try. Default is <code>''</code>. For each
332 extension, <a name="idx:absolutefilename3:1506"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
373 extension, <a id="idx:absolutefilename3:1506"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
333374 will first add the extension and then verify the conditions imposed by
334375 the other options. If the condition fails, the next extension on the
335376 list is tried. Extensions may be specified both as <code>.ext</code> or
338379 <dd class="defbody">
339380 Resolve the path relative to the given directory or the directory
340381 holding the given file. Without this option, paths are resolved relative
341 to the working directory (see <a name="idx:workingdirectory2:1507"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>)
342 or, if <var>Spec</var> is atomic and <a name="idx:absolutefilename23:1508"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>
382 to the working directory (see <a id="idx:workingdirectory2:1507"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>)
383 or, if <var>Spec</var> is atomic and <a id="idx:absolutefilename23:1508"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>
343384 is executed in a directive, it uses the current source file as
344385 reference.</dd>
345386 <dt><strong>access</strong>(<var>Mode</var>)</dt>
346387 <dd class="defbody">
347388 Imposes the condition access_file(<var>File</var>, <var>Mode</var>). <var>Mode</var>
348389 is one of <code>read</code>, <code>write</code>, <code>append</code>,
349 <code>execute</code>, <code>exist</code> or <code>none</code>. See also <a name="idx:accessfile2:1509"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>.</dd>
390 <code>execute</code>, <code>exist</code> or <code>none</code>. See also <a id="idx:accessfile2:1509"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>.</dd>
350391 <dt><strong>file_type</strong>(<var>Type</var>)</dt>
351392 <dd class="defbody">
352393 Defines extensions. Current mapping: <code>txt</code> implies <code>['']</code>,
356397 and
357398 <code>directory</code> implies <code>['']</code>. The file type <code>source</code>
358399 is an alias for <code>prolog</code> for compatibility with SICStus
359 Prolog. See also <a name="idx:prologfiletype2:1510"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>.
400 Prolog. See also <a id="idx:prologfiletype2:1510"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>.
360401 This predicate only returns non-directories, unless the option <code>file_type(directory)</code>
361402 is specified.</dd>
362403 <dt><strong>file_errors</strong>(<var>fail/error</var>)</dt>
373414 <dt><strong>expand</strong>(<var>Boolean</var>)</dt>
374415 <dd class="defbody">
375416 If <code>true</code> (default is <code>false</code>) and <var>Spec</var>
376 is atomic, call <a name="idx:expandfilename2:1511"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
377 followed by <a name="idx:member2:1512"></a><a class="pred" href="lists.html#member/2">member/2</a>
417 is atomic, call <a id="idx:expandfilename2:1511"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
418 followed by <a id="idx:member2:1512"></a><a class="pred" href="lists.html#member/2">member/2</a>
378419 on <var>Spec</var> before proceeding. This is a SWI-Prolog extension
379420 intended to minimise porting effort after SWI-Prolog stopped expanding
380421 environment variables and the <code><code>~</code></code> by default.
391432 argument order was <code>absolute_file_name(+Spec, +Options, -Path)</code>.
392433 The argument order has been changed for compatibility with ISO and
393434 SICStus. The Quintus argument order is still accepted.</dd>
394 <dt class="pubdef"><a name="is_absolute_file_name/1"><strong>is_absolute_file_name</strong>(<var>+File</var>)</a></dt>
435 <dt class="pubdef"><a id="is_absolute_file_name/1"><strong>is_absolute_file_name</strong>(<var>+File</var>)</a></dt>
395436 <dd class="defbody">
396437 True if <var>File</var> specifies an absolute path name. On Unix
397438 systems, this implies the path starts with a `/'. For Microsoft-based
398439 systems this implies the path starts with <code>&lt;<var>letter</var>&gt;:</code>.
399440 This predicate is intended to provide platform-independent checking for
400 absolute paths. See also <a name="idx:absolutefilename2:1513"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>
401 and <a name="idx:prologtoosfilename2:1514"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.</dd>
402 <dt class="pubdef"><a name="file_name_extension/3"><strong>file_name_extension</strong>(<var>?Base,
441 absolute paths. See also <a id="idx:absolutefilename2:1513"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>
442 and <a id="idx:prologtoosfilename2:1514"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.</dd>
443 <dt class="pubdef"><a id="file_name_extension/3"><strong>file_name_extension</strong>(<var>?Base,
403444 ?Extension, ?Name</var>)</a></dt>
404445 <dd class="defbody">
405446 This predicate is used to add, remove or test filename extensions. The
408449 testing for an extension will also be done case-insensitive. <var>Extension</var>
409450 may be specified with or without a leading dot (<code><code>.</code></code>).
410451 If an <var>Extension</var> is generated, it will not have a leading dot.</dd>
411 <dt class="pubdef"><a name="directory_files/2"><strong>directory_files</strong>(<var>+Directory,
452 <dt class="pubdef"><a id="directory_files/2"><strong>directory_files</strong>(<var>+Directory,
412453 -Entries</var>)</a></dt>
413454 <dd class="defbody">
414455 Unify <var>Entries</var> with a list of entries in <var>Directory</var>.
416457 to <var>Directory</var>. <var>Entries</var> contains all entries,
417458 including hidden files and, if supplied by the OS, the special entries <code><code>.</code></code>
418459 and
419 <code>..</code>. See also <a name="idx:expandfilename2:1515"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.<sup class="fn">136<span class="fn-text">This
460 <code>..</code>. See also <a id="idx:expandfilename2:1515"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.<sup class="fn">136<span class="fn-text">This
420461 predicate should be considered a misnomer because it returns entries
421462 rather than files. We stick to this name for compatibility with, e.g.,
422463 SICStus, Ciao and YAP.</span></sup></dd>
423 <dt class="pubdef"><a name="expand_file_name/2"><strong>expand_file_name</strong>(<var>+WildCard,
464 <dt class="pubdef"><a id="expand_file_name/2"><strong>expand_file_name</strong>(<var>+WildCard,
424465 -List</var>)</a></dt>
425466 <dd class="defbody">
426467 Unify <var>List</var> with a sorted list of files or directories
447488 set the environment variable <code>HOME</code> to point to the
448489 SWI-Prolog home directory if neither <code>HOME</code> nor <code>HOMEPATH</code>
449490 and <code>HOMEDRIVE</code> are defined.</span></sup></dd>
450 <dt class="pubdef"><a name="prolog_to_os_filename/2"><strong>prolog_to_os_filename</strong>(<var>?PrologPath,
491 <dt class="pubdef"><a id="prolog_to_os_filename/2"><strong>prolog_to_os_filename</strong>(<var>?PrologPath,
451492 ?OsPath</var>)</a></dt>
452493 <dd class="defbody">
453494 Convert between the internal Prolog path name conventions and the
455496 the POSIX standard, which implies that this predicate is equivalent to
456497 =/2 (unify) on POSIX (e.g., Unix) systems. On Windows systems it changes
457498 the directory separator from <code><code>\</code></code> into <code><code>/</code></code>.</dd>
458 <dt class="pubdef"><a name="read_link/3"><strong>read_link</strong>(<var>+File,
499 <dt class="pubdef"><a id="read_link/3"><strong>read_link</strong>(<var>+File,
459500 -Link, -Target</var>)</a></dt>
460501 <dd class="defbody">
461502 If <var>File</var> points to a symbolic link, unify <var>Link</var> with
464505 <var>Target</var> points to a file, directory or non-existing entry in
465506 the file system, but never to a link. Fails if <var>File</var> is not a
466507 link. Fails always on systems that do not support symbolic links.</dd>
467 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="tmp_file/2"><strong>tmp_file</strong>(<var>+Base,
508 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="tmp_file/2"><strong>tmp_file</strong>(<var>+Base,
468509 -TmpName</var>)</a></dt>
469510 <dd class="defbody">
470511 Create a name for a temporary file. <var>Base</var> is an identifier for
476517
477518 <p>Because it is possible to guess the generated filename, attackers may
478519 create the filesystem entry as a link and possibly create a security
479 issue. New code should use <a name="idx:tmpfilestream3:1516"></a><a class="pred" href="files.html#tmp_file_stream/3">tmp_file_stream/3</a>.</dd>
480 <dt class="pubdef"><a name="tmp_file_stream/3"><strong>tmp_file_stream</strong>(<var>+Encoding,
520 issue. New code should use <a id="idx:tmpfilestream3:1516"></a><a class="pred" href="files.html#tmp_file_stream/3">tmp_file_stream/3</a>.</dd>
521 <dt class="pubdef"><a id="tmp_file_stream/3"><strong>tmp_file_stream</strong>(<var>+Encoding,
481522 -FileName, -Stream</var>)</a></dt>
482523 <dd class="defbody">
483524 Create a temporary filename <var>FileName</var> and open it for writing
487528 supports it, the created file is only accessible to the current user. If
488529 the OS supports it, the file is created using the open()-flag <code>O_EXCL</code>,
489530 which guarantees that the file did not exist before this call. This
490 predicate is a safe replacement of <a name="idx:tmpfile2:1517"></a><a class="pred" href="files.html#tmp_file/2">tmp_file/2</a>.
531 predicate is a safe replacement of <a id="idx:tmpfile2:1517"></a><a class="pred" href="files.html#tmp_file/2">tmp_file/2</a>.
491532 Note that in those cases where the temporary file is needed to store
492533 output from an external command, the file must be closed first. E.g.,
493534 the following downloads a file from a URL to a temporary file and opens
504545 </pre>
505546
506547 <p>Temporary files created using this call are removed if the Prolog
507 process terminates <em>gracefully</em>. Calling <a name="idx:deletefile1:1518"></a><a class="pred" href="files.html#delete_file/1">delete_file/1</a>
548 process terminates <em>gracefully</em>. Calling <a id="idx:deletefile1:1518"></a><a class="pred" href="files.html#delete_file/1">delete_file/1</a>
508549 using
509550 <var>FileName</var> removes the file and removes the entry from the
510551 administration of files-to-be-deleted.</dd>
511 <dt class="pubdef"><a name="make_directory/1"><strong>make_directory</strong>(<var>+Directory</var>)</a></dt>
552 <dt class="pubdef"><a id="make_directory/1"><strong>make_directory</strong>(<var>+Directory</var>)</a></dt>
512553 <dd class="defbody">
513554 Create a new directory (folder) on the filesystem. Raises an exception
514555 on failure. On Unix systems, the directory is created with default
515556 permissions (defined by the process <em>umask</em> setting).</dd>
516 <dt class="pubdef"><a name="delete_directory/1"><strong>delete_directory</strong>(<var>+Directory</var>)</a></dt>
557 <dt class="pubdef"><a id="delete_directory/1"><strong>delete_directory</strong>(<var>+Directory</var>)</a></dt>
517558 <dd class="defbody">
518559 Delete directory (folder) from the filesystem. Raises an exception on
519560 failure. Please note that in general it will not be possible to delete a
520561 non-empty directory.</dd>
521 <dt class="pubdef"><a name="working_directory/2"><strong>working_directory</strong>(<var>-Old,
562 <dt class="pubdef"><a id="working_directory/2"><strong>working_directory</strong>(<var>-Old,
522563 +New</var>)</a></dt>
523564 <dd class="defbody">
524565 Unify <var>Old</var> with an absolute path to the current working
525566 directory and change working directory to <var>New</var>. Use the
526567 pattern
527568 <code>working_directory(CWD, CWD)</code> to get the current directory.
528 See also <a name="idx:absolutefilename2:1519"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>
529 and <a name="idx:chdir1:1520"></a><a class="pred" href="files.html#chdir/1">chdir/1</a>.<sup class="fn">bug<span class="fn-text">Some
569 See also <a id="idx:absolutefilename2:1519"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>
570 and <a id="idx:chdir1:1520"></a><a class="pred" href="files.html#chdir/1">chdir/1</a>.<sup class="fn">bug<span class="fn-text">Some
530571 of the file I/O predicates use local filenames. Changing directory while
531 file-bound streams are open causes wrong results on <a name="idx:telling1:1521"></a><a class="pred" href="IO.html#telling/1">telling/1</a>, <a name="idx:seeing1:1522"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
532 and <a name="idx:currentstream3:1523"></a><a class="pred" href="IO.html#current_stream/3">current_stream/3</a>.</span></sup>
572 file-bound streams are open causes wrong results on <a id="idx:telling1:1521"></a><a class="pred" href="IO.html#telling/1">telling/1</a>, <a id="idx:seeing1:1522"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
573 and <a id="idx:currentstream3:1523"></a><a class="pred" href="IO.html#current_stream/3">current_stream/3</a>.</span></sup>
533574 Note that the working directory is shared between all threads.</dd>
534 <dt class="pubdef"><a name="chdir/1"><strong>chdir</strong>(<var>+Path</var>)</a></dt>
535 <dd class="defbody">
536 Compatibility predicate. New code should use <a name="idx:workingdirectory2:1524"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
575 <dt class="pubdef"><a id="chdir/1"><strong>chdir</strong>(<var>+Path</var>)</a></dt>
576 <dd class="defbody">
577 Compatibility predicate. New code should use <a id="idx:workingdirectory2:1524"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
537578 </dd>
538579 </dl>
539580
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 12.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="useresource.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="libpl.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:findappfile"><a name="sec:12.4"><span class="sec-nr">12.4</span> <span class="sec-title">Finding
235 <h2 id="sec:findappfile"><a id="sec:12.4"><span class="sec-nr">12.4</span> <span class="sec-title">Finding
195236 Application files</span></a></h2>
196237
197 <a name="sec:findappfile"></a>
238 <a id="sec:findappfile"></a>
198239
199240 <p>If your application uses files that are not part of the saved program
200241 such as database files, configuration files, etc., the runtime version
201 has to be able to locate these files. The <a name="idx:filesearchpath2:2129"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
242 has to be able to locate these files. The <a id="idx:filesearchpath2:2133"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
202243 mechanism in combination with the <strong>-p</strong>alias command line
203244 argument is the preferred way to locate runtime files. The first step is
204245 to define an alias for the top-level directory of your application. We
227268 ).
228269 </pre>
229270
230 <p><h3 id="sec:runtime-file-search-path"><a name="sec:12.4.1"><span class="sec-nr">12.4.1</span> <span class="sec-title">Specifying
271 <p><h3 id="sec:runtime-file-search-path"><a id="sec:12.4.1"><span class="sec-nr">12.4.1</span> <span class="sec-title">Specifying
231272 a file search path from the command line</span></a></h3>
232273
233 <a name="sec:runtime-file-search-path"></a>
274 <a id="sec:runtime-file-search-path"></a>
234275
235276 <p>Suppose the system administrator has installed the SWI-Prolog runtime
236277 environment in <code>/usr/local/lib/rt-pl-3.2.0</code>. A user wants to
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="plld.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreignxmp.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:findhome"><a name="sec:11.6"><span class="sec-nr">11.6</span> <span class="sec-title">The
235 <h2 id="sec:findhome"><a id="sec:11.6"><span class="sec-nr">11.6</span> <span class="sec-title">The
195236 Prolog `home' directory</span></a></h2>
196237
197 <a name="sec:findhome"></a>
238 <a id="sec:findhome"></a>
198239
199240 <p>Executables embedding SWI-Prolog should be able to find the `home'
200241 directory of the development environment unless a self-contained saved
201 state has been added to the executable (see <a name="idx:qsaveprogram12:2088"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
202 and <a class="sec" href="plld.html">section 11.5</a>).
242 state has been added to the executable (see <a id="idx:qsaveprogram12:2092"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
243 and <a class="sec" href="plld.html#sec:11.5">section 11.5</a>).
203244
204245 <p>If Prolog starts up, it will try to locate the development
205246 environment. To do so, it will try the following steps until one
227268 SWI-Prolog gives up. If a state is attached, the current working
228269 directory is used.
229270
230 <p>The <a name="idx:filesearchpath2:2089"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
271 <p>The <a id="idx:filesearchpath2:2093"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
231272 alias <code>swi</code> is set to point to the home directory located.
232273
233274 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.11</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="compilation.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="hooks.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:flags"><a name="sec:2.11"><span class="sec-nr">2.11</span> <span class="sec-title">Environment
235 <h2 id="sec:flags"><a id="sec:2.11"><span class="sec-nr">2.11</span> <span class="sec-title">Environment
195236 Control (Prolog flags)</span></a></h2>
196237
197 <a name="sec:flags"></a>
198
199 <p>The predicates <a name="idx:currentprologflag2:80"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
200 and <a name="idx:setprologflag2:81"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
238 <a id="sec:flags"></a>
239
240 <p>The predicates <a id="idx:currentprologflag2:80"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
241 and <a id="idx:setprologflag2:81"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
201242 allow the user to examine and modify the execution environment. It
202243 provides access to whether optional features are available on this
203244 version, operating system, foreign code environment, command line
206247 Prolog environments.
207248
208249 <dl class="latex">
209 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_prolog_flag/2"><strong>current_prolog_flag</strong>(<var>?Key,
250 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_prolog_flag/2"><strong>current_prolog_flag</strong>(<var>?Key,
210251 -Value</var>)</a></dt>
211252 <dd class="defbody">
212 The predicate <a name="idx:currentprologflag2:82"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
253 The predicate <a id="idx:currentprologflag2:82"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
213254 defines an interface to installation features: options compiled in,
214255 version, home, etc. With both arguments unbound, it will generate all
215256 defined Prolog flags. With <var>Key</var> instantiated, it unifies <var>Value</var>
217258 a Prolog flag.
218259
219260 <p>Flags marked <b>rw</b> can be modified by the user using
220 <a name="idx:setprologflag2:83"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>.
261 <a id="idx:setprologflag2:83"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>.
221262 Flag values are typed. Flags marked as <code>bool</code> can have the
222263 values <code>true</code> or <code>false</code>. The predicate
223 <a name="idx:createprologflag3:84"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
264 <a id="idx:createprologflag3:84"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
224265 may be used to create flags that describe or control behaviour of
225266 libraries and applications. The library
226267 <code>library(settings)</code> provides an alternative interface for
246287 <a class="flag" href="flags.html#flag:generate_debug_info">generate_debug_info</a>
247288 and <a class="flag" href="flags.html#flag:optimise">optimise</a>.
248289
249 <p>A new thread (see <a class="sec" href="threads.html">section 9</a>) <em>copies</em>
290 <p>A new thread (see <a class="sec" href="threads.html#sec:9">section 9</a>) <em>copies</em>
250291 all flags from the thread that created the new thread (its <em>parent</em>).<sup class="fn">17<span class="fn-text">This
251292 is implemented using the copy-on-write tecnhnique.</span></sup> As a
252293 consequence, modifying a flag inside a thread does not affect other
253294 threads.
254295
255296 <dl class="latex">
256 <dt class="pubdef"><a name="flag:access_level"><strong>access_level</strong>(<var>atom</var>, changeable)</a></dt>
297 <dt class="pubdef"><a id="flag:access_level"><strong>access_level</strong>(<var>atom</var>, changeable)</a></dt>
257298 <dd class="defbody">
258299 This flag defines a normal `user' view (<code>user</code>, default) or a
259300 `system' view. In system view all system code is fully accessible as if
261302 permitted and some details are kept invisible. We leave the exact
262303 consequences undefined, but, for example, system code can be traced
263304 using system access and system predicates can be redefined.</dd>
264 <dt class="pubdef"><a name="flag:address_bits"><strong>address_bits</strong>(<var>integer</var>)</a></dt>
305 <dt class="pubdef"><a id="flag:address_bits"><strong>address_bits</strong>(<var>integer</var>)</a></dt>
265306 <dd class="defbody">
266307 Address size of the hosting machine. Typically 32 or 64. Except for the
267308 maximum stack limit, this has few implications to the user. See also the
268309 Prolog flag <a class="flag" href="flags.html#flag:arch">arch</a>.</dd>
269 <dt class="pubdef"><a name="flag:agc_margin"><strong>agc_margin</strong>(<var>integer</var>, changeable)</a></dt>
310 <dt class="pubdef"><a id="flag:agc_margin"><strong>agc_margin</strong>(<var>integer</var>, changeable)</a></dt>
270311 <dd class="defbody">
271312 If this amount of atoms possible garbage atoms exist perform atom
272313 garbage collection at the first opportunity. Initial value is 10,000.
274315 See also <a class="func" href="foreigninclude.html#PL_register_atom()">PL_register_atom()</a>.<sup class="fn">18<span class="fn-text">Given
275316 that SWI-Prolog has no limit on the length of atoms, 10,000 atoms may
276317 still occupy a lot of memory. Applications using extremely large atoms
277 may wish to call <a name="idx:garbagecollectatoms0:85"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>
318 may wish to call <a id="idx:garbagecollectatoms0:85"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>
278319 explicitly or lower the margin.</span></sup></dd>
279 <dt class="pubdef"><a name="flag:apple"><strong>apple</strong>(<var>bool</var>)</a></dt>
280 <dd class="defbody">
281 <a name="idx:MacOS:86"></a>If present and <code>true</code>, the
282 operating system is MacOSX. Defined if the C compiler used to compile
283 this version of SWI-Prolog defines
320 <dt class="pubdef"><a id="flag:apple"><strong>apple</strong>(<var>bool</var>)</a></dt>
321 <dd class="defbody">
322 <a id="idx:MacOS:86"></a>If present and <code>true</code>, the operating
323 system is MacOSX. Defined if the C compiler used to compile this version
324 of SWI-Prolog defines
284325 <code>__APPLE__</code>. Note that the <a class="flag" href="flags.html#flag:unix">unix</a>
285326 is also defined for MacOSX.</dd>
286 <dt class="pubdef"><a name="flag:allow_dot_in_atom"><strong>allow_dot_in_atom</strong>(<var>bool</var>, changeable)</a></dt>
327 <dt class="pubdef"><a id="flag:allow_dot_in_atom"><strong>allow_dot_in_atom</strong>(<var>bool</var>, changeable)</a></dt>
287328 <dd class="defbody">
288329 If <code>true</code> (default <code>false</code>), dots may be embedded
289330 into atoms that are not quoted and start with a letter. The embedded dot
293334 that this conflicts with cascading functional notation. For example,
294335 <code>Post.meta.author</code> is read as <code>.(Post, 'meta.author'</code>
295336 if this flag is set to <code>true</code>.</dd>
296 <dt class="pubdef"><a name="flag:allow_variable_name_as_functor"><strong>allow_variable_name_as_functor</strong>(<var>bool</var>, changeable)</a></dt>
337 <dt class="pubdef"><a id="flag:allow_variable_name_as_functor"><strong>allow_variable_name_as_functor</strong>(<var>bool</var>, changeable)</a></dt>
297338 <dd class="defbody">
298339 If true (default is false), <code>Functor(arg)</code> is read as if it
299340 were written <code>'Functor'(arg)</code>. Some applications use the
300 Prolog <a name="idx:read1:87"></a><a class="pred" href="termrw.html#read/1">read/1</a>
341 Prolog <a id="idx:read1:87"></a><a class="pred" href="termrw.html#read/1">read/1</a>
301342 predicate for reading an application-defined script language. In these
302343 cases, it is often difficult to explain to non-Prolog users of the
303344 application that constants and functions can only start with a lowercase
304345 letter. Variables can be turned into atoms starting with an uppercase
305 atom by calling <a name="idx:readterm2:88"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
346 atom by calling <a id="idx:readterm2:88"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
306347 using the option <code>variable_names</code> and binding the variables
307348 to their name. Using this feature, F(x) can be turned into valid syntax
308349 for such script languages. Suggested by Robert van Engelen. SWI-Prolog
309350 specific.</dd>
310 <dt class="pubdef"><a name="flag:argv"><strong>argv</strong>(<var>list</var>, changeable)</a></dt>
351 <dt class="pubdef"><a id="flag:argv"><strong>argv</strong>(<var>list</var>, changeable)</a></dt>
311352 <dd class="defbody">
312353 List is a list of atoms representing the application command line
313354 arguments. Application command line arguments are those that have
318359 was defined as <a class="flag" href="flags.html#flag:os_argv">os_argv</a>
319360 is now. The change was made for compatibility reasons and because the
320361 current definition is more practical.</span></sup></dd>
321 <dt class="pubdef"><a name="flag:arch"><strong>arch</strong>(<var>atom</var>)</a></dt>
362 <dt class="pubdef"><a id="flag:arch"><strong>arch</strong>(<var>atom</var>)</a></dt>
322363 <dd class="defbody">
323364 Identifier for the hardware and operating system SWI-Prolog is running
324365 on. Used to select foreign files for the right architecture. See also
325 <a class="sec" href="foreignlink.html">section 11.2.3</a> and <a name="idx:filesearchpath2:89"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
326 <dt class="pubdef"><a name="flag:associated_file"><strong>associated_file</strong>(<var>atom</var>)</a></dt>
327 <dd class="defbody">
328 Set if Prolog was started with a prolog file as argument. Used by e.g., <a name="idx:edit0:90"></a><a class="pred" href="edit.html#edit/0">edit/0</a>
366 <a class="sec" href="foreignlink.html#sec:11.2.3">section 11.2.3</a> and <a id="idx:filesearchpath2:89"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
367 <dt class="pubdef"><a id="flag:associated_file"><strong>associated_file</strong>(<var>atom</var>)</a></dt>
368 <dd class="defbody">
369 Set if Prolog was started with a prolog file as argument. Used by e.g., <a id="idx:edit0:90"></a><a class="pred" href="edit.html#edit/0">edit/0</a>
329370 to edit the initial file.</dd>
330 <dt class="pubdef"><a name="flag:autoload"><strong>autoload</strong>(<var>bool</var>, changeable)</a></dt>
371 <dt class="pubdef"><a id="flag:autoload"><strong>autoload</strong>(<var>bool</var>, changeable)</a></dt>
331372 <dd class="defbody">
332373 If <code>true</code> (default) autoloading of library functions is
333374 enabled.</dd>
334 <dt class="pubdef"><a name="flag:back_quotes"><strong>back_quotes</strong>(<var>codes,chars,string,symbol_char</var>, changeable)</a></dt>
375 <dt class="pubdef"><a id="flag:back_quotes"><strong>back_quotes</strong>(<var>codes,chars,string,symbol_char</var>, changeable)</a></dt>
335376 <dd class="defbody">
336377 Defines the term-representation for back-quoted material. The default is <code>codes</code>.
337378 If <strong>--traditional</strong> is given, the default is <code>symbol_char</code>,
338379 which allows using <code>`</code> in operators composed of symbols.<sup class="fn">20<span class="fn-text">Older
339380 versions had a boolean flag <code>backquoted_strings</code>, which
340381 toggled between <code>string</code> and <code>symbol_char</code></span></sup>.
341 See also <a class="sec" href="strings.html">section 5.2</a>.</dd>
342 <dt class="pubdef"><a name="flag:backtrace"><strong>backtrace</strong>(<var>bool</var>, changeable)</a></dt>
382 See also <a class="sec" href="strings.html#sec:5.2">section 5.2</a>.</dd>
383 <dt class="pubdef"><a id="flag:backtrace"><strong>backtrace</strong>(<var>bool</var>, changeable)</a></dt>
343384 <dd class="defbody">
344385 If <code>true</code> (default), print a backtrace on an uncaught
345386 exception.</dd>
346 <dt class="pubdef"><a name="flag:backtrace_depth"><strong>backtrace_depth</strong>(<var>integer</var>, changeable)</a></dt>
387 <dt class="pubdef"><a id="flag:backtrace_depth"><strong>backtrace_depth</strong>(<var>integer</var>, changeable)</a></dt>
347388 <dd class="defbody">
348389 If backtraces on errors are enabled, this flag defines the maximum
349390 number of frames that is printed (default&nbsp;20).</dd>
350 <dt class="pubdef"><a name="flag:backtrace_goal_depth"><strong>backtrace_goal_depth</strong>(<var>integer</var>, changeable)</a></dt>
391 <dt class="pubdef"><a id="flag:backtrace_goal_depth"><strong>backtrace_goal_depth</strong>(<var>integer</var>, changeable)</a></dt>
351392 <dd class="defbody">
352393 The frame of a backtrace is printed after making a shallow copy of the
353394 goal. This flag determines the depth to which the goal term is copied.
354395 Default is `3'.</dd>
355 <dt class="pubdef"><a name="flag:backtrace_show_lines"><strong>backtrace_show_lines</strong>(<var>bool</var>, changeable)</a></dt>
396 <dt class="pubdef"><a id="flag:backtrace_show_lines"><strong>backtrace_show_lines</strong>(<var>bool</var>, changeable)</a></dt>
356397 <dd class="defbody">
357398 If <code>true</code> (default), try to reconstruct the line number at
358399 which the exception happened.</dd>
359 <dt class="pubdef"><a name="flag:bounded"><strong>bounded</strong>(<var>bool</var>)</a></dt>
400 <dt class="pubdef"><a id="flag:bounded"><strong>bounded</strong>(<var>bool</var>)</a></dt>
360401 <dd class="defbody">
361402 ISO Prolog flag. If <code>true</code>, integer representation is bound
362403 by
364405 If <code>false</code> integers can be arbitrarily large and the <a class="flag" href="flags.html#flag:min_integer">min_integer</a>
365406 and
366407 <a class="flag" href="flags.html#flag:max_integer">max_integer</a> are
367 not present. See <a class="sec" href="arith.html">section 4.27.2.1</a>.</dd>
368 <dt class="pubdef"><a name="flag:break_level"><strong>break_level</strong>(<var>integer</var>)</a></dt>
408 not present. See <a class="sec" href="arith.html#sec:4.27.2.1">section
409 4.27.2.1</a>.</dd>
410 <dt class="pubdef"><a id="flag:break_level"><strong>break_level</strong>(<var>integer</var>)</a></dt>
369411 <dd class="defbody">
370412 Current break-level. The initial top level (started with
371 <strong>-t</strong>) has value 0. See <a name="idx:break0:91"></a><a class="pred" href="toplevel.html#break/0">break/0</a>.
413 <strong>-t</strong>) has value 0. See <a id="idx:break0:91"></a><a class="pred" href="toplevel.html#break/0">break/0</a>.
372414 This flag is absent from threads that are not running a top-level loop.</dd>
373 <dt class="pubdef"><a name="flag:c_cc"><strong>c_cc</strong>(<var>atom</var>, changeable)</a></dt>
415 <dt class="pubdef"><a id="flag:c_cc"><strong>c_cc</strong>(<var>atom</var>, changeable)</a></dt>
374416 <dd class="defbody">
375417 Name of the C compiler used to compile SWI-Prolog. Normally either gcc
376 or cc. See <a class="sec" href="plld.html">section 11.5</a>.</dd>
377 <dt class="pubdef"><a name="flag:c_cflags"><strong>c_cflags</strong>(<var>atom</var>, changeable)</a></dt>
378 <dd class="defbody">
379 CFLAGS used to compile SWI-Prolog. See <a class="sec" href="plld.html">section
418 or cc. See <a class="sec" href="plld.html#sec:11.5">section 11.5</a>.</dd>
419 <dt class="pubdef"><a id="flag:c_cflags"><strong>c_cflags</strong>(<var>atom</var>, changeable)</a></dt>
420 <dd class="defbody">
421 CFLAGS used to compile SWI-Prolog. See <a class="sec" href="plld.html#sec:11.5">section
380422 11.5</a>.</dd>
381 <dt class="pubdef"><a name="flag:c_ldflags"><strong>c_ldflags</strong>(<var>atom</var>, changeable)</a></dt>
382 <dd class="defbody">
383 LDFLAGS used to link SWI-Prolog. See <a class="sec" href="plld.html">section
423 <dt class="pubdef"><a id="flag:c_ldflags"><strong>c_ldflags</strong>(<var>atom</var>, changeable)</a></dt>
424 <dd class="defbody">
425 LDFLAGS used to link SWI-Prolog. See <a class="sec" href="plld.html#sec:11.5">section
384426 11.5</a>.</dd>
385 <dt class="pubdef"><a name="flag:c_libs"><strong>c_libs</strong>(<var>atom</var>, changeable)</a></dt>
427 <dt class="pubdef"><a id="flag:c_libs"><strong>c_libs</strong>(<var>atom</var>, changeable)</a></dt>
386428 <dd class="defbody">
387429 Libraries needed to link executables that embed SWI-Prolog. Typically
388430 <code>-lswipl</code> if the SWI-Prolog kernel is a shared (DLL). If the
389431 SWI-Prolog kernel is in a static library, this flag also contains the
390432 dependencies.</dd>
391 <dt class="pubdef"><a name="flag:c_libplso"><strong>c_libplso</strong>(<var>atom</var>, changeable)</a></dt>
433 <dt class="pubdef"><a id="flag:c_libplso"><strong>c_libplso</strong>(<var>atom</var>, changeable)</a></dt>
392434 <dd class="defbody">
393435 Libraries needed to link extensions (shared object, DLL) to SWI-Prolog.
394436 Typically empty on ELF systems and <code>-lswipl</code> on COFF-based
395 systems. See <a class="sec" href="plld.html">section 11.5</a>.</dd>
396 <dt class="pubdef"><a name="flag:char_conversion"><strong>char_conversion</strong>(<var>bool</var>, changeable)</a></dt>
437 systems. See <a class="sec" href="plld.html#sec:11.5">section 11.5</a>.</dd>
438 <dt class="pubdef"><a id="flag:char_conversion"><strong>char_conversion</strong>(<var>bool</var>, changeable)</a></dt>
397439 <dd class="defbody">
398440 Determines whether character conversion takes place while reading terms.
399 See also <a name="idx:charconversion2:92"></a><a class="pred" href="charconv.html#char_conversion/2">char_conversion/2</a>.</dd>
400 <dt class="pubdef"><a name="flag:character_escapes"><strong>character_escapes</strong>(<var>bool</var>, changeable)</a></dt>
401 <dd class="defbody">
402 If <code>true</code> (default), <a name="idx:read1:93"></a><a class="pred" href="termrw.html#read/1">read/1</a>
441 See also <a id="idx:charconversion2:92"></a><a class="pred" href="charconv.html#char_conversion/2">char_conversion/2</a>.</dd>
442 <dt class="pubdef"><a id="flag:character_escapes"><strong>character_escapes</strong>(<var>bool</var>, changeable)</a></dt>
443 <dd class="defbody">
444 If <code>true</code> (default), <a id="idx:read1:93"></a><a class="pred" href="termrw.html#read/1">read/1</a>
403445 interprets <code>\</code> escape sequences in quoted atoms and strings.
404446 May be changed. This flag is local to the module in which it is changed.
405 See <a class="sec" href="syntax.html">section 2.16.1.3</a>.</dd>
406 <dt class="pubdef"><a name="flag:colon_sets_calling_context"><strong>colon_sets_calling_context</strong>(<var>bool</var>, changeable)</a></dt>
447 See <a class="sec" href="syntax.html#sec:2.16.1.3">section 2.16.1.3</a>.</dd>
448 <dt class="pubdef"><a id="flag:colon_sets_calling_context"><strong>colon_sets_calling_context</strong>(<var>bool</var>, changeable)</a></dt>
407449 <dd class="defbody">
408450 Using the construct &lt;<var>module</var>&gt;:&lt;<var>goal</var>&gt;
409451 sets the <em>calling context</em> for executing &lt;<var>goal</var>&gt;.
410 This flag is defined by ISO/IEC 13211-2 (Prolog modules standard). See <a class="sec" href="modules.html">section
452 This flag is defined by ISO/IEC 13211-2 (Prolog modules standard). See <a class="sec" href="modules.html#sec:6">section
411453 6</a>.</dd>
412 <dt class="pubdef"><a name="flag:color_term"><strong>color_term</strong>(<var>bool</var>, changeable)</a></dt>
454 <dt class="pubdef"><a id="flag:color_term"><strong>color_term</strong>(<var>bool</var>, changeable)</a></dt>
413455 <dd class="defbody">
414456 This flag is managed by library <code>library(ansi_term)</code>, which
415457 is loaded at startup if the two conditions below are both true. Note
416458 that this implies that setting this flag to <code>false</code> from the
417 system or personal initialization file (see <a class="sec" href="initfile.html">section
418 2.2</a> disables colored output. The predicate <a name="idx:messageproperty2:94"></a><a class="pred" href="exception.html#message_property/2">message_property/2</a>
459 system or personal initialization file (see <a class="sec" href="initfile.html#sec:2.2">section
460 2.2</a> disables colored output. The predicate <a id="idx:messageproperty2:94"></a><a class="pred" href="exception.html#message_property/2">message_property/2</a>
419461 can be used to control the actual color scheme depending in the message
420462 type passed to
421 <a name="idx:printmessage2:95"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
463 <a id="idx:printmessage2:95"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
422464
423465 <p>
424466 <ul class="latex">
426468 <li><code>\+ current_prolog_flag(color_term, false)</code>
427469 </ul>
428470 </dd>
429 <dt class="pubdef"><a name="flag:compile_meta_arguments"><strong>compile_meta_arguments</strong>(<var>atom</var>, changeable)</a></dt>
471 <dt class="pubdef"><a id="flag:compile_meta_arguments"><strong>compile_meta_arguments</strong>(<var>atom</var>, changeable)</a></dt>
430472 <dd class="defbody">
431473 Experimental flag that controls compilation of arguments passed to
432 meta-calls marked `0' or `<code><code>^</code></code>' (see <a name="idx:metapredicate1:96"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>).
474 meta-calls marked `0' or `<code><code>^</code></code>' (see <a id="idx:metapredicate1:96"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>).
433475 Supported values are:
434476
435477 <dl class="latex">
449491 <dd class="defbody">
450492 Also compile references to normal user predicates. This harms
451493 performance (a little), but enhances the power of poor-mens consistency
452 check used by <a name="idx:make0:97"></a><a class="pred" href="consulting.html#make/0">make/0</a>
453 and implemented by <a name="idx:listundefined0:98"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>.
494 check used by <a id="idx:make0:97"></a><a class="pred" href="consulting.html#make/0">make/0</a>
495 and implemented by <a id="idx:listundefined0:98"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>.
454496 </dd>
455497 <dt><strong>always</strong></dt>
456498 <dd class="defbody">
457499 Always create an intermediate clause, even for system predicates. This
458500 prepares for replacing the normal head of the generated predicate with a
459501 special reference (similar to database references as used by, e.g.,
460 <a name="idx:assert2:99"></a><a class="pred" href="db.html#assert/2">assert/2</a>)
502 <a id="idx:assert2:99"></a><a class="pred" href="db.html#assert/2">assert/2</a>)
461503 that provides direct access to the executable code, thus avoiding
462504 runtime lookup of predicates for meta-calling.
463505 </dd>
464506 </dl>
465507
466508 </dd>
467 <dt class="pubdef"><a name="flag:compiled_at"><strong>compiled_at</strong>(<var>atom</var>)</a></dt>
509 <dt class="pubdef"><a id="flag:compiled_at"><strong>compiled_at</strong>(<var>atom</var>)</a></dt>
468510 <dd class="defbody">
469511 Describes when the system has been compiled. Only available if the C
470512 compiler used to compile SWI-Prolog provides the __DATE__ and __TIME__
471513 macros.</dd>
472 <dt class="pubdef"><a name="flag:console_menu"><strong>console_menu</strong>(<var>bool</var>)</a></dt>
514 <dt class="pubdef"><a id="flag:console_menu"><strong>console_menu</strong>(<var>bool</var>)</a></dt>
473515 <dd class="defbody">
474516 Set to <code>true</code> in <b>swipl-win.exe</b> to indicate that the
475 console supports menus. See also <a class="sec" href="system.html">section
517 console supports menus. See also <a class="sec" href="system.html#sec:4.35.3">section
476518 4.35.3</a>.</dd>
477 <dt class="pubdef"><a name="flag:cpu_count"><strong>cpu_count</strong>(<var>integer</var>, changeable)</a></dt>
519 <dt class="pubdef"><a id="flag:cpu_count"><strong>cpu_count</strong>(<var>integer</var>, changeable)</a></dt>
478520 <dd class="defbody">
479521 Number of physical CPUs or cores in the system. The flag is marked
480522 read-write both to allow pretending the system has more or less
481 processors. See also <a name="idx:threadsetconcurrency2:100"></a><a class="pred" href="threadcreate.html#thread_setconcurrency/2">thread_setconcurrency/2</a>
523 processors. See also <a id="idx:threadsetconcurrency2:100"></a><a class="pred" href="threadcreate.html#thread_setconcurrency/2">thread_setconcurrency/2</a>
482524 and the library
483525 <code>library(thread)</code>. This flag is not available on systems
484526 where we do not know how to get the number of CPUs. This flag is not
485 included in a saved state (see <a name="idx:qsaveprogram1:101"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>).</dd>
486 <dt class="pubdef"><a name="flag:dde"><strong>dde</strong>(<var>bool</var>)</a></dt>
527 included in a saved state (see <a id="idx:qsaveprogram1:101"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>).</dd>
528 <dt class="pubdef"><a id="flag:dde"><strong>dde</strong>(<var>bool</var>)</a></dt>
487529 <dd class="defbody">
488530 Set to <code>true</code> if this instance of Prolog supports DDE as
489 described in <a class="sec" href="DDE.html">section 4.43</a>.</dd>
490 <dt class="pubdef"><a name="flag:debug"><strong>debug</strong>(<var>bool</var>, changeable)</a></dt>
531 described in <a class="sec" href="DDE.html#sec:4.43">section 4.43</a>.</dd>
532 <dt class="pubdef"><a id="flag:debug"><strong>debug</strong>(<var>bool</var>, changeable)</a></dt>
491533 <dd class="defbody">
492534 Switch debugging mode on/off. If debug mode is activated the system
493 traps encountered spy points (see <a name="idx:spy1:102"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
494 and trace points (see <a name="idx:trace1:103"></a><a class="pred" href="debugger.html#trace/1">trace/1</a>).
535 traps encountered spy points (see <a id="idx:spy1:102"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
536 and trace points (see <a id="idx:trace1:103"></a><a class="pred" href="debugger.html#trace/1">trace/1</a>).
495537 In addition, last-call optimisation is disabled and the system is more
496538 conservative in destroying choice points to simplify debugging.
497539
498540 <p>Disabling these optimisations can cause the system to run out of
499541 memory on programs that behave correctly if debug mode is off.</dd>
500 <dt class="pubdef"><a name="flag:debug_on_error"><strong>debug_on_error</strong>(<var>bool</var>, changeable)</a></dt>
542 <dt class="pubdef"><a id="flag:debug_on_error"><strong>debug_on_error</strong>(<var>bool</var>, changeable)</a></dt>
501543 <dd class="defbody">
502544 If <code>true</code>, start the tracer after an error is detected.
503545 Otherwise just continue execution. The goal that raised the error will
504546 normally fail. See also the Prolog flag <a class="flag" href="flags.html#flag:report_error">report_error</a>.
505547 Default is <code>true</code>.</dd>
506 <dt class="pubdef"><a name="flag:debugger_write_options"><strong>debugger_write_options</strong>(<var>term</var>, changeable)</a></dt>
507 <dd class="defbody">
508 This argument is given as option-list to <a name="idx:writeterm2:104"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
548 <dt class="pubdef"><a id="flag:debugger_write_options"><strong>debugger_write_options</strong>(<var>term</var>, changeable)</a></dt>
549 <dd class="defbody">
550 This argument is given as option-list to <a id="idx:writeterm2:104"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
509551 for printing goals by the debugger. Modified by the `w', `p' and `&lt;N&gt;
510552 d' commands of the debugger. Default is <code>[quoted(true),
511553 portray(true), max_depth(10), attributes(portray)]</code>.</dd>
512 <dt class="pubdef"><a name="flag:debugger_show_context"><strong>debugger_show_context</strong>(<var>bool</var>, changeable)</a></dt>
554 <dt class="pubdef"><a id="flag:debugger_show_context"><strong>debugger_show_context</strong>(<var>bool</var>, changeable)</a></dt>
513555 <dd class="defbody">
514556 If <code>true</code>, show the context module while printing a
515557 stack-frame in the tracer. Normally controlled using the `C' option of
516558 the tracer.</dd>
517 <dt class="pubdef"><a name="flag:dialect"><strong>dialect</strong>(<var>atom</var>)</a></dt>
559 <dt class="pubdef"><a id="flag:dialect"><strong>dialect</strong>(<var>atom</var>)</a></dt>
518560 <dd class="defbody">
519561 Fixed to <code>swi</code>. The code below is a reliable and portable way
520562 to detect SWI-Prolog.
525567 </pre>
526568
527569 </dd>
528 <dt class="pubdef"><a name="flag:double_quotes"><strong>double_quotes</strong>(<var>codes,chars,atom,string</var>, changeable)</a></dt>
570 <dt class="pubdef"><a id="flag:double_quotes"><strong>double_quotes</strong>(<var>codes,chars,atom,string</var>, changeable)</a></dt>
529571 <dd class="defbody">
530572 This flag determines how double quoted strings are read by Prolog and is
531573 ---like <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
532574 and <a class="flag" href="flags.html#flag:back_quotes">back_quotes</a>---
533575 maintained for each module. The default is <code>string</code>, which
534 produces a string as described in <a class="sec" href="strings.html">section
576 produces a string as described in <a class="sec" href="strings.html#sec:5.2">section
535577 5.2</a>. If
536578 <strong>--traditional</strong> is given, the default is <code>codes</code>,
537579 which produces a list of character codes, integers that represent a
538580 Unicode code-point. The value <code>chars</code> produces a list of
539581 one-character atoms and the value <code>atom</code> makes double quotes
540 the same as single quotes, creating a atom. See also <a class="sec" href="extensions.html">section
582 the same as single quotes, creating a atom. See also <a class="sec" href="extensions.html#sec:5">section
541583 5</a>.</dd>
542 <dt class="pubdef"><a name="flag:editor"><strong>editor</strong>(<var>atom</var>, changeable)</a></dt>
543 <dd class="defbody">
544 Determines the editor used by <a name="idx:edit1:105"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
545 See <a class="sec" href="edit.html">section 4.4.1</a> for details on
546 selecting the editor used.</dd>
547 <dt class="pubdef"><a name="flag:emacs_inferior_process"><strong>emacs_inferior_process</strong>(<var>bool</var>)</a></dt>
584 <dt class="pubdef"><a id="flag:editor"><strong>editor</strong>(<var>atom</var>, changeable)</a></dt>
585 <dd class="defbody">
586 Determines the editor used by <a id="idx:edit1:105"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
587 See <a class="sec" href="edit.html#sec:4.4.1">section 4.4.1</a> for
588 details on selecting the editor used.</dd>
589 <dt class="pubdef"><a id="flag:emacs_inferior_process"><strong>emacs_inferior_process</strong>(<var>bool</var>)</a></dt>
548590 <dd class="defbody">
549591 If true, SWI-Prolog is running as an <em>inferior process</em> of
550592 (GNU/X-)Emacs. SWI-Prolog assumes this is the case if the environment
551593 variable <code>EMACS</code> is <code>t</code> and <code>INFERIOR</code>
552594 is <code>yes</code>.</dd>
553 <dt class="pubdef"><a name="flag:encoding"><strong>encoding</strong>(<var>atom</var>, changeable)</a></dt>
595 <dt class="pubdef"><a id="flag:encoding"><strong>encoding</strong>(<var>atom</var>, changeable)</a></dt>
554596 <dd class="defbody">
555597 Default encoding used for opening files in <code>text</code> mode. The
556 initial value is deduced from the environment. See <a class="sec" href="widechars.html">section
598 initial value is deduced from the environment. See <a class="sec" href="widechars.html#sec:2.19.1">section
557599 2.19.1</a> for details.</dd>
558 <dt class="pubdef"><a name="flag:executable"><strong>executable</strong>(<var>atom</var>)</a></dt>
559 <dd class="defbody">
560 Pathname of the running executable. Used by <a name="idx:qsaveprogram2:106"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
600 <dt class="pubdef"><a id="flag:executable"><strong>executable</strong>(<var>atom</var>)</a></dt>
601 <dd class="defbody">
602 Pathname of the running executable. Used by <a id="idx:qsaveprogram2:106"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
561603 as default emulator.</dd>
562 <dt class="pubdef"><a name="flag:exit_status"><strong>exit_status</strong>(<var>integer</var>)</a></dt>
563 <dd class="defbody">
564 Set by <a name="idx:halt1:107"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>
604 <dt class="pubdef"><a id="flag:exit_status"><strong>exit_status</strong>(<var>integer</var>)</a></dt>
605 <dd class="defbody">
606 Set by <a id="idx:halt1:107"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>
565607 to its argument, making the exit status available to hooks registered
566 with <a name="idx:athalt1:108"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>.</dd>
567 <dt class="pubdef"><a name="flag:file_name_case_handling"><strong>file_name_case_handling</strong>(<var>atom</var>, changeable)</a></dt>
608 with <a id="idx:athalt1:108"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>.</dd>
609 <dt class="pubdef"><a id="flag:file_name_case_handling"><strong>file_name_case_handling</strong>(<var>atom</var>, changeable)</a></dt>
568610 <dd class="defbody">
569611 This flag defines how Prolog handles the case of file names. The flag is
570612 used for case normalization and to determine whether two names refer to
593635 </dl>
594636
595637 </dd>
596 <dt class="pubdef"><a name="flag:file_name_variables"><strong>file_name_variables</strong>(<var>bool</var>, changeable)</a></dt>
638 <dt class="pubdef"><a id="flag:file_name_variables"><strong>file_name_variables</strong>(<var>bool</var>, changeable)</a></dt>
597639 <dd class="defbody">
598640 If <code>true</code> (default <code>false</code>), expand <code>$<var>varname</var></code>
599641 and <code><code>~</code></code> in arguments of built-in predicates that
600 accept a file name (<a name="idx:open3:109"></a><a class="pred" href="IO.html#open/3">open/3</a>, <a name="idx:existsfile1:110"></a><a class="pred" href="files.html#exists_file/1">exists_file/1</a>, <a name="idx:accessfile2:111"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>,
642 accept a file name (<a id="idx:open3:109"></a><a class="pred" href="IO.html#open/3">open/3</a>, <a id="idx:existsfile1:110"></a><a class="pred" href="files.html#exists_file/1">exists_file/1</a>, <a id="idx:accessfile2:111"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>,
601643 etc.). The predicate
602 <a name="idx:expandfilename2:112"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
644 <a id="idx:expandfilename2:112"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
603645 can be used to expand environment variables and wildcard patterns. This
604646 Prolog flag is intended for backward compatibility with older versions
605647 of SWI-Prolog.</dd>
606 <dt class="pubdef"><a name="flag:file_search_cache_time"><strong>file_search_cache_time</strong>(<var>number</var>, changeable)</a></dt>
607 <dd class="defbody">
608 Time in seconds for which search results from <a name="idx:absolutefilename3:113"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
648 <dt class="pubdef"><a id="flag:file_search_cache_time"><strong>file_search_cache_time</strong>(<var>number</var>, changeable)</a></dt>
649 <dd class="defbody">
650 Time in seconds for which search results from <a id="idx:absolutefilename3:113"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
609651 are cached. Within this time limit, the system will first check that the
610652 old search result satisfies the conditions. Default is 10 seconds, which
611653 typically avoids most repetitive searches for (library) files during
612654 compilation. Setting this value to 0 (zero) disables the cache.</dd>
613 <dt class="pubdef"><a name="flag:gc"><strong>gc</strong>(<var>bool</var>, changeable)</a></dt>
655 <dt class="pubdef"><a id="flag:gc"><strong>gc</strong>(<var>bool</var>, changeable)</a></dt>
614656 <dd class="defbody">
615657 If true (default), the garbage collector is active. If false, neither
616658 garbage collection, nor stack shifts will take place, even not on
617659 explicit request. May be changed.</dd>
618 <dt class="pubdef"><a name="flag:rc_thread"><strong>rc_thread</strong>(<var>bool</var>, changeable)</a></dt>
660 <dt class="pubdef"><a id="flag:rc_thread"><strong>rc_thread</strong>(<var>bool</var>, changeable)</a></dt>
619661 <dd class="defbody">
620662 If <code>true</code> (default if threading is enabled), atom and clause
621663 garbage collection are executed in a seperate thread with the
623665 sufficient garbage executes the garbage collector. As running these
624666 global collectors may take relatively using a seperate thread improves
625667 real time behaviour.</dd>
626 <dt class="pubdef"><a name="flag:generate_debug_info"><strong>generate_debug_info</strong>(<var>bool</var>, changeable)</a></dt>
668 <dt class="pubdef"><a id="flag:generate_debug_info"><strong>generate_debug_info</strong>(<var>bool</var>, changeable)</a></dt>
627669 <dd class="defbody">
628670 If <code>true</code> (default) generate code that can be debugged using
629 <a name="idx:trace0:114"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>, <a name="idx:spy1:115"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
671 <a id="idx:trace0:114"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>, <a id="idx:spy1:115"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
630672 etc. Can be set to <code>false</code> using the
631673 <strong>-nodebug</strong>. This flag is scoped within a source file.
632674 Many of the libraries have
635677 the current implementation this only causes a flag to be set on the
636678 predicate that causes children to be hidden from the debugger. The name
637679 anticipates further changes to the compiler.</span></sup></dd>
638 <dt class="pubdef"><a name="flag:gmp_version"><strong>gmp_version</strong>(<var>integer</var>)</a></dt>
680 <dt class="pubdef"><a id="flag:gmp_version"><strong>gmp_version</strong>(<var>integer</var>)</a></dt>
639681 <dd class="defbody">
640682 If Prolog is linked with GMP, this flag gives the major version of the
641 GMP library used. See also <a class="sec" href="foreigninclude.html">section
683 GMP library used. See also <a class="sec" href="foreigninclude.html#sec:11.4.8">section
642684 11.4.8</a>.</dd>
643 <dt class="pubdef"><a name="flag:gui"><strong>gui</strong>(<var>bool</var>)</a></dt>
685 <dt class="pubdef"><a id="flag:gui"><strong>gui</strong>(<var>bool</var>)</a></dt>
644686 <dd class="defbody">
645687 Set to <code>true</code> if XPCE is around and can be used for graphics.</dd>
646 <dt class="pubdef"><a name="flag:history"><strong>history</strong>(<var>integer</var>, changeable)</a></dt>
688 <dt class="pubdef"><a id="flag:history"><strong>history</strong>(<var>integer</var>, changeable)</a></dt>
647689 <dd class="defbody">
648690 If <var><var>integer</var>&gt; 0</var>, support Unix <b>csh(1)</b>-like
649 history as described in <a class="sec" href="history.html">section 2.7</a>.
650 Otherwise, only support reusing commands through the command line
651 editor. The default is to set this Prolog flag to 0 if a command line
652 editor is provided (see Prolog flag
691 history as described in <a class="sec" href="history.html#sec:2.7">section
692 2.7</a>. Otherwise, only support reusing commands through the command
693 line editor. The default is to set this Prolog flag to 0 if a command
694 line editor is provided (see Prolog flag
653695 <a class="flag" href="flags.html#flag:readline">readline</a>) and 15
654696 otherwise.</dd>
655 <dt class="pubdef"><a name="flag:home"><strong>home</strong>(<var>atom</var>)</a></dt>
697 <dt class="pubdef"><a id="flag:home"><strong>home</strong>(<var>atom</var>)</a></dt>
656698 <dd class="defbody">
657699 SWI-Prolog's notion of the home directory. SWI-Prolog uses its home
658700 directory to find its startup file as
660702 <code>&lt;<var>home</var>&gt;/boot64.prc</code> (64-bit machines) and to
661703 find its library as
662704 <code>&lt;<var>home</var>&gt;/library</code>.</dd>
663 <dt class="pubdef"><a name="flag:hwnd"><strong>hwnd</strong>(<var>integer</var>)</a></dt>
705 <dt class="pubdef"><a id="flag:hwnd"><strong>hwnd</strong>(<var>integer</var>)</a></dt>
664706 <dd class="defbody">
665707 In <b>swipl-win.exe</b>, this refers to the MS-Windows window handle of
666708 the console window.</dd>
667 <dt class="pubdef"><a name="flag:integer_rounding_function"><strong>integer_rounding_function</strong>(<var>down,toward_zero</var>)</a></dt>
709 <dt class="pubdef"><a id="flag:integer_rounding_function"><strong>integer_rounding_function</strong>(<var>down,toward_zero</var>)</a></dt>
668710 <dd class="defbody">
669711 ISO Prolog flag describing rounding by <code>//</code> and <code>rem</code>
670712 arithmetic functions. Value depends on the C compiler used.</dd>
671 <dt class="pubdef"><a name="flag:iso"><strong>iso</strong>(<var>bool</var>, changeable)</a></dt>
713 <dt class="pubdef"><a id="flag:iso"><strong>iso</strong>(<var>bool</var>, changeable)</a></dt>
672714 <dd class="defbody">
673715 Include some weird ISO compatibility that is incompatible with normal
674716 SWI-Prolog behaviour. Currently it has the following effect:
675717 <ul class="latex">
676718 <li>The <code><code>/</code>/2</code> (float division) <em>always</em>
677719 returns a float, even if applied to integers that can be divided.
678 <li>In the standard order of terms (see <a class="sec" href="compare.html">section
720 <li>In the standard order of terms (see <a class="sec" href="compare.html#sec:4.7.1">section
679721 4.7.1</a>), all floats are before all integers.
680 <li><a name="idx:atomlength2:116"></a><a class="pred" href="manipatom.html#atom_length/2">atom_length/2</a>
722 <li><a id="idx:atomlength2:116"></a><a class="pred" href="manipatom.html#atom_length/2">atom_length/2</a>
681723 yields a type error if the first argument is a number.
682 <li><a name="idx:clause23:117"></a><a class="pred" href="examineprog.html#clause/2">clause/[2,3]</a>
724 <li><a id="idx:clause23:117"></a><a class="pred" href="examineprog.html#clause/2">clause/[2,3]</a>
683725 raises a permission error when accessing static predicates.
684 <li><a name="idx:abolish12:118"></a><a class="pred" href="db.html#abolish/1">abolish/[1,2]</a>
726 <li><a id="idx:abolish12:118"></a><a class="pred" href="db.html#abolish/1">abolish/[1,2]</a>
685727 raises a permission error when accessing static predicates.
686728 <li>Syntax is closer to the ISO standard:
687729 <ul class="latex">
702744 == -, true.</code> write <code>X == (-), true.</code> Currently, this is
703745 not entirely enforced.
704746 <li>Backslash-escaped newlines are interpreted according to the ISO
705 standard. See <a class="sec" href="syntax.html">section 2.16.1.3</a>.
747 standard. See <a class="sec" href="syntax.html#sec:2.16.1.3">section
748 2.16.1.3</a>.
706749 </ul>
707750 </ul>
708751 </dd>
709 <dt class="pubdef"><a name="flag:large_files"><strong>large_files</strong>(<var>bool</var>)</a></dt>
752 <dt class="pubdef"><a id="flag:large_files"><strong>large_files</strong>(<var>bool</var>)</a></dt>
710753 <dd class="defbody">
711754 If present and <code>true</code>, SWI-Prolog has been compiled with
712755 <em>large file support</em> (LFS) and is capable of accessing files
713756 larger than 2GB on 32-bit hardware. Large file support is default on
714757 installations built using <b>configure</b> that support it and may be
715758 switched off using the configure option <code>--disable-largefile</code>.</dd>
716 <dt class="pubdef"><a name="flag:last_call_optimisation"><strong>last_call_optimisation</strong>(<var>bool</var>, changeable)</a></dt>
759 <dt class="pubdef"><a id="flag:last_call_optimisation"><strong>last_call_optimisation</strong>(<var>bool</var>, changeable)</a></dt>
717760 <dd class="defbody">
718761 Determines whether or not last-call optimisation is enabled. Normally
719762 the value of this flag is the negation of the <a class="flag" href="flags.html#flag:debug">debug</a>
720763 flag. As programs may run out of stack if last-call optimisation is
721764 omitted, it is sometimes necessary to enable it during debugging.</dd>
722 <dt class="pubdef"><a name="flag:max_arity"><strong>max_arity</strong>(<var>unbounded</var>)</a></dt>
765 <dt class="pubdef"><a id="flag:max_arity"><strong>max_arity</strong>(<var>unbounded</var>)</a></dt>
723766 <dd class="defbody">
724767 ISO Prolog flag describing there is no maximum arity to compound terms.</dd>
725 <dt class="pubdef"><a name="flag:max_integer"><strong>max_integer</strong>(<var>integer</var>)</a></dt>
768 <dt class="pubdef"><a id="flag:max_integer"><strong>max_integer</strong>(<var>integer</var>)</a></dt>
726769 <dd class="defbody">
727770 Maximum integer value if integers are <em>bounded</em>. See also the
728 flag <a class="flag" href="flags.html#flag:bounded">bounded</a> and <a class="sec" href="arith.html">section
771 flag <a class="flag" href="flags.html#flag:bounded">bounded</a> and <a class="sec" href="arith.html#sec:4.27.2.1">section
729772 4.27.2.1</a>.</dd>
730 <dt class="pubdef"><a name="flag:max_tagged_integer"><strong>max_tagged_integer</strong>(<var>integer</var>)</a></dt>
773 <dt class="pubdef"><a id="flag:max_tagged_integer"><strong>max_tagged_integer</strong>(<var>integer</var>)</a></dt>
731774 <dd class="defbody">
732775 Maximum integer value represented as a `tagged' value. Tagged integers
733776 require one word storage. Larger integers are represented as `indirect
734777 data' and require significantly more space.</dd>
735 <dt class="pubdef"><a name="flag:min_integer"><strong>min_integer</strong>(<var>integer</var>)</a></dt>
778 <dt class="pubdef"><a id="flag:min_integer"><strong>min_integer</strong>(<var>integer</var>)</a></dt>
736779 <dd class="defbody">
737780 Minimum integer value if integers are <em>bounded</em>. See also the
738 flag <a class="flag" href="flags.html#flag:bounded">bounded</a> and <a class="sec" href="arith.html">section
781 flag <a class="flag" href="flags.html#flag:bounded">bounded</a> and <a class="sec" href="arith.html#sec:4.27.2.1">section
739782 4.27.2.1</a>.</dd>
740 <dt class="pubdef"><a name="flag:min_tagged_integer"><strong>min_tagged_integer</strong>(<var>integer</var>)</a></dt>
783 <dt class="pubdef"><a id="flag:min_tagged_integer"><strong>min_tagged_integer</strong>(<var>integer</var>)</a></dt>
741784 <dd class="defbody">
742785 Start of the tagged-integer value range.</dd>
743 <dt class="pubdef"><a name="flag:occurs_check"><strong>occurs_check</strong>(<var>atom</var>, changeable)</a></dt>
786 <dt class="pubdef"><a id="flag:occurs_check"><strong>occurs_check</strong>(<var>atom</var>, changeable)</a></dt>
744787 <dd class="defbody">
745788 This flag controls unification that creates an infinite tree (also
746789 called <em>cyclic term</em>) and can have three values. Using
747790 <code>false</code> (default), unification succeeds, creating an infinite
748 tree. Using <code>true</code>, unification behaves as <a name="idx:unifywithoccurscheck2:119"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>,
791 tree. Using <code>true</code>, unification behaves as <a id="idx:unifywithoccurscheck2:119"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>,
749792 failing silently. Using <code>error</code>, an attempt to create a
750793 cyclic term results in an <code>occurs_check</code> exception. The
751794 latter is intended for debugging unintentional creations of cyclic
752795 terms. Note that this flag is a global flag modifying fundamental
753796 behaviour of Prolog. Changing the flag from its default may cause
754797 libraries to stop functioning properly.</dd>
755 <dt class="pubdef"><a name="flag:open_shared_object"><strong>open_shared_object</strong>(<var>bool</var>)</a></dt>
756 <dd class="defbody">
757 If true, <a name="idx:opensharedobject2:120"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
798 <dt class="pubdef"><a id="flag:open_shared_object"><strong>open_shared_object</strong>(<var>bool</var>)</a></dt>
799 <dd class="defbody">
800 If true, <a id="idx:opensharedobject2:120"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
758801 and friends are implemented, providing access to shared libraries (<code>.so</code>
759802 files) or dynamic link libraries (<code>.DLL</code> files).</dd>
760 <dt class="pubdef"><a name="flag:optimise"><strong>optimise</strong>(<var>bool</var>, changeable)</a></dt>
803 <dt class="pubdef"><a id="flag:optimise"><strong>optimise</strong>(<var>bool</var>, changeable)</a></dt>
761804 <dd class="defbody">
762805 If <code>true</code>, compile in optimised mode. The initial value is
763806 <code>true</code> if Prolog was started with the <strong>-O</strong>
765808 flag is scoped to a source file.
766809
767810 <p>Currently optimised compilation implies compilation of arithmetic,
768 and deletion of redundant <a name="idx:true0:121"></a><a class="pred" href="control.html#true/0">true/0</a>
769 that may result from <a name="idx:expandgoal2:122"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>.
811 and deletion of redundant <a id="idx:true0:121"></a><a class="pred" href="control.html#true/0">true/0</a>
812 that may result from <a id="idx:expandgoal2:122"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>.
770813
771814 <p>Later versions might imply various other optimisations such as
772815 integrating small predicates into their callers, eliminating constant
773816 expressions and other predictable constructs. Source code optimisation
774817 is never applied to predicates that are declared dynamic (see
775 <a name="idx:dynamic1:123"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>).</dd>
776 <dt class="pubdef"><a name="flag:os_argv"><strong>os_argv</strong>(<var>list</var>, changeable)</a></dt>
818 <a id="idx:dynamic1:123"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>).</dd>
819 <dt class="pubdef"><a id="flag:os_argv"><strong>os_argv</strong>(<var>list</var>, changeable)</a></dt>
777820 <dd class="defbody">
778821 List is a list of atoms representing the command line arguments used to
779822 invoke SWI-Prolog. Please note that <b>all</b> arguments are included in
780823 the list returned. See <a class="flag" href="flags.html#flag:argv">argv</a>
781824 to get the application options.</dd>
782 <dt class="pubdef"><a name="flag:pid"><strong>pid</strong>(<var>int</var>)</a></dt>
825 <dt class="pubdef"><a id="flag:pid"><strong>pid</strong>(<var>int</var>)</a></dt>
783826 <dd class="defbody">
784827 Process identifier of the running Prolog process. Existence of this flag
785828 is implementation-defined.</dd>
786 <dt class="pubdef"><a name="flag:pipe"><strong>pipe</strong>(<var>bool</var>, changeable)</a></dt>
829 <dt class="pubdef"><a id="flag:pipe"><strong>pipe</strong>(<var>bool</var>, changeable)</a></dt>
787830 <dd class="defbody">
788831 If true, <code>open(pipe(command), mode, Stream)</code>, etc. are
789832 supported. Can be changed to disable the use of pipes in applications
790833 testing this feature. Not recommended.</dd>
791 <dt class="pubdef"><a name="flag:print_write_options"><strong>print_write_options</strong>(<var>term</var>, changeable)</a></dt>
792 <dd class="defbody">
793 Specifies the options for <a name="idx:writeterm2:124"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
794 used by <a name="idx:print1:125"></a><a class="pred" href="termrw.html#print/1">print/1</a>
795 and <a name="idx:print2:126"></a><a class="pred" href="termrw.html#print/2">print/2</a>.</dd>
796 <dt class="pubdef"><a name="flag:prompt_alternatives_on"><strong>prompt_alternatives_on</strong>(<var>atom</var>, changeable)</a></dt>
797 <dd class="defbody">
798 <a name="idx:promptalternatives:127"></a>Determines prompting for
834 <dt class="pubdef"><a id="flag:print_write_options"><strong>print_write_options</strong>(<var>term</var>, changeable)</a></dt>
835 <dd class="defbody">
836 Specifies the options for <a id="idx:writeterm2:124"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
837 used by <a id="idx:print1:125"></a><a class="pred" href="termrw.html#print/1">print/1</a>
838 and <a id="idx:print2:126"></a><a class="pred" href="termrw.html#print/2">print/2</a>.</dd>
839 <dt class="pubdef"><a id="flag:prompt_alternatives_on"><strong>prompt_alternatives_on</strong>(<var>atom</var>, changeable)</a></dt>
840 <dd class="defbody">
841 <a id="idx:promptalternatives:127"></a>Determines prompting for
799842 alternatives in the Prolog top level. Default is
800843 <code>determinism</code>, which implies the system prompts for
801844 alternatives if the goal succeeded while leaving choice points. Many
802845 classical Prolog systems behave as <code>groundness</code>: they prompt
803846 for alternatives if and only if the query contains variables.</dd>
804 <dt class="pubdef"><a name="flag:protect_static_code"><strong>protect_static_code</strong>(<var>bool</var>, changeable)</a></dt>
805 <dd class="defbody">
806 If <code>true</code> (default <code>false</code>), <a name="idx:clause2:128"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
847 <dt class="pubdef"><a id="flag:protect_static_code"><strong>protect_static_code</strong>(<var>bool</var>, changeable)</a></dt>
848 <dd class="defbody">
849 If <code>true</code> (default <code>false</code>), <a id="idx:clause2:128"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
807850 does not operate on static code, providing some basic protection from
808851 hackers that wish to list the static code of your Prolog program. Once
809852 the flag is
810853 <code>true</code>, it cannot be changed back to <code>false</code>.
811854 Protection is default in ISO mode (see Prolog flag <a class="flag" href="flags.html#flag:iso">iso</a>).
812 Note that many parts of the development environment require <a name="idx:clause2:129"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
855 Note that many parts of the development environment require <a id="idx:clause2:129"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
813856 to work on static code, and enabling this flag should thus only be used
814857 for production code.</dd>
815 <dt class="pubdef"><a name="flag:qcompile"><strong>qcompile</strong>(<var>atom</var>, changeable)</a></dt>
858 <dt class="pubdef"><a id="flag:qcompile"><strong>qcompile</strong>(<var>atom</var>, changeable)</a></dt>
816859 <dd class="defbody">
817860 This option provides the default for the <code>qcompile(+Atom)</code>
818 option of <a name="idx:loadfiles2:130"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
819 <dt class="pubdef"><a name="flag:readline"><strong>readline</strong>(<var>atom</var>, changeable)</a></dt>
861 option of <a id="idx:loadfiles2:130"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
862 <dt class="pubdef"><a id="flag:readline"><strong>readline</strong>(<var>atom</var>, changeable)</a></dt>
820863 <dd class="defbody">
821864 Specifies which form of command line editing is provided. Possible
822865 values are below. The flag may be set from the user's init file (see
823 <a class="sec" href="initgoal.html">section 2.3</a>) to one of <code>false</code>, <code>readline</code>
866 <a class="sec" href="initgoal.html#sec:2.3">section 2.3</a>) to one of <code>false</code>, <code>readline</code>
824867 or
825868 <code>editline</code>. This causes the toplevel not to load a command
826869 line editor (<code>false</code>) or load the specified one. If loading
847890 </dl>
848891
849892 </dd>
850 <dt class="pubdef"><a name="flag:resource_database"><strong>resource_database</strong>(<var>atom</var>)</a></dt>
893 <dt class="pubdef"><a id="flag:resource_database"><strong>resource_database</strong>(<var>atom</var>)</a></dt>
851894 <dd class="defbody">
852895 Set to the absolute filename of the attached state. Typically this is
853896 the file <code>boot32.prc</code>, the file specified with <strong>-x</strong>
854 or the running executable. See also <a name="idx:resource3:131"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.</dd>
855 <dt class="pubdef"><a name="flag:report_error"><strong>report_error</strong>(<var>bool</var>, changeable)</a></dt>
897 or the running executable. See also <a id="idx:resource3:131"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.</dd>
898 <dt class="pubdef"><a id="flag:report_error"><strong>report_error</strong>(<var>bool</var>, changeable)</a></dt>
856899 <dd class="defbody">
857900 If <code>true</code>, print error messages; otherwise suppress them. May
858901 be changed. See also the <a class="flag" href="flags.html#flag:debug_on_error">debug_on_error</a>
859902 Prolog flag. Default is <code>true</code>, except for the runtime
860903 version.</dd>
861 <dt class="pubdef"><a name="flag:runtime"><strong>runtime</strong>(<var>bool</var>)</a></dt>
904 <dt class="pubdef"><a id="flag:runtime"><strong>runtime</strong>(<var>bool</var>)</a></dt>
862905 <dd class="defbody">
863906 If present and <code>true</code>, SWI-Prolog is compiled with
864907 -DO_RUNTIME, disabling various useful development features (currently
865908 the tracer and profiler).</dd>
866 <dt class="pubdef"><a name="flag:sandboxed_load"><strong>sandboxed_load</strong>(<var>bool</var>, changeable)</a></dt>
867 <dd class="defbody">
868 If <code>true</code> (default <code>false</code>), <a name="idx:loadfiles2:132"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
909 <dt class="pubdef"><a id="flag:sandboxed_load"><strong>sandboxed_load</strong>(<var>bool</var>, changeable)</a></dt>
910 <dd class="defbody">
911 If <code>true</code> (default <code>false</code>), <a id="idx:loadfiles2:132"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
869912 calls hooks to allow library(sandbox) to verify the safety of
870913 directives.</dd>
871 <dt class="pubdef"><a name="flag:saved_program"><strong>saved_program</strong>(<var>bool</var>)</a></dt>
914 <dt class="pubdef"><a id="flag:saved_program"><strong>saved_program</strong>(<var>bool</var>)</a></dt>
872915 <dd class="defbody">
873916 If present and <code>true</code>, Prolog has been started from a state
874 saved with <a name="idx:qsaveprogram12:133"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.</dd>
875 <dt class="pubdef"><a name="flag:shared_object_extension"><strong>shared_object_extension</strong>(<var>atom</var>)</a></dt>
917 saved with <a id="idx:qsaveprogram12:133"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.</dd>
918 <dt class="pubdef"><a id="flag:shared_object_extension"><strong>shared_object_extension</strong>(<var>atom</var>)</a></dt>
876919 <dd class="defbody">
877920 Extension used by the operating system for shared objects. <code>.so</code>
878921 for most Unix systems and <code>.dll</code> for Windows. Used for
879922 locating files using the <code>file_type</code> <code>executable</code>.
880923 See also
881 <a name="idx:absolutefilename3:134"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
882 <dt class="pubdef"><a name="flag:shared_object_search_path"><strong>shared_object_search_path</strong>(<var>atom</var>)</a></dt>
924 <a id="idx:absolutefilename3:134"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
925 <dt class="pubdef"><a id="flag:shared_object_search_path"><strong>shared_object_search_path</strong>(<var>atom</var>)</a></dt>
883926 <dd class="defbody">
884927 Name of the environment variable used by the system to search for shared
885928 objects.</dd>
886 <dt class="pubdef"><a name="flag:signals"><strong>signals</strong>(<var>bool</var>)</a></dt>
929 <dt class="pubdef"><a id="flag:signals"><strong>signals</strong>(<var>bool</var>)</a></dt>
887930 <dd class="defbody">
888931 Determine whether Prolog is handling signals (software interrupts). This
889932 flag is <code>false</code> if the hosting OS does not support signal
890933 handling or the command line option <strong>-nosignals</strong> is
891934 active. See
892 <a class="sec" href="foreigninclude.html">section 11.4.21.1</a> for
893 details.</dd>
894 <dt class="pubdef"><a name="flag:stream_type_check"><strong>stream_type_check</strong>(<var>atom</var>, changeable)</a></dt>
935 <a class="sec" href="foreigninclude.html#sec:11.4.21.1">section
936 11.4.21.1</a> for details.</dd>
937 <dt class="pubdef"><a id="flag:stream_type_check"><strong>stream_type_check</strong>(<var>atom</var>, changeable)</a></dt>
895938 <dd class="defbody">
896939 Defines whether and how strictly the system validates that byte I/O
897940 should not be applied to text streams and text I/O should not be applied
899942 (full checking) and <code>loose</code>. Using checking mode <code>loose</code>
900943 (default), the system accepts byte I/O from text stream that use ISO
901944 Latin-1 encoding and accepts writing text to binary streams.</dd>
902 <dt class="pubdef"><a name="flag:system_thread_id"><strong>system_thread_id</strong>(<var>int</var>)</a></dt>
903 <dd class="defbody">
904 Available in multithreaded version (see <a class="sec" href="threads.html">section
945 <dt class="pubdef"><a id="flag:system_thread_id"><strong>system_thread_id</strong>(<var>int</var>)</a></dt>
946 <dd class="defbody">
947 Available in multithreaded version (see <a class="sec" href="threads.html#sec:9">section
905948 9</a>) where the operating system provides system-wide integer thread
906949 identifiers. The integer is the thread identifier used by the operating
907 system for the calling thread. See also <a name="idx:threadself1:135"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>.</dd>
908 <dt class="pubdef"><a name="flag:table_space"><strong>table_space</strong>(<var>integer</var>, changeable)</a></dt>
950 system for the calling thread. See also <a id="idx:threadself1:135"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>.</dd>
951 <dt class="pubdef"><a id="flag:table_space"><strong>table_space</strong>(<var>integer</var>, changeable)</a></dt>
909952 <dd class="defbody">
910953 Space reserved for storing answer tables for <em>tabled predicates</em>
911 (see <a name="idx:table1:136"></a><a class="pred" href="tabling.html#table/1">table/1</a>).<sup class="fn">bug<span class="fn-text">Currently
954 (see <a id="idx:table1:136"></a><a class="pred" href="tabling.html#table/1">table/1</a>).<sup class="fn">bug<span class="fn-text">Currently
912955 only counts the space occupied by the nodes in the answer tries.</span></sup>
913956 When exceeded a
914957 <code>resource_error(table_space)</code> exception is raised.</dd>
915 <dt class="pubdef"><a name="flag:timezone"><strong>timezone</strong>(<var>integer</var>)</a></dt>
958 <dt class="pubdef"><a id="flag:timezone"><strong>timezone</strong>(<var>integer</var>)</a></dt>
916959 <dd class="defbody">
917960 Offset in seconds west of GMT of the current time zone. Set at
918961 initialization time from the <code>timezone</code> variable associated
919 with the POSIX tzset() function. See also <a name="idx:formattime3:137"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>.</dd>
920 <dt class="pubdef"><a name="flag:toplevel_goal"><strong>toplevel_goal</strong>(<var>term</var>, changeable)</a></dt>
962 with the POSIX tzset() function. See also <a id="idx:formattime3:137"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>.</dd>
963 <dt class="pubdef"><a id="flag:toplevel_goal"><strong>toplevel_goal</strong>(<var>term</var>, changeable)</a></dt>
921964 <dd class="defbody">
922965 Defines the goal that is executed after running the initialization goals
923 and entry point (see <strong>-g</strong>, <a name="idx:initialization2:138"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
966 and entry point (see <strong>-g</strong>, <a id="idx:initialization2:138"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
924967 and
925 <a class="sec" href="compilation.html">section 2.10.2.1</a>. The initial
926 value is <code>default</code>, starting a normal interactive session.
927 This value may be changed using the command line option <strong>-t</strong>.
968 <a class="sec" href="compilation.html#sec:2.10.2.1">section 2.10.2.1</a>.
969 The initial value is <code>default</code>, starting a normal interactive
970 session. This value may be changed using the command line option <strong>-t</strong>.
928971 The explicit value <code>prolog</code> is equavalent to <code>default</code>.
929972 If <code>initialization(Goal,main)</code> is used and the toplevel is <code>default</code>,
930973 the toplevel is set to
931 <code>halt</code> (see <a name="idx:halt0:139"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>).</dd>
932 <dt class="pubdef"><a name="flag:toplevel_mode"><strong>toplevel_mode</strong>(<var>atom</var>, changeable)</a></dt>
974 <code>halt</code> (see <a id="idx:halt0:139"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>).</dd>
975 <dt class="pubdef"><a id="flag:toplevel_mode"><strong>toplevel_mode</strong>(<var>atom</var>, changeable)</a></dt>
933976 <dd class="defbody">
934977 If <code>backtracking</code> (default), the toplevel backtracks after
935978 completing a query. If <code>recursive</code>, the toplevel is
936979 implemented as a recursive loop. This implies that global variables set
937980 using
938 <a name="idx:bsetval2:140"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
981 <a id="idx:bsetval2:140"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
939982 are maintained between queries. In <em>recursive</em> mode, answers to
940 toplevel variables (see <a class="sec" href="topvars.html">section 2.8</a>)
941 are kept in backtrackable global variables and thus <b>not copied</b>.
942 In
983 toplevel variables (see <a class="sec" href="topvars.html#sec:2.8">section
984 2.8</a>) are kept in backtrackable global variables and thus <b>not
985 copied</b>. In
943986 <em>backtracking</em> mode answers to toplevel variables are kept in the
944 recorded database (see <a class="sec" href="db.html">section 4.14.2</a>).
987 recorded database (see <a class="sec" href="db.html#sec:4.14.2">section
988 4.14.2</a>).
945989
946990 <p>The recursive mode has been added for interactive usage of CHR (see
947 <a class="sec" href="chr.html">section 8</a>),<sup class="fn">22<span class="fn-text">Suggested
991 <a class="sec" href="chr.html#sec:8">section 8</a>),<sup class="fn">22<span class="fn-text">Suggested
948992 by Falco Nogatz</span></sup> which maintains the global constraint store
949993 in backtrackable global variables.</dd>
950 <dt class="pubdef"><a name="flag:toplevel_print_anon"><strong>toplevel_print_anon</strong>(<var>bool</var>, changeable)</a></dt>
994 <dt class="pubdef"><a id="flag:toplevel_print_anon"><strong>toplevel_print_anon</strong>(<var>bool</var>, changeable)</a></dt>
951995 <dd class="defbody">
952996 If <code>true</code>, top-level variables starting with an underscore (<code>_</code>)
953997 are printed normally. If <code>false</code> they are hidden. This may be
954998 used to hide bindings in complex queries from the top level.</dd>
955 <dt class="pubdef"><a name="flag:toplevel_print_factorized"><strong>toplevel_print_factorized</strong>(<var>bool</var>, changeable)</a></dt>
999 <dt class="pubdef"><a id="flag:toplevel_print_factorized"><strong>toplevel_print_factorized</strong>(<var>bool</var>, changeable)</a></dt>
9561000 <dd class="defbody">
9571001 If <code>true</code> (default <code>false</code>) show the internal
9581002 sharing of subterms in the answer substitution. The example below
9591003 reveals internal sharing of leaf nodes in <em>red-black trees</em> as
9601004 implemented by the
961 <code>library(rbtrees)</code> predicate rb_new1:
1005 <code>library(rbtrees)</code> predicate rb_new/1 :
9621006
9631007 <pre class="code">
9641008 ?- set_prolog_flag(toplevel_print_factorized, true).
9801024 </pre>
9811025
9821026 </dd>
983 <dt class="pubdef"><a name="flag:answer_write_options"><strong>answer_write_options</strong>(<var>term</var>, changeable)</a></dt>
984 <dd class="defbody">
985 This argument is given as option-list to <a name="idx:writeterm2:141"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
1027 <dt class="pubdef"><a id="flag:answer_write_options"><strong>answer_write_options</strong>(<var>term</var>, changeable)</a></dt>
1028 <dd class="defbody">
1029 This argument is given as option-list to <a id="idx:writeterm2:141"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
9861030 for printing results of queries. Default is <code>[quoted(true),
9871031 portray(true), max_depth(10), attributes(portray)]</code>.</dd>
988 <dt class="pubdef"><a name="flag:toplevel_prompt"><strong>toplevel_prompt</strong>(<var>atom</var>, changeable)</a></dt>
1032 <dt class="pubdef"><a id="flag:toplevel_prompt"><strong>toplevel_prompt</strong>(<var>atom</var>, changeable)</a></dt>
9891033 <dd class="defbody">
9901034 Define the prompt that is used by the interactive top level. The
9911035 following <code>~</code> (tilde) sequences are replaced:
9921036
993 <p><table border="2" frame="hsides" rules="groups" style="margin:auto">
994 <tr valign="top"><td><code><code>~</code></code>m</td><td><em>Type in</em>
995 module if not <code>user</code> (see <a name="idx:module1:142"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>) </td></tr>
996 <tr valign="top"><td><code><code>~</code></code>l</td><td><em>Break
997 level</em> if not 0 (see <a name="idx:break0:143"></a><a class="pred" href="toplevel.html#break/0">break/0</a>) </td></tr>
998 <tr valign="top"><td><code><code>~</code></code>d</td><td><em>Debugging
999 state</em> if not normal execution (see <a name="idx:debug0:144"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>, <a name="idx:trace0:145"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>) </td></tr>
1000 <tr valign="top"><td><code><code>~</code></code>!</td><td><em>History
1001 event</em> if history is enabled (see flag <a class="flag" href="flags.html#flag:history">history</a>) </td></tr>
1037 <p><table class="latex frame-hsides center">
1038 <tr><td><code><code>~</code></code>m</td><td><em>Type in</em> module if
1039 not <code>user</code> (see <a id="idx:module1:142"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>) </td></tr>
1040 <tr><td><code><code>~</code></code>l</td><td><em>Break level</em> if not
1041 0 (see <a id="idx:break0:143"></a><a class="pred" href="toplevel.html#break/0">break/0</a>) </td></tr>
1042 <tr><td><code><code>~</code></code>d</td><td><em>Debugging state</em> if
1043 not normal execution (see <a id="idx:debug0:144"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>, <a id="idx:trace0:145"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>) </td></tr>
1044 <tr><td><code><code>~</code></code>!</td><td><em>History event</em> if
1045 history is enabled (see flag <a class="flag" href="flags.html#flag:history">history</a>) </td></tr>
10021046 </table>
10031047 </dd>
1004 <dt class="pubdef"><a name="flag:toplevel_var_size"><strong>toplevel_var_size</strong>(<var>int</var>, changeable)</a></dt>
1048 <dt class="pubdef"><a id="flag:toplevel_var_size"><strong>toplevel_var_size</strong>(<var>int</var>, changeable)</a></dt>
10051049 <dd class="defbody">
10061050 Maximum size counted in literals of a term returned as a binding for a
10071051 variable in a top-level query that is saved for re-use using the
1008 <code><code>$</code></code> variable reference. See <a class="sec" href="topvars.html">section
1052 <code><code>$</code></code> variable reference. See <a class="sec" href="topvars.html#sec:2.8">section
10091053 2.8</a>.</dd>
1010 <dt class="pubdef"><a name="flag:trace_gc"><strong>trace_gc</strong>(<var>bool</var>, changeable)</a></dt>
1054 <dt class="pubdef"><a id="flag:trace_gc"><strong>trace_gc</strong>(<var>bool</var>, changeable)</a></dt>
10111055 <dd class="defbody">
10121056 If <code>true</code> (default <code>false</code>), garbage collections
10131057 and stack-shifts will be reported on the terminal. May be changed.
10231067 </pre>
10241068
10251069 </dd>
1026 <dt class="pubdef"><a name="flag:traditional"><strong>traditional</strong>(<var>bool</var>)</a></dt>
1070 <dt class="pubdef"><a id="flag:traditional"><strong>traditional</strong>(<var>bool</var>)</a></dt>
10271071 <dd class="defbody">
10281072 Available in SWI-Prolog version&nbsp;7. If <code>true</code>,
10291073 `traditional' mode has been selected using <strong>--traditional</strong>.
10301074 Notice that some SWI7 features, like the functional notation on dicts,
1031 do not work in this mode. See also <a class="sec" href="extensions.html">section
1075 do not work in this mode. See also <a class="sec" href="extensions.html#sec:5">section
10321076 5</a>.</dd>
1033 <dt class="pubdef"><a name="flag:tty_control"><strong>tty_control</strong>(<var>bool</var>, changeable)</a></dt>
1077 <dt class="pubdef"><a id="flag:tty_control"><strong>tty_control</strong>(<var>bool</var>, changeable)</a></dt>
10341078 <dd class="defbody">
10351079 Determines whether the terminal is switched to raw mode for
1036 <a name="idx:getsinglechar1:146"></a><a class="pred" href="chario.html#get_single_char/1">get_single_char/1</a>,
1080 <a id="idx:getsinglechar1:146"></a><a class="pred" href="chario.html#get_single_char/1">get_single_char/1</a>,
10371081 which also reads the user actions for the trace. May be set. If this
10381082 flag is <code>false</code> at startup, command line editing is disabled.
10391083 See also the <strong>+/-tty</strong> command line option.</dd>
1040 <dt class="pubdef"><a name="flag:unix"><strong>unix</strong>(<var>bool</var>)</a></dt>
1041 <dd class="defbody">
1042 <a name="idx:unix:147"></a>If present and <code>true</code>, the
1043 operating system is some version of Unix. Defined if the C compiler used
1044 to compile this version of SWI-Prolog either defines <code>__unix__</code>
1084 <dt class="pubdef"><a id="flag:unix"><strong>unix</strong>(<var>bool</var>)</a></dt>
1085 <dd class="defbody">
1086 <a id="idx:unix:147"></a>If present and <code>true</code>, the operating
1087 system is some version of Unix. Defined if the C compiler used to
1088 compile this version of SWI-Prolog either defines <code>__unix__</code>
10451089 or <code>unix</code>. On other systems this flag is not available. See
10461090 also <a class="flag" href="flags.html#flag:apple">apple</a> and <a class="flag" href="flags.html#flag:windows">windows</a>.</dd>
1047 <dt class="pubdef"><a name="flag:unknown"><strong>unknown</strong>(<var>fail,warning,error</var>, changeable)</a></dt>
1091 <dt class="pubdef"><a id="flag:unknown"><strong>unknown</strong>(<var>fail,warning,error</var>, changeable)</a></dt>
10481092 <dd class="defbody">
10491093 Determines the behaviour if an undefined procedure is encountered. If
10501094 <code>fail</code>, the predicate fails silently. If <code>warn</code>, a
10561100 which in turn inherit the value <code>error</code> from <code>system</code>.
10571101 The user may change the flag for module <code>user</code> to change the
10581102 default for all application modules or for a specific module. It is
1059 strongly advised to keep the <code>error</code> default and use <a name="idx:dynamic1:148"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
1060 and/or <a name="idx:multifile1:149"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>
1103 strongly advised to keep the <code>error</code> default and use <a id="idx:dynamic1:148"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
1104 and/or <a id="idx:multifile1:149"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>
10611105 to specify possible non-existence of a predicate.</dd>
1062 <dt class="pubdef"><a name="flag:unload_foreign_libraries"><strong>unload_foreign_libraries</strong>(<var>bool</var>, changeable)</a></dt>
1106 <dt class="pubdef"><a id="flag:unload_foreign_libraries"><strong>unload_foreign_libraries</strong>(<var>bool</var>, changeable)</a></dt>
10631107 <dd class="defbody">
10641108 If <code>true</code> (default <code>false</code>), unload all loaded
10651109 foreign libraries. Default is <code>false</code> because modern OSes
10661110 reclaim the resources anyway and unloading the foreign code may cause
10671111 registered hooks to point to no longer existing data or code.</dd>
1068 <dt class="pubdef"><a name="flag:user_flags"><strong>user_flags</strong>(<var>Atom</var>, changeable)</a></dt>
1069 <dd class="defbody">
1070 Define the behaviour of <a name="idx:setprologflag2:150"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
1112 <dt class="pubdef"><a id="flag:user_flags"><strong>user_flags</strong>(<var>Atom</var>, changeable)</a></dt>
1113 <dd class="defbody">
1114 Define the behaviour of <a id="idx:setprologflag2:150"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
10711115 if the flag is not known. Values are <code>silent</code>, <code>warning</code>
10721116 and <code>error</code>. The first two create the flag on-the-fly, where <code>warning</code>
10731117 prints a message. The value <code>error</code> is consistent with ISO:
1074 it raises an existence error and does not create the flag. See also <a name="idx:createprologflag3:151"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>.
1118 it raises an existence error and does not create the flag. See also <a id="idx:createprologflag3:151"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>.
10751119 The default is <code>silent</code>, but future versions may change that.
1076 Developers are encouraged to use another value and ensure proper use of <a name="idx:createprologflag3:152"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
1120 Developers are encouraged to use another value and ensure proper use of <a id="idx:createprologflag3:152"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
10771121 to create flags for their library.</dd>
1078 <dt class="pubdef"><a name="flag:var_prefix"><strong>var_prefix</strong>(<var>bool</var>, changeable)</a></dt>
1122 <dt class="pubdef"><a id="flag:var_prefix"><strong>var_prefix</strong>(<var>bool</var>, changeable)</a></dt>
10791123 <dd class="defbody">
10801124 If <code>true</code> (default <code>false</code>), variables must start
10811125 with an underscore (<code>_</code>). May be changed. This flag is local
1082 to the module in which it is changed. See <a class="sec" href="syntax.html">section
1126 to the module in which it is changed. See <a class="sec" href="syntax.html#sec:2.16.1.7">section
10831127 2.16.1.7</a>.</dd>
1084 <dt class="pubdef"><a name="flag:verbose"><strong>verbose</strong>(<var>atom</var>, changeable)</a></dt>
1085 <dd class="defbody">
1086 This flag is used by <a name="idx:printmessage2:153"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
1128 <dt class="pubdef"><a id="flag:verbose"><strong>verbose</strong>(<var>atom</var>, changeable)</a></dt>
1129 <dd class="defbody">
1130 This flag is used by <a id="idx:printmessage2:153"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
10871131 If its value is <code>silent</code>, messages of type <code>informational</code>
10881132 and <code>banner</code> are suppressed. The <strong>-q</strong> switches
10891133 the value from the initial
10901134 <code>normal</code> to <code>silent</code>.</dd>
1091 <dt class="pubdef"><a name="flag:verbose_autoload"><strong>verbose_autoload</strong>(<var>bool</var>, changeable)</a></dt>
1135 <dt class="pubdef"><a id="flag:verbose_autoload"><strong>verbose_autoload</strong>(<var>bool</var>, changeable)</a></dt>
10921136 <dd class="defbody">
10931137 If <code>true</code> the normal consult message will be printed if a
10941138 library is autoloaded. By default this message is suppressed. Intended
10951139 to be used for debugging purposes.</dd>
1096 <dt class="pubdef"><a name="flag:verbose_load"><strong>verbose_load</strong>(<var>atom</var>, changeable)</a></dt>
1140 <dt class="pubdef"><a id="flag:verbose_load"><strong>verbose_load</strong>(<var>atom</var>, changeable)</a></dt>
10971141 <dd class="defbody">
10981142 Determines messages printed for loading (compiling) Prolog files.
10991143 Current values are <code>full</code> (print a message at the start and
11021146 loading the toplevel file), and <code>silent</code> (no messages are
11031147 printed, default). The value of this flag is normally controlled by the
11041148 option
1105 <code>silent(Bool)</code> provided by <a name="idx:loadfiles2:154"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
1106 <dt class="pubdef"><a name="flag:verbose_file_search"><strong>verbose_file_search</strong>(<var>bool</var>, changeable)</a></dt>
1149 <code>silent(Bool)</code> provided by <a id="idx:loadfiles2:154"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
1150 <dt class="pubdef"><a id="flag:verbose_file_search"><strong>verbose_file_search</strong>(<var>bool</var>, changeable)</a></dt>
11071151 <dd class="defbody">
11081152 If <code>true</code> (default <code>false</code>), print messages
1109 indicating the progress of <a name="idx:absolutefilename23:155"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>
1153 indicating the progress of <a id="idx:absolutefilename23:155"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>
11101154 in locating files. Intended for debugging complicated file-search paths.
1111 See also <a name="idx:filesearchpath2:156"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
1112 <dt class="pubdef"><a name="flag:version"><strong>version</strong>(<var>integer</var>)</a></dt>
1155 See also <a id="idx:filesearchpath2:156"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
1156 <dt class="pubdef"><a id="flag:version"><strong>version</strong>(<var>integer</var>)</a></dt>
11131157 <dd class="defbody">
11141158 The version identifier is an integer with value:
11151159 <blockquote><var>10000 &times; <var>Major</var> + 100 &times; <var>Minor</var>
11161160 + <var>Patch</var></var></blockquote>
11171161 </dd>
1118 <dt class="pubdef"><a name="flag:version_data"><strong>version_data</strong>(<var>swi(Major, Minor, Patch, Extra)</var>)</a></dt>
1162 <dt class="pubdef"><a id="flag:version_data"><strong>version_data</strong>(<var>swi(Major, Minor, Patch, Extra)</var>)</a></dt>
11191163 <dd class="defbody">
11201164 Part of the dialect compatibility layer; see also the Prolog flag
1121 <a class="flag" href="flags.html#flag:dialect">dialect</a> and <a class="sec" href="dialect.html">section
1165 <a class="flag" href="flags.html#flag:dialect">dialect</a> and <a class="sec" href="dialect.html#sec:C">section
11221166 C</a>. <var>Extra</var> provides platform-specific version information
11231167 as a list. <var>Extra</var> is used for
11241168 <em>tagged versions</em> such as ``7.4.0-rc1'', in which case
11251169 <var>Extra</var> contains a term <code>tag(rc1)</code>.</dd>
1126 <dt class="pubdef"><a name="flag:version_git"><strong>version_git</strong>(<var>atom</var>)</a></dt>
1170 <dt class="pubdef"><a id="flag:version_git"><strong>version_git</strong>(<var>atom</var>)</a></dt>
11271171 <dd class="defbody">
11281172 Available if created from a git repository. See <b>git-describe</b> for
11291173 details.</dd>
1130 <dt class="pubdef"><a name="flag:warn_override_implicit_import"><strong>warn_override_implicit_import</strong>(<var>bool</var>, changeable)</a></dt>
1174 <dt class="pubdef"><a id="flag:warn_override_implicit_import"><strong>warn_override_implicit_import</strong>(<var>bool</var>, changeable)</a></dt>
11311175 <dd class="defbody">
11321176 If <code>true</code> (default), a warning is printed if an implicitly
11331177 imported predicate is clobbered by a local definition. See
1134 <a name="idx:usemodule1:157"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1178 <a id="idx:usemodule1:157"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
11351179 for details.</dd>
1136 <dt class="pubdef"><a name="flag:win_file_access_check"><strong>win_file_access_check</strong>(<var>atom</var>, changeable)</a></dt>
1137 <dd class="defbody">
1138 Controls the behaviour or <a name="idx:accessfile2:158"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>
1180 <dt class="pubdef"><a id="flag:win_file_access_check"><strong>win_file_access_check</strong>(<var>atom</var>, changeable)</a></dt>
1181 <dd class="defbody">
1182 Controls the behaviour or <a id="idx:accessfile2:158"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>
11391183 under Windows. There is no reliable way to check access to files and
11401184 directories on Windows. This flag allows for switching between three
11411185 alternative approximations.
11611205 </dl>
11621206
11631207 </dd>
1164 <dt class="pubdef"><a name="flag:windows"><strong>windows</strong>(<var>bool</var>)</a></dt>
1165 <dd class="defbody">
1166 <a name="idx:windows:159"></a>If present and <code>true</code>, the
1208 <dt class="pubdef"><a id="flag:windows"><strong>windows</strong>(<var>bool</var>)</a></dt>
1209 <dd class="defbody">
1210 <a id="idx:windows:159"></a>If present and <code>true</code>, the
11671211 operating system is an implementation of Microsoft Windows. This flag is
11681212 only available on MS-Windows based versions. See also <a class="flag" href="flags.html#flag:unix">unix</a>.</dd>
1169 <dt class="pubdef"><a name="flag:write_attributes"><strong>write_attributes</strong>(<var>atom</var>, changeable)</a></dt>
1170 <dd class="defbody">
1171 Defines how <a name="idx:write1:160"></a><a class="pred" href="termrw.html#write/1">write/1</a>
1213 <dt class="pubdef"><a id="flag:write_attributes"><strong>write_attributes</strong>(<var>atom</var>, changeable)</a></dt>
1214 <dd class="defbody">
1215 Defines how <a id="idx:write1:160"></a><a class="pred" href="termrw.html#write/1">write/1</a>
11721216 and friends write attributed variables. The option values are described
11731217 with the <code>attributes</code> option of
1174 <a name="idx:writeterm3:161"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
1218 <a id="idx:writeterm3:161"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
11751219 Default is <code>ignore</code>.</dd>
1176 <dt class="pubdef"><a name="flag:write_help_with_overstrike"><strong>write_help_with_overstrike</strong>(<var>bool</var>)</a></dt>
1177 <dd class="defbody">
1178 Internal flag used by <a name="idx:help1:162"></a><a class="pred" href="help.html#help/1">help/1</a>
1220 <dt class="pubdef"><a id="flag:write_help_with_overstrike"><strong>write_help_with_overstrike</strong>(<var>bool</var>)</a></dt>
1221 <dd class="defbody">
1222 Internal flag used by <a id="idx:help1:162"></a><a class="pred" href="help.html#help/1">help/1</a>
11791223 when writing to a terminal. If present and <code>true</code> it prints
11801224 bold and underlined text using
11811225 <em>overstrike</em>.</dd>
1182 <dt class="pubdef"><a name="flag:xpce"><strong>xpce</strong>(<var>bool</var>)</a></dt>
1226 <dt class="pubdef"><a id="flag:xpce"><strong>xpce</strong>(<var>bool</var>)</a></dt>
11831227 <dd class="defbody">
11841228 Available and set to <code>true</code> if the XPCE graphics system is
11851229 loaded.</dd>
1186 <dt class="pubdef"><a name="flag:xpce_version"><strong>xpce_version</strong>(<var>atom</var>)</a></dt>
1230 <dt class="pubdef"><a id="flag:xpce_version"><strong>xpce_version</strong>(<var>atom</var>)</a></dt>
11871231 <dd class="defbody">
11881232 Available and set to the version of the loaded XPCE system.</dd>
1189 <dt class="pubdef"><a name="flag:xref"><strong>xref</strong>(<var>bool</var>, changeable)</a></dt>
1233 <dt class="pubdef"><a id="flag:xref"><strong>xref</strong>(<var>bool</var>, changeable)</a></dt>
11901234 <dd class="defbody">
11911235 If <code>true</code>, source code is being read for <em>analysis</em>
11921236 purposes such as cross-referencing. Otherwise (default) it is being read
1193 to be compiled. This flag is used at several places by <a name="idx:termexpansion2:163"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1237 to be compiled. This flag is used at several places by <a id="idx:termexpansion2:163"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
11941238 and
1195 <a name="idx:goalexpansion2:164"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1239 <a id="idx:goalexpansion2:164"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11961240 hooks, notably if these hooks use side effects. See also the libraries <code>library(prolog_source)</code>
11971241 and <code>library(prolog_xref)</code>.
11981242 </dd>
11991243 </dl>
12001244
12011245 </dd>
1202 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_prolog_flag/2"><strong>set_prolog_flag</strong>(<var>:Key,
1246 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_prolog_flag/2"><strong>set_prolog_flag</strong>(<var>:Key,
12031247 +Value</var>)</a></dt>
12041248 <dd class="defbody">
12051249 Define a new Prolog flag or change its value. <var>Key</var> is an atom.
12241268
12251269 <p>The behaviour when <var>Key</var> denotes a non-existent key depends
12261270 on the Prolog flag <a class="flag" href="flags.html#flag:user_flags">user_flags</a>.
1227 The default is to define them silently. New code is encouraged to use <a name="idx:createprologflag3:165"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
1271 The default is to define them silently. New code is encouraged to use <a id="idx:createprologflag3:165"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
12281272 for portability.</dd>
1229 <dt class="pubdef"><span class="pred-tag">[YAP]</span><a name="create_prolog_flag/3"><strong>create_prolog_flag</strong>(<var>+Key,
1273 <dt class="pubdef"><span class="pred-tag">[YAP]</span><a id="create_prolog_flag/3"><strong>create_prolog_flag</strong>(<var>+Key,
12301274 +Value, +Options</var>)</a></dt>
12311275 <dd class="defbody">
12321276 Create a new Prolog flag. The ISO standard does not foresee creation of
12471291 <dt><strong>keep</strong>(<var>+Boolean</var>)</dt>
12481292 <dd class="defbody">
12491293 If <code>true</code>, do not modify the flag if it already exists.
1250 Otherwise (default), this predicate behaves as <a name="idx:setprologflag2:166"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
1294 Otherwise (default), this predicate behaves as <a id="idx:setprologflag2:166"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
12511295 if the flag already exists.
12521296 </dd>
12531297 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.31</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.31</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="allsolutions.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="format.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:forall2"><a name="sec:4.31"><span class="sec-nr">4.31</span> <span class="sec-title">Forall</span></a></h2>
195
196 <a name="sec:forall2"></a>
235 <h2 id="sec:forall2"><a id="sec:4.31"><span class="sec-nr">4.31</span> <span class="sec-title">Forall</span></a></h2>
236
237 <a id="sec:forall2"></a>
197238
198239 <dl class="latex">
199 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="forall/2"><strong>forall</strong>(<var>:Cond,
240 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="forall/2"><strong>forall</strong>(<var>:Cond,
200241 :Action</var>)</a></dt>
201242 <dd class="defbody">
202243 For all alternative bindings of <var>Cond</var>, <var>Action</var> can
209250 Result =:= Formula).
210251 </pre>
211252
212 <p>The predicate <a name="idx:forall2:1375"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
253 <p>The predicate <a id="idx:forall2:1375"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
213254 is implemented as <code>\+ ( Cond, \+ Action)</code>, i.e., <i>There is
214255 no instantiation of <var>Cond</var> for which <var>Action</var> is
215256 false.</i>. The use of double negation implies that
216 <a name="idx:forall2:1376"></a><a class="pred" href="forall2.html#forall/2">forall/2</a> <em>does
217 not change any variable bindings</em>. It proves a relation. The <a name="idx:forall2:1377"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
257 <a id="idx:forall2:1376"></a><a class="pred" href="forall2.html#forall/2">forall/2</a> <em>does
258 not change any variable bindings</em>. It proves a relation. The <a id="idx:forall2:1377"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
218259 control structure can be used for its side-effects. E.g., the following
219260 asserts relations in a list into the dynamic database:
220261
223264 assertz(child_of(Child, Parent))).
224265 </pre>
225266
226 <p>Using <a name="idx:forall2:1378"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
267 <p>Using <a id="idx:forall2:1378"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
227268 as <code>forall(Generator, SideEffect)</code> is preferred over the
228269 classical <em>failure driven loop</em> as shown below because it makes
229270 it explicit which part of the construct is the generator and which part
241282 )
242283 </pre>
243284
244 <p>If your intent is to create variable bindings, the <a name="idx:forall2:1379"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
245 control structure is inadequate. Possibly you are looking for <a name="idx:maplist2:1380"></a><a class="pred" href="apply.html#maplist/2">maplist/2</a>,
246 <a name="idx:findall3:1381"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
247 or <a name="idx:foreach2:1382"></a><a class="pred" href="aggregate.html#foreach/2">foreach/2</a>.
285 <p>If your intent is to create variable bindings, the <a id="idx:forall2:1379"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
286 control structure is inadequate. Possibly you are looking for <a id="idx:maplist2:1380"></a><a class="pred" href="apply.html#maplist/2">maplist/2</a>,
287 <a id="idx:findall3:1381"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
288 or <a id="idx:foreach2:1382"></a><a class="pred" href="aggregate.html#foreach/2">foreach/2</a>.
248289 </dd>
249290 </dl>
250291
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="engine-predicates.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreignoverview.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:foreign"><a name="sec:11"><span class="sec-nr">11</span> <span class="sec-title">Foreign
235 <h1 id="sec:foreign"><a id="sec:11"><span class="sec-nr">11</span> <span class="sec-title">Foreign
195236 Language Interface</span></a></h1>
196237
197 <a name="sec:foreign"></a>
238 <a id="sec:foreign"></a>
198239
199240 <p>SWI-Prolog offers a powerful interface to C <cite><a class="cite" href="Bibliography.html#Kernighan:78">Kernighan &amp;
200241 Ritchie, 1978</a></cite>. The main design objectives of the foreign
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreigntypes.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="plld.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:foreigninclude"><a name="sec:11.4"><span class="sec-nr">11.4</span> <span class="sec-title">The
235 <h2 id="sec:foreigninclude"><a id="sec:11.4"><span class="sec-nr">11.4</span> <span class="sec-title">The
195236 Foreign Include File</span></a></h2>
196237
197 <a name="sec:foreigninclude"></a>
198
199 <p><h3 id="sec:foreign-control"><a name="sec:11.4.1"><span class="sec-nr">11.4.1</span> <span class="sec-title">Argument
238 <a id="sec:foreigninclude"></a>
239
240 <p><h3 id="sec:foreign-control"><a id="sec:11.4.1"><span class="sec-nr">11.4.1</span> <span class="sec-title">Argument
200241 Passing and Control</span></a></h3>
201242
202 <a name="sec:foreign-control"></a>
243 <a id="sec:foreign-control"></a>
203244
204245 <p>If Prolog encounters a foreign predicate at run time it will call a
205246 function specified in the predicate definition of the foreign predicate.
210251 alternatives to return control back to Prolog:
211252
212253 <dl class="latex">
213 <dt class="pubdef"><a name="PL_succeed()"><var>(return) foreign_t</var> <strong>PL_succeed</strong>(<var></var>)</a></dt>
254 <dt class="pubdef"><a id="PL_succeed()"><var>(return) foreign_t</var> <strong>PL_succeed</strong>(<var></var>)</a></dt>
214255 <dd class="defbody">
215256 Succeed deterministically. PL_succeed is defined as
216257 <code>return <code>TRUE</code></code>.
217258 </dd>
218 <dt class="pubdef"><a name="PL_fail()"><var>(return) foreign_t</var> <strong>PL_fail</strong>(<var></var>)</a></dt>
259 <dt class="pubdef"><a id="PL_fail()"><var>(return) foreign_t</var> <strong>PL_fail</strong>(<var></var>)</a></dt>
219260 <dd class="defbody">
220261 Fail and start Prolog backtracking. PL_fail is defined as <code>return <code>FALSE</code></code>.
221262 </dd>
222263 </dl>
223264
224 <p><h4 id="sec:foreignnondet"><a name="sec:11.4.1.1"><span class="sec-nr">11.4.1.1</span> <span class="sec-title">Non-deterministic
265 <p><h4 id="sec:foreignnondet"><a id="sec:11.4.1.1"><span class="sec-nr">11.4.1.1</span> <span class="sec-title">Non-deterministic
225266 Foreign Predicates</span></a></h4>
226267
227 <a name="sec:foreignnondet"></a>
268 <a id="sec:foreignnondet"></a>
228269
229270 <p>By default foreign predicates are deterministic. Using the
230271 <code>PL_FA_NONDETERMINISTIC</code> attribute (see <a class="func" href="foreigninclude.html#PL_register_foreign()">PL_register_foreign()</a>)
274315 <code>PL_foreign_context*()</code> macro.
275316
276317 <dl class="latex">
277 <dt class="pubdef"><a name="PL_retry()"><var>(return) foreign_t</var> <strong>PL_retry</strong>(<var>intptr_t
318 <dt class="pubdef"><a id="PL_retry()"><var>(return) foreign_t</var> <strong>PL_retry</strong>(<var>intptr_t
278319 value</var>)</a></dt>
279320 <dd class="defbody">
280321 The foreign function succeeds while leaving a choice point. On
286327 or 62 bits (two bits are used for status indication). Defined as <code>return
287328 _<a class="func" href="foreigninclude.html#PL_retry()">PL_retry(n)</a></code>.
288329 See also <a class="func" href="foreigninclude.html#PL_succeed()">PL_succeed()</a>.</dd>
289 <dt class="pubdef"><a name="PL_retry_address()"><var>(return) foreign_t</var> <strong>PL_retry_address</strong>(<var>void
330 <dt class="pubdef"><a id="PL_retry_address()"><var>(return) foreign_t</var> <strong>PL_retry_address</strong>(<var>void
290331 *</var>)</a></dt>
291332 <dd class="defbody">
292333 As <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a>,
294335 Defined as <code>return _<a class="func" href="foreigninclude.html#PL_retry_address()">PL_retry_address(n)</a></code>.
295336 See also
296337 <a class="func" href="foreigninclude.html#PL_succeed()">PL_succeed()</a>.</dd>
297 <dt class="pubdef"><a name="PL_foreign_control()"><var>int</var> <strong>PL_foreign_control</strong>(<var>control_t</var>)</a></dt>
338 <dt class="pubdef"><a id="PL_foreign_control()"><var>int</var> <strong>PL_foreign_control</strong>(<var>control_t</var>)</a></dt>
298339 <dd class="defbody">
299340 Extracts the type of call from the control argument. The return values
300341 are described above. Note that the function should be prepared to handle
301342 the <code>PL_PRUNED</code> case and should be aware that the other
302343 arguments are not valid in this case.</dd>
303 <dt class="pubdef"><a name="PL_foreign_context()"><var>intptr_t</var> <strong>PL_foreign_context</strong>(<var>control_t</var>)</a></dt>
344 <dt class="pubdef"><a id="PL_foreign_context()"><var>intptr_t</var> <strong>PL_foreign_context</strong>(<var>control_t</var>)</a></dt>
304345 <dd class="defbody">
305346 Extracts the context from the context argument. If the call type is
306347 <code>PL_FIRST_CALL</code> the context value is 0L. Otherwise it is the
307348 value returned by the last <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a>
308349 associated with this goal (both if the call type is <code>PL_REDO</code>
309350 or <code>PL_PRUNED</code>).</dd>
310 <dt class="pubdef"><a name="PL_foreign_context_address()"><var>void *</var> <strong>PL_foreign_context_address</strong>(<var>control_t</var>)</a></dt>
351 <dt class="pubdef"><a id="PL_foreign_context_address()"><var>void *</var> <strong>PL_foreign_context_address</strong>(<var>control_t</var>)</a></dt>
311352 <dd class="defbody">
312353 Extracts an address as passed in by <a class="func" href="foreigninclude.html#PL_retry_address()">PL_retry_address()</a>.</dd>
313 <dt class="pubdef"><a name="PL_foreign_context_predicate()"><var>predicate_t</var> <strong>PL_foreign_context_predicate</strong>(<var>control_t</var>)</a></dt>
354 <dt class="pubdef"><a id="PL_foreign_context_predicate()"><var>predicate_t</var> <strong>PL_foreign_context_predicate</strong>(<var>control_t</var>)</a></dt>
314355 <dd class="defbody">
315356
316357 <p>Fetch the Prolog predicate that is executing this function. Note that
361402
362403 <div class="caption"><b>Figure 6 : </b>Skeleton for non-deterministic
363404 foreign functions</div>
364 <a name="fig:nondetermf"></a>
365
366 <p><h3 id="sec:foreign-atoms"><a name="sec:11.4.2"><span class="sec-nr">11.4.2</span> <span class="sec-title">Atoms
405 <a id="fig:nondetermf"></a>
406
407 <p><h3 id="sec:foreign-atoms"><a id="sec:11.4.2"><span class="sec-nr">11.4.2</span> <span class="sec-title">Atoms
367408 and functors</span></a></h3>
368409
369 <a name="sec:foreign-atoms"></a>
410 <a id="sec:foreign-atoms"></a>
370411
371412 <p>The following functions provide for communication using atoms and
372413 functors.
373414
374415 <dl class="latex">
375 <dt class="pubdef"><a name="PL_new_atom()"><var>atom_t</var> <strong>PL_new_atom</strong>(<var>const
416 <dt class="pubdef"><a id="PL_new_atom()"><var>atom_t</var> <strong>PL_new_atom</strong>(<var>const
376417 char *</var>)</a></dt>
377418 <dd class="defbody">
378419 Return an atom handle for the given C-string. This function always
379420 succeeds. The returned handle is valid as long as the atom is referenced
380 (see <a class="sec" href="foreigninclude.html">section 11.4.2.1</a>).
381 The following atoms are provided as macros, giving access to the empty
382 list symbol and the name of the list constructor. Prior to version&nbsp;7, <code>ATOM_nil</code>
383 is the same as <code><a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom("[]")</a></code>
421 (see <a class="sec" href="foreigninclude.html#sec:11.4.2.1">section
422 11.4.2.1</a>). The following atoms are provided as macros, giving access
423 to the empty list symbol and the name of the list constructor. Prior to
424 version&nbsp;7, <code>ATOM_nil</code> is the same as <code><a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom("[]")</a></code>
384425 and <code>ATOM_dot</code> is the same as
385426 <code><a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom(".")</a></code>.
386427 This is no long the case in SWI-Prolog version&nbsp;7.
387428
388429 <dl class="latex">
389 <dt class="pubdef"><a name="ATOM_nil()"><var>atom_t</var> <strong>ATOM_nil</strong>(<var>ATOM_nil</var>)</a></dt>
430 <dt class="pubdef"><a id="ATOM_nil()"><var>atom_t</var> <strong>ATOM_nil</strong>(<var>ATOM_nil</var>)</a></dt>
390431 <dd class="defbody">
391432 tomic constant that represents the empty list. It is adviced to use <a class="func" href="foreigninclude.html#PL_get_nil()">PL_get_nil()</a>, <a class="func" href="foreigninclude.html#PL_put_nil()">PL_put_nil()</a>
392433 or <a class="func" href="foreigninclude.html#PL_unify_nil()">PL_unify_nil()</a>
393434 where applicable.</dd>
394 <dt class="pubdef"><a name="ATOM_dot()"><var>atom_t</var> <strong>ATOM_dot</strong>(<var>ATOM_dot</var>)</a></dt>
435 <dt class="pubdef"><a id="ATOM_dot()"><var>atom_t</var> <strong>ATOM_dot</strong>(<var>ATOM_dot</var>)</a></dt>
395436 <dd class="defbody">
396437 tomic constant that represents the name of the list constructor. The
397438 list constructor itself is created using
404445 </dl>
405446
406447 </dd>
407 <dt class="pubdef"><a name="PL_new_atom_mbchars()"><var>atom_t</var> <strong>PL_new_atom_mbchars</strong>(<var>int
448 <dt class="pubdef"><a id="PL_new_atom_mbchars()"><var>atom_t</var> <strong>PL_new_atom_mbchars</strong>(<var>int
408449 rep, size_t len, const char *s</var>)</a></dt>
409450 <dd class="defbody">
410451 This function generalizes <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>
415456 If
416457 <var>len</var> is <code>(size_t)-1</code>, it is computed from <var>s</var>
417458 using strlen().</dd>
418 <dt class="pubdef"><a name="PL_atom_chars()"><var>const char*</var> <strong>PL_atom_chars</strong>(<var>atom_t
459 <dt class="pubdef"><a id="PL_atom_chars()"><var>const char*</var> <strong>PL_atom_chars</strong>(<var>atom_t
419460 atom</var>)</a></dt>
420461 <dd class="defbody">
421462 Return a C-string for the text represented by the given atom. The
422463 returned text will not be changed by Prolog. It is not allowed to modify
423464 the contents, not even `temporary' as the string may reside in read-only
424465 memory. The returned string becomes invalid if the atom is garbage
425 collected (see <a class="sec" href="foreigninclude.html">section
466 collected (see <a class="sec" href="foreigninclude.html#sec:11.4.2.1">section
426467 11.4.2.1</a>). Foreign functions that require the text from an atom
427468 passed in a <code>term_t</code> normally use
428469 <a class="func" href="foreigninclude.html#PL_get_atom_chars()">PL_get_atom_chars()</a>
429470 or <a class="func" href="foreigninclude.html#PL_get_atom_nchars()">PL_get_atom_nchars()</a>.</dd>
430 <dt class="pubdef"><a name="PL_new_functor()"><var>functor_t</var> <strong>PL_new_functor</strong>(<var>atom_t
471 <dt class="pubdef"><a id="PL_new_functor()"><var>functor_t</var> <strong>PL_new_functor</strong>(<var>atom_t
431472 name, int arity</var>)</a></dt>
432473 <dd class="defbody">
433474 Returns a <em>functor identifier</em>, a handle for the name/arity pair.
434475 The returned handle is valid for the entire Prolog session.
435476 </dd>
436 <dt class="pubdef"><a name="PL_functor_name()"><var>atom_t</var> <strong>PL_functor_name</strong>(<var>functor_t
477 <dt class="pubdef"><a id="PL_functor_name()"><var>atom_t</var> <strong>PL_functor_name</strong>(<var>functor_t
437478 f</var>)</a></dt>
438479 <dd class="defbody">
439480 Return an atom representing the name of the given functor.
440481 </dd>
441 <dt class="pubdef"><a name="PL_functor_arity()"><var>size_t</var> <strong>PL_functor_arity</strong>(<var>functor_t
482 <dt class="pubdef"><a id="PL_functor_arity()"><var>size_t</var> <strong>PL_functor_arity</strong>(<var>functor_t
442483 f</var>)</a></dt>
443484 <dd class="defbody">
444485 Return the arity of the given functor.
445486 </dd>
446487 </dl>
447488
448 <p><h4 id="sec:atomgc"><a name="sec:11.4.2.1"><span class="sec-nr">11.4.2.1</span> <span class="sec-title">Atoms
489 <p><h4 id="sec:atomgc"><a id="sec:11.4.2.1"><span class="sec-nr">11.4.2.1</span> <span class="sec-title">Atoms
449490 and atom garbage collection</span></a></h4>
450491
451 <a name="sec:atomgc"></a>
492 <a id="sec:atomgc"></a>
452493
453494 <p>With the introduction of atom garbage collection in version 3.3.0,
454495 atoms no longer live as long as the process. Instead, their lifetime is
455496 guaranteed only as long as they are referenced. In the single-threaded
456497 version, atom garbage collections are only invoked at the
457 <em>call-port</em>. In the multithreaded version (see <a class="sec" href="threads.html">chapter
498 <em>call-port</em>. In the multithreaded version (see <a class="sec" href="threads.html#sec:9">chapter
458499 9</a>), they appear asynchronously, except for the invoking thread.
459500
460501 <p>For dealing with atom garbage collection, two additional functions
461502 are provided:
462503
463504 <dl class="latex">
464 <dt class="pubdef"><a name="PL_register_atom()"><var>void</var> <strong>PL_register_atom</strong>(<var>atom_t
505 <dt class="pubdef"><a id="PL_register_atom()"><var>void</var> <strong>PL_register_atom</strong>(<var>atom_t
465506 atom</var>)</a></dt>
466507 <dd class="defbody">
467508 Increment the reference count of the atom by one. <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>
468509 performs this automatically, returning an atom with a reference count of
469 at least one.<sup class="fn">169<span class="fn-text">Otherwise
510 at least one.<sup class="fn">170<span class="fn-text">Otherwise
470511 asynchronous atom garbage collection might destroy the atom before it is
471512 used.</span></sup></dd>
472 <dt class="pubdef"><a name="PL_unregister_atom()"><var>void</var> <strong>PL_unregister_atom</strong>(<var>atom_t
513 <dt class="pubdef"><a id="PL_unregister_atom()"><var>void</var> <strong>PL_unregister_atom</strong>(<var>atom_t
473514 atom</var>)</a></dt>
474515 <dd class="defbody">
475516 Decrement the reference count of the atom. If the reference count drops
490531 advised to use the *_chars() or *_nchars() functions whenever
491532 applicable.
492533
493 <p><h3 id="sec:foreign-term-analysis"><a name="sec:11.4.3"><span class="sec-nr">11.4.3</span> <span class="sec-title">Analysing
534 <p><h3 id="sec:foreign-term-analysis"><a id="sec:11.4.3"><span class="sec-nr">11.4.3</span> <span class="sec-title">Analysing
494535 Terms via the Foreign Interface</span></a></h3>
495536
496 <a name="sec:foreign-term-analysis"></a>
537 <a id="sec:foreign-term-analysis"></a>
497538
498539 <p>Each argument of a foreign function (except for the control argument)
499540 is of type <code>term_t</code>, an opaque handle to a Prolog term. Three
500541 groups of functions are available for the analysis of terms. The first
501 just validates the type, like the Prolog predicates <a name="idx:var1:2015"></a><a class="pred" href="typetest.html#var/1">var/1</a>, <a name="idx:atom1:2016"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>,
542 just validates the type, like the Prolog predicates <a id="idx:var1:2019"></a><a class="pred" href="typetest.html#var/1">var/1</a>, <a id="idx:atom1:2020"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>,
502543 etc., and are called <code>PL_is_*()</code>. The second group attempts
503544 to translate the argument into a C primitive type. These predicates take
504545 a <code>term_t</code> and a pointer to the appropriate C type and return <code>TRUE</code>
506547 <code>FALSE</code> depending on successful or unsuccessful translation.
507548 If the translation fails, the pointed-to data is never modified.
508549
509 <p><h4 id="sec:foreign-term-type"><a name="sec:11.4.3.1"><span class="sec-nr">11.4.3.1</span> <span class="sec-title">Testing
550 <p><h4 id="sec:foreign-term-type"><a id="sec:11.4.3.1"><span class="sec-nr">11.4.3.1</span> <span class="sec-title">Testing
510551 the type of a term</span></a></h4>
511552
512 <a name="sec:foreign-term-type"></a>
513
514 <dl class="latex">
515 <dt class="pubdef"><a name="PL_term_type()"><var>int</var> <strong>PL_term_type</strong>(<var>term_t</var>)</a></dt>
553 <a id="sec:foreign-term-type"></a>
554
555 <dl class="latex">
556 <dt class="pubdef"><a id="PL_term_type()"><var>int</var> <strong>PL_term_type</strong>(<var>term_t</var>)</a></dt>
516557 <dd class="defbody">
517558 Obtain the type of a term, which should be a term returned by one of the
518559 other interface predicates or passed as an argument. The function
541582 classify <code>PL_NIL</code> and <code>PL_BLOB</code> as <code>PL_ATOM</code>,
542583 <code>PL_LIST_PAIR</code> as <code>PL_TERM</code> and do not have dicts.
543584
544 <p><table border="2" frame="box" rules="groups">
545 <tr valign="top"><td><code>PL_VARIABLE</code> </td><td>A variable or
546 attributed variable </td></tr>
547 <tr valign="top"><td><code>PL_ATOM</code> </td><td>A Prolog atom </td></tr>
548 <tr valign="top"><td><code>PL_NIL</code> </td><td>The constant <code>[]</code> </td></tr>
549 <tr valign="top"><td><code>PL_BLOB</code> </td><td>A blob (see <a class="sec" href="foreigninclude.html">section
585 <p><table class="latex frame-box">
586 <tr><td><code>PL_VARIABLE</code> </td><td>A variable or attributed
587 variable </td></tr>
588 <tr><td><code>PL_ATOM</code> </td><td>A Prolog atom </td></tr>
589 <tr><td><code>PL_NIL</code> </td><td>The constant <code>[]</code> </td></tr>
590 <tr><td><code>PL_BLOB</code> </td><td>A blob (see <a class="sec" href="foreigninclude.html#sec:11.4.7.2">section
550591 11.4.7.2</a>) </td></tr>
551 <tr valign="top"><td><code>PL_STRING</code> </td><td>A string (see <a class="sec" href="strings.html">section
592 <tr><td><code>PL_STRING</code> </td><td>A string (see <a class="sec" href="strings.html#sec:5.2">section
552593 5.2</a>) </td></tr>
553 <tr valign="top"><td><code>PL_INTEGER</code> </td><td>A integer </td></tr>
554 <tr valign="top"><td><code>PL_FLOAT</code> </td><td>A floating point
555 number </td></tr>
556 <tr valign="top"><td><code>PL_TERM</code> </td><td>A compound term </td></tr>
557 <tr valign="top"><td><code>PL_LIST_PAIR</code> </td><td>A list cell (<code>[H|T]</code>) </td></tr>
558 <tr valign="top"><td><code>PL_DICT</code> </td><td>A dict (see <a class="sec" href="dicts.html">section
594 <tr><td><code>PL_INTEGER</code> </td><td>A integer </td></tr>
595 <tr><td><code>PL_FLOAT</code> </td><td>A floating point number </td></tr>
596 <tr><td><code>PL_TERM</code> </td><td>A compound term </td></tr>
597 <tr><td><code>PL_LIST_PAIR</code> </td><td>A list cell (<code>[H|T]</code>) </td></tr>
598 <tr><td><code>PL_DICT</code> </td><td>A dict (see <a class="sec" href="dicts.html#sec:5.4">section
559599 5.4</a>)) </td></tr>
560600 </table>
561601 </dd>
571611 functions below. All these functions return either <code>TRUE</code> or <code>FALSE</code>.
572612
573613 <dl class="latex">
574 <dt class="pubdef"><a name="PL_is_variable()"><var>int</var> <strong>PL_is_variable</strong>(<var>term_t</var>)</a></dt>
614 <dt class="pubdef"><a id="PL_is_variable()"><var>int</var> <strong>PL_is_variable</strong>(<var>term_t</var>)</a></dt>
575615 <dd class="defbody">
576616 Returns non-zero if <var>term</var> is a variable.</dd>
577 <dt class="pubdef"><a name="PL_is_ground()"><var>int</var> <strong>PL_is_ground</strong>(<var>term_t</var>)</a></dt>
578 <dd class="defbody">
579 Returns non-zero if <var>term</var> is a ground term. See also <a name="idx:ground1:2017"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>.
617 <dt class="pubdef"><a id="PL_is_ground()"><var>int</var> <strong>PL_is_ground</strong>(<var>term_t</var>)</a></dt>
618 <dd class="defbody">
619 Returns non-zero if <var>term</var> is a ground term. See also <a id="idx:ground1:2021"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>.
580620 This function is cycle-safe.</dd>
581 <dt class="pubdef"><a name="PL_is_atom()"><var>int</var> <strong>PL_is_atom</strong>(<var>term_t</var>)</a></dt>
621 <dt class="pubdef"><a id="PL_is_atom()"><var>int</var> <strong>PL_is_atom</strong>(<var>term_t</var>)</a></dt>
582622 <dd class="defbody">
583623 Returns non-zero if <var>term</var> is an atom.</dd>
584 <dt class="pubdef"><a name="PL_is_string()"><var>int</var> <strong>PL_is_string</strong>(<var>term_t</var>)</a></dt>
624 <dt class="pubdef"><a id="PL_is_string()"><var>int</var> <strong>PL_is_string</strong>(<var>term_t</var>)</a></dt>
585625 <dd class="defbody">
586626 Returns non-zero if <var>term</var> is a string.</dd>
587 <dt class="pubdef"><a name="PL_is_integer()"><var>int</var> <strong>PL_is_integer</strong>(<var>term_t</var>)</a></dt>
627 <dt class="pubdef"><a id="PL_is_integer()"><var>int</var> <strong>PL_is_integer</strong>(<var>term_t</var>)</a></dt>
588628 <dd class="defbody">
589629 Returns non-zero if <var>term</var> is an integer.</dd>
590 <dt class="pubdef"><a name="PL_is_float()"><var>int</var> <strong>PL_is_float</strong>(<var>term_t</var>)</a></dt>
630 <dt class="pubdef"><a id="PL_is_float()"><var>int</var> <strong>PL_is_float</strong>(<var>term_t</var>)</a></dt>
591631 <dd class="defbody">
592632 Returns non-zero if <var>term</var> is a float.</dd>
593 <dt class="pubdef"><a name="PL_is_callable()"><var>int</var> <strong>PL_is_callable</strong>(<var>term_t</var>)</a></dt>
594 <dd class="defbody">
595 Returns non-zero if <var>term</var> is a callable term. See <a name="idx:callable1:2018"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>
633 <dt class="pubdef"><a id="PL_is_callable()"><var>int</var> <strong>PL_is_callable</strong>(<var>term_t</var>)</a></dt>
634 <dd class="defbody">
635 Returns non-zero if <var>term</var> is a callable term. See <a id="idx:callable1:2022"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>
596636 for details.</dd>
597 <dt class="pubdef"><a name="PL_is_compound()"><var>int</var> <strong>PL_is_compound</strong>(<var>term_t</var>)</a></dt>
637 <dt class="pubdef"><a id="PL_is_compound()"><var>int</var> <strong>PL_is_compound</strong>(<var>term_t</var>)</a></dt>
598638 <dd class="defbody">
599639 Returns non-zero if <var>term</var> is a compound term.</dd>
600 <dt class="pubdef"><a name="PL_is_functor()"><var>int</var> <strong>PL_is_functor</strong>(<var>term_t,
640 <dt class="pubdef"><a id="PL_is_functor()"><var>int</var> <strong>PL_is_functor</strong>(<var>term_t,
601641 functor_t</var>)</a></dt>
602642 <dd class="defbody">
603643 Returns non-zero if <var>term</var> is compound and its functor is <var>functor</var>.
604644 This test is equivalent to <a class="func" href="foreigninclude.html#PL_get_functor()">PL_get_functor()</a>,
605645 followed by testing the functor, but easier to write and faster.</dd>
606 <dt class="pubdef"><a name="PL_is_list()"><var>int</var> <strong>PL_is_list</strong>(<var>term_t</var>)</a></dt>
646 <dt class="pubdef"><a id="PL_is_list()"><var>int</var> <strong>PL_is_list</strong>(<var>term_t</var>)</a></dt>
607647 <dd class="defbody">
608648 Returns non-zero if <var>term</var> is a compound term using the list
609649 constructor or the list terminator. See also <a class="func" href="foreigninclude.html#PL_is_pair()">PL_is_pair()</a>
610650 and
611651 <a class="func" href="foreigninclude.html#PL_skip_list()">PL_skip_list()</a>.</dd>
612 <dt class="pubdef"><a name="PL_is_pair()"><var>int</var> <strong>PL_is_pair</strong>(<var>term_t</var>)</a></dt>
652 <dt class="pubdef"><a id="PL_is_pair()"><var>int</var> <strong>PL_is_pair</strong>(<var>term_t</var>)</a></dt>
613653 <dd class="defbody">
614654 Returns non-zero if <var>term</var> is a compound term using the list
615655 constructor. See also <a class="func" href="foreigninclude.html#PL_is_list()">PL_is_list()</a>
616656 and <a class="func" href="foreigninclude.html#PL_skip_list()">PL_skip_list()</a>.</dd>
617 <dt class="pubdef"><a name="PL_is_atomic()"><var>int</var> <strong>PL_is_atomic</strong>(<var>term_t</var>)</a></dt>
657 <dt class="pubdef"><a id="PL_is_atomic()"><var>int</var> <strong>PL_is_atomic</strong>(<var>term_t</var>)</a></dt>
618658 <dd class="defbody">
619659 Returns non-zero if <var>term</var> is atomic (not variable or
620660 compound).</dd>
621 <dt class="pubdef"><a name="PL_is_number()"><var>int</var> <strong>PL_is_number</strong>(<var>term_t</var>)</a></dt>
661 <dt class="pubdef"><a id="PL_is_number()"><var>int</var> <strong>PL_is_number</strong>(<var>term_t</var>)</a></dt>
622662 <dd class="defbody">
623663 Returns non-zero if <var>term</var> is an integer or float.</dd>
624 <dt class="pubdef"><a name="PL_is_acyclic()"><var>int</var> <strong>PL_is_acyclic</strong>(<var>term_t</var>)</a></dt>
664 <dt class="pubdef"><a id="PL_is_acyclic()"><var>int</var> <strong>PL_is_acyclic</strong>(<var>term_t</var>)</a></dt>
625665 <dd class="defbody">
626666 Returns non-zero if <var>term</var> is acyclic (i.e. a finite tree).
627667 </dd>
628668 </dl>
629669
630 <p><h4 id="sec:foreign-extract-from-term"><a name="sec:11.4.3.2"><span class="sec-nr">11.4.3.2</span> <span class="sec-title">Reading
670 <p><h4 id="sec:foreign-extract-from-term"><a id="sec:11.4.3.2"><span class="sec-nr">11.4.3.2</span> <span class="sec-title">Reading
631671 data from a term</span></a></h4>
632672
633 <a name="sec:foreign-extract-from-term"></a>
673 <a id="sec:foreign-extract-from-term"></a>
634674
635675 <p>The functions <code>PL_get_*()</code> read information from a Prolog
636676 term. Most of them take two arguments. The first is the input term and
637677 the second is a pointer to the output value or a term reference.
638678
639679 <dl class="latex">
640 <dt class="pubdef"><a name="PL_get_atom()"><var>int</var> <strong>PL_get_atom</strong>(<var>term_t
680 <dt class="pubdef"><a id="PL_get_atom()"><var>int</var> <strong>PL_get_atom</strong>(<var>term_t
641681 +t, atom_t *a</var>)</a></dt>
642682 <dd class="defbody">
643683 If <var>t</var> is an atom, store the unique atom identifier over <var>a</var>.
647687 advised to manipulate atoms using their handle. As the atom is
648688 referenced by <var>t</var>, it will live at least as long as <var>t</var>
649689 does. If longer live-time is required, the atom should be locked using <a class="func" href="foreigninclude.html#PL_register_atom()">PL_register_atom()</a>.</dd>
650 <dt class="pubdef"><a name="PL_get_atom_chars()"><var>int</var> <strong>PL_get_atom_chars</strong>(<var>term_t
690 <dt class="pubdef"><a id="PL_get_atom_chars()"><var>int</var> <strong>PL_get_atom_chars</strong>(<var>term_t
651691 +t, char **s</var>)</a></dt>
652692 <dd class="defbody">
653693 If <var>t</var> is an atom, store a pointer to a 0-terminated C-string
656696 the contents of this string. Some built-in atoms may have the string
657697 allocated in read-only memory, so `temporary manipulation' can cause an
658698 error.</dd>
659 <dt class="pubdef"><a name="PL_get_string_chars()"><var>int</var> <strong>PL_get_string_chars</strong>(<var>term_t
699 <dt class="pubdef"><a id="PL_get_string_chars()"><var>int</var> <strong>PL_get_string_chars</strong>(<var>term_t
660700 +t, char **s, size_t *len</var>)</a></dt>
661701 <dd class="defbody">
662702 If <var>t</var> is a string object, store a pointer to a 0-terminated
664704 Note that this pointer is invalidated by backtracking, garbage
665705 collection and stack-shifts, so generally the only save operations are
666706 to pass it immediately to a C function that doesn't involve Prolog.</dd>
667 <dt class="pubdef"><a name="PL_get_chars()"><var>int</var> <strong>PL_get_chars</strong>(<var>term_t
707 <dt class="pubdef"><a id="PL_get_chars()"><var>int</var> <strong>PL_get_chars</strong>(<var>term_t
668708 +t, char **s, unsigned flags</var>)</a></dt>
669709 <dd class="defbody">
670710 Convert the argument term <var>t</var> to a 0-terminated C-string. <em>flags</em>
678718 using <a class="func" href="foreignnotes.html#PL_free()">PL_free()</a>
679719 when no longer needed.
680720
681 <p>With the introduction of wide characters (see <a class="sec" href="widechars.html">section
721 <p>With the introduction of wide characters (see <a class="sec" href="widechars.html#sec:2.19.1">section
682722 2.19.1</a>), not all atoms can be converted into a <code>char*</code>.
683723 This function fails if <var>t</var> is of the wrong type, but also if
684724 the text cannot be represented. See the <code>REP_*</code> flags below
700740 <dt><strong>CVT_FLOAT</strong></dt>
701741 <dd class="defbody">
702742 Convert if term is a float. The characters returned are the same as
703 <a name="idx:write1:2019"></a><a class="pred" href="termrw.html#write/1">write/1</a>
743 <a id="idx:write1:2023"></a><a class="pred" href="termrw.html#write/1">write/1</a>
704744 would write for the floating point number.</dd>
705745 <dt><strong>CVT_NUMBER</strong></dt>
706746 <dd class="defbody">
714754 <dt><strong>CVT_WRITE</strong></dt>
715755 <dd class="defbody">
716756 Convert any term that is not converted by any of the other flags using
717 <a name="idx:write1:2020"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
757 <a id="idx:write1:2024"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
718758 If no <code>BUF_*</code> is provided, <code>BUF_RING</code> is implied.</dd>
719759 <dt><strong>CVT_WRITE_CANONICAL</strong></dt>
720760 <dd class="defbody">
721 As <code>CVT_WRITE</code>, but using <a name="idx:writecanonical2:2021"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.</dd>
761 As <code>CVT_WRITE</code>, but using <a id="idx:writecanonical2:2025"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.</dd>
722762 <dt><strong>CVT_WRITEQ</strong></dt>
723763 <dd class="defbody">
724 As <code>CVT_WRITE</code>, but using <a name="idx:writeq2:2022"></a><a class="pred" href="termrw.html#writeq/2">writeq/2</a>.</dd>
764 As <code>CVT_WRITE</code>, but using <a id="idx:writeq2:2026"></a><a class="pred" href="termrw.html#writeq/2">writeq/2</a>.</dd>
725765 <dt><strong>CVT_ALL</strong></dt>
726766 <dd class="defbody">
727767 Convert if term is any of the above, except for <code>CVT_VARIABLE</code>
757797 </dl>
758798
759799 </dd>
760 <dt class="pubdef"><a name="PL_get_list_chars()"><var>int</var> <strong>PL_get_list_chars</strong>(<var>+term_t
800 <dt class="pubdef"><a id="PL_get_list_chars()"><var>int</var> <strong>PL_get_list_chars</strong>(<var>+term_t
761801 l, char **s, unsigned flags</var>)</a></dt>
762802 <dd class="defbody">
763803 Same as <code><a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars(<var>l</var>, <var>s</var>,
764804 CVT_LIST|<var>flags</var>)</a></code>, provided <var>flags</var>
765805 contains none of the <code>CVT_*</code> flags.
766806 </dd>
767 <dt class="pubdef"><a name="PL_get_integer()"><var>int</var> <strong>PL_get_integer</strong>(<var>+term_t
807 <dt class="pubdef"><a id="PL_get_integer()"><var>int</var> <strong>PL_get_integer</strong>(<var>+term_t
768808 t, int *i</var>)</a></dt>
769809 <dd class="defbody">
770810 If <var>t</var> is a Prolog integer, assign its value over <var>i</var>.
771811 On 32-bit machines, this is the same as <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>,
772812 but avoids a warning from the compiler. See also <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>.</dd>
773 <dt class="pubdef"><a name="PL_get_long()"><var>int</var> <strong>PL_get_long</strong>(<var>term_t
813 <dt class="pubdef"><a id="PL_get_long()"><var>int</var> <strong>PL_get_long</strong>(<var>term_t
774814 +t, long *i</var>)</a></dt>
775815 <dd class="defbody">
776816 If <var>t</var> is a Prolog integer that can be represented as a long,
778818 cannot be represented by a C long, this function returns <code>FALSE</code>.
779819 If <var>t</var> is a floating point number that can be represented as a
780820 long, this function succeeds as well. See also <a class="func" href="foreigninclude.html#PL_get_int64()">PL_get_int64()</a>.</dd>
781 <dt class="pubdef"><a name="PL_get_int64()"><var>int</var> <strong>PL_get_int64</strong>(<var>term_t
821 <dt class="pubdef"><a id="PL_get_int64()"><var>int</var> <strong>PL_get_int64</strong>(<var>term_t
782822 +t, int64_t *i</var>)</a></dt>
783823 <dd class="defbody">
784824 If <var>t</var> is a Prolog integer or float that can be represented as
785825 a
786826 <code>int64_t</code>, assign its value over <var>i</var>.</dd>
787 <dt class="pubdef"><a name="PL_get_intptr()"><var>int</var> <strong>PL_get_intptr</strong>(<var>term_t
827 <dt class="pubdef"><a id="PL_get_intptr()"><var>int</var> <strong>PL_get_intptr</strong>(<var>term_t
788828 +t, intptr_t *i</var>)</a></dt>
789829 <dd class="defbody">
790830 Get an integer that is at least as wide as a pointer. On most platforms
791831 this is the same as <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>,
792832 but on Win64 pointers are 8 bytes and longs only 4. Unlike <a class="func" href="foreigninclude.html#PL_get_pointer()">PL_get_pointer()</a>,
793833 the value is not modified.</dd>
794 <dt class="pubdef"><a name="PL_get_bool()"><var>int</var> <strong>PL_get_bool</strong>(<var>term_t
834 <dt class="pubdef"><a id="PL_get_bool()"><var>int</var> <strong>PL_get_bool</strong>(<var>term_t
795835 +t, int *val</var>)</a></dt>
796836 <dd class="defbody">
797837 If <var>t</var> has the value <code>true</code> or <code>false</code>,
798838 set <var>val</var> to the C constant <code>TRUE</code> or <code>FALSE</code>
799839 and return success, otherwise return failure.
800840 </dd>
801 <dt class="pubdef"><a name="PL_get_pointer()"><var>int</var> <strong>PL_get_pointer</strong>(<var>term_t
841 <dt class="pubdef"><a id="PL_get_pointer()"><var>int</var> <strong>PL_get_pointer</strong>(<var>term_t
802842 +t, void **ptr</var>)</a></dt>
803843 <dd class="defbody">
804844 In the current system, pointers are represented by Prolog integers, but
808848 guarantee pointers in the range of malloc() are handled without
809849 truncating.
810850 </dd>
811 <dt class="pubdef"><a name="PL_get_float()"><var>int</var> <strong>PL_get_float</strong>(<var>term_t
851 <dt class="pubdef"><a id="PL_get_float()"><var>int</var> <strong>PL_get_float</strong>(<var>term_t
812852 +t, double *f</var>)</a></dt>
813853 <dd class="defbody">
814854 If <var>t</var> is a float or integer, its value is assigned over <var>f</var>.
815855 </dd>
816 <dt class="pubdef"><a name="PL_get_functor()"><var>int</var> <strong>PL_get_functor</strong>(<var>term_t
856 <dt class="pubdef"><a id="PL_get_functor()"><var>int</var> <strong>PL_get_functor</strong>(<var>term_t
817857 +t, functor_t *f</var>)</a></dt>
818858 <dd class="defbody">
819859 If <var>t</var> is compound or an atom, the Prolog representation of the
820860 name-arity pair will be assigned over <var>f</var>. See also
821861 <a class="func" href="foreigninclude.html#PL_get_name_arity()">PL_get_name_arity()</a>
822862 and <a class="func" href="foreigninclude.html#PL_is_functor()">PL_is_functor()</a>.</dd>
823 <dt class="pubdef"><a name="PL_get_name_arity()"><var>int</var> <strong>PL_get_name_arity</strong>(<var>term_t
863 <dt class="pubdef"><a id="PL_get_name_arity()"><var>int</var> <strong>PL_get_name_arity</strong>(<var>term_t
824864 +t, atom_t *name, size_t *arity</var>)</a></dt>
825865 <dd class="defbody">
826866 If <var>t</var> is compound or an atom, the functor name will be
828868 also
829869 <a class="func" href="foreigninclude.html#PL_get_functor()">PL_get_functor()</a>
830870 and <a class="func" href="foreigninclude.html#PL_is_functor()">PL_is_functor()</a>.
831 See <a class="sec" href="foreigntypes.html">section 11.3.2.1</a>.</dd>
832 <dt class="pubdef"><a name="PL_get_compound_name_arity()"><var>int</var> <strong>PL_get_compound_name_arity</strong>(<var>term_t
871 See <a class="sec" href="foreigntypes.html#sec:11.3.2.1">section
872 11.3.2.1</a>.</dd>
873 <dt class="pubdef"><a id="PL_get_compound_name_arity()"><var>int</var> <strong>PL_get_compound_name_arity</strong>(<var>term_t
833874 +t, atom_t *name, size_t *arity</var>)</a></dt>
834875 <dd class="defbody">
835876 If <var>t</var> is compound term, the functor name will be assigned over
836877 <var>name</var> and the arity over <var>arity</var>. This is the same as
837878 <a class="func" href="foreigninclude.html#PL_get_name_arity()">PL_get_name_arity()</a>,
838879 but this function fails if <var>t</var> is an atom.</dd>
839 <dt class="pubdef"><a name="PL_get_module()"><var>int</var> <strong>PL_get_module</strong>(<var>term_t
880 <dt class="pubdef"><a id="PL_get_module()"><var>int</var> <strong>PL_get_module</strong>(<var>term_t
840881 +t, module_t *module</var>)</a></dt>
841882 <dd class="defbody">
842883 If <var>t</var> is an atom, the system will look up or create the
843884 corresponding module and assign an opaque pointer to it over <em>module</em>.
844885 </dd>
845 <dt class="pubdef"><a name="PL_get_arg()"><var>int</var> <strong>PL_get_arg</strong>(<var>size_t
886 <dt class="pubdef"><a id="PL_get_arg()"><var>int</var> <strong>PL_get_arg</strong>(<var>size_t
846887 index, term_t +t, term_t -a</var>)</a></dt>
847888 <dd class="defbody">
848889 If <var>t</var> is compound and index is between 1 and arity
849890 (inclusive), assign <var>a</var> with a term reference to the argument.
850891 </dd>
851 <dt class="pubdef"><a name="_PL_get_arg()"><var>int</var> <strong>_PL_get_arg</strong>(<var>size_t
892 <dt class="pubdef"><a id="_PL_get_arg()"><var>int</var> <strong>_PL_get_arg</strong>(<var>size_t
852893 index, term_t +t, term_t -a</var>)</a></dt>
853894 <dd class="defbody">
854895 Same as <a class="func" href="foreigninclude.html#PL_get_arg()">PL_get_arg()</a>,
857898 </dd>
858899 </dl>
859900
860 <p><h4 id="sec:foreign-text-with-length"><a name="sec:11.4.3.3"><span class="sec-nr">11.4.3.3</span> <span class="sec-title">Exchanging
901 <p><h4 id="sec:foreign-text-with-length"><a id="sec:11.4.3.3"><span class="sec-nr">11.4.3.3</span> <span class="sec-title">Exchanging
861902 text using length and string</span></a></h4>
862903
863 <a name="sec:foreign-text-with-length"></a>
904 <a id="sec:foreign-text-with-length"></a>
864905
865906 <p>All internal text representation in SWI-Prolog is represented using
866907 <code>char *</code> plus length and allow for <em>0-bytes</em> in them.
870911 *_chars() function.
871912
872913 <dl class="latex">
873 <dt class="pubdef"><a name="PL_get_atom_nchars()"><var>int</var> <strong>PL_get_atom_nchars</strong>(<var>term_t
914 <dt class="pubdef"><a id="PL_get_atom_nchars()"><var>int</var> <strong>PL_get_atom_nchars</strong>(<var>term_t
874915 t, size_t *len, char **s</var>)</a></dt>
875916 <dd class="defbody">
876917 See <a class="func" href="foreigninclude.html#PL_get_atom_chars()">PL_get_atom_chars()</a>.
877918 </dd>
878 <dt class="pubdef"><a name="PL_get_list_nchars()"><var>int</var> <strong>PL_get_list_nchars</strong>(<var>term_t
919 <dt class="pubdef"><a id="PL_get_list_nchars()"><var>int</var> <strong>PL_get_list_nchars</strong>(<var>term_t
879920 t, size_t *len, char **s</var>)</a></dt>
880921 <dd class="defbody">
881922 See <a class="func" href="foreigninclude.html#PL_get_list_chars()">PL_get_list_chars()</a>.
882923 </dd>
883 <dt class="pubdef"><a name="PL_get_nchars()"><var>int</var> <strong>PL_get_nchars</strong>(<var>term_t
924 <dt class="pubdef"><a id="PL_get_nchars()"><var>int</var> <strong>PL_get_nchars</strong>(<var>term_t
884925 t, size_t *len, char **s, unsigned int flags</var>)</a></dt>
885926 <dd class="defbody">
886927 See <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>.
887928 </dd>
888 <dt class="pubdef"><a name="PL_put_atom_nchars()"><var>int</var> <strong>PL_put_atom_nchars</strong>(<var>term_t
929 <dt class="pubdef"><a id="PL_put_atom_nchars()"><var>int</var> <strong>PL_put_atom_nchars</strong>(<var>term_t
889930 t, size_t len, const char *s</var>)</a></dt>
890931 <dd class="defbody">
891932 See <a class="func" href="foreigninclude.html#PL_put_atom_chars()">PL_put_atom_chars()</a>.
892933 </dd>
893 <dt class="pubdef"><a name="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
934 <dt class="pubdef"><a id="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
894935 t, size_t len, const char *s</var>)</a></dt>
895936 <dd class="defbody">
896937 See <a class="func" href="foreigninclude.html#PL_put_string_chars()">PL_put_string_chars()</a>.
897938 </dd>
898 <dt class="pubdef"><a name="PL_put_list_ncodes()"><var>int</var> <strong>PL_put_list_ncodes</strong>(<var>term_t
939 <dt class="pubdef"><a id="PL_put_list_ncodes()"><var>int</var> <strong>PL_put_list_ncodes</strong>(<var>term_t
899940 t, size_t len, const char *s</var>)</a></dt>
900941 <dd class="defbody">
901942 See <b>PL_put_list_codes()</b>.
902943 </dd>
903 <dt class="pubdef"><a name="PL_put_list_nchars()"><var>int</var> <strong>PL_put_list_nchars</strong>(<var>term_t
944 <dt class="pubdef"><a id="PL_put_list_nchars()"><var>int</var> <strong>PL_put_list_nchars</strong>(<var>term_t
904945 t, size_t len, const char *s</var>)</a></dt>
905946 <dd class="defbody">
906947 See <a class="func" href="foreigninclude.html#PL_put_list_chars()">PL_put_list_chars()</a>.
907948 </dd>
908 <dt class="pubdef"><a name="PL_unify_atom_nchars()"><var>int</var> <strong>PL_unify_atom_nchars</strong>(<var>term_t
949 <dt class="pubdef"><a id="PL_unify_atom_nchars()"><var>int</var> <strong>PL_unify_atom_nchars</strong>(<var>term_t
909950 t, size_t len, const char *s</var>)</a></dt>
910951 <dd class="defbody">
911952 See <a class="func" href="foreigninclude.html#PL_unify_atom_chars()">PL_unify_atom_chars()</a>.
912953 </dd>
913 <dt class="pubdef"><a name="PL_unify_string_nchars()"><var>int</var> <strong>PL_unify_string_nchars</strong>(<var>term_t
954 <dt class="pubdef"><a id="PL_unify_string_nchars()"><var>int</var> <strong>PL_unify_string_nchars</strong>(<var>term_t
914955 t, size_t len, const char *s</var>)</a></dt>
915956 <dd class="defbody">
916957 See <a class="func" href="foreigninclude.html#PL_unify_string_chars()">PL_unify_string_chars()</a>.
917958 </dd>
918 <dt class="pubdef"><a name="PL_unify_list_ncodes()"><var>int</var> <strong>PL_unify_list_ncodes</strong>(<var>term_t
959 <dt class="pubdef"><a id="PL_unify_list_ncodes()"><var>int</var> <strong>PL_unify_list_ncodes</strong>(<var>term_t
919960 t, size_t len, const char *s</var>)</a></dt>
920961 <dd class="defbody">
921962 See <b>PL_unify_codes()</b>.
922963 </dd>
923 <dt class="pubdef"><a name="PL_unify_list_nchars()"><var>int</var> <strong>PL_unify_list_nchars</strong>(<var>term_t
964 <dt class="pubdef"><a id="PL_unify_list_nchars()"><var>int</var> <strong>PL_unify_list_nchars</strong>(<var>term_t
924965 t, size_t len, const char *s</var>)</a></dt>
925966 <dd class="defbody">
926967 See <a class="func" href="foreigninclude.html#PL_unify_list_chars()">PL_unify_list_chars()</a>.
931972 inspecting atoms:
932973
933974 <dl class="latex">
934 <dt class="pubdef"><a name="PL_new_atom_nchars()"><var>atom_t</var> <strong>PL_new_atom_nchars</strong>(<var>size_t
975 <dt class="pubdef"><a id="PL_new_atom_nchars()"><var>atom_t</var> <strong>PL_new_atom_nchars</strong>(<var>size_t
935976 len, const char *s</var>)</a></dt>
936977 <dd class="defbody">
937978 Create a new atom as <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>,
938979 but using the given length and characters. If <var>len</var> is <code>(size_t)-1</code>,
939980 it is computed from <var>s</var> using strlen().</dd>
940 <dt class="pubdef"><a name="PL_atom_nchars()"><var>const char *</var> <strong>PL_atom_nchars</strong>(<var>atom_t
981 <dt class="pubdef"><a id="PL_atom_nchars()"><var>const char *</var> <strong>PL_atom_nchars</strong>(<var>atom_t
941982 a, size_t *len</var>)</a></dt>
942983 <dd class="defbody">
943984 Extract the text and length of an atom.
944985 </dd>
945986 </dl>
946987
947 <p><h4 id="sec:foreign-unicode"><a name="sec:11.4.3.4"><span class="sec-nr">11.4.3.4</span> <span class="sec-title">Wide-character
988 <p><h4 id="sec:foreign-unicode"><a id="sec:11.4.3.4"><span class="sec-nr">11.4.3.4</span> <span class="sec-title">Wide-character
948989 versions</span></a></h4>
949990
950 <a name="sec:foreign-unicode"></a>
991 <a id="sec:foreign-unicode"></a>
951992
952993 <p>Support for exchange of wide-character strings is still under
953994 consideration. The functions dealing with 8-bit character strings return
9601001 using the GNU C library (glibc) this represents 32-bit UCS4 characters.
9611002
9621003 <dl class="latex">
963 <dt class="pubdef"><a name="PL_new_atom_wchars()"><var>atom_t</var> <strong>PL_new_atom_wchars</strong>(<var>size_t
1004 <dt class="pubdef"><a id="PL_new_atom_wchars()"><var>atom_t</var> <strong>PL_new_atom_wchars</strong>(<var>size_t
9641005 len, const pl_wchar_t *s</var>)</a></dt>
9651006 <dd class="defbody">
9661007 Create atom from wide-character string as <a class="func" href="foreigninclude.html#PL_new_atom_nchars()">PL_new_atom_nchars()</a>
9671008 does for ISO-Latin-1 strings. If <var>s</var> only contains ISO-Latin-1
9681009 characters a normal byte-array atom is created. If <var>len</var> is <code>(size_t)-1</code>,
9691010 it is computed from <var>s</var> using wcslen().</dd>
970 <dt class="pubdef"><a name="PL_atom_wchars()"><var>pl_wchar_t*</var> <strong>PL_atom_wchars</strong>(<var>atom_t
1011 <dt class="pubdef"><a id="PL_atom_wchars()"><var>pl_wchar_t*</var> <strong>PL_atom_wchars</strong>(<var>atom_t
9711012 atom, int *len</var>)</a></dt>
9721013 <dd class="defbody">
9731014 Extract characters from a wide-character atom. Succeeds on any atom
9751016 returned pointer is a pointer into the atom structure. If it is an
9761017 ISO-Latin-1 character, the returned pointer comes from Prolog's `buffer
9771018 ring' (see <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>).</dd>
978 <dt class="pubdef"><a name="PL_get_wchars()"><var>int</var> <strong>PL_get_wchars</strong>(<var>term_t
1019 <dt class="pubdef"><a id="PL_get_wchars()"><var>int</var> <strong>PL_get_wchars</strong>(<var>term_t
9791020 t, size_t *len, pl_wchar_t **s, unsigned flags</var>)</a></dt>
9801021 <dd class="defbody">
9811022 Wide-character version of <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>.
9821023 The <var>flags</var> argument is the same as for <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>.</dd>
983 <dt class="pubdef"><a name="PL_unify_wchars()"><var>int</var> <strong>PL_unify_wchars</strong>(<var>term_t
1024 <dt class="pubdef"><a id="PL_unify_wchars()"><var>int</var> <strong>PL_unify_wchars</strong>(<var>term_t
9841025 t, int type, size_t len, const pl_wchar_t *s</var>)</a></dt>
9851026 <dd class="defbody">
9861027 Unify <var>t</var> with a textual representation of the C wide-character
9881029 representation and is one of <code>PL_ATOM</code>, <code>PL_STRING</code>,
9891030 <code>PL_CODE_LIST</code> or <code>PL_CHAR_LIST</code>.
9901031 </dd>
991 <dt class="pubdef"><a name="PL_unify_wchars_diff()"><var>int</var> <strong>PL_unify_wchars_diff</strong>(<var>term_t
1032 <dt class="pubdef"><a id="PL_unify_wchars_diff()"><var>int</var> <strong>PL_unify_wchars_diff</strong>(<var>term_t
9921033 +t, term_t -tail, int type, size_t len, const pl_wchar_t *s</var>)</a></dt>
9931034 <dd class="defbody">
9941035 Difference list version of <a class="func" href="foreigninclude.html#PL_unify_wchars()">PL_unify_wchars()</a>,
10011042 </dd>
10021043 </dl>
10031044
1004 <p><h4 id="sec:foreign-read-list"><a name="sec:11.4.3.5"><span class="sec-nr">11.4.3.5</span> <span class="sec-title">Reading
1045 <p><h4 id="sec:foreign-read-list"><a id="sec:11.4.3.5"><span class="sec-nr">11.4.3.5</span> <span class="sec-title">Reading
10051046 a list</span></a></h4>
10061047
1007 <a name="sec:foreign-read-list"></a>
1048 <a id="sec:foreign-read-list"></a>
10081049
10091050 <p>The functions from this section are intended to read a Prolog list
10101051 from C. Suppose we expect a list of atoms; the following code will print
10301071 </pre>
10311072
10321073 <p>Note that as of version&nbsp;7, lists have a new representation
1033 unless the option <strong>--traditional</strong> is used. see <a class="sec" href="ext-lists.html">section
1074 unless the option <strong>--traditional</strong> is used. see <a class="sec" href="ext-lists.html#sec:5.1">section
10341075 5.1</a>.
10351076
10361077 <dl class="latex">
1037 <dt class="pubdef"><a name="PL_get_list()"><var>int</var> <strong>PL_get_list</strong>(<var>term_t
1078 <dt class="pubdef"><a id="PL_get_list()"><var>int</var> <strong>PL_get_list</strong>(<var>term_t
10381079 +l, term_t -h, term_t -t</var>)</a></dt>
10391080 <dd class="defbody">
10401081 If <var>l</var> is a list and not the empty list, assign a term
10411082 reference to the head to <var>h</var> and to the tail to <var>t</var>.</dd>
1042 <dt class="pubdef"><a name="PL_get_head()"><var>int</var> <strong>PL_get_head</strong>(<var>term_t
1083 <dt class="pubdef"><a id="PL_get_head()"><var>int</var> <strong>PL_get_head</strong>(<var>term_t
10431084 +l, term_t -h</var>)</a></dt>
10441085 <dd class="defbody">
10451086 If <var>l</var> is a list and not the empty list, assign a term
10461087 reference to the head to <var>h</var>.</dd>
1047 <dt class="pubdef"><a name="PL_get_tail()"><var>int</var> <strong>PL_get_tail</strong>(<var>term_t
1088 <dt class="pubdef"><a id="PL_get_tail()"><var>int</var> <strong>PL_get_tail</strong>(<var>term_t
10481089 +l, term_t -t</var>)</a></dt>
10491090 <dd class="defbody">
10501091 If <var>l</var> is a list and not the empty list, assign a term
10511092 reference to the tail to <var>t</var>.</dd>
1052 <dt class="pubdef"><a name="PL_get_nil()"><var>int</var> <strong>PL_get_nil</strong>(<var>term_t
1093 <dt class="pubdef"><a id="PL_get_nil()"><var>int</var> <strong>PL_get_nil</strong>(<var>term_t
10531094 +l</var>)</a></dt>
10541095 <dd class="defbody">
10551096 Succeeds if <var>l</var> represents the list termination constant.</dd>
1056 <dt class="pubdef"><a name="PL_skip_list()"><var>int</var> <strong>PL_skip_list</strong>(<var>term_t
1097 <dt class="pubdef"><a id="PL_skip_list()"><var>int</var> <strong>PL_skip_list</strong>(<var>term_t
10571098 +list, term_t -tail, size_t *len</var>)</a></dt>
10581099 <dd class="defbody">
10591100 This is a multi-purpose function to deal with lists. It allows for
10631104 return value indicates the status of the list:
10641105
10651106 <dl class="latex">
1066 <dt><a name="PL_LIST"><strong>PL_LIST</strong></a></dt>
1107 <dt><a id="PL_LIST"><strong>PL_LIST</strong></a></dt>
10671108 <dd class="defbody">
10681109 The list is a `proper' list: one that ends in the list terminator
10691110 constant and <var>tail</var> is filled with the terminator constant.</dd>
1070 <dt><a name="PL_PARTIAL_LIST"><strong>PL_PARTIAL_LIST</strong></a></dt>
1111 <dt><a id="PL_PARTIAL_LIST"><strong>PL_PARTIAL_LIST</strong></a></dt>
10711112 <dd class="defbody">
10721113 The list is a `partial' list: one that ends in a variable and
10731114 <var>tail</var> is a reference to this variable.</dd>
1074 <dt><a name="PL_CYCLIC_TERM"><strong>PL_CYCLIC_TERM</strong></a></dt>
1115 <dt><a id="PL_CYCLIC_TERM"><strong>PL_CYCLIC_TERM</strong></a></dt>
10751116 <dd class="defbody">
10761117 The list is cyclic (e.g. X = [a|X]). <var>tail</var> points to an
10771118 arbitrary cell of the list and <var>len</var> is at most twice the cycle
10781119 length of the list.</dd>
1079 <dt><a name="PL_NOT_A_LIST"><strong>PL_NOT_A_LIST</strong></a></dt>
1120 <dt><a id="PL_NOT_A_LIST"><strong>PL_NOT_A_LIST</strong></a></dt>
10801121 <dd class="defbody">
10811122 The term <var>list</var> is not a list at all. <var>tail</var> is bound
10821123 to the non-list term and <var>len</var> is set to the number of
10881129 </dd>
10891130 </dl>
10901131
1091 <p><h4 id="sec:foreign-write"><a name="sec:11.4.3.6"><span class="sec-nr">11.4.3.6</span> <span class="sec-title">An
1132 <p><h4 id="sec:foreign-write"><a id="sec:11.4.3.6"><span class="sec-nr">11.4.3.6</span> <span class="sec-title">An
10921133 example: defining write/1 in C</span></a></h4>
10931134
1094 <a name="sec:foreign-write"></a>
1135 <a id="sec:foreign-write"></a>
10951136
10961137 <p><a class="fig" href="foreigninclude.html#fig:pl-display">Figure 7</a>
1097 shows a simplified definition of <a name="idx:write1:2024"></a><a class="pred" href="termrw.html#write/1">write/1</a>
1138 shows a simplified definition of <a id="idx:write1:2028"></a><a class="pred" href="termrw.html#write/1">write/1</a>
10981139 to illustrate the described functions. This simplified version does not
1099 deal with operators. It is called <a name="idx:display1:2025"></a><span class="pred-ext">display/1</span>,
1140 deal with operators. It is called <a id="idx:display1:2029"></a><span class="pred-ext">display/1</span>,
11001141 because it mimics closely the behaviour of this Edinburgh predicate.
11011142
11021143 <pre class="code">
11401181 }
11411182 </pre>
11421183
1143 <div class="caption"><b>Figure 7 : </b>A Foreign definition of <a name="idx:display1:2026"></a><span class="pred-ext">display/1</span></div>
1144 <a name="fig:pl-display"></a>
1145
1146 <p><h3 id="sec:foreign-term-construct"><a name="sec:11.4.4"><span class="sec-nr">11.4.4</span> <span class="sec-title">Constructing
1184 <div class="caption"><b>Figure 7 : </b>A Foreign definition of <a id="idx:display1:2030"></a><span class="pred-ext">display/1</span></div>
1185 <a id="fig:pl-display"></a>
1186
1187 <p><h3 id="sec:foreign-term-construct"><a id="sec:11.4.4"><span class="sec-nr">11.4.4</span> <span class="sec-title">Constructing
11471188 Terms</span></a></h3>
11481189
1149 <a name="sec:foreign-term-construct"></a>
1190 <a id="sec:foreign-term-construct"></a>
11501191
11511192 <p>Terms can be constructed using functions from the <code>PL_put_*()</code>
11521193 and
11601201 <a class="func" href="foreigninclude.html#PL_open_query()">PL_open_query()</a>.
11611202
11621203 <dl class="latex">
1163 <dt class="pubdef"><a name="PL_put_variable()"><var>void</var> <strong>PL_put_variable</strong>(<var>term_t
1204 <dt class="pubdef"><a id="PL_put_variable()"><var>void</var> <strong>PL_put_variable</strong>(<var>term_t
11641205 -t</var>)</a></dt>
11651206 <dd class="defbody">
11661207 Put a fresh variable in the term, resetting the term reference to its
1167 initial state.<sup class="fn">170<span class="fn-text">Older versions
1208 initial state.<sup class="fn">171<span class="fn-text">Older versions
11681209 created a variable on the global stack.</span></sup>
11691210 </dd>
1170 <dt class="pubdef"><a name="PL_put_atom()"><var>void</var> <strong>PL_put_atom</strong>(<var>term_t
1211 <dt class="pubdef"><a id="PL_put_atom()"><var>void</var> <strong>PL_put_atom</strong>(<var>term_t
11711212 -t, atom_t a</var>)</a></dt>
11721213 <dd class="defbody">
11731214 Put an atom in the term reference from a handle. See also
11741215 <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>
11751216 and <a class="func" href="foreigninclude.html#PL_atom_chars()">PL_atom_chars()</a>.
11761217 </dd>
1177 <dt class="pubdef"><a name="PL_put_bool()"><var>void</var> <strong>PL_put_bool</strong>(<var>term_t
1218 <dt class="pubdef"><a id="PL_put_bool()"><var>void</var> <strong>PL_put_bool</strong>(<var>term_t
11781219 -t, int val</var>)</a></dt>
11791220 <dd class="defbody">
11801221 Put one of the atoms <code>true</code> or <code>false</code> in the term
11811222 reference See also <a class="func" href="foreigninclude.html#PL_put_atom()">PL_put_atom()</a>, <a class="func" href="foreigninclude.html#PL_unify_bool()">PL_unify_bool()</a>
11821223 and <a class="func" href="foreigninclude.html#PL_get_bool()">PL_get_bool()</a>.
11831224 </dd>
1184 <dt class="pubdef"><a name="PL_put_chars()"><var>int</var> <strong>PL_put_chars</strong>(<var>term_t
1225 <dt class="pubdef"><a id="PL_put_chars()"><var>int</var> <strong>PL_put_chars</strong>(<var>term_t
11851226 -t, int flags, size_t len, const char *chars</var>)</a></dt>
11861227 <dd class="defbody">
11871228 New function to deal with setting a term from a <code>char*</code> with
11981239 zero-terminated and the length is computed from <var>chars</var> using
11991240 strlen().
12001241 </dd>
1201 <dt class="pubdef"><a name="PL_put_atom_chars()"><var>int</var> <strong>PL_put_atom_chars</strong>(<var>term_t
1242 <dt class="pubdef"><a id="PL_put_atom_chars()"><var>int</var> <strong>PL_put_atom_chars</strong>(<var>term_t
12021243 -t, const char *chars</var>)</a></dt>
12031244 <dd class="defbody">
12041245 Put an atom in the term reference constructed from the zero-terminated
12051246 string. The string itself will never be referenced by Prolog after this
12061247 function.
12071248 </dd>
1208 <dt class="pubdef"><a name="PL_put_string_chars()"><var>int</var> <strong>PL_put_string_chars</strong>(<var>term_t
1249 <dt class="pubdef"><a id="PL_put_string_chars()"><var>int</var> <strong>PL_put_string_chars</strong>(<var>term_t
12091250 -t, const char *chars</var>)</a></dt>
12101251 <dd class="defbody">
12111252 Put a zero-terminated string in the term reference. The data will be
12121253 copied. See also <a class="func" href="foreigninclude.html#PL_put_string_nchars()">PL_put_string_nchars()</a>.
12131254 </dd>
1214 <dt class="pubdef"><a name="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
1255 <dt class="pubdef"><a id="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
12151256 -t, size_t len, const char *chars</var>)</a></dt>
12161257 <dd class="defbody">
12171258
12181259 <p>Put a string, represented by a length/start pointer pair in the term
12191260 reference. The data will be copied. This interface can deal with 0-bytes
1220 in the string. See also <a class="sec" href="foreigninclude.html">section
1261 in the string. See also <a class="sec" href="foreigninclude.html#sec:11.4.20">section
12211262 11.4.20</a>.
12221263 </dd>
1223 <dt class="pubdef"><a name="PL_put_list_chars()"><var>int</var> <strong>PL_put_list_chars</strong>(<var>term_t
1264 <dt class="pubdef"><a id="PL_put_list_chars()"><var>int</var> <strong>PL_put_list_chars</strong>(<var>term_t
12241265 -t, const char *chars</var>)</a></dt>
12251266 <dd class="defbody">
12261267 Put a list of ASCII values in the term reference.
12271268 </dd>
1228 <dt class="pubdef"><a name="PL_put_integer()"><var>int</var> <strong>PL_put_integer</strong>(<var>term_t
1269 <dt class="pubdef"><a id="PL_put_integer()"><var>int</var> <strong>PL_put_integer</strong>(<var>term_t
12291270 -t, long i</var>)</a></dt>
12301271 <dd class="defbody">
12311272 Put a Prolog integer in the term reference.
12321273 </dd>
1233 <dt class="pubdef"><a name="PL_put_int64()"><var>int</var> <strong>PL_put_int64</strong>(<var>term_t
1274 <dt class="pubdef"><a id="PL_put_int64()"><var>int</var> <strong>PL_put_int64</strong>(<var>term_t
12341275 -t, int64_t i</var>)</a></dt>
12351276 <dd class="defbody">
12361277 Put a Prolog integer in the term reference.
12371278 </dd>
1238 <dt class="pubdef"><a name="PL_put_pointer()"><var>int</var> <strong>PL_put_pointer</strong>(<var>term_t
1279 <dt class="pubdef"><a id="PL_put_pointer()"><var>int</var> <strong>PL_put_pointer</strong>(<var>term_t
12391280 -t, void *ptr</var>)</a></dt>
12401281 <dd class="defbody">
12411282 Put a Prolog integer in the term reference. Provided <var>ptr</var> is
12421283 in the `malloc()-area', <a class="func" href="foreigninclude.html#PL_get_pointer()">PL_get_pointer()</a>
12431284 will get the pointer back.
12441285 </dd>
1245 <dt class="pubdef"><a name="PL_put_float()"><var>int</var> <strong>PL_put_float</strong>(<var>term_t
1286 <dt class="pubdef"><a id="PL_put_float()"><var>int</var> <strong>PL_put_float</strong>(<var>term_t
12461287 -t, double f</var>)</a></dt>
12471288 <dd class="defbody">
12481289 Put a floating-point value in the term reference.</dd>
1249 <dt class="pubdef"><a name="PL_put_functor()"><var>int</var> <strong>PL_put_functor</strong>(<var>term_t
1290 <dt class="pubdef"><a id="PL_put_functor()"><var>int</var> <strong>PL_put_functor</strong>(<var>term_t
12501291 -t, functor_t functor</var>)</a></dt>
12511292 <dd class="defbody">
12521293 Create a new compound term from <var>functor</var> and bind <var>t</var>
12531294 to this term. All arguments of the term will be variables. To create a
12541295 term with instantiated arguments, either instantiate the arguments using
12551296 the <code>PL_unify_*()</code> functions or use <a class="func" href="foreigninclude.html#PL_cons_functor()">PL_cons_functor()</a>.</dd>
1256 <dt class="pubdef"><a name="PL_put_list()"><var>int</var> <strong>PL_put_list</strong>(<var>term_t
1297 <dt class="pubdef"><a id="PL_put_list()"><var>int</var> <strong>PL_put_list</strong>(<var>term_t
12571298 -l</var>)</a></dt>
12581299 <dd class="defbody">
12591300 As <a class="func" href="foreigninclude.html#PL_put_functor()">PL_put_functor()</a>,
12611302 SWI-Prolog using the option
12621303 <strong>--traditional</strong>, this is <code><code>.</code>/2</code>,
12631304 while on SWI-Prolog version&nbsp;7 this is <code><code>[|]</code>/2</code>.</dd>
1264 <dt class="pubdef"><a name="PL_put_nil()"><var>int</var> <strong>PL_put_nil</strong>(<var>term_t
1305 <dt class="pubdef"><a id="PL_put_nil()"><var>int</var> <strong>PL_put_nil</strong>(<var>term_t
12651306 -l</var>)</a></dt>
12661307 <dd class="defbody">
12671308 Put the list terminator constant in <var>l</var>. Always returns
12691310 SWI-Prolog using the option <strong>--traditional</strong>, this is the
12701311 same as
12711312 <code><a class="func" href="foreigninclude.html#PL_put_atom_chars()">PL_put_atom_chars("[]")</a></code>.
1272 See <a class="sec" href="ext-lists.html">section 5.1</a>.</dd>
1273 <dt class="pubdef"><a name="PL_put_term()"><var>void</var> <strong>PL_put_term</strong>(<var>term_t
1313 See <a class="sec" href="ext-lists.html#sec:5.1">section 5.1</a>.</dd>
1314 <dt class="pubdef"><a id="PL_put_term()"><var>void</var> <strong>PL_put_term</strong>(<var>term_t
12741315 -t1, term_t +t2</var>)</a></dt>
12751316 <dd class="defbody">
12761317 Make <var>t1</var> point to the same term as <var>t2</var>.</dd>
1277 <dt class="pubdef"><a name="PL_cons_functor()"><var>int</var> <strong>PL_cons_functor</strong>(<var>term_t
1318 <dt class="pubdef"><a id="PL_cons_functor()"><var>int</var> <strong>PL_cons_functor</strong>(<var>term_t
12781319 -h, functor_t f, ...</var>)</a></dt>
12791320 <dd class="defbody">
12801321 Create a term whose arguments are filled from a variable argument list
13011342 <p>After this sequence, the term references <var>a1</var> and <var>a2</var>
13021343 may be used for other purposes.
13031344 </dd>
1304 <dt class="pubdef"><a name="PL_cons_functor_v()"><var>int</var> <strong>PL_cons_functor_v</strong>(<var>term_t
1345 <dt class="pubdef"><a id="PL_cons_functor_v()"><var>int</var> <strong>PL_cons_functor_v</strong>(<var>term_t
13051346 -h, functor_t f, term_t a0</var>)</a></dt>
13061347 <dd class="defbody">
13071348 Create a compound term like <a class="func" href="foreigninclude.html#PL_cons_functor()">PL_cons_functor()</a>,
13091350 The length of this array should match the number of arguments required
13101351 by the functor.
13111352 </dd>
1312 <dt class="pubdef"><a name="PL_cons_list()"><var>int</var> <strong>PL_cons_list</strong>(<var>term_t
1353 <dt class="pubdef"><a id="PL_cons_list()"><var>int</var> <strong>PL_cons_list</strong>(<var>term_t
13131354 -l, term_t +h, term_t +t</var>)</a></dt>
13141355 <dd class="defbody">
13151356 Create a list (cons-) cell in <var>l</var> from the head <var>h</var>
13361377 </dd>
13371378 </dl>
13381379
1339 <p><h3 id="sec:foreign-unify"><a name="sec:11.4.5"><span class="sec-nr">11.4.5</span> <span class="sec-title">Unifying
1380 <p><h3 id="sec:foreign-unify"><a id="sec:11.4.5"><span class="sec-nr">11.4.5</span> <span class="sec-title">Unifying
13401381 data</span></a></h3>
13411382
1342 <a name="sec:foreign-unify"></a>
1383 <a id="sec:foreign-unify"></a>
13431384
13441385 <p>The functions of this section <em>unify</em> terms with other terms
13451386 or translated C data structures. Except for <a class="func" href="foreigninclude.html#PL_unify()">PL_unify()</a>,
13871428 for details.
13881429
13891430 <dl class="latex">
1390 <dt class="pubdef"><a name="PL_unify()"><var>int</var> <strong>PL_unify</strong>(<var>term_t
1431 <dt class="pubdef"><a id="PL_unify()"><var>int</var> <strong>PL_unify</strong>(<var>term_t
13911432 ?t1, term_t ?t2</var>)</a></dt>
13921433 <dd class="defbody">
13931434 Unify two Prolog terms and return <code>TRUE</code> on success.
14281469 encounter an exception must return <code>FAIL</code> to Prolog as soon
14291470 as possible or call <a class="func" href="foreigninclude.html#PL_clear_exception()">PL_clear_exception()</a>
14301471 if they wish to ignore the exception.</dd>
1431 <dt class="pubdef"><a name="PL_unify_atom()"><var>int</var> <strong>PL_unify_atom</strong>(<var>term_t
1472 <dt class="pubdef"><a id="PL_unify_atom()"><var>int</var> <strong>PL_unify_atom</strong>(<var>term_t
14321473 ?t, atom_t a</var>)</a></dt>
14331474 <dd class="defbody">
14341475 Unify <var>t</var> with the atom <var>a</var> and return non-zero on
14351476 success.</dd>
1436 <dt class="pubdef"><a name="PL_unify_bool()"><var>int</var> <strong>PL_unify_bool</strong>(<var>term_t
1477 <dt class="pubdef"><a id="PL_unify_bool()"><var>int</var> <strong>PL_unify_bool</strong>(<var>term_t
14371478 ?t, int a</var>)</a></dt>
14381479 <dd class="defbody">
14391480 Unify <var>t</var> with either <code>true</code> or <code>false</code>.</dd>
1440 <dt class="pubdef"><a name="PL_unify_chars()"><var>int</var> <strong>PL_unify_chars</strong>(<var>term_t
1481 <dt class="pubdef"><a id="PL_unify_chars()"><var>int</var> <strong>PL_unify_chars</strong>(<var>term_t
14411482 ?t, int flags, size_t len, const char *chars</var>)</a></dt>
14421483 <dd class="defbody">
14431484 New function to deal with unification of <code>char*</code> with various
14611502 converted to a <em>difference list</em>. The tail of the difference list
14621503 is
14631504 <var>t+1</var>.</dd>
1464 <dt class="pubdef"><a name="PL_unify_atom_chars()"><var>int</var> <strong>PL_unify_atom_chars</strong>(<var>term_t
1505 <dt class="pubdef"><a id="PL_unify_atom_chars()"><var>int</var> <strong>PL_unify_atom_chars</strong>(<var>term_t
14651506 ?t, const char *chars</var>)</a></dt>
14661507 <dd class="defbody">
14671508 Unify <var>t</var> with an atom created from <var>chars</var> and return
14681509 non-zero on success.</dd>
1469 <dt class="pubdef"><a name="PL_unify_list_chars()"><var>int</var> <strong>PL_unify_list_chars</strong>(<var>term_t
1510 <dt class="pubdef"><a id="PL_unify_list_chars()"><var>int</var> <strong>PL_unify_list_chars</strong>(<var>term_t
14701511 ?t, const char *chars</var>)</a></dt>
14711512 <dd class="defbody">
14721513 Unify <var>t</var> with a list of ASCII characters constructed from
14731514 <var>chars</var>.</dd>
1474 <dt class="pubdef"><a name="PL_unify_string_chars()"><var>void</var> <strong>PL_unify_string_chars</strong>(<var>term_t
1515 <dt class="pubdef"><a id="PL_unify_string_chars()"><var>void</var> <strong>PL_unify_string_chars</strong>(<var>term_t
14751516 ?t, const char *chars</var>)</a></dt>
14761517 <dd class="defbody">
14771518 Unify <var>t</var> with a Prolog string object created from the
14781519 zero-terminated string <var>chars</var>. The data will be copied. See
14791520 also <a class="func" href="foreigninclude.html#PL_unify_string_nchars()">PL_unify_string_nchars()</a>.
14801521 </dd>
1481 <dt class="pubdef"><a name="PL_unify_integer()"><var>int</var> <strong>PL_unify_integer</strong>(<var>term_t
1522 <dt class="pubdef"><a id="PL_unify_integer()"><var>int</var> <strong>PL_unify_integer</strong>(<var>term_t
14821523 ?t, intptr_t n</var>)</a></dt>
14831524 <dd class="defbody">
14841525 Unify <var>t</var> with a Prolog integer from <var>n</var>.
14851526 </dd>
1486 <dt class="pubdef"><a name="PL_unify_int64()"><var>int</var> <strong>PL_unify_int64</strong>(<var>term_t
1527 <dt class="pubdef"><a id="PL_unify_int64()"><var>int</var> <strong>PL_unify_int64</strong>(<var>term_t
14871528 ?t, int64_t n</var>)</a></dt>
14881529 <dd class="defbody">
14891530 Unify <var>t</var> with a Prolog integer from <var>n</var>.
14901531 </dd>
1491 <dt class="pubdef"><a name="PL_unify_uint64()"><var>int</var> <strong>PL_unify_uint64</strong>(<var>term_t
1532 <dt class="pubdef"><a id="PL_unify_uint64()"><var>int</var> <strong>PL_unify_uint64</strong>(<var>term_t
14921533 ?t, uint64_t n</var>)</a></dt>
14931534 <dd class="defbody">
14941535 Unify <var>t</var> with a Prolog integer from <var>n</var>. Note that
14961537 <code>int64_t</code>. If unbounded integers are not supported a
14971538 <code>representation_error</code> is raised.
14981539 </dd>
1499 <dt class="pubdef"><a name="PL_unify_float()"><var>int</var> <strong>PL_unify_float</strong>(<var>term_t
1540 <dt class="pubdef"><a id="PL_unify_float()"><var>int</var> <strong>PL_unify_float</strong>(<var>term_t
15001541 ?t, double f</var>)</a></dt>
15011542 <dd class="defbody">
15021543 Unify <var>t</var> with a Prolog float from <var>f</var>.
15031544 </dd>
1504 <dt class="pubdef"><a name="PL_unify_pointer()"><var>int</var> <strong>PL_unify_pointer</strong>(<var>term_t
1545 <dt class="pubdef"><a id="PL_unify_pointer()"><var>int</var> <strong>PL_unify_pointer</strong>(<var>term_t
15051546 ?t, void *ptr</var>)</a></dt>
15061547 <dd class="defbody">
15071548 Unify <var>t</var> with a Prolog integer describing the pointer. See
15081549 also
15091550 <a class="func" href="foreigninclude.html#PL_put_pointer()">PL_put_pointer()</a>
15101551 and <a class="func" href="foreigninclude.html#PL_get_pointer()">PL_get_pointer()</a>.</dd>
1511 <dt class="pubdef"><a name="PL_unify_functor()"><var>int</var> <strong>PL_unify_functor</strong>(<var>term_t
1552 <dt class="pubdef"><a id="PL_unify_functor()"><var>int</var> <strong>PL_unify_functor</strong>(<var>term_t
15121553 ?t, functor_t f</var>)</a></dt>
15131554 <dd class="defbody">
15141555 If <var>t</var> is a compound term with the given functor, just succeed.
15161557 that this function does not create a term if the argument is already
15171558 instantiated. If <var>f</var> is a functor with arity 0, <var>t</var> is
15181559 unified with an atom. See also <a class="func" href="foreigninclude.html#PL_unify_compound()">PL_unify_compound()</a>.</dd>
1519 <dt class="pubdef"><a name="PL_unify_compound()"><var>int</var> <strong>PL_unify_compound</strong>(<var>term_t
1560 <dt class="pubdef"><a id="PL_unify_compound()"><var>int</var> <strong>PL_unify_compound</strong>(<var>term_t
15201561 ?t, functor_t f</var>)</a></dt>
15211562 <dd class="defbody">
15221563 If <var>t</var> is a compound term with the given functor, just succeed.
15251566 instantiated. If <var>f</var> is a functor with arity 0, <var>t</var> is
15261567 unified with compound without arguments. See also
15271568 <a class="func" href="foreigninclude.html#PL_unify_functor()">PL_unify_functor()</a>.</dd>
1528 <dt class="pubdef"><a name="PL_unify_list()"><var>int</var> <strong>PL_unify_list</strong>(<var>term_t
1569 <dt class="pubdef"><a id="PL_unify_list()"><var>int</var> <strong>PL_unify_list</strong>(<var>term_t
15291570 ?l, term_t -h, term_t -t</var>)</a></dt>
15301571 <dd class="defbody">
15311572 Unify <var>l</var> with a list-cell (<code>./2</code>). If successful,
15621603 </pre>
15631604
15641605 </dd>
1565 <dt class="pubdef"><a name="PL_unify_nil()"><var>int</var> <strong>PL_unify_nil</strong>(<var>term_t
1606 <dt class="pubdef"><a id="PL_unify_nil()"><var>int</var> <strong>PL_unify_nil</strong>(<var>term_t
15661607 ?l</var>)</a></dt>
15671608 <dd class="defbody">
15681609 Unify <var>l</var> with the atom <code>[]</code>.
15691610 </dd>
1570 <dt class="pubdef"><a name="PL_unify_arg()"><var>int</var> <strong>PL_unify_arg</strong>(<var>int
1611 <dt class="pubdef"><a id="PL_unify_arg()"><var>int</var> <strong>PL_unify_arg</strong>(<var>int
15711612 index, term_t ?t, term_t ?a</var>)</a></dt>
15721613 <dd class="defbody">
15731614 Unifies the <em>index-th</em> argument (1-based) of <var>t</var> with
15741615 <var>a</var>.
15751616 </dd>
1576 <dt class="pubdef"><a name="PL_unify_term()"><var>int</var> <strong>PL_unify_term</strong>(<var>term_t
1617 <dt class="pubdef"><a id="PL_unify_term()"><var>int</var> <strong>PL_unify_term</strong>(<var>term_t
15771618 ?t, ...</var>)</a></dt>
15781619 <dd class="defbody">
15791620 Unify <var>t</var> with a (normally) compound term. The remaining
17581799 </pre>
17591800
17601801 </dd>
1761 <dt class="pubdef"><a name="PL_chars_to_term()"><var>int</var> <strong>PL_chars_to_term</strong>(<var>const
1802 <dt class="pubdef"><a id="PL_chars_to_term()"><var>int</var> <strong>PL_chars_to_term</strong>(<var>const
17621803 char *chars, term_t -t</var>)</a></dt>
17631804 <dd class="defbody">
17641805 Parse the string <var>chars</var> and put the resulting Prolog term into
17661807 full-stop (i.e., a dot followed by a blank). Returns <code>FALSE</code>
17671808 if a syntax error was encountered and <code>TRUE</code> after successful
17681809 completion. In addition to returning <code>FALSE</code>, the
1769 exception-term is returned in <var>t</var> on a syntax error. See also <a name="idx:termtoatom2:2027"></a><a class="pred" href="manipatom.html#term_to_atom/2">term_to_atom/2</a>.
1810 exception-term is returned in <var>t</var> on a syntax error. See also <a id="idx:termtoatom2:2031"></a><a class="pred" href="manipatom.html#term_to_atom/2">term_to_atom/2</a>.
17701811
17711812 <p>The following example builds a goal term from a string and calls it.
17721813
17911832 </pre>
17921833
17931834 </dd>
1794 <dt class="pubdef"><a name="PL_wchars_to_term()"><var>int</var> <strong>PL_wchars_to_term</strong>(<var>const
1835 <dt class="pubdef"><a id="PL_wchars_to_term()"><var>int</var> <strong>PL_wchars_to_term</strong>(<var>const
17951836 pl_wchar_t *chars, term_t -t</var>)</a></dt>
17961837 <dd class="defbody">
17971838 Wide character version of <a class="func" href="foreigninclude.html#PL_chars_to_term()">PL_chars_to_term()</a>.</dd>
1798 <dt class="pubdef"><a name="PL_quote()"><var>char *</var> <strong>PL_quote</strong>(<var>int
1839 <dt class="pubdef"><a id="PL_quote()"><var>char *</var> <strong>PL_quote</strong>(<var>int
17991840 chr, const char *string</var>)</a></dt>
18001841 <dd class="defbody">
18011842 Return a quoted version of <var>string</var>. If <var>chr</var> is
18121853 </dd>
18131854 </dl>
18141855
1815 <p><h3 id="sec:cerror"><a name="sec:11.4.6"><span class="sec-nr">11.4.6</span> <span class="sec-title">Convenient
1856 <p><h3 id="sec:cerror"><a id="sec:11.4.6"><span class="sec-nr">11.4.6</span> <span class="sec-title">Convenient
18161857 functions to generate Prolog exceptions</span></a></h3>
18171858
1818 <a name="sec:cerror"></a>
1859 <a id="sec:cerror"></a>
18191860
18201861 <p>The typical implementation of a foreign predicate first uses the
18211862 PL_get_*() functions to extract C data types from the Prolog terms.
18441885 </pre>
18451886
18461887 <dl class="latex">
1847 <dt class="pubdef"><a name="PL_get_atom_ex()"><var>int</var> <strong>PL_get_atom_ex</strong>(<var>term_t
1888 <dt class="pubdef"><a id="PL_get_atom_ex()"><var>int</var> <strong>PL_get_atom_ex</strong>(<var>term_t
18481889 t, atom_t *a</var>)</a></dt>
18491890 <dd class="defbody">
18501891 As <a class="func" href="foreigninclude.html#PL_get_atom()">PL_get_atom()</a>,
18511892 but raises a type or instantiation error if
18521893 <var>t</var> is not an atom.</dd>
1853 <dt class="pubdef"><a name="PL_get_integer_ex()"><var>int</var> <strong>PL_get_integer_ex</strong>(<var>term_t
1894 <dt class="pubdef"><a id="PL_get_integer_ex()"><var>int</var> <strong>PL_get_integer_ex</strong>(<var>term_t
18541895 t, int *i</var>)</a></dt>
18551896 <dd class="defbody">
18561897 As <a class="func" href="foreigninclude.html#PL_get_integer()">PL_get_integer()</a>,
18571898 but raises a type or instantiation error if
18581899 <var>t</var> is not an integer, or a representation error if the Prolog
18591900 integer does not fit in a C <code>int</code>.</dd>
1860 <dt class="pubdef"><a name="PL_get_long_ex()"><var>int</var> <strong>PL_get_long_ex</strong>(<var>term_t
1901 <dt class="pubdef"><a id="PL_get_long_ex()"><var>int</var> <strong>PL_get_long_ex</strong>(<var>term_t
18611902 t, long *i</var>)</a></dt>
18621903 <dd class="defbody">
18631904 As <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>,
18641905 but raises a type or instantiation error if
18651906 <var>t</var> is not an atom, or a representation error if the Prolog
18661907 integer does not fit in a C <code>long</code>.</dd>
1867 <dt class="pubdef"><a name="PL_get_int64_ex()"><var>int</var> <strong>PL_get_int64_ex</strong>(<var>term_t
1908 <dt class="pubdef"><a id="PL_get_int64_ex()"><var>int</var> <strong>PL_get_int64_ex</strong>(<var>term_t
18681909 t, int64_t *i</var>)</a></dt>
18691910 <dd class="defbody">
18701911 As <a class="func" href="foreigninclude.html#PL_get_int64()">PL_get_int64()</a>,
18711912 but raises a type or instantiation error if
18721913 <var>t</var> is not an atom, or a representation error if the Prolog
18731914 integer does not fit in a C <code>int64_t</code>.</dd>
1874 <dt class="pubdef"><a name="PL_get_intptr_ex()"><var>int</var> <strong>PL_get_intptr_ex</strong>(<var>term_t
1915 <dt class="pubdef"><a id="PL_get_intptr_ex()"><var>int</var> <strong>PL_get_intptr_ex</strong>(<var>term_t
18751916 t, intptr_t *i</var>)</a></dt>
18761917 <dd class="defbody">
18771918 As <a class="func" href="foreigninclude.html#PL_get_intptr()">PL_get_intptr()</a>,
18781919 but raises a type or instantiation error if
18791920 <var>t</var> is not an atom, or a representation error if the Prolog
18801921 integer does not fit in a C <code>intptr_t</code>.</dd>
1881 <dt class="pubdef"><a name="PL_get_size_ex()"><var>int</var> <strong>PL_get_size_ex</strong>(<var>term_t
1922 <dt class="pubdef"><a id="PL_get_size_ex()"><var>int</var> <strong>PL_get_size_ex</strong>(<var>term_t
18821923 t, size_t *i</var>)</a></dt>
18831924 <dd class="defbody">
18841925 As <b>PL_get_size()</b>, but raises a type or instantiation error if
18851926 <var>t</var> is not an atom, or a representation error if the Prolog
18861927 integer does not fit in a C <code>size_t</code>.</dd>
1887 <dt class="pubdef"><a name="PL_get_bool_ex()"><var>int</var> <strong>PL_get_bool_ex</strong>(<var>term_t
1928 <dt class="pubdef"><a id="PL_get_bool_ex()"><var>int</var> <strong>PL_get_bool_ex</strong>(<var>term_t
18881929 t, int *i</var>)</a></dt>
18891930 <dd class="defbody">
18901931 As <a class="func" href="foreigninclude.html#PL_get_bool()">PL_get_bool()</a>,
18911932 but raises a type or instantiation error if
18921933 <var>t</var> is not an boolean.</dd>
1893 <dt class="pubdef"><a name="PL_get_float_ex()"><var>int</var> <strong>PL_get_float_ex</strong>(<var>term_t
1934 <dt class="pubdef"><a id="PL_get_float_ex()"><var>int</var> <strong>PL_get_float_ex</strong>(<var>term_t
18941935 t, double *f</var>)</a></dt>
18951936 <dd class="defbody">
18961937 As <a class="func" href="foreigninclude.html#PL_get_float()">PL_get_float()</a>,
18971938 but raises a type or instantiation error if
18981939 <var>t</var> is not a float.</dd>
1899 <dt class="pubdef"><a name="PL_get_char_ex()"><var>int</var> <strong>PL_get_char_ex</strong>(<var>term_t
1940 <dt class="pubdef"><a id="PL_get_char_ex()"><var>int</var> <strong>PL_get_char_ex</strong>(<var>term_t
19001941 t, int *p, int eof</var>)</a></dt>
19011942 <dd class="defbody">
19021943 Get a character code from <var>t</var>, where <var>t</var> is either an
19031944 integer or an atom with length one. If <var>eof</var> is <code>TRUE</code>
19041945 and <var>t</var> is -1, <var>p</var> is filled with -1. Raises an
19051946 appropriate error if the conversion is not possible.</dd>
1906 <dt class="pubdef"><a name="PL_get_pointer_ex()"><var>int</var> <strong>PL_get_pointer_ex</strong>(<var>term_t
1947 <dt class="pubdef"><a id="PL_get_pointer_ex()"><var>int</var> <strong>PL_get_pointer_ex</strong>(<var>term_t
19071948 t, void **addrp</var>)</a></dt>
19081949 <dd class="defbody">
19091950 As <a class="func" href="foreigninclude.html#PL_get_pointer()">PL_get_pointer()</a>,
19101951 but raises a type or instantiation error if
19111952 <var>t</var> is not a pointer.</dd>
1912 <dt class="pubdef"><a name="PL_get_list_ex()"><var>int</var> <strong>PL_get_list_ex</strong>(<var>term_t
1953 <dt class="pubdef"><a id="PL_get_list_ex()"><var>int</var> <strong>PL_get_list_ex</strong>(<var>term_t
19131954 l, term_t h, term_t t</var>)</a></dt>
19141955 <dd class="defbody">
19151956 As <a class="func" href="foreigninclude.html#PL_get_list()">PL_get_list()</a>,
19161957 but raises a type or instantiation error if
19171958 <var>t</var> is not a list.</dd>
1918 <dt class="pubdef"><a name="PL_get_nil_ex()"><var>int</var> <strong>PL_get_nil_ex</strong>(<var>term_t
1959 <dt class="pubdef"><a id="PL_get_nil_ex()"><var>int</var> <strong>PL_get_nil_ex</strong>(<var>term_t
19191960 l</var>)</a></dt>
19201961 <dd class="defbody">
19211962 As <a class="func" href="foreigninclude.html#PL_get_nil()">PL_get_nil()</a>,
19221963 but raises a type or instantiation error if
19231964 <var>t</var> is not the empty list.</dd>
1924 <dt class="pubdef"><a name="PL_unify_list_ex()"><var>int</var> <strong>PL_unify_list_ex</strong>(<var>term_t
1965 <dt class="pubdef"><a id="PL_unify_list_ex()"><var>int</var> <strong>PL_unify_list_ex</strong>(<var>term_t
19251966 l, term_t h, term_t t</var>)</a></dt>
19261967 <dd class="defbody">
19271968 As <a class="func" href="foreigninclude.html#PL_unify_list()">PL_unify_list()</a>,
19281969 but raises a type error if <var>t</var> is not a variable, list-cell or
19291970 the empty list.</dd>
1930 <dt class="pubdef"><a name="PL_unify_nil_ex()"><var>int</var> <strong>PL_unify_nil_ex</strong>(<var>term_t
1971 <dt class="pubdef"><a id="PL_unify_nil_ex()"><var>int</var> <strong>PL_unify_nil_ex</strong>(<var>term_t
19311972 l</var>)</a></dt>
19321973 <dd class="defbody">
19331974 As <a class="func" href="foreigninclude.html#PL_unify_nil()">PL_unify_nil()</a>,
19341975 but raises a type error if <var>t</var> is not a variable, list-cell or
19351976 the empty list.</dd>
1936 <dt class="pubdef"><a name="PL_unify_bool_ex()"><var>int</var> <strong>PL_unify_bool_ex</strong>(<var>term_t
1977 <dt class="pubdef"><a id="PL_unify_bool_ex()"><var>int</var> <strong>PL_unify_bool_ex</strong>(<var>term_t
19371978 t, int val</var>)</a></dt>
19381979 <dd class="defbody">
19391980 As <a class="func" href="foreigninclude.html#PL_unify_bool()">PL_unify_bool()</a>,
19491990 context. See also <a class="func" href="foreigninclude.html#PL_raise_exception()">PL_raise_exception()</a>.
19501991
19511992 <dl class="latex">
1952 <dt class="pubdef"><a name="PL_instantiation_error()"><var>int</var> <strong>PL_instantiation_error</strong>(<var>term_t
1993 <dt class="pubdef"><a id="PL_instantiation_error()"><var>int</var> <strong>PL_instantiation_error</strong>(<var>term_t
19531994 culprit</var>)</a></dt>
19541995 <dd class="defbody">
19551996 Raise <code>instantiation_error</code>. <var>Culprit</var> is ignored,
19561997 but should be bound to the term that is insufficiently instantiated. See
1957 <a name="idx:instantiationerror1:2028"></a><a class="pred" href="error.html#instantiation_error/1">instantiation_error/1</a>.</dd>
1958 <dt class="pubdef"><a name="PL_uninstantiation_error()"><var>int</var> <strong>PL_uninstantiation_error</strong>(<var>term_t
1998 <a id="idx:instantiationerror1:2032"></a><a class="pred" href="error.html#instantiation_error/1">instantiation_error/1</a>.</dd>
1999 <dt class="pubdef"><a id="PL_uninstantiation_error()"><var>int</var> <strong>PL_uninstantiation_error</strong>(<var>term_t
19592000 culprit</var>)</a></dt>
19602001 <dd class="defbody">
19612002 Raise <code>uninstantiation_error(culprit)</code>. This should be called
19622003 if an argument that must be unbound at entry is bound to <var>culprit</var>.
19632004 This error is typically raised for a pure output arguments such as a
1964 newly created stream handle (e.g., the third argument of <a name="idx:open3:2029"></a><a class="pred" href="IO.html#open/3">open/3</a>).</dd>
1965 <dt class="pubdef"><a name="PL_representation_error()"><var>int</var> <strong>PL_representation_error</strong>(<var>const
2005 newly created stream handle (e.g., the third argument of <a id="idx:open3:2033"></a><a class="pred" href="IO.html#open/3">open/3</a>).</dd>
2006 <dt class="pubdef"><a id="PL_representation_error()"><var>int</var> <strong>PL_representation_error</strong>(<var>const
19662007 char *resource</var>)</a></dt>
19672008 <dd class="defbody">
1968 Raise <code>representation_error(resource)</code>. See <a name="idx:representationerror1:2030"></a><a class="pred" href="error.html#representation_error/1">representation_error/1</a>.</dd>
1969 <dt class="pubdef"><a name="PL_type_error()"><var>int</var> <strong>PL_type_error</strong>(<var>const
2009 Raise <code>representation_error(resource)</code>. See <a id="idx:representationerror1:2034"></a><a class="pred" href="error.html#representation_error/1">representation_error/1</a>.</dd>
2010 <dt class="pubdef"><a id="PL_type_error()"><var>int</var> <strong>PL_type_error</strong>(<var>const
19702011 char *expected, term_t culprit</var>)</a></dt>
19712012 <dd class="defbody">
1972 Raise <code>type_error(expected, culprit)</code>. See <a name="idx:typeerror2:2031"></a><a class="pred" href="error.html#type_error/2">type_error/2</a>.</dd>
1973 <dt class="pubdef"><a name="PL_domain_error()"><var>int</var> <strong>PL_domain_error</strong>(<var>const
2013 Raise <code>type_error(expected, culprit)</code>. See <a id="idx:typeerror2:2035"></a><a class="pred" href="error.html#type_error/2">type_error/2</a>.</dd>
2014 <dt class="pubdef"><a id="PL_domain_error()"><var>int</var> <strong>PL_domain_error</strong>(<var>const
19742015 char *expected, term_t culprit</var>)</a></dt>
19752016 <dd class="defbody">
1976 Raise <code>domain_error(expected, culprit)</code>. See <a name="idx:domainerror2:2032"></a><a class="pred" href="error.html#domain_error/2">domain_error/2</a>.</dd>
1977 <dt class="pubdef"><a name="PL_existence_error()"><var>int</var> <strong>PL_existence_error</strong>(<var>const
2017 Raise <code>domain_error(expected, culprit)</code>. See <a id="idx:domainerror2:2036"></a><a class="pred" href="error.html#domain_error/2">domain_error/2</a>.</dd>
2018 <dt class="pubdef"><a id="PL_existence_error()"><var>int</var> <strong>PL_existence_error</strong>(<var>const
19782019 char *type, term_t culprit</var>)</a></dt>
19792020 <dd class="defbody">
1980 Raise <code>existence_error(type, culprit)</code>. See <a name="idx:typeerror2:2033"></a><a class="pred" href="error.html#type_error/2">type_error/2</a>.</dd>
1981 <dt class="pubdef"><a name="PL_permission_error()"><var>int</var> <strong>PL_permission_error</strong>(<var>const
2021 Raise <code>existence_error(type, culprit)</code>. See <a id="idx:typeerror2:2037"></a><a class="pred" href="error.html#type_error/2">type_error/2</a>.</dd>
2022 <dt class="pubdef"><a id="PL_permission_error()"><var>int</var> <strong>PL_permission_error</strong>(<var>const
19822023 char *operation, const char *type, term_t culprit</var>)</a></dt>
19832024 <dd class="defbody">
19842025 Raise <code>permission_error(operation, type, culprit)</code>. See
1985 <a name="idx:permissionerror3:2034"></a><a class="pred" href="error.html#permission_error/3">permission_error/3</a>.
1986 </dd>
1987 <dt class="pubdef"><a name="PL_resource_error()"><var>int</var> <strong>PL_resource_error</strong>(<var>const
2026 <a id="idx:permissionerror3:2038"></a><a class="pred" href="error.html#permission_error/3">permission_error/3</a>.
2027 </dd>
2028 <dt class="pubdef"><a id="PL_resource_error()"><var>int</var> <strong>PL_resource_error</strong>(<var>const
19882029 char *resource</var>)</a></dt>
19892030 <dd class="defbody">
1990 Raise <code>resource_error(resource)</code>. See <a name="idx:resourceerror1:2035"></a><a class="pred" href="error.html#resource_error/1">resource_error/1</a>.
1991 </dd>
1992 <dt class="pubdef"><a name="PL_syntax_error()"><var>int</var> <strong>PL_syntax_error</strong>(<var>const
2031 Raise <code>resource_error(resource)</code>. See <a id="idx:resourceerror1:2039"></a><a class="pred" href="error.html#resource_error/1">resource_error/1</a>.
2032 </dd>
2033 <dt class="pubdef"><a id="PL_syntax_error()"><var>int</var> <strong>PL_syntax_error</strong>(<var>const
19932034 char *message, IOSTREAM *in</var>)</a></dt>
19942035 <dd class="defbody">
19952036 Raise <code>syntax_error(message)</code>. If <var>arg</var> is not <code>NULL</code>,
19972038 </dd>
19982039 </dl>
19992040
2000 <p><h3 id="sec:blob"><a name="sec:11.4.7"><span class="sec-nr">11.4.7</span> <span class="sec-title">BLOBS:
2041 <p><h3 id="sec:blob"><a id="sec:11.4.7"><span class="sec-nr">11.4.7</span> <span class="sec-title">BLOBS:
20012042 Using atoms to store arbitrary binary data</span></a></h3>
20022043
2003 <a name="sec:blob"></a>
2004
2005 <p><a name="idx:Java:2036"></a><a name="idx:COM:2037"></a>SWI-Prolog
2006 atoms as well as strings can represent arbitrary binary data of
2007 arbitrary length. This facility is attractive for storing foreign data
2008 such as images in an atom. An atom is a unique handle to this data and
2009 the atom garbage collector is able to destroy atoms that are no longer
2010 referenced by the Prolog engine. This property of atoms makes them
2011 attractive as a handle to foreign resources, such as Java atoms,
2012 Microsoft's COM objects, etc., providing safe combined garbage
2013 collection.
2044 <a id="sec:blob"></a>
2045
2046 <p><a id="idx:Java:2040"></a><a id="idx:COM:2041"></a>SWI-Prolog atoms
2047 as well as strings can represent arbitrary binary data of arbitrary
2048 length. This facility is attractive for storing foreign data such as
2049 images in an atom. An atom is a unique handle to this data and the atom
2050 garbage collector is able to destroy atoms that are no longer referenced
2051 by the Prolog engine. This property of atoms makes them attractive as a
2052 handle to foreign resources, such as Java atoms, Microsoft's COM
2053 objects, etc., providing safe combined garbage collection.
20142054
20152055 <p>To exploit these features safely and in an organised manner, the
20162056 SWI-Prolog foreign interface allows for creating `atoms' with additional
20222062 <a class="func" href="foreigninclude.html#compare()">compare()</a>
20232063 function. Rank numbers are assigned when the type is registered.
20242064
2025 <p><h4 id="sec:blobtype"><a name="sec:11.4.7.1"><span class="sec-nr">11.4.7.1</span> <span class="sec-title">Defining
2065 <p><h4 id="sec:blobtype"><a id="sec:11.4.7.1"><span class="sec-nr">11.4.7.1</span> <span class="sec-title">Defining
20262066 a BLOB type</span></a></h4>
20272067
2028 <a name="sec:blobtype"></a>
2068 <a id="sec:blobtype"></a>
20292069
20302070 <p>The type <code>PL_blob_t</code> represents a structure with the
20312071 layout displayed below. The structure contains additional fields at the
20492089 <var>flags</var> is a bitwise <em>or</em> of the following constants:
20502090
20512091 <dl class="latex">
2052 <dt><a name="PL_BLOB_TEXT"><strong>PL_BLOB_TEXT</strong></a></dt>
2092 <dt><a id="PL_BLOB_TEXT"><strong>PL_BLOB_TEXT</strong></a></dt>
20532093 <dd class="defbody">
20542094 If specified the blob is assumed to contain text and is considered a
20552095 normal Prolog atom.</dd>
2056 <dt><a name="PL_BLOB_UNIQUE"><strong>PL_BLOB_UNIQUE</strong></a></dt>
2096 <dt><a id="PL_BLOB_UNIQUE"><strong>PL_BLOB_UNIQUE</strong></a></dt>
20572097 <dd class="defbody">
20582098 If specified the system ensures that the blob-handle is a unique
20592099 reference for a blob with the given type, length and content. If this
20602100 flag is not specified, each lookup creates a new blob.</dd>
2061 <dt><a name="PL_BLOB_NOCOPY"><strong>PL_BLOB_NOCOPY</strong></a></dt>
2101 <dt><a id="PL_BLOB_NOCOPY"><strong>PL_BLOB_NOCOPY</strong></a></dt>
20622102 <dd class="defbody">
20632103 By default the content of the blob is copied. Using this flag the blob
20642104 references the external data directly. The user must ensure the provided
20692109 </dl>
20702110
20712111 <p>The <var>name</var> field represents the type name as available to
2072 Prolog. See also <a name="idx:currentblob2:2038"></a><a class="pred" href="examineprog.html#current_blob/2">current_blob/2</a>.
2112 Prolog. See also <a id="idx:currentblob2:2042"></a><a class="pred" href="examineprog.html#current_blob/2">current_blob/2</a>.
20732113 The other fields are function pointers that must be initialised to
20742114 proper functions or <code>NULL</code> to get the default behaviour of
20752115 built-in atoms. Below are the defined member functions:
20762116
20772117 <dl class="latex">
2078 <dt class="pubdef"><a name="acquire()"><var>void</var> <strong>acquire</strong>(<var>atom_t
2118 <dt class="pubdef"><a id="acquire()"><var>void</var> <strong>acquire</strong>(<var>atom_t
20792119 a</var>)</a></dt>
20802120 <dd class="defbody">
20812121 Called if a new blob of this type is created through <a class="func" href="foreigninclude.html#PL_put_blob()">PL_put_blob()</a>
20822122 or <a class="func" href="foreigninclude.html#PL_unify_blob()">PL_unify_blob()</a>.
20832123 This callback may be used together with the release hook to deal with
20842124 reference-counted external objects.</dd>
2085 <dt class="pubdef"><a name="release()"><var>int</var> <strong>release</strong>(<var>atom_t
2125 <dt class="pubdef"><a id="release()"><var>int</var> <strong>release</strong>(<var>atom_t
20862126 a</var>)</a></dt>
20872127 <dd class="defbody">
20882128 The blob (atom) <var>a</var> is about to be released. This function can
20892129 retrieve the data of the blob using <a class="func" href="foreigninclude.html#PL_blob_data()">PL_blob_data()</a>.
20902130 If it returns <code>FALSE</code> the atom garbage collector will <em>not</em>
20912131 reclaim the atom.</dd>
2092 <dt class="pubdef"><a name="compare()"><var>int</var> <strong>compare</strong>(<var>atom_t
2132 <dt class="pubdef"><a id="compare()"><var>int</var> <strong>compare</strong>(<var>atom_t
20932133 a, atom_t b</var>)</a></dt>
20942134 <dd class="defbody">
20952135 Compare the blobs <var>a</var> and <var>b</var>, both of which are of
20972137 <var>&lt; 0</var> if <var>a</var> is less than <var>b</var>, <var>= 0</var>
20982138 if both are equal, and
20992139 <var>&gt; 0</var> otherwise.</dd>
2100 <dt class="pubdef"><a name="write()"><var>int</var> <strong>write</strong>(<var>IOSTREAM
2140 <dt class="pubdef"><a id="write()"><var>int</var> <strong>write</strong>(<var>IOSTREAM
21012141 *s, atom_t a, int flags</var>)</a></dt>
21022142 <dd class="defbody">
21032143 Write the content of the blob <var>a</var> to the stream <var>s</var>
21072147 undocumented <code>SWI-Stream.h</code> is included <em>before</em>
21082148 <code>SWI-Prolog.h</code>.
21092149
2110 <p>If this function is not provided, <a name="idx:write1:2039"></a><a class="pred" href="termrw.html#write/1">write/1</a>
2150 <p>If this function is not provided, <a id="idx:write1:2043"></a><a class="pred" href="termrw.html#write/1">write/1</a>
21112151 emits the content of the blob for blobs of type <code>PL_BLOB_TEXT</code>
21122152 or a string of the format <code>&lt;#</code><i>hex data</i><code>&gt;</code>
21132153 for binary blobs.
21192159 released.
21202160
21212161 <dl class="latex">
2122 <dt class="pubdef"><a name="PL_unregister_blob_type()"><var>int</var> <strong>PL_unregister_blob_type</strong>(<var>PL_blob_t
2162 <dt class="pubdef"><a id="PL_unregister_blob_type()"><var>int</var> <strong>PL_unregister_blob_type</strong>(<var>PL_blob_t
21232163 *type</var>)</a></dt>
21242164 <dd class="defbody">
21252165 Unlink the blob type from the registered type and transform the type of
21322172 </dd>
21332173 </dl>
21342174
2135 <p><h4 id="sec:blobaccess"><a name="sec:11.4.7.2"><span class="sec-nr">11.4.7.2</span> <span class="sec-title">Accessing
2175 <p><h4 id="sec:blobaccess"><a id="sec:11.4.7.2"><span class="sec-nr">11.4.7.2</span> <span class="sec-title">Accessing
21362176 blobs</span></a></h4>
21372177
2138 <a name="sec:blobaccess"></a>
2178 <a id="sec:blobaccess"></a>
21392179
21402180 <p>The blob access functions are similar to the atom accessing
21412181 functions. Blobs being atoms, the atom functions operate on blobs and
21432183 however, it is not advised to rely on this.
21442184
21452185 <dl class="latex">
2146 <dt class="pubdef"><a name="PL_is_blob()"><var>int</var> <strong>PL_is_blob</strong>(<var>term_t
2186 <dt class="pubdef"><a id="PL_is_blob()"><var>int</var> <strong>PL_is_blob</strong>(<var>term_t
21472187 t, PL_blob_t **type</var>)</a></dt>
21482188 <dd class="defbody">
21492189 Succeeds if <var>t</var> refers to a blob, in which case <var>type</var>
21502190 is filled with the type of the blob.</dd>
2151 <dt class="pubdef"><a name="PL_unify_blob()"><var>int</var> <strong>PL_unify_blob</strong>(<var>term_t
2191 <dt class="pubdef"><a id="PL_unify_blob()"><var>int</var> <strong>PL_unify_blob</strong>(<var>term_t
21522192 t, void *blob, size_t len, PL_blob_t *type</var>)</a></dt>
21532193 <dd class="defbody">
21542194 Unify <var>t</var> to a new blob constructed from the given data and
21552195 associated to the given type. See also <a class="func" href="foreigninclude.html#PL_unify_atom_nchars()">PL_unify_atom_nchars()</a>.</dd>
2156 <dt class="pubdef"><a name="PL_put_blob()"><var>int</var> <strong>PL_put_blob</strong>(<var>term_t
2196 <dt class="pubdef"><a id="PL_put_blob()"><var>int</var> <strong>PL_put_blob</strong>(<var>term_t
21572197 t, void *blob, size_t len, PL_blob_t *type</var>)</a></dt>
21582198 <dd class="defbody">
21592199 Store the described blob in <var>t</var>. The return value indicates
21642204 count must be incremented, and it must be decremented on blob
21652205 destruction callback. See also
21662206 <a class="func" href="foreigninclude.html#PL_put_atom_nchars()">PL_put_atom_nchars()</a>.</dd>
2167 <dt class="pubdef"><a name="PL_get_blob()"><var>int</var> <strong>PL_get_blob</strong>(<var>term_t
2207 <dt class="pubdef"><a id="PL_get_blob()"><var>int</var> <strong>PL_get_blob</strong>(<var>term_t
21682208 t, void **blob, size_t *len, PL_blob_t **type</var>)</a></dt>
21692209 <dd class="defbody">
21702210 If <var>t</var> holds a blob or atom, get the data and type and return
21712211 <code>TRUE</code>. Otherwise return <code>FALSE</code>. Each result
21722212 pointer may be <code>NULL</code>, in which case the requested
21732213 information is ignored.</dd>
2174 <dt class="pubdef"><a name="PL_blob_data()"><var>void *</var> <strong>PL_blob_data</strong>(<var>atom_t
2214 <dt class="pubdef"><a id="PL_blob_data()"><var>void *</var> <strong>PL_blob_data</strong>(<var>atom_t
21752215 a, size_t *len, PL_blob_t **type</var>)</a></dt>
21762216 <dd class="defbody">
21772217 Get the data and type associated to a blob. This function is mainly used
2178 from the callback functions described in <a class="sec" href="foreigninclude.html">section
2218 from the callback functions described in <a class="sec" href="foreigninclude.html#sec:11.4.7.1">section
21792219 11.4.7.1</a>.
21802220 </dd>
21812221 </dl>
21822222
2183 <p><h3 id="sec:gmpforeign"><a name="sec:11.4.8"><span class="sec-nr">11.4.8</span> <span class="sec-title">Exchanging
2223 <p><h3 id="sec:gmpforeign"><a id="sec:11.4.8"><span class="sec-nr">11.4.8</span> <span class="sec-title">Exchanging
21842224 GMP numbers</span></a></h3>
21852225
2186 <a name="sec:gmpforeign"></a>
2226 <a id="sec:gmpforeign"></a>
21872227
21882228 <p>If SWI-Prolog is linked with the GNU Multiple Precision Arithmetic
21892229 Library (GMP, used by default), the foreign interface provides functions
22402280 </pre>
22412281
22422282 <dl class="latex">
2243 <dt class="pubdef"><a name="PL_get_mpz()"><var>int</var> <strong>PL_get_mpz</strong>(<var>term_t
2283 <dt class="pubdef"><a id="PL_get_mpz()"><var>int</var> <strong>PL_get_mpz</strong>(<var>term_t
22442284 t, mpz_t mpz</var>)</a></dt>
22452285 <dd class="defbody">
22462286 If <var>t</var> represents an integer, <var>mpz</var> is filled with the
22482288 is untouched and the function returns <code>FALSE</code>. Note that <var>mpz</var>
22492289 must have been initialised before calling this function and must be
22502290 cleared using mpz_clear() to reclaim any storage associated with it.</dd>
2251 <dt class="pubdef"><a name="PL_get_mpq()"><var>int</var> <strong>PL_get_mpq</strong>(<var>term_t
2291 <dt class="pubdef"><a id="PL_get_mpq()"><var>int</var> <strong>PL_get_mpq</strong>(<var>term_t
22522292 t, mpq_t mpq</var>)</a></dt>
22532293 <dd class="defbody">
22542294 If <var>t</var> is an integer or rational number (term <code>rdiv/2</code>),
22572297 untouched and the function returns <code>FALSE</code>. Note that <var>mpq</var>
22582298 must have been initialised before calling this function and must be
22592299 cleared using mpq_clear() to reclaim any storage associated with it.</dd>
2260 <dt class="pubdef"><a name="PL_unify_mpz()"><var>int</var> <strong>PL_unify_mpz</strong>(<var>term_t
2300 <dt class="pubdef"><a id="PL_unify_mpz()"><var>int</var> <strong>PL_unify_mpz</strong>(<var>term_t
22612301 t, mpz_t mpz</var>)</a></dt>
22622302 <dd class="defbody">
22632303 Unify <var>t</var> with the integer value represented by <var>mpz</var>
22642304 and return
22652305 <code>TRUE</code> on success. The <var>mpz</var> argument is not
22662306 changed.</dd>
2267 <dt class="pubdef"><a name="PL_unify_mpq()"><var>int</var> <strong>PL_unify_mpq</strong>(<var>term_t
2307 <dt class="pubdef"><a id="PL_unify_mpq()"><var>int</var> <strong>PL_unify_mpq</strong>(<var>term_t
22682308 t, mpq_t mpq</var>)</a></dt>
22692309 <dd class="defbody">
22702310 Unify <var>t</var> with a rational number represented by <var>mpq</var>
22752315 </dd>
22762316 </dl>
22772317
2278 <p><h3 id="sec:calling-prolog-from-c"><a name="sec:11.4.9"><span class="sec-nr">11.4.9</span> <span class="sec-title">Calling
2318 <p><h3 id="sec:calling-prolog-from-c"><a id="sec:11.4.9"><span class="sec-nr">11.4.9</span> <span class="sec-title">Calling
22792319 Prolog from C</span></a></h3>
22802320
2281 <a name="sec:calling-prolog-from-c"></a>
2321 <a id="sec:calling-prolog-from-c"></a>
22822322
22832323 <p>The Prolog engine can be called from C. There are two interfaces for
22842324 this. For the first, a term is created that could be used as an argument
2285 to <a name="idx:call1:2040"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
2325 to <a id="idx:call1:2044"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
22862326 and then <a class="func" href="foreigninclude.html#PL_call()">PL_call()</a>
22872327 is used to call Prolog. This system is simple, but does not allow to
22882328 inspect the different answers to a non-deterministic goal and is
22942334 <a class="func" href="foreigninclude.html#PL_close_query()">PL_close_query()</a>.
22952335 This mechanism is more powerful, but also more complicated to use.
22962336
2297 <p><h4 id="sec:foreign-predicate-handle"><a name="sec:11.4.9.1"><span class="sec-nr">11.4.9.1</span> <span class="sec-title">Predicate
2337 <p><h4 id="sec:foreign-predicate-handle"><a id="sec:11.4.9.1"><span class="sec-nr">11.4.9.1</span> <span class="sec-title">Predicate
22982338 references</span></a></h4>
22992339
2300 <a name="sec:foreign-predicate-handle"></a>
2340 <a id="sec:foreign-predicate-handle"></a>
23012341
23022342 <p>This section discusses the functions used to communicate about
23032343 predicates. Though a Prolog predicate may be defined or not, redefined,
23052345 moved. This handle is known by the type <code>predicate_t</code>.
23062346
23072347 <dl class="latex">
2308 <dt class="pubdef"><a name="PL_pred()"><var>predicate_t</var> <strong>PL_pred</strong>(<var>functor_t
2348 <dt class="pubdef"><a id="PL_pred()"><var>predicate_t</var> <strong>PL_pred</strong>(<var>functor_t
23092349 f, module_t m</var>)</a></dt>
23102350 <dd class="defbody">
23112351 Return a handle to a predicate for the specified name/arity in the given
23122352 module. This function always succeeds, creating a handle for an
23132353 undefined predicate if no handle was available. If the module argument
23142354 <var>m</var> is <code>NULL</code>, the current context module is used.</dd>
2315 <dt class="pubdef"><a name="PL_predicate()"><var>predicate_t</var> <strong>PL_predicate</strong>(<var>const
2355 <dt class="pubdef"><a id="PL_predicate()"><var>predicate_t</var> <strong>PL_predicate</strong>(<var>const
23162356 char *name, int arity, const char* module</var>)</a></dt>
23172357 <dd class="defbody">
23182358 Same as <a class="func" href="foreigninclude.html#PL_pred()">PL_pred()</a>,
23192359 but provides a more convenient interface to the C programmer.</dd>
2320 <dt class="pubdef"><a name="PL_predicate_info()"><var>void</var> <strong>PL_predicate_info</strong>(<var>predicate_t
2360 <dt class="pubdef"><a id="PL_predicate_info()"><var>void</var> <strong>PL_predicate_info</strong>(<var>predicate_t
23212361 p, atom_t *n, size_t *a, module_t *m</var>)</a></dt>
23222362 <dd class="defbody">
23232363 Return information on the predicate <var>p</var>. The name is stored
23342374 </dd>
23352375 </dl>
23362376
2337 <p><h4 id="sec:foreign-create-query"><a name="sec:11.4.9.2"><span class="sec-nr">11.4.9.2</span> <span class="sec-title">Initiating
2377 <p><h4 id="sec:foreign-create-query"><a id="sec:11.4.9.2"><span class="sec-nr">11.4.9.2</span> <span class="sec-title">Initiating
23382378 a query from C</span></a></h4>
23392379
2340 <a name="sec:foreign-create-query"></a>
2380 <a id="sec:foreign-create-query"></a>
23412381
23422382 <p>This section discusses the functions for creating and manipulating
23432383 queries from C. Note that a foreign context can have at most one active
23512391 back to Prolog.
23522392
23532393 <dl class="latex">
2354 <dt class="pubdef"><a name="PL_open_query()"><var>qid_t</var> <strong>PL_open_query</strong>(<var>module_t
2394 <dt class="pubdef"><a id="PL_open_query()"><var>qid_t</var> <strong>PL_open_query</strong>(<var>module_t
23552395 ctx, int flags, predicate_t p, term_t +t0</var>)</a></dt>
23562396 <dd class="defbody">
23572397
23592399 module</em> of the goal. When <code>NULL</code>, the context module of
23602400 the calling context will be used, or <code>user</code> if there is no
23612401 calling context (as may happen in embedded systems). Note that the
2362 context module only matters for <em>meta-predicates</em>. See <a name="idx:metapredicate1:2041"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>,
2363 <a name="idx:contextmodule1:2042"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
2364 and <a name="idx:moduletransparent1:2043"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>.
2402 context module only matters for <em>meta-predicates</em>. See <a id="idx:metapredicate1:2045"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>,
2403 <a id="idx:contextmodule1:2046"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
2404 and <a id="idx:moduletransparent1:2047"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>.
23652405 The <var>p</var> argument specifies the predicate, and should be the
23662406 result of a call to <a class="func" href="foreigninclude.html#PL_pred()">PL_pred()</a>
23672407 or <a class="func" href="foreigninclude.html#PL_predicate()">PL_predicate()</a>.
23792419 <dd class="defbody">
23802420 Normal operation. The debugger inherits its settings from the
23812421 environment. If an exception occurs that is not handled in Prolog, a
2382 message is printed and the tracer is started to debug the error.<sup class="fn">171<span class="fn-text">Do
2422 message is printed and the tracer is started to debug the error.<sup class="fn">172<span class="fn-text">Do
23832423 not pass the integer 0 for normal operation, as this is interpreted as <code>PL_Q_NODEBUG</code>
23842424 for backward compatibility reasons.</span></sup>
23852425 </dd>
23862426 <dt><b><code>PL_Q_NODEBUG</code></b></dt>
23872427 <dd class="defbody">
23882428 Switch off the debugger while executing the goal. This option is used by
2389 many calls to hook-predicates to avoid tracing the hooks. An example is <a name="idx:print1:2044"></a><a class="pred" href="termrw.html#print/1">print/1</a>
2390 calling <a name="idx:portray1:2045"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
2429 many calls to hook-predicates to avoid tracing the hooks. An example is <a id="idx:print1:2048"></a><a class="pred" href="termrw.html#print/1">print/1</a>
2430 calling <a id="idx:portray1:2049"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
23912431 from foreign code.
23922432 </dd>
23932433 <dt><b><code>PL_Q_CATCH_EXCEPTION</code></b></dt>
24132453 <code>TRUE</code> or <code>FALSE</code> extended status as illustrated
24142454 in the following table:
24152455
2416 <p><table border="0" frame="void" rules="groups" style="margin:auto">
2417 <tr valign="top"><td><b>Extended</b></td><td><b>Normal</b></td></tr>
2418 <tbody>
2419 <tr valign="top"><td>PL_S_EXCEPTION</td><td>FALSE</td><td>Exception
2456 <p><table class="latex frame-void center">
2457 <tr><td><b>Extended</b></td><td><b>Normal</b></td></tr>
2458 <tr class="hline"><td>PL_S_EXCEPTION</td><td>FALSE</td><td>Exception
24202459 available through <a class="func" href="foreigninclude.html#PL_exception()">PL_exception()</a> </td></tr>
2421 <tr valign="top"><td>PL_S_FALSE</td><td>FALSE</td><td>Query failed </td></tr>
2422 <tr valign="top"><td>PL_S_TRUE</td><td>TRUE</td><td>Query succeeded with
2460 <tr><td>PL_S_FALSE</td><td>FALSE</td><td>Query failed </td></tr>
2461 <tr><td>PL_S_TRUE</td><td>TRUE</td><td>Query succeeded with choicepoint </td></tr>
2462 <tr><td>PL_S_LAST</td><td>TRUE</td><td>Query succeeded without
24232463 choicepoint </td></tr>
2424 <tr valign="top"><td>PL_S_LAST</td><td>TRUE</td><td>Query succeeded
2425 without choicepoint </td></tr>
24262464 </table>
24272465 </dd>
24282466 </dl>
24542492 </pre>
24552493
24562494 </dd>
2457 <dt class="pubdef"><a name="PL_next_solution()"><var>int</var> <strong>PL_next_solution</strong>(<var>qid_t
2495 <dt class="pubdef"><a id="PL_next_solution()"><var>int</var> <strong>PL_next_solution</strong>(<var>qid_t
24582496 qid</var>)</a></dt>
24592497 <dd class="defbody">
24602498 Generate the first (next) solution for the given query. The return value
24622500 indicate the query could not be proven. This function may be called
24632501 repeatedly until it fails to generate all solutions to the query.
24642502 </dd>
2465 <dt class="pubdef"><a name="PL_cut_query()"><var>void</var> <strong>PL_cut_query</strong>(<var>qid_t
2503 <dt class="pubdef"><a id="PL_cut_query()"><var>void</var> <strong>PL_cut_query</strong>(<var>qid_t
24662504 qid</var>)</a></dt>
24672505 <dd class="defbody">
24682506 Discards the query, but does not delete any of the data created by the
24692507 query. It just invalidates <var>qid</var>, allowing for a new call to
24702508 <a class="func" href="foreigninclude.html#PL_open_query()">PL_open_query()</a>
24712509 in this context.</dd>
2472 <dt class="pubdef"><a name="PL_close_query()"><var>void</var> <strong>PL_close_query</strong>(<var>qid_t
2510 <dt class="pubdef"><a id="PL_close_query()"><var>void</var> <strong>PL_close_query</strong>(<var>qid_t
24732511 qid</var>)</a></dt>
24742512 <dd class="defbody">
24752513 As <a class="func" href="foreigninclude.html#PL_cut_query()">PL_cut_query()</a>,
24762514 but all data and bindings created by the query are destroyed.</dd>
2477 <dt class="pubdef"><a name="PL_current_query()"><var>qid_t</var> <strong>PL_current_query</strong>(<var>void</var>)</a></dt>
2515 <dt class="pubdef"><a id="PL_current_query()"><var>qid_t</var> <strong>PL_current_query</strong>(<var>void</var>)</a></dt>
24782516 <dd class="defbody">
24792517 Returns the query id of of the current query or <code>0</code> if the
24802518 current thread is not executing any queries.</dd>
2481 <dt class="pubdef"><a name="PL_call_predicate()"><var>int</var> <strong>PL_call_predicate</strong>(<var>module_t
2519 <dt class="pubdef"><a id="PL_call_predicate()"><var>int</var> <strong>PL_call_predicate</strong>(<var>module_t
24822520 m, int flags, predicate_t pred, term_t +t0</var>)</a></dt>
24832521 <dd class="defbody">
24842522 Shorthand for <a class="func" href="foreigninclude.html#PL_open_query()">PL_open_query()</a>, <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>, <a class="func" href="foreigninclude.html#PL_cut_query()">PL_cut_query()</a>,
24862524 <a class="func" href="foreigninclude.html#PL_open_query()">PL_open_query()</a>,
24872525 the return value is the same as <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>.
24882526 </dd>
2489 <dt class="pubdef"><a name="PL_call()"><var>int</var> <strong>PL_call</strong>(<var>term_t
2527 <dt class="pubdef"><a id="PL_call()"><var>int</var> <strong>PL_call</strong>(<var>term_t
24902528 t, module_t m</var>)</a></dt>
24912529 <dd class="defbody">
2492 Call term <var>t</var> just like the Prolog predicate <a name="idx:once1:2046"></a><a class="pred" href="metacall.html#once/1">once/1</a>. <var>t</var>
2530 Call term <var>t</var> just like the Prolog predicate <a id="idx:once1:2050"></a><a class="pred" href="metacall.html#once/1">once/1</a>. <var>t</var>
24932531 is called in the module <var>m</var>, or in the context module if <var>m</var>
24942532 == NULL. Returns <code>TRUE</code> if the call succeeds, <code>FALSE</code>
24952533 otherwise.
24992537 </dd>
25002538 </dl>
25012539
2502 <p><h3 id="sec:foreign-discard-term-t"><a name="sec:11.4.10"><span class="sec-nr">11.4.10</span> <span class="sec-title">Discarding
2540 <p><h3 id="sec:foreign-discard-term-t"><a id="sec:11.4.10"><span class="sec-nr">11.4.10</span> <span class="sec-title">Discarding
25032541 Data</span></a></h3>
25042542
2505 <a name="sec:foreign-discard-term-t"></a>
2543 <a id="sec:foreign-discard-term-t"></a>
25062544
25072545 <p>The Prolog data created and term references needed to set up the call
25082546 and/or analyse the result can in most cases be discarded right after the
25122550 8</a> for an example.
25132551
25142552 <dl class="latex">
2515 <dt class="pubdef"><a name="PL_open_foreign_frame()"><var>fid_t</var> <strong>PL_open_foreign_frame</strong>(<var></var>)</a></dt>
2553 <dt class="pubdef"><a id="PL_open_foreign_frame()"><var>fid_t</var> <strong>PL_open_foreign_frame</strong>(<var></var>)</a></dt>
25162554 <dd class="defbody">
25172555 Create a foreign frame, holding a mark that allows the system to undo
25182556 bindings and destroy data created after it, as well as providing the
25192557 environment for creating term references. This function is called by the
25202558 kernel before calling a foreign predicate.
25212559 </dd>
2522 <dt class="pubdef"><a name="PL_close_foreign_frame()"><var>void</var> <strong>PL_close_foreign_frame</strong>(<var>fid_t
2560 <dt class="pubdef"><a id="PL_close_foreign_frame()"><var>void</var> <strong>PL_close_foreign_frame</strong>(<var>fid_t
25232561 id</var>)</a></dt>
25242562 <dd class="defbody">
25252563 Discard all term references created after the frame was opened. All
25262564 other Prolog data is retained. This function is called by the kernel
25272565 whenever a foreign function returns control back to Prolog.
25282566 </dd>
2529 <dt class="pubdef"><a name="PL_discard_foreign_frame()"><var>void</var> <strong>PL_discard_foreign_frame</strong>(<var>fid_t
2567 <dt class="pubdef"><a id="PL_discard_foreign_frame()"><var>void</var> <strong>PL_discard_foreign_frame</strong>(<var>fid_t
25302568 id</var>)</a></dt>
25312569 <dd class="defbody">
25322570 Same as <a class="func" href="foreigninclude.html#PL_close_foreign_frame()">PL_close_foreign_frame()</a>,
25332571 but also undo all bindings made since the open and destroy all Prolog
25342572 data.
25352573 </dd>
2536 <dt class="pubdef"><a name="PL_rewind_foreign_frame()"><var>void</var> <strong>PL_rewind_foreign_frame</strong>(<var>fid_t
2574 <dt class="pubdef"><a id="PL_rewind_foreign_frame()"><var>void</var> <strong>PL_rewind_foreign_frame</strong>(<var>fid_t
25372575 id</var>)</a></dt>
25382576 <dd class="defbody">
25392577 Undo all bindings and discard all term references created since the
25672605 </pre>
25682606
25692607 <div class="caption"><b>Figure 8 : </b>Calling Prolog</div>
2570 <a name="fig:calling"></a>
2571
2572 <p><h3 id="sec:foreign-modules"><a name="sec:11.4.11"><span class="sec-nr">11.4.11</span> <span class="sec-title">Foreign
2608 <a id="fig:calling"></a>
2609
2610 <p><h3 id="sec:foreign-modules"><a id="sec:11.4.11"><span class="sec-nr">11.4.11</span> <span class="sec-title">Foreign
25732611 Code and Modules</span></a></h3>
25742612
2575 <a name="sec:foreign-modules"></a>
2613 <a id="sec:foreign-modules"></a>
25762614
25772615 <p>Modules are identified via a unique handle. The following functions
25782616 are available to query and manipulate modules.
25792617
25802618 <dl class="latex">
2581 <dt class="pubdef"><a name="PL_context()"><var>module_t</var> <strong>PL_context</strong>(<var></var>)</a></dt>
2619 <dt class="pubdef"><a id="PL_context()"><var>module_t</var> <strong>PL_context</strong>(<var></var>)</a></dt>
25822620 <dd class="defbody">
25832621 Return the module identifier of the context module of the currently
25842622 active foreign predicate.</dd>
2585 <dt class="pubdef"><a name="PL_strip_module()"><var>int</var> <strong>PL_strip_module</strong>(<var>term_t
2623 <dt class="pubdef"><a id="PL_strip_module()"><var>int</var> <strong>PL_strip_module</strong>(<var>term_t
25862624 +raw, module_t *m, term_t -plain</var>)</a></dt>
25872625 <dd class="defbody">
25882626 Utility function. If <var>raw</var> is a term, possibly holding the
26082646 </pre>
26092647
26102648 </dd>
2611 <dt class="pubdef"><a name="PL_module_name()"><var>atom_t</var> <strong>PL_module_name</strong>(<var>module_t
2649 <dt class="pubdef"><a id="PL_module_name()"><var>atom_t</var> <strong>PL_module_name</strong>(<var>module_t
26122650 module</var>)</a></dt>
26132651 <dd class="defbody">
26142652 Return the name of <var>module</var> as an atom.
26152653 </dd>
2616 <dt class="pubdef"><a name="PL_new_module()"><var>module_t</var> <strong>PL_new_module</strong>(<var>atom_t
2654 <dt class="pubdef"><a id="PL_new_module()"><var>module_t</var> <strong>PL_new_module</strong>(<var>atom_t
26172655 name</var>)</a></dt>
26182656 <dd class="defbody">
26192657 Find an existing module or create a new module with the name <var>name</var>.
26202658 </dd>
26212659 </dl>
26222660
2623 <p><h3 id="sec:foreign-exceptions"><a name="sec:11.4.12"><span class="sec-nr">11.4.12</span> <span class="sec-title">Prolog
2661 <p><h3 id="sec:foreign-exceptions"><a id="sec:11.4.12"><span class="sec-nr">11.4.12</span> <span class="sec-title">Prolog
26242662 exceptions in foreign code</span></a></h3>
26252663
2626 <a name="sec:foreign-exceptions"></a>
2664 <a id="sec:foreign-exceptions"></a>
26272665
26282666 <p>This section discusses <a class="func" href="foreigninclude.html#PL_exception()">PL_exception()</a>, <a class="func" href="foreigninclude.html#PL_throw()">PL_throw()</a>
26292667 and
26542692 or
26552693 <a class="func" href="foreigninclude.html#PL_discard_foreign_frame()">PL_discard_foreign_frame()</a>
26562694 afterwards, as this will invalidate the exception term. Below is the
2657 code that calls a Prolog-defined arithmetic function (see <a name="idx:arithmeticfunction1:2047"></a><span class="pred-ext">arithmetic_function/1</span>).
2695 code that calls a Prolog-defined arithmetic function (see <a id="idx:arithmeticfunction1:2051"></a><span class="pred-ext">arithmetic_function/1</span>).
26582696
26592697 <p>If <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>
26602698 succeeds, the result is analysed and translated to a number, after which
27042742 </pre>
27052743
27062744 <dl class="latex">
2707 <dt class="pubdef"><a name="PL_raise_exception()"><var>int</var> <strong>PL_raise_exception</strong>(<var>term_t
2745 <dt class="pubdef"><a id="PL_raise_exception()"><var>int</var> <strong>PL_raise_exception</strong>(<var>term_t
27082746 exception</var>)</a></dt>
27092747 <dd class="defbody">
2710 Generate an exception (as <a name="idx:throw1:2048"></a><a class="pred" href="exception.html#throw/1">throw/1</a>)
2748 Generate an exception (as <a id="idx:throw1:2052"></a><a class="pred" href="exception.html#throw/1">throw/1</a>)
27112749 and return <code>FALSE</code>. Below is an example returning an
27122750 exception from a foreign predicate:
27132751
27342772 </pre>
27352773
27362774 </dd>
2737 <dt class="pubdef"><a name="PL_throw()"><var>int</var> <strong>PL_throw</strong>(<var>term_t
2775 <dt class="pubdef"><a id="PL_throw()"><var>int</var> <strong>PL_throw</strong>(<var>term_t
27382776 exception</var>)</a></dt>
27392777 <dd class="defbody">
27402778 Similar to <a class="func" href="foreigninclude.html#PL_raise_exception()">PL_raise_exception()</a>,
27412779 but returns using the C longjmp() function to the innermost <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>.</dd>
2742 <dt class="pubdef"><a name="PL_exception()"><var>term_t</var> <strong>PL_exception</strong>(<var>qid_t
2780 <dt class="pubdef"><a id="PL_exception()"><var>term_t</var> <strong>PL_exception</strong>(<var>qid_t
27432781 qid</var>)</a></dt>
27442782 <dd class="defbody">
27452783 If <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>
27462784 fails, this can be due to normal failure of the Prolog call, or because
2747 an exception was raised using <a name="idx:throw1:2049"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
2785 an exception was raised using <a id="idx:throw1:2053"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
27482786 This function returns a handle to the exception term if an exception was
27492787 raised, or 0 if the Prolog goal simply failed. If there is an exception,
27502788 <a class="func" href="foreigninclude.html#PL_exception()">PL_exception()</a>
27552793 pending exception in the current query or 0 if no exception is pending.
27562794 This can be used to check the error status after a failing call to,
27572795 e.g., one of the unification functions.</dd>
2758 <dt class="pubdef"><a name="PL_clear_exception()"><var>void</var> <strong>PL_clear_exception</strong>(<var>void</var>)</a></dt>
2796 <dt class="pubdef"><a id="PL_clear_exception()"><var>void</var> <strong>PL_clear_exception</strong>(<var>void</var>)</a></dt>
27592797 <dd class="defbody">
27602798 Tells Prolog that the encountered exception must be ignored. This
27612799 function must be called if control remains in C after a previous API
2762 call fails with an exception.<sup class="fn">172<span class="fn-text">This
2800 call fails with an exception.<sup class="fn">173<span class="fn-text">This
27632801 feature is non-portable. Other Prolog systems (e.g., YAP) have no
27642802 facilities to ignore raised exceptions, and the design of YAP's
27652803 exception handling does not support such a facility.</span></sup>
27662804 </dd>
27672805 </dl>
27682806
2769 <p><h3 id="sec:csignal"><a name="sec:11.4.13"><span class="sec-nr">11.4.13</span> <span class="sec-title">Catching
2807 <p><h3 id="sec:csignal"><a id="sec:11.4.13"><span class="sec-nr">11.4.13</span> <span class="sec-title">Catching
27702808 Signals (Software Interrupts)</span></a></h3>
27712809
2772 <a name="sec:csignal"></a>
2810 <a id="sec:csignal"></a>
27732811
27742812 <p>SWI-Prolog offers both a C and Prolog interface to deal with software
27752813 interrupts (signals). The Prolog mapping is defined in
2776 <a class="sec" href="signal.html">section 4.12</a>. This subsection
2777 deals with handling signals from C.
2814 <a class="sec" href="signal.html#sec:4.12">section 4.12</a>. This
2815 subsection deals with handling signals from C.
27782816
27792817 <p>If a signal is not used by Prolog and the handler does not call
27802818 Prolog in any way, the native signal interface routines may be used.
27872825 Prolog.
27882826
27892827 <dl class="latex">
2790 <dt class="pubdef"><a name="PL_sigaction()"><var>int</var> <strong>PL_sigaction</strong>(<var>int
2828 <dt class="pubdef"><a id="PL_sigaction()"><var>int</var> <strong>PL_sigaction</strong>(<var>int
27912829 sig, pl_sigaction_t *act, pl_sigaction_t *oldact</var>)</a></dt>
27922830 <dd class="defbody">
27932831 Install or query the status for signal <var>sig</var>. The signal is an
28182856 <p>Finally, 0 (zero) may be passsed for <var>sig</var>. In that case the
28192857 system allocates a free signal in the <i>Prolog range</i> (32 ... 64).
28202858 Such signal handler are activated using <b>PL_thread_raise()</b>.</dd>
2821 <dt class="pubdef"><a name="PL_signal()"><var>void (*)()</var> <strong>PL_signal</strong>(<var>sig,
2859 <dt class="pubdef"><a id="PL_signal()"><var>void (*)()</var> <strong>PL_signal</strong>(<var>sig,
28222860 func</var>)</a></dt>
28232861 <dd class="defbody">
28242862 This function is equivalent to the BSD-Unix signal() function,
28412879 which is checked by <a class="func" href="foreigninclude.html#PL_handle_signals()">PL_handle_signals()</a>
28422880 at the call- and redo-port. This behaviour is realised by <em>or</em>-ing <var>sig</var>
28432881 with the constant
2844 <code>PL_SIGSYNC</code>.<sup class="fn">173<span class="fn-text">A
2882 <code>PL_SIGSYNC</code>.<sup class="fn">174<span class="fn-text">A
28452883 better default would be to use synchronous handling, but this interface
28462884 preserves backward compatibility.</span></sup>
28472885
28502888 The use of <a class="func" href="foreigninclude.html#PL_throw()">PL_throw()</a>
28512889 is not safe. If a synchronous handler raises an exception, the exception
28522890 is delayed to the next call to <a class="func" href="foreigninclude.html#PL_handle_signals()">PL_handle_signals()</a>;</dd>
2853 <dt class="pubdef"><a name="PL_raise()"><var>int</var> <strong>PL_raise</strong>(<var>int
2891 <dt class="pubdef"><a id="PL_raise()"><var>int</var> <strong>PL_raise</strong>(<var>int
28542892 sig</var>)</a></dt>
28552893 <dd class="defbody">
28562894 Register <var>sig</var> for <em>synchronous</em> handling by Prolog.
28572895 Synchronous signals are handled at the call-port or if foreign code
28582896 calls <a class="func" href="foreigninclude.html#PL_handle_signals()">PL_handle_signals()</a>.
2859 See also <a name="idx:threadsignal2:2050"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.</dd>
2860 <dt class="pubdef"><a name="PL_handle_signals()"><var>int</var> <strong>PL_handle_signals</strong>(<var>void</var>)</a></dt>
2897 See also <a id="idx:threadsignal2:2054"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.</dd>
2898 <dt class="pubdef"><a id="PL_handle_signals()"><var>int</var> <strong>PL_handle_signals</strong>(<var>void</var>)</a></dt>
28612899 <dd class="defbody">
28622900 Handle any signals pending from <a class="func" href="foreigninclude.html#PL_raise()">PL_raise()</a>. <a class="func" href="foreigninclude.html#PL_handle_signals()">PL_handle_signals()</a>
28632901 is called at each pass through the call- and redo-port at a safe point.
28692907 signals handled. If a handler raises an exception, the return value is
28702908 -1 and the calling routine should return with <code>FALSE</code> as soon
28712909 as possible.</dd>
2872 <dt class="pubdef"><a name="PL_get_signum_ex()"><var>int</var> <strong>PL_get_signum_ex</strong>(<var>term_t
2910 <dt class="pubdef"><a id="PL_get_signum_ex()"><var>int</var> <strong>PL_get_signum_ex</strong>(<var>term_t
28732911 t, int *sig</var>)</a></dt>
28742912 <dd class="defbody">
28752913 Extract a signal specification from a Prolog term and store as an
28812919 </dd>
28822920 </dl>
28832921
2884 <p><h3 id="sec:foreign-misc"><a name="sec:11.4.14"><span class="sec-nr">11.4.14</span> <span class="sec-title">Miscellaneous</span></a></h3>
2885
2886 <a name="sec:foreign-misc"></a>
2887
2888 <p><h4 id="sec:foreign-compare"><a name="sec:11.4.14.1"><span class="sec-nr">11.4.14.1</span> <span class="sec-title">Term
2922 <p><h3 id="sec:foreign-misc"><a id="sec:11.4.14"><span class="sec-nr">11.4.14</span> <span class="sec-title">Miscellaneous</span></a></h3>
2923
2924 <a id="sec:foreign-misc"></a>
2925
2926 <p><h4 id="sec:foreign-compare"><a id="sec:11.4.14.1"><span class="sec-nr">11.4.14.1</span> <span class="sec-title">Term
28892927 Comparison</span></a></h4>
28902928
2891 <a name="sec:foreign-compare"></a>
2892
2893 <dl class="latex">
2894 <dt class="pubdef"><a name="PL_compare()"><var>int</var> <strong>PL_compare</strong>(<var>term_t
2929 <a id="sec:foreign-compare"></a>
2930
2931 <dl class="latex">
2932 <dt class="pubdef"><a id="PL_compare()"><var>int</var> <strong>PL_compare</strong>(<var>term_t
28952933 t1, term_t t2</var>)</a></dt>
28962934 <dd class="defbody">
28972935 Compares two terms using the standard order of terms and returns -1, 0
2898 or 1. See also <a name="idx:compare3:2051"></a><a class="pred" href="compare.html#compare/3">compare/3</a>.
2899 </dd>
2900 <dt class="pubdef"><a name="PL_same_compound()"><var>int</var> <strong>PL_same_compound</strong>(<var>term_t
2936 or 1. See also <a id="idx:compare3:2055"></a><a class="pred" href="compare.html#compare/3">compare/3</a>.
2937 </dd>
2938 <dt class="pubdef"><a id="PL_same_compound()"><var>int</var> <strong>PL_same_compound</strong>(<var>term_t
29012939 t1, term_t t2</var>)</a></dt>
29022940 <dd class="defbody">
29032941 Yields <code>TRUE</code> if <var>t1</var> and <var>t2</var> refer to
29052943 </dd>
29062944 </dl>
29072945
2908 <p><h4 id="sec:foreign-recorded"><a name="sec:11.4.14.2"><span class="sec-nr">11.4.14.2</span> <span class="sec-title">Recorded
2946 <p><h4 id="sec:foreign-recorded"><a id="sec:11.4.14.2"><span class="sec-nr">11.4.14.2</span> <span class="sec-title">Recorded
29092947 database</span></a></h4>
29102948
2911 <a name="sec:foreign-recorded"></a>
2949 <a id="sec:foreign-recorded"></a>
29122950
29132951 <p>In some applications it is useful to store and retrieve Prolog terms
29142952 from C code. For example, the XPCE graphical environment does this for
29222960
29232961 <p>Two groups of functions are provided. The first group (<a class="func" href="foreigninclude.html#PL_record()">PL_record()</a>
29242962 and friends) store Prolog terms on the Prolog heap for retrieval during
2925 the same session. These functions are also used by <a name="idx:recorda3:2052"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
2963 the same session. These functions are also used by <a id="idx:recorda3:2056"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
29262964 and friends. The recorded database may be used to communicate Prolog
29272965 terms between threads.
29282966
29292967 <dl class="latex">
2930 <dt class="pubdef"><a name="PL_record()"><var>record_t</var> <strong>PL_record</strong>(<var>term_t
2968 <dt class="pubdef"><a id="PL_record()"><var>record_t</var> <strong>PL_record</strong>(<var>term_t
29312969 +t</var>)</a></dt>
29322970 <dd class="defbody">
2933 Record the term <var>t</var> into the Prolog database as <a name="idx:recorda3:2053"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
2971 Record the term <var>t</var> into the Prolog database as <a id="idx:recorda3:2057"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
29342972 and return an opaque handle to the term. The returned handle remains
29352973 valid until <a class="func" href="foreigninclude.html#PL_erase()">PL_erase()</a>
29362974 is called on it. <a class="func" href="foreigninclude.html#PL_recorded()">PL_recorded()</a>
29372975 is used to copy recorded terms back to the Prolog stack.</dd>
2938 <dt class="pubdef"><a name="PL_duplicate_record()"><var>record_t</var> <strong>PL_duplicate_record</strong>(<var>record_t
2976 <dt class="pubdef"><a id="PL_duplicate_record()"><var>record_t</var> <strong>PL_duplicate_record</strong>(<var>record_t
29392977 record</var>)</a></dt>
29402978 <dd class="defbody">
29412979 Return a duplicate of <var>record</var>. As records are read-only
29422980 objects this function merely increments the records reference count.</dd>
2943 <dt class="pubdef"><a name="PL_recorded()"><var>int</var> <strong>PL_recorded</strong>(<var>record_t
2981 <dt class="pubdef"><a id="PL_recorded()"><var>int</var> <strong>PL_recorded</strong>(<var>record_t
29442982 record, term_t -t</var>)</a></dt>
29452983 <dd class="defbody">
29462984 Copy a recorded term back to the Prolog stack. The same record may be
29482986 on success, and <code>FALSE</code> if there is not enough space on the
29492987 stack to accommodate the term. See also <a class="func" href="foreigninclude.html#PL_record()">PL_record()</a>
29502988 and <a class="func" href="foreigninclude.html#PL_erase()">PL_erase()</a>.</dd>
2951 <dt class="pubdef"><a name="PL_erase()"><var>void</var> <strong>PL_erase</strong>(<var>record_t
2989 <dt class="pubdef"><a id="PL_erase()"><var>void</var> <strong>PL_erase</strong>(<var>record_t
29522990 record</var>)</a></dt>
29532991 <dd class="defbody">
29542992 Remove the recorded term from the Prolog database, reclaiming all
29873025 </ul>
29883026
29893027 <dl class="latex">
2990 <dt class="pubdef"><a name="PL_record_external()"><var>char *</var> <strong>PL_record_external</strong>(<var>term_t
3028 <dt class="pubdef"><a id="PL_record_external()"><var>char *</var> <strong>PL_record_external</strong>(<var>term_t
29913029 +t, size_t *len</var>)</a></dt>
29923030 <dd class="defbody">
2993 Record the term <var>t</var> into the Prolog database as <a name="idx:recorda3:2054"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
3031 Record the term <var>t</var> into the Prolog database as <a id="idx:recorda3:2058"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
29943032 and return an opaque handle to the term. The returned handle remains
29953033 valid until <a class="func" href="foreigninclude.html#PL_erase_external()">PL_erase_external()</a>
29963034 is called on it.
30033041 <p><a class="func" href="foreigninclude.html#PL_recorded_external()">PL_recorded_external()</a>
30043042 is used to copy such recorded terms back to the Prolog stack.
30053043 </dd>
3006 <dt class="pubdef"><a name="PL_recorded_external()"><var>int</var> <strong>PL_recorded_external</strong>(<var>const
3044 <dt class="pubdef"><a id="PL_recorded_external()"><var>int</var> <strong>PL_recorded_external</strong>(<var>const
30073045 char *record, term_t -t</var>)</a></dt>
30083046 <dd class="defbody">
30093047 Copy a recorded term back to the Prolog stack. The same record may be
30113049 also <a class="func" href="foreigninclude.html#PL_record_external()">PL_record_external()</a>
30123050 and <a class="func" href="foreigninclude.html#PL_erase_external()">PL_erase_external()</a>.
30133051 </dd>
3014 <dt class="pubdef"><a name="PL_erase_external()"><var>int</var> <strong>PL_erase_external</strong>(<var>char
3052 <dt class="pubdef"><a id="PL_erase_external()"><var>int</var> <strong>PL_erase_external</strong>(<var>char
30153053 *record</var>)</a></dt>
30163054 <dd class="defbody">
30173055 Remove the recorded term from the Prolog database, reclaiming all
30193057 </dd>
30203058 </dl>
30213059
3022 <p><h4 id="sec:cfilenames"><a name="sec:11.4.14.3"><span class="sec-nr">11.4.14.3</span> <span class="sec-title">Getting
3060 <p><h4 id="sec:cfilenames"><a id="sec:11.4.14.3"><span class="sec-nr">11.4.14.3</span> <span class="sec-title">Getting
30233061 file names</span></a></h4>
30243062
3025 <a name="sec:cfilenames"></a>
3063 <a id="sec:cfilenames"></a>
30263064
30273065 <p>The function <a class="func" href="foreigninclude.html#PL_get_file_name()">PL_get_file_name()</a>
30283066 provides access to Prolog filenames and its file-search mechanism
3029 described with <a name="idx:absolutefilename3:2055"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
3067 described with <a id="idx:absolutefilename3:2059"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
30303068 Its existence is motivated to realise a uniform interface to deal with
30313069 file properties, search, naming conventions, etc., from foreign code.
30323070
30333071 <dl class="latex">
3034 <dt class="pubdef"><a name="PL_get_file_name()"><var>int</var> <strong>PL_get_file_name</strong>(<var>term_t
3072 <dt class="pubdef"><a id="PL_get_file_name()"><var>int</var> <strong>PL_get_file_name</strong>(<var>term_t
30353073 spec, char **name, int flags</var>)</a></dt>
30363074 <dd class="defbody">
30373075 Translate a Prolog term into a file name. The name is stored in the
30553093 </dd>
30563094 <dt><b><code>PL_FILE_SEARCH</code></b></dt>
30573095 <dd class="defbody">
3058 Invoke <a name="idx:absolutefilename3:2056"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
3059 This implies rules from <a name="idx:filesearchpath2:2057"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
3096 Invoke <a id="idx:absolutefilename3:2060"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
3097 This implies rules from <a id="idx:filesearchpath2:2061"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
30603098 are used.
30613099 </dd>
30623100 <dt><b><code>PL_FILE_EXIST</code></b></dt>
30823120 </dl>
30833121
30843122 </dd>
3085 <dt class="pubdef"><a name="PL_get_file_nameW()"><var>int</var> <strong>PL_get_file_nameW</strong>(<var>term_t
3123 <dt class="pubdef"><a id="PL_get_file_nameW()"><var>int</var> <strong>PL_get_file_nameW</strong>(<var>term_t
30863124 spec, wchar_t **name, int flags</var>)</a></dt>
30873125 <dd class="defbody">
30883126 Same as <a class="func" href="foreigninclude.html#PL_get_file_name()">PL_get_file_name()</a>,
30933131 </dd>
30943132 </dl>
30953133
3096 <p><h4 id="sec:cprologflags"><a name="sec:11.4.14.4"><span class="sec-nr">11.4.14.4</span> <span class="sec-title">Dealing
3134 <p><h4 id="sec:cprologflags"><a id="sec:11.4.14.4"><span class="sec-nr">11.4.14.4</span> <span class="sec-title">Dealing
30973135 with Prolog flags from C</span></a></h4>
30983136
3099 <a name="sec:cprologflags"></a>
3137 <a id="sec:cprologflags"></a>
31003138
31013139 <p>Foreign code can set or create Prolog flags using <a class="func" href="foreigninclude.html#PL_set_prolog_flag()">PL_set_prolog_flag()</a>.
3102 See <a name="idx:setprologflag2:2058"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
3103 and <a name="idx:createprologflag3:2059"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>.<sup class="fn">174<span class="fn-text">The
3140 See <a id="idx:setprologflag2:2062"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
3141 and <a id="idx:createprologflag3:2063"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>.<sup class="fn">175<span class="fn-text">The
31043142 current C API does not provide for a dedicated mechanism for fetching
31053143 the value of Prolog flags. Relatively slow access is provided by calling <a class="func" href="foreigninclude.html#PL_call_predicate()">PL_call_predicate()</a>
3106 using <a name="idx:currentprologflag2:2060"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.</span></sup>
3107
3108 <dl class="latex">
3109 <dt class="pubdef"><a name="PL_set_prolog_flag()"><var>int</var> <strong>PL_set_prolog_flag</strong>(<var>const
3144 using <a id="idx:currentprologflag2:2064"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.</span></sup>
3145
3146 <dl class="latex">
3147 <dt class="pubdef"><a id="PL_set_prolog_flag()"><var>int</var> <strong>PL_set_prolog_flag</strong>(<var>const
31103148 char *name, int type, ...</var>)</a></dt>
31113149 <dd class="defbody">
31123150 Set/create a Prolog flag from C. <var>name</var> is the name of the
31373175 </dd>
31383176 </dl>
31393177
3140 <p><h3 id="sec:foreign-print-warning"><a name="sec:11.4.15"><span class="sec-nr">11.4.15</span> <span class="sec-title">Errors
3178 <p><h3 id="sec:foreign-print-warning"><a id="sec:11.4.15"><span class="sec-nr">11.4.15</span> <span class="sec-title">Errors
31413179 and warnings</span></a></h3>
31423180
3143 <a name="sec:foreign-print-warning"></a>
3181 <a id="sec:foreign-print-warning"></a>
31443182
31453183 <p><a class="func" href="foreigninclude.html#PL_warning()">PL_warning()</a>
31463184 prints a standard Prolog warning message to the standard error (<code>user_error</code>)
31473185 stream. Please note that new code should consider using <a class="func" href="foreigninclude.html#PL_raise_exception()">PL_raise_exception()</a>
3148 to raise a Prolog exception. See also <a class="sec" href="exception.html">section
3186 to raise a Prolog exception. See also <a class="sec" href="exception.html#sec:4.11">section
31493187 4.11</a>.
31503188
31513189 <dl class="latex">
3152 <dt class="pubdef"><a name="PL_warning()"><var>int</var> <strong>PL_warning</strong>(<var>format,
3190 <dt class="pubdef"><a id="PL_warning()"><var>int</var> <strong>PL_warning</strong>(<var>format,
31533191 a1, ...</var>)</a></dt>
31543192 <dd class="defbody">
31553193 Print an error message starting with `<code>[WARNING: </code>', followed
31593197 </dd>
31603198 </dl>
31613199
3162 <p><h3 id="sec:foreign-control-prolog"><a name="sec:11.4.16"><span class="sec-nr">11.4.16</span> <span class="sec-title">Environment
3200 <p><h3 id="sec:foreign-control-prolog"><a id="sec:11.4.16"><span class="sec-nr">11.4.16</span> <span class="sec-title">Environment
31633201 Control from Foreign Code</span></a></h3>
31643202
3165 <a name="sec:foreign-control-prolog"></a>
3166
3167 <dl class="latex">
3168 <dt class="pubdef"><a name="PL_action()"><var>int</var> <strong>PL_action</strong>(<var>int,
3203 <a id="sec:foreign-control-prolog"></a>
3204
3205 <dl class="latex">
3206 <dt class="pubdef"><a id="PL_action()"><var>int</var> <strong>PL_action</strong>(<var>int,
31693207 ...</var>)</a></dt>
31703208 <dd class="defbody">
31713209 Perform some action on the Prolog system. <var>int</var> describes the
31753213 <dl class="latex">
31763214 <dt><strong>PL_ACTION_TRACE</strong></dt>
31773215 <dd class="defbody">
3178 Start Prolog tracer (<a name="idx:trace0:2061"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>).
3216 Start Prolog tracer (<a id="idx:trace0:2065"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>).
31793217 Requires no arguments.</dd>
31803218 <dt><strong>PL_ACTION_DEBUG</strong></dt>
31813219 <dd class="defbody">
3182 Switch on Prolog debug mode (<a name="idx:debug0:2062"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>).
3220 Switch on Prolog debug mode (<a id="idx:debug0:2066"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>).
31833221 Requires no arguments.</dd>
31843222 <dt><strong>PL_ACTION_BACKTRACE</strong></dt>
31853223 <dd class="defbody">
31893227 <dd class="defbody">
31903228 Halt Prolog execution. This action should be called rather than Unix
31913229 exit() to give Prolog the opportunity to clean up. This call does not
3192 return. The argument (an <code>int</code>) is the exit code. See <a name="idx:halt1:2063"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>.</dd>
3230 return. The argument (an <code>int</code>) is the exit code. See <a id="idx:halt1:2067"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>.</dd>
31933231 <dt><strong>PL_ACTION_ABORT</strong></dt>
31943232 <dd class="defbody">
3195 Generate a Prolog abort (<a name="idx:abort0:2064"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
3233 Generate a Prolog abort (<a id="idx:abort0:2068"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
31963234 This call does not return. Requires no arguments.</dd>
31973235 <dt><strong>PL_ACTION_BREAK</strong></dt>
31983236 <dd class="defbody">
3199 Create a standard Prolog break environment (<a name="idx:break0:2065"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
3237 Create a standard Prolog break environment (<a id="idx:break0:2069"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
32003238 Returns after the user types the end-of-file character. Requires no
32013239 arguments.</dd>
32023240 <dt><strong>PL_ACTION_GUIAPP</strong></dt>
32193257 <dt><strong>PL_ACTION_ATTACH_CONSOLE</strong></dt>
32203258 <dd class="defbody">
32213259 Attach a console to a thread if it does not have one. See
3222 <a name="idx:attachconsole0:2066"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.</dd>
3260 <a id="idx:attachconsole0:2070"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.</dd>
32233261 <dt><strong>PL_GMP_SET_ALLOC_FUNCTIONS</strong></dt>
32243262 <dd class="defbody">
32253263 Takes an integer argument. If <code>TRUE</code>, the GMP allocations are
32343272 </dd>
32353273 </dl>
32363274
3237 <p><h3 id="sec:foreign-query"><a name="sec:11.4.17"><span class="sec-nr">11.4.17</span> <span class="sec-title">Querying
3275 <p><h3 id="sec:foreign-query"><a id="sec:11.4.17"><span class="sec-nr">11.4.17</span> <span class="sec-title">Querying
32383276 Prolog</span></a></h3>
32393277
3240 <a name="sec:foreign-query"></a>
3241
3242 <dl class="latex">
3243 <dt class="pubdef"><a name="PL_query()"><var>long</var> <strong>PL_query</strong>(<var>int</var>)</a></dt>
3278 <a id="sec:foreign-query"></a>
3279
3280 <dl class="latex">
3281 <dt class="pubdef"><a id="PL_query()"><var>long</var> <strong>PL_query</strong>(<var>int</var>)</a></dt>
32443282 <dd class="defbody">
32453283 Obtain status information on the Prolog system. The actual argument type
32463284 depends on the information required. <var>int</var> describes what
3247 information is wanted.<sup class="fn">175<span class="fn-text">Returning
3285 information is wanted.<sup class="fn">176<span class="fn-text">Returning
32483286 pointers and integers as a long is bad style. The signature of this
32493287 function should be changed.</span></sup> The options are given in <a class="tab" href="foreigninclude.html#tab:query">table
32503288 9</a>.
3251 <blockquote><table border="2" frame="box" rules="groups">
3252 <tr valign="top"><td><code>PL_QUERY_ARGC</code> </td><td>Return an
3253 integer holding the number of arguments given to Prolog from Unix. </td></tr>
3254 <tr valign="top"><td><code>PL_QUERY_ARGV</code> </td><td>Return a <code>char
3255 **</code> holding the argument vector given to Prolog from Unix. </td></tr>
3256 <tr valign="top"><td><code>PL_QUERY_SYMBOLFILE</code> </td><td>Return a <code>char
3257 *</code> holding the current symbol file of the running process. </td></tr>
3258 <tr valign="top"><td><code>PL_MAX_INTEGER</code> </td><td>Return a long,
3259 representing the maximal integer value represented by a Prolog integer. </td></tr>
3260 <tr valign="top"><td><code>PL_MIN_INTEGER</code> </td><td>Return a long,
3261 representing the minimal integer value. </td></tr>
3262 <tr valign="top"><td><code>PL_QUERY_VERSION</code> </td><td>Return a
3263 long, representing the version as
3289 <blockquote><table class="latex frame-box">
3290 <tr><td><code>PL_QUERY_ARGC</code> </td><td>Return an integer holding
3291 the number of arguments given to Prolog from Unix. </td></tr>
3292 <tr><td><code>PL_QUERY_ARGV</code> </td><td>Return a <code>char **</code>
3293 holding the argument vector given to Prolog from Unix. </td></tr>
3294 <tr><td><code>PL_QUERY_SYMBOLFILE</code> </td><td>Return a <code>char *</code>
3295 holding the current symbol file of the running process. </td></tr>
3296 <tr><td><code>PL_MAX_INTEGER</code> </td><td>Return a long, representing
3297 the maximal integer value represented by a Prolog integer. </td></tr>
3298 <tr><td><code>PL_MIN_INTEGER</code> </td><td>Return a long, representing
3299 the minimal integer value. </td></tr>
3300 <tr><td><code>PL_QUERY_VERSION</code> </td><td>Return a long,
3301 representing the version as
32643302 <var>10,000 &times; M + 100 &times; m + p</var>, where
32653303 <var>M</var> is the major, <var>m</var> the minor version number and <var>p</var>
32663304 the patch level. For example,
32673305 <code>20717</code> means <code>2.7.17</code>. </td></tr>
3268 <tr valign="top"><td><code>PL_QUERY_ENCODING</code> </td><td>Return the
3269 default stream encoding of Prolog (of type <code>IOENC</code>). </td></tr>
3270 <tr valign="top"><td><code>PL_QUERY_USER_CPU</code> </td><td>Get amount
3271 of user CPU time of the process in milliseconds. </td></tr>
3306 <tr><td><code>PL_QUERY_ENCODING</code> </td><td>Return the default
3307 stream encoding of Prolog (of type <code>IOENC</code>). </td></tr>
3308 <tr><td><code>PL_QUERY_USER_CPU</code> </td><td>Get amount of user CPU
3309 time of the process in milliseconds. </td></tr>
32723310 </table>
32733311 </blockquote>
32743312 <div class="caption"><b>Table 9 : </b><a class="func" href="foreigninclude.html#PL_query()">PL_query()</a>
32753313 options</div>
3276 <a name="tab:query"></a>
3277 </dd>
3278 </dl>
3279
3280 <p><h3 id="sec:foreign-register-predicate"><a name="sec:11.4.18"><span class="sec-nr">11.4.18</span> <span class="sec-title">Registering
3314 <a id="tab:query"></a>
3315 </dd>
3316 </dl>
3317
3318 <p><h3 id="sec:foreign-register-predicate"><a id="sec:11.4.18"><span class="sec-nr">11.4.18</span> <span class="sec-title">Registering
32813319 Foreign Predicates</span></a></h3>
32823320
3283 <a name="sec:foreign-register-predicate"></a>
3284
3285 <dl class="latex">
3286 <dt class="pubdef"><a name="PL_register_foreign_in_module()"><var>int</var> <strong>PL_register_foreign_in_module</strong>(<var>char
3321 <a id="sec:foreign-register-predicate"></a>
3322
3323 <dl class="latex">
3324 <dt class="pubdef"><a id="PL_register_foreign_in_module()"><var>int</var> <strong>PL_register_foreign_in_module</strong>(<var>char
32873325 *mod, char *name, int arity, foreign_t (*f)(), int flags, ...</var>)</a></dt>
32883326 <dd class="defbody">
32893327 Register the C function <var>f</var> to implement a Prolog predicate.
32983336 form a bitwise <em>or</em>'ed list of options for the installation.
32993337 These are:
33003338
3301 <p><table border="2" frame="box" rules="groups">
3302 <tr valign="top"><td><code>PL_FA_META</code> </td><td>Provide
3303 meta-predicate info (see below) </td></tr>
3304 <tr valign="top"><td><code>PL_FA_TRANSPARENT</code> </td><td>Predicate
3305 is module transparent (deprecated) </td></tr>
3306 <tr valign="top"><td><code>PL_FA_NONDETERMINISTIC</code> </td><td>Predicate
3307 is non-deterministic. See also <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a>. </td></tr>
3308 <tr valign="top"><td><code>PL_FA_NOTRACE</code> </td><td>Predicate
3309 cannot be seen in the tracer </td></tr>
3310 <tr valign="top"><td><code>PL_FA_VARARGS</code> </td><td>Use alternative
3311 calling convention. </td></tr>
3339 <p><table class="latex frame-box">
3340 <tr><td><code>PL_FA_META</code> </td><td>Provide meta-predicate info
3341 (see below) </td></tr>
3342 <tr><td><code>PL_FA_TRANSPARENT</code> </td><td>Predicate is module
3343 transparent (deprecated) </td></tr>
3344 <tr><td><code>PL_FA_NONDETERMINISTIC</code> </td><td>Predicate is
3345 non-deterministic. See also <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a>. </td></tr>
3346 <tr><td><code>PL_FA_NOTRACE</code> </td><td>Predicate cannot be seen in
3347 the tracer </td></tr>
3348 <tr><td><code>PL_FA_VARARGS</code> </td><td>Use alternative calling
3349 convention. </td></tr>
33123350 </table>
33133351
33143352 <p>If <code>PL_FA_META</code> is provided, <a class="func" href="foreigninclude.html#PL_register_foreign_in_module()">PL_register_foreign_in_module()</a>
33163354 This string must be exactly as long as the number of arguments of the
33173355 predicate and filled with characters from the set <code>0-9:^-+?</code>.
33183356 See
3319 <a name="idx:metapredicate1:2067"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
3357 <a id="idx:metapredicate1:2071"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
33203358 for details. <code>PL_FA_TRANSPARENT</code> is implied if at least one
33213359 meta-argument is provided (<code>0-9:^</code>). Note that meta-arguments
33223360 are <em>not always</em> passed as &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;.
33233361 Always use <a class="func" href="foreigninclude.html#PL_strip_module()">PL_strip_module()</a>
3324 to extract the module and plain term from a meta-argument.<sup class="fn">176<span class="fn-text">It
3362 to extract the module and plain term from a meta-argument.<sup class="fn">177<span class="fn-text">It
33253363 is encouraged to pass an additional <code>NULL</code> pointer for
33263364 non-meta-predicates.</span></sup>
33273365
33343372 is passed the same number of <code>term_t</code> arguments as the arity
33353373 of the predicate and, if the predicate is non-deterministic, an extra
33363374 argument of type
3337 <code>control_t</code> (see <a class="sec" href="foreigninclude.html">section
3375 <code>control_t</code> (see <a class="sec" href="foreigninclude.html#sec:11.4.1.1">section
33383376 11.4.1.1</a>). If <code>PL_FA_VARARGS</code> is provided, <var>function</var>
33393377 is called with three arguments. The first argument is a <code>term_t</code>
33403378 handle to the first argument. Further arguments can be reached by adding
33703408 </pre>
33713409
33723410 </dd>
3373 <dt class="pubdef"><a name="PL_register_foreign()"><var>int</var> <strong>PL_register_foreign</strong>(<var>const
3411 <dt class="pubdef"><a id="PL_register_foreign()"><var>int</var> <strong>PL_register_foreign</strong>(<var>const
33743412 char *name, int arity, foreign_t (*function)(), int flags, ...</var>)</a></dt>
33753413 <dd class="defbody">
33763414 Same as <a class="func" href="foreigninclude.html#PL_register_foreign_in_module()">PL_register_foreign_in_module()</a>,
33773415 passing <code>NULL</code> for the
33783416 <var>module</var>.</dd>
3379 <dt class="pubdef"><a name="PL_register_extensions_in_module()"><var>void</var> <strong>PL_register_extensions_in_module</strong>(<var>const
3417 <dt class="pubdef"><a id="PL_register_extensions_in_module()"><var>void</var> <strong>PL_register_extensions_in_module</strong>(<var>const
33803418 char *module, PL_extension *e</var>)</a></dt>
33813419 <dd class="defbody">
33823420 Register a series of predicates from an array of definitions of the type
34163454 </pre>
34173455
34183456 </dd>
3419 <dt class="pubdef"><a name="PL_register_extensions()"><var>void</var> <strong>PL_register_extensions</strong>(<var>
3457 <dt class="pubdef"><a id="PL_register_extensions()"><var>void</var> <strong>PL_register_extensions</strong>(<var>
34203458 PL_extension *e</var>)</a></dt>
34213459 <dd class="defbody">
34223460 Same as <a class="func" href="foreigninclude.html#PL_register_extensions_in_module()">PL_register_extensions_in_module()</a>
34243462 </dd>
34253463 </dl>
34263464
3427 <p><h3 id="sec:foreign-hooks"><a name="sec:11.4.19"><span class="sec-nr">11.4.19</span> <span class="sec-title">Foreign
3465 <p><h3 id="sec:foreign-hooks"><a id="sec:11.4.19"><span class="sec-nr">11.4.19</span> <span class="sec-title">Foreign
34283466 Code Hooks</span></a></h3>
34293467
3430 <a name="sec:foreign-hooks"></a>
3468 <a id="sec:foreign-hooks"></a>
34313469
34323470 <p>For various specific applications some hooks are provided.
34333471
34343472 <dl class="latex">
3435 <dt class="pubdef"><a name="PL_dispatch_hook()"><var>PL_dispatch_hook_t</var> <strong>PL_dispatch_hook</strong>(<var>PL_dispatch_hook_t</var>)</a></dt>
3473 <dt class="pubdef"><a id="PL_dispatch_hook()"><var>PL_dispatch_hook_t</var> <strong>PL_dispatch_hook</strong>(<var>PL_dispatch_hook_t</var>)</a></dt>
34363474 <dd class="defbody">
34373475 If this hook is not NULL, this function is called when reading from the
34383476 terminal. It is supposed to dispatch events when SWI-Prolog is connected
34473485 </pre>
34483486
34493487 </dd>
3450 <dt class="pubdef"><a name="PL_abort_hook()"><var>void</var> <strong>PL_abort_hook</strong>(<var>PL_abort_hook_t</var>)</a></dt>
3451 <dd class="defbody">
3452 Install a hook when <a name="idx:abort0:2068"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
3453 is executed. SWI-Prolog <a name="idx:abort0:2069"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
3488 <dt class="pubdef"><a id="PL_abort_hook()"><var>void</var> <strong>PL_abort_hook</strong>(<var>PL_abort_hook_t</var>)</a></dt>
3489 <dd class="defbody">
3490 Install a hook when <a id="idx:abort0:2072"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
3491 is executed. SWI-Prolog <a id="idx:abort0:2073"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
34543492 is implemented using C setjmp()/longjmp() construct. The hooks are
34553493 executed in the reverse order of their registration after the longjmp()
34563494 took place and before the Prolog top level is reinvoked. The type
34613499 </pre>
34623500
34633501 </dd>
3464 <dt class="pubdef"><a name="PL_abort_unhook()"><var>int</var> <strong>PL_abort_unhook</strong>(<var>PL_abort_hook_t</var>)</a></dt>
3502 <dt class="pubdef"><a id="PL_abort_unhook()"><var>int</var> <strong>PL_abort_unhook</strong>(<var>PL_abort_hook_t</var>)</a></dt>
34653503 <dd class="defbody">
34663504 Remove a hook installed with <a class="func" href="foreigninclude.html#PL_abort_hook()">PL_abort_hook()</a>.
34673505 Returns <code>FALSE</code> if no such hook is found, <code>TRUE</code>
34683506 otherwise.</dd>
3469 <dt class="pubdef"><a name="PL_on_halt()"><var>void</var> <strong>PL_on_halt</strong>(<var>int
3507 <dt class="pubdef"><a id="PL_on_halt()"><var>void</var> <strong>PL_on_halt</strong>(<var>int
34703508 (*f)(int, void *), void *closure</var>)</a></dt>
34713509 <dd class="defbody">
34723510 Register the function <var>f</var> to be called if SWI-Prolog is halted.
34743512 (0 if this cannot be determined) and the <var>closure</var> argument
34753513 passed to the <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>
34763514 call. Handlers <em>must</em> return 0. Other return values are reserved
3477 for future use. See also <a name="idx:athalt1:2070"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>.<sup class="fn">bug<span class="fn-text">Although
3515 for future use. See also <a id="idx:athalt1:2074"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>.<sup class="fn">bug<span class="fn-text">Although
34783516 both <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>
3479 and <a name="idx:athalt1:2071"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
3480 are called in FIFO order, <em>all</em> <a name="idx:athalt1:2072"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
3517 and <a id="idx:athalt1:2075"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
3518 are called in FIFO order, <em>all</em> <a id="idx:athalt1:2076"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
34813519 handlers are called before <em>all</em> <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>
34823520 handlers.</span></sup> These handlers are called <em>before</em> system
34833521 cleanup and can therefore access all normal Prolog resources. See also <a class="func" href="foreigninclude.html#PL_exit_hook()">PL_exit_hook()</a>.</dd>
3484 <dt class="pubdef"><a name="PL_exit_hook()"><var>void</var> <strong>PL_exit_hook</strong>(<var>int
3522 <dt class="pubdef"><a id="PL_exit_hook()"><var>void</var> <strong>PL_exit_hook</strong>(<var>int
34853523 (*f)(int, void *), void *closure</var>)</a></dt>
34863524 <dd class="defbody">
34873525 Similar to <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>,
34883526 but the hooks are executed by <a class="func" href="foreigninclude.html#PL_halt()">PL_halt()</a>
34893527 instead of <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</a>
34903528 just before calling exit().</dd>
3491 <dt class="pubdef"><a name="PL_agc_hook()"><var>PL_agc_hook_t</var> <strong>PL_agc_hook</strong>(<var>PL_agc_hook_t
3529 <dt class="pubdef"><a id="PL_agc_hook()"><var>PL_agc_hook_t</var> <strong>PL_agc_hook</strong>(<var>PL_agc_hook_t
34923530 new</var>)</a></dt>
34933531 <dd class="defbody">
34943532 Register a hook with the atom-garbage collector (see
3495 <a name="idx:garbagecollectatoms0:2073"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>)
3533 <a id="idx:garbagecollectatoms0:2077"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>)
34963534 that is called on any atom that is reclaimed. The old hook is returned.
34973535 If no hook is currently defined, <code>NULL</code> is returned. The
34983536 argument of the called hook is the atom that is to be garbage collected.
35303568 <p></dd>
35313569 </dl>
35323570
3533 <p><h3 id="sec:foreigndata"><a name="sec:11.4.20"><span class="sec-nr">11.4.20</span> <span class="sec-title">Storing
3571 <p><h3 id="sec:foreigndata"><a id="sec:11.4.20"><span class="sec-nr">11.4.20</span> <span class="sec-title">Storing
35343572 foreign data</span></a></h3>
35353573
3536 <a name="sec:foreigndata"></a>
3574 <a id="sec:foreigndata"></a>
35373575
35383576 <p>When combining foreign code with Prolog, it can be necessary to make
35393577 data represented in the foreign language available to Prolog. For
35573595 <p>
35583596 <li><i>Opaque packed data on the stacks</i><br>
35593597 It is possible to represent the raw binary representation of the foreign
3560 object as a Prolog string (see <a class="sec" href="strings.html">section
3598 object as a Prolog string (see <a class="sec" href="strings.html#sec:5.2">section
35613599 5.2</a>). Strings may be created from foreign data using <a class="func" href="foreigninclude.html#PL_put_string_nchars()">PL_put_string_nchars()</a>
35623600 and retrieved using
35633601 <a class="func" href="foreigninclude.html#PL_get_string_chars()">PL_get_string_chars()</a>.
35643602 It is good practice to wrap the string in a compound term with arity 1,
35653603 so Prolog can identify the type. The hook
3566 <a name="idx:portray1:2074"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
3604 <a id="idx:portray1:2078"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
35673605 rules may be used to streamline printing such terms during development.
35683606
35693607 <p>
35703608 <li><i>Opaque packed data in a blob</i><br>
35713609 Similar to the above solution, binary data can be stored in an atom. The
3572 blob interface (<a class="sec" href="foreigninclude.html">section 11.4.7</a>)
3573 provides additional facilities to assign a type and hook-functions that
3574 act on creation and destruction of the underlying atom.
3610 blob interface (<a class="sec" href="foreigninclude.html#sec:11.4.7">section
3611 11.4.7</a>) provides additional facilities to assign a type and
3612 hook-functions that act on creation and destruction of the underlying
3613 atom.
35753614
35763615 <p>
35773616 <li><i>Natural foreign data, passed as a pointer</i><br>
36133652 implements a predicate. If the predicate is deterministic, foreign
36143653 automatic variables are suitable. If the predicate is non-deterministic,
36153654 the data may be allocated using malloc() and a pointer may be passed.
3616 See <a class="sec" href="foreigninclude.html">section 11.4.1.1</a>.
3655 See <a class="sec" href="foreigninclude.html#sec:11.4.1.1">section
3656 11.4.1.1</a>.
36173657 </ol>
36183658 </ul>
36193659
3620 <p><h4 id="sec:foreign-store-data"><a name="sec:11.4.20.1"><span class="sec-nr">11.4.20.1</span> <span class="sec-title">Examples
3660 <p><h4 id="sec:foreign-store-data"><a id="sec:11.4.20.1"><span class="sec-nr">11.4.20.1</span> <span class="sec-title">Examples
36213661 for storing foreign data</span></a></h4>
36223662
3623 <a name="sec:foreign-store-data"></a>
3663 <a id="sec:foreign-store-data"></a>
36243664
36253665 <p>In this section, we outline some examples, covering typical cases. In
36263666 the first example, we will deal with extending Prolog's data
37123752 }
37133753 </pre>
37143754
3715 <p><b>The DDE interface</b> (see <a class="sec" href="DDE.html">section
3755 <p><b>The DDE interface</b> (see <a class="sec" href="DDE.html#sec:4.43">section
37163756 4.43</a>) represents another common usage of the foreign interface:
37173757 providing communication to new operating system features. The DDE
37183758 interface requires knowledge about active DDE server and client
37383778 debugging purposes, wrapping the handle in a compound is a good
37393779 suggestion.
37403780
3741 <p><h3 id="sec:embedded"><a name="sec:11.4.21"><span class="sec-nr">11.4.21</span> <span class="sec-title">Embedding
3781 <p><h3 id="sec:embedded"><a id="sec:11.4.21"><span class="sec-nr">11.4.21</span> <span class="sec-title">Embedding
37423782 SWI-Prolog in other applications</span></a></h3>
37433783
3744 <a name="sec:embedded"></a>
3784 <a id="sec:embedded"></a>
37453785
37463786 <p>With embedded Prolog we refer to the situation where the `main'
37473787 program is not the Prolog application. Prolog is sometimes embedded in
37723812 </pre>
37733813
37743814 <dl class="latex">
3775 <dt class="pubdef"><a name="PL_initialise()"><var>int</var> <strong>PL_initialise</strong>(<var>int
3815 <dt class="pubdef"><a id="PL_initialise()"><var>int</var> <strong>PL_initialise</strong>(<var>int
37763816 argc, char **argv</var>)</a></dt>
37773817 <dd class="defbody">
37783818 Initialises the SWI-Prolog heap and stacks, restores the Prolog state,
3779 loads the system and personal initialisation files, runs the <a name="idx:initialization1:2075"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
3819 loads the system and personal initialisation files, runs the <a id="idx:initialization1:2079"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
37803820 hooks and finally runs the
37813821 <strong>-g</strong> <var>goal</var> hook.
37823822
37923832 <ul class="latex">
37933833 <li>See whether a Prolog saved state is appended to the file. If this is
37943834 the case, this state will be loaded instead of the default <code>boot.prc</code>
3795 file from the SWI-Prolog home directory. See also <a name="idx:qsaveprogram12:2076"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
3796 and <a class="sec" href="plld.html">section 11.5</a>.
3835 file from the SWI-Prolog home directory. See also <a id="idx:qsaveprogram12:2080"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
3836 and <a class="sec" href="plld.html#sec:11.5">section 11.5</a>.
37973837 <li>Find the Prolog home directory. This process is described in detail
3798 in <a class="sec" href="findhome.html">section 11.6</a>.
3838 in <a class="sec" href="findhome.html#sec:11.6">section 11.6</a>.
37993839 </ul>
38003840
38013841 <p><a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
38373877 <code>"libpl.dll"</code> as <code>argv[0]</code>. If the Prolog state is
38383878 attached to a DLL (see the <strong>-dll</strong> option of <b>swipl-ld</b>),
38393879 pass the name of this DLL.</dd>
3840 <dt class="pubdef"><a name="PL_is_initialised()"><var>int</var> <strong>PL_is_initialised</strong>(<var>int
3880 <dt class="pubdef"><a id="PL_is_initialised()"><var>int</var> <strong>PL_is_initialised</strong>(<var>int
38413881 *argc, char ***argv</var>)</a></dt>
38423882 <dd class="defbody">
38433883 Test whether the Prolog engine is already initialised. Returns
38453885 otherwise. If the engine is initialised and <var>argc</var> is not <code>NULL</code>,
38463886 the argument count used with <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
38473887 is stored in <var>argc</var>. Same for the argument vector <var>argv</var>.</dd>
3848 <dt class="pubdef"><a name="PL_set_resource_db_mem()"><var>int</var> <strong>PL_set_resource_db_mem</strong>(<var>const
3888 <dt class="pubdef"><a id="PL_set_resource_db_mem()"><var>int</var> <strong>PL_set_resource_db_mem</strong>(<var>const
38493889 unsigned char *data, size_t size</var>)</a></dt>
38503890 <dd class="defbody">
38513891 This function must be called at most once and <em>before</em> calling
38523892 <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>.
38533893 The memory area designated by <var>data</var> and <var>size</var> must
38543894 contain the resource data and be in the format as produced by
3855 <a name="idx:qsaveprogram2:2077"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
3895 <a id="idx:qsaveprogram2:2081"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
38563896 The memory area is accessed by <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
3857 as well as calls to <a name="idx:openresource3:2078"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.<sup class="fn">177<span class="fn-text">This
3897 as well as calls to <a id="idx:openresource3:2082"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.<sup class="fn">178<span class="fn-text">This
38583898 implies that the data must remain accessible during the lifetime of the
3859 process if <a name="idx:openresource3:2079"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
3899 process if <a id="idx:openresource3:2083"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
38603900 is used. Future versions may provide a function to detach the resource
3861 database and cause <a name="idx:openresource3:2080"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
3901 database and cause <a id="idx:openresource3:2084"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
38623902 to raise an exception.</span></sup>
38633903
38643904 <p>For example, we can include the bootstrap data into an embedded
38673907
38683908 <p>
38693909 <ol class="latex">
3870 <li>Create a saved state using <a name="idx:qsaveprogram2:2081"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
3910 <li>Create a saved state using <a id="idx:qsaveprogram2:2085"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
38713911 or
38723912
38733913 <pre class="code">
39443984 <p>As Jose Morales pointed at
39453985 <a class="url" href="https://github.com/graphitemaster/incbin">https://github.com/graphitemaster/incbin</a>,
39463986 which contains a portability layer on top of the above idea.</dd>
3947 <dt class="pubdef"><a name="PL_toplevel()"><var>int</var> <strong>PL_toplevel</strong>(<var></var>)</a></dt>
3987 <dt class="pubdef"><a id="PL_toplevel()"><var>int</var> <strong>PL_toplevel</strong>(<var></var>)</a></dt>
39483988 <dd class="defbody">
39493989 Runs the goal of the <strong>-t</strong> <var>toplevel</var> switch
3950 (default <a name="idx:prolog0:2082"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>)
3990 (default <a id="idx:prolog0:2086"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>)
39513991 and returns 1 if successful, 0 otherwise.</dd>
3952 <dt class="pubdef"><a name="PL_cleanup()"><var>int</var> <strong>PL_cleanup</strong>(<var>int
3992 <dt class="pubdef"><a id="PL_cleanup()"><var>int</var> <strong>PL_cleanup</strong>(<var>int
39533993 status</var>)</a></dt>
39543994 <dd class="defbody">
39553995 This function performs the reverse of <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>.
39563996 It runs the
39573997 <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>
3958 and <a name="idx:athalt1:2083"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
3998 and <a id="idx:athalt1:2087"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
39593999 handlers, closes all streams (except for the `standard I/O' streams
39604000 which are flushed only), deallocates all memory if <var>status</var>
39614001 equals `0' and restores all signal handlers. The
39654005 <p>The function returns <code>TRUE</code> if successful and <code>FALSE</code>
39664006 otherwise. Currently, <code>FALSE</code> is returned when an attempt is
39674007 made to call <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</a>
3968 recursively or if one of the exit handlers cancels the termination using <a name="idx:cancelhalt1:2084"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>.
4008 recursively or if one of the exit handlers cancels the termination using <a id="idx:cancelhalt1:2088"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>.
39694009 Exit handlers may only cancel termination if <var>status</var> is 0.
39704010
39714011 <p>In theory, this function allows deleting and restarting the Prolog
39774017 you want to use Prolog temporarily, consider running it in a separate
39784018 process. If you want to be able to reset Prolog, your options are
39794019 (again) a separate process, modules or threads.</dd>
3980 <dt class="pubdef"><a name="PL_cleanup_fork()"><var>void</var> <strong>PL_cleanup_fork</strong>(<var></var>)</a></dt>
3981 <dd class="defbody">
3982 Stop intervaltimer that may be running on behalf of <a name="idx:profile1:2085"></a><a class="pred" href="profile.html#profile/1">profile/1</a>.
4020 <dt class="pubdef"><a id="PL_cleanup_fork()"><var>void</var> <strong>PL_cleanup_fork</strong>(<var></var>)</a></dt>
4021 <dd class="defbody">
4022 Stop intervaltimer that may be running on behalf of <a id="idx:profile1:2089"></a><a class="pred" href="profile.html#profile/1">profile/1</a>.
39834023 The call is intended to be used in combination with fork():
39844024
39854025 <pre class="code">
39914031
39924032 <p>The call behaves the same on Windows, though there is probably no
39934033 meaningful application.</dd>
3994 <dt class="pubdef"><a name="PL_halt()"><var>int</var> <strong>PL_halt</strong>(<var>int
4034 <dt class="pubdef"><a id="PL_halt()"><var>int</var> <strong>PL_halt</strong>(<var>int
39954035 status</var>)</a></dt>
39964036 <dd class="defbody">
39974037 Clean up the Prolog environment using <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</a>
40004040 </dd>
40014041 </dl>
40024042
4003 <p><h4 id="sec:sigembedded"><a name="sec:11.4.21.1"><span class="sec-nr">11.4.21.1</span> <span class="sec-title">Threading,
4043 <p><h4 id="sec:sigembedded"><a id="sec:11.4.21.1"><span class="sec-nr">11.4.21.1</span> <span class="sec-title">Threading,
40044044 Signals and embedded Prolog</span></a></h4>
40054045
4006 <a name="sec:sigembedded"></a>
4046 <a id="sec:sigembedded"></a>
40074047
40084048 <p>This section applies to Unix-based environments that have signals or
40094049 multithreading. The Windows version is compiled for multithreading, and
40284068 <dd>
40294069 has an empty signal handler. This signal is sent to a thread after
40304070 sending a thread-signal (see
4031 <a name="idx:threadsignal2:2086"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>).
4071 <a id="idx:threadsignal2:2090"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>).
40324072 It causes blocking system calls to return with <code>EINTR</code>, which
40334073 gives them the opportunity to react to thread-signals.
40344074
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreignoverview.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreigntypes.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:foreignlink"><a name="sec:11.2"><span class="sec-nr">11.2</span> <span class="sec-title">Linking
235 <h2 id="sec:foreignlink"><a id="sec:11.2"><span class="sec-nr">11.2</span> <span class="sec-title">Linking
195236 Foreign Modules</span></a></h2>
196237
197 <a name="sec:foreignlink"></a>
238 <a id="sec:foreignlink"></a>
198239
199240 <p>Foreign modules may be linked to Prolog in two ways. Using
200241 <em>static linking</em>, the extensions, a (short) file defining main()
203244 executable. Using <em>dynamic linking</em>, the extensions are linked to
204245 a shared library (<code>.so</code> file on most Unix systems) or dynamic
205246 link library (<code>.DLL</code> file on Microsoft platforms) and loaded
206 into the running Prolog process.<sup class="fn">167<span class="fn-text">The
247 into the running Prolog process.<sup class="fn">168<span class="fn-text">The
207248 system also contains code to load <code>.o</code> files directly for
208249 some operating systems, notably Unix systems using the BSD <code>a.out</code>
209250 executable format. As the number of Unix platforms supporting this
210251 quickly gets smaller and this interface is difficult to port and slow,
211252 it is no longer described in this manual. The best alternative would be
212 to use the <a name="idx:dld:2007">dld</a> package on machines that do
213 not have shared libraries.</span></sup>
214
215 <p><h3 id="sec:foreign-linking"><a name="sec:11.2.1"><span class="sec-nr">11.2.1</span> <span class="sec-title">What
253 to use the <a id="idx:dld:2011">dld</a> package on machines that do not
254 have shared libraries.</span></sup>
255
256 <p><h3 id="sec:foreign-linking"><a id="sec:11.2.1"><span class="sec-nr">11.2.1</span> <span class="sec-title">What
216257 linking is provided?</span></a></h3>
217258
218 <a name="sec:foreign-linking"></a>
259 <a id="sec:foreign-linking"></a>
219260
220261 <p>The <em>static linking</em> schema can be used on all versions of
221262 SWI-Prolog. Whether or not dynamic linking is supported can be deduced
222263 from the Prolog flag <a class="flag" href="flags.html#flag:open_shared_object">open_shared_object</a>
223264 (see
224 <a name="idx:currentprologflag2:2008"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
265 <a id="idx:currentprologflag2:2012"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
225266 If this Prolog flag yields <code>true</code>,
226 <a name="idx:opensharedobject2:2009"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
267 <a id="idx:opensharedobject2:2013"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
227268 and related predicates are defined. See
228 <a class="sec" href="foreignlink.html">section 11.2.3</a> for a suitable
229 high-level interface to these predicates.
230
231 <p><h3 id="sec:foreign-linking-options"><a name="sec:11.2.2"><span class="sec-nr">11.2.2</span> <span class="sec-title">What
269 <a class="sec" href="foreignlink.html#sec:11.2.3">section 11.2.3</a> for
270 a suitable high-level interface to these predicates.
271
272 <p><h3 id="sec:foreign-linking-options"><a id="sec:11.2.2"><span class="sec-nr">11.2.2</span> <span class="sec-title">What
232273 kind of loading should I be using?</span></a></h3>
233274
234 <a name="sec:foreign-linking-options"></a>
275 <a id="sec:foreign-linking-options"></a>
235276
236277 <p>All described approaches have their advantages and disadvantages.
237278 Static linking is portable and allows for debugging on all platforms. It
238279 is relatively cumbersome and the libraries you need to pass to the
239280 linker may vary from system to system, though the utility program
240 <b>swipl-ld</b> described in <a class="sec" href="plld.html">section
281 <b>swipl-ld</b> described in <a class="sec" href="plld.html#sec:11.5">section
241282 11.5</a> often hides these problems from the user.
242283
243284 <p>Loading shared objects (DLL files on Windows) provides sharing and
244285 protection and is generally the best choice. If a saved state is created
245 using <a name="idx:qsaveprogram12:2010"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>,
246 an <a name="idx:initialization1:2011"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
286 using <a id="idx:qsaveprogram12:2014"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>,
287 an <a id="idx:initialization1:2015"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
247288 directive may be used to load the appropriate library at startup.
248289
249290 <p>Note that the definition of the foreign predicates is the same,
250291 regardless of the linking type used.
251292
252 <p><h3 id="sec:shlib"><a name="sec:11.2.3"><span class="sec-nr">11.2.3</span> <span class="sec-title">library(shlib):
293 <p><h3 id="sec:shlib"><a id="sec:11.2.3"><span class="sec-nr">11.2.3</span> <span class="sec-title">library(shlib):
253294 Utility library for loading foreign objects (DLLs, shared objects)</span></a></h3>
254295
255 <p><a name="sec:shlib"></a>
296 <p><a id="sec:shlib"></a>
256297
257298 <p>This section discusses the functionality of the (autoload)
258299 <code>library(shlib)</code>, providing an interface to manage shared
307348 and provides the predicate defined in C.
308349
309350 <dl class="latex">
310 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="load_foreign_library/1"><strong>load_foreign_library</strong>(<var>:FileSpec</var>)</a></dt>
311 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="load_foreign_library/2"><strong>load_foreign_library</strong>(<var>:FileSpec,
351 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="load_foreign_library/1"><strong>load_foreign_library</strong>(<var>:FileSpec</var>)</a></dt>
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="load_foreign_library/2"><strong>load_foreign_library</strong>(<var>:FileSpec,
312353 +Entry:atom</var>)</a></dt>
313354 <dd class="defbody">
314355 Load a <i>shared object</i> or <i>DLL</i>. After loading the <var>Entry</var>
325366 </pre>
326367
327368 <table class="arglist">
328 <tr valign="top"><td><var>FileSpec</var> </td><td>is a specification for <a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
369 <tr><td><var>FileSpec</var> </td><td>is a specification for <a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
329370 If searching the file fails, the plain name is passed to the OS to try
330371 the default method of the OS for locating foreign objects. The default
331372 definition of <a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
343384 </dl>
344385
345386 </dd>
346 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="use_foreign_library/1"><strong>use_foreign_library</strong>(<var>+FileSpec</var>)</a></dt>
347 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="use_foreign_library/2"><strong>use_foreign_library</strong>(<var>+FileSpec,
387 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="use_foreign_library/1"><strong>use_foreign_library</strong>(<var>+FileSpec</var>)</a></dt>
388 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="use_foreign_library/2"><strong>use_foreign_library</strong>(<var>+FileSpec,
348389 +Entry:atom</var>)</a></dt>
349390 <dd class="defbody">
350391 Load and install a foreign library as <a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>,2
361402 loads the library
362403 <i>immediately</i>. I.e. the difference is only relevant if the
363404 remainder of the file uses functionality of the C-library.</dd>
364 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="unload_foreign_library/1"><strong>unload_foreign_library</strong>(<var>+FileSpec</var>)</a></dt>
365 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="unload_foreign_library/2"><strong>unload_foreign_library</strong>(<var>+FileSpec,
405 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="unload_foreign_library/1"><strong>unload_foreign_library</strong>(<var>+FileSpec</var>)</a></dt>
406 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="unload_foreign_library/2"><strong>unload_foreign_library</strong>(<var>+FileSpec,
366407 +Exit:atom</var>)</a></dt>
367408 <dd class="defbody">
368409 Unload a <i>shared object</i> or <i>DLL</i>. After calling the <var>Exit</var>
369410 function, the shared object is removed from the process. The default
370411 exit function is composed from =uninstall_=, followed by the file
371412 base-name.</dd>
372 <dt class="pubdef"><a name="current_foreign_library/2"><strong>current_foreign_library</strong>(<var>?File,
413 <dt class="pubdef"><a id="current_foreign_library/2"><strong>current_foreign_library</strong>(<var>?File,
373414 ?Public</var>)</a></dt>
374415 <dd class="defbody">
375416 Query currently loaded shared libraries.</dd>
376 <dt class="pubdef"><a name="reload_foreign_libraries/0"><strong>reload_foreign_libraries</strong></a></dt>
417 <dt class="pubdef"><a id="reload_foreign_libraries/0"><strong>reload_foreign_libraries</strong></a></dt>
377418 <dd class="defbody">
378419 Reload all foreign libraries loaded (after restore of a state created
379420 using <a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
380421 </dd>
381422 </dl>
382423
383 <p><h3 id="sec:sharedobj"><a name="sec:11.2.4"><span class="sec-nr">11.2.4</span> <span class="sec-title">Low-level
424 <p><h3 id="sec:sharedobj"><a id="sec:11.2.4"><span class="sec-nr">11.2.4</span> <span class="sec-title">Low-level
384425 operations on shared libraries</span></a></h3>
385426
386 <a name="sec:sharedobj"></a>
427 <a id="sec:sharedobj"></a>
387428
388429 <p>The interface defined in this section allows the user to load shared
389430 libraries (<code>.so</code> files on most Unix systems, <code>.dll</code>
390431 files on Windows). This interface is portable to Windows as well as to
391432 Unix machines providing <strong>dlopen</strong>(2) (Solaris, Linux,
392433 FreeBSD, Irix and many more) or <strong>shl_open</strong>(2) (HP/UX). It
393 is advised to use the predicates from <a class="sec" href="foreignlink.html">section
434 is advised to use the predicates from <a class="sec" href="foreignlink.html#sec:11.2.3">section
394435 11.2.3</a> in your application.
395436
396437 <dl class="latex">
397 <dt class="pubdef"><a name="open_shared_object/2"><strong>open_shared_object</strong>(<var>+File,
438 <dt class="pubdef"><a id="open_shared_object/2"><strong>open_shared_object</strong>(<var>+File,
398439 -Handle</var>)</a></dt>
399440 <dd class="defbody">
400441 <var>File</var> is the name of a shared object file (DLL in MS-Windows).
401442 This file is attached to the current process, and
402443 <var>Handle</var> is unified with a handle to the library. Equivalent to
403444 <code>open_shared_object(File, Handle, [])</code>. See also
404 <a name="idx:opensharedobject3:2012"></a><a class="pred" href="foreignlink.html#open_shared_object/3">open_shared_object/3</a>
405 and <a name="idx:loadforeignlibrary1:2013"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>.
445 <a id="idx:opensharedobject3:2016"></a><a class="pred" href="foreignlink.html#open_shared_object/3">open_shared_object/3</a>
446 and <a id="idx:loadforeignlibrary1:2017"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>.
406447
407448 <p>On errors, an exception <code>shared_object(Action, Message)</code>
408449 is raised. <var>Message</var> is the return value from dlerror().</dd>
409 <dt class="pubdef"><a name="open_shared_object/3"><strong>open_shared_object</strong>(<var>+File,
450 <dt class="pubdef"><a id="open_shared_object/3"><strong>open_shared_object</strong>(<var>+File,
410451 -Handle, +Options</var>)</a></dt>
411452 <dd class="defbody">
412 As <a name="idx:opensharedobject2:2014"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>,
453 As <a id="idx:opensharedobject2:2018"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>,
413454 but allows for additional flags to be passed.
414455 <var>Options</var> is a list of atoms. <code>now</code> implies the
415456 symbols are resolved immediately rather than lazy (default). <code>global</code>
418459 not be supported by your operating system. Check the documentation of
419460 dlopen() or equivalent on your operating system. Unsupported flags are
420461 silently ignored.</dd>
421 <dt class="pubdef"><a name="close_shared_object/1"><strong>close_shared_object</strong>(<var>+Handle</var>)</a></dt>
462 <dt class="pubdef"><a id="close_shared_object/1"><strong>close_shared_object</strong>(<var>+Handle</var>)</a></dt>
422463 <dd class="defbody">
423464 Detach the shared object identified by <var>Handle</var>.</dd>
424 <dt class="pubdef"><a name="call_shared_object_function/2"><strong>call_shared_object_function</strong>(<var>+Handle,
465 <dt class="pubdef"><a id="call_shared_object_function/2"><strong>call_shared_object_function</strong>(<var>+Handle,
425466 +Function</var>)</a></dt>
426467 <dd class="defbody">
427468 Call the named function in the loaded shared library. The function is
431472 </dd>
432473 </dl>
433474
434 <p><h3 id="sec:staticl"><a name="sec:11.2.5"><span class="sec-nr">11.2.5</span> <span class="sec-title">Static
475 <p><h3 id="sec:staticl"><a id="sec:11.2.5"><span class="sec-nr">11.2.5</span> <span class="sec-title">Static
435476 Linking</span></a></h3>
436477
437 <a name="sec:staticl"></a>
478 <a id="sec:staticl"></a>
438479
439480 <p>Below is an outline of the file structure required for statically
440481 linking SWI-Prolog with foreign extensions. <code>.../swipl</code>
442483 <code>&lt;<var>arch</var>&gt;</code> refers to the architecture
443484 identifier that may be obtained using the Prolog flag <a class="flag" href="flags.html#flag:arch">arch</a>.
444485
445 <p><table border="0" frame="void" rules="groups" style="margin:auto">
446 <tr valign="top"><td><code>.../swipl/runtime/&lt;<var>arch</var>&gt;/libswipl.a</code> </td><td>SWI-Library </td></tr>
447 <tr valign="top"><td><code>.../swipl/include/SWI-Prolog.h</code> </td><td>Include
486 <p><table class="latex frame-void center">
487 <tr><td><code>.../swipl/runtime/&lt;<var>arch</var>&gt;/libswipl.a</code> </td><td>SWI-Library </td></tr>
488 <tr><td><code>.../swipl/include/SWI-Prolog.h</code> </td><td>Include
448489 file </td></tr>
449 <tr valign="top"><td><code>.../swipl/include/SWI-Stream.h</code> </td><td>Stream
450 I/O include file </td></tr>
451 <tr valign="top"><td><code>.../swipl/include/SWI-Exports</code> </td><td>Export
490 <tr><td><code>.../swipl/include/SWI-Stream.h</code> </td><td>Stream I/O
491 include file </td></tr>
492 <tr><td><code>.../swipl/include/SWI-Exports</code> </td><td>Export
452493 declarations (AIX only) </td></tr>
453 <tr valign="top"><td><code>.../swipl/include/stub.c</code> </td><td>Extension
454 stub</td></tr>
494 <tr><td><code>.../swipl/include/stub.c</code> </td><td>Extension stub</td></tr>
455495 </table>
456496
457497 <p>The definition of the foreign predicates is the same as for dynamic
492532 libraries required by both the extensions and the SWI-Prolog kernel.
493533 This may be done by hand, or by using the <b>swipl-ld</b> utility
494534 described in
495 <a class="sec" href="plld.html">section 11.5</a>. If the linking is
496 performed by hand, the command line option <code>-dump-runtime-variables</code>
497 (see <a class="sec" href="cmdline.html">section 2.4</a>) can be used to
498 obtain the required paths, libraries and linking options to link the new
499 executable.
535 <a class="sec" href="plld.html#sec:11.5">section 11.5</a>. If the
536 linking is performed by hand, the command line option <code>-dump-runtime-variables</code>
537 (see <a class="sec" href="cmdline.html#sec:2.4">section 2.4</a>) can be
538 used to obtain the required paths, libraries and linking options to link
539 the new executable.
500540
501541 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreignxmp.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="runtime.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:foreignnotes"><a name="sec:11.8"><span class="sec-nr">11.8</span> <span class="sec-title">Notes
235 <h2 id="sec:foreignnotes"><a id="sec:11.8"><span class="sec-nr">11.8</span> <span class="sec-title">Notes
195236 on Using Foreign Code</span></a></h2>
196237
197 <a name="sec:foreignnotes"></a>
198
199 <p><h3 id="sec:foreign-debug"><a name="sec:11.8.1"><span class="sec-nr">11.8.1</span> <span class="sec-title">Foreign
238 <a id="sec:foreignnotes"></a>
239
240 <p><h3 id="sec:foreign-debug"><a id="sec:11.8.1"><span class="sec-nr">11.8.1</span> <span class="sec-title">Foreign
200241 debugging functions</span></a></h3>
201242
202 <a name="sec:foreign-debug"></a>
243 <a id="sec:foreign-debug"></a>
203244
204245 <p>The functions in this section are primarily intended for debugging
205246 foreign extensions or embedded Prolog. Violating the constraints of the
220261 critical location in your code or the system code.
221262
222263 <dl class="latex">
223 <dt class="pubdef"><a name="PL_backtrace()"><var>void</var> <strong>PL_backtrace</strong>(<var>int
264 <dt class="pubdef"><a id="PL_backtrace()"><var>void</var> <strong>PL_backtrace</strong>(<var>int
224265 depth, int flags</var>)</a></dt>
225266 <dd class="defbody">
226267 Dump a Prolog backtrace to the <code>user_error</code> stream. <var>Depth</var>
243284 </dl>
244285
245286 </dd>
246 <dt class="pubdef"><a name="PL_backtrace_string()"><var>char *</var> <strong>PL_backtrace_string</strong>(<var>int
287 <dt class="pubdef"><a id="PL_backtrace_string()"><var>char *</var> <strong>PL_backtrace_string</strong>(<var>int
247288 depth, int flags</var>)</a></dt>
248289 <dd class="defbody">
249290 As <a class="func" href="foreignnotes.html#PL_backtrace()">PL_backtrace()</a>,
262303 that exploits <b>gdb</b> and <a class="func" href="foreignnotes.html#PL_backtrace_string()">PL_backtrace_string()</a>
263304 to print stack traces in various formats for a SWI-Prolog process, given
264305 its process id.</dd>
265 <dt class="pubdef"><a name="PL_check_data()"><var>int</var> <strong>PL_check_data</strong>(<var>term_t
306 <dt class="pubdef"><a id="PL_check_data()"><var>int</var> <strong>PL_check_data</strong>(<var>term_t
266307 data</var>)</a></dt>
267308 <dd class="defbody">
268309 Check the consistency of the term <var>data</var>. Returns <code>TRUE</code>
270311 <code>FALSE</code> otherwise. The actual implementation only exists if
271312 the system is compiled with the cflag <code>-DO_DEBUG</code> or
272313 <code>-DO_MAINTENANCE</code>. This is <em>not</em> the default.</dd>
273 <dt class="pubdef"><a name="PL_check_stacks()"><var>int</var> <strong>PL_check_stacks</strong>(<var></var>)</a></dt>
314 <dt class="pubdef"><a id="PL_check_stacks()"><var>int</var> <strong>PL_check_stacks</strong>(<var></var>)</a></dt>
274315 <dd class="defbody">
275316 Check the consistency of the runtime stacks of the calling thread.
276317 Returns <code>TRUE</code> this is actually implemented in the current
284325 <p>The Prolog kernel sources use the macro <b>DEBUG(Topic, Code)</b>.
285326 These macros are disabled in the production version and must be enabled
286327 by recompiling the system as described above. Specific topics can be
287 enabled and disabled using the predicates <a name="idx:prologdebug1:2090"></a><a class="pred" href="foreignnotes.html#prolog_debug/1">prolog_debug/1</a>
328 enabled and disabled using the predicates <a id="idx:prologdebug1:2094"></a><a class="pred" href="foreignnotes.html#prolog_debug/1">prolog_debug/1</a>
288329 and
289 <a name="idx:prolognodebug1:2091"></a><a class="pred" href="foreignnotes.html#prolog_nodebug/1">prolog_nodebug/1</a>.
330 <a id="idx:prolognodebug1:2095"></a><a class="pred" href="foreignnotes.html#prolog_nodebug/1">prolog_nodebug/1</a>.
290331 In addition, they can be activated from the commandline using
291332 commandline option <code>-d topics</code>, where
292333 <var>topics</var> is a comma-separated list of debug topics to enable.
298339 </pre>
299340
300341 <dl class="latex">
301 <dt class="pubdef"><a name="prolog_debug/1"><strong>prolog_debug</strong>(<var>+Topic</var>)</a></dt>
302 <dt class="pubdef"><a name="prolog_nodebug/1"><strong>prolog_nodebug</strong>(<var>+Topic</var>)</a></dt>
342 <dt class="pubdef"><a id="prolog_debug/1"><strong>prolog_debug</strong>(<var>+Topic</var>)</a></dt>
343 <dt class="pubdef"><a id="prolog_nodebug/1"><strong>prolog_nodebug</strong>(<var>+Topic</var>)</a></dt>
303344 <dd class="defbody">
304345 Enable/disable a debug topic. <var>Topic</var> is an atom that
305346 identifies the desired topic. The available topics are defined in
320361 </dd>
321362 </dl>
322363
323 <p><h3 id="sec:foreign-malloc"><a name="sec:11.8.2"><span class="sec-nr">11.8.2</span> <span class="sec-title">Memory
364 <p><h3 id="sec:foreign-malloc"><a id="sec:11.8.2"><span class="sec-nr">11.8.2</span> <span class="sec-title">Memory
324365 Allocation</span></a></h3>
325366
326 <a name="sec:foreign-malloc"></a>
367 <a id="sec:foreign-malloc"></a>
327368
328369 <p>SWI-Prolog's heap memory allocation is based on the <strong>malloc</strong>(3)
329370 library routines. SWI-Prolog provides the functions below as a wrapper
340381 functions on the same memory.
341382
342383 <dl class="latex">
343 <dt class="pubdef"><a name="PL_malloc()"><var>void *</var> <strong>PL_malloc</strong>(<var>size_t
384 <dt class="pubdef"><a id="PL_malloc()"><var>void *</var> <strong>PL_malloc</strong>(<var>size_t
344385 bytes</var>)</a></dt>
345386 <dd class="defbody">
346387 Allocate <var>bytes</var> of memory. On failure SWI-Prolog's fatal-error
348389 does not return. Memory allocated using these functions must use <a class="func" href="foreignnotes.html#PL_realloc()">PL_realloc()</a>
349390 and <a class="func" href="foreignnotes.html#PL_free()">PL_free()</a>
350391 rather than realloc() and free().</dd>
351 <dt class="pubdef"><a name="PL_realloc()"><var>void *</var> <strong>PL_realloc</strong>(<var>void
392 <dt class="pubdef"><a id="PL_realloc()"><var>void *</var> <strong>PL_realloc</strong>(<var>void
352393 *mem, size_t size</var>)</a></dt>
353394 <dd class="defbody">
354395 Change the size of the allocated chunk, possibly moving it. The
356397 or
357398 <a class="func" href="foreignnotes.html#PL_realloc()">PL_realloc()</a>
358399 call.</dd>
359 <dt class="pubdef"><a name="PL_free()"><var>void</var> <strong>PL_free</strong>(<var>void
400 <dt class="pubdef"><a id="PL_free()"><var>void</var> <strong>PL_free</strong>(<var>void
360401 *mem</var>)</a></dt>
361402 <dd class="defbody">
362403 Release memory. The <var>mem</var> argument must be obtained from a
366407 </dd>
367408 </dl>
368409
369 <p><h4 id="sec:boehm-gc"><a name="sec:11.8.2.1"><span class="sec-nr">11.8.2.1</span> <span class="sec-title">Boehm-GC
410 <p><h4 id="sec:boehm-gc"><a id="sec:11.8.2.1"><span class="sec-nr">11.8.2.1</span> <span class="sec-title">Boehm-GC
370411 support</span></a></h4>
371412
372 <a name="sec:boehm-gc"></a>
413 <a id="sec:boehm-gc"></a>
373414 <blockquote> This section is obsolete. Although the Boehm-GC interfaces
374415 still exist, it turns out that the scalability is not good enough for
375416 SWI-Prolog. It is unlikely that SWI-Prolog will ever switch to Boehm-GC.
376417 </blockquote>
377418
378 <p><a name="idx:BoehmGC:2092"></a>To accommodate future use of the Boehm
379 garbage collector<sup class="fn">178<span class="fn-text"><a class="url" href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">http://www.hpl.hp.com/personal/Hans_Boehm/gc/</a></span></sup>
419 <p><a id="idx:BoehmGC:2096"></a>To accommodate future use of the Boehm
420 garbage collector<sup class="fn">179<span class="fn-text"><a class="url" href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">http://www.hpl.hp.com/personal/Hans_Boehm/gc/</a></span></sup>
380421 for heap memory allocation, the interface provides the functions
381422 described below. Foreign extensions that wish to use the Boehm-GC
382423 facilities can use these wrappers. Please note that if SWI-Prolog is not
384425 to reclaim memory.
385426
386427 <dl class="latex">
387 <dt class="pubdef"><a name="PL_malloc_atomic()"><var>void*</var> <strong>PL_malloc_atomic</strong>(<var>size_t
428 <dt class="pubdef"><a id="PL_malloc_atomic()"><var>void*</var> <strong>PL_malloc_atomic</strong>(<var>size_t
388429 bytes</var>)</a></dt>
389 <dt class="pubdef"><a name="PL_malloc_uncollectable()"><var>void*</var> <strong>PL_malloc_uncollectable</strong>(<var>size_t
430 <dt class="pubdef"><a id="PL_malloc_uncollectable()"><var>void*</var> <strong>PL_malloc_uncollectable</strong>(<var>size_t
390431 bytes</var>)</a></dt>
391 <dt class="pubdef"><a name="PL_malloc_atomic_uncollectable()"><var>void*</var> <strong>PL_malloc_atomic_uncollectable</strong>(<var>size_t
432 <dt class="pubdef"><a id="PL_malloc_atomic_uncollectable()"><var>void*</var> <strong>PL_malloc_atomic_uncollectable</strong>(<var>size_t
392433 bytes</var>)</a></dt>
393434 <dd class="defbody">
394435 If Boehm-GC is not used, these are all the same as <a class="func" href="foreignnotes.html#PL_malloc()">PL_malloc()</a>.
397438 pointers, and <em>uncollectable</em> means that the object should never
398439 be garbage collected.
399440 </dd>
400 <dt class="pubdef"><a name="PL_malloc_stubborn()"><var>void*</var> <strong>PL_malloc_stubborn</strong>(<var>size_t
441 <dt class="pubdef"><a id="PL_malloc_stubborn()"><var>void*</var> <strong>PL_malloc_stubborn</strong>(<var>size_t
401442 bytes</var>)</a></dt>
402 <dt class="pubdef"><a name="PL_end_stubborn_change()"><var>void</var> <strong>PL_end_stubborn_change</strong>(<var>void
443 <dt class="pubdef"><a id="PL_end_stubborn_change()"><var>void</var> <strong>PL_end_stubborn_change</strong>(<var>void
403444 *memory</var>)</a></dt>
404445 <dd class="defbody">
405446 These functions allow creating objects, promising GC that the content
407448 </dd>
408449 </dl>
409450
410 <p><h3 id="sec:foreign-compat"><a name="sec:11.8.3"><span class="sec-nr">11.8.3</span> <span class="sec-title">Compatibility
451 <p><h3 id="sec:foreign-compat"><a id="sec:11.8.3"><span class="sec-nr">11.8.3</span> <span class="sec-title">Compatibility
411452 between Prolog versions</span></a></h3>
412453
413 <a name="sec:foreign-compat"></a>
454 <a id="sec:foreign-compat"></a>
414455
415456 <p>Great care is taken to ensure binary compatibility of foreign
416457 extensions between different Prolog versions. Only the much less
417458 frequently used stream interface has been responsible for binary
418459 incompatibilities.
419460
420 <p><a name="idx:PLVERSION:2093"></a>Source code that relies on new
461 <p><a id="idx:PLVERSION:2097"></a>Source code that relies on new
421462 features of the foreign interface can use the macro <code>PLVERSION</code>
422463 to find the version of
423464 <code>SWI-Prolog.h</code> and <a class="func" href="foreigninclude.html#PL_query()">PL_query()</a>
425466 <code>PL_QUERY_VERSION</code> to find the version of the attached Prolog
426467 system. Both follow the same numbering schema explained with <a class="func" href="foreigninclude.html#PL_query()">PL_query()</a>.
427468
428 <p><h3 id="sec:foreign-debug-and-profile"><a name="sec:11.8.4"><span class="sec-nr">11.8.4</span> <span class="sec-title">Debugging
469 <p><h3 id="sec:foreign-debug-and-profile"><a id="sec:11.8.4"><span class="sec-nr">11.8.4</span> <span class="sec-title">Debugging
429470 and profiling foreign code (valgrind)</span></a></h3>
430471
431 <a name="sec:foreign-debug-and-profile"></a>
432
433 <p><a name="idx:valgrind:2094"></a><a name="idx:profilingforeigncode:2095"></a>This
472 <a id="sec:foreign-debug-and-profile"></a>
473
474 <p><a id="idx:valgrind:2098"></a><a id="idx:profilingforeigncode:2099"></a>This
434475 section is only relevant for Unix users on platforms supported by
435 http://valgrind.org/valgrind. Valgrind is an excellent binary
436 instrumentation platform. Unlike many other instrumentation platforms,
437 valgrind can deal with code loaded through dlopen().
476 <a class="url" href="http://valgrind.org/">valgrind</a>. Valgrind is an
477 excellent binary instrumentation platform. Unlike many other
478 instrumentation platforms, valgrind can deal with code loaded through
479 dlopen().
438480
439481 <p>The <b>callgrind</b> tool can be used to profile foreign code loaded
440482 under SWI-Prolog. Compile the foreign library adding <strong>-g</strong>
442484 variable <code>VALGRIND</code> to <code>yes</code>, SWI-Prolog will <em>not</em>
443485 release loaded shared objects using dlclose(). This trick is required to
444486 get source information on the loaded library. Without, valgrind claims
445 that the shared object has no debugging information.<sup class="fn">179<span class="fn-text">Tested
487 that the shared object has no debugging information.<sup class="fn">180<span class="fn-text">Tested
446488 using valgrind version 3.2.3 on x64.</span></sup> Here is the complete
447489 sequence using <b>bash</b> as login shell:
448490
452494 % kcachegrind callgrind.out.&lt;pid&gt;
453495 </pre>
454496
455 <p><h3 id="sec:foreign-name-conflicts"><a name="sec:11.8.5"><span class="sec-nr">11.8.5</span> <span class="sec-title">Name
497 <p><h3 id="sec:foreign-name-conflicts"><a id="sec:11.8.5"><span class="sec-nr">11.8.5</span> <span class="sec-title">Name
456498 Conflicts in C modules</span></a></h3>
457499
458 <a name="sec:foreign-name-conflicts"></a>
500 <a id="sec:foreign-name-conflicts"></a>
459501
460502 <p>In the current version of the system all public C functions of
461503 SWI-Prolog are in the symbol table. This can lead to name clashes with
474516 library loader will only look for symbols in the main executable for
475517 symbols that are not defined in the library itself.
476518
477 <p><h3 id="sec:foreign-quintus-sicstus"><a name="sec:11.8.6"><span class="sec-nr">11.8.6</span> <span class="sec-title">Compatibility
519 <p><h3 id="sec:foreign-quintus-sicstus"><a id="sec:11.8.6"><span class="sec-nr">11.8.6</span> <span class="sec-title">Compatibility
478520 of the Foreign Interface</span></a></h3>
479521
480 <a name="sec:foreign-quintus-sicstus"></a>
522 <a id="sec:foreign-quintus-sicstus"></a>
481523
482524 <p>The term reference mechanism was first used by Quintus Prolog version&nbsp;3.
483525 SICStus Prolog version 3 is strongly based on the Quintus interface. The
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreign.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreignlink.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:foreignoverview"><a name="sec:11.1"><span class="sec-nr">11.1</span> <span class="sec-title">Overview
235 <h2 id="sec:foreignoverview"><a id="sec:11.1"><span class="sec-nr">11.1</span> <span class="sec-title">Overview
195236 of the Interface</span></a></h2>
196237
197 <a name="sec:foreignoverview"></a>
238 <a id="sec:foreignoverview"></a>
198239
199240 <p>A special include file called <code>SWI-Prolog.h</code> should be
200241 included with each C source file that is to be loaded via the foreign
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 9.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="thutil.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="mt-xpce.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:foreignthread"><a name="sec:9.6"><span class="sec-nr">9.6</span> <span class="sec-title">Multithreaded
235 <h2 id="sec:foreignthread"><a id="sec:9.6"><span class="sec-nr">9.6</span> <span class="sec-title">Multithreaded
195236 mixed C and Prolog applications</span></a></h2>
196237
197 <a name="sec:foreignthread"></a>
238 <a id="sec:foreignthread"></a>
198239
199240 <p>All foreign code linked to the multithreading version of SWI-Prolog
200241 should be thread-safe (<em>reentrant</em>) or guarded in Prolog using
201 <a name="idx:withmutex2:1953"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
242 <a id="idx:withmutex2:1957"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
202243 from simultaneous access from multiple Prolog threads. If you want to
203244 write mixed multithreaded C and Prolog applications you should first
204245 familiarise yourself with writing multithreaded applications in C (C++).
209250 Without creating an engine, a thread can only use functions that do
210251 <em>not</em> use the <code>term_t</code> type (for example <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>).
211252
212 <p>The system supports two models. <a class="sec" href="foreignthread.html">Section
253 <p>The system supports two models. <a class="sec" href="foreignthread.html#sec:9.6.1">Section
213254 9.6.1</a> describes the original one-to-one mapping. In this schema a
214255 native thread attaches a Prolog thread if it needs to call Prolog and
215 detaches it when finished, as opposed to the model from <a class="sec" href="foreignthread.html">section
256 detaches it when finished, as opposed to the model from <a class="sec" href="foreignthread.html#sec:9.6.2">section
216257 9.6.2</a>, where threads temporarily use a Prolog engine.
217258
218 <p><h3 id="sec:threadoneone"><a name="sec:9.6.1"><span class="sec-nr">9.6.1</span> <span class="sec-title">A
259 <p><h3 id="sec:threadoneone"><a id="sec:9.6.1"><span class="sec-nr">9.6.1</span> <span class="sec-title">A
219260 Prolog thread for each native thread (one-to-one)</span></a></h3>
220261
221 <a name="sec:threadoneone"></a>
262 <a id="sec:threadoneone"></a>
222263
223264 <p>In the one-to-one model, the thread that called <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
224265 has a Prolog engine attached. If another C thread in the system wishes
225266 to call Prolog it must first attach an engine using <a class="func" href="foreignthread.html#PL_thread_attach_engine()">PL_thread_attach_engine()</a>
226267 and call <a class="func" href="foreignthread.html#PL_thread_destroy_engine()">PL_thread_destroy_engine()</a>
227268 after all Prolog work is finished. This model is especially suitable
228 with long running threads that need to do Prolog work regularly. See <a class="sec" href="foreignthread.html">section
269 with long running threads that need to do Prolog work regularly. See <a class="sec" href="foreignthread.html#sec:9.6.2">section
229270 9.6.2</a> for the alternative many-to-many model.
230271
231272 <dl class="latex">
232 <dt class="pubdef"><a name="PL_thread_self()"><var>int</var> <strong>PL_thread_self</strong>(<var></var>)</a></dt>
273 <dt class="pubdef"><a id="PL_thread_self()"><var>int</var> <strong>PL_thread_self</strong>(<var></var>)</a></dt>
233274 <dd class="defbody">
234275 Returns the integer Prolog identifier of the engine or -1 if the calling
235276 thread has no Prolog engine. This function is also provided in the
236277 single-threaded version of SWI-Prolog, where it returns -2.</dd>
237 <dt class="pubdef"><a name="PL_unify_thread_id()"><var>int</var> <strong>PL_unify_thread_id</strong>(<var>term_t
278 <dt class="pubdef"><a id="PL_unify_thread_id()"><var>int</var> <strong>PL_unify_thread_id</strong>(<var>term_t
238279 t, int i</var>)</a></dt>
239280 <dd class="defbody">
240281 Unify <var>t</var> with the Prolog thread identifier for thread <var>i</var>.
241282 Thread identifiers are normally returned from <a class="func" href="foreignthread.html#PL_thread_self()">PL_thread_self()</a>.
242283 Returns -1 if the thread does not exist or the unification fails.</dd>
243 <dt class="pubdef"><a name="PL_thread_attach_engine()"><var>int</var> <strong>PL_thread_attach_engine</strong>(<var>const
284 <dt class="pubdef"><a id="PL_thread_attach_engine()"><var>int</var> <strong>PL_thread_attach_engine</strong>(<var>const
244285 PL_thread_attr_t *attr</var>)</a></dt>
245286 <dd class="defbody">
246287 Creates a new Prolog engine in the calling thread. If the calling thread
279320 (as returned by <a class="func" href="foreignthread.html#PL_thread_self()">PL_thread_self()</a>).
280321 If an error occurs, -1 is returned. If this Prolog is not compiled for
281322 multithreading, -2 is returned.</dd>
282 <dt class="pubdef"><a name="PL_thread_destroy_engine()"><var>int</var> <strong>PL_thread_destroy_engine</strong>(<var></var>)</a></dt>
323 <dt class="pubdef"><a id="PL_thread_destroy_engine()"><var>int</var> <strong>PL_thread_destroy_engine</strong>(<var></var>)</a></dt>
283324 <dd class="defbody">
284325 Destroy the Prolog engine in the calling thread. Only takes effect if
285326 <a class="func" href="foreignthread.html#PL_thread_destroy_engine()">PL_thread_destroy_engine()</a>
292333 <p>Please note that construction and destruction of engines are
293334 relatively expensive operations. Only destroy an engine if performance
294335 is not critical and memory is a critical resource.</dd>
295 <dt class="pubdef"><a name="PL_thread_at_exit()"><var>int</var> <strong>PL_thread_at_exit</strong>(<var>void
336 <dt class="pubdef"><a id="PL_thread_at_exit()"><var>int</var> <strong>PL_thread_at_exit</strong>(<var>void
296337 (*function)(void *), void *closure, int global</var>)</a></dt>
297338 <dd class="defbody">
298339 Register a handle to be called as the Prolog engine is destroyed. The
302343 <em>for all threads</em>. Globally installed handlers are executed after
303344 the thread-local handlers. If the handler is installed local for the
304345 current thread only (<var>global</var> == <code>FALSE</code>) it is
305 stored in the same FIFO queue as used by <a name="idx:threadatexit1:1954"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>.
346 stored in the same FIFO queue as used by <a id="idx:threadatexit1:1958"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>.
306347 </dd>
307348 </dl>
308349
309 <p><h3 id="sec:threadmanymany"><a name="sec:9.6.2"><span class="sec-nr">9.6.2</span> <span class="sec-title">Pooling
350 <p><h3 id="sec:threadmanymany"><a id="sec:9.6.2"><span class="sec-nr">9.6.2</span> <span class="sec-title">Pooling
310351 Prolog engines (many-to-many)</span></a></h3>
311352
312 <a name="sec:threadmanymany"></a>
353 <a id="sec:threadmanymany"></a>
313354
314355 <p>In this model Prolog engines live as entities that are independent
315356 from threads. If a thread needs to call Prolog it takes one of the
340381 </ul>
341382
342383 <dl class="latex">
343 <dt class="pubdef"><a name="PL_create_engine()"><var>PL_engine_t</var> <strong>PL_create_engine</strong>(<var>PL_thread_attr_t
384 <dt class="pubdef"><a id="PL_create_engine()"><var>PL_engine_t</var> <strong>PL_create_engine</strong>(<var>PL_thread_attr_t
344385 *attributes</var>)</a></dt>
345386 <dd class="defbody">
346387 Create a new Prolog engine. <var>attributes</var> is described with
353394
354395 <p>In the single-threaded version this call always returns <code>NULL</code>,
355396 indicating failure.</dd>
356 <dt class="pubdef"><a name="PL_destroy_engine()"><var>int</var> <strong>PL_destroy_engine</strong>(<var>PL_engine_t
397 <dt class="pubdef"><a id="PL_destroy_engine()"><var>int</var> <strong>PL_destroy_engine</strong>(<var>PL_engine_t
357398 e</var>)</a></dt>
358399 <dd class="defbody">
359400 Destroy the given engine. Destroying an engine is only allowed if the
360401 engine is not attached to any thread or attached to the calling thread.
361402 On success this function returns <code>TRUE</code>, on failure the
362403 return value is <code>FALSE</code>.</dd>
363 <dt class="pubdef"><a name="PL_set_engine()"><var>int</var> <strong>PL_set_engine</strong>(<var>PL_engine_t
404 <dt class="pubdef"><a id="PL_set_engine()"><var>int</var> <strong>PL_set_engine</strong>(<var>PL_engine_t
364405 engine, PL_engine_t *old</var>)</a></dt>
365406 <dd class="defbody">
366407 Make the calling thread ready to use <var>engine</var>. If <var>old</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreignlink.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreigninclude.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:foreigntypes"><a name="sec:11.3"><span class="sec-nr">11.3</span> <span class="sec-title">Interface
235 <h2 id="sec:foreigntypes"><a id="sec:11.3"><span class="sec-nr">11.3</span> <span class="sec-title">Interface
195236 Data Types</span></a></h2>
196237
197 <a name="sec:foreigntypes"></a>
198
199 <p><h3 id="sec:type-term-t"><a name="sec:11.3.1"><span class="sec-nr">11.3.1</span> <span class="sec-title">Type <code>term_t</code>:
238 <a id="sec:foreigntypes"></a>
239
240 <p><h3 id="sec:type-term-t"><a id="sec:11.3.1"><span class="sec-nr">11.3.1</span> <span class="sec-title">Type <code>term_t</code>:
200241 a reference to a Prolog term</span></a></h3>
201242
202 <a name="sec:type-term-t"></a>
243 <a id="sec:type-term-t"></a>
203244
204245 <p>The principal data type is <code>term_t</code>. Type <code>term_t</code>
205246 is what Quintus calls <code>QP_term_ref</code>. This name indicates
234275 <em>write</em> to term references. In this document we use the following
235276 notation for arguments of type <code>term_t</code>:
236277 <blockquote>
237 <table border="0" frame="void" rules="groups">
238 <tr valign="top"><td><code>term_t +t</code></td><td>Accessed in
239 read-mode. The `+' indicates the argument is `input'. </td></tr>
240 <tr valign="top"><td><code>term_t -t</code></td><td>Accessed in
241 write-mode. </td></tr>
242 <tr valign="top"><td><code>term_t ?t</code></td><td>Accessed in
243 unify-mode. </td></tr>
278 <table class="latex frame-void">
279 <tr><td><code>term_t +t</code></td><td>Accessed in read-mode. The `+'
280 indicates the argument is `input'. </td></tr>
281 <tr><td><code>term_t -t</code></td><td>Accessed in write-mode. </td></tr>
282 <tr><td><code>term_t ?t</code></td><td>Accessed in unify-mode. </td></tr>
244283 </table>
245284 </blockquote>
246285
247286 <p><b>WARNING</b> Term references that are accessed in `write' (-) mode
248287 will refer to an invalid term if the term is allocated on the global
249288 stack and backtracking takes us back to a point before the term was
250 written.<sup class="fn">168<span class="fn-text">This could have been
289 written.<sup class="fn">169<span class="fn-text">This could have been
251290 avoided by <em>trailing</em> term references when data is written to
252291 them. This seriously hurds performance in some scenarios though. If this
253292 is desired, use <a class="func" href="foreigninclude.html#PL_put_variable()">PL_put_variable()</a>
304343 <code>term_t</code>, but all copies will always refer to the same term.
305344
306345 <dl class="latex">
307 <dt class="pubdef"><a name="PL_new_term_ref()"><var>term_t</var> <strong>PL_new_term_ref</strong>(<var></var>)</a></dt>
346 <dt class="pubdef"><a id="PL_new_term_ref()"><var>term_t</var> <strong>PL_new_term_ref</strong>(<var></var>)</a></dt>
308347 <dd class="defbody">
309348 Return a fresh reference to a term. The reference is allocated on the
310349 <em>local</em> stack. Allocating a term reference may trigger a
312351 allocation of the Prolog stacks. The returned reference describes a
313352 variable.
314353 </dd>
315 <dt class="pubdef"><a name="PL_new_term_refs()"><var>term_t</var> <strong>PL_new_term_refs</strong>(<var>int
354 <dt class="pubdef"><a id="PL_new_term_refs()"><var>term_t</var> <strong>PL_new_term_refs</strong>(<var>int
316355 n</var>)</a></dt>
317356 <dd class="defbody">
318357 Return <var>n</var> new term references. The first term reference is
332371 </pre>
333372
334373 </dd>
335 <dt class="pubdef"><a name="PL_copy_term_ref()"><var>term_t</var> <strong>PL_copy_term_ref</strong>(<var>term_t
374 <dt class="pubdef"><a id="PL_copy_term_ref()"><var>term_t</var> <strong>PL_copy_term_ref</strong>(<var>term_t
336375 from</var>)</a></dt>
337376 <dd class="defbody">
338377 Create a new term reference and make it point initially to the same term
339378 as <var>from</var>. This function is commonly used to copy a predicate
340379 argument to a term reference that may be written.
341380 </dd>
342 <dt class="pubdef"><a name="PL_reset_term_refs()"><var>void</var> <strong>PL_reset_term_refs</strong>(<var>term_t
381 <dt class="pubdef"><a id="PL_reset_term_refs()"><var>void</var> <strong>PL_reset_term_refs</strong>(<var>term_t
343382 after</var>)</a></dt>
344383 <dd class="defbody">
345384 Destroy all term references that have been created after <var>after</var>,
355394 </dd>
356395 </dl>
357396
358 <p><h4 id="sec:foreign-gc"><a name="sec:11.3.1.1"><span class="sec-nr">11.3.1.1</span> <span class="sec-title">Interaction
397 <p><h4 id="sec:foreign-gc"><a id="sec:11.3.1.1"><span class="sec-nr">11.3.1.1</span> <span class="sec-title">Interaction
359398 with the garbage collector and stack-shifter</span></a></h4>
360399
361 <a name="sec:foreign-gc"></a>
400 <a id="sec:foreign-gc"></a>
362401
363402 <p>Prolog implements two mechanisms for avoiding stack overflow: garbage
364403 collection and stack expansion. On machines that allow for it, Prolog
370409 the information necessary to perform its memory management without
371410 special precautions from the C programmer.
372411
373 <p><h3 id="sec:foreign-types"><a name="sec:11.3.2"><span class="sec-nr">11.3.2</span> <span class="sec-title">Other
412 <p><h3 id="sec:foreign-types"><a id="sec:11.3.2"><span class="sec-nr">11.3.2</span> <span class="sec-title">Other
374413 foreign interface types</span></a></h3>
375414
376 <a name="sec:foreign-types"></a>
415 <a id="sec:foreign-types"></a>
377416
378417 <dl class="latex">
379418 <dt><b>atom_t</b></dt>
430469 <dt><b>install_t</b></dt>
431470 <dd>
432471 Type for the install() and uninstall() functions of shared or dynamic
433 link libraries. See <a class="sec" href="foreignlink.html">section
472 link libraries. See <a class="sec" href="foreignlink.html#sec:11.2.3">section
434473 11.2.3</a>.
435474 </dd>
436475 <dt><b>int64_t</b></dt>
449488 </dd>
450489 </dl>
451490
452 <p><h4 id="sec:pl-arity-as-size"><a name="sec:11.3.2.1"><span class="sec-nr">11.3.2.1</span> <span class="sec-title">PL_ARITY_AS_SIZE</span></a></h4>
453
454 <a name="sec:pl-arity-as-size"></a>
491 <p><h4 id="sec:pl-arity-as-size"><a id="sec:11.3.2.1"><span class="sec-nr">11.3.2.1</span> <span class="sec-title">PL_ARITY_AS_SIZE</span></a></h4>
492
493 <a id="sec:pl-arity-as-size"></a>
455494
456495 <p>As of SWI-Prolog 7.3.12, the arity of terms has changed from <code>int</code>
457496 to <code>size_t</code>. To deal with this transition, all affecting
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="findhome.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreignnotes.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:foreignxmp"><a name="sec:11.7"><span class="sec-nr">11.7</span> <span class="sec-title">Example
235 <h2 id="sec:foreignxmp"><a id="sec:11.7"><span class="sec-nr">11.7</span> <span class="sec-title">Example
195236 of Using the Foreign Interface</span></a></h2>
196237
197 <a name="sec:foreignxmp"></a>
238 <a id="sec:foreignxmp"></a>
198239
199240 <p>Below is an example showing all stages of the declaration of a
200241 foreign predicate that transforms atoms possibly holding uppercase
236277 </pre>
237278
238279 <div class="caption"><b>Figure 10 : </b>Lowercase source file</div>
239 <a name="fig:lowercase-c"></a>
280 <a id="fig:lowercase-c"></a>
240281
241282 <pre class="code">
242283 % gcc -I/usr/local/lib/swipl-\plversion/include -fpic -c lowercase.c
254295
255296 <div class="caption"><b>Figure 11 : </b>Compiling the C source and
256297 loading the object file</div>
257 <a name="fig:load-foreign"></a>
298 <a id="fig:load-foreign"></a>
258299 </body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.32</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.32</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="forall2.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="gvar.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:format"><a name="sec:4.32"><span class="sec-nr">4.32</span> <span class="sec-title">Formatted
235 <h2 id="sec:format"><a id="sec:4.32"><span class="sec-nr">4.32</span> <span class="sec-title">Formatted
195236 Write</span></a></h2>
196237
197 <a name="sec:format"></a>
238 <a id="sec:format"></a>
198239
199240 <p>The current version of SWI-Prolog provides two formatted write
200 predicates. The `writef' family (<a name="idx:writef1:1383"></a><a class="pred" href="format.html#writef/1">writef/1</a>, <a name="idx:writef2:1384"></a><a class="pred" href="format.html#writef/2">writef/2</a>, <a name="idx:swritef3:1385"></a><a class="pred" href="format.html#swritef/3">swritef/3</a>),
241 predicates. The `writef' family (<a id="idx:writef1:1383"></a><a class="pred" href="format.html#writef/1">writef/1</a>, <a id="idx:writef2:1384"></a><a class="pred" href="format.html#writef/2">writef/2</a>, <a id="idx:swritef3:1385"></a><a class="pred" href="format.html#swritef/3">swritef/3</a>),
201242 is compatible with Edinburgh C-Prolog and should be considered
202 <em>deprecated</em>. The `format' family (<a name="idx:format1:1386"></a><a class="pred" href="format.html#format/1">format/1</a>, <a name="idx:format2:1387"></a><a class="pred" href="format.html#format/2">format/2</a>, <a name="idx:format3:1388"></a><a class="pred" href="format.html#format/3">format/3</a>),
243 <em>deprecated</em>. The `format' family (<a id="idx:format1:1386"></a><a class="pred" href="format.html#format/1">format/1</a>, <a id="idx:format2:1387"></a><a class="pred" href="format.html#format/2">format/2</a>, <a id="idx:format3:1388"></a><a class="pred" href="format.html#format/3">format/3</a>),
203244 was defined by Quintus Prolog and currently available in many Prolog
204245 systems, although the details vary.
205246
206 <p><h3 id="sec:writef"><a name="sec:4.32.1"><span class="sec-nr">4.32.1</span> <span class="sec-title">Writef</span></a></h3>
207
208 <a name="sec:writef"></a>
247 <p><h3 id="sec:writef"><a id="sec:4.32.1"><span class="sec-nr">4.32.1</span> <span class="sec-title">Writef</span></a></h3>
248
249 <a id="sec:writef"></a>
209250
210251 <dl class="latex">
211 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="writef/1"><strong>writef</strong>(<var>+Atom</var>)</a></dt>
212 <dd class="defbody">
213 Equivalent to <code>writef(Atom, []).</code> See <a name="idx:writef2:1389"></a><a class="pred" href="format.html#writef/2">writef/2</a>
252 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="writef/1"><strong>writef</strong>(<var>+Atom</var>)</a></dt>
253 <dd class="defbody">
254 Equivalent to <code>writef(Atom, []).</code> See <a id="idx:writef2:1389"></a><a class="pred" href="format.html#writef/2">writef/2</a>
214255 for details.
215256 </dd>
216 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="writef/2"><strong>writef</strong>(<var>+Format,
257 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="writef/2"><strong>writef</strong>(<var>+Format,
217258 +Arguments</var>)</a></dt>
218259 <dd class="defbody">
219260 Formatted write. <var>Format</var> is an atom whose characters will be
224265
225266 <p>Escape sequences to generate a single special character:
226267
227 <p><table border="2" frame="box" rules="groups" style="margin:auto">
228 <tr valign="top"><td><code>\n</code> </td><td>Output a newline character
229 (see also <a name="idx:nl01:1390"></a><a class="pred" href="chario.html#nl/0">nl/[0,1]</a>) </td></tr>
230 <tr valign="top"><td><code>\l</code> </td><td>Output a line separator
231 (same as <code>\n</code>) </td></tr>
232 <tr valign="top"><td><code>\r</code> </td><td>Output a carriage return
233 character (ASCII 13) </td></tr>
234 <tr valign="top"><td><code>\t</code> </td><td>Output the ASCII character
235 TAB (9) </td></tr>
236 <tr valign="top"><td><code>\\</code> </td><td>The character <code><code>\</code></code>
268 <p><table class="latex frame-box center">
269 <tr><td><code>\n</code> </td><td>Output a newline character (see also <a id="idx:nl01:1390"></a><a class="pred" href="chario.html#nl/0">nl/[0,1]</a>) </td></tr>
270 <tr><td><code>\l</code> </td><td>Output a line separator (same as <code>\n</code>) </td></tr>
271 <tr><td><code>\r</code> </td><td>Output a carriage return character
272 (ASCII 13) </td></tr>
273 <tr><td><code>\t</code> </td><td>Output the ASCII character TAB (9) </td></tr>
274 <tr><td><code>\\</code> </td><td>The character <code><code>\</code></code>
237275 is output </td></tr>
238 <tr valign="top"><td><code>\%</code> </td><td>The character <code><code>%</code></code>
276 <tr><td><code>\%</code> </td><td>The character <code><code>%</code></code>
239277 is output </td></tr>
240 <tr valign="top"><td><code>\nnn</code> </td><td>where &lt;<var>nnn</var>&gt;
241 is an integer (1-3 digits); the character with code &lt;<var>nnn</var>&gt;
242 is output (NB : &lt;<var>nnn</var>&gt; is read as <strong>decimal</strong>) </td></tr>
278 <tr><td><code>\nnn</code> </td><td>where &lt;<var>nnn</var>&gt; is an
279 integer (1-3 digits); the character with code &lt;<var>nnn</var>&gt; is
280 output (NB : &lt;<var>nnn</var>&gt; is read as <strong>decimal</strong>) </td></tr>
243281 </table>
244282
245283 <p>Note that <code>\l</code>, <code>\nnn</code> and <code>\\</code> are
246284 interpreted differently when character escapes are in effect. See
247 <a class="sec" href="syntax.html">section 2.16.1.3</a>.
285 <a class="sec" href="syntax.html#sec:2.16.1.3">section 2.16.1.3</a>.
248286
249287 <p>Escape sequences to include arguments from <var>Arguments</var>. Each
250288 time a
251289 % escape sequence is found in <var>Format</var> the next argument from <var>Arguments</var>
252290 is formatted according to the specification.
253291
254 <p><table border="2" frame="box" rules="groups" style="margin:auto">
255 <tr valign="top"><td><code>%t</code> </td><td><a name="idx:print1:1391"></a><a class="pred" href="termrw.html#print/1">print/1</a>
292 <p><table class="latex frame-box center">
293 <tr><td><code>%t</code> </td><td><a id="idx:print1:1391"></a><a class="pred" href="termrw.html#print/1">print/1</a>
256294 the next item (mnemonic: term) </td></tr>
257 <tr valign="top"><td><code>%w</code> </td><td><a name="idx:write1:1392"></a><a class="pred" href="termrw.html#write/1">write/1</a>
295 <tr><td><code>%w</code> </td><td><a id="idx:write1:1392"></a><a class="pred" href="termrw.html#write/1">write/1</a>
258296 the next item </td></tr>
259 <tr valign="top"><td><code>%q</code> </td><td><a name="idx:writeq1:1393"></a><a class="pred" href="termrw.html#writeq/1">writeq/1</a>
297 <tr><td><code>%q</code> </td><td><a id="idx:writeq1:1393"></a><a class="pred" href="termrw.html#writeq/1">writeq/1</a>
260298 the next item </td></tr>
261 <tr valign="top"><td><code>%d</code> </td><td>Write the term, ignoring
262 operators. See also
263 <a name="idx:writeterm2:1394"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
264 Mnemonic: old Edinburgh <a name="idx:display1:1395"></a><span class="pred-ext">display/1</span> </td></tr>
265 <tr valign="top"><td><code>%p</code> </td><td><a name="idx:print1:1396"></a><a class="pred" href="termrw.html#print/1">print/1</a>
299 <tr><td><code>%d</code> </td><td>Write the term, ignoring operators. See
300 also
301 <a id="idx:writeterm2:1394"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
302 Mnemonic: old Edinburgh <a id="idx:display1:1395"></a><span class="pred-ext">display/1</span> </td></tr>
303 <tr><td><code>%p</code> </td><td><a id="idx:print1:1396"></a><a class="pred" href="termrw.html#print/1">print/1</a>
266304 the next item (identical to <code>%t</code>) </td></tr>
267 <tr valign="top"><td><code>%n</code> </td><td>Put the next item as a
268 character (i.e., it is a character code) </td></tr>
269 <tr valign="top"><td><code>%r</code> </td><td>Write the next item N
270 times where N is the second item (an integer) </td></tr>
271 <tr valign="top"><td><code>%s</code> </td><td>Write the next item as a
272 String (so it must be a list of characters) </td></tr>
273 <tr valign="top"><td><code>%f</code> </td><td>Perform a <a name="idx:ttyflush0:1397"></a><a class="pred" href="chario.html#ttyflush/0">ttyflush/0</a>
305 <tr><td><code>%n</code> </td><td>Put the next item as a character (i.e.,
306 it is a character code) </td></tr>
307 <tr><td><code>%r</code> </td><td>Write the next item N times where N is
308 the second item (an integer) </td></tr>
309 <tr><td><code>%s</code> </td><td>Write the next item as a String (so it
310 must be a list of characters) </td></tr>
311 <tr><td><code>%f</code> </td><td>Perform a <a id="idx:ttyflush0:1397"></a><a class="pred" href="chario.html#ttyflush/0">ttyflush/0</a>
274312 (no items used) </td></tr>
275 <tr valign="top"><td><code>%Nc</code> </td><td>Write the next item
276 Centered in <var>N</var> columns </td></tr>
277 <tr valign="top"><td><code>%Nl</code> </td><td>Write the next item Left
278 justified in <var>N</var> columns </td></tr>
279 <tr valign="top"><td><code>%Nr</code> </td><td>Write the next item Right
280 justified in <var>N</var> columns.
313 <tr><td><code>%Nc</code> </td><td>Write the next item Centered in <var>N</var>
314 columns </td></tr>
315 <tr><td><code>%Nl</code> </td><td>Write the next item Left justified in <var>N</var>
316 columns </td></tr>
317 <tr><td><code>%Nr</code> </td><td>Write the next item Right justified in <var>N</var>
318 columns.
281319 <var>N</var> is a decimal number with at least one digit. The item must
282320 be an atom, integer, float or string. </td></tr>
283321 </table>
284322 </dd>
285 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="swritef/3"><strong>swritef</strong>(<var>-String,
323 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="swritef/3"><strong>swritef</strong>(<var>-String,
286324 +Format, +Arguments</var>)</a></dt>
287325 <dd class="defbody">
288 Equivalent to <a name="idx:writef2:1398"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
326 Equivalent to <a id="idx:writef2:1398"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
289327 but ``writes'' the result on <var>String</var> instead of the current
290328 output stream. Example:
291329
296334 </pre>
297335
298336 </dd>
299 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="swritef/2"><strong>swritef</strong>(<var>-String,
337 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="swritef/2"><strong>swritef</strong>(<var>-String,
300338 +Format</var>)</a></dt>
301339 <dd class="defbody">
302340 Equivalent to <code>swritef(String, Format, []).</code>
303341 </dd>
304342 </dl>
305343
306 <p><h3 id="sec:format-predicates"><a name="sec:4.32.2"><span class="sec-nr">4.32.2</span> <span class="sec-title">Format</span></a></h3>
307
308 <a name="sec:format-predicates"></a>
344 <p><h3 id="sec:format-predicates"><a id="sec:4.32.2"><span class="sec-nr">4.32.2</span> <span class="sec-title">Format</span></a></h3>
345
346 <a id="sec:format-predicates"></a>
309347
310348 <p>The format family of predicates is the most versatile and portable<sup class="fn">126<span class="fn-text">Unfortunately
311349 not covered by any standard.</span></sup> way to produce textual output.
312350
313351 <dl class="latex">
314 <dt class="pubdef"><a name="format/1"><strong>format</strong>(<var>+Format</var>)</a></dt>
352 <dt class="pubdef"><a id="format/1"><strong>format</strong>(<var>+Format</var>)</a></dt>
315353 <dd class="defbody">
316354 Defined as `<code>format(Format) :- format(Format, []).</code>'. See
317 <a name="idx:format2:1399"></a><a class="pred" href="format.html#format/2">format/2</a>
355 <a id="idx:format2:1399"></a><a class="pred" href="format.html#format/2">format/2</a>
318356 for details.</dd>
319 <dt class="pubdef"><a name="format/2"><strong>format</strong>(<var>+Format,
357 <dt class="pubdef"><a id="format/2"><strong>format</strong>(<var>+Format,
320358 :Arguments</var>)</a></dt>
321359 <dd class="defbody">
322360 <var>Format</var> is an atom, list of character codes, or a Prolog
349387 <p>Numeric conversion (<code>d</code>, <code>D</code>, <code>e</code>, <code>E</code>, <code>f</code>, <code>g</code>
350388 and <code>G</code>) accept an arithmetic expression as argument. This is
351389 introduced to handle rational numbers transparently (see
352 <a class="sec" href="arith.html">section 4.27.2.2</a>). The floating
353 point conversions allow for unlimited precision for printing rational
354 numbers in decimal form. E.g., the following will write as many 3's as
355 you want by changing the `50'.
390 <a class="sec" href="arith.html#sec:4.27.2.2">section 4.27.2.2</a>). The
391 floating point conversions allow for unlimited precision for printing
392 rational numbers in decimal form. E.g., the following will write as many
393 3's as you want by changing the `50'.
356394
357395 <pre class="code">
358396 ?- format('~50f', [10 rdiv 3]).
377415 the actually emitted bytes are defined by the character encoding of the
378416 output stream and an exception may be raised if the output stream is not
379417 capable of representing the requested Unicode character. See
380 <a class="sec" href="widechars.html">section 2.19.1</a> for details.
418 <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a> for
419 details.
381420
382421 <p>
383422 <li><code>d</code><br>
387426 integers, such as handling amounts of money).
388427
389428 <p>The colon modifier (e.g., <code>~:d</code>) causes the number to be
390 printed according to the locale of the output stream. See <a class="sec" href="locale.html">section
429 printed according to the locale of the output stream. See <a class="sec" href="locale.html#sec:4.23">section
391430 4.23</a>.
392431
393432 <p>
433472 <li><code>I</code><br>
434473 Emit a decimal number using Prolog digit grouping (the underscore,
435474 <code>_</code>). The argument describes the size of each digit group.
436 The default is 3. See also <a class="sec" href="syntax.html">section
475 The default is 3. See also <a class="sec" href="syntax.html#sec:2.16.1.5">section
437476 2.16.1.5</a>. For example:
438477
439478 <pre class="code">
443482
444483 <p>
445484 <li><code>k</code><br>
446 Give the next argument to <a name="idx:writecanonical1:1400"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>.
485 Give the next argument to <a id="idx:writecanonical1:1400"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>.
447486 <li><code>n</code><br>
448487 Output a newline character.
449488 <li><code>N</code><br>
450489 Only output a newline if the last character output on this stream was
451490 not a newline. Not properly implemented yet.
452491 <li><code>p</code><br>
453 Give the next argument to <a name="idx:print1:1401"></a><a class="pred" href="termrw.html#print/1">print/1</a>.
492 Give the next argument to <a id="idx:print1:1401"></a><a class="pred" href="termrw.html#print/1">print/1</a>.
454493 <li><code>q</code><br>
455 Give the next argument to <a name="idx:writeq1:1402"></a><a class="pred" href="termrw.html#writeq/1">writeq/1</a>.
494 Give the next argument to <a id="idx:writeq1:1402"></a><a class="pred" href="termrw.html#writeq/1">writeq/1</a>.
456495
457496 <p>
458497 <li><code>r</code><br>
466505 <li><code>R</code><br>
467506 Same as <b>r</b>, but uses uppercase letters for digits above 9.
468507 <li><code>s</code><br>
469 Output text from a list of character codes or a string (see <a name="idx:string1:1403"></a><a class="pred" href="typetest.html#string/1">string/1</a>
508 Output text from a list of character codes or a string (see <a id="idx:string1:1403"></a><a class="pred" href="typetest.html#string/1">string/1</a>
470509 and
471 <a class="sec" href="strings.html">section 5.2</a>) from the next
472 argument.<sup class="fn">128<span class="fn-text">The <b>s</b> modifier
473 also accepts an atom for compatibility. This is deprecated due to the
474 ambiguity of <code>[]</code>.</span></sup>
510 <a class="sec" href="strings.html#sec:5.2">section 5.2</a>) from the
511 next argument.<sup class="fn">128<span class="fn-text">The <b>s</b>
512 modifier also accepts an atom for compatibility. This is deprecated due
513 to the ambiguity of <code>[]</code>.</span></sup>
475514 <li><code>@</code><br>
476515 Interpret the next argument as a goal and execute it. Output written to
477516 the <code>current_output</code> stream is inserted at this place. Goal
478 is called in the module calling <a name="idx:format3:1404"></a><a class="pred" href="format.html#format/3">format/3</a>.
517 is called in the module calling <a id="idx:format3:1404"></a><a class="pred" href="format.html#format/3">format/3</a>.
479518 This option is not present in the original definition by Quintus, but
480519 supported by some other Prolog systems.
481520 <li><code>t</code><br>
508547
509548 <p>
510549 <li><code>w</code><br>
511 Give the next argument to <a name="idx:write1:1405"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
550 Give the next argument to <a id="idx:write1:1405"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
512551 <li><code>W</code><br>
513 Give the next two arguments to <a name="idx:writeterm2:1406"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
552 Give the next two arguments to <a id="idx:writeterm2:1406"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
514553 For example,
515554 <code>format('~W', [Term, [numbervars(true)]])</code>. This option is
516555 SWI-Prolog specific.
536575 </pre>
537576
538577 </dd>
539 <dt class="pubdef"><a name="format/3"><strong>format</strong>(<var>+Output,
578 <dt class="pubdef"><a id="format/3"><strong>format</strong>(<var>+Output,
540579 +Format, :Arguments</var>)</a></dt>
541580 <dd class="defbody">
542 As <a name="idx:format2:1407"></a><a class="pred" href="format.html#format/2">format/2</a>,
581 As <a id="idx:format2:1407"></a><a class="pred" href="format.html#format/2">format/2</a>,
543582 but write the output on the given <var>Output</var>. The de-facto
544583 standard only allows <var>Output</var> to be a stream. The SWI-Prolog
545584 implementation allows all valid arguments for
546 <a name="idx:withoutputto2:1408"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.<sup class="fn">129<span class="fn-text">Earlier
585 <a id="idx:withoutputto2:1408"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.<sup class="fn">129<span class="fn-text">Earlier
547586 versions defined sformat/3 . These predicates have been moved to the
548587 library <code>library(backcomp)</code>.</span></sup> For example:
549588
555594 <p></dd>
556595 </dl>
557596
558 <p><h3 id="sec:format-hook"><a name="sec:4.32.3"><span class="sec-nr">4.32.3</span> <span class="sec-title">Programming
597 <p><h3 id="sec:format-hook"><a id="sec:4.32.3"><span class="sec-nr">4.32.3</span> <span class="sec-title">Programming
559598 Format</span></a></h3>
560599
561 <a name="sec:format-hook"></a>
600 <a id="sec:format-hook"></a>
562601
563602 <dl class="latex">
564 <dt class="pubdef"><a name="format_predicate/2"><strong>format_predicate</strong>(<var>+Char,
603 <dt class="pubdef"><a id="format_predicate/2"><strong>format_predicate</strong>(<var>+Char,
565604 +Head</var>)</a></dt>
566605 <dd class="defbody">
567606 If a sequence <code>~c</code> (tilde, followed by some character) is
568 found, the <a name="idx:format3:1409"></a><a class="pred" href="format.html#format/3">format/3</a>
607 found, the <a id="idx:format3:1409"></a><a class="pred" href="format.html#format/3">format/3</a>
569608 and friends first check whether the user has defined a predicate to
570609 handle the format. If not, the built-in formatting rules described above
571610 are used. <var>Char</var> is either a character code or a one-character
576615 if no argument is specified. The remaining arguments are filled from the
577616 argument list. The example below defines <code>~T</code> to print a
578617 timestamp in ISO8601 format (see
579 <a name="idx:formattime3:1410"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>).
618 <a id="idx:formattime3:1410"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>).
580619 The subsequent block illustrates a possible call.
581620
582621 <pre class="code">
595634 </pre>
596635
597636 </dd>
598 <dt class="pubdef"><a name="current_format_predicate/2"><strong>current_format_predicate</strong>(<var>?Code,
637 <dt class="pubdef"><a id="current_format_predicate/2"><strong>current_format_predicate</strong>(<var>?Code,
599638 ?:Head</var>)</a></dt>
600639 <dd class="defbody">
601640 True when <code><code>~</code></code><var>Code</var> is handled by the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section F.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="library.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="opsummary.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:funcsummary"><a name="sec:F.3"><span class="sec-nr">F.3</span> <span class="sec-title">Arithmetic
235 <h2 id="sec:funcsummary"><a id="sec:F.3"><span class="sec-nr">F.3</span> <span class="sec-title">Arithmetic
195236 Functions</span></a></h2>
196237
197 <a name="sec:funcsummary"></a>
238 <a id="sec:funcsummary"></a>
198239 <table>
199240 <tr><td><a class="function" href="arith.html#f-*/2">*/2</a></td><td>Multiplication</td></tr>
200241 <tr><td><a class="function" href="arith.html#f-**/2">**/2</a></td><td>Power
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.15</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="packs.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="syntax.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:gc"><a name="sec:2.15"><span class="sec-nr">2.15</span> <span class="sec-title">Garbage
235 <h2 id="sec:gc"><a id="sec:2.15"><span class="sec-nr">2.15</span> <span class="sec-title">Garbage
195236 Collection</span></a></h2>
196237
197 <a name="sec:gc"></a>
238 <a id="sec:gc"></a>
198239
199240 <p>SWI-Prolog provides garbage collection, last-call optimization and
200241 atom garbage collection. These features are controlled using Prolog
201 flags (see <a name="idx:currentprologflag2:211"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
242 flags (see <a id="idx:currentprologflag2:211"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
202243
203244 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="cmdline.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="help.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:gemacs"><a name="sec:2.5"><span class="sec-nr">2.5</span> <span class="sec-title">GNU
235 <h2 id="sec:gemacs"><a id="sec:2.5"><span class="sec-nr">2.5</span> <span class="sec-title">GNU
195236 Emacs Interface</span></a></h2>
196237
197 <a name="sec:gemacs"></a>
198
199 <p><a name="idx:GNUEmacs:46"></a><a name="idx:Emacs:47"></a>Unfortunately
238 <a id="sec:gemacs"></a>
239
240 <p><a id="idx:GNUEmacs:46"></a><a id="idx:Emacs:47"></a>Unfortunately
200241 the default Prolog mode of GNU&nbsp;Emacs is not very good. There are
201242 several alternatives though:
202243
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.13</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="error.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="iostream.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:gensym"><a name="sec:A.13"><span class="sec-nr">A.13</span> <span class="sec-title">library(gensym):
235 <h2 id="sec:gensym"><a id="sec:A.13"><span class="sec-nr">A.13</span> <span class="sec-title">library(gensym):
195236 Generate unique identifiers</span></a></h2>
196237
197 <a name="sec:gensym"></a>
238 <a id="sec:gensym"></a>
198239
199240 <p>Gensym (<b>Gen</b>erate <b>Sym</b>bols) is an old library for
200241 generating unique symbols (atoms). Such symbols are generated from a
207248 over all threads.
208249
209250 <dl class="latex">
210 <dt class="pubdef"><a name="gensym/2"><strong>gensym</strong>(<var>+Base,
251 <dt class="pubdef"><a id="gensym/2"><strong>gensym</strong>(<var>+Base,
211252 -Unique</var>)</a></dt>
212253 <dd class="defbody">
213254 Generate a unique atom from base <var>Base</var> and unify it with <var>Unique</var>.
214255 <var>Base</var> should be an atom. The first call will return &lt;<var>base</var>&gt;1
215256 , the next &lt;<var>base</var>&gt;2 , etc. Note that this is no
216257 guarantee that the atom is unique in the system.</dd>
217 <dt class="pubdef"><a name="reset_gensym/1"><strong>reset_gensym</strong>(<var>+Base</var>)</a></dt>
258 <dt class="pubdef"><a id="reset_gensym/1"><strong>reset_gensym</strong>(<var>+Base</var>)</a></dt>
218259 <dd class="defbody">
219260 Restart generation of identifiers from <var>Base</var> at &lt;<var>Base</var>&gt;1.
220261 Used to make sure a program produces the same results on subsequent
221262 runs. Use with care.</dd>
222 <dt class="pubdef"><a name="reset_gensym/0"><strong>reset_gensym</strong></a></dt>
263 <dt class="pubdef"><a id="reset_gensym/0"><strong>reset_gensym</strong></a></dt>
223264 <dd class="defbody">
224265 Reset gensym for all registered keys. This predicate is available for
225266 compatibility only. New code is strongly advised to avoid the use of
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="portabilitystrategies.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="license.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:glossary"><a name="sec:D"><span class="sec-nr">D</span> <span class="sec-title">Glossary
235 <h1 id="sec:glossary"><a id="sec:D"><span class="sec-nr">D</span> <span class="sec-title">Glossary
195236 of Terms</span></a></h1>
196237
197 <a name="sec:glossary"></a>
238 <a id="sec:glossary"></a>
198239
199240 <dl class="latex">
200 <dt><a name="gloss:anonymou"><strong>anonymous [variable]</strong></a></dt>
201 <dd class="defbody">
202 <a name="idx:anonymousvariable:2266"></a><a name="idx:variableanonymous:2267"></a>The
241 <dt><a id="gloss:anonymou"><strong>anonymous [variable]</strong></a></dt>
242 <dd class="defbody">
243 <a id="idx:anonymousvariable:2270"></a><a id="idx:variableanonymous:2271"></a>The
203244 variable <code>_</code> is called the <a class="gloss" href="glossary.html#gloss:anonymou">anonymous</a>
204245 variable. Multiple occurrences of <code>_</code> in a single <a class="gloss" href="glossary.html#gloss:term">term</a>
205246 are not <a class="gloss" href="glossary.html#gloss:shared">shared</a>.</dd>
206 <dt><a name="gloss:argument"><strong>arguments</strong></a></dt>
247 <dt><a id="gloss:argument"><strong>arguments</strong></a></dt>
207248 <dd class="defbody">
208249 Arguments are <a class="gloss" href="glossary.html#gloss:term">terms</a>
209250 that appear in a <a class="gloss" href="glossary.html#gloss:compound">compound</a> <a class="gloss" href="glossary.html#gloss:term">term</a>. <var>A1</var>
210251 and <var>a2</var> are the first and second argument of the term
211252 <code>myterm(A1, a2)</code>.</dd>
212 <dt><a name="gloss:arity"><strong>arity</strong></a></dt>
213 <dd class="defbody">
214 <a name="idx:arity:2268"></a>Argument count (= number of arguments) of a <a class="gloss" href="glossary.html#gloss:compound">compound</a> <a class="gloss" href="glossary.html#gloss:term">term</a>.</dd>
215 <dt><a name="gloss:assert"><strong>assert</strong></a></dt>
216 <dd class="defbody">
217 <a name="idx:assert:2269"></a>Add a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
253 <dt><a id="gloss:arity"><strong>arity</strong></a></dt>
254 <dd class="defbody">
255 <a id="idx:arity:2272"></a>Argument count (= number of arguments) of a <a class="gloss" href="glossary.html#gloss:compound">compound</a> <a class="gloss" href="glossary.html#gloss:term">term</a>.</dd>
256 <dt><a id="gloss:assert"><strong>assert</strong></a></dt>
257 <dd class="defbody">
258 <a id="idx:assert:2273"></a>Add a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
218259 to a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>.
219260 Clauses can be added at either end of the clause-list of a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>.
220 See <a name="idx:asserta1:2270"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
221 and <a name="idx:assertz1:2271"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>.</dd>
222 <dt><a name="gloss:atom"><strong>atom</strong></a></dt>
223 <dd class="defbody">
224 <a name="idx:atom:2272"></a>Textual constant. Used as name for <a class="gloss" href="glossary.html#gloss:compound">compound</a>
261 See <a id="idx:asserta1:2274"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
262 and <a id="idx:assertz1:2275"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>.</dd>
263 <dt><a id="gloss:atom"><strong>atom</strong></a></dt>
264 <dd class="defbody">
265 <a id="idx:atom:2276"></a>Textual constant. Used as name for <a class="gloss" href="glossary.html#gloss:compound">compound</a>
225266 terms, to represent constants or text.</dd>
226 <dt><a name="gloss:backtracking"><strong>backtracking</strong></a></dt>
227 <dd class="defbody">
228 <a name="idx:backtracking:2273"></a>Search process used by Prolog. If a
267 <dt><a id="gloss:backtracking"><strong>backtracking</strong></a></dt>
268 <dd class="defbody">
269 <a id="idx:backtracking:2277"></a>Search process used by Prolog. If a
229270 predicate offers multiple
230271 <a class="gloss" href="glossary.html#gloss:clause">clauses</a> to solve
231272 a <a class="gloss" href="glossary.html#gloss:goal">goal</a>, they are
236277 the <a class="gloss" href="glossary.html#gloss:variable">variables</a>),
237278 causing Prolog to reject the previously chosen <a class="gloss" href="glossary.html#gloss:clause">clause</a>
238279 and try the next one.</dd>
239 <dt><a name="gloss:binding"><strong>binding [of a variable]</strong></a></dt>
240 <dd class="defbody">
241 <a name="idx:binding:2274"></a>Current value of the <a class="gloss" href="glossary.html#gloss:variable">variable</a>.
280 <dt><a id="gloss:binding"><strong>binding [of a variable]</strong></a></dt>
281 <dd class="defbody">
282 <a id="idx:binding:2278"></a>Current value of the <a class="gloss" href="glossary.html#gloss:variable">variable</a>.
242283 See also <a class="gloss" href="glossary.html#gloss:backtracking">backtracking</a>
243284 and
244285 <a class="gloss" href="glossary.html#gloss:query">query</a>.</dd>
245 <dt><a name="gloss:built-in"><strong>built-in [predicate]</strong></a></dt>
246 <dd class="defbody">
247 <a name="idx:builtinpredicate:2275"></a>Predicate that is part of the
286 <dt><a id="gloss:built-in"><strong>built-in [predicate]</strong></a></dt>
287 <dd class="defbody">
288 <a id="idx:builtinpredicate:2279"></a>Predicate that is part of the
248289 Prolog system. Built-in predicates cannot be redefined by the user,
249290 unless this is overruled using
250 <a name="idx:redefinesystempredicate1:2276"></a><a class="pred" href="db.html#redefine_system_predicate/1">redefine_system_predicate/1</a>.</dd>
251 <dt><a name="gloss:body"><strong>body</strong></a></dt>
252 <dd class="defbody">
253 <a name="idx:body:2277"></a>Part of a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
291 <a id="idx:redefinesystempredicate1:2280"></a><a class="pred" href="db.html#redefine_system_predicate/1">redefine_system_predicate/1</a>.</dd>
292 <dt><a id="gloss:body"><strong>body</strong></a></dt>
293 <dd class="defbody">
294 <a id="idx:body:2281"></a>Part of a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
254295 behind the <a class="gloss" href="glossary.html#gloss:neck">neck</a>
255296 operator (<code><code>:-</code></code>).</dd>
256 <dt><a name="gloss:choice-point"><strong>choice point</strong></a></dt>
257 <dd class="defbody">
258 <a name="idx:choicepoint:2278"></a>A <a class="gloss" href="glossary.html#gloss:choice-point">choice point</a>
297 <dt><a id="gloss:choice-point"><strong>choice point</strong></a></dt>
298 <dd class="defbody">
299 <a id="idx:choicepoint:2282"></a>A <a class="gloss" href="glossary.html#gloss:choice-point">choice point</a>
259300 represents a choice in the search for a <a class="gloss" href="glossary.html#gloss:solution">solution</a>.
260301 Choice points are created if multiple clauses match a <a class="gloss" href="glossary.html#gloss:query">query</a>
261302 or using disjunction (<a class="pred" href="control.html#;/2">;/2</a>).
264305 is restored and search continues with the next alternative (i.e., next
265306 clause or second branch of
266307 <a class="pred" href="control.html#;/2">;/2</a>).</dd>
267 <dt><a name="gloss:clause"><strong>clause</strong></a></dt>
268 <dd class="defbody">
269 <a name="idx:clause:2279"></a>`Sentence' of a Prolog program. A <a class="gloss" href="glossary.html#gloss:clause">clause</a>
308 <dt><a id="gloss:clause"><strong>clause</strong></a></dt>
309 <dd class="defbody">
310 <a id="idx:clause:2283"></a>`Sentence' of a Prolog program. A <a class="gloss" href="glossary.html#gloss:clause">clause</a>
270311 consists of a <a class="gloss" href="glossary.html#gloss:head">head</a>
271312 and
272313 <a class="gloss" href="glossary.html#gloss:body">body</a> separated by
281322
282323 <p>Expressed as ``X is a parent if X is a father of someone''. See also
283324 <a class="gloss" href="glossary.html#gloss:variable">variable</a> and <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>.</dd>
284 <dt><a name="gloss:compile"><strong>compile</strong></a></dt>
325 <dt><a id="gloss:compile"><strong>compile</strong></a></dt>
285326 <dd class="defbody">
286327 Process where a Prolog <a class="gloss" href="glossary.html#gloss:program">program</a>
287328 is translated to a sequence of instructions. See also <a class="gloss" href="glossary.html#gloss:interpreted">interpreted</a>.
288329 SWI-Prolog always compiles your program before executing it.</dd>
289 <dt><a name="gloss:compound"><strong>compound [term]</strong></a></dt>
290 <dd class="defbody">
291 <a name="idx:compound:2280"></a>Also called <a class="gloss" href="glossary.html#gloss:structure">structure</a>.
330 <dt><a id="gloss:compound"><strong>compound [term]</strong></a></dt>
331 <dd class="defbody">
332 <a id="idx:compound:2284"></a>Also called <a class="gloss" href="glossary.html#gloss:structure">structure</a>.
292333 It consists of a name followed by <var>N</var>
293334 <a class="gloss" href="glossary.html#gloss:argument">arguments</a>, each
294335 of which are <a class="gloss" href="glossary.html#gloss:term">terms</a>. <var>N</var>
295336 is called the
296337 <a class="gloss" href="glossary.html#gloss:arity">arity</a> of the term.</dd>
297 <dt><a name="gloss:context-module"><strong>context module</strong></a></dt>
298 <dd class="defbody">
299 <a name="idx:contextmodule:2281"></a><a name="idx:modulecontex:2282"></a>If
338 <dt><a id="gloss:context-module"><strong>context module</strong></a></dt>
339 <dd class="defbody">
340 <a id="idx:contextmodule:2285"></a><a id="idx:modulecontex:2286"></a>If
300341 a <a class="gloss" href="glossary.html#gloss:term">term</a> is referring
301342 to a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
302343 in a <a class="gloss" href="glossary.html#gloss:module">module</a>, the
307348 is <a class="gloss" href="glossary.html#gloss:module-transparent">module transparent</a>,
308349 in which case the <a class="gloss" href="glossary.html#gloss:context-module">context module</a>
309350 is inherited from the parent
310 <a class="gloss" href="glossary.html#gloss:goal">goal</a>. See also <a name="idx:moduletransparent1:2283"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
351 <a class="gloss" href="glossary.html#gloss:goal">goal</a>. See also <a id="idx:moduletransparent1:2287"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
311352 and <a class="gloss" href="glossary.html#gloss:meta-predicate">meta-predicate</a>.</dd>
312 <dt><a name="gloss:dcg"><strong>dcg</strong></a></dt>
313 <dd class="defbody">
314 <a name="idx:dcg:2284"></a>Abbreviation for <b>Definite Clause Grammar</b>.</dd>
315 <dt><a name="gloss:det"><strong>det [determinism]</strong></a></dt>
316 <dd class="defbody">
317 <a name="idx:det:2285"></a>Short for <a class="gloss" href="glossary.html#gloss:deterministic">deterministic</a>.</dd>
318 <dt><a name="gloss:determinism"><strong>determinism</strong></a></dt>
319 <dd class="defbody">
320 <a name="idx:determinism:2286"></a>How many solutions a <a class="gloss" href="glossary.html#gloss:goal">goal</a>
353 <dt><a id="gloss:dcg"><strong>dcg</strong></a></dt>
354 <dd class="defbody">
355 <a id="idx:dcg:2288"></a>Abbreviation for <b>Definite Clause Grammar</b>.</dd>
356 <dt><a id="gloss:det"><strong>det [determinism]</strong></a></dt>
357 <dd class="defbody">
358 <a id="idx:det:2289"></a>Short for <a class="gloss" href="glossary.html#gloss:deterministic">deterministic</a>.</dd>
359 <dt><a id="gloss:determinism"><strong>determinism</strong></a></dt>
360 <dd class="defbody">
361 <a id="idx:determinism:2290"></a>How many solutions a <a class="gloss" href="glossary.html#gloss:goal">goal</a>
321362 can provide. Values are `nondet' (zero to infinite), `multi' (one to
322363 infinite), `det' (exactly one) and `semidet' (zero or one).</dd>
323 <dt><a name="gloss:deterministic"><strong>deterministic</strong></a></dt>
324 <dd class="defbody">
325 <a name="idx:deterministic:2287"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
364 <dt><a id="gloss:deterministic"><strong>deterministic</strong></a></dt>
365 <dd class="defbody">
366 <a id="idx:deterministic:2291"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
326367 is <a class="gloss" href="glossary.html#gloss:deterministic">deterministic</a>
327368 if it succeeds exactly one time without leaving a <a class="gloss" href="glossary.html#gloss:choice-point">choice point</a>.</dd>
328 <dt><a name="gloss:dynamic"><strong>dynamic [predicate]</strong></a></dt>
329 <dd class="defbody">
330 <a name="idx:dynamicpredicate:2288"></a><a name="idx:predicatedynamic:2289"></a>A <a class="gloss" href="glossary.html#gloss:dynamic">dynamic</a>
369 <dt><a id="gloss:dynamic"><strong>dynamic [predicate]</strong></a></dt>
370 <dd class="defbody">
371 <a id="idx:dynamicpredicate:2292"></a><a id="idx:predicatedynamic:2293"></a>A <a class="gloss" href="glossary.html#gloss:dynamic">dynamic</a>
331372 predicate is a predicate to which <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
332373 may be
333374 <a class="gloss" href="glossary.html#gloss:assert">assert</a>ed and from
334375 which <a class="gloss" href="glossary.html#gloss:clause">clauses</a> may
335376 be <a class="gloss" href="glossary.html#gloss:retract">retract</a>ed
336377 while the program is running. See also <a class="gloss" href="glossary.html#gloss:update-view">update view</a>.</dd>
337 <dt><a name="gloss:exported"><strong>exported [predicate]</strong></a></dt>
338 <dd class="defbody">
339 <a name="idx:exportedpredicate:2290"></a><a name="idx:predicateexported:2291"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
378 <dt><a id="gloss:exported"><strong>exported [predicate]</strong></a></dt>
379 <dd class="defbody">
380 <a id="idx:exportedpredicate:2294"></a><a id="idx:predicateexported:2295"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
340381 is said to be <a class="gloss" href="glossary.html#gloss:exported">exported</a>
341382 from a <a class="gloss" href="glossary.html#gloss:module">module</a> if
342383 it appears in the <a class="gloss" href="glossary.html#gloss:public-list">public list</a>.
343384 This implies that the predicate can be <a class="gloss" href="glossary.html#gloss:imported">imported</a>
344 into another module to make it visible there. See also <a name="idx:usemodule12:2292"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.</dd>
345 <dt><a name="gloss:fact"><strong>fact</strong></a></dt>
346 <dd class="defbody">
347 <a name="idx:fact:2293"></a><a class="gloss" href="glossary.html#gloss:clause">Clause</a>
385 into another module to make it visible there. See also <a id="idx:usemodule12:2296"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.</dd>
386 <dt><a id="gloss:fact"><strong>fact</strong></a></dt>
387 <dd class="defbody">
388 <a id="idx:fact:2297"></a><a class="gloss" href="glossary.html#gloss:clause">Clause</a>
348389 without a <a class="gloss" href="glossary.html#gloss:body">body</a>.
349390 This is called a fact because, interpreted as logic, there is no
350391 condition to be satisfied. The example below states <code>john</code> is
355396 </pre>
356397
357398 </dd>
358 <dt><a name="gloss:fail"><strong>fail</strong></a></dt>
399 <dt><a id="gloss:fail"><strong>fail</strong></a></dt>
359400 <dd class="defbody">
360401 A <a class="gloss" href="glossary.html#gloss:goal">goal</a> is said to
361402 haved failed if it could not be <a class="gloss" href="glossary.html#gloss:prove">proven</a>.</dd>
362 <dt><a name="gloss:float"><strong>float</strong></a></dt>
403 <dt><a id="gloss:float"><strong>float</strong></a></dt>
363404 <dd class="defbody">
364405 Computer's crippled representation of a real number. Represented as
365406 `IEEE double'.</dd>
366 <dt><a name="gloss:foreign"><strong>foreign</strong></a></dt>
407 <dt><a id="gloss:foreign"><strong>foreign</strong></a></dt>
367408 <dd class="defbody">
368409 Computer code expressed in languages other than Prolog. SWI-Prolog can
369410 only cooperate directly with the C and C++ computer languages.</dd>
370 <dt><a name="gloss:functor"><strong>functor</strong></a></dt>
371 <dd class="defbody">
372 <a name="idx:functor:2294"></a>Combination of name and <a class="gloss" href="glossary.html#gloss:arity">arity</a>
411 <dt><a id="gloss:functor"><strong>functor</strong></a></dt>
412 <dd class="defbody">
413 <a id="idx:functor:2298"></a>Combination of name and <a class="gloss" href="glossary.html#gloss:arity">arity</a>
373414 of a <a class="gloss" href="glossary.html#gloss:compound">compound</a>
374415 term. The term
375416 <code>foo(a, b, c)</code> is said to be a term belonging to the functor
376417 foo/3 . foo/0 is used to refer to the <a class="gloss" href="glossary.html#gloss:atom">atom</a>
377418 <code>foo</code>.</dd>
378 <dt><a name="gloss:goal"><strong>goal</strong></a></dt>
379 <dd class="defbody">
380 <a name="idx:goal:2295"></a><a name="idx:query:2296"></a>Question stated
381 to the Prolog engine. A <a class="gloss" href="glossary.html#gloss:goal">goal</a>
419 <dt><a id="gloss:goal"><strong>goal</strong></a></dt>
420 <dd class="defbody">
421 <a id="idx:goal:2299"></a><a id="idx:query:2300"></a>Question stated to
422 the Prolog engine. A <a class="gloss" href="glossary.html#gloss:goal">goal</a>
382423 is either an <a class="gloss" href="glossary.html#gloss:atom">atom</a>
383424 or a <a class="gloss" href="glossary.html#gloss:compound">compound</a>
384425 term. A <a class="gloss" href="glossary.html#gloss:goal">goal</a> either
388429 terms have a <a class="gloss" href="glossary.html#gloss:binding">binding</a>,
389430 or it <a class="gloss" href="glossary.html#gloss:fail">fails</a> if
390431 Prolog fails to prove it.</dd>
391 <dt><a name="gloss:hashing"><strong>hashing</strong></a></dt>
392 <dd class="defbody">
393 <a name="idx:hashing:2297"></a><a class="gloss" href="glossary.html#gloss:indexing">Indexing</a>
432 <dt><a id="gloss:hashing"><strong>hashing</strong></a></dt>
433 <dd class="defbody">
434 <a id="idx:hashing:2301"></a><a class="gloss" href="glossary.html#gloss:indexing">Indexing</a>
394435 technique used for quick lookup.</dd>
395 <dt><a name="gloss:head"><strong>head</strong></a></dt>
396 <dd class="defbody">
397 <a name="idx:head:2298"></a>Part of a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
436 <dt><a id="gloss:head"><strong>head</strong></a></dt>
437 <dd class="defbody">
438 <a id="idx:head:2302"></a>Part of a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
398439 before the <a class="gloss" href="glossary.html#gloss:neck">neck</a>
399440 operator (<code><code>:-</code></code>). This is an <a class="gloss" href="glossary.html#gloss:atom">atom</a>
400441 or <a class="gloss" href="glossary.html#gloss:compound">compound</a>
401442 term.</dd>
402 <dt><a name="gloss:imported"><strong>imported [predicate]</strong></a></dt>
403 <dd class="defbody">
404 <a name="idx:importedpredicate:2299"></a><a name="idx:predicateimported:2300"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
443 <dt><a id="gloss:imported"><strong>imported [predicate]</strong></a></dt>
444 <dd class="defbody">
445 <a id="idx:importedpredicate:2303"></a><a id="idx:predicateimported:2304"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
405446 is said to be <a class="gloss" href="glossary.html#gloss:imported">imported</a>
406447 into a <a class="gloss" href="glossary.html#gloss:module">module</a> if
407448 it is defined in another <a class="gloss" href="glossary.html#gloss:module">module</a>
408449 and made available in this <a class="gloss" href="glossary.html#gloss:module">module</a>.
409 See also <a class="sec" href="modules.html">chapter 6</a>.</dd>
410 <dt><a name="gloss:indexing"><strong>indexing</strong></a></dt>
411 <dd class="defbody">
412 <a name="idx:indexing:2301"></a>Indexing is a technique used to quickly
450 See also <a class="sec" href="modules.html#sec:6">chapter 6</a>.</dd>
451 <dt><a id="gloss:indexing"><strong>indexing</strong></a></dt>
452 <dd class="defbody">
453 <a id="idx:indexing:2305"></a>Indexing is a technique used to quickly
413454 select candidate <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
414455 of a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
415456 for a specific <a class="gloss" href="glossary.html#gloss:goal">goal</a>.
422463 is used to quickly select all <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
423464 where the first argument may <a class="gloss" href="glossary.html#gloss:unify">unify</a>
424465 with the first argument of the <a class="gloss" href="glossary.html#gloss:goal">goal</a>.
425 SWI-Prolog supports just-in-time and multi-argument indexing. See <a class="sec" href="jitindex.html">section
466 SWI-Prolog supports just-in-time and multi-argument indexing. See <a class="sec" href="jitindex.html#sec:2.18">section
426467 2.18</a>.</dd>
427 <dt><a name="gloss:integer"><strong>integer</strong></a></dt>
428 <dd class="defbody">
429 <a name="idx:integer:2302"></a>Whole number. On all implementations of
468 <dt><a id="gloss:integer"><strong>integer</strong></a></dt>
469 <dd class="defbody">
470 <a id="idx:integer:2306"></a>Whole number. On all implementations of
430471 SWI-Prolog integers are at least 64-bit signed values. When linked to
431 the GNU GMP library, integer arithmetic is unbounded. See also <a name="idx:currentprologflag2:2303"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>,
472 the GNU GMP library, integer arithmetic is unbounded. See also <a id="idx:currentprologflag2:2307"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>,
432473 flags <a class="flag" href="flags.html#flag:bounded">bounded</a>, <a class="flag" href="flags.html#flag:max_integer">max_integer</a>
433474 and <a class="flag" href="flags.html#flag:min_integer">min_integer</a>.</dd>
434 <dt><a name="gloss:interpreted"><strong>interpreted</strong></a></dt>
435 <dd class="defbody">
436 <a name="idx:interpreted:2304"></a>As opposed to <a class="gloss" href="glossary.html#gloss:compile">compiled</a>,
475 <dt><a id="gloss:interpreted"><strong>interpreted</strong></a></dt>
476 <dd class="defbody">
477 <a id="idx:interpreted:2308"></a>As opposed to <a class="gloss" href="glossary.html#gloss:compile">compiled</a>,
437478 interpreted means the Prolog system attempts to prove a <a class="gloss" href="glossary.html#gloss:goal">goal</a>
438479 by directly reading the <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
439480 rather than executing instructions from an (abstract) instruction set
440481 that is not or only indirectly related to Prolog.</dd>
441 <dt><a name="gloss:instantiation"><strong>instantiation [of an argument]</strong></a></dt>
442 <dd class="defbody">
443 <a name="idx:instantiation:2305"></a>To what extend a term is bound to a
482 <dt><a id="gloss:instantiation"><strong>instantiation [of an argument]</strong></a></dt>
483 <dd class="defbody">
484 <a id="idx:instantiation:2309"></a>To what extend a term is bound to a
444485 value. Typical levels are `unbound' (a <a class="gloss" href="glossary.html#gloss:variable">variable</a>),
445486 `ground' (term without variables) or `partially bound' (term with
446487 embedded variables).</dd>
447 <dt><a name="gloss:meta-predicate"><strong>meta-predicate</strong></a></dt>
448 <dd class="defbody">
449 <a name="idx:metapredicate:2306"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
488 <dt><a id="gloss:meta-predicate"><strong>meta-predicate</strong></a></dt>
489 <dd class="defbody">
490 <a id="idx:metapredicate:2310"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
450491 that reasons about other <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>,
451492 either by calling them, (re)defining them or querying <a class="gloss" href="glossary.html#gloss:property">properties</a>.</dd>
452 <dt><a name="gloss:mode"><strong>mode [declaration]</strong></a></dt>
453 <dd class="defbody">
454 <a name="idx:mode:2307"></a>Declaration of an argument <a class="gloss" href="glossary.html#gloss:instantiation">instantiation</a>
493 <dt><a id="gloss:mode"><strong>mode [declaration]</strong></a></dt>
494 <dd class="defbody">
495 <a id="idx:mode:2311"></a>Declaration of an argument <a class="gloss" href="glossary.html#gloss:instantiation">instantiation</a>
455496 pattern for a
456497 <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>,
457498 often accompanied with a <a class="gloss" href="glossary.html#gloss:determinism">determinism</a>.</dd>
458 <dt><a name="gloss:module"><strong>module</strong></a></dt>
459 <dd class="defbody">
460 <a name="idx:module:2308"></a>Collection of predicates. Each module
499 <dt><a id="gloss:module"><strong>module</strong></a></dt>
500 <dd class="defbody">
501 <a id="idx:module:2312"></a>Collection of predicates. Each module
461502 defines a name-space for predicates. <a class="gloss" href="glossary.html#gloss:built-in">built-in</a>
462503 predicates are accessible from all modules. Predicates can be published
463504 (<a class="gloss" href="glossary.html#gloss:exported">exported</a>) and <a class="gloss" href="glossary.html#gloss:imported">imported</a>
464505 to make their definition available to other modules.</dd>
465 <dt><a name="gloss:module-transparent"><strong>module transparent [predicate]</strong></a></dt>
466 <dd class="defbody">
467 <a name="idx:moduletransparent:2309"></a><a name="idx:transparent:2310"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
506 <dt><a id="gloss:module-transparent"><strong>module transparent [predicate]</strong></a></dt>
507 <dd class="defbody">
508 <a id="idx:moduletransparent:2313"></a><a id="idx:transparent:2314"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
468509 that does not change the <a class="gloss" href="glossary.html#gloss:context-module">context module</a>.
469510 Sometimes also called a <a class="gloss" href="glossary.html#gloss:meta-predicate">meta-predicate</a>.</dd>
470 <dt><a name="gloss:multi"><strong>multi [determinism]</strong></a></dt>
471 <dd class="defbody">
472 <a name="idx:multi:2311"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
511 <dt><a id="gloss:multi"><strong>multi [determinism]</strong></a></dt>
512 <dd class="defbody">
513 <a id="idx:multi:2315"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
473514 is said to have <a class="gloss" href="glossary.html#gloss:determinism">determinism</a>
474515 multi if it generates at
475516 <em>least</em> one answer.</dd>
476 <dt><a name="gloss:multifile"><strong>multifile [predicate]</strong></a></dt>
517 <dt><a id="gloss:multifile"><strong>multifile [predicate]</strong></a></dt>
477518 <dd class="defbody">
478519 Predicate for which the definition is distributed over multiple source
479 files. See <a name="idx:multifile1:2312"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.</dd>
480 <dt><a name="gloss:neck"><strong>neck</strong></a></dt>
481 <dd class="defbody">
482 <a name="idx:neck:2313"></a>Operator (<code><code>:-</code></code>)
520 files. See <a id="idx:multifile1:2316"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.</dd>
521 <dt><a id="gloss:neck"><strong>neck</strong></a></dt>
522 <dd class="defbody">
523 <a id="idx:neck:2317"></a>Operator (<code><code>:-</code></code>)
483524 separating <a class="gloss" href="glossary.html#gloss:head">head</a>
484525 from <a class="gloss" href="glossary.html#gloss:body">body</a> in a <a class="gloss" href="glossary.html#gloss:clause">clause</a>.</dd>
485 <dt><a name="gloss:nondet"><strong>nondet</strong></a></dt>
486 <dd class="defbody">
487 <a name="idx:nondet:2314"></a>Short for <a class="gloss" href="glossary.html#gloss:non-deterministic">non deterministic</a>.</dd>
488 <dt><a name="gloss:non-deterministic"><strong>non deterministic</strong></a></dt>
489 <dd class="defbody">
490 <a name="idx:nondeterministic:2315"></a>A <a class="gloss" href="glossary.html#gloss:non-deterministic">non deterministic</a>
526 <dt><a id="gloss:nondet"><strong>nondet</strong></a></dt>
527 <dd class="defbody">
528 <a id="idx:nondet:2318"></a>Short for <a class="gloss" href="glossary.html#gloss:non-deterministic">non deterministic</a>.</dd>
529 <dt><a id="gloss:non-deterministic"><strong>non deterministic</strong></a></dt>
530 <dd class="defbody">
531 <a id="idx:nondeterministic:2319"></a>A <a class="gloss" href="glossary.html#gloss:non-deterministic">non deterministic</a>
491532 predicate is a predicate that mail fail or succeed any number of times.</dd>
492 <dt><a name="gloss:operator"><strong>operator</strong></a></dt>
493 <dd class="defbody">
494 <a name="idx:operator:2316"></a>Symbol (<a class="gloss" href="glossary.html#gloss:atom">atom</a>)
533 <dt><a id="gloss:operator"><strong>operator</strong></a></dt>
534 <dd class="defbody">
535 <a id="idx:operator:2320"></a>Symbol (<a class="gloss" href="glossary.html#gloss:atom">atom</a>)
495536 that may be placed before its <a class="gloss" href="glossary.html#gloss:operand">operand</a>
496537 (prefix), after its <a class="gloss" href="glossary.html#gloss:operand">operand</a>
497538 (postfix) or between its two <a class="gloss" href="glossary.html#gloss:operand">operands</a>
499540
500541 <p>In Prolog, the expression <code>a+b</code> is exactly the same as the
501542 canonical term <code>+(a,b)</code>.</dd>
502 <dt><a name="gloss:operand"><strong>operand</strong></a></dt>
503 <dd class="defbody">
504 <a name="idx:operand:2317"></a><a class="gloss" href="glossary.html#gloss:argument">Argument</a>
543 <dt><a id="gloss:operand"><strong>operand</strong></a></dt>
544 <dd class="defbody">
545 <a id="idx:operand:2321"></a><a class="gloss" href="glossary.html#gloss:argument">Argument</a>
505546 of an <a class="gloss" href="glossary.html#gloss:operator">operator</a>.</dd>
506 <dt><a name="gloss:precedence"><strong>precedence</strong></a></dt>
507 <dd class="defbody">
508 <a name="idx:precedence:2318"></a>The <a class="gloss" href="glossary.html#gloss:priority">priority</a>
547 <dt><a id="gloss:precedence"><strong>precedence</strong></a></dt>
548 <dd class="defbody">
549 <a id="idx:precedence:2322"></a>The <a class="gloss" href="glossary.html#gloss:priority">priority</a>
509550 of an <a class="gloss" href="glossary.html#gloss:operator">operator</a>.
510551 Operator precedence is used to interpret <code>a+b*c</code> as <code>+(a, *(b,c))</code>.</dd>
511 <dt><a name="gloss:predicate"><strong>predicate</strong></a></dt>
512 <dd class="defbody">
513 <a name="idx:predicate:2319"></a>Collection of <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
552 <dt><a id="gloss:predicate"><strong>predicate</strong></a></dt>
553 <dd class="defbody">
554 <a id="idx:predicate:2323"></a>Collection of <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
514555 with the same <a class="gloss" href="glossary.html#gloss:functor">functor</a>
515556 (name/<a class="gloss" href="glossary.html#gloss:arity">arity</a>). If a <a class="gloss" href="glossary.html#gloss:goal">goal</a>
516557 is proved, the system looks for a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
518559 to select candidate <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
519560 and then tries these <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
520561 one-by-one. See also <a class="gloss" href="glossary.html#gloss:backtracking">backtracking</a>.</dd>
521 <dt><a name="gloss:predicate-indicator"><strong>predicate indicator</strong></a></dt>
522 <dd class="defbody">
523 <a name="idx:predicateindicator:2320"></a>Term of the form Name/Arity
562 <dt><a id="gloss:predicate-indicator"><strong>predicate indicator</strong></a></dt>
563 <dd class="defbody">
564 <a id="idx:predicateindicator:2324"></a>Term of the form Name/Arity
524565 (traditional) or Name//Arity (ISO DCG proposal), where Name is an atom
525566 and Arity a non-negative integer. It acts as an <em>indicator</em> (or
526567 reference) to a predicate or
527568 <a class="gloss" href="glossary.html#gloss:dcg">DCG</a> rule.</dd>
528 <dt><a name="gloss:priority"><strong>priority</strong></a></dt>
529 <dd class="defbody">
530 <a name="idx:priority:2321"></a>In the context of <a class="gloss" href="glossary.html#gloss:operator">operators</a>
569 <dt><a id="gloss:priority"><strong>priority</strong></a></dt>
570 <dd class="defbody">
571 <a id="idx:priority:2325"></a>In the context of <a class="gloss" href="glossary.html#gloss:operator">operators</a>
531572 a synonym for <a class="gloss" href="glossary.html#gloss:precedence">precedence</a>.</dd>
532 <dt><a name="gloss:program"><strong>program</strong></a></dt>
533 <dd class="defbody">
534 <a name="idx:program:2322"></a>Collection of <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>.</dd>
535 <dt><a name="gloss:property"><strong>property</strong></a></dt>
536 <dd class="defbody">
537 <a name="idx:property:2323"></a>Attribute of an object. SWI-Prolog
538 defines various <em>*_property</em> predicates to query the status of
573 <dt><a id="gloss:program"><strong>program</strong></a></dt>
574 <dd class="defbody">
575 <a id="idx:program:2326"></a>Collection of <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>.</dd>
576 <dt><a id="gloss:property"><strong>property</strong></a></dt>
577 <dd class="defbody">
578 <a id="idx:property:2327"></a>Attribute of an object. SWI-Prolog defines
579 various <em>*_property</em> predicates to query the status of
539580 predicates, clauses. etc.</dd>
540 <dt><a name="gloss:prove"><strong>prove</strong></a></dt>
541 <dd class="defbody">
542 <a name="idx:prove:2324"></a>Process where Prolog attempts to prove a <a class="gloss" href="glossary.html#gloss:query">query</a>
581 <dt><a id="gloss:prove"><strong>prove</strong></a></dt>
582 <dd class="defbody">
583 <a id="idx:prove:2328"></a>Process where Prolog attempts to prove a <a class="gloss" href="glossary.html#gloss:query">query</a>
543584 using the available
544585 <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>.</dd>
545 <dt><a name="gloss:public-list"><strong>public list</strong></a></dt>
546 <dd class="defbody">
547 <a name="idx:publiclist:2325"></a>List of <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>
586 <dt><a id="gloss:public-list"><strong>public list</strong></a></dt>
587 <dd class="defbody">
588 <a id="idx:publiclist:2329"></a>List of <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>
548589 exported from a <a class="gloss" href="glossary.html#gloss:module">module</a>.</dd>
549 <dt><a name="gloss:query"><strong>query</strong></a></dt>
590 <dt><a id="gloss:query"><strong>query</strong></a></dt>
550591 <dd class="defbody">
551592 See <a class="gloss" href="glossary.html#gloss:goal">goal</a>.</dd>
552 <dt><a name="gloss:retract"><strong>retract</strong></a></dt>
553 <dd class="defbody">
554 <a name="idx:retract:2326"></a>Remove a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
593 <dt><a id="gloss:retract"><strong>retract</strong></a></dt>
594 <dd class="defbody">
595 <a id="idx:retract:2330"></a>Remove a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
555596 from a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>.
556597 See also <a class="gloss" href="glossary.html#gloss:dynamic">dynamic</a>,
557598 <a class="gloss" href="glossary.html#gloss:update-view">update view</a>
558599 and <a class="gloss" href="glossary.html#gloss:assert">assert</a>.</dd>
559 <dt><a name="gloss:semidet"><strong>semidet</strong></a></dt>
560 <dd class="defbody">
561 <a name="idx:semidet:2327"></a>Shorthand for </dd>
562 <dt><a name="gloss:semi-deterministic"><strong>semi deterministic</strong></a></dt>
600 <dt><a id="gloss:semidet"><strong>semidet</strong></a></dt>
601 <dd class="defbody">
602 <a id="idx:semidet:2331"></a>Shorthand for </dd>
603 <dt><a id="gloss:semi-deterministic"><strong>semi deterministic</strong></a></dt>
563604 <dd class="defbody">
564605 .</dd>
565 <dt><a name="gloss:semi-deterministic"><strong>semi deterministic</strong></a></dt>
566 <dd class="defbody">
567 <a name="idx:semideterministic:2328"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
606 <dt><a id="gloss:semi-deterministic"><strong>semi deterministic</strong></a></dt>
607 <dd class="defbody">
608 <a id="idx:semideterministic:2332"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
568609 that is <a class="gloss" href="glossary.html#gloss:semi-deterministic">semi deterministic</a>
569610 either fails or succeeds exactly once without a <a class="gloss" href="glossary.html#gloss:choice-point">choice point</a>.
570611 See also
571612 <a class="gloss" href="glossary.html#gloss:deterministic">deterministic</a>.</dd>
572 <dt><a name="gloss:shared"><strong>shared</strong></a></dt>
573 <dd class="defbody">
574 <a name="idx:shared:2329"></a>Two <a class="gloss" href="glossary.html#gloss:variable">variables</a>
613 <dt><a id="gloss:shared"><strong>shared</strong></a></dt>
614 <dd class="defbody">
615 <a id="idx:shared:2333"></a>Two <a class="gloss" href="glossary.html#gloss:variable">variables</a>
575616 are called <a class="gloss" href="glossary.html#gloss:shared">shared</a>
576617 after they are <a class="gloss" href="glossary.html#gloss:unify">unified</a>.
577618 This implies if either of them is <a class="gloss" href="glossary.html#gloss:binding">bound</a>,
583624 </pre>
584625
585626 </dd>
586 <dt><a name="gloss:singleton"><strong>singleton [variable]</strong></a></dt>
587 <dd class="defbody">
588 <a name="idx:singleton:2330"></a><a class="gloss" href="glossary.html#gloss:variable">Variable</a>
627 <dt><a id="gloss:singleton"><strong>singleton [variable]</strong></a></dt>
628 <dd class="defbody">
629 <a id="idx:singleton:2334"></a><a class="gloss" href="glossary.html#gloss:variable">Variable</a>
589630 appearing only one time in a <a class="gloss" href="glossary.html#gloss:clause">clause</a>.
590631 SWI-Prolog normally warns for this to avoid you making spelling
591632 mistakes. If a variable appears on purpose only once in a clause, write
592633 it as <code>_</code> (see <a class="gloss" href="glossary.html#gloss:anonymou">anonymous</a>).
593 Rules for naming a variable and avoiding a warning are given in <a class="sec" href="syntax.html">section
634 Rules for naming a variable and avoiding a warning are given in <a class="sec" href="syntax.html#sec:2.16.1.9">section
594635 2.16.1.9</a>.</dd>
595 <dt><a name="gloss:solution"><strong>solution</strong></a></dt>
596 <dd class="defbody">
597 <a name="idx:solution:2331"></a><a class="gloss" href="glossary.html#gloss:binding">Bindings</a>
636 <dt><a id="gloss:solution"><strong>solution</strong></a></dt>
637 <dd class="defbody">
638 <a id="idx:solution:2335"></a><a class="gloss" href="glossary.html#gloss:binding">Bindings</a>
598639 resulting from a successfully <a class="gloss" href="glossary.html#gloss:prove">prove</a>n <a class="gloss" href="glossary.html#gloss:goal">goal</a>.</dd>
599 <dt><a name="gloss:structure"><strong>structure</strong></a></dt>
600 <dd class="defbody">
601 <a name="idx:structure:2332"></a>Synonym for <a class="gloss" href="glossary.html#gloss:compound">compound</a>
640 <dt><a id="gloss:structure"><strong>structure</strong></a></dt>
641 <dd class="defbody">
642 <a id="idx:structure:2336"></a>Synonym for <a class="gloss" href="glossary.html#gloss:compound">compound</a>
602643 term.</dd>
603 <dt><a name="gloss:string"><strong>string</strong></a></dt>
604 <dd class="defbody">
605 Used for the following representations of text: a packed array (see <a class="sec" href="strings.html">section
644 <dt><a id="gloss:string"><strong>string</strong></a></dt>
645 <dd class="defbody">
646 Used for the following representations of text: a packed array (see <a class="sec" href="strings.html#sec:5.2">section
606647 5.2</a>, SWI-Prolog specific), a list of character codes or a list of
607648 one-character <a class="gloss" href="glossary.html#gloss:atom">atoms</a>.</dd>
608 <dt><a name="gloss:succeed"><strong>succeed</strong></a></dt>
609 <dd class="defbody">
610 <a name="idx:succeed:2333"></a>A <a class="gloss" href="glossary.html#gloss:goal">goal</a>
649 <dt><a id="gloss:succeed"><strong>succeed</strong></a></dt>
650 <dd class="defbody">
651 <a id="idx:succeed:2337"></a>A <a class="gloss" href="glossary.html#gloss:goal">goal</a>
611652 is said to have <a class="gloss" href="glossary.html#gloss:succeed">succeeded</a>
612653 if it has been <a class="gloss" href="glossary.html#gloss:prove">proven</a>.</dd>
613 <dt><a name="gloss:term"><strong>term</strong></a></dt>
614 <dd class="defbody">
615 <a name="idx:term:2334"></a>Value in Prolog. A <a class="gloss" href="glossary.html#gloss:term">term</a>
654 <dt><a id="gloss:term"><strong>term</strong></a></dt>
655 <dd class="defbody">
656 <a id="idx:term:2338"></a>Value in Prolog. A <a class="gloss" href="glossary.html#gloss:term">term</a>
616657 is either a <a class="gloss" href="glossary.html#gloss:variable">variable</a>, <a class="gloss" href="glossary.html#gloss:atom">atom</a>, <a class="gloss" href="glossary.html#gloss:integer">integer</a>,
617658 <a class="gloss" href="glossary.html#gloss:float">float</a> or <a class="gloss" href="glossary.html#gloss:compound">compound</a>
618659 term. In addition, SWI-Prolog also defines the type <a class="gloss" href="glossary.html#gloss:string">string</a>.</dd>
619 <dt><a name="gloss:transparent"><strong>transparent</strong></a></dt>
660 <dt><a id="gloss:transparent"><strong>transparent</strong></a></dt>
620661 <dd class="defbody">
621662 See <a class="gloss" href="glossary.html#gloss:module-transparent">module transparent</a>.</dd>
622 <dt><a name="gloss:unify"><strong>unify</strong></a></dt>
623 <dd class="defbody">
624 <a name="idx:unify:2335"></a>Prolog process to make two terms equal by
663 <dt><a id="gloss:unify"><strong>unify</strong></a></dt>
664 <dd class="defbody">
665 <a id="idx:unify:2339"></a>Prolog process to make two terms equal by
625666 assigning variables in one term to values at the corresponding location
626667 of the other term. For example:
627668
633674
634675 <p>Unlike assignment (which does not exist in Prolog), unification is
635676 not directed.</dd>
636 <dt><a name="gloss:update-view"><strong>update view</strong></a></dt>
637 <dd class="defbody">
638 <a name="idx:updateview:2336"></a><a name="idx:viewupdate:2337"></a>How
677 <dt><a id="gloss:update-view"><strong>update view</strong></a></dt>
678 <dd class="defbody">
679 <a id="idx:updateview:2340"></a><a id="idx:viewupdate:2341"></a>How
639680 Prolog behaves when a <a class="gloss" href="glossary.html#gloss:dynamic">dynamic</a> <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
640681 is changed while it is running. There are two models. In most older
641682 Prolog systems the change becomes immediately visible to the <a class="gloss" href="glossary.html#gloss:goal">goal</a>,
642683 in modern systems including SWI-Prolog, the running <a class="gloss" href="glossary.html#gloss:goal">goal</a>
643684 is not affected. Only new <a class="gloss" href="glossary.html#gloss:goal">goals</a>
644685 `see' the new definition.</dd>
645 <dt><a name="gloss:variable"><strong>variable</strong></a></dt>
646 <dd class="defbody">
647 <a name="idx:variable:2338"></a>A Prolog variable is a value that `is
648 not yet bound'. After <a class="gloss" href="glossary.html#gloss:binding">binding</a>
686 <dt><a id="gloss:variable"><strong>variable</strong></a></dt>
687 <dd class="defbody">
688 <a id="idx:variable:2342"></a>A Prolog variable is a value that `is not
689 yet bound'. After <a class="gloss" href="glossary.html#gloss:binding">binding</a>
649690 a variable, it cannot be modified. <a class="gloss" href="glossary.html#gloss:backtracking">Backtracking</a>
650691 to a point in the execution before the variable was bound will turn it
651692 back into a variable:
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="sicstus-chr.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="errors.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:guidelines"><a name="sec:8.7"><span class="sec-nr">8.7</span> <span class="sec-title">Programming
235 <h2 id="sec:guidelines"><a id="sec:8.7"><span class="sec-nr">8.7</span> <span class="sec-title">Programming
195236 Tips and Tricks</span></a></h2>
196237
197 <a name="sec:guidelines"></a> In this section we cover several
198 guidelines on how to use CHR to write constraint solvers and how to do
199 so efficiently.
238 <a id="sec:guidelines"></a> In this section we cover several guidelines
239 on how to use CHR to write constraint solvers and how to do so
240 efficiently.
200241
201242 <p>
202243 <ul class="latex">
231272 into Prolog code. When you disable optimizations the CHR compiler will
232273 be a lot quicker, but you may lose performance. Alternatively, you can
233274 just use SWI-Prolog's
234 <a name="idx:qcompile1:1826"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
275 <a id="idx:qcompile1:1830"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
235276 to generate a <code>.qlf</code> file once from your
236277 <code>.pl</code> file. This <code>.qlf</code> contains the generated
237278 code of the CHR compiler (be it in a binary format). When you consult
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="pceemacs.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="navigator.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:guitracer"><a name="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">The
235 <h2 id="sec:guitracer"><a id="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">The
195236 Graphical Debugger</span></a></h2>
196237
197 <a name="sec:guitracer"></a>
238 <a id="sec:guitracer"></a>
198239
199240 <p>SWI-Prolog offers two debuggers. One is the traditional text
200241 console-based 4-port Prolog tracer and the other is a window-based
201242 source level debugger. The window-based debugger requires XPCE
202 installed. It operates based on the <a name="idx:prologtraceinterception4:314"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
203 hook and other low-level functionality described in <a class="sec" href="hack.html">chapter
243 installed. It operates based on the <a id="idx:prologtraceinterception4:314"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
244 hook and other low-level functionality described in <a class="sec" href="hack.html#sec:B">chapter
204245 B</a>.
205246
206247 <p>Window-based tracing provides a much better overview due to the
211252 the graphical debugger just presents a (much better) overview of the
212253 current state.
213254
214 <p><h3 id="sec:start-guitracer"><a name="sec:3.5.1"><span class="sec-nr">3.5.1</span> <span class="sec-title">Invoking
255 <p><h3 id="sec:start-guitracer"><a id="sec:3.5.1"><span class="sec-nr">3.5.1</span> <span class="sec-title">Invoking
215256 the window-based debugger</span></a></h3>
216257
217 <a name="sec:start-guitracer"></a>
258 <a id="sec:start-guitracer"></a>
218259
219260 <p>Whether the text-based or window-based debugger is used is controlled
220 using the predicates <a name="idx:guitracer0:315"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>
221 and <a name="idx:noguitracer0:316"></a><a class="pred" href="guitracer.html#noguitracer/0">noguitracer/0</a>.
222 Entering debug mode is controlled using the normal predicates for this: <a name="idx:trace0:317"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
261 using the predicates <a id="idx:guitracer0:315"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>
262 and <a id="idx:noguitracer0:316"></a><a class="pred" href="guitracer.html#noguitracer/0">noguitracer/0</a>.
263 Entering debug mode is controlled using the normal predicates for this: <a id="idx:trace0:317"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
223264 and
224 <a name="idx:spy1:318"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>.
265 <a id="idx:spy1:318"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>.
225266 In addition, PceEmacs prolog mode provides the command
226267 <strong>Prolog/Break at</strong> (<code>Control-c b</code>) to insert a
227268 break-point at a specific location in the source code.
231272 used from a background thread.
232273
233274 <dl class="latex">
234 <dt class="pubdef"><a name="guitracer/0"><strong>guitracer</strong></a></dt>
275 <dt class="pubdef"><a id="guitracer/0"><strong>guitracer</strong></a></dt>
235276 <dd class="defbody">
236277 This predicate installs the above-mentioned hooks that redirect tracing
237278 to the window-based environment. No window appears. The debugger window
238 appears as actual tracing is started through <a name="idx:trace0:319"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>,
239 by hitting a spy point defined by <a name="idx:spy1:320"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
279 appears as actual tracing is started through <a id="idx:trace0:319"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>,
280 by hitting a spy point defined by <a id="idx:spy1:320"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
240281 or a break point defined using the PceEmacs command <strong>Prolog/Break
241282 at</strong> (<code>Control-c b</code>).</dd>
242 <dt class="pubdef"><a name="noguitracer/0"><strong>noguitracer</strong></a></dt>
243 <dd class="defbody">
244 Disable the hooks installed by <a name="idx:guitracer0:321"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>,
283 <dt class="pubdef"><a id="noguitracer/0"><strong>noguitracer</strong></a></dt>
284 <dd class="defbody">
285 Disable the hooks installed by <a id="idx:guitracer0:321"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>,
245286 reverting to normal text console-based tracing.</dd>
246 <dt class="pubdef"><a name="gtrace/0"><strong>gtrace</strong></a></dt>
287 <dt class="pubdef"><a id="gtrace/0"><strong>gtrace</strong></a></dt>
247288 <dd class="defbody">
248289 Utility defined as <code>guitracer,trace</code>.</dd>
249 <dt class="pubdef"><a name="gdebug/0"><strong>gdebug</strong></a></dt>
290 <dt class="pubdef"><a id="gdebug/0"><strong>gdebug</strong></a></dt>
250291 <dd class="defbody">
251292 Utility defined as <code>guitracer,debug</code>.</dd>
252 <dt class="pubdef"><a name="gspy/1"><strong>gspy</strong>(<var>+Predicate</var>)</a></dt>
293 <dt class="pubdef"><a id="gspy/1"><strong>gspy</strong>(<var>+Predicate</var>)</a></dt>
253294 <dd class="defbody">
254295 Utility defined as <code>guitracer,spy(Predicate)</code>.
255296 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.33</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.33</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="format.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="tty.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:gvar"><a name="sec:4.33"><span class="sec-nr">4.33</span> <span class="sec-title">Global
235 <h2 id="sec:gvar"><a id="sec:4.33"><span class="sec-nr">4.33</span> <span class="sec-title">Global
195236 variables</span></a></h2>
196237
197 <a name="sec:gvar"></a>
238 <a id="sec:gvar"></a>
198239
199240 <p>Global variables are associations between names (atoms) and terms.
200 They differ in various ways from storing information using <a name="idx:assert1:1411"></a><a class="pred" href="db.html#assert/1">assert/1</a>
201 or <a name="idx:recorda3:1412"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>.
241 They differ in various ways from storing information using <a id="idx:assert1:1411"></a><a class="pred" href="db.html#assert/1">assert/1</a>
242 or <a id="idx:recorda3:1412"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>.
202243
203244 <p>
204245 <ul class="latex">
208249 the CHR global constraint store.
209250
210251 <p>
211 <li>They support both global assignment using <a name="idx:nbsetval2:1413"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
212 and backtrackable assignment using <a name="idx:bsetval2:1414"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>.
252 <li>They support both global assignment using <a id="idx:nbsetval2:1413"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
253 and backtrackable assignment using <a id="idx:bsetval2:1414"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>.
213254
214255 <p>
215256 <li>Only one value (which can be an arbitrary complex Prolog term) can
224265 module scoping in future versions.
225266 </ul>
226267
227 <p>Both <a name="idx:bsetval2:1415"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
228 and <a name="idx:nbsetval2:1416"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
268 <p>Both <a id="idx:bsetval2:1415"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
269 and <a id="idx:nbsetval2:1416"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
229270 implicitly create a variable if the referenced name does not already
230271 refer to a variable.
231272
232273 <p>Global variables may be initialised from directives to make them
233274 available during the program lifetime, but some considerations are
234275 necessary for saved states and threads. Saved states do not store global
235 variables, which implies they have to be declared with <a name="idx:initialization1:1417"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
276 variables, which implies they have to be declared with <a id="idx:initialization1:1417"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
236277 to recreate them after loading the saved state. Each thread has its own
237278 set of global variables, starting with an empty set. Using
238 <a name="idx:threadinitialization1:1418"></a><a class="pred" href="threadcreate.html#thread_initialization/1">thread_initialization/1</a>
279 <a id="idx:threadinitialization1:1418"></a><a class="pred" href="threadcreate.html#thread_initialization/1">thread_initialization/1</a>
239280 to define a global variable it will be defined, restored after reloading
240281 a saved state and created in all threads that are created <em>after</em>
241282 the registration. Finally, global variables can be initialised using the
242283 exception hook
243 <a name="idx:exception3:1419"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>.
244 The latter technique is used by CHR (see <a class="sec" href="chr.html">chapter
284 <a id="idx:exception3:1419"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>.
285 The latter technique is used by CHR (see <a class="sec" href="chr.html#sec:8">chapter
245286 8</a>).
246287
247288 <dl class="latex">
248 <dt class="pubdef"><a name="b_setval/2"><strong>b_setval</strong>(<var>+Name,
289 <dt class="pubdef"><a id="b_setval/2"><strong>b_setval</strong>(<var>+Name,
249290 +Value</var>)</a></dt>
250291 <dd class="defbody">
251292 Associate the term <var>Value</var> with the atom <var>Name</var> or
254295 value
255296 <code>[]</code> is created (the empty list). On backtracking the
256297 assignment is reversed.</dd>
257 <dt class="pubdef"><a name="b_getval/2"><strong>b_getval</strong>(<var>+Name,
298 <dt class="pubdef"><a id="b_getval/2"><strong>b_getval</strong>(<var>+Name,
258299 -Value</var>)</a></dt>
259300 <dd class="defbody">
260301 Get the value associated with the global variable <var>Name</var> and
261302 unify it with <var>Value</var>. Note that this unification may further
262303 instantiate the value of the global variable. If this is undesirable the
263 normal precautions (double negation or <a name="idx:copyterm2:1420"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>)
304 normal precautions (double negation or <a id="idx:copyterm2:1420"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>)
264305 must be taken. The
265 <a name="idx:bgetval2:1421"></a><a class="pred" href="gvar.html#b_getval/2">b_getval/2</a>
306 <a id="idx:bgetval2:1421"></a><a class="pred" href="gvar.html#b_getval/2">b_getval/2</a>
266307 predicate generates errors if <var>Name</var> is not an atom or the
267308 requested variable does not exist.
268309 </dd>
269310 </dl>
270311
271312 <dl class="latex">
272 <dt class="pubdef"><a name="nb_setval/2"><strong>nb_setval</strong>(<var>+Name,
313 <dt class="pubdef"><a id="nb_setval/2"><strong>nb_setval</strong>(<var>+Name,
273314 +Value</var>)</a></dt>
274315 <dd class="defbody">
275 Associates a copy of <var>Value</var> created with <a name="idx:duplicateterm2:1422"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>
316 Associates a copy of <var>Value</var> created with <a id="idx:duplicateterm2:1422"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>
276317 with the atom <var>Name</var>. Note that this can be used to set an
277318 initial value other than <code>[]</code> prior to backtrackable
278319 assignment.</dd>
279 <dt class="pubdef"><a name="nb_getval/2"><strong>nb_getval</strong>(<var>+Name,
320 <dt class="pubdef"><a id="nb_getval/2"><strong>nb_getval</strong>(<var>+Name,
280321 -Value</var>)</a></dt>
281322 <dd class="defbody">
282 The <a name="idx:nbgetval2:1423"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
283 predicate is a synonym for <a name="idx:bgetval2:1424"></a><a class="pred" href="gvar.html#b_getval/2">b_getval/2</a>,
323 The <a id="idx:nbgetval2:1423"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
324 predicate is a synonym for <a id="idx:bgetval2:1424"></a><a class="pred" href="gvar.html#b_getval/2">b_getval/2</a>,
284325 introduced for compatibility and symmetry. As most scenarios will use a
285326 particular global variable using either non-backtrackable or
286 backtrackable assignment, using <a name="idx:nbgetval2:1425"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
327 backtrackable assignment, using <a id="idx:nbgetval2:1425"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
287328 can be used to document that the variable is non-backtrackable. Raises <code>existence_error(variable,
288 Name)</code> if the variable does not exist. Alternatively, <a name="idx:nbcurrent2:1426"></a><a class="pred" href="gvar.html#nb_current/2">nb_current/2</a>
329 Name)</code> if the variable does not exist. Alternatively, <a id="idx:nbcurrent2:1426"></a><a class="pred" href="gvar.html#nb_current/2">nb_current/2</a>
289330 can used to query a global variable. This version <em>fails</em> if the
290331 variable does not exist rather than raising an exception.</dd>
291 <dt class="pubdef"><a name="nb_linkval/2"><strong>nb_linkval</strong>(<var>+Name,
332 <dt class="pubdef"><a id="nb_linkval/2"><strong>nb_linkval</strong>(<var>+Name,
292333 +Value</var>)</a></dt>
293334 <dd class="defbody">
294335 Associates the term <var>Value</var> with the atom <var>Name</var>
295 without copying it. This is a fast special-purpose variation of <a name="idx:nbsetval2:1427"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
336 without copying it. This is a fast special-purpose variation of <a id="idx:nbsetval2:1427"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
296337 intended for expert users only because the semantics on backtracking to
297338 a point before creating the link are poorly defined for compound terms.
298339 The principal term is always left untouched, but backtracking behaviour
313354 </pre>
314355
315356 </dd>
316 <dt class="pubdef"><a name="nb_current/2"><strong>nb_current</strong>(<var>?Name,
357 <dt class="pubdef"><a id="nb_current/2"><strong>nb_current</strong>(<var>?Name,
317358 ?Value</var>)</a></dt>
318359 <dd class="defbody">
319360 Enumerate all defined variables with their value. The order of
320 enumeration is undefined. Note that <a name="idx:nbcurrent2:1428"></a><a class="pred" href="gvar.html#nb_current/2">nb_current/2</a>
321 can be used as an alternative for <a name="idx:nbgetval2:1429"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
361 enumeration is undefined. Note that <a id="idx:nbcurrent2:1428"></a><a class="pred" href="gvar.html#nb_current/2">nb_current/2</a>
362 can be used as an alternative for <a id="idx:nbgetval2:1429"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
322363 to request the value of a variable and fail silently if the variable
323364 does not exists.</dd>
324 <dt class="pubdef"><a name="nb_delete/1"><strong>nb_delete</strong>(<var>+Name</var>)</a></dt>
365 <dt class="pubdef"><a id="nb_delete/1"><strong>nb_delete</strong>(<var>+Name</var>)</a></dt>
325366 <dd class="defbody">
326367 Delete the named global variable. Succeeds also if the named variable
327368 does not exist.
328369 </dd>
329370 </dl>
330371
331 <p><h3 id="sec:gvars-compat"><a name="sec:4.33.1"><span class="sec-nr">4.33.1</span> <span class="sec-title">Compatibility
372 <p><h3 id="sec:gvars-compat"><a id="sec:4.33.1"><span class="sec-nr">4.33.1</span> <span class="sec-title">Compatibility
332373 of SWI-Prolog Global Variables</span></a></h3>
333374
334 <a name="sec:gvars-compat"></a>
375 <a id="sec:gvars-compat"></a>
335376
336377 <p>Global variables have been introduced by various Prolog
337378 implementations recently. The implementation of them in SWI-Prolog is
338379 based on hProlog by Bart Demoen. In discussion with Bart it was decided
339 that the semantics of hProlog <a name="idx:nbsetval2:1430"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>,
340 which is equivalent to <a name="idx:nblinkval2:1431"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>,
380 that the semantics of hProlog <a id="idx:nbsetval2:1430"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>,
381 which is equivalent to <a id="idx:nblinkval2:1431"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>,
341382 is not acceptable for normal Prolog users as the behaviour is influenced
342 by how built-in predicates that construct terms (<a name="idx:read1:1432"></a><a class="pred" href="termrw.html#read/1">read/1</a>,
383 by how built-in predicates that construct terms (<a id="idx:read1:1432"></a><a class="pred" href="termrw.html#read/1">read/1</a>,
343384 =../2, etc.) are implemented.
344385
345386 <p>GNU-Prolog provides a rich set of global variables, including arrays.
346 Arrays can be implemented easily in SWI-Prolog using <a name="idx:functor3:1433"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
387 Arrays can be implemented easily in SWI-Prolog using <a id="idx:functor3:1433"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
347388 and
348 <a name="idx:setarg3:1434"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
389 <a id="idx:setarg3:1434"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
349390 due to the unrestricted arity of compound terms.
350391
351392 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="yall.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="manipstack.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:hack"><a name="sec:B"><span class="sec-nr">B</span> <span class="sec-title">Hackers
235 <h1 id="sec:hack"><a id="sec:B"><span class="sec-nr">B</span> <span class="sec-title">Hackers
195236 corner</span></a></h1>
196237
197 <a name="sec:hack"></a>
238 <a id="sec:hack"></a>
198239
199240 <p>This appendix describes a number of predicates which enable the
200241 Prolog user to inspect the Prolog environment and manipulate (or even
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="gemacs.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="history.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:help"><a name="sec:2.6"><span class="sec-nr">2.6</span> <span class="sec-title">Online
235 <h2 id="sec:help"><a id="sec:2.6"><span class="sec-nr">2.6</span> <span class="sec-title">Online
195236 Help</span></a></h2>
196237
197 <a name="sec:help"></a>
238 <a id="sec:help"></a>
198239
199240 <p>SWI-Prolog provides an online help system that covers this manual. If
200241 the XPCE graphics system is available, online help opens a graphical
208249 and following the instructions in the <code>README</code> file.
209250
210251 <dl class="latex">
211 <dt class="pubdef"><a name="help/0"><strong>help</strong></a></dt>
212 <dd class="defbody">
213 Equivalent to <code>help(<a name="idx:help1:48"></a><a class="pred" href="help.html#help/1">help/1</a>)</code>.</dd>
214 <dt class="pubdef"><a name="help/1"><strong>help</strong>(<var>+What</var>)</a></dt>
252 <dt class="pubdef"><a id="help/0"><strong>help</strong></a></dt>
253 <dd class="defbody">
254 Equivalent to <code>help(<a id="idx:help1:48"></a><a class="pred" href="help.html#help/1">help/1</a>)</code>.</dd>
255 <dt class="pubdef"><a id="help/1"><strong>help</strong>(<var>+What</var>)</a></dt>
215256 <dd class="defbody">
216257 Show specified part of the manual. <var>What</var> is one of:
217 <div style="text-align:center"><table border="0" frame="void" rules="groups">
218 <tr valign="top"><td>&lt;<var>Name</var>&gt;/&lt;<var>Arity</var>&gt; </td><td>Give
258 <table class="latex frame-void center">
259 <tr><td>&lt;<var>Name</var>&gt;/&lt;<var>Arity</var>&gt; </td><td>Give
219260 help on specified predicate </td></tr>
220 <tr valign="top"><td>&lt;<var>Name</var>&gt; </td><td>Give help on named
221 predicate with any arity or C interface function with that name </td></tr>
222 <tr valign="top"><td>&lt;<var>Section</var>&gt; </td><td>Display
223 specified section. Section numbers are dash-separated numbers: <code>2-3</code>
224 refers to section 2.3 of the manual. Section numbers are obtained using <a name="idx:apropos1:49"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>.</td></tr>
261 <tr><td>&lt;<var>Name</var>&gt; </td><td>Give help on named predicate
262 with any arity or C interface function with that name </td></tr>
263 <tr><td>&lt;<var>Section</var>&gt; </td><td>Display specified section.
264 Section numbers are dash-separated numbers: <code>2-3</code> refers to
265 section 2.3 of the manual. Section numbers are obtained using <a id="idx:apropos1:49"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>.</td></tr>
225266 </table>
226 </div>
227267
228268 <p>Examples:
229 <div style="text-align:center"><table border="0" frame="void" rules="groups">
230 <tr valign="top"><td><code>?- help(assert).</code> </td><td>Give help on
231 predicate assert </td></tr>
232 <tr valign="top"><td><code>?- help(3-4).</code> </td><td>Display section
233 3.4 of the manual </td></tr>
234 <tr valign="top"><td><code>?- help('PL_retry').</code></td><td>Give help
235 on interface function <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a> </td></tr>
269 <table class="latex frame-void center">
270 <tr><td><code>?- help(assert).</code> </td><td>Give help on predicate
271 assert </td></tr>
272 <tr><td><code>?- help(3-4).</code> </td><td>Display section 3.4 of the
273 manual </td></tr>
274 <tr><td><code>?- help('PL_retry').</code></td><td>Give help on interface
275 function <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a> </td></tr>
236276 </table>
237 </div>
238
239 <p>See also <a name="idx:apropos1:50"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
277
278 <p>See also <a id="idx:apropos1:50"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
240279 and the SWI-Prolog home page at
241280 <a class="url" href="http://www.swi-prolog.org">http://www.swi-prolog.org</a>,
242281 which provides a FAQ, an HTML version of the manual for online browsing,
243282 and HTML and PDF versions for downloading.</dd>
244 <dt class="pubdef"><a name="apropos/1"><strong>apropos</strong>(<var>+Pattern</var>)</a></dt>
283 <dt class="pubdef"><a id="apropos/1"><strong>apropos</strong>(<var>+Pattern</var>)</a></dt>
245284 <dd class="defbody">
246285 Display all predicates, functions and sections that have <em>Pattern</em>
247286 in their name or summary description. Lowercase letters in
248287 <var>Pattern</var> also match a corresponding uppercase letter. Example:
249 <div style="text-align:center"><table border="0" frame="void" rules="groups">
250 <tr valign="top"><td><code>?- apropos(file).</code> </td><td>Display
251 predicates, functions and sections that have `file' (or `File', etc.) in
252 their summary description. </td></tr>
288 <table class="latex frame-void center">
289 <tr><td><code>?- apropos(file).</code> </td><td>Display predicates,
290 functions and sections that have `file' (or `File', etc.) in their
291 summary description. </td></tr>
253292 </table>
254 </div>
255293 </dd>
256 <dt class="pubdef"><a name="explain/1"><strong>explain</strong>(<var>+ToExplain</var>)</a></dt>
294 <dt class="pubdef"><a id="explain/1"><strong>explain</strong>(<var>+ToExplain</var>)</a></dt>
257295 <dd class="defbody">
258296 Give an explanation on the given `object'. The argument may be any
259297 Prolog data object. If the argument is an atom, a term of the form
260298 <var>Name/Arity</var> or a term of the form <em>Module:Name/Arity</em>,
261 <a name="idx:explain1:51"></a><a class="pred" href="help.html#explain/1">explain/1</a>
262 describes the predicate as well as possible references to it. See also <a name="idx:gxref0:52"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>.</dd>
263 <dt class="pubdef"><a name="explain/2"><strong>explain</strong>(<var>+ToExplain,
299 <a id="idx:explain1:51"></a><a class="pred" href="help.html#explain/1">explain/1</a>
300 describes the predicate as well as possible references to it. See also <a id="idx:gxref0:52"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>.</dd>
301 <dt class="pubdef"><a id="explain/2"><strong>explain</strong>(<var>+ToExplain,
264302 -Explanation</var>)</a></dt>
265303 <dd class="defbody">
266304 Unify <var>Explanation</var> with an explanation for <var>ToExplain</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="help.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="topvars.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:history"><a name="sec:2.7"><span class="sec-nr">2.7</span> <span class="sec-title">Command
235 <h2 id="sec:history"><a id="sec:2.7"><span class="sec-nr">2.7</span> <span class="sec-title">Command
195236 line history</span></a></h2>
196237
197 <a name="sec:history"></a>
238 <a id="sec:history"></a>
198239
199240 <p>SWI-Prolog offers a query substitution mechanism similar to what is
200241 seen in Unix shells. The availability of this feature is controlled by
201 <a name="idx:setprologflag2:53"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>,
242 <a id="idx:setprologflag2:53"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>,
202243 using the <a class="flag" href="flags.html#flag:history">history</a>
203244 Prolog flag. By default, history is available if no interactive command
204245 line editor is available. To enable history, remembering the last 50
205 commands, put the following into your startup file (see <a class="sec" href="initfile.html">section
246 commands, put the following into your startup file (see <a class="sec" href="initfile.html#sec:2.2">section
206247 2.2</a>):
207248
208249 <pre class="code">
215256 1</a>. History expansion is not done if these sequences appear in quoted
216257 atoms or strings.
217258
218 <p><table border="2" frame="box" rules="groups" style="margin:auto">
219 <tr valign="top"><td><code>!!.</code> </td><td>Repeat last query </td></tr>
220 <tr valign="top"><td><code>!nr.</code> </td><td>Repeat query numbered &lt;<var>nr</var>&gt; </td></tr>
221 <tr valign="top"><td><code>!str.</code> </td><td>Repeat last query
222 starting with &lt;<var>str</var>&gt; </td></tr>
223 <tr valign="top"><td><code>h.</code> </td><td>Show history of commands </td></tr>
224 <tr valign="top"><td><code>!h.</code> </td><td>Show this list </td></tr>
259 <p><table class="latex frame-box center">
260 <tr><td><code>!!.</code> </td><td>Repeat last query </td></tr>
261 <tr><td><code>!nr.</code> </td><td>Repeat query numbered &lt;<var>nr</var>&gt; </td></tr>
262 <tr><td><code>!str.</code> </td><td>Repeat last query starting with &lt;<var>str</var>&gt; </td></tr>
263 <tr><td><code>h.</code> </td><td>Show history of commands </td></tr>
264 <tr><td><code>!h.</code> </td><td>Show this list </td></tr>
225265 </table>
226266 <div class="caption"><b>Table 1 : </b>History commands</div>
227 <a name="tab:history"></a>
267 <a id="tab:history"></a>
228268
229269 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.12</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="flags.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="autoload.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:hooks"><a name="sec:2.12"><span class="sec-nr">2.12</span> <span class="sec-title">An
235 <h2 id="sec:hooks"><a id="sec:2.12"><span class="sec-nr">2.12</span> <span class="sec-title">An
195236 overview of hook predicates</span></a></h2>
196237
197 <a name="sec:hooks"></a>
198
199 <p><a name="idx:hooks:167"></a>SWI-Prolog provides a large number of
238 <a id="sec:hooks"></a>
239
240 <p><a id="idx:hooks:167"></a>SWI-Prolog provides a large number of
200241 hooks, mainly to control handling messages, debugging, startup,
201242 shut-down, macro-expansion, etc. Below is a summary of all defined hooks
202243 with an indication of their portability.
204245 <p>
205246 <ul class="latex">
206247 <li><i>portray/1</i><br>
207 Hook into <a name="idx:writeterm3:168"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>
248 Hook into <a id="idx:writeterm3:168"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>
208249 to alter the way terms are printed (ISO).
209250 <li><i>message_hook/3</i><br>
210 Hook into <a name="idx:printmessage2:169"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
251 Hook into <a id="idx:printmessage2:169"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
211252 to alter the way system messages are printed (Quintus/SICStus).
212253 <li><i>message_property/2</i><br>
213 Hook into <a name="idx:printmessage2:170"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
254 Hook into <a id="idx:printmessage2:170"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
214255 that defines prefix, output stream, color, etc.
215256 <li><i>library_directory/1</i><br>
216 Hook into <a name="idx:absolutefilename3:171"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
257 Hook into <a id="idx:absolutefilename3:171"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
217258 to define new library directories (most Prolog systems).
218259 <li><i>file_search_path/2</i><br>
219 Hook into <a name="idx:absolutefilename3:172"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
260 Hook into <a id="idx:absolutefilename3:172"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
220261 to define new search paths (Quintus/SICStus).
221262 <li><i>term_expansion/2</i><br>
222 Hook into <a name="idx:loadfiles2:173"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
263 Hook into <a id="idx:loadfiles2:173"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
223264 to modify read terms before they are compiled (macro-processing) (most
224265 Prolog systems).
225266 <li><i>goal_expansion/2</i><br>
226 Same as <a name="idx:termexpansion2:174"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
267 Same as <a id="idx:termexpansion2:174"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
227268 for individual goals (SICStus).
228269 <li><i>prolog_load_file/2</i><br>
229 Hook into <a name="idx:loadfiles2:175"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
270 Hook into <a id="idx:loadfiles2:175"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
230271 to load other data formats for Prolog sources from `non-file' resources.
231 The <a name="idx:loadfiles2:176"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
232 predicate is the ancestor of <a name="idx:consult1:177"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>, <a name="idx:usemodule1:178"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,
272 The <a id="idx:loadfiles2:176"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
273 predicate is the ancestor of <a id="idx:consult1:177"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>, <a id="idx:usemodule1:178"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,
233274 etc.
234275 <li><i>qpredrefprolog_editlocate3</i><br>
235 Hook into <a name="idx:edit1:179"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
276 Hook into <a id="idx:edit1:179"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
236277 to locate objects (SWI).
237278 <li><i>qpredrefprolog_editedit_source1</i><br>
238 Hook into <a name="idx:edit1:180"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
279 Hook into <a id="idx:edit1:180"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
239280 to call an internal editor (SWI).
240281 <li><i>prolog_edit:edit_command/2</i><br>
241 Hook into <a name="idx:edit1:181"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
282 Hook into <a id="idx:edit1:181"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
242283 to define the external editor to use (SWI).
243284 <li><i>prolog_list_goal/1</i><br>
244285 Hook into the tracer to list the code associated to a particular goal
246287 <li><i>prolog_trace_interception/4</i><br>
247288 Hook into the tracer to handle trace events (SWI).
248289 <li><i>qpredrefprologdebug_control_hook1</i><br>
249 Hook in <a name="idx:spy1:182"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>, <a name="idx:nospy1:183"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>, <a name="idx:nospyall0:184"></a><a class="pred" href="debugger.html#nospyall/0">nospyall/0</a>
250 and <a name="idx:debugging0:185"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>
290 Hook in <a id="idx:spy1:182"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>, <a id="idx:nospy1:183"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>, <a id="idx:nospyall0:184"></a><a class="pred" href="debugger.html#nospyall/0">nospyall/0</a>
291 and <a id="idx:debugging0:185"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>
251292 to extend these control predicates to higher-level libraries.
252293 <li><i>qpredrefprologhelp_hook1</i><br>
253 Hook in <a name="idx:help0:186"></a><a class="pred" href="help.html#help/0">help/0</a>, <a name="idx:help1:187"></a><a class="pred" href="help.html#help/1">help/1</a>
254 and <a name="idx:apropos1:188"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
294 Hook in <a id="idx:help0:186"></a><a class="pred" href="help.html#help/0">help/0</a>, <a id="idx:help1:187"></a><a class="pred" href="help.html#help/1">help/1</a>
295 and <a id="idx:apropos1:188"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
255296 to extend the help system.
256297 <li><i>resource/3</i><br>
257298 Define a new resource (not really a hook, but similar) (SWI).
260301 (SWI).
261302 <li><i>attr_unify_hook/2</i><br>
262303 Unification hook for attributed variables. Can be defined in any module.
263 See <a class="sec" href="attvar.html">section 7.1</a> for details.
304 See <a class="sec" href="attvar.html#sec:7.1">section 7.1</a> for
305 details.
264306 </ul>
265307
266308 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="xref.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="idesummary.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:idepreds"><a name="sec:3.8"><span class="sec-nr">3.8</span> <span class="sec-title">Accessing
235 <h2 id="sec:idepreds"><a id="sec:3.8"><span class="sec-nr">3.8</span> <span class="sec-title">Accessing
195236 the IDE from your program</span></a></h2>
196237
197 <a name="sec:idepreds"></a>
238 <a id="sec:idepreds"></a>
198239
199240 <p>Over the years a collection of IDE components have been developed,
200241 each with its own interface. In addition, some of these components
201242 require each other, and loading IDE components must be on demand to
202 avoid the IDE being part of a saved state (see <a name="idx:qsaveprogram2:325"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>).
243 avoid the IDE being part of a saved state (see <a id="idx:qsaveprogram2:325"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>).
203244 For this reason, access to the IDE is concentrated on a single interface
204 called <a name="idx:prologide1:326"></a><a class="pred" href="idepreds.html#prolog_ide/1">prolog_ide/1</a>:
245 called <a id="idx:prologide1:326"></a><a class="pred" href="idepreds.html#prolog_ide/1">prolog_ide/1</a>:
205246
206247 <dl class="latex">
207 <dt class="pubdef"><a name="prolog_ide/1"><strong>prolog_ide</strong>(<var>+Action</var>)</a></dt>
248 <dt class="pubdef"><a id="prolog_ide/1"><strong>prolog_ide</strong>(<var>+Action</var>)</a></dt>
208249 <dd class="defbody">
209250 This predicate ensures the IDE-enabling XPCE component is loaded,
210 creates the XPCE class and sends <var>Action</var> to its one and only
211 instance <code>@prolog_ide</code>. <var>Action</var> is one of the
212 following:
251 creates the XPCE class <i>prolog_ide</i> and sends <var>Action</var> to
252 its one and only instance <code>@prolog_ide</code>. <var>Action</var> is
253 one of the following:
213254
214255 <dl class="latex">
215256 <dt><strong>open_navigator</strong>(<var>+Directory</var>)</dt>
216257 <dd class="defbody">
217 Open the Prolog Navigator (see <a class="sec" href="navigator.html">section
258 Open the Prolog Navigator (see <a class="sec" href="navigator.html#sec:3.6">section
218259 3.6</a>) in the given
219260 <var>Directory</var>.</dd>
220261 <dt><strong>open_debug_status</strong></dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.9</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="idepreds.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="builtin.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:idesummary"><a name="sec:3.9"><span class="sec-nr">3.9</span> <span class="sec-title">Summary
235 <h2 id="sec:idesummary"><a id="sec:3.9"><span class="sec-nr">3.9</span> <span class="sec-title">Summary
195236 of the IDE</span></a></h2>
196237
197 <a name="sec:idesummary"></a>
238 <a id="sec:idesummary"></a>
198239
199240 <p>The SWI-Prolog development environment consists of a number of
200241 interrelated but not (yet) integrated tools. Here is a list of the most
210251 alternatives on the command <code>Alt-?</code>.
211252
212253 <p>
213 <li><i>Use <a name="idx:edit1:327"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
254 <li><i>Use <a id="idx:edit1:327"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
214255 for finding locations</i><br>
215 The command <a name="idx:edit1:328"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
256 The command <a id="idx:edit1:328"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
216257 takes the name of a file, module, predicate or other entity registered
217258 through extensions and starts the user's preferred editor at the right
218259 location.
225266
226267 <p>
227268 <li><i>Update Prolog after editing</i><br>
228 Using <a name="idx:make0:329"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
269 Using <a id="idx:make0:329"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
229270 all files you have edited are re-loaded.
230271
231272 <p>
235276
236277 <p>
237278 <li><i>Using the graphical debugger</i><br>
238 The predicates <a name="idx:guitracer0:330"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>
239 and <a name="idx:noguitracer0:331"></a><a class="pred" href="guitracer.html#noguitracer/0">noguitracer/0</a>
279 The predicates <a id="idx:guitracer0:330"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>
280 and <a id="idx:noguitracer0:331"></a><a class="pred" href="guitracer.html#noguitracer/0">noguitracer/0</a>
240281 switch between traditional text-based and window-based debugging. The
241 tracer is activated using the <a name="idx:trace0:332"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>, <a name="idx:spy1:333"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
282 tracer is activated using the <a id="idx:trace0:332"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>, <a id="idx:spy1:333"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
242283 or menu items from PceEmacs or the Prolog Navigator.
243284
244285 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 1.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="sponsor.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="acknowledge.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:implhistory"><a name="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Implementation
235 <h2 id="sec:implhistory"><a id="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Implementation
195236 history</span></a></h2>
196237
197 <a name="sec:implhistory"></a>
238 <a id="sec:implhistory"></a>
198239
199240 <p>SWI-Prolog started back in 1986 with the requirement for a Prolog
200241 that could handle recursive interaction with the C-language: Prolog
229270 of compiled code. The extensions include specialised instructions for
230271 unification, predicate invocation, some frequently used built-in
231272 predicates, arithmetic, and control (<a class="pred" href="control.html#;/2">;/2</a>, <a class="pred" href="control.html#|/2">|/2</a>),
232 if-then (<a class="pred" href="control.html#send_arrow/2">-&gt;/2</a>)
233 and negation-by-failure (<a class="pred" href="control.html#\+/1">\+/1</a>).
273 if-then (<a class="pred" href="control.html#->/2">-&gt;/2</a>) and
274 negation-by-failure (<a class="pred" href="control.html#\+/1">\+/1</a>).
234275
235276 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="defmodule.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="metapred.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:import"><a name="sec:6.3"><span class="sec-nr">6.3</span> <span class="sec-title">Importing
235 <h2 id="sec:import"><a id="sec:6.3"><span class="sec-nr">6.3</span> <span class="sec-title">Importing
195236 Predicates into a Module</span></a></h2>
196237
197 <a name="sec:import"></a>
238 <a id="sec:import"></a>
198239
199240 <p>Predicates can be added to a module by <em>importing</em> them from
200241 another module. Importing adds predicates to the namespace of a module.
203244 module in which it has been defined.
204245
205246 <p>Importing the predicates from another module is achieved using the
206 directives <a name="idx:usemodule1:1666"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
207 or <a name="idx:usemodule2:1667"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.
247 directives <a id="idx:usemodule1:1670"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
248 or <a id="idx:usemodule2:1671"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.
208249 Note that both directives take
209250 <var>filename(s)</var> as arguments. That is, modules are imported based
210251 on their filename rather than their module name.
211252
212253 <dl class="latex">
213 <dt class="pubdef"><a name="use_module/1"><strong>use_module</strong>(<var>+Files</var>)</a></dt>
254 <dt class="pubdef"><a id="use_module/1"><strong>use_module</strong>(<var>+Files</var>)</a></dt>
214255 <dd class="defbody">
215 Load the file(s) specified with <var>Files</var> just like <a name="idx:ensureloaded1:1668"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>.
256 Load the file(s) specified with <var>Files</var> just like <a id="idx:ensureloaded1:1672"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>.
216257 The files must all be module files. All exported predicates from the
217258 loaded files are imported into the module from which this predicate is
218 called. This predicate is equivalent to <a name="idx:ensureloaded1:1669"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>,
259 called. This predicate is equivalent to <a id="idx:ensureloaded1:1673"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>,
219260 except that it raises an error if <var>Files</var> are not module files.
220261
221262 <p>The imported predicates act as <em>weak symbols</em> in the module
223264 predicate overrides (clobbers) the imported definition. If the flag
224265 <a class="flag" href="flags.html#flag:warn_override_implicit_import">warn_override_implicit_import</a>
225266 is <code>true</code> (default), a warning is printed. Below is an
226 example of a module that uses library(lists), but redefines <a name="idx:flatten2:1670"></a><a class="pred" href="lists.html#flatten/2">flatten/2</a>,
267 example of a module that uses library(lists), but redefines <a id="idx:flatten2:1674"></a><a class="pred" href="lists.html#flatten/2">flatten/2</a>,
227268 giving it a totally different meaning:
228269
229270 <pre class="code">
242283 overrides weak import from lists
243284 </pre>
244285
245 <p>This warning can be avoided by (1) using <a name="idx:usemodule2:1671"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
286 <p>This warning can be avoided by (1) using <a id="idx:usemodule2:1675"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
246287 to only import the predicates from the <code>lists</code> library that
247288 are actually used in the `shapes' module, (2) using the <code>except([flatten/2])</code>
248 option of <a name="idx:usemodule2:1672"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>,
289 option of <a id="idx:usemodule2:1676"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>,
249290 (3) use
250 <code>:- abolish(<a name="idx:flatten2:1673"></a><a class="pred" href="lists.html#flatten/2">flatten/2</a>).</code>
291 <code>:- abolish(<a id="idx:flatten2:1677"></a><a class="pred" href="lists.html#flatten/2">flatten/2</a>).</code>
251292 before the local definition or (4) setting
252293 <a class="flag" href="flags.html#flag:warn_override_implicit_import">warn_override_implicit_import</a>
253294 to <code>false</code>. Globally disabling this warning is only
255296 design choices or the program is ported from a system that silently
256297 overrides imported predicates.
257298
258 <p>Note that it is always an error to import two modules with <a name="idx:usemodule1:1674"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
299 <p>Note that it is always an error to import two modules with <a id="idx:usemodule1:1678"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
259300 that export the same predicate. Such conflicts must be resolved with
260 <a name="idx:usemodule2:1675"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
301 <a id="idx:usemodule2:1679"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
261302 as described above.</dd>
262 <dt class="pubdef"><a name="use_module/2"><strong>use_module</strong>(<var>+File,
303 <dt class="pubdef"><a id="use_module/2"><strong>use_module</strong>(<var>+File,
263304 +ImportList</var>)</a></dt>
264305 <dd class="defbody">
265306 Load <var>File</var>, which must be a module file, and import the
268309 imported from the loaded module. <var>ImportList</var> also allows for
269310 renaming or import-everything-except. See also the <code>import</code>
270311 option of
271 <a name="idx:loadfiles2:1676"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
272 The first example below loads <a name="idx:member2:1677"></a><a class="pred" href="lists.html#member/2">member/2</a>
273 from the <code>lists</code> library and <a name="idx:append2:1678"></a><a class="pred" href="lists.html#append/2">append/2</a>
312 <a id="idx:loadfiles2:1680"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
313 The first example below loads <a id="idx:member2:1681"></a><a class="pred" href="lists.html#member/2">member/2</a>
314 from the <code>lists</code> library and <a id="idx:append2:1682"></a><a class="pred" href="lists.html#append/2">append/2</a>
274315 under the name <code>list_concat</code>, which is how this predicate is
275316 named in YAP. The second example loads all exports from library <code>option</code>
276 except for <a name="idx:metaoptions3:1679"></a><a class="pred" href="option.html#meta_options/3">meta_options/3</a>.
317 except for <a id="idx:metaoptions3:1683"></a><a class="pred" href="option.html#meta_options/3">meta_options/3</a>.
277318 These renaming facilities are generally used to deal with portability
278 issues with as few changes as possible to the actual code. See also <a class="sec" href="dialect.html">section
319 issues with as few changes as possible to the actual code. See also <a class="sec" href="dialect.html#sec:C">section
279320 C</a> and
280 <a class="sec" href="reexport.html">section 6.7</a>.
321 <a class="sec" href="reexport.html#sec:6.7">section 6.7</a>.
281322
282323 <pre class="code">
283324 :- use_module(library(lists), [ member/2,
291332
292333 <p>In most cases a module is imported because some of its predicates are
293334 being used. However, sometimes a module is imported for other reasons,
294 e.g., for its declarations. In such cases it is best practice to use <a name="idx:usemodule2:1680"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
335 e.g., for its declarations. In such cases it is best practice to use <a id="idx:usemodule2:1684"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
295336 with empty ImportList. This distinguishes an imported module that is
296337 used, although not for its predicates, from a module that is needlessly
297338 imported.
298339
299 <p>The <a name="idx:module2:1681"></a><a class="pred" href="defmodule.html#module/2">module/2</a>, <a name="idx:usemodule1:1682"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
300 and <a name="idx:usemodule2:1683"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
340 <p>The <a id="idx:module2:1685"></a><a class="pred" href="defmodule.html#module/2">module/2</a>, <a id="idx:usemodule1:1686"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
341 and <a id="idx:usemodule2:1687"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
301342 directives are sufficient to partition a simple Prolog program into
302 modules. The SWI-Prolog graphical cross-referencing tool <a name="idx:gxref0:1684"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
343 modules. The SWI-Prolog graphical cross-referencing tool <a id="idx:gxref0:1688"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
303344 can be used to analyse the dependencies between non-module files and
304345 propose module declarations for each file.
305346
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.9</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="moduleop.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="resmodules.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:importmodule"><a name="sec:6.9"><span class="sec-nr">6.9</span> <span class="sec-title">Dynamic
235 <h2 id="sec:importmodule"><a id="sec:6.9"><span class="sec-nr">6.9</span> <span class="sec-title">Dynamic
195236 importing using import modules</span></a></h2>
196237
197 <a name="sec:importmodule"></a>
238 <a id="sec:importmodule"></a>
198239
199240 <p>Until now we discussed the public module interface that is, at least
200241 to some extent, portable between Prolog implementations with a module
210251 and
211252 <code>system</code> for all system library modules. Module <code>user</code>
212253 imports from <code>system</code> where all built-in predicates reside.
213 These special modules are described in more detail in <a class="sec" href="resmodules.html">section
254 These special modules are described in more detail in <a class="sec" href="resmodules.html#sec:6.10">section
214255 6.10</a>.
215256
216257 <p>The list of import modules can be manipulated and queried using the
217 following predicates, as well as using <a name="idx:setmodule1:1718"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>.
258 following predicates, as well as using <a id="idx:setmodule1:1722"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>.
218259
219260 <dl class="latex">
220 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="import_module/2"><strong>import_module</strong>(<var>+Module,
261 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="import_module/2"><strong>import_module</strong>(<var>+Module,
221262 -Import</var>)</a></dt>
222263 <dd class="defbody">
223264 True if <var>Module</var> inherits directly from <var>Import</var>. All
224265 normal modules only import from <code>user</code>, which imports from
225 <code>system</code>. The predicates <a name="idx:addimportmodule3:1719"></a><a class="pred" href="importmodule.html#add_import_module/3">add_import_module/3</a>
266 <code>system</code>. The predicates <a id="idx:addimportmodule3:1723"></a><a class="pred" href="importmodule.html#add_import_module/3">add_import_module/3</a>
226267 and
227 <a name="idx:deleteimportmodule2:1720"></a><a class="pred" href="importmodule.html#delete_import_module/2">delete_import_module/2</a>
228 can be used to manipulate the import list. See also <a name="idx:defaultmodule2:1721"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>.</dd>
229 <dt class="pubdef"><span class="pred-tag">[multi]</span><a name="default_module/2"><strong>default_module</strong>(<var>+Module,
268 <a id="idx:deleteimportmodule2:1724"></a><a class="pred" href="importmodule.html#delete_import_module/2">delete_import_module/2</a>
269 can be used to manipulate the import list. See also <a id="idx:defaultmodule2:1725"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>.</dd>
270 <dt class="pubdef"><span class="pred-tag">[multi]</span><a id="default_module/2"><strong>default_module</strong>(<var>+Module,
230271 -Default</var>)</a></dt>
231272 <dd class="defbody">
232273 True if predicates and operators in <var>Default</var> are visible in
233274 <var>Module</var>. Modules are returned in the same search order used
234275 for predicates and operators. That is, <var>Default</var> is first
235276 unified with <var>Module</var>, followed by the depth-first transitive
236 closure of <a name="idx:importmodule2:1722"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>.</dd>
237 <dt class="pubdef"><a name="add_import_module/3"><strong>add_import_module</strong>(<var>+Module,
277 closure of <a id="idx:importmodule2:1726"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>.</dd>
278 <dt class="pubdef"><a id="add_import_module/3"><strong>add_import_module</strong>(<var>+Module,
238279 +Import, +StartOrEnd</var>)</a></dt>
239280 <dd class="defbody">
240281 If <var>Import</var> is not already an import module for <var>Module</var>,
241282 add it to this list at the <code>start</code> or <code>end</code>
242283 depending on
243 <var>StartOrEnd</var>. See also <a name="idx:importmodule2:1723"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>
244 and <a name="idx:deleteimportmodule2:1724"></a><a class="pred" href="importmodule.html#delete_import_module/2">delete_import_module/2</a>.</dd>
245 <dt class="pubdef"><a name="delete_import_module/2"><strong>delete_import_module</strong>(<var>+Module,
284 <var>StartOrEnd</var>. See also <a id="idx:importmodule2:1727"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>
285 and <a id="idx:deleteimportmodule2:1728"></a><a class="pred" href="importmodule.html#delete_import_module/2">delete_import_module/2</a>.</dd>
286 <dt class="pubdef"><a id="delete_import_module/2"><strong>delete_import_module</strong>(<var>+Module,
246287 +Import</var>)</a></dt>
247288 <dd class="defbody">
248289 Delete <var>Import</var> from the list of import modules for <var>Module</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="contents" href="Contents.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="contents" href="Contents.html">
55 <link rel="index" href="DocIndex.html">
66 <link rel="summary" href="summary.html">
77 <link rel="next" href="Contents.html">
1515 { margin-bottom: 1em;
1616 }
1717
18 dt.pubdef
19 { background-color: #c5e1ff;
20 }
21
22 dt.multidef
23 { background-color: #c8ffc7;
24 }
18 dt.pubdef, dt.multidef
19 { color: #fff;
20 padding: 2px 10px 0px 10px;
21 margin-bottom: 5px;
22 font-size: 18px;
23 vertical-align: middle;
24 overflow: hidden;
25 }
26
27 dt.pubdef { background-color: #0c3d6e; }
28 dt.multidef { background-color: #ef9439; }
2529
2630 .bib dd
2731 { margin-bottom: 1em;
115119 padding-top: 0.2em;
116120 font-size: 80%;
117121 font-style: italic;
118 color: #202020;
122 color: #fff;
119123 }
120124
121125 div.caption
125129 }
126130
127131 /* Footnotes */
128
129 sup.fn { color: blue; text-decoration: underline; }
130 span.fn-text { display: none; }
131 sup.fn span {display: none;}
132 sup:hover span
133 { display: block !important;
134 position: absolute; top: auto; left: auto; width: 80%;
135 color: #000; background: white;
136 border: 2px solid;
137 padding: 5px; margin: 10px; z-index: 100;
138 font-size: smaller;
132 .fn {
133 color: red;
134 font-size: 70%;
135 }
136
137 .fn-text, .fnp {
138 position: absolute;
139 top: auto;
140 left: 10%;
141 border: 1px solid #000;
142 box-shadow: 5px 5px 5px #888;
143 display: none;
144 background: #fff;
145 color: #000;
146 margin-top: 25px;
147 padding: 8px 12px;
148 font-size: larger;
149 }
150
151 sup:hover span.fn-text
152 { display: block;
139153 }
140154
141155 /* Lists */
179193 font-size: +1;
180194 margin-top: 1ex;
181195 }
196
197 /* Tables */
198
199 table.center
200 { margin: auto;
201 }
202
203 table.latex
204 { border-collapse:collapse;
205 }
206
207 table.latex tr
208 { vertical-align: text-top;
209 }
210
211 table.latex td,th
212 { padding: 2px 1em;
213 }
214
215 table.latex tr.hline td,th
216 { border-top: 1px solid black;
217 }
218
219 table.frame-box
220 { border: 2px solid black;
221 }
222
182223 </style>
183224 </head>
184225 <body style="background:white">
187228 <a class="nav" href="summary.html"><img src="info.gif" alt="Summary"></a>
188229 <a class="nav" href="Contents.html"><img src="next.gif" alt="Next"></a>
189230 </div>
190 <div class="title">SWI-Prolog 7.6.2 Reference Manual</div>
191 <div class="author">mailto:J.Wielemaker@vu.nlJan Wielemaker <br>
231 <div class="title">SWI-Prolog 7.7.4 Reference Manual</div>
232 <div class="author"><a class="url" href="mailto:J.Wielemaker@vu.nl">Jan
233 Wielemaker</a> <br>
192234 Department of Computer Science <br>
193235 VU University Amsterdam <br>
194236 De Boelelaan 1081a, 1081 HV&nbsp;&nbsp;Amsterdam
230272 sources. From the same source we generate the plain-text version and
231273 index used by the online help system (located in the file <code>MANUAL</code>
232274 in the library directory) as well as the PDF version. Sources, binaries
233 and documentation can be downloaded from the http://www.swi-prolog.org/Download.htmlSWI-Prolog
234 download page .
275 and documentation can be downloaded from the <a class="url" href="http://www.swi-prolog.org/Download.html">SWI-Prolog
276 download page</a>.
235277
236278 <p>The SWI-Prolog project <b>home page</b> is
237 http://www.swi-prolog.orghttp://www.swi-prolog.org
279 <a class="url" href="http://www.swi-prolog.org">http://www.swi-prolog.org</a>
280
281 <p><img src="by-sa.png">
238282
239283 <p>This work is licensed under the Creative Commons
240284 Attribution-ShareAlike 3.0 Unported License. To view a copy of this
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="quickstart.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="initgoal.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:initfile"><a name="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">The
235 <h2 id="sec:initfile"><a id="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">The
195236 user's initialisation file</span></a></h2>
196237
197 <a name="sec:initfile"></a>
198
199 <p><a name="idx:startupfile:18"></a><a name="idx:userprofilefile:19"></a><a name="idx:profilefile:20"></a>After
238 <a id="sec:initfile"></a>
239
240 <p><a id="idx:startupfile:18"></a><a id="idx:userprofilefile:19"></a><a id="idx:profilefile:20"></a>After
200241 the system initialisation, the system consults (see
201 <a name="idx:consult1:21"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
242 <a id="idx:consult1:21"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
202243 the user's startup file. The basename of this file follows conventions
203244 of the operating system. On MS-Windows, it is the file
204245 <code>swipl.ini</code> and on Unix systems <code>.swiplrc</code>. The
205 file is searched using the <a name="idx:filesearchpath2:22"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
246 file is searched using the <a id="idx:filesearchpath2:22"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
206247 clauses for
207248 <code>user_profile</code>.<sup class="fn">9<span class="fn-text">Older
208249 versions first searched in the current working directory. This feature
211252 The table below shows the default value for this search path. The phrase &lt;<var>appdata</var>&gt;
212253 refers to the Windows CSIDL name for the folder. The actual name depends
213254 on the Windows language. English versions typically use <code>ApplicationData</code>.
214 See also <a name="idx:winfolder2:23"></a><a class="pred" href="system.html#win_folder/2">win_folder/2</a>
215
216 <p><table border="2" frame="box" rules="groups" style="margin:auto">
217 <tr valign="top"><td></td><td><b>Unix</b></td><td><b>Windows </b></td></tr>
218 <tbody>
219 <tr valign="top"><td><b>home</b></td><td><code><code>~</code></code> </td><td>&lt;<var>appdata</var>&gt;/SWI-Prolog </td></tr>
255 See also <a id="idx:winfolder2:23"></a><a class="pred" href="system.html#win_folder/2">win_folder/2</a>
256
257 <p><table class="latex frame-box center">
258 <tr><td></td><td><b>Unix</b></td><td><b>Windows </b></td></tr>
259 <tr class="hline"><td><b>home</b></td><td><code><code>~</code></code> </td><td>&lt;<var>appdata</var>&gt;/SWI-Prolog </td></tr>
220260 </table>
221261
222262 <p>After the first startup file is found it is loaded and Prolog stops
235275 system skeleton.
236276
237277 <p>See also the <strong>-s</strong> (script) and <strong>-F</strong>
238 (system-wide initialisation) in <a class="sec" href="cmdline.html">section
239 2.4</a> and <a class="sec" href="initgoal.html">section 2.3</a>.
278 (system-wide initialisation) in <a class="sec" href="cmdline.html#sec:2.4">section
279 2.4</a> and <a class="sec" href="initgoal.html#sec:2.3">section 2.3</a>.
240280
241281 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="initfile.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="cmdline.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:initgoal"><a name="sec:2.3"><span class="sec-nr">2.3</span> <span class="sec-title">Initialisation
235 <h2 id="sec:initgoal"><a id="sec:2.3"><span class="sec-nr">2.3</span> <span class="sec-title">Initialisation
195236 files and goals</span></a></h2>
196237
197 <a name="sec:initgoal"></a>
198
199 <p>Using command line arguments (see <a class="sec" href="cmdline.html">section
238 <a id="sec:initgoal"></a>
239
240 <p>Using command line arguments (see <a class="sec" href="cmdline.html#sec:2.4">section
200241 2.4</a>), SWI-Prolog can be forced to load files and execute queries for
201242 initialisation purposes or non-interactive operation. The most commonly
202243 used options are
238279 :- halt. % and exit
239280 </pre>
240281
241 <p><a class="sec" href="compilation.html">Section 2.10.2.1</a> discusses
242 further scripting options, and
243 <a class="sec" href="runtime.html">chapter 12</a> discusses the
282 <p><a class="sec" href="compilation.html#sec:2.10.2.1">Section 2.10.2.1</a>
283 discusses further scripting options, and
284 <a class="sec" href="runtime.html#sec:12">chapter 12</a> discusses the
244285 generation of runtime executables. Runtime executables are a means to
245286 deliver executables that do not require the Prolog system.
246287
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="exception3.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="loadfilehook.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:intlibs"><a name="sec:B.7"><span class="sec-nr">B.7</span> <span class="sec-title">Hooks
235 <h2 id="sec:intlibs"><a id="sec:B.7"><span class="sec-nr">B.7</span> <span class="sec-title">Hooks
195236 for integrating libraries</span></a></h2>
196237
197 <a name="sec:intlibs"></a>
238 <a id="sec:intlibs"></a>
198239
199240 <p>Some libraries realise an entirely new programming paradigm on top of
200241 Prolog. An example is XPCE which adds an object system to Prolog as well
201242 as an extensive set of graphical primitives. SWI-Prolog provides several
202243 hooks to improve the integration of such libraries. See also
203 <a class="sec" href="listing.html">section 4.5</a> for editing hooks and <a class="sec" href="exception.html">section
204 4.11.4</a> for hooking into the message system.
244 <a class="sec" href="listing.html#sec:4.5">section 4.5</a> for editing
245 hooks and <a class="sec" href="exception.html#sec:4.11.4">section 4.11.4</a>
246 for hooking into the message system.
205247
206248 <dl class="latex">
207 <dt class="pubdef"><a name="prolog_list_goal/1"><strong>prolog_list_goal</strong>(<var>:Goal</var>)</a></dt>
249 <dt class="pubdef"><a id="prolog_list_goal/1"><strong>prolog_list_goal</strong>(<var>:Goal</var>)</a></dt>
208250 <dd class="defbody">
209251 Hook, normally not defined. This hook is called by the 'L' command of
210252 the tracer in the module <code>user</code> to list the currently called
211253 predicate. This hook may be defined to list only relevant clauses of the
212254 indicated <var>Goal</var> and/or show the actual source code in an
213 editor. See also <a name="idx:portray1:2219"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
214 and <a name="idx:multifile1:2220"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.</dd>
215 <dt class="pubdef"><a name="prolog:debug_control_hook/1"><strong>prolog:debug_control_hook</strong>(<var>:Action</var>)</a></dt>
255 editor. See also <a id="idx:portray1:2223"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
256 and <a id="idx:multifile1:2224"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.</dd>
257 <dt class="pubdef"><a id="prolog:debug_control_hook/1"><strong>prolog:debug_control_hook</strong>(<var>:Action</var>)</a></dt>
216258 <dd class="defbody">
217259 Hook for the debugger control predicates that allows the creator of more
218260 high-level programming languages to use the common front-end predicates
222264 <dl class="latex">
223265 <dt><strong>spy</strong>(<var>Spec</var>)</dt>
224266 <dd class="defbody">
225 Hook in <a name="idx:spy1:2221"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>.
226 If the hook succeeds <a name="idx:spy1:2222"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
267 Hook in <a id="idx:spy1:2225"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>.
268 If the hook succeeds <a id="idx:spy1:2226"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
227269 takes no further action.
228270 </dd>
229271 <dt><strong>nospy</strong>(<var>Spec</var>)</dt>
230272 <dd class="defbody">
231 Hook in <a name="idx:nospy1:2223"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
232 If the hook succeeds <a name="idx:nospy1:2224"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>
233 takes no further action. If <a name="idx:spy1:2225"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
273 Hook in <a id="idx:nospy1:2227"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
274 If the hook succeeds <a id="idx:nospy1:2228"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>
275 takes no further action. If <a id="idx:spy1:2229"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
234276 is hooked, it is advised to place a complementary hook for
235 <a name="idx:nospy1:2226"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
277 <a id="idx:nospy1:2230"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
236278 </dd>
237279 <dt><strong>nospyall</strong></dt>
238280 <dd class="defbody">
239 Hook in <a name="idx:nospyall0:2227"></a><a class="pred" href="debugger.html#nospyall/0">nospyall/0</a>.
281 Hook in <a id="idx:nospyall0:2231"></a><a class="pred" href="debugger.html#nospyall/0">nospyall/0</a>.
240282 Should remove all spy points. This hook is called in a failure-driven
241283 loop.
242284 </dd>
243285 <dt><strong>debugging</strong></dt>
244286 <dd class="defbody">
245 Hook in <a name="idx:debugging0:2228"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>.
287 Hook in <a id="idx:debugging0:2232"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>.
246288 It can be used in two ways. It can report the status of the additional
247289 debug points controlled by the above hooks and fail to let the system
248 report the others, or it succeeds, overruling the entire behaviour of <a name="idx:debugging0:2229"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>.
290 report the others, or it succeeds, overruling the entire behaviour of <a id="idx:debugging0:2233"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>.
249291 </dd>
250292 </dl>
251293
252294 </dd>
253 <dt class="pubdef"><a name="prolog:help_hook/1"><strong>prolog:help_hook</strong>(<var>+Action</var>)</a></dt>
254 <dd class="defbody">
255 Hook into <a name="idx:help0:2230"></a><a class="pred" href="help.html#help/0">help/0</a>
256 and <a name="idx:help1:2231"></a><a class="pred" href="help.html#help/1">help/1</a>.
295 <dt class="pubdef"><a id="prolog:help_hook/1"><strong>prolog:help_hook</strong>(<var>+Action</var>)</a></dt>
296 <dd class="defbody">
297 Hook into <a id="idx:help0:2234"></a><a class="pred" href="help.html#help/0">help/0</a>
298 and <a id="idx:help1:2235"></a><a class="pred" href="help.html#help/1">help/1</a>.
257299 If the hook succeeds, the built-in actions are not executed. For
258300 example, <code>?- help(picture).</code> is caught by the XPCE help hook
259301 to give help on the class <em>picture</em>. Defined actions are:
261303 <dl class="latex">
262304 <dt><strong>help</strong></dt>
263305 <dd class="defbody">
264 User entered plain <a name="idx:help0:2232"></a><a class="pred" href="help.html#help/0">help/0</a>
306 User entered plain <a id="idx:help0:2236"></a><a class="pred" href="help.html#help/0">help/0</a>
265307 to give default help. The default performs
266 <code>help(<a name="idx:help1:2233"></a><a class="pred" href="help.html#help/1">help/1</a>)</code>,
308 <code>help(<a id="idx:help1:2237"></a><a class="pred" href="help.html#help/1">help/1</a>)</code>,
267309 giving help on help.
268310 </dd>
269311 <dt><strong>help</strong>(<var>What</var>)</dt>
270312 <dd class="defbody">
271 Hook in <a name="idx:help1:2234"></a><a class="pred" href="help.html#help/1">help/1</a>
313 Hook in <a id="idx:help1:2238"></a><a class="pred" href="help.html#help/1">help/1</a>
272314 on the topic <var>What</var>.
273315 </dd>
274316 <dt><strong>apropos</strong>(<var>What</var>)</dt>
275317 <dd class="defbody">
276 Hook in <a name="idx:apropos1:2235"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
318 Hook in <a id="idx:apropos1:2239"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
277319 on the topic <var>What</var>.
278320 </dd>
279321 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="Contents.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="swiprolog.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:intro"><a name="sec:1"><span class="sec-nr">1</span> <span class="sec-title">Introduction</span></a></h1>
195
196 <a name="sec:intro"></a>
235 <h1 id="sec:intro"><a id="sec:1"><span class="sec-nr">1</span> <span class="sec-title">Introduction</span></a></h1>
236
237 <a id="sec:intro"></a>
197238
198239 <p>This document is a <em>reference manual</em>. That means that it
199240 documents the system, but it does not explain the basics of the Prolog
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.14</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="gensym.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="lists.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:iostream"><a name="sec:A.14"><span class="sec-nr">A.14</span> <span class="sec-title">library(iostream):
235 <h2 id="sec:iostream"><a id="sec:A.14"><span class="sec-nr">A.14</span> <span class="sec-title">library(iostream):
195236 Utilities to deal with streams</span></a></h2>
196237
197 <p><a name="sec:iostream"></a>
238 <p><a id="sec:iostream"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">See also</dt>
229270 <a class="pred" href="iostream.html#open_any/5">open_any/5</a>.
230271
231272 <dl class="latex">
232 <dt class="pubdef"><a name="open_any/5"><strong>open_any</strong>(<var>+Specification,
273 <dt class="pubdef"><a id="open_any/5"><strong>open_any</strong>(<var>+Specification,
233274 +Mode, -Stream, -Close, +Options</var>)</a></dt>
234275 <dd class="defbody">
235276 Establish a stream from <var>Specification</var> that should be closed
299340 </dl>
300341
301342 </dd>
302 <dt class="pubdef"><a name="close_any/1"><strong>close_any</strong>(<var>+Goal</var>)</a></dt>
343 <dt class="pubdef"><a id="close_any/1"><strong>close_any</strong>(<var>+Goal</var>)</a></dt>
303344 <dd class="defbody">
304345 Execute the <var>Close</var> closure returned by <a class="pred" href="iostream.html#open_any/5">open_any/5</a>.
305346 The closure can also be called directly. Using <a class="pred" href="iostream.html#close_any/1">close_any/1</a>
306347 can be considered better style and enhances tractability of the source
307348 code.</dd>
308 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="open_hook/6"><strong>open_hook</strong>(<var>+Spec,
349 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="open_hook/6"><strong>open_hook</strong>(<var>+Spec,
309350 +Mode, -Stream, -Close, +Options0, -Options</var>)</a></dt>
310351 <dd class="defbody">
311352 Open <var>Spec</var> in <var>Mode</var>, producing <var>Stream</var>.
312353 <table class="arglist">
313 <tr valign="top"><td><var>Close</var> </td><td>is unified to a goal that
314 must be called to undo the side-effects of the action, e.g., typically
315 the term <code>close(Stream)</code> </td></tr>
316 <tr valign="top"><td><var>Options0</var> </td><td>are the options passed
317 to <a class="pred" href="iostream.html#open_any/5">open_any/5</a> </td></tr>
318 <tr valign="top"><td><var>Options</var> </td><td>are passed to the post
319 processing filters that may be installed by <a class="pred" href="iostream.html#open_any/5">open_any/5</a>. </td></tr>
354 <tr><td><var>Close</var> </td><td>is unified to a goal that must be
355 called to undo the side-effects of the action, e.g., typically the term <code>close(Stream)</code> </td></tr>
356 <tr><td><var>Options0</var> </td><td>are the options passed to <a class="pred" href="iostream.html#open_any/5">open_any/5</a> </td></tr>
357 <tr><td><var>Options</var> </td><td>are passed to the post processing
358 filters that may be installed by <a class="pred" href="iostream.html#open_any/5">open_any/5</a>. </td></tr>
320359 </table>
321360 </dd>
322361 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.18</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.18</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="cyclic.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="widechars.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:jitindex"><a name="sec:2.18"><span class="sec-nr">2.18</span> <span class="sec-title">Just-in-time
235 <h2 id="sec:jitindex"><a id="sec:2.18"><span class="sec-nr">2.18</span> <span class="sec-title">Just-in-time
195236 clause indexing</span></a></h2>
196237
197 <a name="sec:jitindex"></a>
198
199 <p><a name="idx:jitindex:255"></a>SWI-Prolog provides `just-in-time'
238 <a id="sec:jitindex"></a>
239
240 <p><a id="idx:jitindex:255"></a>SWI-Prolog provides `just-in-time'
200241 indexing over multiple arguments.<sup class="fn">31<span class="fn-text">JIT
201242 indexing was added in version 5.11.29 (Oct. 2011).</span></sup>
202243 `Just-in-time' means that clause indexes are not built by the compiler
203 (or <a name="idx:asserta1:256"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
244 (or <a id="idx:asserta1:256"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
204245 for dynamic predicates), but on the first call to such a predicate where
205246 an index might help (i.e., a call where at least one argument is
206247 instantiated). This section describes the rules used by the indexing
258299 approach will recreate a suitable index on the next call. Indexes of
259300 running predicates cannot be deleted. They are added to a `removed index
260301 list' associated to the predicate. Outdated indexes of predicates are
261 reclaimed by <a name="idx:garbagecollectclauses0:257"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
302 reclaimed by <a id="idx:garbagecollectclauses0:257"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
262303 The clause garbage collector is scheduled automatically, based on time
263 and space based heuristics. See <a name="idx:garbagecollectclauses0:258"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>
304 and space based heuristics. See <a id="idx:garbagecollectclauses0:258"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>
264305 for details.
265306 </ul>
266307
267 <p>The library <code>library(prolog_jiti)</code> provides <a name="idx:jitilist0:259"></a><span class="pred-ext">jiti_list/0</span>,1
308 <p>The library <code>library(prolog_jiti)</code> provides <a id="idx:jitilist0:259"></a><span class="pred-ext">jiti_list/0</span>,1
268309 to list the characteristics of all or some of the created hash tables.
269310
270 <p><h3 id="sec:indexfut"><a name="sec:2.18.1"><span class="sec-nr">2.18.1</span> <span class="sec-title">Future
311 <p><h3 id="sec:indexfut"><a id="sec:2.18.1"><span class="sec-nr">2.18.1</span> <span class="sec-title">Future
271312 directions</span></a></h3>
272313
273 <a name="sec:indexfut"></a>
314 <a id="sec:indexfut"></a>
274315
275316 <p>
276317 <ul class="latex">
286327 lookup is too costly.
287328 </ul>
288329
289 <p><h3 id="sec:indexport"><a name="sec:2.18.2"><span class="sec-nr">2.18.2</span> <span class="sec-title">Indexing
330 <p><h3 id="sec:indexport"><a id="sec:2.18.2"><span class="sec-nr">2.18.2</span> <span class="sec-title">Indexing
290331 and portability</span></a></h3>
291332
292 <a name="sec:indexport"></a>
333 <a id="sec:indexport"></a>
293334
294335 <p>The base-line functionality of Prolog implementations provides
295336 indexing on constants and functor (name/arity) on the first argument.
296337 This must be your assumption if wide portability of your program is
297 important. This can typically be achieved by exploiting <a name="idx:termhash2:260"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
298 or <a name="idx:termhash4:261"></a><a class="pred" href="db.html#term_hash/4">term_hash/4</a>
338 important. This can typically be achieved by exploiting <a id="idx:termhash2:260"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
339 or <a id="idx:termhash4:261"></a><a class="pred" href="db.html#term_hash/4">term_hash/4</a>
299340 and/or maintaining multiple copies of a predicate with reordered
300341 arguments and wrappers that update all implementations (assert/retract)
301342 and selects the appropriate implementation (query).
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="findappfile.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="aggregate.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:libpl"><a name="sec:A"><span class="sec-nr">A</span> <span class="sec-title">The
235 <h1 id="sec:libpl"><a id="sec:A"><span class="sec-nr">A</span> <span class="sec-title">The
195236 SWI-Prolog library</span></a></h1>
196237
197 <a name="sec:libpl"></a>
238 <a id="sec:libpl"></a>
198239
199240 <p>This chapter documents the SWI-Prolog library. As SWI-Prolog provides
200241 auto-loading, there is little difference between library predicates and
209250
210251 <p>
211252 <li>If autoloading is disabled explicitly or because trapping unknown
212 predicates is disabled (see <a name="idx:unknown2:2130"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
253 predicates is disabled (see <a id="idx:unknown2:2134"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
213254 and
214 <a name="idx:currentprologflag2:2131"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>),
255 <a id="idx:currentprologflag2:2135"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>),
215256 library predicates must be loaded explicitly.
216257
217258 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section F.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="predsummary.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="funcsummary.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:library"><a name="sec:F.2"><span class="sec-nr">F.2</span> <span class="sec-title">Library
235 <h2 id="sec:library"><a id="sec:F.2"><span class="sec-nr">F.2</span> <span class="sec-title">Library
195236 predicates</span></a></h2>
196237
197 <a name="sec:library"></a>
198
199 <p><h3 id="sec:summary-lib-aggregate"><a name="sec:F.2.1"><span class="sec-nr">F.2.1</span> <span class="sec-title">library(aggregate)</span></a></h3>
200
201 <a name="sec:summary-lib-aggregate"></a>
238 <a id="sec:library"></a>
239
240 <p><h3 id="sec:summary-lib-aggregate"><a id="sec:F.2.1"><span class="sec-nr">F.2.1</span> <span class="sec-title">library(aggregate)</span></a></h3>
241
242 <a id="sec:summary-lib-aggregate"></a>
202243 <table>
203244 <tr><td><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a></td><td>Aggregate
204245 bindings in Goal according to Template.</td></tr>
214255 free variables in bagof/setof template.</td></tr>
215256 </table>
216257
217 <p><h3 id="sec:summary-lib-apply"><a name="sec:F.2.2"><span class="sec-nr">F.2.2</span> <span class="sec-title">library(apply)</span></a></h3>
218
219 <a name="sec:summary-lib-apply"></a>
258 <p><h3 id="sec:summary-lib-apply"><a id="sec:F.2.2"><span class="sec-nr">F.2.2</span> <span class="sec-title">library(apply)</span></a></h3>
259
260 <a id="sec:summary-lib-apply"></a>
220261 <table>
221262 <tr><td><a class="pred" href="apply.html#convlist/3">convlist/3</a></td><td>Similar
222263 to maplist/3, but elements for which call(Goal, ElemIn, _) fails are
255296 scan of list.</td></tr>
256297 </table>
257298
258 <p><h3 id="sec:summary-lib-assoc"><a name="sec:F.2.3"><span class="sec-nr">F.2.3</span> <span class="sec-title">library(assoc)</span></a></h3>
259
260 <a name="sec:summary-lib-assoc"></a>
299 <p><h3 id="sec:summary-lib-assoc"><a id="sec:F.2.3"><span class="sec-nr">F.2.3</span> <span class="sec-title">library(assoc)</span></a></h3>
300
301 <a id="sec:summary-lib-assoc"></a>
261302 <table>
262303 <tr><td><a class="pred" href="assoc.html#assoc_to_list/2">assoc_to_list/2</a></td><td>Translate
263304 assoc into a pairs list</td></tr>
289330 association to an assoc</td></tr>
290331 </table>
291332
292 <p><h3 id="sec:summary-lib-broadcast"><a name="sec:F.2.4"><span class="sec-nr">F.2.4</span> <span class="sec-title">library(broadcast)</span></a></h3>
293
294 <a name="sec:summary-lib-broadcast"></a>
333 <p><h3 id="sec:summary-lib-broadcast"><a id="sec:F.2.4"><span class="sec-nr">F.2.4</span> <span class="sec-title">library(broadcast)</span></a></h3>
334
335 <a id="sec:summary-lib-broadcast"></a>
295336 <table>
296337 <tr><td><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a></td><td>Send
297338 event notification</td></tr>
311352 is listening to event notifications?</td></tr>
312353 </table>
313354
314 <p><h3 id="sec:summary-lib-charsio"><a name="sec:F.2.5"><span class="sec-nr">F.2.5</span> <span class="sec-title">library(charsio)</span></a></h3>
315
316 <a name="sec:summary-lib-charsio"></a>
355 <p><h3 id="sec:summary-lib-charsio"><a id="sec:F.2.5"><span class="sec-nr">F.2.5</span> <span class="sec-title">library(charsio)</span></a></h3>
356
357 <a id="sec:summary-lib-charsio"></a>
317358 <table>
318359 <tr><td><a class="pred" href="charsio.html#atom_to_chars/2">atom_to_chars/2</a></td><td>Convert
319360 Atom into a list of character codes.</td></tr>
345386 a term to a code list.</td></tr>
346387 </table>
347388
348 <p><h3 id="sec:summary-lib-check"><a name="sec:F.2.6"><span class="sec-nr">F.2.6</span> <span class="sec-title">library(check)</span></a></h3>
349
350 <a name="sec:summary-lib-check"></a>
389 <p><h3 id="sec:summary-lib-check"><a id="sec:F.2.6"><span class="sec-nr">F.2.6</span> <span class="sec-title">library(check)</span></a></h3>
390
391 <a id="sec:summary-lib-check"></a>
351392 <table>
352393 <tr><td><a class="pred" href="check.html#check/0">check/0</a></td><td>Run
353394 all consistency checks defined by checker/2.</td></tr>
381422 hook that qualifies Goal as valid for list_strings/0.</td></tr>
382423 </table>
383424
384 <p><h3 id="sec:summary-lib-clpb"><a name="sec:F.2.7"><span class="sec-nr">F.2.7</span> <span class="sec-title">library(clpb)</span></a></h3>
385
386 <a name="sec:summary-lib-clpb"></a>
425 <p><h3 id="sec:summary-lib-clpb"><a id="sec:F.2.7"><span class="sec-nr">F.2.7</span> <span class="sec-title">library(clpb)</span></a></h3>
426
427 <a id="sec:summary-lib-clpb"></a>
387428 <table>
388429 <tr><td><a class="pred" href="clpb.html#labeling/1">labeling/1</a></td><td>Enumerate
389430 concrete solutions.</td></tr>
399440 weighted optima over admissible assignments.</td></tr>
400441 </table>
401442
402 <p><h3 id="sec:summary-lib-clpfd"><a name="sec:F.2.8"><span class="sec-nr">F.2.8</span> <span class="sec-title">library(clpfd)</span></a></h3>
403
404 <a name="sec:summary-lib-clpfd"></a>
443 <p><h3 id="sec:summary-lib-clpfd"><a id="sec:F.2.8"><span class="sec-nr">F.2.8</span> <span class="sec-title">library(clpfd)</span></a></h3>
444
445 <a id="sec:summary-lib-clpfd"></a>
405446 <table>
406447 <tr><td><a class="pred" href="clpfd.html##/\/2">#/\/2</a></td><td>P and
407448 Q hold.</td></tr>
490531 to compare/3, with finite domain variables A and B.</td></tr>
491532 </table>
492533
493 <p><h3 id="sec:summary-lib-clpqr"><a name="sec:F.2.9"><span class="sec-nr">F.2.9</span> <span class="sec-title">library(clpqr)</span></a></h3>
494
495 <a name="sec:summary-lib-clpqr"></a>
534 <p><h3 id="sec:summary-lib-clpqr"><a id="sec:F.2.9"><span class="sec-nr">F.2.9</span> <span class="sec-title">library(clpqr)</span></a></h3>
535
536 <a id="sec:summary-lib-clpqr"></a>
496537 <table>
497538 <tr><td><a class="pred" href="clpqr.html#entailed/1">entailed/1</a></td><td>Check
498539 if constraint is entailed</td></tr>
514555 constraints on variables</td></tr>
515556 </table>
516557
517 <p><h3 id="sec:summary-lib-csv"><a name="sec:F.2.10"><span class="sec-nr">F.2.10</span> <span class="sec-title">library(csv)</span></a></h3>
518
519 <a name="sec:summary-lib-csv"></a>
558 <p><h3 id="sec:summary-lib-csv"><a id="sec:F.2.10"><span class="sec-nr">F.2.10</span> <span class="sec-title">library(csv)</span></a></h3>
559
560 <a id="sec:summary-lib-csv"></a>
520561 <table>
521562 <tr><td><a class="pred" href="csv.html#csv_options/2">csv_options/2</a></td><td>Compiled
522563 is the compiled representation of the CSV processing options as they may
535576 a list of Prolog terms to a CSV file.</td></tr>
536577 <tr><td><a class="pred" href="csv.html#csv_write_stream/3">csv_write_stream/3</a></td><td>Write
537578 the rows in Data to Stream.</td></tr>
538 csv1Prolog DCG to `read/write' CSV data.
539 csv2Prolog DCG to `read/write' CSV data.
540 </table>
541
542 <p><h3 id="sec:summary-lib-debug"><a name="sec:F.2.11"><span class="sec-nr">F.2.11</span> <span class="sec-title">library(debug)</span></a></h3>
543
544 <a name="sec:summary-lib-debug"></a>
579 <tr><td><a class="pred" href="csv.html#csv//1">csv//1</a></td><td>Prolog
580 DCG to `read/write' CSV data.</td></tr>
581 <tr><td><a class="pred" href="csv.html#csv//2">csv//2</a></td><td>Prolog
582 DCG to `read/write' CSV data.</td></tr>
583 </table>
584
585 <p><h3 id="sec:summary-lib-debug"><a id="sec:F.2.11"><span class="sec-nr">F.2.11</span> <span class="sec-title">library(debug)</span></a></h3>
586
587 <a id="sec:summary-lib-debug"></a>
545588 <table>
546589 <tr><td><a class="pred" href="debug.html#assertion/1">assertion/1</a></td><td>Acts
547590 similar to C assert() macro.</td></tr>
565608 a topic from being printed.</td></tr>
566609 </table>
567610
568 <p><h3 id="sec:summary-lib-error"><a name="sec:F.2.12"><span class="sec-nr">F.2.12</span> <span class="sec-title">library(error)</span></a></h3>
569
570 <a name="sec:summary-lib-error"></a>
611 <p><h3 id="sec:summary-lib-error"><a id="sec:F.2.12"><span class="sec-nr">F.2.12</span> <span class="sec-title">library(error)</span></a></h3>
612
613 <a id="sec:summary-lib-error"></a>
571614 <table>
572615 <tr><td><a class="pred" href="error.html#current_type/3">current_type/3</a></td><td>True
573616 when Type is a currently defined type and Var satisfies Type of the body
601644 argument is over-instantiated.</td></tr>
602645 </table>
603646
604 <p><h3 id="sec:summary-lib-iostream"><a name="sec:F.2.13"><span class="sec-nr">F.2.13</span> <span class="sec-title">library(iostream)</span></a></h3>
605
606 <a name="sec:summary-lib-iostream"></a>
607 <h3 id="sec:summary-lib-summaries.d-iostream-tex"><a name="sec:F.2.14"><span class="sec-nr">F.2.14</span> <span class="sec-title">library(summaries.d/iostream/tex)</span></a></h3>
608
609 <a name="sec:summary-lib-summaries.d-iostream-tex"></a>
610
611 <p><h3 id="sec:summary-lib-lists"><a name="sec:F.2.15"><span class="sec-nr">F.2.15</span> <span class="sec-title">library(lists)</span></a></h3>
612
613 <a name="sec:summary-lib-lists"></a>
647 <p><h3 id="sec:summary-lib-iostream"><a id="sec:F.2.13"><span class="sec-nr">F.2.13</span> <span class="sec-title">library(iostream)</span></a></h3>
648
649 <a id="sec:summary-lib-iostream"></a>
650 <h3 id="sec:summary-lib-summaries.d-iostream-tex"><a id="sec:F.2.14"><span class="sec-nr">F.2.14</span> <span class="sec-title">library(summaries.d/iostream/tex)</span></a></h3>
651
652 <a id="sec:summary-lib-summaries.d-iostream-tex"></a>
653
654 <p><h3 id="sec:summary-lib-lists"><a id="sec:F.2.15"><span class="sec-nr">F.2.15</span> <span class="sec-title">library(lists)</span></a></h3>
655
656 <a id="sec:summary-lib-lists"></a>
614657 <table>
615658 <tr><td><a class="pred" href="lists.html#append/2">append/2</a></td><td>Concatenate
616659 a list of lists.</td></tr>
678721 if Set3 unifies with the union of the lists Set1 and Set2.</td></tr>
679722 </table>
680723
681 <p><h3 id="sec:summary-lib-main"><a name="sec:F.2.16"><span class="sec-nr">F.2.16</span> <span class="sec-title">library(main)</span></a></h3>
682
683 <a name="sec:summary-lib-main"></a>
724 <p><h3 id="sec:summary-lib-main"><a id="sec:F.2.16"><span class="sec-nr">F.2.16</span> <span class="sec-title">library(main)</span></a></h3>
725
726 <a id="sec:summary-lib-main"></a>
684727 <table>
685728 <tr><td><a class="pred" href="main.html#argv_options/3">argv_options/3</a></td><td>Generic
686729 transformation of long commandline arguments to options.</td></tr>
688731 main/1 using the passed command-line arguments.</td></tr>
689732 </table>
690733
691 <p><h3 id="sec:summary-lib-option"><a name="sec:F.2.17"><span class="sec-nr">F.2.17</span> <span class="sec-title">library(option)</span></a></h3>
692
693 <a name="sec:summary-lib-option"></a>
734 <p><h3 id="sec:summary-lib-option"><a id="sec:F.2.17"><span class="sec-nr">F.2.17</span> <span class="sec-title">library(option)</span></a></h3>
735
736 <a id="sec:summary-lib-option"></a>
694737 <table>
695738 <tr><td><a class="pred" href="option.html#dict_options/2">dict_options/2</a></td><td>Convert
696739 between an option list and a dictionary.</td></tr>
708751 and remove Option with default value.</td></tr>
709752 </table>
710753
711 <p><h3 id="sec:summary-lib-optparse"><a name="sec:F.2.18"><span class="sec-nr">F.2.18</span> <span class="sec-title">library(optparse)</span></a></h3>
712
713 <a name="sec:summary-lib-optparse"></a>
754 <p><h3 id="sec:summary-lib-optparse"><a id="sec:F.2.18"><span class="sec-nr">F.2.18</span> <span class="sec-title">library(optparse)</span></a></h3>
755
756 <a id="sec:summary-lib-optparse"></a>
714757 <table>
715758 <tr><td><a class="pred" href="optparse.html#opt_arguments/3">opt_arguments/3</a></td><td>Extract
716759 commandline options according to a specification.</td></tr>
724767 to parse option text Codes to an object of type Type.</td></tr>
725768 </table>
726769
727 <p><h3 id="sec:summary-lib-ordsets"><a name="sec:F.2.19"><span class="sec-nr">F.2.19</span> <span class="sec-title">library(ordsets)</span></a></h3>
728
729 <a name="sec:summary-lib-ordsets"></a>
770 <p><h3 id="sec:summary-lib-ordsets"><a id="sec:F.2.19"><span class="sec-nr">F.2.19</span> <span class="sec-title">library(ordsets)</span></a></h3>
771
772 <a id="sec:summary-lib-ordsets"></a>
730773 <table>
731774 <tr><td><a class="pred" href="ordsets.html#is_ordset/1">is_ordset/1</a></td><td>True
732775 if Term is an ordered set.</td></tr>
770813 iff ord_union(Set1, Set2, Union) and ord_subtract(Set2, Set1, New).</td></tr>
771814 </table>
772815
773 <p><h3 id="sec:summary-lib-persistency"><a name="sec:F.2.20"><span class="sec-nr">F.2.20</span> <span class="sec-title">library(persistency)</span></a></h3>
774
775 <a name="sec:summary-lib-persistency"></a>
816 <p><h3 id="sec:summary-lib-persistency"><a id="sec:F.2.20"><span class="sec-nr">F.2.20</span> <span class="sec-title">library(persistency)</span></a></h3>
817
818 <a id="sec:summary-lib-persistency"></a>
776819 <table>
777820 <tr><td><a class="pred" href="persistency.html#current_persistent_predicate/1">current_persistent_predicate/1</a></td><td>True
778821 if PI is a predicate that provides access to the persistent database DB.</td></tr>
791834 dynamic database terms.</td></tr>
792835 </table>
793836
794 <p><h3 id="sec:summary-lib-predicate_options"><a name="sec:F.2.21"><span class="sec-nr">F.2.21</span> <span class="sec-title">library(predicate_options)</span></a></h3>
795
796 <a name="sec:summary-lib-predicate_options"></a>
837 <p><h3 id="sec:summary-lib-predicate_options"><a id="sec:F.2.21"><span class="sec-nr">F.2.21</span> <span class="sec-title">library(predicate_options)</span></a></h3>
838
839 <a id="sec:summary-lib-predicate_options"></a>
797840 <table>
798841 <tr><td><a class="pred" href="predicate_options.html#assert_predicate_options/4">assert_predicate_options/4</a></td><td>As
799842 predicate_options(:PI, +Arg, +Options).</td></tr>
819862 all dynamically (derived) predicate options.</td></tr>
820863 </table>
821864
822 <p><h3 id="sec:summary-lib-prologpack"><a name="sec:F.2.22"><span class="sec-nr">F.2.22</span> <span class="sec-title">library(prologpack)</span></a></h3>
823
824 <a name="sec:summary-lib-prologpack"></a>
865 <p><h3 id="sec:summary-lib-prologpack"><a id="sec:F.2.22"><span class="sec-nr">F.2.22</span> <span class="sec-title">library(prologpack)</span></a></h3>
866
867 <a id="sec:summary-lib-prologpack"></a>
825868 <table>
826869 <tr><td><a class="pred" href="prologpack.html#environment/2">environment/2</a></td><td>Hook
827870 to define the environment for building packs.</td></tr>
851894 if File is a unique id for the referenced pack and version.</td></tr>
852895 </table>
853896
854 <p><h3 id="sec:summary-lib-prologxref"><a name="sec:F.2.23"><span class="sec-nr">F.2.23</span> <span class="sec-title">library(prologxref)</span></a></h3>
855
856 <a name="sec:summary-lib-prologxref"></a>
897 <p><h3 id="sec:summary-lib-prologxref"><a id="sec:F.2.23"><span class="sec-nr">F.2.23</span> <span class="sec-title">library(prologxref)</span></a></h3>
898
899 <a id="sec:summary-lib-prologxref"></a>
857900 <table>
858901 <tr><td><a class="pred" href="prolog_xref.html#prolog:called_by/2">prolog:called_by/2</a></td><td><i>(hook)</i>
859902 Extend cross-referencer</td></tr>
875918 analysis of source</td></tr>
876919 </table>
877920
878 <p><h3 id="sec:summary-lib-pairs"><a name="sec:F.2.24"><span class="sec-nr">F.2.24</span> <span class="sec-title">library(pairs)</span></a></h3>
879
880 <a name="sec:summary-lib-pairs"></a>
921 <p><h3 id="sec:summary-lib-pairs"><a id="sec:F.2.24"><span class="sec-nr">F.2.24</span> <span class="sec-title">library(pairs)</span></a></h3>
922
923 <a id="sec:summary-lib-pairs"></a>
881924 <table>
882925 <tr><td><a class="pred" href="pairs.html#group_pairs_by_key/2">group_pairs_by_key/2</a></td><td>Group
883926 values with equivalent (==/2) consecutive keys.</td></tr>
893936 Key-Value to Value-Key.</td></tr>
894937 </table>
895938
896 <p><h3 id="sec:summary-lib-pio"><a name="sec:F.2.25"><span class="sec-nr">F.2.25</span> <span class="sec-title">library(pio)</span></a></h3>
897
898 <a name="sec:summary-lib-pio"></a>
899 <h4 id="sec:summary-lib-pure-input"><a name="sec:F.2.25.1"><span class="sec-nr">F.2.25.1</span> <span class="sec-title">library(pure_input)</span></a></h4>
900
901 <a name="sec:summary-lib-pure-input"></a>
939 <p><h3 id="sec:summary-lib-pio"><a id="sec:F.2.25"><span class="sec-nr">F.2.25</span> <span class="sec-title">library(pio)</span></a></h3>
940
941 <a id="sec:summary-lib-pio"></a>
942 <h4 id="sec:summary-lib-pure-input"><a id="sec:F.2.25.1"><span class="sec-nr">F.2.25.1</span> <span class="sec-title">library(pure_input)</span></a></h4>
943
944 <a id="sec:summary-lib-pure-input"></a>
902945 <table>
903946 <tr><td><a class="pred" href="pio.html#phrase_from_file/2">phrase_from_file/2</a></td><td>Process
904947 the content of File using the DCG rule Grammar.</td></tr>
908951 Grammer against the character codes on Stream.</td></tr>
909952 <tr><td><a class="pred" href="pio.html#stream_to_lazy_list/2">stream_to_lazy_list/2</a></td><td>Create
910953 a lazy list representing the character codes in Stream.</td></tr>
911 lazy_list_character_count1True when CharCount is the current character
912 count in the Lazy list.
913 lazy_list_location1Determine current (error) location in a lazy list.
914 syntax_error1Throw the syntax error Error at the current location of the
915 input.
916 </table>
917
918 <p><h3 id="sec:summary-lib-random"><a name="sec:F.2.26"><span class="sec-nr">F.2.26</span> <span class="sec-title">library(random)</span></a></h3>
919
920 <a name="sec:summary-lib-random"></a>
954 <tr><td><a class="pred" href="pio.html#lazy_list_character_count//1">lazy_list_character_count//1</a></td><td>True
955 when CharCount is the current character count in the Lazy list.</td></tr>
956 <tr><td><a class="pred" href="pio.html#lazy_list_location//1">lazy_list_location//1</a></td><td>Determine
957 current (error) location in a lazy list.</td></tr>
958 <tr><td><a class="pred" href="pio.html#syntax_error//1">syntax_error//1</a></td><td>Throw
959 the syntax error Error at the current location of the input.</td></tr>
960 </table>
961
962 <p><h3 id="sec:summary-lib-random"><a id="sec:F.2.26"><span class="sec-nr">F.2.26</span> <span class="sec-title">library(random)</span></a></h3>
963
964 <a id="sec:summary-lib-random"></a>
921965 <table>
922966 <tr><td><a class="pred" href="random.html#getrand/1">getrand/1</a></td><td>Query/set
923967 the state of the random generator.</td></tr>
949993 the state of the random generator.</td></tr>
950994 </table>
951995
952 <p><h3 id="sec:summary-lib-readutil"><a name="sec:F.2.27"><span class="sec-nr">F.2.27</span> <span class="sec-title">library(readutil)</span></a></h3>
953
954 <a name="sec:summary-lib-readutil"></a>
996 <p><h3 id="sec:summary-lib-readutil"><a id="sec:F.2.27"><span class="sec-nr">F.2.27</span> <span class="sec-title">library(readutil)</span></a></h3>
997
998 <a id="sec:summary-lib-readutil"></a>
955999 <table>
9561000 <tr><td><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a></td><td>Read
9571001 line from a stream</td></tr>
9671011 contents of file to Prolog terms</td></tr>
9681012 </table>
9691013
970 <p><h3 id="sec:summary-lib-record"><a name="sec:F.2.28"><span class="sec-nr">F.2.28</span> <span class="sec-title">library(record)</span></a></h3>
971
972 <a name="sec:summary-lib-record"></a>
1014 <p><h3 id="sec:summary-lib-record"><a id="sec:F.2.28"><span class="sec-nr">F.2.28</span> <span class="sec-title">library(record)</span></a></h3>
1015
1016 <a id="sec:summary-lib-record"></a>
9731017 <table>
9741018 <tr><td><a class="pred" href="record.html#record/1">record/1</a></td><td>Define
9751019 named fields in a term</td></tr>
9761020 </table>
9771021
978 <p><h3 id="sec:summary-lib-registry"><a name="sec:F.2.29"><span class="sec-nr">F.2.29</span> <span class="sec-title">library(registry)</span></a></h3>
979
980 <a name="sec:summary-lib-registry"></a>
1022 <p><h3 id="sec:summary-lib-registry"><a id="sec:F.2.29"><span class="sec-nr">F.2.29</span> <span class="sec-title">library(registry)</span></a></h3>
1023
1024 <a id="sec:summary-lib-registry"></a>
9811025
9821026 <p>This library is only available on Windows systems.
9831027 <table>
9991043 Prolog</td></tr>
10001044 </table>
10011045
1002 <p><h3 id="sec:summary-lib-simplex"><a name="sec:F.2.30"><span class="sec-nr">F.2.30</span> <span class="sec-title">library(simplex)</span></a></h3>
1003
1004 <a name="sec:summary-lib-simplex"></a>
1046 <p><h3 id="sec:summary-lib-simplex"><a id="sec:F.2.30"><span class="sec-nr">F.2.30</span> <span class="sec-title">library(simplex)</span></a></h3>
1047
1048 <a id="sec:summary-lib-simplex"></a>
10051049 <table>
10061050 <tr><td><a class="pred" href="simplex.html#assignment/2">assignment/2</a></td><td>Solve
10071051 assignment problem</td></tr>
10271071 value of variable in solved state</td></tr>
10281072 </table>
10291073
1030 <p><h3 id="sec:summary-lib-ugraphs"><a name="sec:F.2.31"><span class="sec-nr">F.2.31</span> <span class="sec-title">library(ugraphs)</span></a></h3>
1031
1032 <a name="sec:summary-lib-ugraphs"></a>
1074 <p><h3 id="sec:summary-lib-ugraphs"><a id="sec:F.2.31"><span class="sec-nr">F.2.31</span> <span class="sec-title">library(ugraphs)</span></a></h3>
1075
1076 <a id="sec:summary-lib-ugraphs"></a>
10331077 <table>
10341078 <tr><td><a class="pred" href="ugraphs.html#vertices_edges_to_ugraph/3">vertices_edges_to_ugraph/3</a></td><td>Create
10351079 unweighted graph</td></tr>
10661110 of two graphs</td></tr>
10671111 </table>
10681112
1069 <p><h3 id="sec:summary-lib-url"><a name="sec:F.2.32"><span class="sec-nr">F.2.32</span> <span class="sec-title">library(url)</span></a></h3>
1070
1071 <a name="sec:summary-lib-url"></a>
1113 <p><h3 id="sec:summary-lib-url"><a id="sec:F.2.32"><span class="sec-nr">F.2.32</span> <span class="sec-title">library(url)</span></a></h3>
1114
1115 <a id="sec:summary-lib-url"></a>
10721116 <table>
10731117 <tr><td><a class="pred" href="url.html#file_name_to_url/2">file_name_to_url/2</a></td><td>Translate
10741118 between a filename and a file:<code>//</code> URL.</td></tr>
10921136 to/from application/x-www-form-encoded.</td></tr>
10931137 </table>
10941138
1095 <p><h3 id="sec:summary-lib-www_browser"><a name="sec:F.2.33"><span class="sec-nr">F.2.33</span> <span class="sec-title">library(www_browser)</span></a></h3>
1096
1097 <a name="sec:summary-lib-www_browser"></a>
1139 <p><h3 id="sec:summary-lib-www_browser"><a id="sec:F.2.33"><span class="sec-nr">F.2.33</span> <span class="sec-title">library(www_browser)</span></a></h3>
1140
1141 <a id="sec:summary-lib-www_browser"></a>
10981142 <table>
10991143 <tr><td><a class="pred" href="www_browser.html#www_open_url/1">www_open_url/1</a></td><td>Open
11001144 a web-page in a browser</td></tr>
11011145 </table>
11021146
1103 <p><h3 id="sec:summary-lib-solution_sequences"><a name="sec:F.2.34"><span class="sec-nr">F.2.34</span> <span class="sec-title">library(solution_sequences)</span></a></h3>
1104
1105 <a name="sec:summary-lib-solution_sequences"></a>
1106 <table>
1147 <p><h3 id="sec:summary-lib-solution_sequences"><a id="sec:F.2.34"><span class="sec-nr">F.2.34</span> <span class="sec-title">library(solution_sequences)</span></a></h3>
1148
1149 <a id="sec:summary-lib-solution_sequences"></a>
1150 <table>
1151 <tr><td><a class="pred" href="solutionsequences.html#call_nth/2">call_nth/2</a></td><td>True
1152 when Goal succeeded for the Nth time.</td></tr>
11071153 <tr><td><a class="pred" href="solutionsequences.html#distinct/1">distinct/1</a></td><td>True
11081154 if Goal is true and no previous solution of Goal bound Witness to the
11091155 same value.</td></tr>
11261172 a limited amount of memory.</td></tr>
11271173 </table>
11281174
1129 <p><h3 id="sec:summary-lib-thread_pool"><a name="sec:F.2.35"><span class="sec-nr">F.2.35</span> <span class="sec-title">library(thread_pool)</span></a></h3>
1130
1131 <a name="sec:summary-lib-thread_pool"></a>
1175 <p><h3 id="sec:summary-lib-thread_pool"><a id="sec:F.2.35"><span class="sec-nr">F.2.35</span> <span class="sec-title">library(thread_pool)</span></a></h3>
1176
1177 <a id="sec:summary-lib-thread_pool"></a>
11321178 <table>
11331179 <tr><td><a class="pred" href="threadpool.html#create_pool/1">create_pool/1</a></td><td>Hook
11341180 to create a thread pool lazily.</td></tr>
11441190 if Property is a property of thread pool Name.</td></tr>
11451191 </table>
11461192
1147 <p><h3 id="sec:summary-lib-varnumbers"><a name="sec:F.2.36"><span class="sec-nr">F.2.36</span> <span class="sec-title">library(varnumbers)</span></a></h3>
1148
1149 <a name="sec:summary-lib-varnumbers"></a>
1193 <p><h3 id="sec:summary-lib-varnumbers"><a id="sec:F.2.36"><span class="sec-nr">F.2.36</span> <span class="sec-title">library(varnumbers)</span></a></h3>
1194
1195 <a id="sec:summary-lib-varnumbers"></a>
11501196 <table>
11511197 <tr><td><a class="pred" href="varnumbers.html#max_var_number/3">max_var_number/3</a></td><td>True
11521198 when Max is the max of Start and the highest numbered $VAR(N) term.</td></tr>
11631209 the `X` terms with the variable it is mapped to.</td></tr>
11641210 </table>
11651211
1166 <p><h3 id="sec:summary-lib-yall"><a name="sec:F.2.37"><span class="sec-nr">F.2.37</span> <span class="sec-title">library(yall)</span></a></h3>
1167
1168 <a name="sec:summary-lib-yall"></a>
1212 <p><h3 id="sec:summary-lib-yall"><a id="sec:F.2.37"><span class="sec-nr">F.2.37</span> <span class="sec-title">library(yall)</span></a></h3>
1213
1214 <a id="sec:summary-lib-yall"></a>
11691215 <table>
11701216 <tr><td><a class="pred" href="yall.html#//2">//2</a></td><td>Shorthand
11711217 for `Free/[]<code>&gt;&gt;</code>Lambda`.</td></tr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="glossary.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="contrib.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:license"><a name="sec:E"><span class="sec-nr">E</span> <span class="sec-title">SWI-Prolog
235 <h1 id="sec:license"><a id="sec:E"><span class="sec-nr">E</span> <span class="sec-title">SWI-Prolog
195236 License Conditions and Tools</span></a></h1>
196237
197 <a name="sec:license"></a>
198
199 <p>As of version 7.4.0<sup class="fn">188<span class="fn-text">Actually
238 <a id="sec:license"></a>
239
240 <p>As of version 7.4.0<sup class="fn">189<span class="fn-text">Actually
200241 pre-release 7.3.33</span></sup>, the SWI-Prolog source code is
201242 distributed under the
202 https://opensource.org/licenses/BSD-2-ClauseSimplified BSD license:
243 <a class="url" href="https://opensource.org/licenses/BSD-2-Clause">Simplified
244 BSD</a> license:
203245
204246 <pre class="code">
205247 Redistribution and use in source and binary forms, with or without
233275 linked to libraries that are more restrictive and in addition your code
234276 may have loaded extension packages that have more restrictive
235277 conditions. In particular, the core is by default linked to
236 https://gmplib.org/libgmp, distributed under the Lesser GNU Public
237 license.
278 <a class="url" href="https://gmplib.org/">libgmp</a>, distributed under
279 the Lesser GNU Public license.
238280
239281 <p>The above implies you need to configure and recompile the system
240282 without these components. For this we provide options to the <b>configure</b>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.20</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.20</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="widechars.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="64bits.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:limits"><a name="sec:2.20"><span class="sec-nr">2.20</span> <span class="sec-title">System
235 <h2 id="sec:limits"><a id="sec:2.20"><span class="sec-nr">2.20</span> <span class="sec-title">System
195236 limits</span></a></h2>
196237
197 <a name="sec:limits"></a>
198
199 <p><h3 id="sec:memlimit"><a name="sec:2.20.1"><span class="sec-nr">2.20.1</span> <span class="sec-title">Limits
238 <a id="sec:limits"></a>
239
240 <p><h3 id="sec:memlimit"><a id="sec:2.20.1"><span class="sec-nr">2.20.1</span> <span class="sec-title">Limits
200241 on memory areas</span></a></h3>
201242
202 <a name="sec:memlimit"></a>
243 <a id="sec:memlimit"></a>
203244
204245 <p>SWI-Prolog has a number of memory areas which are only enlarged to a
205246 certain limit. The internal data representation limits the local, global
213254 data.
214255
215256 <p>The limits can be changed from the command line as well as at runtime
216 using <a name="idx:setprologstack2:278"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
257 using <a id="idx:setprologstack2:278"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
217258 The table below shows these areas. The first column gives the option
218259 name to modify the size of the area. The option character is immediately
219260 followed by a number and optionally by a
221262 indicator, the value is interpreted in Kbytes (1024&nbsp;bytes); with <code>m</code>,
222263 the value is interpreted in Mbytes (<var>1024 &times; 1024</var> bytes).
223264
224 <p>The PrologScript facility described in <a class="sec" href="compilation.html">section
265 <p>The PrologScript facility described in <a class="sec" href="compilation.html#sec:2.10.2.1">section
225266 2.10.2.1</a> provides a mechanism for specifying options with the load
226267 file. On Windows the default stack sizes are controlled using the
227 Windows <a name="idx:registry:279">registry</a> on the key <code>HKEY_CURRENT_USER\Software\SWI\Prolog</code>
268 Windows <a id="idx:registry:279">registry</a> on the key <code>HKEY_CURRENT_USER\Software\SWI\Prolog</code>
228269 using the names <code>localSize</code>, <code>globalSize</code> and <code>trailSize</code>.
229270 The value is a <code>DWORD</code> expressing the default stack size in
230271 Kbytes. A GUI for modifying these values is provided using the XPCE
231 package. To use this, start the XPCE manual tools using manpce0, after
272 package. To use this, start the XPCE manual tools using manpce/0 , after
232273 which you find <i>Preferences</i> in the <i>File</i> menu.
233274
234275 <p>Considering portability, applications that need to modify the default
235 limits are advised to do so using <a name="idx:setprologstack2:280"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
236
237 <p><table border="2" frame="box" rules="groups" style="margin:auto">
238 <tr valign="top"><td align=center>Option</td><td align=center>Default</td><td>Area
276 limits are advised to do so using <a id="idx:setprologstack2:280"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
277
278 <p><table class="latex frame-box center">
279 <tr><td align=center>Option</td><td align=center>Default</td><td>Area
239280 name</td><td>Description </td></tr>
240 <tbody>
241 <tr valign="top"><td align=center><strong>-L</strong> </td><td align=center>128M</td><td><b>local
281 <tr class="hline"><td align=center><strong>-L</strong> </td><td align=center>128M</td><td><b>local
242282 stack</b></td><td>The local stack is used to store the execution
243283 environments of procedure invocations. The space for an environment is
244284 reclaimed when it fails, exits without leaving choice points, the
245285 alternatives are cut off with the !/0 predicate or no choice points have
246286 been created since the invocation and the last subclause is started
247287 (last call optimisation). </td></tr>
248 <tr valign="top"><td align=center><strong>-G</strong> </td><td align=center>128M</td><td><b>global
288 <tr><td align=center><strong>-G</strong> </td><td align=center>128M</td><td><b>global
249289 stack</b></td><td>The global stack is used to store terms created during
250290 Prolog's execution. Terms on this stack will be reclaimed by
251291 backtracking to a point before the term was created or by garbage
252292 collection (provided the term is no longer referenced). </td></tr>
253 <tr valign="top"><td align=center><strong>-T</strong> </td><td align=center>128M</td><td><b>trail
293 <tr><td align=center><strong>-T</strong> </td><td align=center>128M</td><td><b>trail
254294 stack</b></td><td>The trail stack is used to store assignments during
255295 execution. Entries on this stack remain alive until backtracking before
256296 the point of creation or the garbage collector determines they are no
257297 longer needed. </td></tr>
258298 </table>
259299 <div class="caption"><b>Table 2 : </b>Memory areas</div>
260 <a name="tab:areas"></a>
261
262 <p><h4 id="sec:heap"><a name="sec:2.20.1.1"><span class="sec-nr">2.20.1.1</span> <span class="sec-title">The
300 <a id="tab:areas"></a>
301
302 <p><h4 id="sec:heap"><a id="sec:2.20.1.1"><span class="sec-nr">2.20.1.1</span> <span class="sec-title">The
263303 heap</span></a></h4>
264304
265 <a name="sec:heap"></a>
266
267 <p><a name="idx:stackmemorymanagement:281"></a><a name="idx:memorylayout:282"></a>With
305 <a id="sec:heap"></a>
306
307 <p><a id="idx:stackmemorymanagement:281"></a><a id="idx:memorylayout:282"></a>With
268308 the heap, we refer to the memory area used by malloc() and friends.
269309 SWI-Prolog uses the area to store atoms, functors, predicates and their
270310 clauses, records and other dynamic data. No limits are imposed on the
271311 addresses returned by malloc() and friends.
272312
273 <p><h3 id="sec:morelimits"><a name="sec:2.20.2"><span class="sec-nr">2.20.2</span> <span class="sec-title">Other
313 <p><h3 id="sec:morelimits"><a id="sec:2.20.2"><span class="sec-nr">2.20.2</span> <span class="sec-title">Other
274314 Limits</span></a></h3>
275315
276 <a name="sec:morelimits"></a>
316 <a id="sec:morelimits"></a>
277317
278318 <dl class="latex">
279319 <dt><b>Clauses</b></dt>
285325 <dd>
286326 SWI-Prolog has no limits on the length of atoms and strings. The number
287327 of atoms is limited to 16777216 (16M) on 32-bit machines. On 64-bit
288 machines this is virtually unlimited. See also <a class="sec" href="foreigninclude.html">section
328 machines this is virtually unlimited. See also <a class="sec" href="foreigninclude.html#sec:11.4.2.1">section
289329 11.4.2.1</a>.</dd>
290330 <dt><b>Memory areas</b></dt>
291331 <dd>
300340 managed stack and perform optimization for processing the last argument
301341 of a term. This implies they can process deeply nested terms at constant
302342 and low usage of the C stack, and the system raises a resource error if
303 no more stack can be allocated. Currently only <a name="idx:read1:283"></a><a class="pred" href="termrw.html#read/1">read/1</a>
304 and <a name="idx:write1:284"></a><a class="pred" href="termrw.html#write/1">write/1</a>
343 no more stack can be allocated. Currently only <a id="idx:read1:283"></a><a class="pred" href="termrw.html#read/1">read/1</a>
344 and <a id="idx:write1:284"></a><a class="pred" href="termrw.html#write/1">write/1</a>
305345 (and all variations thereof) still use the C stack and may cause the
306346 system to crash in an uncontrolled way (i.e., not mapped to a Prolog
307347 exception that can be caught).</dd>
324364 </dd>
325365 </dl>
326366
327 <p><h3 id="sec:resnames"><a name="sec:2.20.3"><span class="sec-nr">2.20.3</span> <span class="sec-title">Reserved
367 <p><h3 id="sec:resnames"><a id="sec:2.20.3"><span class="sec-nr">2.20.3</span> <span class="sec-title">Reserved
328368 Names</span></a></h3>
329369
330 <a name="sec:resnames"></a>
370 <a id="sec:resnames"></a>
331371
332372 <p>The boot compiler (see <strong>-b</strong> option) does not support
333373 the module system. As large parts of the system are written in Prolog
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="edit.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="typetest.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:listing"><a name="sec:4.5"><span class="sec-nr">4.5</span> <span class="sec-title">List
235 <h2 id="sec:listing"><a id="sec:4.5"><span class="sec-nr">4.5</span> <span class="sec-title">List
195236 the program, predicates or clauses</span></a></h2>
196237
197 <a name="sec:listing"></a>
238 <a id="sec:listing"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="listing/1"><strong>listing</strong>(<var>:Pred</var>)</a></dt>
241 <dt class="pubdef"><a id="listing/1"><strong>listing</strong>(<var>:Pred</var>)</a></dt>
201242 <dd class="defbody">
202243 List predicates specified by <var>Pred</var>. <var>Pred</var> may be a
203244 predicate name (atom), which lists all predicates with this name,
209250
210251 <p>A listing is produced by enumerating the clauses of the predicate
211252 using
212 <a name="idx:clause2:595"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
213 and printing each clause using <a name="idx:portrayclause1:596"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>.
253 <a id="idx:clause2:595"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
254 and printing each clause using <a id="idx:portrayclause1:596"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>.
214255 This implies that the variable names are generated (<var>A</var>, <var>B</var>,
215 ... ) and the layout is defined by rules in <a name="idx:portrayclause1:597"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>.</dd>
216 <dt class="pubdef"><a name="listing/0"><strong>listing</strong></a></dt>
217 <dd class="defbody">
218 List all predicates from the calling module using <a name="idx:listing1:598"></a><a class="pred" href="listing.html#listing/1">listing/1</a>.
256 ... ) and the layout is defined by rules in <a id="idx:portrayclause1:597"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>.</dd>
257 <dt class="pubdef"><a id="listing/0"><strong>listing</strong></a></dt>
258 <dd class="defbody">
259 List all predicates from the calling module using <a id="idx:listing1:598"></a><a class="pred" href="listing.html#listing/1">listing/1</a>.
219260 For example,
220261 <code>?- listing.</code> lists clauses in the default <code>user</code>
221262 module and <code>?- lists:listing.</code> lists the clauses in the
222263 module
223264 <code>lists</code>.</dd>
224 <dt class="pubdef"><a name="portray_clause/1"><strong>portray_clause</strong>(<var>+Clause</var>)</a></dt>
265 <dt class="pubdef"><a id="portray_clause/1"><strong>portray_clause</strong>(<var>+Clause</var>)</a></dt>
225266 <dd class="defbody">
226267 Pretty print a clause. A clause should be specified as a term `<code>&lt;<var>Head</var>&gt;
227268 :- &lt;<var>Body</var>&gt;</code>'. Facts are represented as `<code>&lt;<var>Head</var>&gt;
228269 :- true</code>' or simply <code>&lt;<var>Head</var>&gt;</code>.
229270 Variables in the clause are written as <var>A</var>, <var>B</var>, ... .
230 Singleton variables are written as <code>_</code>. See also <a name="idx:portrayclause2:599"></a><a class="pred" href="listing.html#portray_clause/2">portray_clause/2</a>.</dd>
231 <dt class="pubdef"><a name="portray_clause/2"><strong>portray_clause</strong>(<var>+Stream,
271 Singleton variables are written as <code>_</code>. See also <a id="idx:portrayclause2:599"></a><a class="pred" href="listing.html#portray_clause/2">portray_clause/2</a>.</dd>
272 <dt class="pubdef"><a id="portray_clause/2"><strong>portray_clause</strong>(<var>+Stream,
232273 +Clause</var>)</a></dt>
233274 <dd class="defbody">
234 Pretty print a clause to <var>Stream</var>. See <a name="idx:portrayclause1:600"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>
275 Pretty print a clause to <var>Stream</var>. See <a id="idx:portrayclause1:600"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>
235276 for details.
236277 </dd>
237278 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.15</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="iostream.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="main.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:lists"><a name="sec:A.15"><span class="sec-nr">A.15</span> <span class="sec-title">library(lists):
235 <h2 id="sec:lists"><a id="sec:A.15"><span class="sec-nr">A.15</span> <span class="sec-title">library(lists):
195236 List Manipulation</span></a></h2>
196237
197 <p><a name="sec:lists"></a>
238 <p><a id="sec:lists"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">Compatibility</dt>
215256 their specification by Quintus and SICStus.
216257
217258 <dl class="latex">
218 <dt class="pubdef"><a name="member/2"><strong>member</strong>(<var>?Elem,
259 <dt class="pubdef"><a id="member/2"><strong>member</strong>(<var>?Elem,
219260 ?List</var>)</a></dt>
220261 <dd class="defbody">
221262 True if <var>Elem</var> is a member of <var>List</var>. The SWI-Prolog
235276 </dl>
236277
237278 </dd>
238 <dt class="pubdef"><a name="append/3"><strong>append</strong>(<var>?List1,
279 <dt class="pubdef"><a id="append/3"><strong>append</strong>(<var>?List1,
239280 ?List2, ?List1AndList2</var>)</a></dt>
240281 <dd class="defbody">
241282 <var>List1AndList2</var> is the concatenation of <var>List1</var> and <var>List2</var></dd>
242 <dt class="pubdef"><a name="append/2"><strong>append</strong>(<var>+ListOfLists,
283 <dt class="pubdef"><a id="append/2"><strong>append</strong>(<var>+ListOfLists,
243284 ?List</var>)</a></dt>
244285 <dd class="defbody">
245286 Concatenate a list of lists. Is true if <var>ListOfLists</var> is a list
246287 of lists, and <var>List</var> is the concatenation of these lists.
247288 <table class="arglist">
248 <tr valign="top"><td><var>ListOfLists</var> </td><td>must be a list of <i>possibly</i>
289 <tr><td><var>ListOfLists</var> </td><td>must be a list of <i>possibly</i>
249290 partial lists </td></tr>
250291 </table>
251292 </dd>
252 <dt class="pubdef"><a name="prefix/2"><strong>prefix</strong>(<var>?Part,
293 <dt class="pubdef"><a id="prefix/2"><strong>prefix</strong>(<var>?Part,
253294 ?Whole</var>)</a></dt>
254295 <dd class="defbody">
255296 True iff <var>Part</var> is a leading substring of <var>Whole</var>.
256297 This is the same as <code>append(Part, _, Whole)</code>.</dd>
257 <dt class="pubdef"><a name="select/3"><strong>select</strong>(<var>?Elem,
298 <dt class="pubdef"><a id="select/3"><strong>select</strong>(<var>?Elem,
258299 ?List1, ?List2</var>)</a></dt>
259300 <dd class="defbody">
260301 Is true when <var>List1</var>, with <var>Elem</var> removed, results in <var>List2</var>.</dd>
261 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="selectchk/3"><strong>selectchk</strong>(<var>+Elem,
302 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="selectchk/3"><strong>selectchk</strong>(<var>+Elem,
262303 +List, -Rest</var>)</a></dt>
263304 <dd class="defbody">
264305 Semi-deterministic removal of first element in <var>List</var> that
265306 unifies with <var>Elem</var>.</dd>
266 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="select/4"><strong>select</strong>(<var>?X,
307 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="select/4"><strong>select</strong>(<var>?X,
267308 ?XList, ?Y, ?YList</var>)</a></dt>
268309 <dd class="defbody">
269310 Select from two lists at the same positon. True if <var>XList</var> is
289330 </dl>
290331
291332 </dd>
292 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="selectchk/4"><strong>selectchk</strong>(<var>?X,
333 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="selectchk/4"><strong>selectchk</strong>(<var>?X,
293334 ?XList, ?Y, ?YList</var>)</a></dt>
294335 <dd class="defbody">
295336 Semi-deterministic version of <a class="pred" href="lists.html#select/4">select/4</a>.</dd>
296 <dt class="pubdef"><a name="nextto/3"><strong>nextto</strong>(<var>?X,
297 ?Y, ?List</var>)</a></dt>
337 <dt class="pubdef"><a id="nextto/3"><strong>nextto</strong>(<var>?X, ?Y,
338 ?List</var>)</a></dt>
298339 <dd class="defbody">
299340 True if <var>Y</var> directly follows <var>X</var> in <var>List</var>.</dd>
300 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="delete/3"><strong>delete</strong>(<var>+List1,
341 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="delete/3"><strong>delete</strong>(<var>+List1,
301342 @Elem, -List2</var>)</a></dt>
302343 <dd class="defbody">
303344 Delete matching elements from a list. True when <var>List2</var> is a
321362 </dl>
322363
323364 </dd>
324 <dt class="pubdef"><a name="nth0/3"><strong>nth0</strong>(<var>?Index,
365 <dt class="pubdef"><a id="nth0/3"><strong>nth0</strong>(<var>?Index,
325366 ?List, ?Elem</var>)</a></dt>
326367 <dd class="defbody">
327368 True when <var>Elem</var> is the <var>Index</var>'th element of <var>List</var>.
340381 </dl>
341382
342383 </dd>
343 <dt class="pubdef"><a name="nth1/3"><strong>nth1</strong>(<var>?Index,
384 <dt class="pubdef"><a id="nth1/3"><strong>nth1</strong>(<var>?Index,
344385 ?List, ?Elem</var>)</a></dt>
345386 <dd class="defbody">
346387 Is true when <var>Elem</var> is the <var>Index</var>'th element of <var>List</var>.
354395 </dl>
355396
356397 </dd>
357 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="nth0/4"><strong>nth0</strong>(<var>?N,
398 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="nth0/4"><strong>nth0</strong>(<var>?N,
358399 ?List, ?Elem, ?Rest</var>)</a></dt>
359400 <dd class="defbody">
360401 Select/insert element at index. True when <var>Elem</var> is the <var>N</var>'th
377418 </pre>
378419
379420 </dd>
380 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="nth1/4"><strong>nth1</strong>(<var>?N,
421 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="nth1/4"><strong>nth1</strong>(<var>?N,
381422 ?List, ?Elem, ?Rest</var>)</a></dt>
382423 <dd class="defbody">
383424 As <a class="pred" href="lists.html#nth0/4">nth0/4</a>, but counting
384425 starts at 1.</dd>
385 <dt class="pubdef"><a name="last/2"><strong>last</strong>(<var>?List,
426 <dt class="pubdef"><a id="last/2"><strong>last</strong>(<var>?List,
386427 ?Last</var>)</a></dt>
387428 <dd class="defbody">
388429 Succeeds when <var>Last</var> is the last element of <var>List</var>.
400441 </dl>
401442
402443 </dd>
403 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="proper_length/2"><strong>proper_length</strong>(<var>@List,
444 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="proper_length/2"><strong>proper_length</strong>(<var>@List,
404445 -Length</var>)</a></dt>
405446 <dd class="defbody">
406447 True when <var>Length</var> is the number of elements in the proper list
413454 </pre>
414455
415456 </dd>
416 <dt class="pubdef"><a name="same_length/2"><strong>same_length</strong>(<var>?List1,
457 <dt class="pubdef"><a id="same_length/2"><strong>same_length</strong>(<var>?List1,
417458 ?List2</var>)</a></dt>
418459 <dd class="defbody">
419460 Is true when <var>List1</var> and <var>List2</var> are lists with the
429470 </dl>
430471
431472 </dd>
432 <dt class="pubdef"><a name="reverse/2"><strong>reverse</strong>(<var>?List1,
473 <dt class="pubdef"><a id="reverse/2"><strong>reverse</strong>(<var>?List1,
433474 ?List2</var>)</a></dt>
434475 <dd class="defbody">
435476 Is true when the elements of <var>List2</var> are in reverse order
436477 compared to
437478 <var>List1</var>.</dd>
438 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="permutation/2"><strong>permutation</strong>(<var>?Xs,
479 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="permutation/2"><strong>permutation</strong>(<var>?Xs,
439480 ?Ys</var>)</a></dt>
440481 <dd class="defbody">
441482 True when <var>Xs</var> is a permutation of <var>Ys</var>. This can
480521 </dl>
481522
482523 </dd>
483 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="flatten/2"><strong>flatten</strong>(<var>+NestedList,
524 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="flatten/2"><strong>flatten</strong>(<var>+NestedList,
484525 -FlatList</var>)</a></dt>
485526 <dd class="defbody">
486527 Is true if <var>FlatList</var> is a non-nested version of <var>NestedList</var>.
502543 </dl>
503544
504545 </dd>
505 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="max_member/2"><strong>max_member</strong>(<var>-Max,
546 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="max_member/2"><strong>max_member</strong>(<var>-Max,
506547 +List</var>)</a></dt>
507548 <dd class="defbody">
508549 True when <var>Max</var> is the largest member in the standard order of
518559 </dl>
519560
520561 </dd>
521 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="min_member/2"><strong>min_member</strong>(<var>-Min,
562 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="min_member/2"><strong>min_member</strong>(<var>-Min,
522563 +List</var>)</a></dt>
523564 <dd class="defbody">
524565 True when <var>Min</var> is the smallest member in the standard order of
534575 </dl>
535576
536577 </dd>
537 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="sum_list/2"><strong>sum_list</strong>(<var>+List,
578 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="sum_list/2"><strong>sum_list</strong>(<var>+List,
538579 -Sum</var>)</a></dt>
539580 <dd class="defbody">
540581 <var>Sum</var> is the result of adding all numbers in <var>List</var>.</dd>
541 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="max_list/2"><strong>max_list</strong>(<var>+List:list(number),
582 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="max_list/2"><strong>max_list</strong>(<var>+List:list(number),
542583 -Max:number</var>)</a></dt>
543584 <dd class="defbody">
544585 True if <var>Max</var> is the largest number in <var>List</var>. Fails
552593 </dl>
553594
554595 </dd>
555 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="min_list/2"><strong>min_list</strong>(<var>+List:list(number),
596 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="min_list/2"><strong>min_list</strong>(<var>+List:list(number),
556597 -Min:number</var>)</a></dt>
557598 <dd class="defbody">
558599 True if <var>Min</var> is the smallest number in <var>List</var>. Fails
566607 </dl>
567608
568609 </dd>
569 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="numlist/3"><strong>numlist</strong>(<var>+Low,
610 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="numlist/3"><strong>numlist</strong>(<var>+Low,
570611 +High, -List</var>)</a></dt>
571612 <dd class="defbody">
572613 <var>List</var> is a list [<var>Low</var>, <var>Low</var>+1, ... <var>High</var>].
581622 </dl>
582623
583624 </dd>
584 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_set/1"><strong>is_set</strong>(<var>@Set</var>)</a></dt>
625 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_set/1"><strong>is_set</strong>(<var>@Set</var>)</a></dt>
585626 <dd class="defbody">
586627 True if <var>Set</var> is a proper list without duplicates. Equivalence
587628 is based on <a class="pred" href="compare.html#==/2">==/2</a>. The
589630 which implies that the complexity is N*<code>log(N)</code> and the
590631 predicate may cause a resource-error. There are no other error
591632 conditions.</dd>
592 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_to_set/2"><strong>list_to_set</strong>(<var>+List,
633 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_to_set/2"><strong>list_to_set</strong>(<var>+List,
593634 ?Set</var>)</a></dt>
594635 <dd class="defbody">
595636 True when <var>Set</var> has the same elements as <var>List</var> in the
619660 </dl>
620661
621662 </dd>
622 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="intersection/3"><strong>intersection</strong>(<var>+Set1,
663 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="intersection/3"><strong>intersection</strong>(<var>+Set1,
623664 +Set2, -Set3</var>)</a></dt>
624665 <dd class="defbody">
625666 True if <var>Set3</var> unifies with the intersection of <var>Set1</var>
635676 </dl>
636677
637678 </dd>
638 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="union/3"><strong>union</strong>(<var>+Set1,
679 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="union/3"><strong>union</strong>(<var>+Set1,
639680 +Set2, -Set3</var>)</a></dt>
640681 <dd class="defbody">
641682 True if <var>Set3</var> unifies with the union of the lists <var>Set1</var>
651692 </dl>
652693
653694 </dd>
654 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="subset/2"><strong>subset</strong>(<var>+SubSet,
695 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="subset/2"><strong>subset</strong>(<var>+SubSet,
655696 +Set</var>)</a></dt>
656697 <dd class="defbody">
657698 True if all elements of <var>SubSet</var> belong to <var>Set</var> as
669710 </dl>
670711
671712 </dd>
672 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="subtract/3"><strong>subtract</strong>(<var>+Set,
713 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="subtract/3"><strong>subtract</strong>(<var>+Set,
673714 +Delete, -Result</var>)</a></dt>
674715 <dd class="defbody">
675716 <var>Delete</var> all elements in <var>Delete</var> from <var>Set</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="intlibs.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="dialect.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:loadfilehook"><a name="sec:B.8"><span class="sec-nr">B.8</span> <span class="sec-title">Hooks
235 <h2 id="sec:loadfilehook"><a id="sec:B.8"><span class="sec-nr">B.8</span> <span class="sec-title">Hooks
195236 for loading files</span></a></h2>
196237
197 <a name="sec:loadfilehook"></a>
198
199 <p>All loading of source files is achieved by <a name="idx:loadfiles2:2236"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
238 <a id="sec:loadfilehook"></a>
239
240 <p>All loading of source files is achieved by <a id="idx:loadfiles2:2240"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
200241 The hook
201 <a name="idx:prologloadfile2:2237"></a><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a>
242 <a id="idx:prologloadfile2:2241"></a><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a>
202243 can be used to load Prolog code from non-files or even load entirely
203244 different information, such as foreign files.
204245
205246 <dl class="latex">
206 <dt class="pubdef"><a name="prolog_load_file/2"><strong>prolog_load_file</strong>(<var>+Spec,
247 <dt class="pubdef"><a id="prolog_load_file/2"><strong>prolog_load_file</strong>(<var>+Spec,
207248 +Options</var>)</a></dt>
208249 <dd class="defbody">
209 Load a single object. If this call succeeds, <a name="idx:loadfiles2:2238"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
250 Load a single object. If this call succeeds, <a id="idx:loadfiles2:2242"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
210251 assumes the action has been taken care of. This hook is only called if <var>Options</var>
211252 does not contain the <code>stream(Input)</code> option. The hook must be
212253 defined in the module <code>user</code>.
216257 server. It can also be used to load source in unusual forms, such as
217258 loading compressed files without decompressing them first. There is
218259 currently no example of that.</dd>
219 <dt class="pubdef"><a name="prolog:comment_hook/3"><strong>prolog:comment_hook</strong>(<var>+Comments,
260 <dt class="pubdef"><a id="prolog:comment_hook/3"><strong>prolog:comment_hook</strong>(<var>+Comments,
220261 +Pos, +Term</var>)</a></dt>
221262 <dd class="defbody">
222263 This hook allows for processing comments encountered by the compiler. If
223 this hook is defined, the compiler calls <a name="idx:readterm2:2239"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
264 this hook is defined, the compiler calls <a id="idx:readterm2:2243"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
224265 with the option
225266 <code>comments(Comments)</code>. If the list of comments returned by
226 <a name="idx:readterm2:2240"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
267 <a id="idx:readterm2:2244"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
227268 is not empty it calls this comment hook with the following arguments.
228269
229270 <p>
230271 <ul class="latex">
231272 <li><var>Comments</var> is the non-empty list of comments. Each comment
232273 is a pair <var>Position</var>-<var>String</var>, where
233 <var>String</var> is a string object (see <a class="sec" href="strings.html">section
274 <var>String</var> is a string object (see <a class="sec" href="strings.html#sec:5.2">section
234275 5.2</a>) that contains the comment <em>including</em> delimiters.
235276 Consecutive line comments are returned as a single comment.
236277 <li><var>Pos</var> is a stream-position term that describes the starting
239280 </ul>
240281
241282 <p>This hook is exploited by the documentation system. See
242 <a name="idx:streampositiondata3:2241"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.
243 See also <a name="idx:readterm3:2242"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
283 <a id="idx:streampositiondata3:2245"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.
284 See also <a id="idx:readterm3:2246"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
244285 </dd>
245286 </dl>
246287
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.23</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.23</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="manipatom.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="chartype.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:locale"><a name="sec:4.23"><span class="sec-nr">4.23</span> <span class="sec-title">Localization
235 <h2 id="sec:locale"><a id="sec:4.23"><span class="sec-nr">4.23</span> <span class="sec-title">Localization
195236 (locale) support</span></a></h2>
196237
197 <a name="sec:locale"></a>
238 <a id="sec:locale"></a>
198239
199240 <p>SWI-Prolog provides (currently limited) support for localized
200241 applications.
201242
202243 <p>
203244 <ul class="latex">
204 <li>The predicates <a name="idx:chartype2:1280"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
205 and <a name="idx:codetype2:1281"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>
245 <li>The predicates <a id="idx:chartype2:1280"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
246 and <a id="idx:codetype2:1281"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>
206247 query character classes depending on the locale.
207 <li>The predicates <a name="idx:collationkey2:1282"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
208 and <a name="idx:localesort2:1283"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
248 <li>The predicates <a id="idx:collationkey2:1282"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
249 and <a id="idx:localesort2:1283"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
209250 can be used for locale dependent sorting of atoms.
210 <li>The predicate <a name="idx:formattime3:1284"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>
251 <li>The predicate <a id="idx:formattime3:1284"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>
211252 can be used to format time and date representations, where some of the
212253 specifiers are locale dependent.
213 <li>The predicate <a name="idx:format2:1285"></a><a class="pred" href="format.html#format/2">format/2</a>
254 <li>The predicate <a id="idx:format2:1285"></a><a class="pred" href="format.html#format/2">format/2</a>
214255 provides locale-specific formating of numbers. This functionality is
215256 based on a more fine-grained localization model that is the subject of
216257 this section.
218259
219260 <p>A locale is a (optionally named) read-only object that provides
220261 information to locale specific functions.<sup class="fn">105<span class="fn-text">The
221 locale interface described in this section and its effect on <a name="idx:format2:1286"></a><a class="pred" href="format.html#format/2">format/2</a>
262 locale interface described in this section and its effect on <a id="idx:format2:1286"></a><a class="pred" href="format.html#format/2">format/2</a>
222263 and reading integers from digit groups was discussed on the SWI-Prolog
223264 mailinglist. Most input in this discussion is from Ulrich Neumerkel and
224265 Richard O'Keefe. The predicates in this section were designed by Jan
226267 named
227268 <code>default</code> from the system locale. This locale is used as the
228269 initial locale for the three standard streams as well as the
229 <code>main</code> thread. Locale sensitive output predicates such as <a name="idx:format3:1287"></a><a class="pred" href="format.html#format/3">format/3</a>
270 <code>main</code> thread. Locale sensitive output predicates such as <a id="idx:format3:1287"></a><a class="pred" href="format.html#format/3">format/3</a>
230271 get their locale from the stream to which they deliver their output. New
231272 streams get their locale from the thread that created the stream.
232273 Threads get their locale from the thread that created them.
233274
234275 <dl class="latex">
235 <dt class="pubdef"><a name="locale_create/3"><strong>locale_create</strong>(<var>-Locale,
276 <dt class="pubdef"><a id="locale_create/3"><strong>locale_create</strong>(<var>-Locale,
236277 +Default, +Options</var>)</a></dt>
237278 <dd class="defbody">
238279 Create a new locale object. <var>Default</var> is either an existing
273314 [ decimal_point('.'), thousands_sep(','), grouping([repeat(3)]) ]
274315 </pre>
275316
276 <p>Named locales exists until they are destroyed using <a name="idx:localedestroy1:1288"></a><a class="pred" href="locale.html#locale_destroy/1">locale_destroy/1</a>
317 <p>Named locales exists until they are destroyed using <a id="idx:localedestroy1:1288"></a><a class="pred" href="locale.html#locale_destroy/1">locale_destroy/1</a>
277318 and they are no longer referenced. Unnamed locales are subject to (atom)
278319 garbage collection.</dd>
279 <dt class="pubdef"><a name="locale_destroy/1"><strong>locale_destroy</strong>(<var>+Locale</var>)</a></dt>
320 <dt class="pubdef"><a id="locale_destroy/1"><strong>locale_destroy</strong>(<var>+Locale</var>)</a></dt>
280321 <dd class="defbody">
281322 Destroy a locale. If the locale is named, this removes the name
282323 association from the locale, after which the locale is left to be
283324 reclaimed by garbage collection.</dd>
284 <dt class="pubdef"><a name="locale_property/2"><strong>locale_property</strong>(<var>?Locale,
325 <dt class="pubdef"><a id="locale_property/2"><strong>locale_property</strong>(<var>?Locale,
285326 ?Property</var>)</a></dt>
286327 <dd class="defbody">
287328 True when <var>Locale</var> has <var>Property</var>. Properties are the
288 same as the <var>Options</var> described with <a name="idx:localecreate3:1289"></a><a class="pred" href="locale.html#locale_create/3">locale_create/3</a>.</dd>
289 <dt class="pubdef"><a name="set_locale/1"><strong>set_locale</strong>(<var>+Locale</var>)</a></dt>
329 same as the <var>Options</var> described with <a id="idx:localecreate3:1289"></a><a class="pred" href="locale.html#locale_create/3">locale_create/3</a>.</dd>
330 <dt class="pubdef"><a id="set_locale/1"><strong>set_locale</strong>(<var>+Locale</var>)</a></dt>
290331 <dd class="defbody">
291332 Set the default locale for the current thread, as well as the locale for
292333 the standard streams (<code>user_input</code>, <code>user_output</code>,
293334 <code>user_error</code>, <code>current_output</code> and <code>current_input</code>.
294335 This locale is used for new streams, unless overruled using the
295 <code>locale(Locale)</code> option of <a name="idx:open4:1290"></a><a class="pred" href="IO.html#open/4">open/4</a>
296 or <a name="idx:setstream2:1291"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
297 <dt class="pubdef"><a name="current_locale/1"><strong>current_locale</strong>(<var>-Locale</var>)</a></dt>
336 <code>locale(Locale)</code> option of <a id="idx:open4:1290"></a><a class="pred" href="IO.html#open/4">open/4</a>
337 or <a id="idx:setstream2:1291"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
338 <dt class="pubdef"><a id="current_locale/1"><strong>current_locale</strong>(<var>-Locale</var>)</a></dt>
298339 <dd class="defbody">
299340 True when <var>Locale</var> is the locale of the calling thread.
300341 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.16</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.16</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="lists.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="nb_set.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:main"><a name="sec:A.16"><span class="sec-nr">A.16</span> <span class="sec-title">library(main):
235 <h2 id="sec:main"><a id="sec:A.16"><span class="sec-nr">A.16</span> <span class="sec-title">library(main):
195236 Provide entry point for scripts</span></a></h2>
196237
197 <p><a name="sec:main"></a>
238 <p><a id="sec:main"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">See also</dt>
229270 </pre>
230271
231272 <dl class="latex">
232 <dt class="pubdef"><a name="main/0"><strong>main</strong></a></dt>
273 <dt class="pubdef"><a id="main/0"><strong>main</strong></a></dt>
233274 <dd class="defbody">
234275 Call <span class="pred-ext">main/1</span> using the passed command-line
235276 arguments. Before calling
236277 <span class="pred-ext">main/1</span> this predicate installs a signal
237278 handler for <code>SIGINT</code> (Control-C) that terminates the process
238279 with status 1.</dd>
239 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="argv_options/3"><strong>argv_options</strong>(<var>+Argv,
280 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="argv_options/3"><strong>argv_options</strong>(<var>+Argv,
240281 -RestArgv, -Options</var>)</a></dt>
241282 <dd class="defbody">
242283 Generic transformation of long commandline arguments to options. Each
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.22</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.22</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="manipterm.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="locale.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:manipatom"><a name="sec:4.22"><span class="sec-nr">4.22</span> <span class="sec-title">Analysing
235 <h2 id="sec:manipatom"><a id="sec:4.22"><span class="sec-nr">4.22</span> <span class="sec-title">Analysing
195236 and Constructing Atoms</span></a></h2>
196237
197 <a name="sec:manipatom"></a>
238 <a id="sec:manipatom"></a>
198239
199240 <p>These predicates convert between Prolog constants and lists of
200 character codes. The predicates <a name="idx:atomcodes2:1240"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>, <a name="idx:numbercodes2:1241"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
201 and <a name="idx:name2:1242"></a><a class="pred" href="manipatom.html#name/2">name/2</a>
241 character codes. The predicates <a id="idx:atomcodes2:1240"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>, <a id="idx:numbercodes2:1241"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
242 and <a id="idx:name2:1242"></a><a class="pred" href="manipatom.html#name/2">name/2</a>
202243 behave the same when converting from a constant to a list of character
203 codes. When converting the other way around, <a name="idx:atomcodes2:1243"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
204 will generate an atom, <a name="idx:numbercodes2:1244"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
205 will generate a number or exception and <a name="idx:name2:1245"></a><a class="pred" href="manipatom.html#name/2">name/2</a>
244 codes. When converting the other way around, <a id="idx:atomcodes2:1243"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
245 will generate an atom, <a id="idx:numbercodes2:1244"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
246 will generate a number or exception and <a id="idx:name2:1245"></a><a class="pred" href="manipatom.html#name/2">name/2</a>
206247 will return a number if possible and an atom otherwise.
207248
208 <p>The ISO standard defines <a name="idx:atomchars2:1246"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
249 <p>The ISO standard defines <a id="idx:atomchars2:1246"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
209250 to describe the `broken-up' atom as a list of one-character atoms
210 instead of a list of codes. Up to version 3.2.x, SWI-Prolog's <a name="idx:atomchars2:1247"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
251 instead of a list of codes. Up to version 3.2.x, SWI-Prolog's <a id="idx:atomchars2:1247"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
211252 behaved like atom_codes, compatible with Quintus and SICStus Prolog. As
212253 of 3.3.x, SWI-Prolog
213 <a name="idx:atomcodes2:1248"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
214 and <a name="idx:atomchars2:1249"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
254 <a id="idx:atomcodes2:1248"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
255 and <a id="idx:atomchars2:1249"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
215256 are compliant to the ISO standard.
216257
217258 <p>To ease the pain of all variations in the Prolog community, all
220261 `atom-side' accepts all atomic types (atom, number and string).
221262
222263 <dl class="latex">
223 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom_codes/2"><strong>atom_codes</strong>(<var>?Atom,
264 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom_codes/2"><strong>atom_codes</strong>(<var>?Atom,
224265 ?String</var>)</a></dt>
225266 <dd class="defbody">
226267 Convert between an atom and a list of character codes. If
228269 character codes and the result is unified with <var>String</var>. If <var>Atom</var>
229270 is unbound and <var>String</var> is a list of character codes,
230271 <var>Atom</var> will be unified with an atom constructed from this list.</dd>
231 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom_chars/2"><strong>atom_chars</strong>(<var>?Atom,
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom_chars/2"><strong>atom_chars</strong>(<var>?Atom,
232273 ?CharList</var>)</a></dt>
233274 <dd class="defbody">
234 As <a name="idx:atomcodes2:1250"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>,
275 As <a id="idx:atomcodes2:1250"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>,
235276 but <var>CharList</var> is a list of one-character atoms rather than a
236277 list of character codes.<sup class="fn">100<span class="fn-text">Up to
237 version 3.2.x, <a name="idx:atomchars2:1251"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
238 behaved as the current <a name="idx:atomcodes2:1252"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.
278 version 3.2.x, <a id="idx:atomchars2:1251"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
279 behaved as the current <a id="idx:atomcodes2:1252"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.
239280 The current definition is compliant with the ISO standard.</span></sup>
240281
241282 <pre class="code">
245286 </pre>
246287
247288 </dd>
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="char_code/2"><strong>char_code</strong>(<var>?Atom,
289 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="char_code/2"><strong>char_code</strong>(<var>?Atom,
249290 ?Code</var>)</a></dt>
250291 <dd class="defbody">
251292 Convert between character and character code for a single character.<sup class="fn">101<span class="fn-text">This
252293 is also called atom_char/2 in older versions of SWI-Prolog as well as
253294 some other Prolog implementations. The atom_char/2 predicate is
254295 available from the library <code>backcomp.pl</code></span></sup></dd>
255 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="number_chars/2"><strong>number_chars</strong>(<var>?Number,
296 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="number_chars/2"><strong>number_chars</strong>(<var>?Number,
256297 ?CharList</var>)</a></dt>
257298 <dd class="defbody">
258 Similar to <a name="idx:atomchars2:1253"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>,
299 Similar to <a id="idx:atomchars2:1253"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>,
259300 but converts between a number and its representation as a list of
260301 one-character atoms. If <var>CharList</var> is a
261302 <em>proper list</em>, i.e., not unbound or a <em>partial list</em>,
273314 implementations--believe this is incorrect. We also beleive it would
274315 have been better not to allow for white space, or to allow for both
275316 leading and trailing white space. Prolog syntax-based conversion can
276 also be achieved using <a name="idx:format3:1254"></a><a class="pred" href="format.html#format/3">format/3</a>
277 and <a name="idx:readfromchars2:1255"></a><a class="pred" href="charsio.html#read_from_chars/2">read_from_chars/2</a>.</span></sup>
317 also be achieved using <a id="idx:format3:1254"></a><a class="pred" href="format.html#format/3">format/3</a>
318 and <a id="idx:readfromchars2:1255"></a><a class="pred" href="charsio.html#read_from_chars/2">read_from_chars/2</a>.</span></sup>
278319 A <code>syntax_error</code> exception is raised if <var>CharList</var>
279320 does not represent a valid Prolog number.</dd>
280 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="number_codes/2"><strong>number_codes</strong>(<var>?Number,
321 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="number_codes/2"><strong>number_codes</strong>(<var>?Number,
281322 ?CodeList</var>)</a></dt>
282323 <dd class="defbody">
283 As <a name="idx:numberchars2:1256"></a><a class="pred" href="manipatom.html#number_chars/2">number_chars/2</a>,
324 As <a id="idx:numberchars2:1256"></a><a class="pred" href="manipatom.html#number_chars/2">number_chars/2</a>,
284325 but converts to a list of character codes rather than one-character
285326 atoms. In the mode (-,+), both predicates behave identically to improve
286327 handling of non-ISO source.</dd>
287 <dt class="pubdef"><a name="atom_number/2"><strong>atom_number</strong>(<var>?Atom,
328 <dt class="pubdef"><a id="atom_number/2"><strong>atom_number</strong>(<var>?Atom,
288329 ?Number</var>)</a></dt>
289330 <dd class="defbody">
290 Realises the popular combination of <a name="idx:atomcodes2:1257"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
291 and <a name="idx:numbercodes2:1258"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
331 Realises the popular combination of <a id="idx:atomcodes2:1257"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
332 and <a id="idx:numbercodes2:1258"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
292333 to convert between atom and number (integer or float) in one predicate,
293 avoiding the intermediate list. Unlike the ISO <a name="idx:numbercodes2:1259"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
294 predicates, <a name="idx:atomnumber2:1260"></a><a class="pred" href="manipatom.html#atom_number/2">atom_number/2</a>
334 avoiding the intermediate list. Unlike the ISO <a id="idx:numbercodes2:1259"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
335 predicates, <a id="idx:atomnumber2:1260"></a><a class="pred" href="manipatom.html#atom_number/2">atom_number/2</a>
295336 fails silently in mode (+,-) if <var>Atom</var> does not represent a
296337 number.<sup class="fn">103<span class="fn-text">Versions prior to 6.1.7
297 raised a syntax error, compliant to <a name="idx:numbercodes2:1261"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a></span></sup>
298 See also <a name="idx:atomiclistconcat2:1262"></a><a class="pred" href="manipatom.html#atomic_list_concat/2">atomic_list_concat/2</a>
338 raised a syntax error, compliant to <a id="idx:numbercodes2:1261"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a></span></sup>
339 See also <a id="idx:atomiclistconcat2:1262"></a><a class="pred" href="manipatom.html#atomic_list_concat/2">atomic_list_concat/2</a>
299340 for assembling an atom from atoms and numbers.</dd>
300 <dt class="pubdef"><a name="name/2"><strong>name</strong>(<var>?Atomic,
341 <dt class="pubdef"><a id="name/2"><strong>name</strong>(<var>?Atomic,
301342 ?CodeList</var>)</a></dt>
302343 <dd class="defbody">
303344 <var>CodeList</var> is a list of character codes representing the same
317358 considered <em>deprecated</em> although, given its long tradition, it is
318359 unlikely to be removed from the system. It still has some value for
319360 converting input to, depending on the syntax, a number or atom. New code
320 should consider the ISO predicates <a name="idx:atomcodes2:1263"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>, <a name="idx:numbercodes2:1264"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
321 or the SWI-Prolog predicate <a name="idx:atomnumber2:1265"></a><a class="pred" href="manipatom.html#atom_number/2">atom_number/2</a>.</dd>
322 <dt class="pubdef"><a name="term_to_atom/2"><strong>term_to_atom</strong>(<var>?Term,
361 should consider the ISO predicates <a id="idx:atomcodes2:1263"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>, <a id="idx:numbercodes2:1264"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
362 or the SWI-Prolog predicate <a id="idx:atomnumber2:1265"></a><a class="pred" href="manipatom.html#atom_number/2">atom_number/2</a>.</dd>
363 <dt class="pubdef"><a id="term_to_atom/2"><strong>term_to_atom</strong>(<var>?Term,
323364 ?Atom</var>)</a></dt>
324365 <dd class="defbody">
325366 True if <var>Atom</var> describes a term that unifies with <var>Term</var>.
328369 result unified with <var>Term</var>. If <var>Atom</var> has no valid
329370 syntax, a
330371 <code>syntax_error</code> exception is raised. Otherwise <var>Term</var>
331 is ``written'' on <var>Atom</var> using <a name="idx:writeterm2:1266"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
372 is ``written'' on <var>Atom</var> using <a id="idx:writeterm2:1266"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
332373 with the option
333 <code>quoted(true)</code>. See also <a name="idx:format3:1267"></a><a class="pred" href="format.html#format/3">format/3</a>, <a name="idx:withoutputto2:1268"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
374 <code>quoted(true)</code>. See also <a id="idx:format3:1267"></a><a class="pred" href="format.html#format/3">format/3</a>, <a id="idx:withoutputto2:1268"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
334375 and
335 <a name="idx:termstring2:1269"></a><a class="pred" href="strings.html#term_string/2">term_string/2</a>.</dd>
336 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="atom_to_term/3"><strong>atom_to_term</strong>(<var>+Atom,
376 <a id="idx:termstring2:1269"></a><a class="pred" href="strings.html#term_string/2">term_string/2</a>.</dd>
377 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="atom_to_term/3"><strong>atom_to_term</strong>(<var>+Atom,
337378 -Term, -Bindings</var>)</a></dt>
338379 <dd class="defbody">
339 Use <var>Atom</var> as input to <a name="idx:readterm2:1270"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
380 Use <var>Atom</var> as input to <a id="idx:readterm2:1270"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
340381 using the option
341382 <code>variable_names</code> and return the read term in <var>Term</var>
342383 and the variable bindings in <var>Bindings</var>. <var>Bindings</var> is
343384 a list of
344385 <var><var>Name</var> = <var>Var</var></var> couples, thus providing
345 access to the actual variable names. See also <a name="idx:readterm2:1271"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
386 access to the actual variable names. See also <a id="idx:readterm2:1271"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
346387 If <var>Atom</var> has no valid syntax, a <code>syntax_error</code>
347388 exception is raised. New code should use
348 <a name="idx:readtermfromatom3:1272"></a><a class="pred" href="termrw.html#read_term_from_atom/3">read_term_from_atom/3</a>.</dd>
349 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom_concat/3"><strong>atom_concat</strong>(<var>?Atom1,
389 <a id="idx:readtermfromatom3:1272"></a><a class="pred" href="termrw.html#read_term_from_atom/3">read_term_from_atom/3</a>.</dd>
390 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom_concat/3"><strong>atom_concat</strong>(<var>?Atom1,
350391 ?Atom2, ?Atom3</var>)</a></dt>
351392 <dd class="defbody">
352393 <var>Atom3</var> forms the concatenation of <var>Atom1</var> and <var>Atom2</var>.
353394 At least two of the arguments must be instantiated to atoms. This
354395 predicate also allows for the mode (-,-,+), non-deterministically
355 splitting the 3rd argument into two parts (as <a name="idx:append3:1273"></a><a class="pred" href="lists.html#append/3">append/3</a>
396 splitting the 3rd argument into two parts (as <a id="idx:append3:1273"></a><a class="pred" href="lists.html#append/3">append/3</a>
356397 does for lists). SWI-Prolog allows for atomic arguments. Portable code
357 must use <a name="idx:atomicconcat3:1274"></a><a class="pred" href="manipatom.html#atomic_concat/3">atomic_concat/3</a>
398 must use <a id="idx:atomicconcat3:1274"></a><a class="pred" href="manipatom.html#atomic_concat/3">atomic_concat/3</a>
358399 if non-atom arguments are involved.</dd>
359 <dt class="pubdef"><a name="atomic_concat/3"><strong>atomic_concat</strong>(<var>+Atomic1,
400 <dt class="pubdef"><a id="atomic_concat/3"><strong>atomic_concat</strong>(<var>+Atomic1,
360401 +Atomic2, -Atom</var>)</a></dt>
361402 <dd class="defbody">
362403 <var>Atom</var> represents the text after converting <var>Atomic1</var>
369410 </pre>
370411
371412 </dd>
372 <dt class="pubdef"><span class="pred-tag">[commons]</span><a name="atomic_list_concat/2"><strong>atomic_list_concat</strong>(<var>+List,
413 <dt class="pubdef"><span class="pred-tag">[commons]</span><a id="atomic_list_concat/2"><strong>atomic_list_concat</strong>(<var>+List,
373414 -Atom</var>)</a></dt>
374415 <dd class="defbody">
375416 <var>List</var> is a list of strings, atoms, integers or floating point
376417 numbers. Succeeds if <var>Atom</var> can be unified with the
377418 concatenated elements of <var>List</var>. Equivalent to <code>atomic_list_concat(List,
378419 '', Atom)</code>.</dd>
379 <dt class="pubdef"><span class="pred-tag">[commons]</span><a name="atomic_list_concat/3"><strong>atomic_list_concat</strong>(<var>+List,
420 <dt class="pubdef"><span class="pred-tag">[commons]</span><a id="atomic_list_concat/3"><strong>atomic_list_concat</strong>(<var>+List,
380421 +Separator, -Atom</var>)</a></dt>
381422 <dd class="defbody">
382 Creates an atom just like <a name="idx:atomiclistconcat2:1275"></a><a class="pred" href="manipatom.html#atomic_list_concat/2">atomic_list_concat/2</a>,
423 Creates an atom just like <a id="idx:atomiclistconcat2:1275"></a><a class="pred" href="manipatom.html#atomic_list_concat/2">atomic_list_concat/2</a>,
383424 but inserts <var>Separator</var> between each pair of inputs. For
384425 example:
385426
392433 <p>The SWI-Prolog version of this predicate can also be used to split
393434 atoms by instantiating <var>Separator</var> and <var>Atom</var> as shown
394435 below. We kept this functionality to simplify porting old SWI-Prolog
395 code where this predicate was called <a name="idx:concatatom3:1276"></a><span class="pred-ext">concat_atom/3</span>.
436 code where this predicate was called <a id="idx:concatatom3:1276"></a><span class="pred-ext">concat_atom/3</span>.
396437 When used in mode (-,+,+),
397 <var>Separator</var> must be a non-empty atom. See also <a name="idx:splitstring4:1277"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>.
438 <var>Separator</var> must be a non-empty atom. See also <a id="idx:splitstring4:1277"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>.
398439
399440 <pre class="code">
400441 ?- atomic_list_concat(L, -, 'gnu-gnat').
403444 </pre>
404445
405446 </dd>
406 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom_length/2"><strong>atom_length</strong>(<var>+Atom,
447 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom_length/2"><strong>atom_length</strong>(<var>+Atom,
407448 -Length</var>)</a></dt>
408449 <dd class="defbody">
409450 True if <var>Atom</var> is an atom of <var>Length</var> characters. The
410451 SWI-Prolog version accepts all atomic types, as well as code-lists and
411452 character-lists. New code should avoid this feature and use
412 <a name="idx:writelength3:1278"></a><a class="pred" href="termrw.html#write_length/3">write_length/3</a>
453 <a id="idx:writelength3:1278"></a><a class="pred" href="termrw.html#write_length/3">write_length/3</a>
413454 to get the number of characters that would be written if the argument
414 was handed to <a name="idx:writeterm3:1279"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.</dd>
415 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="atom_prefix/2"><strong>atom_prefix</strong>(<var>+Atom,
455 was handed to <a id="idx:writeterm3:1279"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.</dd>
456 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="atom_prefix/2"><strong>atom_prefix</strong>(<var>+Atom,
416457 +Prefix</var>)</a></dt>
417458 <dd class="defbody">
418459 True if <var>Atom</var> starts with the characters from <var>Prefix</var>.
419460 Its behaviour is equivalent to
420461 <code>?- sub_atom(<var>Atom</var>, 0, _, _, <var>Prefix</var>)</code>.
421462 Deprecated.</dd>
422 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="sub_atom/5"><strong>sub_atom</strong>(<var>+Atom,
463 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="sub_atom/5"><strong>sub_atom</strong>(<var>+Atom,
423464 ?Before, ?Len, ?After, ?Sub</var>)</a></dt>
424465 <dd class="defbody">
425466 ISO predicate for breaking atoms. It maintains the following relation:
437478 <p>The implementation minimises non-determinism and creation of atoms.
438479 This is a flexible predicate that can do search, prefix- and
439480 suffix-matching, etc.</dd>
440 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="sub_atom_icasechk/3"><strong>sub_atom_icasechk</strong>(<var>+Haystack,
481 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="sub_atom_icasechk/3"><strong>sub_atom_icasechk</strong>(<var>+Haystack,
441482 ?Start, +Needle</var>)</a></dt>
442483 <dd class="defbody">
443484 True when <var>Needle</var> is a sub atom of <var>Haystack</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.14</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ctxmodule.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="modulecompat.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:manipmodule"><a name="sec:6.14"><span class="sec-nr">6.14</span> <span class="sec-title">Module
235 <h2 id="sec:manipmodule"><a id="sec:6.14"><span class="sec-nr">6.14</span> <span class="sec-title">Module
195236 properties</span></a></h2>
196237
197 <a name="sec:manipmodule"></a>
238 <a id="sec:manipmodule"></a>
198239
199240 <p>The following predicates can be used to query the module system for
200241 reflexive programming:
201242
202243 <dl class="latex">
203 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_module/1"><strong>current_module</strong>(<var>?Module</var>)</a></dt>
244 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_module/1"><strong>current_module</strong>(<var>?Module</var>)</a></dt>
204245 <dd class="defbody">
205246 True if <var>Module</var> is a currently defined module. This predicate
206247 enumerates all modules, whether loaded from a file or created
207248 dynamically. Note that modules cannot be destroyed in the current
208249 version of SWI-Prolog.</dd>
209 <dt class="pubdef"><a name="module_property/2"><strong>module_property</strong>(<var>?Module,
250 <dt class="pubdef"><a id="module_property/2"><strong>module_property</strong>(<var>?Module,
210251 ?Property</var>)</a></dt>
211252 <dd class="defbody">
212253 True if <var>Property</var> is a property of <var>Module</var>. Defined
260301 indicators are in canonical form (i.e., always using name/arity and
261302 never the DCG form name//arity). Future versions may also use the DCG
262303 form and include public operators. See also
263 <a name="idx:predicateproperty2:1746"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
304 <a id="idx:predicateproperty2:1750"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
264305 </dd>
265306 <dt><strong>exported_operators</strong>(<var>-ListOfOperators</var>)</dt>
266307 <dd class="defbody">
276317 <dt><strong>program_space</strong>(<var>-Bytes</var>)</dt>
277318 <dd class="defbody">
278319 If present, this number limits the <code>program_size</code>. See
279 <a name="idx:setmodule1:1747"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>.
320 <a id="idx:setmodule1:1751"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>.
280321 </dd>
281322 <dt><strong>last_modified_generation</strong>(<var>-Generation</var>)</dt>
282323 <dd class="defbody">
283324 Integer expression the last database generation where a clause was added
284 or removed from a predicate that is implemented in this module. See also <a name="idx:predicateproperty2:1748"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
325 or removed from a predicate that is implemented in this module. See also <a id="idx:predicateproperty2:1752"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
285326 </dd>
286327 </dl>
287328
288329 </dd>
289 <dt class="pubdef"><a name="set_module/1"><strong>set_module</strong>(<var>:Property</var>)</a></dt>
330 <dt class="pubdef"><a id="set_module/1"><strong>set_module</strong>(<var>:Property</var>)</a></dt>
290331 <dd class="defbody">
291332 Modify properties of the module. Currently, the following properties may
292333 be modified:
297338 Set the default import module of the current module to <var>Module</var>.
298339 Typically, <var>Module</var> is one of <code>user</code> or <code>system</code>.
299340 See
300 <a class="sec" href="importmodule.html">section 6.9</a>.
341 <a class="sec" href="importmodule.html#sec:6.9">section 6.9</a>.
301342 </dd>
302343 <dt><strong>class</strong>(<var>+Class</var>)</dt>
303344 <dd class="defbody">
304 Set the class of the module. See <a name="idx:moduleproperty2:1749"></a><a class="pred" href="manipmodule.html#module_property/2">module_property/2</a>.
345 Set the class of the module. See <a id="idx:moduleproperty2:1753"></a><a class="pred" href="manipmodule.html#module_property/2">module_property/2</a>.
305346 </dd>
306347 <dt><strong>program_space</strong>(<var>+Bytes</var>)</dt>
307348 <dd class="defbody">
309350 module. Raises a permission error if the current usage is above the
310351 requested limit. Setting the limit to 0 (zero) removes the limit. An
311352 attempt to assert clauses that causes the limit to be exceeded causes a
312 <code>resource_error(program_space)</code> exception. See <a name="idx:assertz1:1750"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
353 <code>resource_error(program_space)</code> exception. See <a id="idx:assertz1:1754"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
313354 and
314 <a name="idx:moduleproperty2:1751"></a><a class="pred" href="manipmodule.html#module_property/2">module_property/2</a>.
355 <a id="idx:moduleproperty2:1755"></a><a class="pred" href="manipmodule.html#module_property/2">module_property/2</a>.
315356 </dd>
316357 </dl>
317358
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="hack.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ancestral-cut.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:manipstack"><a name="sec:B.1"><span class="sec-nr">B.1</span> <span class="sec-title">Examining
235 <h2 id="sec:manipstack"><a id="sec:B.1"><span class="sec-nr">B.1</span> <span class="sec-title">Examining
195236 the Environment Stack</span></a></h2>
196237
197 <a name="sec:manipstack"></a>
238 <a id="sec:manipstack"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="prolog_current_frame/1"><strong>prolog_current_frame</strong>(<var>-Frame</var>)</a></dt>
241 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="prolog_current_frame/1"><strong>prolog_current_frame</strong>(<var>-Frame</var>)</a></dt>
201242 <dd class="defbody">
202243 Unify <var>Frame</var> with an integer providing a reference to the
203244 parent of the current local stack frame. A pointer to the current local
204245 frame cannot be provided as the predicate succeeds deterministically and
205246 therefore its frame is destroyed immediately after succeeding.</dd>
206 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="prolog_current_choice/1"><strong>prolog_current_choice</strong>(<var>-Choice</var>)</a></dt>
247 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="prolog_current_choice/1"><strong>prolog_current_choice</strong>(<var>-Choice</var>)</a></dt>
207248 <dd class="defbody">
208249 Unify <var>Choice</var> with an integer provided a reference to the last
209250 choice point. Fails if the current environment has no choice points. See
210 also <a name="idx:prologchoiceattribute3:2177"></a><a class="pred" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a>.</dd>
211 <dt class="pubdef"><a name="prolog_frame_attribute/3"><strong>prolog_frame_attribute</strong>(<var>+Frame,
251 also <a id="idx:prologchoiceattribute3:2181"></a><a class="pred" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a>.</dd>
252 <dt class="pubdef"><a id="prolog_frame_attribute/3"><strong>prolog_frame_attribute</strong>(<var>+Frame,
212253 +Key, :Value</var>)</a></dt>
213254 <dd class="defbody">
214255 Obtain information about the local stack frame <var>Frame</var>. <var>Frame</var>
215 is a frame reference as obtained through <a name="idx:prologcurrentframe1:2178"></a><a class="pred" href="manipstack.html#prolog_current_frame/1">prolog_current_frame/1</a>,
216 <a name="idx:prologtraceinterception4:2179"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
256 is a frame reference as obtained through <a id="idx:prologcurrentframe1:2182"></a><a class="pred" href="manipstack.html#prolog_current_frame/1">prolog_current_frame/1</a>,
257 <a id="idx:prologtraceinterception4:2183"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
217258 or this predicate. The key values are described below.
218259
219260 <dl class="latex">
233274 context, the goal is represented as <code>&lt;<var>module</var>&gt;:&lt;<var>goal</var>&gt;</code>.
234275 Do not instantiate variables in this goal unless you <b>know</b> what
235276 you are doing! Note that the returned term may contain references to the
236 frame and should be discarded before the frame terminates.<sup class="fn">185<span class="fn-text">The
277 frame and should be discarded before the frame terminates.<sup class="fn">186<span class="fn-text">The
237278 returned term is actually an illegal Prolog term that may hold
238279 references from the global to the local stack to preserve the variable
239280 names.</span></sup></dd>
255296 <dd class="defbody">
256297 <var>Value</var> is unified with a reference to the currently running
257298 clause. Fails if the current goal is associated with a foreign (C)
258 defined predicate. See also <a name="idx:nthclause3:2180"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
259 and <a name="idx:clauseproperty2:2181"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
299 defined predicate. See also <a id="idx:nthclause3:2184"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
300 and <a id="idx:clauseproperty2:2185"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
260301 <dt><strong>level</strong></dt>
261302 <dd class="defbody">
262303 <var>Value</var> is unified with the recursion level of <var>Frame</var>.
300341 </dl>
301342
302343 </dd>
303 <dt class="pubdef"><a name="prolog_choice_attribute/3"><strong>prolog_choice_attribute</strong>(<var>+ChoicePoint,
344 <dt class="pubdef"><a id="prolog_choice_attribute/3"><strong>prolog_choice_attribute</strong>(<var>+ChoicePoint,
304345 +Key, -Value</var>)</a></dt>
305346 <dd class="defbody">
306347 Extract attributes of a choice point. <var>ChoicePoint</var> is a
307 reference to a choice point as passed to <a name="idx:prologtraceinterception4:2182"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
308 on the 3rd argument or obtained using <a name="idx:prologcurrentchoice1:2183"></a><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a>. <var>Key</var>
348 reference to a choice point as passed to <a id="idx:prologtraceinterception4:2186"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
349 on the 3rd argument or obtained using <a id="idx:prologcurrentchoice1:2187"></a><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a>. <var>Key</var>
309350 specifies the requested information:
310351
311352 <dl class="latex">
322363 Requests the type. Defined values are <code>clause</code> (the goal has
323364 alternative clauses), <code>foreign</code> (non-deterministic foreign
324365 predicate), <code>jump</code> (clause internal choice point), <code>top</code>
325 (first dummy choice point), <code>catch</code> (<a name="idx:catch3:2184"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
366 (first dummy choice point), <code>catch</code> (<a id="idx:catch3:2188"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
326367 to allow for undo),
327368 <code>debug</code> (help the debugger), or <code>none</code> (has been
328369 deleted).
331372
332373 <p>This predicate is used for the graphical debugger to show the choice
333374 point stack.</dd>
334 <dt class="pubdef"><a name="deterministic/1"><strong>deterministic</strong>(<var>-Boolean</var>)</a></dt>
375 <dt class="pubdef"><a id="deterministic/1"><strong>deterministic</strong>(<var>-Boolean</var>)</a></dt>
335376 <dd class="defbody">
336377 Unifies its argument with <code>true</code> if no choice point exists
337378 that is more recent than the entry of the clause in which it appears.
338379 There are few realistic situations for using this predicate. It is used
339380 by the
340 <a name="idx:prolog0:2185"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
381 <a id="idx:prolog0:2189"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
341382 top level to check whether Prolog should prompt the user for
342383 alternatives. Similar results can be achieved in a more portable fashion
343 using <a name="idx:callcleanup2:2186"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
384 using <a id="idx:callcleanup2:2190"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
344385 </dd>
345386 </dl>
346387
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.21</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.21</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="termrw.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="manipatom.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:manipterm"><a name="sec:4.21"><span class="sec-nr">4.21</span> <span class="sec-title">Analysing
235 <h2 id="sec:manipterm"><a id="sec:4.21"><span class="sec-nr">4.21</span> <span class="sec-title">Analysing
195236 and Constructing Terms</span></a></h2>
196237
197 <a name="sec:manipterm"></a>
238 <a id="sec:manipterm"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="functor/3"><strong>functor</strong>(<var>?Term,
241 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="functor/3"><strong>functor</strong>(<var>?Term,
201242 ?Name, ?Arity</var>)</a></dt>
202243 <dd class="defbody">
203244 True when <var>Term</var> is a term with functor <var>Name</var>/<var>Arity</var>.
211252
212253 <p>SWI-Prolog also supports terms with arity 0, as in <code>a()</code>
213254 (see
214 <a class="sec" href="extensions.html">section 5</a>. Such terms must be
215 processed using
216 <a name="idx:compoundnamearity3:1190"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.
217 The predicate <a name="idx:functor3:1191"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
255 <a class="sec" href="extensions.html#sec:5">section 5</a>. Such terms
256 must be processed using
257 <a id="idx:compoundnamearity3:1190"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.
258 The predicate <a id="idx:functor3:1191"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
218259 and <a class="pred" href="manipterm.html#=../2">=../2</a> raise a <code>domain_error</code>
219260 when faced with these terms. Without this precaution, the inconsistency
220261 demonstrated below could happen silently.<sup class="fn">96<span class="fn-text">Raising
228269 </pre>
229270
230271 </dd>
231 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="arg/3"><strong>arg</strong>(<var>?Arg,
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="arg/3"><strong>arg</strong>(<var>?Arg,
232273 +Term, ?Value</var>)</a></dt>
233274 <dd class="defbody">
234275 <var>Term</var> should be instantiated to a term, <var>Arg</var> to an
240281 is unified with the argument number. Backtracking yields alternative
241282 solutions.<sup class="fn">97<span class="fn-text">The instantiation
242283 pattern (-, +, ?) is an extension to `standard' Prolog. Some systems
243 provide genarg/3 that covers this pattern.</span></sup> The predicate <a name="idx:arg3:1192"></a><a class="pred" href="manipterm.html#arg/3">arg/3</a>
284 provide genarg/3 that covers this pattern.</span></sup> The predicate <a id="idx:arg3:1192"></a><a class="pred" href="manipterm.html#arg/3">arg/3</a>
244285 fails silently if <var><var>Arg</var> = 0</var> or
245286 <var><var>Arg</var> &gt; <em>arity</em></var> and raises the exception
246287 <code>domain_error(not_less_than_zero, <var>Arg</var>)</code> if <var><var>Arg</var>
247288 &lt; 0</var>.</dd>
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=../2"><var>?Term</var> <strong>=..</strong> <var>?List</var></a></dt>
289 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=../2"><var>?Term</var> <strong>=..</strong> <var>?List</var></a></dt>
249290 <dd class="defbody">
250291 <var>List</var> is a list whose head is the functor of <var>Term</var>
251292 and the remaining arguments are the arguments of the term. Either side
262303
263304 <p>SWI-Prolog also supports terms with arity 0, as in <code>a()</code>
264305 (see
265 <a class="sec" href="extensions.html">section 5</a>. Such terms must be
266 processed using
267 <a name="idx:compoundnamearguments3:1193"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.
268 This predicate raises a domain error as shown below. See also <a name="idx:functor3:1194"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>.
306 <a class="sec" href="extensions.html#sec:5">section 5</a>. Such terms
307 must be processed using
308 <a id="idx:compoundnamearguments3:1193"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.
309 This predicate raises a domain error as shown below. See also <a id="idx:functor3:1194"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>.
269310
270311 <pre class="code">
271312 ?- a() =.. L.
273314 </pre>
274315
275316 </dd>
276 <dt class="pubdef"><a name="compound_name_arity/3"><strong>compound_name_arity</strong>(<var>?Compound,
317 <dt class="pubdef"><a id="compound_name_arity/3"><strong>compound_name_arity</strong>(<var>?Compound,
277318 ?Name, ?Arity</var>)</a></dt>
278319 <dd class="defbody">
279 Rationalized version of <a name="idx:functor3:1195"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
320 Rationalized version of <a id="idx:functor3:1195"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
280321 that only works for compound terms and can examine and create compound
281322 terms with zero arguments (e.g,
282 <code>name()</code>. See also <a name="idx:compoundnamearguments3:1196"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.</dd>
283 <dt class="pubdef"><a name="compound_name_arguments/3"><strong>compound_name_arguments</strong>(<var>?Compound,
323 <code>name()</code>. See also <a id="idx:compoundnamearguments3:1196"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.</dd>
324 <dt class="pubdef"><a id="compound_name_arguments/3"><strong>compound_name_arguments</strong>(<var>?Compound,
284325 ?Name, ?Arguments</var>)</a></dt>
285326 <dd class="defbody">
286327 Rationalized version of <a class="pred" href="manipterm.html#=../2">=../2</a>
287328 that can compose and decompose compound terms with zero arguments. See
288 also <a name="idx:compoundnamearity3:1197"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.</dd>
289 <dt class="pubdef"><a name="numbervars/3"><strong>numbervars</strong>(<var>+Term,
329 also <a id="idx:compoundnamearity3:1197"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.</dd>
330 <dt class="pubdef"><a id="numbervars/3"><strong>numbervars</strong>(<var>+Term,
290331 +Start, -End</var>)</a></dt>
291332 <dd class="defbody">
292333 Unify the free variables in <var>Term</var> with a term <code>$VAR(N)</code>,
313354 End = 2.
314355 </pre>
315356
316 <p>See also the <code>numbervars</code> option to <a name="idx:writeterm3:1198"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>
317 and <a name="idx:numbervars4:1199"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>.</dd>
318 <dt class="pubdef"><a name="numbervars/4"><strong>numbervars</strong>(<var>+Term,
357 <p>See also the <code>numbervars</code> option to <a id="idx:writeterm3:1198"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>
358 and <a id="idx:numbervars4:1199"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>.</dd>
359 <dt class="pubdef"><a id="numbervars/4"><strong>numbervars</strong>(<var>+Term,
319360 +Start, -End, +Options</var>)</a></dt>
320361 <dd class="defbody">
321 As <a name="idx:numbervars3:1200"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>,
362 As <a id="idx:numbervars3:1200"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>,
322363 providing the following options:
323364
324365 <dl class="latex">
328369 <dt><strong>attvar</strong>(<var>+Action</var>)</dt>
329370 <dd class="defbody">
330371 What to do if an attributed variable is encountered. Options are
331 <code>skip</code>, which causes <a name="idx:numbervars3:1201"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
372 <code>skip</code>, which causes <a id="idx:numbervars3:1201"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
332373 to ignore the attributed variable, <code>bind</code> which causes it to
333374 treat it as a normal variable and assign the next <code>'$VAR'</code>(N)
334375 term to it, or (default)
337378 Richard O'Keefe, Bart Demoen and Tom Schrijvers.</span></sup></dd>
338379 <dt><strong>singletons</strong>(<var>+Bool</var>)</dt>
339380 <dd class="defbody">
340 If <code>true</code> (default <code>false</code>), <a name="idx:numbervars4:1202"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>
381 If <code>true</code> (default <code>false</code>), <a id="idx:numbervars4:1202"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>
341382 does singleton detection. Singleton variables are unified with <code>'$VAR'('_')</code>,
342 causing them to be printed as <code>_</code> by <a name="idx:writeterm2:1203"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
343 using the numbervars option. This option is exploited by <a name="idx:portrayclause2:1204"></a><a class="pred" href="listing.html#portray_clause/2">portray_clause/2</a>
344 and <a name="idx:writecanonical2:1205"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.<sup class="fn">bug<span class="fn-text">Currently
383 causing them to be printed as <code>_</code> by <a id="idx:writeterm2:1203"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
384 using the numbervars option. This option is exploited by <a id="idx:portrayclause2:1204"></a><a class="pred" href="listing.html#portray_clause/2">portray_clause/2</a>
385 and <a id="idx:writecanonical2:1205"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.<sup class="fn">bug<span class="fn-text">Currently
345386 this option is ignored for cyclic terms.</span></sup>
346387 </dd>
347388 </dl>
348389
349390 </dd>
350 <dt class="pubdef"><a name="var_number/2"><strong>var_number</strong>(<var>@Term,
391 <dt class="pubdef"><a id="var_number/2"><strong>var_number</strong>(<var>@Term,
351392 -VarNumber</var>)</a></dt>
352393 <dd class="defbody">
353 True if <var>Term</var> is numbered by <a name="idx:numbervars3:1206"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
394 True if <var>Term</var> is numbered by <a id="idx:numbervars3:1206"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
354395 and <var>VarNumber</var> is the number given to this variable. This
355396 predicate avoids the need for unification with <code>'$VAR'(X)</code>
356397 and opens the path for replacing this valid Prolog term by an internal
357398 representation that has no textual equivalent.</dd>
358 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="term_variables/2"><strong>term_variables</strong>(<var>+Term,
399 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="term_variables/2"><strong>term_variables</strong>(<var>+Term,
359400 -List</var>)</a></dt>
360401 <dd class="defbody">
361402 Unify <var>List</var> with a list of variables, each sharing with a
362403 unique variable of <var>Term</var>.<sup class="fn">99<span class="fn-text">This
363 predicate used to be called free_variables/2 . The name <a name="idx:termvariables2:1207"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>
404 predicate used to be called free_variables/2 . The name <a id="idx:termvariables2:1207"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>
364405 is more widely used. The old predicate is still available from the
365406 library <code>library(backcomp)</code>.</span></sup> The variables in <var>List</var>
366407 are ordered in order of appearance traversing <var>Term</var>
367408 depth-first and left-to-right. See also
368 <a name="idx:termvariables3:1208"></a><a class="pred" href="manipterm.html#term_variables/3">term_variables/3</a>
369 and <a name="idx:nonground2:1209"></a><a class="pred" href="manipterm.html#nonground/2">nonground/2</a>.
409 <a id="idx:termvariables3:1208"></a><a class="pred" href="manipterm.html#term_variables/3">term_variables/3</a>
410 and <a id="idx:nonground2:1209"></a><a class="pred" href="manipterm.html#nonground/2">nonground/2</a>.
370411 For example:
371412
372413 <pre class="code">
375416 </pre>
376417
377418 </dd>
378 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="nonground/2"><strong>nonground</strong>(<var>+Term,
419 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="nonground/2"><strong>nonground</strong>(<var>+Term,
379420 -Var</var>)</a></dt>
380421 <dd class="defbody">
381422 True when <var>Var</var> is a variable in <var>Term</var>. Fails if <var>Term</var>
382 is <em>ground</em> (see <a name="idx:ground1:1210"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>).
423 is <em>ground</em> (see <a id="idx:ground1:1210"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>).
383424 This predicate is intended for coroutining to trigger a wakeup if <var>Term</var>
384 becomes ground, e.g., using <a name="idx:when2:1211"></a><a class="pred" href="coroutining.html#when/2">when/2</a>.
425 becomes ground, e.g., using <a id="idx:when2:1211"></a><a class="pred" href="coroutining.html#when/2">when/2</a>.
385426 The current implemention always returns the first variable in
386427 depth-first left-right search. Ideally it should return a random member
387 of the set of variables (see <a name="idx:termvariables2:1212"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>)
428 of the set of variables (see <a id="idx:termvariables2:1212"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>)
388429 to realise logarithmetic complexity for the ground trigger. Compatible
389430 with ECLiPSe and hProlog.</dd>
390 <dt class="pubdef"><a name="term_variables/3"><strong>term_variables</strong>(<var>+Term,
431 <dt class="pubdef"><a id="term_variables/3"><strong>term_variables</strong>(<var>+Term,
391432 -List, ?Tail</var>)</a></dt>
392433 <dd class="defbody">
393 Difference list version of <a name="idx:termvariables2:1213"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.
434 Difference list version of <a id="idx:termvariables2:1213"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.
394435 That is, <var>Tail</var> is the tail of the variable list <var>List</var>.</dd>
395 <dt class="pubdef"><a name="term_singletons/2"><strong>term_singletons</strong>(<var>+Term,
436 <dt class="pubdef"><a id="term_singletons/2"><strong>term_singletons</strong>(<var>+Term,
396437 -List</var>)</a></dt>
397438 <dd class="defbody">
398439 Unify <var>List</var> with a list of variables, each sharing with a
401442 is raised.</span></sup> Note that, if a variable appears in a shared
402443 subterm, it is <em>not</em> considered singleton. Thus,
403444 <var>A</var> is <em>not</em> a singleton in the example below. See also
404 the <code>singleton</code> option of <a name="idx:numbervars4:1214"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>.
445 the <code>singleton</code> option of <a id="idx:numbervars4:1214"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>.
405446
406447 <pre class="code">
407448
410451 </pre>
411452
412453 </dd>
413 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="copy_term/2"><strong>copy_term</strong>(<var>+In,
454 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="copy_term/2"><strong>copy_term</strong>(<var>+In,
414455 -Out</var>)</a></dt>
415456 <dd class="defbody">
416457 Create a version of <var>In</var> with renamed (fresh) variables and
417 unify it to <var>Out</var>. Attributed variables (see <a class="sec" href="attvar.html">section
418 7.1</a>) have their attributes copied. The implementation of <a name="idx:copyterm2:1215"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
458 unify it to <var>Out</var>. Attributed variables (see <a class="sec" href="attvar.html#sec:7.1">section
459 7.1</a>) have their attributes copied. The implementation of <a id="idx:copyterm2:1215"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
419460 can deal with infinite trees (cyclic terms). As pure Prolog cannot
420461 distinguish a ground term from another ground term with exactly the same
421462 structure, ground sub-terms are <em>shared</em> between <var>In</var>
422 and <var>Out</var>. Sharing ground terms does affect <a name="idx:setarg3:1216"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>.
463 and <var>Out</var>. Sharing ground terms does affect <a id="idx:setarg3:1216"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>.
423464 SWI-Prolog provides
424 <a name="idx:duplicateterm2:1217"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>
465 <a id="idx:duplicateterm2:1217"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>
425466 to create a true copy of a term.
426467 </dd>
427468 </dl>
428469
429 <p><h3 id="sec:setarg"><a name="sec:4.21.1"><span class="sec-nr">4.21.1</span> <span class="sec-title">Non-logical
470 <p><h3 id="sec:setarg"><a id="sec:4.21.1"><span class="sec-nr">4.21.1</span> <span class="sec-title">Non-logical
430471 operations on terms</span></a></h3>
431472
432 <a name="sec:setarg"></a>
473 <a id="sec:setarg"></a>
433474
434475 <p>Prolog is not able to <em>modify</em> instantiated parts of a term.
435476 Lacking that capability makes the language much safer, but unfortunately
436477 there are problems that suffer severely in terms of time and/or memory
437478 usage. Always try hard to avoid the use of these primitives, but they
438 can be a good alternative to using dynamic predicates. See also <a class="sec" href="gvar.html">section
479 can be a good alternative to using dynamic predicates. See also <a class="sec" href="gvar.html#sec:4.33">section
439480 4.33</a>, discussing the use of global variables.
440481
441482 <dl class="latex">
442 <dt class="pubdef"><a name="setarg/3"><strong>setarg</strong>(<var>+Arg,
483 <dt class="pubdef"><a id="setarg/3"><strong>setarg</strong>(<var>+Arg,
443484 +Term, +Value</var>)</a></dt>
444485 <dd class="defbody">
445486 Extra-logical predicate. Assigns the <var>Arg</var>-th argument of the
446487 compound term <var>Term</var> with the given <var>Value</var>. The
447488 assignment is undone if backtracking brings the state back into a
448 position before the <a name="idx:setarg3:1218"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
449 call. See also <a name="idx:nbsetarg3:1219"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
489 position before the <a id="idx:setarg3:1218"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
490 call. See also <a id="idx:nbsetarg3:1219"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
450491
451492 <p>This predicate may be used for destructive assignment to terms, using
452493 them as an extra-logical storage bin. Always try hard to avoid the use
453 of <a name="idx:setarg3:1220"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
494 of <a id="idx:setarg3:1220"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
454495 as it is not supported by many Prolog systems and one has to be very
455496 careful about unexpected copying as well as unexpected noncopying of
456497 terms. A good practice to improve somewhat on this situation is to make
457 sure that terms whose arguments are subject to <a name="idx:setarg3:1221"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
498 sure that terms whose arguments are subject to <a id="idx:setarg3:1221"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
458499 have one unused and unshared variable in addition to the used arguments.
459 This variable avoids unwanted sharing in, e.g., <a name="idx:copyterm2:1222"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
500 This variable avoids unwanted sharing in, e.g., <a id="idx:copyterm2:1222"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
460501 and causes the term to be considered as non-ground. An alternative is to
461 use <a name="idx:putattr3:1223"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>
462 to attach information to attributed variables (see&nbsp;<a class="sec" href="attvar.html">section
502 use <a id="idx:putattr3:1223"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>
503 to attach information to attributed variables (see&nbsp;<a class="sec" href="attvar.html#sec:7.1">section
463504 7.1</a>).</dd>
464 <dt class="pubdef"><a name="nb_setarg/3"><strong>nb_setarg</strong>(<var>+Arg,
505 <dt class="pubdef"><a id="nb_setarg/3"><strong>nb_setarg</strong>(<var>+Arg,
465506 +Term, +Value</var>)</a></dt>
466507 <dd class="defbody">
467508 Assigns the <var>Arg</var>-th argument of the compound term <var>Term</var>
468 with the given <var>Value</var> as <a name="idx:setarg3:1224"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>,
509 with the given <var>Value</var> as <a id="idx:setarg3:1224"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>,
469510 but on backtracking the assignment is <em>not</em> reversed. If <var>Value</var>
470 is not atomic, it is duplicated using <a name="idx:duplicateterm2:1225"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>.
511 is not atomic, it is duplicated using <a id="idx:duplicateterm2:1225"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>.
471512 This predicate uses the same technique as
472 <a name="idx:nbsetval2:1226"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>.
473 We therefore refer to the description of <a name="idx:nbsetval2:1227"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
513 <a id="idx:nbsetval2:1226"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>.
514 We therefore refer to the description of <a id="idx:nbsetval2:1227"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
474515 for details on non-backtrackable assignment of terms. This predicate is
475516 compatible with GNU-Prolog <code>setarg(A,T,V,false)</code>, removing
476 the type restriction on <var>Value</var>. See also <a name="idx:nblinkarg3:1228"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>.
517 the type restriction on <var>Value</var>. See also <a id="idx:nblinkarg3:1228"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>.
477518 Below is an example for counting the number of solutions of a goal. Note
478519 that this implementation is thread-safe, reentrant and capable of
479520 handling exceptions. Realising these features with a traditional
480 implementation based on assert/retract or <a name="idx:flag3:1229"></a><a class="pred" href="db.html#flag/3">flag/3</a>
521 implementation based on assert/retract or <a id="idx:flag3:1229"></a><a class="pred" href="db.html#flag/3">flag/3</a>
481522 is much more complicated.
482523
483524 <pre class="code">
496537 </pre>
497538
498539 </dd>
499 <dt class="pubdef"><a name="nb_linkarg/3"><strong>nb_linkarg</strong>(<var>+Arg,
540 <dt class="pubdef"><a id="nb_linkarg/3"><strong>nb_linkarg</strong>(<var>+Arg,
500541 +Term, +Value</var>)</a></dt>
501542 <dd class="defbody">
502 As <a name="idx:nbsetarg3:1230"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>,
503 but like <a name="idx:nblinkval2:1231"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
543 As <a id="idx:nbsetarg3:1230"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>,
544 but like <a id="idx:nblinkval2:1231"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
504545 it does <em>not</em> duplicate
505 <var>Value</var>. Use with extreme care and consult the documentation of <a name="idx:nblinkval2:1232"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
546 <var>Value</var>. Use with extreme care and consult the documentation of <a id="idx:nblinkval2:1232"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
506547 before use.</dd>
507 <dt class="pubdef"><a name="duplicate_term/2"><strong>duplicate_term</strong>(<var>+In,
548 <dt class="pubdef"><a id="duplicate_term/2"><strong>duplicate_term</strong>(<var>+In,
508549 -Out</var>)</a></dt>
509550 <dd class="defbody">
510 Version of <a name="idx:copyterm2:1233"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
551 Version of <a id="idx:copyterm2:1233"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
511552 that also copies ground terms and therefore ensures that destructive
512 modification using <a name="idx:setarg3:1234"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
513 does not affect the copy. See also <a name="idx:nbsetval2:1235"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>, <a name="idx:nblinkval2:1236"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>, <a name="idx:nbsetarg3:1237"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>
514 and <a name="idx:nblinkarg3:1238"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>.</dd>
515 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="same_term/2"><strong>same_term</strong>(<var>@T1,
553 modification using <a id="idx:setarg3:1234"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
554 does not affect the copy. See also <a id="idx:nbsetval2:1235"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>, <a id="idx:nblinkval2:1236"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>, <a id="idx:nbsetarg3:1237"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>
555 and <a id="idx:nblinkarg3:1238"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>.</dd>
556 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="same_term/2"><strong>same_term</strong>(<var>@T1,
516557 @T2</var>)</a></dt>
517558 <dd class="defbody">
518559 True if <var>T1</var> and <var>T2</var> are equivalent and will remain
519 equivalent, even if <a name="idx:setarg3:1239"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
560 equivalent, even if <a id="idx:setarg3:1239"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
520561 is used on either of them. This means
521562 <var>T1</var> and <var>T2</var> are the same variable, equivalent atomic
522563 data or a compound term allocated at the same address.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.42</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.42</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="profile.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="DDE.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:memory"><a name="sec:4.42"><span class="sec-nr">4.42</span> <span class="sec-title">Memory
235 <h2 id="sec:memory"><a id="sec:4.42"><span class="sec-nr">4.42</span> <span class="sec-title">Memory
195236 Management</span></a></h2>
196237
197 <a name="sec:memory"></a>
238 <a id="sec:memory"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="garbage_collect/0"><strong>garbage_collect</strong></a></dt>
241 <dt class="pubdef"><a id="garbage_collect/0"><strong>garbage_collect</strong></a></dt>
201242 <dd class="defbody">
202243 Invoke the global and trail stack garbage collector. Normally the
203244 garbage collector is invoked automatically if necessary. Explicit
204245 invocation might be useful to reduce the need for garbage collections in
205246 time-critical segments of the code. After the garbage collection
206 <a name="idx:trimstacks0:1575"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>
247 <a id="idx:trimstacks0:1575"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>
207248 is invoked to release the collected memory resources.</dd>
208 <dt class="pubdef"><a name="garbage_collect_atoms/0"><strong>garbage_collect_atoms</strong></a></dt>
249 <dt class="pubdef"><a id="garbage_collect_atoms/0"><strong>garbage_collect_atoms</strong></a></dt>
209250 <dd class="defbody">
210251 Reclaim unused atoms. Normally invoked after <a class="flag" href="flags.html#flag:agc_margin">agc_margin</a>
211252 (a Prolog flag) atoms have been created. On multithreaded versions the
212253 actual collection is delayed until there are no threads performing
213 normal garbage collection. In this case <a name="idx:garbagecollectatoms0:1576"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>
254 normal garbage collection. In this case <a id="idx:garbagecollectatoms0:1576"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>
214255 returns immediately. Note that there is no guarantee it will <em>ever</em>
215256 happen, as there may always be threads performing garbage collection.</dd>
216 <dt class="pubdef"><a name="trim_stacks/0"><strong>trim_stacks</strong></a></dt>
257 <dt class="pubdef"><a id="trim_stacks/0"><strong>trim_stacks</strong></a></dt>
217258 <dd class="defbody">
218259 Release stack memory resources that are not in use at this moment,
219260 returning them to the operating system. It can be used to release memory
231272
232273 <p>The Prolog top-level loop is written this way, reclaiming memory
233274 resources after every user query.</dd>
234 <dt class="pubdef"><a name="set_prolog_stack/2"><strong>set_prolog_stack</strong>(<var>+Stack,
275 <dt class="pubdef"><a id="set_prolog_stack/2"><strong>set_prolog_stack</strong>(<var>+Stack,
235276 +KeyValue</var>)</a></dt>
236277 <dd class="defbody">
237278 Set a parameter for one of the Prolog runtime stacks. <var>Stack</var>
244285 ?- set_prolog_stack(global, limit(2*10**9)).
245286 </pre>
246287
247 <p>Current settings can be retrieved with <a name="idx:prologstackproperty2:1577"></a><a class="pred" href="memory.html#prolog_stack_property/2">prolog_stack_property/2</a>.
288 <p>Current settings can be retrieved with <a id="idx:prologstackproperty2:1577"></a><a class="pred" href="memory.html#prolog_stack_property/2">prolog_stack_property/2</a>.
248289
249290 <dl class="latex">
250291 <dt><strong>limit</strong>(<var>+Bytes</var>)</dt>
261302 amount is reported and specified in `cells'. A cell is 4 bytes in the
262303 32-bit version and 8 bytes on the 64-bit version. See
263304 <a class="flag" href="flags.html#flag:address_bits">address_bits</a>.
264 See also <a name="idx:trimstacks0:1578"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>
265 and <a name="idx:debug0:1579"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
305 See also <a id="idx:trimstacks0:1578"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>
306 and <a id="idx:debug0:1579"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
266307 <dt><strong>spare</strong>(<var>+Cells</var>)</dt>
267308 <dd class="defbody">
268309 All stacks trigger overflow before actually reaching the limit, so the
269310 resulting error can be handled gracefully. The spare stack is used for
270 <a name="idx:printmessage2:1580"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
311 <a id="idx:printmessage2:1580"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
271312 from the garbage collector and for handling exceptions. The default
272313 suffices, unless the user redefines related hooks. Do
273314 <b>not</b> specify large values for this because it reduces the amount
274315 of memory available for your real task.
275316
276 <p>Related hooks are <a name="idx:messagehook3:1581"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
317 <p>Related hooks are <a id="idx:messagehook3:1581"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
277318 (redefining GC messages),
278 <a name="idx:prologtraceinterception4:1582"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
279 and <a name="idx:prologexceptionhook4:1583"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>.
319 <a id="idx:prologtraceinterception4:1582"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
320 and <a id="idx:prologexceptionhook4:1583"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>.
280321 </dd>
281322 </dl>
282323
283324 </dd>
284 <dt class="pubdef"><a name="prolog_stack_property/2"><strong>prolog_stack_property</strong>(<var>?Stack,
325 <dt class="pubdef"><a id="prolog_stack_property/2"><strong>prolog_stack_property</strong>(<var>?Stack,
285326 ?KeyValue</var>)</a></dt>
286327 <dd class="defbody">
287328 True if <var>KeyValue</var> is a current property of <var>Stack</var>.
288329 See
289 <a name="idx:setprologstack2:1584"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>
330 <a id="idx:setprologstack2:1584"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>
290331 for defined properties.
291332 </dd>
292333 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.9</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="control.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="delcont.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:metacall"><a name="sec:4.9"><span class="sec-nr">4.9</span> <span class="sec-title">Meta-Call
235 <h2 id="sec:metacall"><a id="sec:4.9"><span class="sec-nr">4.9</span> <span class="sec-title">Meta-Call
195236 Predicates</span></a></h2>
196237
197 <a name="sec:metacall"></a>
238 <a id="sec:metacall"></a>
198239
199240 <p>Meta-call predicates are used to call terms constructed at run time.
200241 The basic meta-call mechanism offered by SWI-Prolog is to use variables
204245 normal calls this search is done at compile time.
205246
206247 <dl class="latex">
207 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="call/1"><strong>call</strong>(<var>:Goal</var>)</a></dt>
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="call/1"><strong>call</strong>(<var>:Goal</var>)</a></dt>
208249 <dd class="defbody">
209250 Invoke <var>Goal</var> as a goal. Note that clauses may have variables
210 as subclauses, which is identical to <a name="idx:call1:649"></a><a class="pred" href="metacall.html#call/1">call/1</a>.</dd>
211 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="call/2"><strong>call</strong>(<var>:Goal,
251 as subclauses, which is identical to <a id="idx:call1:649"></a><a class="pred" href="metacall.html#call/1">call/1</a>.</dd>
252 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="call/2"><strong>call</strong>(<var>:Goal,
212253 +ExtraArg1, ...</var>)</a></dt>
213254 <dd class="defbody">
214255 Append <var>ExtraArg1, ExtraArg2, ...</var> to the argument list of
217258 3.
218259
219260 <p>The call/[2..] construct is handled by the compiler. The predicates
220 <a name="idx:call28:650"></a><a class="pred" href="metacall.html#call/2">call/[2-8]</a>
261 <a id="idx:call28:650"></a><a class="pred" href="metacall.html#call/2">call/[2-8]</a>
221262 are defined as real (meta-)predicates and are available to inspection
222 through <a name="idx:currentpredicate1:651"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>, <a name="idx:predicateproperty2:652"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>,
263 through <a id="idx:currentpredicate1:651"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>, <a id="idx:predicateproperty2:652"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>,
223264 etc.<sup class="fn">64<span class="fn-text">Arities 2..8 are demanded by
224265 ISO/IEC 13211-1:1995/Cor.2:2012.</span></sup> Higher arities are handled
225266 by the compiler and runtime system, but the predicates are not
228269 Full logical behaviour, generating all these pseudo predicates, is
229270 probably undesirable and will become impossible if <em>max_arity</em> is
230271 removed.</span></sup></dd>
231 <dt class="pubdef"><a name="apply/2"><strong>apply</strong>(<var>:Goal,
272 <dt class="pubdef"><a id="apply/2"><strong>apply</strong>(<var>:Goal,
232273 +List</var>)</a></dt>
233274 <dd class="defbody">
234275 Append the members of <var>List</var> to the arguments of <var>Goal</var>
237278 <code>plus(1, 2, X)</code>. New code should use call/[2..] if the length
238279 of
239280 <var>List</var> is fixed.</dd>
240 <dt class="pubdef"><a name="not/1"><strong>not</strong>(<var>:Goal</var>)</a></dt>
281 <dt class="pubdef"><a id="not/1"><strong>not</strong>(<var>:Goal</var>)</a></dt>
241282 <dd class="defbody">
242283 True if <var>Goal</var> cannot be proven. Retained for compatibility
243284 only. New code should use <a class="pred" href="control.html#\+/1">\+/1</a>.</dd>
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="once/1"><strong>once</strong>(<var>:Goal</var>)</a></dt>
285 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="once/1"><strong>once</strong>(<var>:Goal</var>)</a></dt>
245286 <dd class="defbody">
246287 Make a possibly <em>nondet</em> goal <em>semidet</em>, i.e., succeed at
247288 most once. Defined as:
251292 call(Goal), !.
252293 </pre>
253294
254 <p><a name="idx:once1:653"></a><a class="pred" href="metacall.html#once/1">once/1</a>
255 can in many cases be replaced with <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a>.
295 <p><a id="idx:once1:653"></a><a class="pred" href="metacall.html#once/1">once/1</a>
296 can in many cases be replaced with <a class="pred" href="control.html#->/2">-&gt;/2</a>.
256297 The only difference is how the cut behaves (see !/0). The following two
257298 clauses below are identical. Be careful about the interaction with
258299 <a class="pred" href="control.html#;/2">;/2</a>. The <code>library(apply_macros)</code>
259 library defines an inline expansion of <a name="idx:once1:654"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
300 library defines an inline expansion of <a id="idx:once1:654"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
260301 mapping it to <code>(Goal\send{true};fail)</code>. Using the full
261302 if-then-else constructs prevents its semantics from being changed when
262303 embedded in a <a class="pred" href="control.html#;/2">;/2</a>
268309 </pre>
269310
270311 </dd>
271 <dt class="pubdef"><a name="ignore/1"><strong>ignore</strong>(<var>:Goal</var>)</a></dt>
272 <dd class="defbody">
273 Calls <var>Goal</var> as <a name="idx:once1:655"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
312 <dt class="pubdef"><a id="ignore/1"><strong>ignore</strong>(<var>:Goal</var>)</a></dt>
313 <dd class="defbody">
314 Calls <var>Goal</var> as <a id="idx:once1:655"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
274315 but succeeds, regardless of whether
275316 <var>Goal</var> succeeded or not. Defined as:
276317
281322 </pre>
282323
283324 </dd>
284 <dt class="pubdef"><a name="call_with_depth_limit/3"><strong>call_with_depth_limit</strong>(<var>:Goal,
325 <dt class="pubdef"><a id="call_with_depth_limit/3"><strong>call_with_depth_limit</strong>(<var>:Goal,
285326 +Limit, -Result</var>)</a></dt>
286327 <dd class="defbody">
287328 If <var>Goal</var> can be proven without recursion deeper than <var>Limit</var>
288 levels, <a name="idx:callwithdepthlimit3:656"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
329 levels, <a id="idx:callwithdepthlimit3:656"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
289330 succeeds, binding <var>Result</var> to the deepest recursion level used
290331 during the proof. Otherwise, <var>Result</var> is unified with <code>depth_limit_exceeded</code>
291332 if the limit was exceeded during the proof, or the entire predicate
293334
294335 <p>The depth limit is guarded by the internal machinery. This may differ
295336 from the depth computed based on a theoretical model. For example,
296 <a name="idx:true0:657"></a><a class="pred" href="control.html#true/0">true/0</a>
337 <a id="idx:true0:657"></a><a class="pred" href="control.html#true/0">true/0</a>
297338 is translated into an inline virtual machine instruction. Also,
298 <a name="idx:repeat0:658"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>
339 <a id="idx:repeat0:658"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>
299340 is not implemented as below, but as a non-deterministic foreign
300341 predicate.
301342
305346 repeat.
306347 </pre>
307348
308 <p>As a result, <a name="idx:callwithdepthlimit3:659"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
349 <p>As a result, <a id="idx:callwithdepthlimit3:659"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
309350 may still loop infinitely on programs that should theoretically finish
310351 in finite time. This problem can be cured by using Prolog equivalents to
311352 such built-in predicates.
312353
313354 <p>This predicate may be used for theorem provers to realise techniques
314 like <em>iterative deepening</em>. See also <a name="idx:callwithinferencelimit3:660"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>.
355 like <em>iterative deepening</em>. See also <a id="idx:callwithinferencelimit3:660"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>.
315356 It was implemented after discussion with Steve Moyle
316357 <a class="url" href="mailto:smoyle@ermine.ox.ac.uk">smoyle@ermine.ox.ac.uk</a>.</dd>
317 <dt class="pubdef"><a name="call_with_inference_limit/3"><strong>call_with_inference_limit</strong>(<var>:Goal,
358 <dt class="pubdef"><a id="call_with_inference_limit/3"><strong>call_with_inference_limit</strong>(<var>:Goal,
318359 +Limit, -Result</var>)</a></dt>
319360 <dd class="defbody">
320361 Equivalent to <code>call(Goal)</code>, but limits the number of
331372 <var>Result</var> is unified with the atom
332373 <code>inference_limit_exceeded</code>.
333374 <i>Otherwise</i>,
334 <li>If <var>Goal</var> fails, <a name="idx:callwithinferencelimit3:661"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>
375 <li>If <var>Goal</var> fails, <a id="idx:callwithinferencelimit3:661"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>
335376 fails.
336377 <li>If <var>Goal</var> succeeds <em>without a choice point</em>,
337378 <var>Result</var> is unified with <code><code>!</code></code>.
338379 <li>If <var>Goal</var> succeeds <em>with a choice point</em>,
339380 <var>Result</var> is unified with <code>true</code>.
340 <li>If <var>Goal</var> throws an exception, <a name="idx:callwithinferencelimit3:662"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>
381 <li>If <var>Goal</var> throws an exception, <a id="idx:callwithinferencelimit3:662"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>
341382 re-throws the exception.
342383 </ul>
343384
346387 instructions for which inferences are not counted. The execution of
347388 predicates defined in other languages (e.g., C, C++) count as a single
348389 inference. This includes potentially expensive built-in predicates such
349 as <a name="idx:sort2:663"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>.
390 as <a id="idx:sort2:663"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>.
350391
351392 <p>Calls to this predicate may be nested. An inner call that sets the
352393 limit below the current is honoured. An inner call that would terminate
353394 after the current limit does not change the effective limit. See also
354 <a name="idx:callwithdepthlimit3:664"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
355 and <a name="idx:callwithtimelimit2:665"></a><span class="pred-ext">call_with_time_limit/2</span>.</dd>
356 <dt class="pubdef"><a name="setup_call_cleanup/3"><strong>setup_call_cleanup</strong>(<var>:Setup,
395 <a id="idx:callwithdepthlimit3:664"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
396 and <a id="idx:callwithtimelimit2:665"></a><span class="pred-ext">call_with_time_limit/2</span>.</dd>
397 <dt class="pubdef"><a id="setup_call_cleanup/3"><strong>setup_call_cleanup</strong>(<var>:Setup,
357398 :Goal, :Cleanup</var>)</a></dt>
358399 <dd class="defbody">
359400 Calls <code>(once(Setup), Goal)</code>. If <var>Setup</var> succeeds, <var>Cleanup</var>
360401 will be called exactly once after <var>Goal</var> is finished: either on
361402 failure, deterministic success, commit, or an exception. The execution
362403 of <var>Setup</var> is protected from asynchronous interrupts like
363 <a name="idx:callwithtimelimit2:666"></a><span class="pred-ext">call_with_time_limit/2</span>
364 (package clib) or <a name="idx:threadsignal2:667"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.
404 <a id="idx:callwithtimelimit2:666"></a><span class="pred-ext">call_with_time_limit/2</span>
405 (package clib) or <a id="idx:threadsignal2:667"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.
365406 In most uses,
366407 <var>Setup</var> will perform temporary side-effects required by <var>Goal</var>
367408 that are finally undone by <var>Cleanup</var>.
368409
369410 <p>Success or failure of <var>Cleanup</var> is ignored, and choice
370 points it created are destroyed (as <a name="idx:once1:668"></a><a class="pred" href="metacall.html#once/1">once/1</a>).
411 points it created are destroyed (as <a id="idx:once1:668"></a><a class="pred" href="metacall.html#once/1">once/1</a>).
371412 If <var>Cleanup</var> throws an exception, this is executed as normal
372413 while it was not triggered as the result of an exception the exception
373414 is propagated as normal. If <var>Cleanup</var> was triggered by an
374415 exception the rules are described in
375 <a class="sec" href="exception.html">section 4.11.1</a>
416 <a class="sec" href="exception.html#sec:4.11.1">section 4.11.1</a>
376417
377418 <p>Typically, this predicate is used to cleanup permanent data storage
378419 required to execute <var>Goal</var>, close file descriptors, etc. The
396437
397438 <p>Note that it is impossible to implement this predicate in Prolog. The
398439 closest approximation would be to read all terms into a list, close the
399 file and call <a name="idx:member2:669"></a><a class="pred" href="lists.html#member/2">member/2</a>.
400 Without <a name="idx:setupcallcleanup3:670"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
401 there is no way to gain control if the choice point left by <a name="idx:repeat0:671"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>
440 file and call <a id="idx:member2:669"></a><a class="pred" href="lists.html#member/2">member/2</a>.
441 Without <a id="idx:setupcallcleanup3:670"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
442 there is no way to gain control if the choice point left by <a id="idx:repeat0:671"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>
402443 is removed by a cut or an exception.
403444
404 <p><a name="idx:setupcallcleanup3:672"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
445 <p><a id="idx:setupcallcleanup3:672"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
405446 can also be used to test determinism of a goal, providing a portable
406 alternative to <a name="idx:deterministic1:673"></a><a class="pred" href="manipstack.html#deterministic/1">deterministic/1</a>:
447 alternative to <a id="idx:deterministic1:673"></a><a class="pred" href="manipstack.html#deterministic/1">deterministic/1</a>:
407448
408449 <pre class="code">
409450 ?- setup_call_cleanup(true,(X=1;X=2), Det=yes).
415456 </pre>
416457
417458 <p>This predicate is under consideration for inclusion into the ISO
418 standard. For compatibility with other Prolog implementations see <a name="idx:callcleanup2:674"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.</dd>
419 <dt class="pubdef"><a name="setup_call_catcher_cleanup/4"><strong>setup_call_catcher_cleanup</strong>(<var>:Setup,
459 standard. For compatibility with other Prolog implementations see <a id="idx:callcleanup2:674"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.</dd>
460 <dt class="pubdef"><a id="setup_call_catcher_cleanup/4"><strong>setup_call_catcher_cleanup</strong>(<var>:Setup,
420461 :Goal, +Catcher, :Cleanup</var>)</a></dt>
421462 <dd class="defbody">
422463 Similar to <code>setup_call_cleanup(Setup, Goal, Cleanup)</code> with
458499 </dl>
459500
460501 </dd>
461 <dt class="pubdef"><a name="call_cleanup/2"><strong>call_cleanup</strong>(<var>:Goal,
502 <dt class="pubdef"><a id="call_cleanup/2"><strong>call_cleanup</strong>(<var>:Goal,
462503 :Cleanup</var>)</a></dt>
463504 <dd class="defbody">
464505 Same as <code>setup_call_cleanup(true, Goal, Cleanup)</code>. This is
465506 provided for compatibility with a number of other Prolog implementations
466 only. Do not use <a name="idx:callcleanup2:675"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>
507 only. Do not use <a id="idx:callcleanup2:675"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>
467508 if you perform side-effects prior to calling that will be undone by <var>Cleanup</var>.
468509 Instead, use
469 <a name="idx:setupcallcleanup3:676"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
510 <a id="idx:setupcallcleanup3:676"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
470511 with an appropriate first argument to perform those side-effects.</dd>
471 <dt class="pubdef"><a name="call_cleanup/3"><strong>call_cleanup</strong>(<var>:Goal,
512 <dt class="pubdef"><a id="call_cleanup/3"><strong>call_cleanup</strong>(<var>:Goal,
472513 +Catcher, :Cleanup</var>)</a></dt>
473514 <dd class="defbody">
474515 Same as <code>setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup)</code>.
475 The same warning as for <a name="idx:callcleanup2:677"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>
516 The same warning as for <a id="idx:callcleanup2:677"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>
476517 applies.
477518 </dd>
478519 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="import.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="overrule.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:metapred"><a name="sec:6.4"><span class="sec-nr">6.4</span> <span class="sec-title">Defining
235 <h2 id="sec:metapred"><a id="sec:6.4"><span class="sec-nr">6.4</span> <span class="sec-title">Defining
195236 a meta-predicate</span></a></h2>
196237
197 <a name="sec:metapred"></a>
238 <a id="sec:metapred"></a>
198239
199240 <p>A meta-predicate is a predicate that calls other predicates
200241 dynamically, modifies a predicate, or reasons about properties of a
201242 predicate. Such predicates use either a compound term or a <em>predicate
202243 indicator</em> to describe the predicate they address, e.g., <code>assert(name(jan))</code>
203 or <code>abolish(<a name="idx:name1:1685"></a><span class="pred-ext">name/1</span>)</code>.
244 or <code>abolish(<a id="idx:name1:1689"></a><span class="pred-ext">name/1</span>)</code>.
204245 With modules, this simple schema no longer works as each module defines
205246 its own mapping from name+arity to predicate. This is resolved by
206247 wrapping the original description in a term &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;,
207248 e.g., <code>assert(person:name(jan))</code> or
208249 <code>abolish(person:name/1)</code>.
209250
210 <p>Of course, when calling <a name="idx:assert1:1686"></a><a class="pred" href="db.html#assert/1">assert/1</a>
251 <p>Of course, when calling <a id="idx:assert1:1690"></a><a class="pred" href="db.html#assert/1">assert/1</a>
211252 from inside a module, we expect to assert to a predicate local to this
212253 module. In other words, we do not wish to provide this <code><code>:</code>/2</code>
213 wrapper by hand. The <a name="idx:metapredicate1:1687"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
254 wrapper by hand. The <a id="idx:metapredicate1:1691"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
214255 directive tells the compiler that certain arguments are terms that will
215256 be used to look up a predicate and thus need to be wrapped (qualified)
216257 with &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;, unless they are
217258 already wrapped.
218259
219 <p>In the example below, we use this to define <a name="idx:maplist3:1688"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
260 <p>In the example below, we use this to define <a id="idx:maplist3:1692"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
220261 inside a module. The argument `2' in the meta_predicate declaration
221262 means that the argument is module-sensitive and refers to a predicate
222263 with an arity that is two more than the term that is passed in. The
225266 and <code><code>?</code></code>, which denote
226267 <em>modes</em>. The values 0..9 are used by the
227268 <em>cross-referencer</em> and syntax highlighting. Note that the helper
228 predicate <a name="idx:maplist3:1689"></a><span class="pred-ext">maplist_/3</span>
229 does not need to be declared as a meta-predicate because the <a name="idx:maplist3:1690"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
269 predicate <a id="idx:maplist3:1693"></a><span class="pred-ext">maplist_/3</span>
270 does not need to be declared as a meta-predicate because the <a id="idx:maplist3:1694"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
230271 wrapper already ensures that
231272 <var>Goal</var> is qualified as &lt;<var>module</var>&gt;:<var>Goal</var>.
232273 See the description of
233 <a name="idx:metapredicate1:1691"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
274 <a id="idx:metapredicate1:1695"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
234275 for details.
235276
236277 <pre class="code">
252293 </pre>
253294
254295 <dl class="latex">
255 <dt class="pubdef"><a name="meta_predicate/1"><strong>meta_predicate</strong> <var>+Head,
296 <dt class="pubdef"><a id="meta_predicate/1"><strong>meta_predicate</strong> <var>+Head,
256297 ...</var></a></dt>
257298 <dd class="defbody">
258299 Define the predicates referenced by the comma-separated list <var>Head</var>
287328 <dd class="defbody">
288329 The argument is not module-sensitive and the mode is unspecified. The
289330 specification <code><code>*</code></code> is equivalent to <code><code>?</code></code>.
290 It is accepted for compatibility reasons. The predicate <a name="idx:predicateproperty2:1692"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
331 It is accepted for compatibility reasons. The predicate <a id="idx:predicateproperty2:1696"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
291332 reports arguments declared using <code><code>*</code></code> with <code><code>?</code></code>.
292333 </dd>
293334 <dt><strong><code>+</code></strong></dt>
298339 <dd class="defbody">
299340 This extension is used to denote the possibly <code>^</code>-annotated
300341 goal of
301 <a name="idx:setof3:1693"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>, <a name="idx:bagof3:1694"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>, <a name="idx:aggregate3:1695"></a><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
302 and <a name="idx:aggregate4:1696"></a><a class="pred" href="aggregate.html#aggregate/4">aggregate/4</a>.
342 <a id="idx:setof3:1697"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>, <a id="idx:bagof3:1698"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>, <a id="idx:aggregate3:1699"></a><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
343 and <a id="idx:aggregate4:1700"></a><a class="pred" href="aggregate.html#aggregate/4">aggregate/4</a>.
303344 It is processed similar to `0', but leaving the <code><code>^</code></code>/2
304345 intact.
305346 </dd>
306347 <dt><strong><code>//</code></strong></dt>
307348 <dd class="defbody">
308 The argument is a DCG body. See <a name="idx:phrase3:1697"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.
349 The argument is a DCG body. See <a id="idx:phrase3:1701"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.
309350 </dd>
310351 </dl>
311352
342383 Module=42, Term = test
343384 </pre>
344385
345 <p>The <a name="idx:metapredicate1:1698"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
386 <p>The <a id="idx:metapredicate1:1702"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
346387 declaration is the portable mechanism for defining meta-predicates and
347388 replaces the old SWI-Prolog specific mechanism provided by the
348 deprecated predicates <a name="idx:moduletransparent1:1699"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>,
349 <a name="idx:contextmodule1:1700"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
350 and <a name="idx:stripmodule3:1701"></a><a class="pred" href="ctxmodule.html#strip_module/3">strip_module/3</a>.
351 See also <a class="sec" href="modulecompat.html">section 6.15</a>.
389 deprecated predicates <a id="idx:moduletransparent1:1703"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>,
390 <a id="idx:contextmodule1:1704"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
391 and <a id="idx:stripmodule3:1705"></a><a class="pred" href="ctxmodule.html#strip_module/3">strip_module/3</a>.
392 See also <a class="sec" href="modulecompat.html#sec:6.15">section 6.15</a>.
352393 </dd>
353394 </dl>
354395
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.28</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.28</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="arith.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="builtinlist.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:miscarith"><a name="sec:4.28"><span class="sec-nr">4.28</span> <span class="sec-title">Misc
235 <h2 id="sec:miscarith"><a id="sec:4.28"><span class="sec-nr">4.28</span> <span class="sec-title">Misc
195236 arithmetic support predicates</span></a></h2>
196237
197 <a name="sec:miscarith"></a>
238 <a id="sec:miscarith"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="set_random/1"><strong>set_random</strong>(<var>+Option</var>)</a></dt>
241 <dt class="pubdef"><a id="set_random/1"><strong>set_random</strong>(<var>+Option</var>)</a></dt>
201242 <dd class="defbody">
202243 Controls the random number generator accessible through the
203244 <em>functions</em> <a class="function" href="arith.html#f-random/1">random/1</a>
224265 </dd>
225266 <dt><strong>state</strong>(<var>+State</var>)</dt>
226267 <dd class="defbody">
227 Set the generator to a state fetched using the state property of <a name="idx:randomproperty1:1340"></a><a class="pred" href="miscarith.html#random_property/1">random_property/1</a>.
268 Set the generator to a state fetched using the state property of <a id="idx:randomproperty1:1340"></a><a class="pred" href="miscarith.html#random_property/1">random_property/1</a>.
228269 Using other values may lead to undefined behaviour.<sup class="fn">117<span class="fn-text">The
229270 limitations of the underlying (GMP) library are unknown, which makes it
230271 impossible to validate the <var>State</var>.</span></sup>
232273 </dl>
233274
234275 </dd>
235 <dt class="pubdef"><a name="random_property/1"><strong>random_property</strong>(<var>?Option</var>)</a></dt>
276 <dt class="pubdef"><a id="random_property/1"><strong>random_property</strong>(<var>?Option</var>)</a></dt>
236277 <dd class="defbody">
237278 True when <var>Option</var> is a current property of the random
238279 generator. Currently, this predicate provides access to the state. This
244285 Describes the current state of the random generator. State is a normal
245286 Prolog term that can be asserted or written to a file. Applications
246287 should make no other assumptions about its representation. The only
247 meaningful operation is to use as argument to <a name="idx:setrandom1:1341"></a><a class="pred" href="miscarith.html#set_random/1">set_random/1</a>
288 meaningful operation is to use as argument to <a id="idx:setrandom1:1341"></a><a class="pred" href="miscarith.html#set_random/1">set_random/1</a>
248289 using the
249290 <code>state(State)</code> option.<sup class="fn">bug<span class="fn-text">GMP
250291 provides no portable mechanism to fetch and restore the state. The
255296 </dl>
256297
257298 </dd>
258 <dt class="pubdef"><a name="current_arithmetic_function/1"><strong>current_arithmetic_function</strong>(<var>?Head</var>)</a></dt>
299 <dt class="pubdef"><a id="current_arithmetic_function/1"><strong>current_arithmetic_function</strong>(<var>?Head</var>)</a></dt>
259300 <dd class="defbody">
260301 True when <var>Head</var> is an evaluable function. For example:
261302
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.44</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.44</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="DDE.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="extensions.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:miscpreds"><a name="sec:4.44"><span class="sec-nr">4.44</span> <span class="sec-title">Miscellaneous</span></a></h2>
195
196 <a name="sec:miscpreds"></a>
235 <h2 id="sec:miscpreds"><a id="sec:4.44"><span class="sec-nr">4.44</span> <span class="sec-title">Miscellaneous</span></a></h2>
236
237 <a id="sec:miscpreds"></a>
197238
198239 <dl class="latex">
199 <dt class="pubdef"><a name="dwim_match/2"><strong>dwim_match</strong>(<var>+Atom1,
240 <dt class="pubdef"><a id="dwim_match/2"><strong>dwim_match</strong>(<var>+Atom1,
200241 +Atom2</var>)</a></dt>
201242 <dd class="defbody">
202243 True if <var>Atom1</var> matches <var>Atom2</var> in the `Do What I
213254 fileExists)
214255 </ul>
215256 </dd>
216 <dt class="pubdef"><a name="dwim_match/3"><strong>dwim_match</strong>(<var>+Atom1,
257 <dt class="pubdef"><a id="dwim_match/3"><strong>dwim_match</strong>(<var>+Atom1,
217258 +Atom2, -Difference</var>)</a></dt>
218259 <dd class="defbody">
219 Equivalent to <a name="idx:dwimmatch2:1586"></a><a class="pred" href="miscpreds.html#dwim_match/2">dwim_match/2</a>,
260 Equivalent to <a id="idx:dwimmatch2:1586"></a><a class="pred" href="miscpreds.html#dwim_match/2">dwim_match/2</a>,
220261 but unifies <var>Difference</var> with an atom identifying the
221262 difference between <var>Atom1</var> and <var>Atom2</var>. The return
222263 values are (in the same order as above): <code>equal</code>,
223264 <code>mismatched_char</code>, <code>inserted_char</code>, <code>transposed_char</code>,
224265 <code>separated</code> and <code>transposed_word</code>.
225266 </dd>
226 <dt class="pubdef"><a name="wildcard_match/2"><strong>wildcard_match</strong>(<var>+Pattern,
267 <dt class="pubdef"><a id="wildcard_match/2"><strong>wildcard_match</strong>(<var>+Pattern,
227268 +String</var>)</a></dt>
228269 <dd class="defbody">
229270 True if <var>String</var> matches the wildcard pattern <var>Pattern</var>.
230271 <var>Pattern</var> is very similar to the Unix <code>csh</code> pattern
231272 matcher. The patterns are given below:
232 <div style="text-align:center"><table border="0" frame="void" rules="groups">
233 <tr valign="top"><td><code><code>?</code></code> </td><td>Matches one
234 arbitrary character. </td></tr>
235 <tr valign="top"><td><code><code>*</code></code> </td><td>Matches any
236 number of arbitrary characters. </td></tr>
237 <tr valign="top"><td><code>[ ... ]</code> </td><td>Matches one of the
238 characters specified between the brackets. </td></tr>
239 <tr valign="top"><td></td><td><code>&lt;<var>char1</var>&gt;-&lt;<var>char2</var>&gt;</code>
273
274 <p><table class="latex frame-void center">
275 <tr><td><code><code>?</code></code> </td><td>Matches one arbitrary
276 character. </td></tr>
277 <tr><td><code><code>*</code></code> </td><td>Matches any number of
278 arbitrary characters. </td></tr>
279 <tr><td><code>[ ... ]</code> </td><td>Matches one of the characters
280 specified between the brackets. </td></tr>
281 <tr><td></td><td><code>&lt;<var>char1</var>&gt;-&lt;<var>char2</var>&gt;</code>
240282 indicates a range. </td></tr>
241 <tr valign="top"><td><code>{...}</code> </td><td>Matches any of the
242 patterns of the comma-separated list between the braces.</td></tr>
283 <tr><td><code>{...}</code> </td><td>Matches any of the patterns of the
284 comma-separated list between the braces.</td></tr>
243285 </table>
244 </div>
245286
246287 <p>Example:
247288
251292 </pre>
252293
253294 </dd>
254 <dt class="pubdef"><a name="sleep/1"><strong>sleep</strong>(<var>+Time</var>)</a></dt>
295 <dt class="pubdef"><a id="sleep/1"><strong>sleep</strong>(<var>+Time</var>)</a></dt>
255296 <dd class="defbody">
256297 Suspend execution <var>Time</var> seconds. <var>Time</var> is either a
257298 floating point number or an integer. Granularity is dependent on the
259300 immediately. On most non-realtime operating systems we can only ensure
260301 execution is suspended for <b>at least</b> <var>Time</var> seconds.
261302
262 <p>On Unix systems the <a name="idx:sleep1:1587"></a><a class="pred" href="miscpreds.html#sleep/1">sleep/1</a>
303 <p>On Unix systems the <a id="idx:sleep1:1587"></a><a class="pred" href="miscpreds.html#sleep/1">sleep/1</a>
263304 predicate is realised ---in order of preference--- by nanosleep(),
264305 usleep(), select() if the time is below 1 minute, or sleep(). On Windows
265306 systems Sleep() is used.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.15</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="manipmodule.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="clp.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:modulecompat"><a name="sec:6.15"><span class="sec-nr">6.15</span> <span class="sec-title">Compatibility
235 <h2 id="sec:modulecompat"><a id="sec:6.15"><span class="sec-nr">6.15</span> <span class="sec-title">Compatibility
195236 of the Module System</span></a></h2>
196237
197 <a name="sec:modulecompat"></a>
238 <a id="sec:modulecompat"></a>
198239
199240 <p>The SWI-Prolog module system is largely derived from the Quintus
200241 Prolog module system, which is also adopted by SICStus, Ciao and YAP.
201242 Originally, the mechanism for defining meta-predicates in SWI-Prolog was
202 based on the <a name="idx:moduletransparent1:1752"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
203 directive and <a name="idx:stripmodule3:1753"></a><a class="pred" href="ctxmodule.html#strip_module/3">strip_module/3</a>.
204 Since 5.7.4 it supports the de-facto standard <a name="idx:metapredicate1:1754"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
243 based on the <a id="idx:moduletransparent1:1756"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
244 directive and <a id="idx:stripmodule3:1757"></a><a class="pred" href="ctxmodule.html#strip_module/3">strip_module/3</a>.
245 Since 5.7.4 it supports the de-facto standard <a id="idx:metapredicate1:1758"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
205246 directive for implementing meta-predicates, providing much better
206247 compatibility.
207248
208 <p>The support for the <a name="idx:metapredicate1:1755"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
249 <p>The support for the <a id="idx:metapredicate1:1759"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
209250 mechanism, however, is considerably different. On most systems, the <em>caller</em>
210251 of a meta-predicate is compiled differently to provide the required &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;
211252 qualification. This implies that the meta-declaration must be available
217258 <ul class="latex">
218259 <li>Modules that provide meta-predicates for a module to be compiled
219260 must be loaded explicitly by that module.
220 <li>The meta-predicate directives of exported predicates must follow the <a name="idx:module2:1756"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
261 <li>The meta-predicate directives of exported predicates must follow the <a id="idx:module2:1760"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
221262 directive immediately.
222263 <li>After changing a meta-declaration, all modules that <em>call</em>
223264 the modified predicates need to be recompiled.
239280 user-defined module is the <code>user</code> module. In turn, the
240281 <code>user</code> module imports from the module <code>system</code>
241282 that provides all built-in predicates. The auto-import hierarchy can be
242 changed using <a name="idx:addimportmodule3:1757"></a><a class="pred" href="importmodule.html#add_import_module/3">add_import_module/3</a>
243 and <a name="idx:deleteimportmodule2:1758"></a><a class="pred" href="importmodule.html#delete_import_module/2">delete_import_module/2</a>.
283 changed using <a id="idx:addimportmodule3:1761"></a><a class="pred" href="importmodule.html#add_import_module/3">add_import_module/3</a>
284 and <a id="idx:deleteimportmodule2:1762"></a><a class="pred" href="importmodule.html#delete_import_module/2">delete_import_module/2</a>.
244285
245286 <p>This mechanism can be used to realise a simple object-oriented system
246287 or a hierarchical module system.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="reexport.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="importmodule.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:moduleop"><a name="sec:6.8"><span class="sec-nr">6.8</span> <span class="sec-title">Operators
235 <h2 id="sec:moduleop"><a id="sec:6.8"><span class="sec-nr">6.8</span> <span class="sec-title">Operators
195236 and modules</span></a></h2>
196237
197 <a name="sec:moduleop"></a>
198
199 <p>Operators (<a class="sec" href="operators.html">section 4.25</a>) are
200 local to modules, where the initial table behaves as if it is copied
238 <a id="sec:moduleop"></a>
239
240 <p>Operators (<a class="sec" href="operators.html#sec:4.25">section 4.25</a>)
241 are local to modules, where the initial table behaves as if it is copied
201242 from the module <code>user</code> (see
202 <a class="sec" href="resmodules.html">section 6.10</a>). A specific
203 operator can be disabled inside a module using <code>:- op(0, Type,
204 Name)</code>. Inheritance from the public table can be restored using <code>:-
205 op(-1, Type, Name)</code>.
206
207 <p>In addition to using the <a name="idx:op3:1716"></a><a class="pred" href="operators.html#op/3">op/3</a>
208 directive, operators can be declared in the <a name="idx:module2:1717"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
243 <a class="sec" href="resmodules.html#sec:6.10">section 6.10</a>). A
244 specific operator can be disabled inside a module using <code>:- op(0,
245 Type, Name)</code>. Inheritance from the public table can be restored
246 using <code>:- op(-1, Type, Name)</code>.
247
248 <p>In addition to using the <a id="idx:op3:1720"></a><a class="pred" href="operators.html#op/3">op/3</a>
249 directive, operators can be declared in the <a id="idx:module2:1721"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
209250 directive as shown below. Such operator declarations are visible inside
210251 the module, and importing such a module makes the operators visible in
211252 the target module. Exporting operators is typically used by modules that
212253 implement sub-languages such as chr (see
213 <a class="sec" href="chr.html">chapter 8</a>). The example below is
214 copied from the library
254 <a class="sec" href="chr.html#sec:8">chapter 8</a>). The example below
255 is copied from the library
215256 <code>library(clpfd)</code>.
216257
217258 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ext-issues.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="whymodules.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:modules"><a name="sec:6"><span class="sec-nr">6</span> <span class="sec-title">Modules</span></a></h1>
195
196 <a name="sec:modules"></a>
235 <h1 id="sec:modules"><a id="sec:6"><span class="sec-nr">6</span> <span class="sec-title">Modules</span></a></h1>
236
237 <a id="sec:modules"></a>
197238
198239 <p>A Prolog module is a collection of predicates which defines a public
199240 interface by means of a set of provided predicates and operators. Prolog
209250
210251 <p>This chapter motivates and describes the SWI-Prolog module system.
211252 Novices can start using the module system after reading
212 <a class="sec" href="defmodule.html">section 6.2</a> and <a class="sec" href="import.html">section
253 <a class="sec" href="defmodule.html#sec:6.2">section 6.2</a> and <a class="sec" href="import.html#sec:6.3">section
213254 6.3</a>. The primitives defined in these sections suffice for basic
214255 usage until one needs to export predicates that call or manage other
215 predicates dynamically (e.g., use <a name="idx:call1:1658"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
216 <a name="idx:assert1:1659"></a><a class="pred" href="db.html#assert/1">assert/1</a>,
256 predicates dynamically (e.g., use <a id="idx:call1:1662"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
257 <a id="idx:assert1:1663"></a><a class="pred" href="db.html#assert/1">assert/1</a>,
217258 etc.). Such predicates are called <em>meta predicates</em> and are
218 discussed in <a class="sec" href="metapred.html">section 6.4</a>. <a class="sec" href="overrule.html">Section
219 6.5</a> to <a class="sec" href="moduleop.html">section 6.8</a> describe
220 more advanced issues. Starting with <a class="sec" href="importmodule.html">section
259 discussed in <a class="sec" href="metapred.html#sec:6.4">section 6.4</a>. <a class="sec" href="overrule.html#sec:6.5">Section
260 6.5</a> to <a class="sec" href="moduleop.html#sec:6.8">section 6.8</a>
261 describe more advanced issues. Starting with <a class="sec" href="importmodule.html#sec:6.9">section
221262 6.9</a>, we discuss more low-level aspects of the SWI-Prolog module
222263 system that are used to implement the visible module system, and can be
223264 used to build other code reuse mechanisms.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 9.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreignthread.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="engines.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:mt-xpce"><a name="sec:9.7"><span class="sec-nr">9.7</span> <span class="sec-title">Multithreading
235 <h2 id="sec:mt-xpce"><a id="sec:9.7"><span class="sec-nr">9.7</span> <span class="sec-title">Multithreading
195236 and the XPCE graphics system</span></a></h2>
196237
197 <a name="sec:mt-xpce"></a>
198 <a name="sec:xpcethread"></a>
238 <a id="sec:mt-xpce"></a>
239 <a id="sec:xpcethread"></a>
199240
200241 <p>GUI applications written in XPCE can benefit from Prolog threads if
201242 they need to do expensive computations that would otherwise block the
210251 <p>Traditionally, XPCE runs in the foreground (<code>main</code>)
211252 thread. We are working towards a situation where XPCE can run
212253 comfortably in a separate thread. A separate XPCE thread can be created
213 using <a name="idx:pcedispatch1:1955"></a><a class="pred" href="mt-xpce.html#pce_dispatch/1">pce_dispatch/1</a>.
254 using <a id="idx:pcedispatch1:1959"></a><a class="pred" href="mt-xpce.html#pce_dispatch/1">pce_dispatch/1</a>.
214255 It is also possible to create this thread as the <code>library(1)</code>pce)
215256 is loaded by setting the <b>xpce_threaded</b> to <code>true</code>.
216257
218259 two predicates to communicate with XPCE.
219260
220261 <dl class="latex">
221 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="in_pce_thread/1"><strong>in_pce_thread</strong>(<var>:Goal</var>)</a></dt>
262 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="in_pce_thread/1"><strong>in_pce_thread</strong>(<var>:Goal</var>)</a></dt>
222263 <dd class="defbody">
223264 Assuming XPCE is running in the foreground thread, this call gives
224265 background threads the opportunity to make calls to the XPCE thread. A
225 call to <a name="idx:inpcethread1:1956"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>
266 call to <a id="idx:inpcethread1:1960"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>
226267 succeeds immediately, copying <var>Goal</var> to the XPCE thread. <var>Goal</var>
227268 is added to the XPCE event queue and executed synchronous to normal user
228269 events like typing and clicking.</dd>
229 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="in_pce_thread_sync/1"><strong>in_pce_thread_sync</strong>(<var>:Goal</var>)</a></dt>
270 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="in_pce_thread_sync/1"><strong>in_pce_thread_sync</strong>(<var>:Goal</var>)</a></dt>
230271 <dd class="defbody">
231 Same as <a name="idx:inpcethread1:1957"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>,
272 Same as <a id="idx:inpcethread1:1961"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>,
232273 but wait for <var>Goal</var> to be completed. Success depends on the
233274 success of executing <var>Goal</var>. Variable bindings inside <var>Goal</var>
234275 are visible to the caller, but it should be noted that the values are
235276 being <em>copied</em>. If <var>Goal</var> throws an exception, this
236 exception is re-thrown by <a name="idx:inpcethread1:1958"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>.
237 If the calling thread is the `pce thread', <a name="idx:inpcethreadsync1:1959"></a><a class="pred" href="mt-xpce.html#in_pce_thread_sync/1">in_pce_thread_sync/1</a>
238 executes a direct meta-call. See also <a name="idx:pcethread1:1960"></a><span class="pred-ext">pce_thread/1</span>.
239
240 <p>Note that <a name="idx:inpcethreadsync1:1961"></a><a class="pred" href="mt-xpce.html#in_pce_thread_sync/1">in_pce_thread_sync/1</a>
277 exception is re-thrown by <a id="idx:inpcethread1:1962"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>.
278 If the calling thread is the `pce thread', <a id="idx:inpcethreadsync1:1963"></a><a class="pred" href="mt-xpce.html#in_pce_thread_sync/1">in_pce_thread_sync/1</a>
279 executes a direct meta-call. See also <a id="idx:pcethread1:1964"></a><span class="pred-ext">pce_thread/1</span>.
280
281 <p>Note that <a id="idx:inpcethreadsync1:1965"></a><a class="pred" href="mt-xpce.html#in_pce_thread_sync/1">in_pce_thread_sync/1</a>
241282 is expensive because it requires copying and thread communication. For
242283 example, <code>in_pce_thread_synctrue</code> runs at approximately
243284 50,000 calls per second (AMD Phenom 9600B, Ubuntu 11.04).</dd>
244 <dt class="pubdef"><a name="pce_dispatch/1"><strong>pce_dispatch</strong>(<var>+Options</var>)</a></dt>
285 <dt class="pubdef"><a id="pce_dispatch/1"><strong>pce_dispatch</strong>(<var>+Options</var>)</a></dt>
245286 <dd class="defbody">
246287 Create a Prolog thread with the alias name <code>pce</code> for XPCE
247288 event handling. In the X11 version this call creates a thread that
248289 executes the X11 event-dispatch loop. In MS-Windows it creates a thread
249290 that executes a windows event-dispatch loop. The XPCE event-handling
250291 thread has the alias <code>pce</code>. <var>Options</var> specifies the
251 thread attributes as <a name="idx:threadcreate3:1962"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>.
292 thread attributes as <a id="idx:threadcreate3:1966"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>.
252293 </dd>
253294 </dl>
254295
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="overrule.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="reexport.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:mtoplevel"><a name="sec:6.6"><span class="sec-nr">6.6</span> <span class="sec-title">Interacting
235 <h2 id="sec:mtoplevel"><a id="sec:6.6"><span class="sec-nr">6.6</span> <span class="sec-title">Interacting
195236 with modules from the top level</span></a></h2>
196237
197 <a name="sec:mtoplevel"></a>
238 <a id="sec:mtoplevel"></a>
198239
199240 <p>Debugging often requires interaction with predicates that reside in
200241 modules: running them, setting spy points on them, etc. This can be
201242 achieved using the &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;
202243 construct explicitly as described above. In SWI-Prolog, you may also
203 wish to omit the module qualification. Setting a spy point (<a name="idx:spy1:1705"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
244 wish to omit the module qualification. Setting a spy point (<a id="idx:spy1:1709"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
204245 on a plain predicate sets a spy point on any predicate with that name in
205 any module. Editing (<a name="idx:edit1:1706"></a><a class="pred" href="edit.html#edit/1">edit/1</a>)
246 any module. Editing (<a id="idx:edit1:1710"></a><a class="pred" href="edit.html#edit/1">edit/1</a>)
206247 or calling an unqualified predicate invokes the DWIM (Do What I Mean)
207248 mechanism, which generally suggests the correct qualified query.
208249
209 <p>Mainly for compatibility, we provide <a name="idx:module1:1707"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>
250 <p>Mainly for compatibility, we provide <a id="idx:module1:1711"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>
210251 to switch the module with which the interactive top level interacts:
211252
212253 <dl class="latex">
213 <dt class="pubdef"><a name="module/1"><strong>module</strong>(<var>+Module</var>)</a></dt>
254 <dt class="pubdef"><a id="module/1"><strong>module</strong>(<var>+Module</var>)</a></dt>
214255 <dd class="defbody">
215256 The call <code>module(<var>Module</var>)</code> may be used to switch
216 the default working module for the interactive top level (see <a name="idx:prolog0:1708"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
257 the default working module for the interactive top level (see <a id="idx:prolog0:1712"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
217258 This may be used when debugging a module. The example below lists the
218 clauses of <a name="idx:fileoflabel2:1709"></a><span class="pred-ext">file_of_label/2</span>
259 clauses of <a id="idx:fileoflabel2:1713"></a><span class="pred-ext">file_of_label/2</span>
219260 in the module <code>tex</code>.
220261
221262 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="guitracer.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="xref.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:navigator"><a name="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">The
235 <h2 id="sec:navigator"><a id="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">The
195236 Prolog Navigator</span></a></h2>
196237
197 <a name="sec:navigator"></a>
238 <a id="sec:navigator"></a>
198239
199240 <p>Another tool is the <em>Prolog Navigator</em>. This tool can be
200241 started from PceEmacs using the command <strong>Browse/Prolog navigator</strong>,
201242 from the GUI debugger or using the programmatic IDE interface described
202243 in
203 <a class="sec" href="idepreds.html">section 3.8</a>.
244 <a class="sec" href="idepreds.html#sec:3.8">section 3.8</a>.
204245
205246 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.17</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.17</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="main.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="www_browser.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:nb_set"><a name="sec:A.17"><span class="sec-nr">A.17</span> <span class="sec-title">library(nb_set):
235 <h2 id="sec:nb_set"><a id="sec:A.17"><span class="sec-nr">A.17</span> <span class="sec-title">library(nb_set):
195236 Non-backtrackable set</span></a></h2>
196237
197 <a name="sec:nb_set"></a>
238 <a id="sec:nb_set"></a>
198239
199240 <p>The library <code>library(nb_set)</code> defines <em>non-backtrackable
200241 sets</em>, implemented as binary trees. The sets are represented as
201 compound terms and manipulated using <a name="idx:nbsetarg3:2145"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
242 compound terms and manipulated using <a id="idx:nbsetarg3:2149"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
202243 Non-backtrackable manipulation of datastructures is not supported by a
203244 large number of Prolog implementations, but it has several advantages
204245 over using the database. It produces less garbage, is thread-safe,
221262 </pre>
222263
223264 <dl class="latex">
224 <dt class="pubdef"><a name="empty_nb_set/1"><strong>empty_nb_set</strong>(<var>?Set</var>)</a></dt>
265 <dt class="pubdef"><a id="empty_nb_set/1"><strong>empty_nb_set</strong>(<var>?Set</var>)</a></dt>
225266 <dd class="defbody">
226267 True if <var>Set</var> is a non-backtrackable empty set.</dd>
227 <dt class="pubdef"><a name="add_nb_set/2"><strong>add_nb_set</strong>(<var>+Key,
268 <dt class="pubdef"><a id="add_nb_set/2"><strong>add_nb_set</strong>(<var>+Key,
228269 !Set</var>)</a></dt>
229270 <dd class="defbody">
230271 Add <var>Key</var> to <var>Set</var>. If <var>Key</var> is already a
231272 member of
232 <var>Set</var>, <a name="idx:addnbset3:2146"></a><a class="pred" href="nb_set.html#add_nb_set/3">add_nb_set/3</a>
273 <var>Set</var>, <a id="idx:addnbset3:2150"></a><a class="pred" href="nb_set.html#add_nb_set/3">add_nb_set/3</a>
233274 succeeds without modifying <var>Set</var>.</dd>
234 <dt class="pubdef"><a name="add_nb_set/3"><strong>add_nb_set</strong>(<var>+Key,
275 <dt class="pubdef"><a id="add_nb_set/3"><strong>add_nb_set</strong>(<var>+Key,
235276 !Set, ?New</var>)</a></dt>
236277 <dd class="defbody">
237278 If <var>Key</var> is not in <var>Set</var> and <var>New</var> is unified
240281 is in <var>Set</var>, <var>New</var> is unified to <code>false</code>.
241282 It can be used for many purposes:
242283
243 <p><table border="0" frame="void" rules="groups" style="margin:auto">
244 <tr valign="top"><td><code>add_nb_set(+, +, false)</code></td><td>Test
245 membership </td></tr>
246 <tr valign="top"><td><code>add_nb_set(+, +, true)</code></td><td>Succeed
247 only if new member </td></tr>
248 <tr valign="top"><td><code>add_nb_set(+, +, Var)</code></td><td>Succeed,
249 binding <var>Var</var> </td></tr>
284 <p><table class="latex frame-void center">
285 <tr><td><code>add_nb_set(+, +, false)</code></td><td>Test membership </td></tr>
286 <tr><td><code>add_nb_set(+, +, true)</code></td><td>Succeed only if new
287 member </td></tr>
288 <tr><td><code>add_nb_set(+, +, Var)</code></td><td>Succeed, binding <var>Var</var> </td></tr>
250289 </table>
251290 </dd>
252 <dt class="pubdef"><a name="gen_nb_set/2"><strong>gen_nb_set</strong>(<var>+Set,
291 <dt class="pubdef"><a id="gen_nb_set/2"><strong>gen_nb_set</strong>(<var>+Set,
253292 -Key</var>)</a></dt>
254293 <dd class="defbody">
255294 Generate all members of <var>Set</var> on backtracking in the standard
256 order of terms. To test membership, use <a name="idx:addnbset3:2147"></a><a class="pred" href="nb_set.html#add_nb_set/3">add_nb_set/3</a>.</dd>
257 <dt class="pubdef"><a name="size_nb_set/2"><strong>size_nb_set</strong>(<var>+Set,
295 order of terms. To test membership, use <a id="idx:addnbset3:2151"></a><a class="pred" href="nb_set.html#add_nb_set/3">add_nb_set/3</a>.</dd>
296 <dt class="pubdef"><a id="size_nb_set/2"><strong>size_nb_set</strong>(<var>+Set,
258297 -Size</var>)</a></dt>
259298 <dd class="defbody">
260299 Unify <var>Size</var> with the number of elements in <var>Set</var>.</dd>
261 <dt class="pubdef"><a name="nb_set_to_list/2"><strong>nb_set_to_list</strong>(<var>+Set,
300 <dt class="pubdef"><a id="nb_set_to_list/2"><strong>nb_set_to_list</strong>(<var>+Set,
262301 -List</var>)</a></dt>
263302 <dd class="defbody">
264303 Unify <var>List</var> with a list of all elements in <var>Set</var> in
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.25</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.25</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="chartype.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="charconv.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:operators"><a name="sec:4.25"><span class="sec-nr">4.25</span> <span class="sec-title">Operators</span></a></h2>
195
196 <a name="sec:operators"></a>
235 <h2 id="sec:operators"><a id="sec:4.25"><span class="sec-nr">4.25</span> <span class="sec-title">Operators</span></a></h2>
236
237 <a id="sec:operators"></a>
197238
198239 <p>Operators are defined to improve the readability of source code. For
199240 example, without operators, to write <code>2*3+4*5</code> one would have
201242 have been predefined. All operators, except for the comma (,) can be
202243 redefined by the user.
203244
204 <p><a name="idx:operatorandmodules:1314"></a>Some care has to be taken
245 <p><a id="idx:operatorandmodules:1314"></a>Some care has to be taken
205246 before defining new operators. Defining too many operators might make
206247 your source `natural' looking, but at the same time make it hard to
207248 understand the limits of your syntax. To ease the pain, as of SWI-Prolog
209250 Operators can be exported from modules using a term
210251 <code>op(Precedence, Type, Name)</code> in the export list as specified
211252 by
212 <a name="idx:module2:1315"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
253 <a id="idx:module2:1315"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
213254 Many modern Prolog systems have module specific operators.
214255 Unfortunately, there is no established interface for exporting and
215256 importing operators. SWI-Prolog's convention has been addopted by YAP.
230271 <p>In SWI-Prolog, a <em>quoted atom</em> never acts as an operator. Note
231272 that the portable way to stop an atom acting as an operator is to
232273 enclose it in parentheses like this: (myop). See also
233 <a class="sec" href="ext-syntax.html">section 5.3.1</a>.
274 <a class="sec" href="ext-syntax.html#sec:5.3.1">section 5.3.1</a>.
234275
235276 <dl class="latex">
236 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="op/3"><strong>op</strong>(<var>+Precedence,
277 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="op/3"><strong>op</strong>(<var>+Precedence,
237278 +Type, :Name</var>)</a></dt>
238279 <dd class="defbody">
239280 Declare <var>Name</var> to be an operator of type <var>Type</var> with
274315 </ul>
275316
276317 <p>In SWI-Prolog, operators are <em>local</em> to a module (see also
277 <a class="sec" href="moduleop.html">section 6.8</a>). Keeping operators
278 in modules and using controlled import/export of operators as described
279 with the <a name="idx:module2:1316"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
318 <a class="sec" href="moduleop.html#sec:6.8">section 6.8</a>). Keeping
319 operators in modules and using controlled import/export of operators as
320 described with the <a id="idx:module2:1316"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
280321 directive keep the issues manageable. The module <code>system</code>
281322 provides the operators from <a class="tab" href="operators.html#tab:operators">table
282323 5</a> and these operators cannot be modified. Files that are loaded from
285326 library and development system modules independent of operator changes
286327 to the <code>user</code> module.
287328
288 <p><table border="2" frame="box" rules="groups" style="margin:auto">
289 <tr valign="top"><td align=right>1200</td><td ALIGN=char CHAR=f>xfx</td><td><strong><code>--&gt;</code></strong>, <strong><code>:-</code></strong> </td></tr>
290 <tr valign="top"><td align=right>1200</td><td ALIGN=char CHAR=f>fx</td><td><strong><code>:-</code></strong>, <strong><code>?-</code></strong> </td></tr>
291 <tr valign="top"><td align=right>1150</td><td ALIGN=char CHAR=f>fx</td><td><strong>dynamic</strong>, <strong>discontiguous</strong>, <strong>initialization</strong>,
329 <p><table class="latex frame-box center">
330 <tr><td align=right>1200</td><td>xfx</td><td><strong><code>--&gt;</code></strong>, <strong><code>:-</code></strong> </td></tr>
331 <tr><td align=right>1200</td><td>fx</td><td><strong><code>:-</code></strong>, <strong><code>?-</code></strong> </td></tr>
332 <tr><td align=right>1150</td><td>fx</td><td><strong>dynamic</strong>, <strong>discontiguous</strong>, <strong>initialization</strong>,
292333 <strong>meta_predicate</strong>,
293334 <strong>module_transparent</strong>, <strong>multifile</strong>, <strong>public</strong>,
294335 <strong>thread_local</strong>, <strong>thread_initialization</strong>, <strong>volatile</strong> </td></tr>
295 <tr valign="top"><td align=right>1100</td><td ALIGN=char CHAR=f>xfy</td><td><strong><code>;</code></strong>, <strong><code>|</code></strong> </td></tr>
296 <tr valign="top"><td align=right>1050</td><td ALIGN=char CHAR=f>xfy</td><td><strong><code>-&gt;</code></strong>, <strong><code>*-&gt;</code></strong> </td></tr>
297 <tr valign="top"><td align=right>1000</td><td ALIGN=char CHAR=f>xfy</td><td><strong><code>,</code></strong> </td></tr>
298 <tr valign="top"><td align=right>990</td><td ALIGN=char CHAR=f>xfx</td><td><strong>:=</strong> </td></tr>
299 <tr valign="top"><td align=right>900</td><td ALIGN=char CHAR=f>fy</td><td><strong><code>\+</code></strong> </td></tr>
300 <tr valign="top"><td align=right>700</td><td ALIGN=char CHAR=f>xfx</td><td><strong><code>&lt;</code></strong>, <strong><code>=</code></strong>, <strong><code>=..</code></strong>, <strong><code>=@=</code></strong>, <strong><code>\=@=</code></strong>,
336 <tr><td align=right>1100</td><td>xfy</td><td><strong><code>;</code></strong>, <strong><code>|</code></strong> </td></tr>
337 <tr><td align=right>1050</td><td>xfy</td><td><strong><code>-&gt;</code></strong>, <strong><code>*-&gt;</code></strong> </td></tr>
338 <tr><td align=right>1000</td><td>xfy</td><td><strong><code>,</code></strong> </td></tr>
339 <tr><td align=right>990</td><td>xfx</td><td><strong>:=</strong> </td></tr>
340 <tr><td align=right>900</td><td>fy</td><td><strong><code>\+</code></strong> </td></tr>
341 <tr><td align=right>700</td><td>xfx</td><td><strong><code>&lt;</code></strong>, <strong><code>=</code></strong>, <strong><code>=..</code></strong>, <strong><code>=@=</code></strong>, <strong><code>\=@=</code></strong>,
301342 <strong><code>=:=</code></strong>, <strong><code>=&lt;</code></strong>, <strong><code>==</code></strong>,
302343 <strong><code>=\=</code></strong>, <strong><code>&gt;</code></strong>, <strong><code>&gt;=</code></strong>, <strong><code>@&lt;</code></strong>, <strong><code>@=&lt;</code></strong>, <strong><code>@&gt;</code></strong>,
303344 <strong><code>@&gt;=</code></strong>, <strong><code>\=</code></strong>, <strong><code>\==</code></strong>, <strong>as</strong>, <strong>is</strong>,
304345 <strong><code>&gt;:&lt;</code></strong>, <strong><code>:&lt;</code></strong>
305346 </td></tr>
306 <tr valign="top"><td align=right>600</td><td ALIGN=char CHAR=f>xfy</td><td><strong><code>:</code></strong> </td></tr>
307 <tr valign="top"><td align=right>500</td><td ALIGN=char CHAR=f>yfx</td><td><strong><code>+</code></strong>, <strong><code>-</code></strong>, <strong><code>/\</code></strong>, <strong><code>\/</code></strong>, <strong>xor</strong> </td></tr>
308 <tr valign="top"><td align=right>500</td><td ALIGN=char CHAR=f>fx</td><td><strong><code>?</code></strong> </td></tr>
309 <tr valign="top"><td align=right>400</td><td ALIGN=char CHAR=f>yfx</td><td><strong><code>*</code></strong>, <strong><code>/</code></strong>, <strong><code>//</code></strong>, <strong>div</strong>, <strong>rdiv</strong>,
347 <tr><td align=right>600</td><td>xfy</td><td><strong><code>:</code></strong> </td></tr>
348 <tr><td align=right>500</td><td>yfx</td><td><strong><code>+</code></strong>, <strong><code>-</code></strong>, <strong><code>/\</code></strong>, <strong><code>\/</code></strong>, <strong>xor</strong> </td></tr>
349 <tr><td align=right>500</td><td>fx</td><td><strong><code>?</code></strong> </td></tr>
350 <tr><td align=right>400</td><td>yfx</td><td><strong><code>*</code></strong>, <strong><code>/</code></strong>, <strong><code>//</code></strong>, <strong>div</strong>, <strong>rdiv</strong>,
310351 <strong><code>&lt;&lt;</code></strong>, <strong><code>&gt;&gt;</code></strong>, <strong>mod</strong>, <strong>rem</strong> </td></tr>
311 <tr valign="top"><td align=right>200</td><td ALIGN=char CHAR=f>xfx</td><td><strong><code>**</code></strong> </td></tr>
312 <tr valign="top"><td align=right>200</td><td ALIGN=char CHAR=f>xfy</td><td><strong><code>^</code></strong> </td></tr>
313 <tr valign="top"><td align=right>200</td><td ALIGN=char CHAR=f>fy</td><td><strong><code>+</code></strong>, <strong><code>-</code></strong>, <strong><code>\</code></strong> </td></tr>
314 <tr valign="top"><td align=right>100</td><td ALIGN=char CHAR=f>yfx</td><td><strong><code>.</code></strong> </td></tr>
315 <tr valign="top"><td align=right>1</td><td ALIGN=char CHAR=f>fx</td><td><strong><code>$</code></strong> </td></tr>
352 <tr><td align=right>200</td><td>xfx</td><td><strong><code>**</code></strong> </td></tr>
353 <tr><td align=right>200</td><td>xfy</td><td><strong><code>^</code></strong> </td></tr>
354 <tr><td align=right>200</td><td>fy</td><td><strong><code>+</code></strong>, <strong><code>-</code></strong>, <strong><code>\</code></strong> </td></tr>
355 <tr><td align=right>100</td><td>yfx</td><td><strong><code>.</code></strong> </td></tr>
356 <tr><td align=right>1</td><td>fx</td><td><strong><code>$</code></strong> </td></tr>
316357 </table>
317358 <div class="caption"><b>Table 5 : </b>System operators</div>
318 <a name="tab:operators"></a>
359 <a id="tab:operators"></a>
319360 </dd>
320 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_op/3"><strong>current_op</strong>(<var>?Precedence,
361 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_op/3"><strong>current_op</strong>(<var>?Precedence,
321362 ?Type, ?:Name</var>)</a></dt>
322363 <dd class="defbody">
323364 True if <var>Name</var> is currently defined as an operator of type <var>Type</var>
324 with precedence <var>Precedence</var>. See also <a name="idx:op3:1317"></a><a class="pred" href="operators.html#op/3">op/3</a>.
365 with precedence <var>Precedence</var>. See also <a id="idx:op3:1317"></a><a class="pred" href="operators.html#op/3">op/3</a>.
325366 </dd>
326367 </dl>
327368
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section F.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="funcsummary.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="Bibliography.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:opsummary"><a name="sec:F.4"><span class="sec-nr">F.4</span> <span class="sec-title">Operators</span></a></h2>
195
196 <a name="sec:opsummary"></a>
235 <h2 id="sec:opsummary"><a id="sec:F.4"><span class="sec-nr">F.4</span> <span class="sec-title">Operators</span></a></h2>
236
237 <a id="sec:opsummary"></a>
197238 <table>
198239 <tr><td>1</td><td>fx</td><td>$</td><td>Bind top-level variable</td></tr>
199240 <tr><td>200</td><td>xfy</td><td>^</td><td>Existential qualification</td></tr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.19</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.19</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="www_browser.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="optparse.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:option"><a name="sec:A.19"><span class="sec-nr">A.19</span> <span class="sec-title">library(option):
235 <h2 id="sec:option"><a id="sec:A.19"><span class="sec-nr">A.19</span> <span class="sec-title">library(option):
195236 Option list processing</span></a></h2>
196237
197 <p><a name="sec:option"></a>
238 <p><a id="sec:option"></a>
198239
199240 <dl class="tags">
200241 <dt class="mtag">See also</dt>
263304 </ul>
264305
265306 <dl class="latex">
266 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="option/3"><strong>option</strong>(<var>?Option,
307 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="option/3"><strong>option</strong>(<var>?Option,
267308 +OptionList, +Default</var>)</a></dt>
268309 <dd class="defbody">
269310 Get an <var>Option</var> from <var>OptionList</var>. <var>OptionList</var>
270311 can use the Name=Value as well as the Name(Value) convention.
271312 <table class="arglist">
272 <tr valign="top"><td><var>Option</var> </td><td>Term of the form
273 Name(?Value). </td></tr>
313 <tr><td><var>Option</var> </td><td>Term of the form Name(?Value). </td></tr>
274314 </table>
275315 </dd>
276 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="option/2"><strong>option</strong>(<var>?Option,
316 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="option/2"><strong>option</strong>(<var>?Option,
277317 +OptionList</var>)</a></dt>
278318 <dd class="defbody">
279319 Get an <var>Option</var> from <var>OptionList</var>. <var>OptionList</var>
280320 can use the Name=Value as well as the Name(Value) convention. Fails
281321 silently if the option does not appear in <var>OptionList</var>.
282322 <table class="arglist">
283 <tr valign="top"><td><var>Option</var> </td><td>Term of the form
284 Name(?Value). </td></tr>
323 <tr><td><var>Option</var> </td><td>Term of the form Name(?Value). </td></tr>
285324 </table>
286325 </dd>
287 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="select_option/3"><strong>select_option</strong>(<var>?Option,
326 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="select_option/3"><strong>select_option</strong>(<var>?Option,
288327 +Options, -RestOptions</var>)</a></dt>
289328 <dd class="defbody">
290329 Get and remove <var>Option</var> from an option list. As <a class="pred" href="option.html#option/2">option/2</a>,
291330 removing the matching option from <var>Options</var> and unifying the
292331 remaining options with <var>RestOptions</var>.</dd>
293 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="select_option/4"><strong>select_option</strong>(<var>?Option,
332 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="select_option/4"><strong>select_option</strong>(<var>?Option,
294333 +Options, -RestOptions, +Default</var>)</a></dt>
295334 <dd class="defbody">
296335 Get and remove <var>Option</var> with default value. As <a class="pred" href="option.html#select_option/3">select_option/3</a>,
297336 but if <var>Option</var> is not in <var>Options</var>, its value is
298337 unified with
299338 <var>Default</var> and <var>RestOptions</var> with <var>Options</var>.</dd>
300 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="merge_options/3"><strong>merge_options</strong>(<var>+New,
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="merge_options/3"><strong>merge_options</strong>(<var>+New,
301340 +Old, -Merged</var>)</a></dt>
302341 <dd class="defbody">
303342 Merge two option lists. <var>Merged</var> is a sorted list of options
307346 <p>Multi-values options (e.g., <code>proxy(Host, Port)</code>) are
308347 allowed, where both option-name and arity define the identity of the
309348 option.</dd>
310 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="meta_options/3"><strong>meta_options</strong>(<var>+IsMeta,
349 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="meta_options/3"><strong>meta_options</strong>(<var>+IsMeta,
311350 :Options0, -Options</var>)</a></dt>
312351 <dd class="defbody">
313352 Perform meta-expansion on options that are module-sensitive. Whether an
333372 </dl>
334373
335374 </dd>
336 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="dict_options/2"><strong>dict_options</strong>(<var>?Dict,
375 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="dict_options/2"><strong>dict_options</strong>(<var>?Dict,
337376 ?Options</var>)</a></dt>
338377 <dd class="defbody">
339378 Convert between an option list and a dictionary. One of the arguments
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.20</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.20</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="option.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ordsets.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:optparse"><a name="sec:A.20"><span class="sec-nr">A.20</span> <span class="sec-title">library(optparse):
235 <h2 id="sec:optparse"><a id="sec:A.20"><span class="sec-nr">A.20</span> <span class="sec-title">library(optparse):
195236 command line parsing</span></a></h2>
196237
197 <p><a name="sec:optparse"></a>
238 <p><a id="sec:optparse"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">author</dt>
480521 <p>This representation may be preferable with the empty-flag
481522 configuration parameter style above (perhaps with asserting <span class="pred-ext">appl_config/2</span>).
482523
483 <p><h3 id="sec:optparse-notes"><a name="sec:A.20.1"><span class="sec-nr">A.20.1</span> <span class="sec-title">Notes
524 <p><h3 id="sec:optparse-notes"><a id="sec:A.20.1"><span class="sec-nr">A.20.1</span> <span class="sec-title">Notes
484525 and tips</span></a></h3>
485526
486 <p><a name="sec:optparse-notes"></a>
527 <p><a id="sec:optparse-notes"></a>
487528
488529 <p>
489530 <ul class="latex">
520561 </ul>
521562
522563 <dl class="latex">
523 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_arguments/3"><strong>opt_arguments</strong>(<var>+OptsSpec,
564 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_arguments/3"><strong>opt_arguments</strong>(<var>+OptsSpec,
524565 -Opts, -PositionalArgs</var>)</a></dt>
525566 <dd class="defbody">
526567 Extract commandline options according to a specification. Convenience
539580 they may go anywhere (although it is good practice to put them last).
540581 Any leading arguments for the runtime (up to and including '--') are
541582 discarded.</dd>
542 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_parse/4"><strong>opt_parse</strong>(<var>+OptsSpec,
583 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_parse/4"><strong>opt_parse</strong>(<var>+OptsSpec,
543584 +ApplArgs, -Opts, -PositionalArgs</var>)</a></dt>
544585 <dd class="defbody">
545586 Equivalent to <code>opt_parse(OptsSpec, ApplArgs, Opts, PositionalArgs, [])</code>.</dd>
546 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_parse/5"><strong>opt_parse</strong>(<var>+OptsSpec,
587 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_parse/5"><strong>opt_parse</strong>(<var>+OptsSpec,
547588 +ApplArgs, -Opts, -PositionalArgs, +ParseOptions</var>)</a></dt>
548589 <dd class="defbody">
549590 Parse the arguments Args (as list of atoms) according to <var>OptsSpec</var>.
589630 </dl>
590631
591632 </dd>
592 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_help/2"><strong>opt_help</strong>(<var>+OptsSpec,
633 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_help/2"><strong>opt_help</strong>(<var>+OptsSpec,
593634 -Help:atom</var>)</a></dt>
594635 <dd class="defbody">
595636 True when <var>Help</var> is a help string synthesized from <var>OptsSpec</var>.</dd>
596 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="parse_type/3"><strong>parse_type</strong>(<var>+Type,
637 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="parse_type/3"><strong>parse_type</strong>(<var>+Type,
597638 +Codes:list(code), -Result</var>)</a></dt>
598639 <dd class="defbody">
599640 Hook to parse option text <var>Codes</var> to an object of type <var>Type</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.21</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.21</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="optparse.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="pairs.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ordsets"><a name="sec:A.21"><span class="sec-nr">A.21</span> <span class="sec-title">library(ordsets):
235 <h2 id="sec:ordsets"><a id="sec:A.21"><span class="sec-nr">A.21</span> <span class="sec-title">library(ordsets):
195236 Ordered set manipulation</span></a></h2>
196237
197 <p><a name="sec:ordsets"></a>
238 <p><a id="sec:ordsets"></a>
198239
199240 <p>Ordered sets are lists with unique elements sorted to the standard
200241 order of terms (see <a class="pred" href="builtinlist.html#sort/2">sort/2</a>).
225266 as an ordset because the order it relies on may have been changed.
226267
227268 <dl class="latex">
228 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_ordset/1"><strong>is_ordset</strong>(<var>@Term</var>)</a></dt>
269 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_ordset/1"><strong>is_ordset</strong>(<var>@Term</var>)</a></dt>
229270 <dd class="defbody">
230271 True if <var>Term</var> is an ordered set. All predicates in this
231272 library expect ordered sets as input arguments. Failing to fullfil this
233274 created by predicates from this library, <a class="pred" href="builtinlist.html#sort/2">sort/2</a>
234275 or
235276 <a class="pred" href="allsolutions.html#setof/3">setof/3</a>.</dd>
236 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_empty/1"><strong>ord_empty</strong>(<var>?List</var>)</a></dt>
277 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_empty/1"><strong>ord_empty</strong>(<var>?List</var>)</a></dt>
237278 <dd class="defbody">
238279 True when <var>List</var> is the empty ordered set. Simply unifies list
239280 with the empty list. Not part of Quintus.</dd>
240 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_seteq/2"><strong>ord_seteq</strong>(<var>+Set1,
281 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_seteq/2"><strong>ord_seteq</strong>(<var>+Set1,
241282 +Set2</var>)</a></dt>
242283 <dd class="defbody">
243284 True if <var>Set1</var> and <var>Set2</var> have the same elements. As
251292 </dl>
252293
253294 </dd>
254 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_to_ord_set/2"><strong>list_to_ord_set</strong>(<var>+List,
295 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_to_ord_set/2"><strong>list_to_ord_set</strong>(<var>+List,
255296 -OrdSet</var>)</a></dt>
256297 <dd class="defbody">
257298 Transform a list into an ordered set. This is the same as sorting the
258299 list.</dd>
259 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_intersect/2"><strong>ord_intersect</strong>(<var>+Set1,
300 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_intersect/2"><strong>ord_intersect</strong>(<var>+Set1,
260301 +Set2</var>)</a></dt>
261302 <dd class="defbody">
262303 True if both ordered sets have a non-empty intersection.</dd>
263 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_disjoint/2"><strong>ord_disjoint</strong>(<var>+Set1,
304 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_disjoint/2"><strong>ord_disjoint</strong>(<var>+Set1,
264305 +Set2</var>)</a></dt>
265306 <dd class="defbody">
266307 True if <var>Set1</var> and <var>Set2</var> have no common elements.
267308 This is the negation of <a class="pred" href="ordsets.html#ord_intersect/2">ord_intersect/2</a>.</dd>
268 <dt class="pubdef"><a name="ord_intersect/3"><strong>ord_intersect</strong>(<var>+Set1,
309 <dt class="pubdef"><a id="ord_intersect/3"><strong>ord_intersect</strong>(<var>+Set1,
269310 +Set2, -Intersection</var>)</a></dt>
270311 <dd class="defbody">
271312 <var>Intersection</var> holds the common elements of <var>Set1</var> and <var>Set2</var>.
278319 </dl>
279320
280321 </dd>
281 <dt class="pubdef"><a name="ord_intersection/2"><strong>ord_intersection</strong>(<var>+PowerSet,
322 <dt class="pubdef"><a id="ord_intersection/2"><strong>ord_intersection</strong>(<var>+PowerSet,
282323 -Intersection</var>)</a></dt>
283324 <dd class="defbody">
284325 <var>Intersection</var> of a powerset. True when <var>Intersection</var>
292333 </dl>
293334
294335 </dd>
295 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_intersection/3"><strong>ord_intersection</strong>(<var>+Set1,
336 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_intersection/3"><strong>ord_intersection</strong>(<var>+Set1,
296337 +Set2, -Intersection</var>)</a></dt>
297338 <dd class="defbody">
298339 <var>Intersection</var> holds the common elements of <var>Set1</var> and <var>Set2</var>.
299340 Uses
300341 <a class="pred" href="ordsets.html#ord_disjoint/2">ord_disjoint/2</a> if <var>Intersection</var>
301342 is bound to <code>[]</code> on entry.</dd>
302 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_intersection/4"><strong>ord_intersection</strong>(<var>+Set1,
343 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_intersection/4"><strong>ord_intersection</strong>(<var>+Set1,
303344 +Set2, ?Intersection, ?Difference</var>)</a></dt>
304345 <dd class="defbody">
305346 <var>Intersection</var> and difference between two ordered sets.
316357 </dl>
317358
318359 </dd>
319 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_add_element/3"><strong>ord_add_element</strong>(<var>+Set1,
360 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_add_element/3"><strong>ord_add_element</strong>(<var>+Set1,
320361 +Element, ?Set2</var>)</a></dt>
321362 <dd class="defbody">
322363 Insert an element into the set. This is the same as
323364 <code>ord_union(Set1, [Element], Set2)</code>.</dd>
324 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_del_element/3"><strong>ord_del_element</strong>(<var>+Set,
365 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_del_element/3"><strong>ord_del_element</strong>(<var>+Set,
325366 +Element, -NewSet</var>)</a></dt>
326367 <dd class="defbody">
327368 Delete an element from an ordered set. This is the same as
328369 <code>ord_subtract(Set, [Element], NewSet)</code>.</dd>
329 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_selectchk/3"><strong>ord_selectchk</strong>(<var>+Item,
370 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_selectchk/3"><strong>ord_selectchk</strong>(<var>+Item,
330371 ?Set1, ?Set2</var>)</a></dt>
331372 <dd class="defbody">
332373 Selectchk/3, specialised for ordered sets. Is true when
346387 </dl>
347388
348389 </dd>
349 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_memberchk/2"><strong>ord_memberchk</strong>(<var>+Element,
390 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_memberchk/2"><strong>ord_memberchk</strong>(<var>+Element,
350391 +OrdSet</var>)</a></dt>
351392 <dd class="defbody">
352393 True if <var>Element</var> is a member of <var>OrdSet</var>, compared
370411 </dl>
371412
372413 </dd>
373 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_subset/2"><strong>ord_subset</strong>(<var>+Sub,
414 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_subset/2"><strong>ord_subset</strong>(<var>+Sub,
374415 +Super</var>)</a></dt>
375416 <dd class="defbody">
376417 Is true if all elements of <var>Sub</var> are in <var>Super</var></dd>
377 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_subtract/3"><strong>ord_subtract</strong>(<var>+InOSet,
418 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_subtract/3"><strong>ord_subtract</strong>(<var>+InOSet,
378419 +NotInOSet, -Diff</var>)</a></dt>
379420 <dd class="defbody">
380421 <var>Diff</var> is the set holding all elements of <var>InOSet</var>
381422 that are not in
382423 <var>NotInOSet</var>.</dd>
383 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_union/2"><strong>ord_union</strong>(<var>+SetOfSets,
424 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_union/2"><strong>ord_union</strong>(<var>+SetOfSets,
384425 -Union</var>)</a></dt>
385426 <dd class="defbody">
386427 True if <var>Union</var> is the union of all elements in the superset
395436 </dl>
396437
397438 </dd>
398 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_union/3"><strong>ord_union</strong>(<var>+Set1,
439 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_union/3"><strong>ord_union</strong>(<var>+Set1,
399440 +Set2, ?Union</var>)</a></dt>
400441 <dd class="defbody">
401442 <var>Union</var> is the union of <var>Set1</var> and <var>Set2</var></dd>
402 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_union/4"><strong>ord_union</strong>(<var>+Set1,
443 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_union/4"><strong>ord_union</strong>(<var>+Set1,
403444 +Set2, -Union, -New</var>)</a></dt>
404445 <dd class="defbody">
405446 True iff <code>ord_union(Set1, Set2, Union)</code> and
406447 <code>ord_subtract(Set2, Set1, New)</code>.</dd>
407 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_symdiff/3"><strong>ord_symdiff</strong>(<var>+Set1,
448 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_symdiff/3"><strong>ord_symdiff</strong>(<var>+Set1,
408449 +Set2, ?Difference</var>)</a></dt>
409450 <dd class="defbody">
410451 Is true when <var>Difference</var> is the symmetric difference of <var>Set1</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section E.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section E.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="softlicense.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="summary.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:otherlicenses"><a name="sec:E.3"><span class="sec-nr">E.3</span> <span class="sec-title">License
235 <h2 id="sec:otherlicenses"><a id="sec:E.3"><span class="sec-nr">E.3</span> <span class="sec-title">License
195236 conditions inherited from used code</span></a></h2>
196237
197 <a name="sec:otherlicenses"></a>
198
199 <p><h3 id="sec:cryptlicense"><a name="sec:E.3.1"><span class="sec-nr">E.3.1</span> <span class="sec-title">Cryptographic
238 <a id="sec:otherlicenses"></a>
239
240 <p><h3 id="sec:cryptlicense"><a id="sec:E.3.1"><span class="sec-nr">E.3.1</span> <span class="sec-title">Cryptographic
200241 routines</span></a></h3>
201242
202 <a name="sec:cryptlicense"></a>
203
204 <p>Cryptographic routines are used in <a name="idx:variantsha12:2344"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>
243 <a id="sec:cryptlicense"></a>
244
245 <p>Cryptographic routines are used in <a id="idx:variantsha12:2348"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>
205246 and <code>library(crypt)</code>. These routines are provided under the
206247 following conditions:
207248
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="metapred.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="mtoplevel.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:overrule"><a name="sec:6.5"><span class="sec-nr">6.5</span> <span class="sec-title">Overruling
235 <h2 id="sec:overrule"><a id="sec:6.5"><span class="sec-nr">6.5</span> <span class="sec-title">Overruling
195236 Module Boundaries</span></a></h2>
196237
197 <a name="sec:overrule"></a>
238 <a id="sec:overrule"></a>
198239
199240 <p>The module system described so far is sufficient to distribute
200241 programs over multiple modules. There are, however, cases in which we
206247 cannot be achieved using importing because importing a predicate with
207248 the same name and arity from two modules results in a name conflict.
208249 Asserting in a different module can be used to create models dynamically
209 in a new module. See <a class="sec" href="dynamic-modules.html">section
250 in a new module. See <a class="sec" href="dynamic-modules.html#sec:6.12">section
210251 6.12</a>.
211252
212253 <p>Direct addressing of modules is achieved using a <code><code>:</code>/2</code>
213254 explicitly in a program and relies on the module qualification mechanism
214 described in <a class="sec" href="metapred.html">section 6.4</a>. Here
215 are a few examples:
255 described in <a class="sec" href="metapred.html#sec:6.4">section 6.4</a>.
256 Here are a few examples:
216257
217258 <pre class="code">
218259 ?- assert(world:done). % asserts done/0 into module world
222263
223264 <p>Note that the second example is the same due to the Prolog flag
224265 <a class="flag" href="flags.html#flag:colon_sets_calling_context">colon_sets_calling_context</a>.
225 The system predicate <a name="idx:asserta1:1702"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
266 The system predicate <a id="idx:asserta1:1706"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
226267 is called in the module <code>world</code>, which is possible because
227268 system predicates are <em>visible</em> in all modules. At the same time,
228269 the
230271 arguments are qualified with the calling context, the resulting call is
231272 the same as the first example.
232273
233 <p><h3 id="sec:set-calling-context"><a name="sec:6.5.1"><span class="sec-nr">6.5.1</span> <span class="sec-title">Explicit
274 <p><h3 id="sec:set-calling-context"><a id="sec:6.5.1"><span class="sec-nr">6.5.1</span> <span class="sec-title">Explicit
234275 manipulation of the calling context</span></a></h3>
235276
236 <a name="sec:set-calling-context"></a>
277 <a id="sec:set-calling-context"></a>
237278
238279 <p>Quintus' derived module systems have no means to separate the lookup
239280 module (for finding predicates) from the calling context (for qualifying
243284 currently mainly to support compatibility layers.
244285
245286 <dl class="latex">
246 <dt class="pubdef"><a name="@/2"><strong>@</strong>(<var>:Goal, +Module</var>)</a></dt>
287 <dt class="pubdef"><a id="@/2"><strong>@</strong>(<var>:Goal, +Module</var>)</a></dt>
247288 <dd class="defbody">
248289 Execute <var>Goal</var>, setting the calling context to <var>Module</var>.
249290 Setting the calling context affects meta-predicates, for which meta
250291 arguments are qualified with <var>Module</var> and transparent
251292 predicates (see
252 <a name="idx:moduletransparent1:1703"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>).
293 <a id="idx:moduletransparent1:1707"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>).
253294 It has no implications for other predicates.
254295
255296 <p>For example, the code <code>asserta(done)@world</code> is the same as
256297 <code>asserta(world:done)</code>. Unlike in <code>world:asserta(done)</code>,
257 <a name="idx:asserta1:1704"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
298 <a id="idx:asserta1:1708"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
258299 is resolved in the current module rather than the module
259300 <code>world</code>. This makes no difference for system predicates, but
260301 usually does make a difference for user predicates.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="acknowledge.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="quickstart.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:overview"><a name="sec:2"><span class="sec-nr">2</span> <span class="sec-title">Overview</span></a></h1>
195
196 <a name="sec:overview"></a>
235 <h1 id="sec:overview"><a id="sec:2"><span class="sec-nr">2</span> <span class="sec-title">Overview</span></a></h1>
236
237 <a id="sec:overview"></a>
197238
198239 <p>
199240 <hr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.14</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="autoload.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="gc.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:packs"><a name="sec:2.14"><span class="sec-nr">2.14</span> <span class="sec-title">Packs:
235 <h2 id="sec:packs"><a id="sec:2.14"><span class="sec-nr">2.14</span> <span class="sec-title">Packs:
195236 community add-ons</span></a></h2>
196237
197 <a name="sec:packs"></a>
238 <a id="sec:packs"></a>
198239
199240 <p>SWI-Prolog has a mechanism for easy incorporation of community
200 extensions. See the http://www.swi-prolog.org/pack/listpack landing page
201 for details and available packs. This section documents the built-in
202 predicates to attach packs. Predicates for creating, registering and
203 installing packs are provided by the library
241 extensions. See the <a class="url" href="http://www.swi-prolog.org/pack/list">pack
242 landing page</a> for details and available packs. This section documents
243 the built-in predicates to attach packs. Predicates for creating,
244 registering and installing packs are provided by the library
204245 <code>library(prolog_pack)</code>.
205246
206247 <dl class="latex">
207 <dt class="pubdef"><a name="attach_packs/0"><strong>attach_packs</strong></a></dt>
248 <dt class="pubdef"><a id="attach_packs/0"><strong>attach_packs</strong></a></dt>
208249 <dd class="defbody">
209250 Attaches all packs in subdirectories of directories that are accessible
210 through the <em>file search path</em> (see <a name="idx:absolutefilename3:208"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>)
251 through the <em>file search path</em> (see <a id="idx:absolutefilename3:208"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>)
211252 <code>pack</code>. The default for this search path is:
212253
213254 <pre class="code">
215256 user:file_search_path(pack, swi(pack)).
216257 </pre>
217258
218 <p>The predicate <a name="idx:attachpacks0:209"></a><a class="pred" href="packs.html#attach_packs/0">attach_packs/0</a>
259 <p>The predicate <a id="idx:attachpacks0:209"></a><a class="pred" href="packs.html#attach_packs/0">attach_packs/0</a>
219260 is called on startup of SWI-Prolog.</dd>
220 <dt class="pubdef"><a name="attach_packs/1"><strong>attach_packs</strong>(<var>+Directory</var>)</a></dt>
261 <dt class="pubdef"><a id="attach_packs/1"><strong>attach_packs</strong>(<var>+Directory</var>)</a></dt>
221262 <dd class="defbody">
222263 Attach all packs in subdirectories of <var>Directory</var>. Same as
223264 <code>attach_packs(Directory,[])</code>.
224265 </dd>
225 <dt class="pubdef"><a name="attach_packs/2"><strong>attach_packs</strong>(<var>+Directory,
266 <dt class="pubdef"><a id="attach_packs/2"><strong>attach_packs</strong>(<var>+Directory,
226267 +Options</var>)</a></dt>
227268 <dd class="defbody">
228269 Attach all packs in subdirectories of <var>Directory</var>. Options is
244285 </dd>
245286 </dl>
246287
247 <p>The predicate <a name="idx:attachpacks2:210"></a><a class="pred" href="packs.html#attach_packs/2">attach_packs/2</a>
288 <p>The predicate <a id="idx:attachpacks2:210"></a><a class="pred" href="packs.html#attach_packs/2">attach_packs/2</a>
248289 can be used to attach packages that are bundled with an application.
249290 </dd>
250291 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.22</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.22</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ordsets.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="persistency.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:pairs"><a name="sec:A.22"><span class="sec-nr">A.22</span> <span class="sec-title">library(pairs):
235 <h2 id="sec:pairs"><a id="sec:A.22"><span class="sec-nr">A.22</span> <span class="sec-title">library(pairs):
195236 Operations on key-value lists</span></a></h2>
196237
197 <p><a name="sec:pairs"></a>
238 <p><a id="sec:pairs"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">author</dt>
218259 O'Keefe.
219260
220261 <dl class="latex">
221 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pairs_keys_values/3"><strong>pairs_keys_values</strong>(<var>?Pairs,
262 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pairs_keys_values/3"><strong>pairs_keys_values</strong>(<var>?Pairs,
222263 ?Keys, ?Values</var>)</a></dt>
223264 <dd class="defbody">
224265 True if <var>Keys</var> holds the keys of <var>Pairs</var> and <var>Values</var>
236277 </dl>
237278
238279 </dd>
239 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pairs_values/2"><strong>pairs_values</strong>(<var>+Pairs,
280 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pairs_values/2"><strong>pairs_values</strong>(<var>+Pairs,
240281 -Values</var>)</a></dt>
241282 <dd class="defbody">
242283 Remove the keys from a list of Key-Value pairs. Same as
243284 <code>pairs_keys_values(Pairs, _, Values)</code></dd>
244 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pairs_keys/2"><strong>pairs_keys</strong>(<var>+Pairs,
285 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pairs_keys/2"><strong>pairs_keys</strong>(<var>+Pairs,
245286 -Keys</var>)</a></dt>
246287 <dd class="defbody">
247288 Remove the values from a list of Key-Value pairs. Same as
248289 <code>pairs_keys_values(Pairs, Keys, _)</code></dd>
249 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="group_pairs_by_key/2"><strong>group_pairs_by_key</strong>(<var>+Pairs,
290 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="group_pairs_by_key/2"><strong>group_pairs_by_key</strong>(<var>+Pairs,
250291 -Joined:list(Key-Values)</var>)</a></dt>
251292 <dd class="defbody">
252293 Group values with equivalent (<a class="pred" href="compare.html#==/2">==/2</a>)
273314 is 1) ensures that the order of the values in the original list of pairs
274315 is maintained.
275316 <table class="arglist">
276 <tr valign="top"><td><var>Pairs</var> </td><td><var>Key</var>-Value list </td></tr>
277 <tr valign="top"><td><var>Joined</var> </td><td>List of <var>Key</var>-Group,
278 where Group is the list of <var>Values</var> associated with equivalent
317 <tr><td><var>Pairs</var> </td><td><var>Key</var>-Value list </td></tr>
318 <tr><td><var>Joined</var> </td><td>List of <var>Key</var>-Group, where
319 Group is the list of <var>Values</var> associated with equivalent
279320 consecutive Keys in the same order as they appear in <var>Pairs</var>. </td></tr>
280321 </table>
281322 </dd>
282 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="transpose_pairs/2"><strong>transpose_pairs</strong>(<var>+Pairs,
323 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="transpose_pairs/2"><strong>transpose_pairs</strong>(<var>+Pairs,
283324 -Transposed</var>)</a></dt>
284325 <dd class="defbody">
285326 Swap Key-Value to Value-Key. The resulting list is sorted using
286327 <a class="pred" href="builtinlist.html#keysort/2">keysort/2</a> on the
287328 new key.</dd>
288 <dt class="pubdef"><a name="map_list_to_pairs/3"><strong>map_list_to_pairs</strong>(<var>:Function,
329 <dt class="pubdef"><a id="map_list_to_pairs/3"><strong>map_list_to_pairs</strong>(<var>:Function,
289330 +List, -Keyed</var>)</a></dt>
290331 <dd class="defbody">
291332 Create a Key-Value list by mapping each element of <var>List</var>. For
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="editreload.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="guitracer.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:pceemacs"><a name="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Using
235 <h2 id="sec:pceemacs"><a id="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Using
195236 the PceEmacs built-in editor</span></a></h2>
196237
197 <a name="sec:pceemacs"></a>
198
199 <p><h3 id="sec:runpceemacs"><a name="sec:3.4.1"><span class="sec-nr">3.4.1</span> <span class="sec-title">Activating
238 <a id="sec:pceemacs"></a>
239
240 <p><h3 id="sec:runpceemacs"><a id="sec:3.4.1"><span class="sec-nr">3.4.1</span> <span class="sec-title">Activating
200241 PceEmacs</span></a></h3>
201242
202 <a name="sec:runpceemacs"></a>
203
204 <p>Initially <a name="idx:edit1:309"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
243 <a id="sec:runpceemacs"></a>
244
245 <p>Initially <a id="idx:edit1:309"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
205246 uses the editor specified in the <code>EDITOR</code> environment
206247 variable. There are two ways to force it to use the built-in editor. One
207248 is to set the Prolog flag <a class="flag" href="flags.html#flag:editor">editor</a>
208249 to
209250 <code>pce_emacs</code> and the other is by starting the editor
210 explicitly using the emacs[0,1] predicates.
211
212 <p><h3 id="sec:emacsbluff"><a name="sec:3.4.2"><span class="sec-nr">3.4.2</span> <span class="sec-title">Bluffing
251 explicitly using the emacs/[0,1] predicates.
252
253 <p><h3 id="sec:emacsbluff"><a id="sec:3.4.2"><span class="sec-nr">3.4.2</span> <span class="sec-title">Bluffing
213254 through PceEmacs</span></a></h3>
214255
215 <a name="sec:emacsbluff"></a>
256 <a id="sec:emacsbluff"></a>
216257
217258 <p>PceEmacs closely mimics Richard Stallman's GNU-Emacs commands, adding
218259 features from modern window-based editors to make it more acceptable for
222263 important GNU-Emacs commands.</span></sup>
223264
224265 <p>At the basis, PceEmacs maps keyboard sequences to methods defined on
225 the extended object. Some frequently used commands are, with their
226 key-binding, presented in the menu bar above each editor window. A
227 complete overview of the bindings for the current <em>mode</em> is
228 provided through <strong>Help/Show key bindings</strong> (<code>Control-h
266 the extended <i>editor</i> object. Some frequently used commands are,
267 with their key-binding, presented in the menu bar above each editor
268 window. A complete overview of the bindings for the current <em>mode</em>
269 is provided through <strong>Help/Show key bindings</strong> (<code>Control-h
229270 Control-b</code>).
230271
231 <p><h4 id="sec:pceemacsmodes"><a name="sec:3.4.2.1"><span class="sec-nr">3.4.2.1</span> <span class="sec-title">Edit
272 <p><h4 id="sec:pceemacsmodes"><a id="sec:3.4.2.1"><span class="sec-nr">3.4.2.1</span> <span class="sec-title">Edit
232273 modes</span></a></h4>
233274
234 <a name="sec:pceemacsmodes"></a>
275 <a id="sec:pceemacsmodes"></a>
235276
236277 <p>Modes are the heart of (Pce)Emacs. Modes define dedicated editing
237278 support for a particular kind of (source) text. For our purpose we want
261302 Prolog mode explicitly.
262303 </ul>
263304
264 <p><h4 id="sec:pceemacscommands"><a name="sec:3.4.2.2"><span class="sec-nr">3.4.2.2</span> <span class="sec-title">Frequently
305 <p><h4 id="sec:pceemacscommands"><a id="sec:3.4.2.2"><span class="sec-nr">3.4.2.2</span> <span class="sec-title">Frequently
265306 used editor commands</span></a></h4>
266307
267 <a name="sec:pceemacscommands"></a>
308 <a id="sec:pceemacscommands"></a>
268309
269310 <p>Below we list a few important commands and how to activate them.
270311
366407 </ul>
367408
368409 <p>These are the most commonly used commands. In
369 <a class="sec" href="pceemacs.html">section 3.4.3</a> we discuss
370 specific support for dealing with Prolog source code.
371
372 <p><h3 id="sec:emacsprologmode"><a name="sec:3.4.3"><span class="sec-nr">3.4.3</span> <span class="sec-title">Prolog
410 <a class="sec" href="pceemacs.html#sec:3.4.3">section 3.4.3</a> we
411 discuss specific support for dealing with Prolog source code.
412
413 <p><h3 id="sec:emacsprologmode"><a id="sec:3.4.3"><span class="sec-nr">3.4.3</span> <span class="sec-title">Prolog
373414 Mode</span></a></h3>
374415
375 <a name="sec:emacsprologmode"></a>
376
377 <p>In the previous section (<a class="sec" href="pceemacs.html">section
416 <a id="sec:emacsprologmode"></a>
417
418 <p>In the previous section (<a class="sec" href="pceemacs.html#sec:3.4.2">section
378419 3.4.2</a>) we explained the basics of PceEmacs. Here we continue with
379420 Prolog-specific functionality. Possibly the most interesting is <em>Syntax
380421 highlighting</em>. Unlike most editors where this is based on simple
425466 Other colours follow intuitive conventions. See <a class="tab" href="pceemacs.html#tab:plcolour">table
426467 3</a>.
427468
428 <p><table border="2" frame="box" rules="groups" style="margin:auto">
429 <tr valign="top"><td colspan=2 align=center>Clauses</tr>
430 <tbody>
431 <tr valign="top"><td>Blue bold</td><td>Head of an exported predicate </td></tr>
432 <tr valign="top"><td>Red bold</td><td>Head of a predicate that is not
433 called </td></tr>
434 <tr valign="top"><td>Black bold</td><td>Head of remaining predicates </td></tr>
435 <tbody>
436 <tr valign="top"><td colspan=2 align=center>Calls in the clause body</tr>
437 <tbody>
438 <tr valign="top"><td>Blue</td><td>Call to built-in or imported predicate </td></tr>
439 <tr valign="top"><td>Red</td><td>Call to undefined predicate </td></tr>
440 <tr valign="top"><td>Purple</td><td>Call to dynamic predicate </td></tr>
441 <tbody>
442 <tr valign="top"><td colspan=2 align=center>Other entities</tr>
443 <tbody>
444 <tr valign="top"><td>Dark green</td><td>Comment </td></tr>
445 <tr valign="top"><td>Dark blue</td><td>Quoted atom or string </td></tr>
446 <tr valign="top"><td>Brown</td><td>Variable </td></tr>
469 <p><table class="latex frame-box center">
470 <tr><td colspan=2 align=center>Clauses</tr>
471 <tr class="hline"><td>Blue bold</td><td>Head of an exported predicate </td></tr>
472 <tr><td>Red bold</td><td>Head of a predicate that is not called </td></tr>
473 <tr><td>Black bold</td><td>Head of remaining predicates </td></tr>
474 <tr class="hline"><td colspan=2 align=center>Calls in the clause body</tr>
475 <tr class="hline"><td>Blue</td><td>Call to built-in or imported
476 predicate </td></tr>
477 <tr><td>Red</td><td>Call to undefined predicate </td></tr>
478 <tr><td>Purple</td><td>Call to dynamic predicate </td></tr>
479 <tr class="hline"><td colspan=2 align=center>Other entities</tr>
480 <tr class="hline"><td>Dark green</td><td>Comment </td></tr>
481 <tr><td>Dark blue</td><td>Quoted atom or string </td></tr>
482 <tr><td>Brown</td><td>Variable </td></tr>
447483 </table>
448 <a name="tab:plcolour"></a>
484 <a id="tab:plcolour"></a>
449485 <div class="caption"><b>Table 3 : </b>Colour conventions</div>
450486
451487 <p><b>Layout support</b>
498534 calls (indented 1 tab), if-then-else, disjunction and argument lists
499535 broken across multiple lines as illustrated above.
500536
501 <p><h4 id="sec:pceemacshelp"><a name="sec:3.4.3.1"><span class="sec-nr">3.4.3.1</span> <span class="sec-title">Finding
537 <p><h4 id="sec:pceemacshelp"><a id="sec:3.4.3.1"><span class="sec-nr">3.4.3.1</span> <span class="sec-title">Finding
502538 your way around</span></a></h4>
503539
504 <a name="sec:pceemacshelp"></a>
540 <a id="sec:pceemacshelp"></a>
505541
506542 <p>The command <code>Alt-.</code> extracts name and arity from the caret
507543 location and jumps (after conformation or edit) to the definition of the
508544 predicate. It does so based on the source-location database of loaded
509 predicates also used by <a name="idx:edit1:310"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
545 predicates also used by <a id="idx:edit1:310"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
510546 This makes locating predicates reliable if all sources are loaded and
511 up-to-date (see <a name="idx:make0:311"></a><a class="pred" href="consulting.html#make/0">make/0</a>).
512
513 <p>In addition, references to files in <a name="idx:usemodule12:312"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>, <a name="idx:consult1:313"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
547 up-to-date (see <a id="idx:make0:311"></a><a class="pred" href="consulting.html#make/0">make/0</a>).
548
549 <p>In addition, references to files in <a id="idx:usemodule12:312"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>, <a id="idx:consult1:313"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
514550 etc. are red if the file cannot be found and underlined blue if the file
515551 can be loaded. A popup allows for opening the referenced file.
516552
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.23</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.23</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="pairs.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="pio.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:persistency"><a name="sec:A.23"><span class="sec-nr">A.23</span> <span class="sec-title">library(persistency):
235 <h2 id="sec:persistency"><a id="sec:A.23"><span class="sec-nr">A.23</span> <span class="sec-title">library(persistency):
195236 Provide persistent dynamic predicates</span></a></h2>
196237
197 <p><a name="sec:persistency"></a>
238 <p><a id="sec:persistency"></a>
198239
199240 <dl class="tags">
200241 <dt class="mtag">To be done</dt>
263304 </pre>
264305
265306 <dl class="latex">
266 <dt class="pubdef"><a name="persistent/1"><strong>persistent</strong> <var>+Spec</var></a></dt>
307 <dt class="pubdef"><a id="persistent/1"><strong>persistent</strong> <var>+Spec</var></a></dt>
267308 <dd class="defbody">
268309 Declare dynamic database terms. Declarations appear in a directive and
269310 have the following format:
283324 </pre>
284325
285326 <p>Types are defined by <code>library(error)</code>.</dd>
286 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_persistent_predicate/1"><strong>current_persistent_predicate</strong>(<var>:PI</var>)</a></dt>
327 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_persistent_predicate/1"><strong>current_persistent_predicate</strong>(<var>:PI</var>)</a></dt>
287328 <dd class="defbody">
288329 True if <var>PI</var> is a predicate that provides access to the
289330 persistent database DB.</dd>
290 <dt class="pubdef"><a name="db_attach/2"><strong>db_attach</strong>(<var>:File,
331 <dt class="pubdef"><a id="db_attach/2"><strong>db_attach</strong>(<var>:File,
291332 +Options</var>)</a></dt>
292333 <dd class="defbody">
293334 Use <var>File</var> as persistent database for the calling module. The
305346
306347 <p>If <var>File</var> is already attached this operation may change the <code>sync</code>
307348 behaviour.</dd>
308 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="db_attached/1"><strong>db_attached</strong>(<var>:File</var>)</a></dt>
349 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="db_attached/1"><strong>db_attached</strong>(<var>:File</var>)</a></dt>
309350 <dd class="defbody">
310351 True if the context module attached to the persistent database <var>File</var>.</dd>
311 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="db_detach/0"><strong>db_detach</strong></a></dt>
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="db_detach/0"><strong>db_detach</strong></a></dt>
312353 <dd class="defbody">
313354 Detach persistency from the calling module and delete all persistent
314355 clauses from the Prolog database. Note that the file is not affected.
315356 After this operation another file may be attached, providing it
316357 satisfies the same persistency declaration.</dd>
317 <dt class="pubdef"><a name="db_sync/1"><strong>db_sync</strong>(<var>:What</var>)</a></dt>
358 <dt class="pubdef"><a id="db_sync/1"><strong>db_sync</strong>(<var>:What</var>)</a></dt>
318359 <dd class="defbody">
319360 Synchronise database with the associated file. <var>What</var> is one
320361 of:
358399 <p>With unbound <var>What</var>, <a class="pred" href="persistency.html#db_sync/1">db_sync/1</a>
359400 reloads the database if it was modified on disk, gc it if it is dirty
360401 and close it if it is opened.</dd>
361 <dt class="pubdef"><a name="db_sync_all/1"><strong>db_sync_all</strong>(<var>+What</var>)</a></dt>
402 <dt class="pubdef"><a id="db_sync_all/1"><strong>db_sync_all</strong>(<var>+What</var>)</a></dt>
362403 <dd class="defbody">
363404 Sync all registered databases.
364405 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.24</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.24</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="persistency.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="predicate_options.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:pio"><a name="sec:A.24"><span class="sec-nr">A.24</span> <span class="sec-title">library(pio):
235 <h2 id="sec:pio"><a id="sec:A.24"><span class="sec-nr">A.24</span> <span class="sec-title">library(pio):
195236 Pure I/O</span></a></h2>
196237
197 <a name="sec:pio"></a>
198 <a name="sec:lib:pio"></a>
238 <a id="sec:pio"></a>
239 <a id="sec:lib:pio"></a>
199240
200241 <p>This library provides pure list-based I/O processing for Prolog,
201242 where the communication to the actual I/O device is performed
202243 transparently through coroutining. This module itself is just an
203244 interface to the actual implementation modules.
204245
205 <p><h3 id="sec:pureinput"><a name="sec:A.24.1"><span class="sec-nr">A.24.1</span> <span class="sec-title">library(pure_input):
246 <p><h3 id="sec:pureinput"><a id="sec:A.24.1"><span class="sec-nr">A.24.1</span> <span class="sec-title">library(pure_input):
206247 Pure Input from files and streams</span></a></h3>
207248
208 <p><a name="sec:pureinput"></a>
249 <p><a id="sec:pureinput"></a>
209250
210251 <dl class="tags">
211252 <dt class="tag">To be done</dt>
232273 attribute handling to realise pure input on any (buffered) stream.
233274
234275 <dl class="latex">
235 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="phrase_from_file/2"><strong>phrase_from_file</strong>(<var>:Grammar,
276 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="phrase_from_file/2"><strong>phrase_from_file</strong>(<var>:Grammar,
236277 +File</var>)</a></dt>
237278 <dd class="defbody">
238279 Process the content of <var>File</var> using the DCG rule <var>Grammar</var>.
242283 on demand due to unification of the attributed tail variable. Below is
243284 an example that counts the number of times a string appears in a file.
244285 The library dcg/basics provides
245 <span class="pred-ext">string/3</span> matching an arbitrary string and <span class="pred-ext">remainder/3</span>
286 <span class="pred-ext">string//1</span> matching an arbitrary string and <span class="pred-ext">remainder//1</span>
246287 which matches the remainder of the input without parsing.
247288
248289 <pre class="code">
268309 </pre>
269310
270311 </dd>
271 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="phrase_from_file/3"><strong>phrase_from_file</strong>(<var>:Grammar,
312 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="phrase_from_file/3"><strong>phrase_from_file</strong>(<var>:Grammar,
272313 +File, +Options</var>)</a></dt>
273314 <dd class="defbody">
274315 As <a class="pred" href="pio.html#phrase_from_file/2">phrase_from_file/2</a>,
275316 providing additional <var>Options</var>. <var>Options</var> are passed
276317 to <a class="pred" href="IO.html#open/4">open/4</a>.</dd>
277 <dt class="pubdef"><a name="phrase_from_stream/2"><strong>phrase_from_stream</strong>(<var>:Grammar,
318 <dt class="pubdef"><a id="phrase_from_stream/2"><strong>phrase_from_stream</strong>(<var>:Grammar,
278319 +Stream</var>)</a></dt>
279320 <dd class="defbody">
280321 Run Grammer against the character codes on <var>Stream</var>. <var>Stream</var>
281322 must be buffered.</dd>
282 <dt class="pubdef"><a name="syntax_error/1"><strong>syntax_error</strong>(<var>+Error</var>)</a><code>//</code></dt>
323 <dt class="pubdef"><a id="syntax_error//1"><strong>syntax_error</strong>(<var>+Error</var>)</a><code>//</code></dt>
283324 <dd class="defbody">
284325 Throw the syntax error <var>Error</var> at the current location of the
285326 input. This predicate is designed to be called from the handler of <a class="pred" href="pio.html#phrase_from_file/3">phrase_from_file/3</a>.
292333 </dl>
293334
294335 </dd>
295 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="lazy_list_location/1"><strong>lazy_list_location</strong>(<var>-Location</var>)</a><code>//</code></dt>
336 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="lazy_list_location//1"><strong>lazy_list_location</strong>(<var>-Location</var>)</a><code>//</code></dt>
296337 <dd class="defbody">
297338 Determine current (error) location in a lazy list. True when
298339 <var>Location</var> is an (error) location term that represents the
299340 current location in the DCG list.
300341 <table class="arglist">
301 <tr valign="top"><td><var>Location</var> </td><td>is a term <code>file(Name, Line, LinePos, CharNo)</code>
342 <tr><td><var>Location</var> </td><td>is a term <code>file(Name, Line, LinePos, CharNo)</code>
302343 or
303344 <code>stream(Stream, Line, LinePos, CharNo)</code> if no file is
304345 associated to the stream RestLazyList. Finally, if the Lazy list is
309350 <dl class="tags">
310351 <dt class="tag">See also</dt>
311352 <dd>
312 <span class="pred-ext">lazy_list_character_count/3</span> only provides
313 the character count.
314 </dd>
315 </dl>
316
317 </dd>
318 <dt class="pubdef"><a name="lazy_list_character_count/1"><strong>lazy_list_character_count</strong>(<var>-CharCount</var>)</a><code>//</code></dt>
353 <a class="pred" href="pio.html#lazy_list_character_count//1">lazy_list_character_count//1</a>
354 only provides the character count.
355 </dd>
356 </dl>
357
358 </dd>
359 <dt class="pubdef"><a id="lazy_list_character_count//1"><strong>lazy_list_character_count</strong>(<var>-CharCount</var>)</a><code>//</code></dt>
319360 <dd class="defbody">
320361 True when <var>CharCount</var> is the current character count in the
321362 Lazy list. The character count is computed by finding the distance to
330371 <dl class="tags">
331372 <dt class="tag">See also</dt>
332373 <dd>
333 <span class="pred-ext">lazy_list_location/3</span> provides full details
334 of the location for error reporting.
335 </dd>
336 </dl>
337
338 </dd>
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="stream_to_lazy_list/2"><strong>stream_to_lazy_list</strong>(<var>+Stream,
374 <a class="pred" href="pio.html#lazy_list_location//1">lazy_list_location//1</a>
375 provides full details of the location for error reporting.
376 </dd>
377 </dl>
378
379 </dd>
380 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="stream_to_lazy_list/2"><strong>stream_to_lazy_list</strong>(<var>+Stream,
340381 -List</var>)</a></dt>
341382 <dd class="defbody">
342383 Create a lazy list representing the character codes in <var>Stream</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 11.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreigninclude.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="findhome.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:plld"><a name="sec:11.5"><span class="sec-nr">11.5</span> <span class="sec-title">Linking
235 <h2 id="sec:plld"><a id="sec:11.5"><span class="sec-nr">11.5</span> <span class="sec-title">Linking
195236 embedded applications using swipl-ld</span></a></h2>
196237
197 <a name="sec:plld"></a>
238 <a id="sec:plld"></a>
198239
199240 <p>The utility program <b>swipl-ld</b> (Win32: swipl-ld.exe) may be used
200241 to link a combination of C files and Prolog files into a stand-alone
267308 <dt><strong>-shared</strong> <var></var></dt>
268309 <dd class="defbody">
269310 Link C, C++ or object files into a shared object (DLL) that can be
270 loaded by the <a name="idx:loadforeignlibrary1:2087"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
311 loaded by the <a id="idx:loadforeignlibrary1:2091"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
271312 predicate. If used with
272313 <strong>-c</strong> it sets the proper options to compile a C or C++
273314 file ready for linking into a shared object.</dd>
354395 </dd>
355396 </dl>
356397
357 <p><h3 id="sec:foreign-example"><a name="sec:11.5.1"><span class="sec-nr">11.5.1</span> <span class="sec-title">A
398 <p><h3 id="sec:foreign-example"><a id="sec:11.5.1"><span class="sec-nr">11.5.1</span> <span class="sec-title">A
358399 simple example</span></a></h3>
359400
360 <a name="sec:foreign-example"></a>
401 <a id="sec:foreign-example"></a>
361402
362403 <p>The following is a very simple example going through all the steps
363404 outlined above. It provides an arithmetic expression evaluator. We will
427468 </pre>
428469
429470 <div class="caption"><b>Figure 9 : </b>C source for the calc application</div>
430 <a name="fig:calc"></a>
471 <a id="fig:calc"></a>
431472
432473 <p>The application is now created using the following command line:
433474
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section C.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section C.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="dialect.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="glossary.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:portabilitystrategies"><a name="sec:C.1"><span class="sec-nr">C.1</span> <span class="sec-title">Some
235 <h2 id="sec:portabilitystrategies"><a id="sec:C.1"><span class="sec-nr">C.1</span> <span class="sec-title">Some
195236 considerations for writing portable code</span></a></h2>
196237
197 <a name="sec:portabilitystrategies"></a>
238 <a id="sec:portabilitystrategies"></a>
198239
199240 <p>The traditional way to write portable code is to define custom
200241 predicates for all potentially non-portable code and define these
210251 the defined semantics are those of dialect <var>X</var>. Emulating all
211252 extreme cases and full error handling compatibility may be tedious and
212253 result in a much slower implementation that needed. Take for example
213 <a name="idx:callcleanup2:2256"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
254 <a id="idx:callcleanup2:2260"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
214255 The SICStus definition is fundamentally different from the SWI
215256 definition, but 99% of the applications just want to make calls like
216257 below to guarantee <var>StreamIn</var> is closed, even if process/1
238279 keeping compatibility with the original dialect(s). This problem is well
239280 known from the C/Unix world and we advise anyone to study the philosophy
240281 of
241 http://www.gnu.org/software/autoconf/GNU autoconf , from which we will
242 illustrate some highlights below.
282 <a class="url" href="http://www.gnu.org/software/autoconf/">GNU autoconf</a>,
283 from which we will illustrate some highlights below.
243284 </ul>
244285
245286 <p>The GNU autoconf suite, known to most people as <b>configure</b>, was
248289 dialects today. Writing a portable C program can only be achieved using
249290 cpp, the C preprocessor. The C preprocessor performs two tasks: macro
250291 expansion and conditional compilation. Prolog realises macro expansion
251 through <a name="idx:termexpansion2:2257"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
252 and <a name="idx:goalexpansion2:2258"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
292 through <a id="idx:termexpansion2:2261"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
293 and <a id="idx:goalexpansion2:2262"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
253294 Conditional compilation is achieved using <code>:- if(Condition)</code>
254295 as explained in
255 <a class="sec" href="consulting.html">section 4.3.1.2</a>. The situation
256 appears similar.
296 <a class="sec" href="consulting.html#sec:4.3.1.2">section 4.3.1.2</a>.
297 The situation appears similar.
257298
258299 <p>The important lesson learned from GNU autoconf is that the <em>last</em>
259300 resort for conditional compilation to achieve portability is to switch
271312
272313 <p>We must learn from the distinction to test for features instead of
273314 platform (dialect), as this makes the platform-specific code robust for
274 future changes of the dialect. Suppose we need <a name="idx:compare3:2259"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
275 as defined in this manual. The <a name="idx:compare3:2260"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
315 future changes of the dialect. Suppose we need <a id="idx:compare3:2263"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
316 as defined in this manual. The <a id="idx:compare3:2264"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
276317 predicate is not part of the ISO standard, but many systems support it
277318 and it is not unlikely it will become ISO standard or the intended
278319 dialect will start supporting it. GNU autoconf strongly advises to test
293334 dialect and, possibly at least as important, will provide compatibility
294335 with dialects you didn't even consider porting to right now.
295336
296 <p>In a more challenging case, the target Prolog has <a name="idx:compare3:2261"></a><a class="pred" href="compare.html#compare/3">compare/3</a>,
337 <p>In a more challenging case, the target Prolog has <a id="idx:compare3:2265"></a><a class="pred" href="compare.html#compare/3">compare/3</a>,
297338 but the semantics are different. What to do? One option is to write a
298 <a name="idx:mycompare3:2262"></a><span class="pred-ext">my_compare/3</span>
339 <a id="idx:mycompare3:2266"></a><span class="pred-ext">my_compare/3</span>
299340 and change all occurrences in the code. Alternatively you can rename
300 calls using <a name="idx:goalexpansion2:2263"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
341 calls using <a id="idx:goalexpansion2:2267"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
301342 like below. This construct will not only deal with Prolog dialects
302 lacking <a name="idx:compare3:2264"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
343 lacking <a id="idx:compare3:2268"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
303344 as well as those that only implement it for numeric comparison or have
304345 changed the argument order. Of course, writing rock-solid code would
305346 require a complete test-suite, but this example will probably cover all
306347 Prolog dialects that allow for conditional compilation, have core ISO
307 facilities and provide <a name="idx:goalexpansion2:2265"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>,
348 facilities and provide <a id="idx:goalexpansion2:2269"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>,
308349 the things we claim a Prolog dialect should have to start writing
309350 portable code for it.
310351
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="SyntaxAndSemantics.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="debugging.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:practical"><a name="sec:8.3"><span class="sec-nr">8.3</span> <span class="sec-title">CHR
235 <h2 id="sec:practical"><a id="sec:8.3"><span class="sec-nr">8.3</span> <span class="sec-title">CHR
195236 in SWI-Prolog Programs</span></a></h2>
196237
197 <a name="sec:practical"></a>
198 <h3 id="sec:chr-embedding"><a name="sec:8.3.1"><span class="sec-nr">8.3.1</span> <span class="sec-title">Embedding
238 <a id="sec:practical"></a>
239 <h3 id="sec:chr-embedding"><a id="sec:8.3.1"><span class="sec-nr">8.3.1</span> <span class="sec-title">Embedding
199240 in Prolog Programs</span></a></h3>
200241
201 <a name="sec:chr-embedding"></a>
242 <a id="sec:chr-embedding"></a>
202243
203244 <p>The CHR constraints defined in a <code>.pl</code> file are associated
204245 with a module. The default module is <code>user</code>. One should never
205246 load different <code>.pl</code> files with the same CHR module name.
206247
207 <p><h3 id="sec:chr-declarations"><a name="sec:8.3.2"><span class="sec-nr">8.3.2</span> <span class="sec-title">Constraint
248 <p><h3 id="sec:chr-declarations"><a id="sec:8.3.2"><span class="sec-nr">8.3.2</span> <span class="sec-title">Constraint
208249 declaration</span></a></h3>
209250
210 <a name="sec:chr-declarations"></a>
251 <a id="sec:chr-declarations"></a>
211252
212253 <dl class="latex">
213 <dt class="pubdef"><a name="chr_constraint/1">:- <strong>chr_constraint</strong>(<var>+Specifier</var>)</a></dt>
254 <dt class="pubdef"><a id="chr_constraint/1">:- <strong>chr_constraint</strong>(<var>+Specifier</var>)</a></dt>
214255 <dd class="defbody">
215256 Every constraint used in CHR rules has to be declared with a
216 <a name="idx:chrconstraint1:1811"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
257 <a id="idx:chrconstraint1:1815"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
217258 declaration by the <em>constraint specifier</em>. For convenience
218259 multiple constraints may be declared at once with the same
219260 <a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
311352 </dl>
312353
313354 <dl class="latex">
314 <dt class="pubdef"><a name="chr_type/1">:- <strong>chr_type</strong>(<var>+TypeDeclaration</var>)</a></dt>
355 <dt class="pubdef"><a id="chr_type/1">:- <strong>chr_type</strong>(<var>+TypeDeclaration</var>)</a></dt>
315356 <dd class="defbody">
316357 User-defined types are algebraic data types, similar to those in Haskell
317358 or the discriminated unions in Mercury. An algebraic data type is
318 defined using <a name="idx:chrtype1:1812"></a><a class="pred" href="practical.html#chr_type/1">chr_type/1</a>:
359 defined using <a id="idx:chrtype1:1816"></a><a class="pred" href="practical.html#chr_type/1">chr_type/1</a>:
319360
320361 <pre class="code">
321362 :- chr_type type ---&gt; body.
449490 runtime overhead.
450491 </ol>
451492
452 <p><h3 id="sec:chr-compilation"><a name="sec:8.3.3"><span class="sec-nr">8.3.3</span> <span class="sec-title">Compilation</span></a></h3>
453
454 <a name="sec:chr-compilation"></a> The SWI-Prolog CHR compiler exploits <a name="idx:termexpansion2:1813"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
493 <p><h3 id="sec:chr-compilation"><a id="sec:8.3.3"><span class="sec-nr">8.3.3</span> <span class="sec-title">Compilation</span></a></h3>
494
495 <a id="sec:chr-compilation"></a> The SWI-Prolog CHR compiler exploits <a id="idx:termexpansion2:1817"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
455496 rules to translate the constraint handling rules to plain Prolog. These
456497 rules are loaded from the library <code>library(chr)</code>. They are
457498 activated if the compiled file has the <code>.chr</code> extension or
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="builtin.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="chars.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:preddesc"><a name="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Notation
235 <h2 id="sec:preddesc"><a id="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Notation
195236 of Predicate Descriptions</span></a></h2>
196237
197 <a name="sec:preddesc"></a>
238 <a id="sec:preddesc"></a>
198239
199240 <p>We have tried to keep the predicate descriptions clear and concise.
200241 First, the predicate name is printed in bold face, followed by the
206247 (-,+) are described as (?,?). The <code>@</code>-mode is often replaced
207248 by <code><code>+</code></code>.</span></sup>
208249
209 <p><table border="2" frame="hsides" rules="groups" style="margin:auto">
210 <tr valign="top"><td>++</td><td>Argument must be ground, i.e., the
211 argument may not contain a variable anywhere. </td></tr>
212 <tr valign="top"><td>+</td><td>Argument must be fully instantiated to a
213 term that satisfies the type. This is not necessarily <em>ground</em>,
214 e.g., the term
250 <p><table class="latex frame-hsides center">
251 <tr><td>++</td><td>Argument must be ground, i.e., the argument may not
252 contain a variable anywhere. </td></tr>
253 <tr><td>+</td><td>Argument must be fully instantiated to a term that
254 satisfies the type. This is not necessarily <em>ground</em>, e.g., the
255 term
215256 <code>[_]</code> is a <em>list</em>, although its only member is
216257 unbound. </td></tr>
217 <tr valign="top"><td>-</td><td>Argument is an <em>output</em> argument.
218 Unless specified otherwise, output arguments need not to be unbound. For
258 <tr><td>-</td><td>Argument is an <em>output</em> argument. Unless
259 specified otherwise, output arguments need not to be unbound. For
219260 example, the goal <code>findall(X, Goal, [T])</code> is good style and
220261 equivalent to <code>findall(X, Goal, Xs), Xs = [T]</code><sup class="fn">44<span class="fn-text">The
221262 ISO standard dictates that <code>findall(X, Goal, 1)</code> raises a <code>type_error</code>
223264 the standard here.</span></sup> Note that the
224265 <em>determinism</em> specification, e.g., ``det'' only applies if this
225266 argument is unbound. </td></tr>
226 <tr valign="top"><td>--</td><td>Argument must be unbound. Typically used
227 by predicates that create `something' and return a handle to the created
228 object, such as <a name="idx:open3:334"></a><a class="pred" href="IO.html#open/3">open/3</a>
267 <tr><td>--</td><td>Argument must be unbound. Typically used by
268 predicates that create `something' and return a handle to the created
269 object, such as <a id="idx:open3:334"></a><a class="pred" href="IO.html#open/3">open/3</a>
229270 which creates a <em>stream</em>. </td></tr>
230 <tr valign="top"><td>?</td><td>Argument must be bound to a <em>partial
231 term</em> of the indicated type. Note that a variable is a partial term
232 for any type. Think of the argument as either <em>input</em> or <em>output</em>
233 or
271 <tr><td>?</td><td>Argument must be bound to a <em>partial term</em> of
272 the indicated type. Note that a variable is a partial term for any type.
273 Think of the argument as either <em>input</em> or <em>output</em> or
234274 <em>both</em> input and output. For example, in
235275 <code>stream_property(S, reposition(Bool))</code>, the <code>reposition</code>
236276 part of the term is input and the uninstantiated <var>Bool</var> is
237277 output. </td></tr>
238 <tr valign="top"><td>:</td><td>Argument is a meta-argument. Implies <code><code>+</code></code>.
239 See <a class="sec" href="modules.html">chapter 6</a> for more
278 <tr><td>:</td><td>Argument is a meta-argument. Implies <code><code>+</code></code>.
279 See <a class="sec" href="modules.html#sec:6">chapter 6</a> for more
240280 information on module handling. </td></tr>
241 <tr valign="top"><td>@</td><td>Argument is not further instantiated.
242 Typically used for type tests.</td></tr>
243 <tr valign="top"><td>!</td><td>Argument contains a mutable structure
244 that may be modified using
245 <a name="idx:setarg3:335"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
246 or <a name="idx:nbsetarg3:336"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>. </td></tr>
281 <tr><td>@</td><td>Argument is not further instantiated. Typically used
282 for type tests.</td></tr>
283 <tr><td>!</td><td>Argument contains a mutable structure that may be
284 modified using
285 <a id="idx:setarg3:335"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
286 or <a id="idx:nbsetarg3:336"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>. </td></tr>
247287 </table>
248288
249 <p><a name="idx:predicateindicator:337"></a>Referring to a predicate in
289 <p><a id="idx:predicateindicator:337"></a>Referring to a predicate in
250290 running text is done using a
251291 <em>predicate indicator</em>. The canonical and most generic form of a
252292 predicate indicator is a term &lt;<var>module</var>&gt;:&lt;<var>name</var>&gt;/&lt;<var>arity</var>&gt;.
253293 If the module is irrelevant (built-in predicate) or can be inferred from
254294 the context it is often omitted. Compliant to the ISO standard draft on
255295 DCG (see
256 <a class="sec" href="DCG.html">section 4.13</a>), SWI-Prolog also allows
257 for [&lt;<var>module</var>&gt;]:&lt;<var>name</var>&gt;//&lt;<var>arity</var>&gt;
296 <a class="sec" href="DCG.html#sec:4.13">section 4.13</a>), SWI-Prolog
297 also allows for [&lt;<var>module</var>&gt;]:&lt;<var>name</var>&gt;//&lt;<var>arity</var>&gt;
258298 to refer to a grammar rule. For all non-negative arity, &lt;<var>name</var>&gt;//&lt;<var>arity</var>&gt;
259299 is the same as &lt;<var>name</var>&gt;/&lt;<var>arity</var>&gt;+2,
260300 regardless of whether or not the referenced predicate is defined or can
261301 be used as a grammar rule. The //-notation can be used in all places
262302 that traditionally allow for a predicate indicator, e.g., the module
263 declaration, <a name="idx:spy1:338"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
264 and <a name="idx:dynamic1:339"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.
303 declaration, <a id="idx:spy1:338"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
304 and <a id="idx:dynamic1:339"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.
265305
266306 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.25</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.25</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="pio.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="prologpack.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:predicate_options"><a name="sec:A.25"><span class="sec-nr">A.25</span> <span class="sec-title">library(predicate_options):
235 <h2 id="sec:predicate_options"><a id="sec:A.25"><span class="sec-nr">A.25</span> <span class="sec-title">library(predicate_options):
195236 Declare option-processing of predicates</span></a></h2>
196237
197 <a name="sec:predicate_options"></a>
238 <a id="sec:predicate_options"></a>
198239
199240 <p><i>Discussions with Jeff Schultz helped shaping this library</i>
200241
201 <p><h3 id="sec:predopts-pro-cons"><a name="sec:A.25.1"><span class="sec-nr">A.25.1</span> <span class="sec-title">The
242 <p><h3 id="sec:predopts-pro-cons"><a id="sec:A.25.1"><span class="sec-nr">A.25.1</span> <span class="sec-title">The
202243 strength and weakness of predicate options</span></a></h3>
203244
204 <p><a name="sec:predopts-pro-cons"></a>
245 <p><a id="sec:predopts-pro-cons"></a>
205246
206247 <p>Many ISO predicates accept options, e.g., <a class="pred" href="IO.html#open/4">open/4</a>, <a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
207248 Options offer an attractive alternative to proliferation into many
258299 Unfortunately, the consequences of a partial emulation cannot be
259300 assessed by tools.
260301
261 <p><h3 id="sec:predopts-environment"><a name="sec:A.25.2"><span class="sec-nr">A.25.2</span> <span class="sec-title">Options
302 <p><h3 id="sec:predopts-environment"><a id="sec:A.25.2"><span class="sec-nr">A.25.2</span> <span class="sec-title">Options
262303 as arguments or environment?</span></a></h3>
263304
264 <p><a name="sec:predopts-environment"></a>
305 <p><a id="sec:predopts-environment"></a>
265306
266307 <p>We distinguish two views on options. One is to see them as additional
267308 parameters that require strict existence, type and domain-checking and
294335 mistyped options are silently ignored. The option infrastructure
295336 described in this section tries to remedy these problems.
296337
297 <p><h3 id="sec:predopts-improving"><a name="sec:A.25.3"><span class="sec-nr">A.25.3</span> <span class="sec-title">Improving
338 <p><h3 id="sec:predopts-improving"><a id="sec:A.25.3"><span class="sec-nr">A.25.3</span> <span class="sec-title">Improving
298339 on the current situation</span></a></h3>
299340
300 <p><a name="sec:predopts-improving"></a>
341 <p><a id="sec:predopts-improving"></a>
301342
302343 <p>Whether we see options as arguments or locally scoped environment
303344 variables, the most obvious way to improve on the current situation is
306347 options can be used by the compiler and development environment as well
307348 as by the runtime system to warn or throw errors.
308349
309 <p><h4 id="sec:predopts-as-types"><a name="sec:A.25.3.1"><span class="sec-nr">A.25.3.1</span> <span class="sec-title">Options
350 <p><h4 id="sec:predopts-as-types"><a id="sec:A.25.3.1"><span class="sec-nr">A.25.3.1</span> <span class="sec-title">Options
310351 as types</span></a></h4>
311352
312 <p><a name="sec:predopts-as-types"></a>
353 <p><a id="sec:predopts-as-types"></a>
313354
314355 <p>An obvious approach to deal with options is to define the different
315356 possible option values as a type and type the argument that processes
337378 code.
338379 </ul>
339380
340 <p><h4 id="sec:predopts-reflextion"><a name="sec:A.25.3.2"><span class="sec-nr">A.25.3.2</span> <span class="sec-title">Reflective
381 <p><h4 id="sec:predopts-reflextion"><a id="sec:A.25.3.2"><span class="sec-nr">A.25.3.2</span> <span class="sec-title">Reflective
341382 access to options</span></a></h4>
342383
343 <p><a name="sec:predopts-reflextion"></a>
384 <p><a id="sec:predopts-reflextion"></a>
344385
345386 <p>From the above, we conclude that we require reflective access to find
346387 out whether an option is supported and valid for a particular predicate.
349390 values. Predicate options are declared using <a class="pred" href="predicate_options.html#predicate_options/3">predicate_options/3</a>:
350391
351392 <dl class="latex">
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="predicate_options/3"><strong>predicate_options</strong>(<var>:PI,
393 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="predicate_options/3"><strong>predicate_options</strong>(<var>:PI,
353394 +Arg, +Options</var>)</a></dt>
354395 <dd class="defbody">
355396 Declare that the predicate <var>PI</var> processes options on <var>Arg</var>. <var>Options</var>
386427 processed by <a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>.
387428 Option processing can be specified at runtime using <span class="pred-ext">assert_predicate_options/3</span>,
388429 which is intended to support program analysis.</dd>
389 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="assert_predicate_options/4"><strong>assert_predicate_options</strong>(<var>:PI,
430 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="assert_predicate_options/4"><strong>assert_predicate_options</strong>(<var>:PI,
390431 +Arg, +Options, ?New</var>)</a></dt>
391432 <dd class="defbody">
392433 As predicate_options(:<var>PI</var>, +<var>Arg</var>, +<var>Options</var>). <var>New</var>
400441 checking for supported options.
401442
402443 <dl class="latex">
403 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_predicate_option/3"><strong>current_predicate_option</strong>(<var>:PI,
444 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_predicate_option/3"><strong>current_predicate_option</strong>(<var>:PI,
404445 ?Arg, ?Option</var>)</a></dt>
405446 <dd class="defbody">
406447 True when <var>Arg</var> of <var>PI</var> processes <var>Option</var>.
416457 predicate
417458 <a class="pred" href="predicate_options.html#current_predicate_options/3">current_predicate_options/3</a>
418459 can be used to access the full capabilities of a predicate.</dd>
419 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="check_predicate_option/3"><strong>check_predicate_option</strong>(<var>:PI,
460 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="check_predicate_option/3"><strong>check_predicate_option</strong>(<var>:PI,
420461 +Arg, +Option</var>)</a></dt>
421462 <dd class="defbody">
422463 Verify predicate options at runtime. Similar to
441482 colouring option names and values.
442483
443484 <dl class="latex">
444 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_option_arg/2"><strong>current_option_arg</strong>(<var>:PI,
485 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_option_arg/2"><strong>current_option_arg</strong>(<var>:PI,
445486 ?Arg</var>)</a></dt>
446487 <dd class="defbody">
447488 True when <var>Arg</var> of <var>PI</var> processes predicate options.
448489 Which options are processed can be accessed using <a class="pred" href="predicate_options.html#current_predicate_option/3">current_predicate_option/3</a>.</dd>
449 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_predicate_options/3"><strong>current_predicate_options</strong>(<var>:PI,
490 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_predicate_options/3"><strong>current_predicate_options</strong>(<var>:PI,
450491 ?Arg, ?Options</var>)</a></dt>
451492 <dd class="defbody">
452493 True when <var>Options</var> is the current active option declaration
462503 <a class="pred" href="predicate_options.html#check_predicate_options/0">check_predicate_options/0</a>:
463504
464505 <dl class="latex">
465 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="check_predicate_options/0"><strong>check_predicate_options</strong></a></dt>
506 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="check_predicate_options/0"><strong>check_predicate_options</strong></a></dt>
466507 <dd class="defbody">
467508 Analyse loaded program for erroneous options. This predicate decompiles
468509 the current program and searches for calls to predicates that process
488529 the module system.
489530
490531 <dl class="latex">
491 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="derive_predicate_options/0"><strong>derive_predicate_options</strong></a></dt>
532 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="derive_predicate_options/0"><strong>derive_predicate_options</strong></a></dt>
492533 <dd class="defbody">
493534 Derive new predicate option declarations. This predicate analyses the
494535 loaded program to find clauses that process options using one of the
505546 </dl>
506547
507548 </dd>
508 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="retractall_predicate_options/0"><strong>retractall_predicate_options</strong></a></dt>
549 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="retractall_predicate_options/0"><strong>retractall_predicate_options</strong></a></dt>
509550 <dd class="defbody">
510551 Remove all dynamically (derived) predicate options.</dd>
511 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="derived_predicate_options/3"><strong>derived_predicate_options</strong>(<var>:PI,
552 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="derived_predicate_options/3"><strong>derived_predicate_options</strong>(<var>:PI,
512553 ?Arg, ?Options</var>)</a></dt>
513554 <dd class="defbody">
514555 Derive option arguments using static analysis. True when <var>Options</var>
515556 is the current <i>derived</i> active option declaration for <var>PI</var>
516557 on
517558 <var>Arg</var>.</dd>
518 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="derived_predicate_options/1"><strong>derived_predicate_options</strong>(<var>+Module</var>)</a></dt>
559 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="derived_predicate_options/1"><strong>derived_predicate_options</strong>(<var>+Module</var>)</a></dt>
519560 <dd class="defbody">
520561 Derive predicate option declarations for a module. The derived options
521562 are printed to the <code>current_output</code> stream.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section F.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="summary.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="library.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:predsummary"><a name="sec:F.1"><span class="sec-nr">F.1</span> <span class="sec-title">Predicates</span></a></h2>
195
196 <a name="sec:predsummary"></a>
197
198 <p>The predicate summary is used by the Prolog predicate <a name="idx:apropos1:2345"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
235 <h2 id="sec:predsummary"><a id="sec:F.1"><span class="sec-nr">F.1</span> <span class="sec-title">Predicates</span></a></h2>
236
237 <a id="sec:predsummary"></a>
238
239 <p>The predicate summary is used by the Prolog predicate <a id="idx:apropos1:2349"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
199240 to suggest predicates from a keyword.
200241 <table>
201242 <tr><td><a class="pred" href="overrule.html#@/2">@/2</a></td><td>Call
204245 (discard choicepoints)</td></tr>
205246 <tr><td><a class="pred" href="control.html#,/2">,/2</a></td><td>Conjunction
206247 of goals</td></tr>
207 <tr><td><span class="pred-ext">-&gt;/2</span></td><td>If-then-else</td></tr>
248 <tr><td><a class="pred" href="control.html#->/2">-&gt;/2</a></td><td>If-then-else</td></tr>
208249 <tr><td><a class="pred" href="control.html#*->/2">*-&gt;/2</a></td><td>Soft-cut</td></tr>
209250 <tr><td><span class="pred-ext">./2</span></td><td>Consult. Also
210251 functional notation</td></tr>
245286 <tr><td><a class="pred" href="compare.html#@>=/2">@&gt;=/2</a></td><td>Standard
246287 order larger or equal</td></tr>
247288 <tr><td><a class="pred" href="control.html#\+/1">\+/1</a></td><td>Negation
248 by failure. Same as <a name="idx:not1:2346"></a><a class="pred" href="metacall.html#not/1">not/1</a></td></tr>
289 by failure. Same as <a id="idx:not1:2350"></a><a class="pred" href="metacall.html#not/1">not/1</a></td></tr>
249290 <tr><td><a class="pred" href="compare.html#\=/2">\=/2</a></td><td>True
250291 if arguments cannot be unified</td></tr>
251292 <tr><td><a class="pred" href="compare.html#\==/2">\==/2</a></td><td>True
253294 <tr><td><a class="pred" href="compare.html#\=@=/2">\=@=/2</a></td><td>Not
254295 structural identical</td></tr>
255296 <tr><td><span class="pred-ext">^/2</span></td><td>Existential
256 quantification (<a name="idx:bagof3:2347"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>, <a name="idx:setof3:2348"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>)</td></tr>
297 quantification (<a id="idx:bagof3:2351"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>, <a id="idx:setof3:2352"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>)</td></tr>
257298 <tr><td><a class="pred" href="control.html#|/2">|/2</a></td><td>Disjunction
258299 in DCGs. Same as <a class="pred" href="control.html#;/2">;/2</a></td></tr>
259300 <tr><td><span class="pred-ext">/1</span></td><td>DCG escape; constraints</td></tr>
326367 <tr><td><a class="pred" href="chario.html#at_end_of_stream/1">at_end_of_stream/1</a></td><td>Test
327368 for end of file on stream</td></tr>
328369 <tr><td><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a></td><td>Register
329 goal to run at <a name="idx:halt1:2349"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a></td></tr>
370 goal to run at <a id="idx:halt1:2353"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a></td></tr>
330371 <tr><td><a class="pred" href="typetest.html#atom/1">atom/1</a></td><td>Type
331372 check for an atom</td></tr>
332373 <tr><td><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a></td><td>Convert
387428 a goal with a cleaup-handler</td></tr>
388429 <tr><td><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a></td><td>Guard
389430 a goal with a cleaup-handler</td></tr>
390 <tr><td><a class="pred" href="DCG.html#call_dcg/3">call_dcg/3</a></td><td>As <a name="idx:phrase3:2350"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
431 <tr><td><a class="pred" href="DCG.html#call_dcg/3">call_dcg/3</a></td><td>As <a id="idx:phrase3:2354"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
391432 without type checking</td></tr>
392433 <tr><td><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a></td><td>Find
393434 residual attributed variables</td></tr>
399440 goal in limited inferences</td></tr>
400441 <tr><td><a class="pred" href="typetest.html#callable/1">callable/1</a></td><td>Test
401442 for atom or compound term</td></tr>
402 <tr><td><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a></td><td>Cancel <a name="idx:halt0:2351"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
403 from an <a name="idx:athalt1:2352"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
443 <tr><td><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a></td><td>Cancel <a id="idx:halt0:2355"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
444 from an <a id="idx:athalt1:2356"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
404445 hook</td></tr>
405446 <tr><td><a class="pred" href="exception.html#catch/3">catch/3</a></td><td>Call
406447 goal, watching for exceptions</td></tr>
449490 <tr><td><a class="pred" href="compare.html#compare/3">compare/3</a></td><td>Compare,
450491 using a predicate to determine the order</td></tr>
451492 <tr><td><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a></td><td>Compile
452 predicates for <a name="idx:goalexpansion2:2353"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a></td></tr>
493 predicates for <a id="idx:goalexpansion2:2357"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a></td></tr>
453494 <tr><td><a class="pred" href="dynamic.html#compile_predicates/1">compile_predicates/1</a></td><td>Compile
454495 dynamic code to static</td></tr>
455496 <tr><td><a class="pred" href="consulting.html#compiling/0">compiling/0</a></td><td>Is
557598 <tr><td><a class="pred" href="debug.html#debug/3">debug/3</a></td><td>Print
558599 debugging message on topic</td></tr>
559600 <tr><td><span class="pred-ext">debug_control_hook/1</span></td><td><i>(hook)</i>
560 Extend <a name="idx:spy1:2354"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
601 Extend <a id="idx:spy1:2358"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
561602 etc.</td></tr>
562603 <tr><td><a class="pred" href="debugger.html#debugging/0">debugging/0</a></td><td>Show
563604 debugger status</td></tr>
696737 <tr><td><a class="pred" href="allsolutions.html#findall/3">findall/3</a></td><td>Find
697738 all solutions to a goal</td></tr>
698739 <tr><td><a class="pred" href="allsolutions.html#findall/4">findall/4</a></td><td>Difference
699 list version of <a name="idx:findall3:2355"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a></td></tr>
740 list version of <a id="idx:findall3:2359"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a></td></tr>
700741 <tr><td><a class="pred" href="allsolutions.html#findnsols/4">findnsols/4</a></td><td>Find
701742 first <var>N</var> solutions</td></tr>
702743 <tr><td><a class="pred" href="allsolutions.html#findnsols/5">findnsols/5</a></td><td>Difference
703 list version of <a name="idx:findnsols4:2356"></a><a class="pred" href="allsolutions.html#findnsols/4">findnsols/4</a></td></tr>
744 list version of <a id="idx:findnsols4:2360"></a><a class="pred" href="allsolutions.html#findnsols/4">findnsols/4</a></td></tr>
704745 <tr><td><a class="pred" href="chario.html#fill_buffer/1">fill_buffer/1</a></td><td>Fill
705746 the input buffer of a stream</td></tr>
706747 <tr><td><a class="pred" href="db.html#flag/3">flag/3</a></td><td>Simple
723764 strftime() like date/time formatter</td></tr>
724765 <tr><td><a class="pred" href="system.html#format_time/4">format_time/4</a></td><td>date/time
725766 formatter with explicit locale</td></tr>
726 <tr><td><a class="pred" href="format.html#format_predicate/2">format_predicate/2</a></td><td>Program <a name="idx:format12:2357"></a><a class="pred" href="format.html#format/1">format/[1,2]</a></td></tr>
767 <tr><td><a class="pred" href="format.html#format_predicate/2">format_predicate/2</a></td><td>Program <a id="idx:format12:2361"></a><a class="pred" href="format.html#format/1">format/[1,2]</a></td></tr>
727768 <tr><td><a class="pred" href="attvar.html#term_attvars/2">term_attvars/2</a></td><td>Find
728769 attributed variables in a term</td></tr>
729770 <tr><td><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a></td><td>Find
938979 between dict and list of pairs</td></tr>
939980 <tr><td><a class="pred" href="assoc.html#max_assoc/3">max_assoc/3</a></td><td>Highest
940981 key in association tree</td></tr>
941 <tr><td><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a></td><td>Deterministic <a name="idx:member2:2358"></a><a class="pred" href="lists.html#member/2">member/2</a></td></tr>
942 <tr><td><a class="pred" href="exception.html#message_hook/3">message_hook/3</a></td><td>Intercept <a name="idx:printmessage2:2359"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a></td></tr>
982 <tr><td><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a></td><td>Deterministic <a id="idx:member2:2362"></a><a class="pred" href="lists.html#member/2">member/2</a></td></tr>
983 <tr><td><a class="pred" href="exception.html#message_hook/3">message_hook/3</a></td><td>Intercept <a id="idx:printmessage2:2363"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a></td></tr>
943984 <tr><td><span class="pred-ext">message_line_element/2</span></td><td><i>(hook)</i>
944 Intercept <a name="idx:printmessagelines3:2360"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a></td></tr>
985 Intercept <a id="idx:printmessagelines3:2364"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a></td></tr>
945986 <tr><td><a class="pred" href="exception.html#message_property/2">message_property/2</a></td><td><i>(hook)</i>
946987 Define display of a message</td></tr>
947988 <tr><td><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a></td><td>Create
11151156 <tr><td><a class="pred" href="arith.html#plus/3">plus/3</a></td><td>Logical
11161157 integer addition</td></tr>
11171158 <tr><td><a class="pred" href="termrw.html#portray/1">portray/1</a></td><td><i>(hook)</i>
1118 Modify behaviour of <a name="idx:print1:2361"></a><a class="pred" href="termrw.html#print/1">print/1</a></td></tr>
1159 Modify behaviour of <a id="idx:print1:2365"></a><a class="pred" href="termrw.html#print/1">print/1</a></td></tr>
11191160 <tr><td><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a></td><td>Pretty
11201161 print a clause</td></tr>
11211162 <tr><td><a class="pred" href="listing.html#portray_clause/2">portray_clause/2</a></td><td>Pretty
11511192 <tr><td><a class="pred" href="ancestral-cut.html#prolog_cut_to/1">prolog_cut_to/1</a></td><td>Realise
11521193 global cuts</td></tr>
11531194 <tr><td><a class="pred" href="edit.html#prolog_edit:locate/2">prolog_edit:locate/2</a></td><td>Locate
1154 targets for <a name="idx:edit1:2362"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
1195 targets for <a id="idx:edit1:2366"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
11551196 <tr><td><a class="pred" href="edit.html#prolog_edit:locate/3">prolog_edit:locate/3</a></td><td>Locate
1156 targets for <a name="idx:edit1:2363"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
1197 targets for <a id="idx:edit1:2367"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
11571198 <tr><td><a class="pred" href="edit.html#prolog_edit:edit_source/1">prolog_edit:edit_source/1</a></td><td>Call
1158 editor for <a name="idx:edit1:2364"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
1199 editor for <a id="idx:edit1:2368"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
11591200 <tr><td><a class="pred" href="edit.html#prolog_edit:edit_command/2">prolog_edit:edit_command/2</a></td><td>Specify
11601201 editor activation</td></tr>
1161 <tr><td><a class="pred" href="edit.html#prolog_edit:load/0">prolog_edit:load/0</a></td><td>Load <a name="idx:edit1:2365"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
1202 <tr><td><a class="pred" href="edit.html#prolog_edit:load/0">prolog_edit:load/0</a></td><td>Load <a id="idx:edit1:2369"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
11621203 extensions</td></tr>
11631204 <tr><td><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a></td><td>Rewrite
11641205 exceptions</td></tr>
11731214 <tr><td><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a></td><td>Context
11741215 information for directives</td></tr>
11751216 <tr><td><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a></td><td><i>(hook)</i>
1176 Program <a name="idx:loadfiles2:2366"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a></td></tr>
1217 Program <a id="idx:loadfiles2:2370"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a></td></tr>
11771218 <tr><td><a class="pred" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a></td><td>Indicate
11781219 deepest recursion to trace</td></tr>
11791220 <tr><td><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a></td><td>Perform
11891230 <tr><td><a class="pred" href="termrw.html#prompt1/1">prompt1/1</a></td><td>Change
11901231 prompt for 1 line</td></tr>
11911232 <tr><td><a class="pred" href="termrw.html#prompt/2">prompt/2</a></td><td>Change
1192 the prompt used by <a name="idx:read1:2367"></a><a class="pred" href="termrw.html#read/1">read/1</a></td></tr>
1233 the prompt used by <a id="idx:read1:2371"></a><a class="pred" href="termrw.html#read/1">read/1</a></td></tr>
11931234 <tr><td><a class="pred" href="protocol.html#protocol/1">protocol/1</a></td><td>Make
11941235 a log of the user interaction</td></tr>
11951236 <tr><td><a class="pred" href="protocol.html#protocola/1">protocola/1</a></td><td>Append
13651406 <tr><td><a class="pred" href="system.html#shell/2">shell/2</a></td><td>Execute
13661407 OS command</td></tr>
13671408 <tr><td><a class="pred" href="delcont.html#shift/1">shift/1</a></td><td>Shift
1368 control to the closest <a name="idx:reset3:2368"></a><a class="pred" href="delcont.html#reset/3">reset/3</a></td></tr>
1409 control to the closest <a id="idx:reset3:2372"></a><a class="pred" href="delcont.html#reset/3">reset/3</a></td></tr>
13691410 <tr><td><a class="pred" href="profile.html#show_profile/1">show_profile/1</a></td><td>Show
13701411 results of the profiler</td></tr>
13711412 <tr><td><a class="pred" href="files.html#size_file/2">size_file/2</a></td><td>Get
14971538 <tr><td><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a></td><td>Declare
14981539 thread-specific clauses for a predicate</td></tr>
14991540 <tr><td><a class="pred" href="exception.html#thread_message_hook/3">thread_message_hook/3</a></td><td>Thread
1500 local <a name="idx:messagehook3:2369"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a></td></tr>
1541 local <a id="idx:messagehook3:2373"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a></td></tr>
15011542 <tr><td><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a></td><td>Test
15021543 for message</td></tr>
15031544 <tr><td><a class="pred" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a></td><td>Test
15191560 <tr><td><a class="pred" href="thutil.html#threads/0">threads/0</a></td><td>List
15201561 running threads</td></tr>
15211562 <tr><td><a class="pred" href="exception.html#throw/1">throw/1</a></td><td>Raise
1522 an exception (see <a name="idx:catch3:2370"></a><a class="pred" href="exception.html#catch/3">catch/3</a>)</td></tr>
1563 an exception (see <a id="idx:catch3:2374"></a><a class="pred" href="exception.html#catch/3">catch/3</a>)</td></tr>
15231564 <tr><td><a class="pred" href="statistics.html#time/1">time/1</a></td><td>Determine
15241565 time needed to execute goal</td></tr>
15251566 <tr><td><a class="pred" href="files.html#time_file/2">time_file/2</a></td><td>Get
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.41</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.41</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="statistics.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="memory.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:profile"><a name="sec:4.41"><span class="sec-nr">4.41</span> <span class="sec-title">Execution
235 <h2 id="sec:profile"><a id="sec:4.41"><span class="sec-nr">4.41</span> <span class="sec-title">Execution
195236 profiling</span></a></h2>
196237
197 <a name="sec:profile"></a>
238 <a id="sec:profile"></a>
198239
199240 <p>This section describes the hierarchical execution profiler. This
200241 profiler is based on ideas from <b>gprof</b> described in
209250 <code>library(swi/pce_profile)</code> to provide an interactive
210251 graphical frontend for the results.
211252
212 <p><h3 id="sec:profiling-predicates"><a name="sec:4.41.1"><span class="sec-nr">4.41.1</span> <span class="sec-title">Profiling
253 <p><h3 id="sec:profiling-predicates"><a id="sec:4.41.1"><span class="sec-nr">4.41.1</span> <span class="sec-title">Profiling
213254 predicates</span></a></h3>
214255
215 <a name="sec:profiling-predicates"></a>
256 <a id="sec:profiling-predicates"></a>
216257
217258 <p>The following predicates are defined to interact with the profiler.
218259
219260 <dl class="latex">
220 <dt class="pubdef"><a name="profile/1"><strong>profile</strong>(<var>:Goal</var>)</a></dt>
221 <dd class="defbody">
222 Execute <var>Goal</var> just like <a name="idx:once1:1566"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
261 <dt class="pubdef"><a id="profile/1"><strong>profile</strong>(<var>:Goal</var>)</a></dt>
262 <dd class="defbody">
263 Execute <var>Goal</var> just like <a id="idx:once1:1566"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
223264 collecting profiling statistics, and call <code>show_profile([])</code>.
224265 With XPCE installed this opens a graphical interface to examine the
225266 collected profiling data.</dd>
226 <dt class="pubdef"><a name="profile/3"><strong>profile</strong>(<var>:Goal,
267 <dt class="pubdef"><a id="profile/3"><strong>profile</strong>(<var>:Goal,
227268 +Options</var>)</a></dt>
228269 <dd class="defbody">
229 Execute <var>Goal</var> just like <a name="idx:once1:1567"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
230 Collect profiling statistics according to <var>Options</var> and call <a name="idx:showprofile1:1568"></a><a class="pred" href="profile.html#show_profile/1">show_profile/1</a>
270 Execute <var>Goal</var> just like <a id="idx:once1:1567"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
271 Collect profiling statistics according to <var>Options</var> and call <a id="idx:showprofile1:1568"></a><a class="pred" href="profile.html#show_profile/1">show_profile/1</a>
231272 with <var>Options</var>. The default collects CPU profiling and opens a
232273 graphical interface when provided, printing the `plain' time usage of
233274 the top 25 predicates as a ballback. Options are described below.
234 Remaining options are passed to <a name="idx:showprofile1:1569"></a><a class="pred" href="profile.html#show_profile/1">show_profile/1</a>.
275 Remaining options are passed to <a id="idx:showprofile1:1569"></a><a class="pred" href="profile.html#show_profile/1">show_profile/1</a>.
235276
236277 <dl class="latex">
237278 <dt><strong>time</strong>(<var>+Which</var>)</dt>
244285 </dl>
245286
246287 </dd>
247 <dt class="pubdef"><a name="show_profile/1"><strong>show_profile</strong>(<var>+Options</var>)</a></dt>
288 <dt class="pubdef"><a id="show_profile/1"><strong>show_profile</strong>(<var>+Options</var>)</a></dt>
248289 <dd class="defbody">
249290 This predicate first calls prolog:show_profile_hook/1. If XPCE is
250291 loaded, this hook is used to activate a GUI interface to visualise the
264305 </dl>
265306
266307 </dd>
267 <dt class="pubdef"><a name="profiler/2"><strong>profiler</strong>(<var>-Old,
308 <dt class="pubdef"><a id="profiler/2"><strong>profiler</strong>(<var>-Old,
268309 +New</var>)</a></dt>
269310 <dd class="defbody">
270311 Query or change the status of the profiler. The status is one of
286327
287328 <p>The value <code>true</code> is accepted as a synonym for <code>cputime</code>
288329 for compatibility reasons.</dd>
289 <dt class="pubdef"><a name="reset_profiler/0"><strong>reset_profiler</strong></a></dt>
330 <dt class="pubdef"><a id="reset_profiler/0"><strong>reset_profiler</strong></a></dt>
290331 <dd class="defbody">
291332 Switches the profiler to <code>false</code> and clears all collected
292333 statistics.</dd>
293 <dt class="pubdef"><a name="noprofile/1"><strong>noprofile</strong>(<var>+Name/+Arity,
334 <dt class="pubdef"><a id="noprofile/1"><strong>noprofile</strong>(<var>+Name/+Arity,
294335 ...</var>)</a></dt>
295336 <dd class="defbody">
296337 Declares the predicate <var>Name</var>/<var>Arity</var> to be invisible
297338 to the profiler. The time spent in the named predicate is added to the
298339 caller, and the callees are linked directly to the caller. This is
299 particularly useful for simple meta-predicates such as <a name="idx:call1:1570"></a><a class="pred" href="metacall.html#call/1">call/1</a>, <a name="idx:ignore1:1571"></a><a class="pred" href="metacall.html#ignore/1">ignore/1</a>, <a name="idx:catch3:1572"></a><a class="pred" href="exception.html#catch/3">catch/3</a>,
340 particularly useful for simple meta-predicates such as <a id="idx:call1:1570"></a><a class="pred" href="metacall.html#call/1">call/1</a>, <a id="idx:ignore1:1571"></a><a class="pred" href="metacall.html#ignore/1">ignore/1</a>, <a id="idx:catch3:1572"></a><a class="pred" href="exception.html#catch/3">catch/3</a>,
300341 etc.
301342 </dd>
302343 </dl>
303344
304 <p><h3 id="sec:pceprofile"><a name="sec:4.41.2"><span class="sec-nr">4.41.2</span> <span class="sec-title">Visualizing
345 <p><h3 id="sec:pceprofile"><a id="sec:4.41.2"><span class="sec-nr">4.41.2</span> <span class="sec-title">Visualizing
305346 profiling data</span></a></h3>
306347
307 <a name="sec:pceprofile"></a>
308
309 <p>Browsing the annotated call-tree as described in <a class="sec" href="profile.html">section
348 <a id="sec:pceprofile"></a>
349
350 <p>Browsing the annotated call-tree as described in <a class="sec" href="profile.html#sec:4.41.3">section
310351 4.41.3</a> itself is not very attractive. Therefore, the results are
311352 combined per predicate, collecting all <em>callers</em> and <em>callees</em>
312353 as well as the propagation of time and activations in both directions.
329370 detail window to the given caller or callee, showing the documentation
330371 (if it is a built-in) and/or jumping to the source.
331372
332 <p><a name="fig:profnode"></a><div style="text-align:center"><img src="profnode.gif"></div>
373 <p><a id="fig:profnode"></a><div style="text-align:center"><img src="profnode.gif"></div>
333374 <div class="caption"><b>Figure 5 : </b> Execution profiler showing the
334375 activity of the predicate chat:inv_map_list/5.</div>
335376
365406 the call-tree are not added to the call-tree.
366407 </ul>
367408
368 <p><h3 id="sec:profilegather"><a name="sec:4.41.3"><span class="sec-nr">4.41.3</span> <span class="sec-title">Information
409 <p><h3 id="sec:profilegather"><a id="sec:4.41.3"><span class="sec-nr">4.41.3</span> <span class="sec-title">Information
369410 gathering</span></a></h3>
370411
371 <a name="sec:profilegather"></a>
412 <a id="sec:profilegather"></a>
372413
373414 <p>While the program executes under the profiler, the system builds a
374415 <em>dynamic</em> call-tree. It does this using three hooks from the
386427 to recursion. For this reason the system performs detection of
387428 recursion. In the simplest case, recursive procedures increment the
388429 `recursive' count on the current node. Mutual recursion, however, is not
389 easily detected. For example, <a name="idx:call1:1573"></a><a class="pred" href="metacall.html#call/1">call/1</a>
390 can call a predicate that uses <a name="idx:call1:1574"></a><a class="pred" href="metacall.html#call/1">call/1</a>
430 easily detected. For example, <a id="idx:call1:1573"></a><a class="pred" href="metacall.html#call/1">call/1</a>
431 can call a predicate that uses <a id="idx:call1:1574"></a><a class="pred" href="metacall.html#call/1">call/1</a>
391432 itself. This can be viewed as a recursive invocation, but this is
392433 generally not desirable. Recursion is currently assumed if the same
393434 predicate <em>with the same parent</em> appears higher in the
399440 <code>SIGPROF</code>, it `ticks' the current node of the call-tree each
400441 time the timer fires. On Windows, a MM-timer in a separate thread checks
401442 100 times per second how much time is spent in the profiled thread and
402 adds this to the current node. See <a class="sec" href="profile.html">section
443 adds this to the current node. See <a class="sec" href="profile.html#sec:4.41.3.1">section
403444 4.41.3.1</a> for details.
404445
405 <p><h4 id="sec:winprofile"><a name="sec:4.41.3.1"><span class="sec-nr">4.41.3.1</span> <span class="sec-title">Profiling
446 <p><h4 id="sec:winprofile"><a id="sec:4.41.3.1"><span class="sec-nr">4.41.3.1</span> <span class="sec-title">Profiling
406447 in the Windows Implementation</span></a></h4>
407448
408 <a name="sec:winprofile"></a>
449 <a id="sec:winprofile"></a>
409450
410451 <p>Profiling in the Windows version is similar, but as profiling is a
411452 statistical process it is good to be aware of the implementation<sup class="fn">140<span class="fn-text">We
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="IDE.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="usingmodules.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:projectfiles"><a name="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">The
235 <h2 id="sec:projectfiles"><a id="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">The
195236 project source files</span></a></h2>
196237
197 <a name="sec:projectfiles"></a>
238 <a id="sec:projectfiles"></a>
198239
199240 <p>Organisation of source files depends largely on the size of your
200241 project. If you are doing exercises for a Prolog course you'll normally
203244 all together. Even bigger projects will be organised in sub-projects,
204245 each using its own directory.
205246
206 <p><h3 id="sec:filelocs"><a name="sec:3.1.1"><span class="sec-nr">3.1.1</span> <span class="sec-title">File
247 <p><h3 id="sec:filelocs"><a id="sec:3.1.1"><span class="sec-nr">3.1.1</span> <span class="sec-title">File
207248 Names and Locations</span></a></h3>
208249
209 <a name="sec:filelocs"></a>
210
211 <p><h4 id="sec:fileext"><a name="sec:3.1.1.1"><span class="sec-nr">3.1.1.1</span> <span class="sec-title">File
250 <a id="sec:filelocs"></a>
251
252 <p><h4 id="sec:fileext"><a id="sec:3.1.1.1"><span class="sec-nr">3.1.1.1</span> <span class="sec-title">File
212253 Name Extensions</span></a></h4>
213254
214 <a name="sec:fileext"></a>
215
216 <p><a name="idx:pl:292"></a><a name="idx:pro:293"></a>The first
255 <a id="sec:fileext"></a>
256
257 <p><a id="idx:pl:292"></a><a id="idx:pro:293"></a>The first
217258 consideration is what extension to use for the source files. Tradition
218259 calls for <code>.pl</code>, but conflicts with Perl force the use of
219260 another extension on systems where extensions have global meaning, such
240281 </dd>
241282 </dl>
242283
243 <p><h4 id="sec:projectdirs"><a name="sec:3.1.1.2"><span class="sec-nr">3.1.1.2</span> <span class="sec-title">Project
284 <p><h4 id="sec:projectdirs"><a id="sec:3.1.1.2"><span class="sec-nr">3.1.1.2</span> <span class="sec-title">Project
244285 Directories</span></a></h4>
245286
246 <a name="sec:projectdirs"></a>
247
248 <p><a name="idx:Sdiv:294"></a><a name="idx:chrSneg:295"></a>Large
249 projects are generally composed of sub-projects, each using its own
250 directory or directory structure. If nobody else will ever touch your
251 files and you use only one computer, there is little to worry about, but
252 this is rarely the case with a large project.
287 <a id="sec:projectdirs"></a>
288
289 <p><a id="idx:Sdiv:294"></a><a id="idx:chrSneg:295"></a>Large projects
290 are generally composed of sub-projects, each using its own directory or
291 directory structure. If nobody else will ever touch your files and you
292 use only one computer, there is little to worry about, but this is
293 rarely the case with a large project.
253294
254295 <p>To improve portability, SWI-Prolog uses the POSIX notation for
255296 filenames, which uses the forward slash (<code><code>/</code></code>) to
256297 separate directories. Just before reaching the file system, SWI-Prolog
257298 uses
258 <a name="idx:prologtoosfilename2:296"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>
299 <a id="idx:prologtoosfilename2:296"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>
259300 to convert the filename to the conventions used by the hosting operating
260301 system. It is <em>strongly</em> advised to write paths using the <code><code>/</code></code>,
261302 especially on systems using the
263304 violates the portability rules and requires you to <em>double</em> the <code><code>\</code></code>
264305 due to the Prolog quoted-atom escape rules.
265306
266 <p>Portable code should use <a name="idx:prologtoosfilename2:297"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>
307 <p>Portable code should use <a id="idx:prologtoosfilename2:297"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>
267308 to convert computed paths into system paths when constructing commands
268 for <a name="idx:shell1:298"></a><a class="pred" href="system.html#shell/1">shell/1</a>
309 for <a id="idx:shell1:298"></a><a class="pred" href="system.html#shell/1">shell/1</a>
269310 and friends.
270311
271 <p><h4 id="sec:projectpaths"><a name="sec:3.1.1.3"><span class="sec-nr">3.1.1.3</span> <span class="sec-title">Sub-projects
312 <p><h4 id="sec:projectpaths"><a id="sec:3.1.1.3"><span class="sec-nr">3.1.1.3</span> <span class="sec-title">Sub-projects
272313 using search paths</span></a></h4>
273314
274 <a name="sec:projectpaths"></a>
315 <a id="sec:projectpaths"></a>
275316
276317 <p>Thanks to Quintus, Prolog adapted an extensible mechanism for
277 searching files using <a name="idx:filesearchpath2:299"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
318 searching files using <a id="idx:filesearchpath2:299"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
278319 This mechanism allows for comfortable and readable specifications.
279320
280321 <p>Suppose you have extensive library packages on graph algorithms, set
285326 <p>Next, there are three options. One is to add the sub-projects to the
286327 directory hierarchy of the current project. Another is to use a
287328 completely dislocated directory. Third, the sub-project can be added to
288 the SWI-Prolog hierarchy. Using local installation, a typical <a name="idx:filesearchpath2:300"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
329 the SWI-Prolog hierarchy. Using local installation, a typical <a id="idx:filesearchpath2:300"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
289330 is:
290331
291332 <pre class="code">
301342 installation, use an absolute path.
302343
303344 <p>Extensive sub-projects with a small well-defined API should define a
304 load file with calls to <a name="idx:usemodule1:301"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
345 load file with calls to <a id="idx:usemodule1:301"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
305346 to import the various library components and export the API.
306347
307 <p><h3 id="sec:project-special-files"><a name="sec:3.1.2"><span class="sec-nr">3.1.2</span> <span class="sec-title">Project
348 <p><h3 id="sec:project-special-files"><a id="sec:3.1.2"><span class="sec-nr">3.1.2</span> <span class="sec-title">Project
308349 Special Files</span></a></h3>
309350
310 <a name="sec:project-special-files"></a>
351 <a id="sec:project-special-files"></a>
311352
312353 <p>There are a number of tasks you typically carry out on your project,
313354 such as loading it, creating a saved state, debugging it, etc. Good
314355 practice on large projects is to define small files that hold the
315356 commands to execute such a task, name this file after the task and give
316357 it a file extension that makes starting easy (see
317 <a class="sec" href="projectfiles.html">section 3.1.1.1</a>). The task <em>load</em>
318 is generally central to these tasks. Here is a tentative list:
358 <a class="sec" href="projectfiles.html#sec:3.1.1.1">section 3.1.1.1</a>).
359 The task <em>load</em> is generally central to these tasks. Here is a
360 tentative list:
319361
320362 <p>
321363 <ul class="latex">
334376 <p>
335377 <li><i><code>save.pl</code></i><br>
336378 Use this file to create a saved state of the application by loading
337 <code>load.pl</code> and calling <a name="idx:qsaveprogram2:302"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
379 <code>load.pl</code> and calling <a id="idx:qsaveprogram2:302"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
338380 to generate a saved state with the proper options.
339381
340382 <p>
341383 <li><i><code>debug.pl</code></i><br>
342384 Loads the program for debugging. In addition to loading <code>load.pl</code>
343 this file defines rules for <a name="idx:portray1:303"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
385 this file defines rules for <a id="idx:portray1:303"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
344386 to modify printing rules for complex terms and customisation rules for
345387 the debugger and editing environment. It may start some of these tools.
346388 </ul>
347389
348 <p><h3 id="sec:intsrcfile"><a name="sec:3.1.3"><span class="sec-nr">3.1.3</span> <span class="sec-title">International
390 <p><h3 id="sec:intsrcfile"><a id="sec:3.1.3"><span class="sec-nr">3.1.3</span> <span class="sec-title">International
349391 source files</span></a></h3>
350392
351 <a name="sec:intsrcfile"></a>
352
353 <p>As discussed in <a class="sec" href="widechars.html">section 2.19</a>,
354 SWI-Prolog supports international character handling. Its internal
355 encoding is UNICODE. I/O streams convert to/from this internal format.
356 This section discusses the options for source files not in US-ASCII.
393 <a id="sec:intsrcfile"></a>
394
395 <p>As discussed in <a class="sec" href="widechars.html#sec:2.19">section
396 2.19</a>, SWI-Prolog supports international character handling. Its
397 internal encoding is UNICODE. I/O streams convert to/from this internal
398 format. This section discusses the options for source files not in
399 US-ASCII.
357400
358401 <p>SWI-Prolog can read files in any of the encodings described in
359 <a class="sec" href="widechars.html">section 2.19</a>. Two encodings are
360 of particular interest. The
402 <a class="sec" href="widechars.html#sec:2.19">section 2.19</a>. Two
403 encodings are of particular interest. The
361404 <code>text</code> encoding deals with the current <em>locale</em>, the
362405 default used by this computer for representing text files. The encodings
363406 <code>utf8</code>, <code>unicode_le</code> and <code>unicode_be</code>
394437 <li><i>Using UTF-8 files</i><br>
395438 The best way to specify source files with many NON-ASCII characters is
396439 definitely the use of UTF-8 encoding. Prolog can be notified of this
397 encoding in two ways, using a UTF-8 <em>BOM</em> (see <a class="sec" href="widechars.html">section
440 encoding in two ways, using a UTF-8 <em>BOM</em> (see <a class="sec" href="widechars.html#sec:2.19.1.1">section
398441 2.19.1.1</a>) or using the directive <code>:- encoding(utf8).</code>
399442 Many of today's text editors, including PceEmacs, are capable of editing
400443 UTF-8 files. Projects that were started using local conventions can be
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.27</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.27</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="prologpack.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="quasiquotations.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:prolog_xref"><a name="sec:A.27"><span class="sec-nr">A.27</span> <span class="sec-title">library(prolog_xref):
235 <h2 id="sec:prolog_xref"><a id="sec:A.27"><span class="sec-nr">A.27</span> <span class="sec-title">library(prolog_xref):
195236 Cross-reference data collection library</span></a></h2>
196237
197 <a name="sec:prolog_xref"></a>
198 <a name="sec:lib:prologxref"></a>
238 <a id="sec:prolog_xref"></a>
239 <a id="sec:lib:prologxref"></a>
199240
200241 <p>This library collects information on defined and used objects in
201242 Prolog source files. Typically these are predicates, but we expect the
214255 consider this interface rock-solid.</b>
215256
216257 <p>The library is exploited by two graphical tools in the SWI-Prolog
217 environment: the XPCE front-end started by <a name="idx:gxref0:2151"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
258 environment: the XPCE front-end started by <a id="idx:gxref0:2155"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
218259 and described in
219 <a class="sec" href="xref.html">section 3.7</a>, and PceEmacs (<a class="sec" href="pceemacs.html">section
260 <a class="sec" href="xref.html#sec:3.7">section 3.7</a>, and PceEmacs (<a class="sec" href="pceemacs.html#sec:3.4">section
220261 3.4</a>), which exploits this library for its syntax colouring.
221262
222263 <p>For all predicates described below, <var>Source</var> is the source
223264 that is processed. This is normally a filename in any notation
224 acceptable to the file loading predicates (see <a name="idx:loadfiles2:2152"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>).
225 Using the hooks defined in <a class="sec" href="prolog_xref.html">section
265 acceptable to the file loading predicates (see <a id="idx:loadfiles2:2156"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>).
266 Using the hooks defined in <a class="sec" href="prolog_xref.html#sec:A.27.1">section
226267 A.27.1</a> it can be anything else that can be translated into a Prolog
227268 stream holding Prolog source text. <var>Callable</var> is a callable
228 term (see <a name="idx:callable1:2153"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>).
269 term (see <a id="idx:callable1:2157"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>).
229270 Callables do not carry a module qualifier unless the referred predicate
230271 is not in the module defined
231272 <var>Source</var>.
232273
233274 <dl class="latex">
234 <dt class="pubdef"><a name="xref_source/1"><strong>xref_source</strong>(<var>+Source</var>)</a></dt>
275 <dt class="pubdef"><a id="xref_source/1"><strong>xref_source</strong>(<var>+Source</var>)</a></dt>
235276 <dd class="defbody">
236277 Gather information on <var>Source</var>. If <var>Source</var> has
237278 already been processed and is still up-to-date according to the file
238279 timestamp, no action is taken. This predicate must be called on a file
239280 before information can be gathered.</dd>
240 <dt class="pubdef"><a name="xref_current_source/1"><strong>xref_current_source</strong>(<var>?Source</var>)</a></dt>
281 <dt class="pubdef"><a id="xref_current_source/1"><strong>xref_current_source</strong>(<var>?Source</var>)</a></dt>
241282 <dd class="defbody">
242283 <var>Source</var> has been processed.</dd>
243 <dt class="pubdef"><a name="xref_clean/1"><strong>xref_clean</strong>(<var>+Source</var>)</a></dt>
284 <dt class="pubdef"><a id="xref_clean/1"><strong>xref_clean</strong>(<var>+Source</var>)</a></dt>
244285 <dd class="defbody">
245286 Remove the information gathered for <var>Source</var></dd>
246 <dt class="pubdef"><a name="xref_defined/3"><strong>xref_defined</strong>(<var>?Source,
287 <dt class="pubdef"><a id="xref_defined/3"><strong>xref_defined</strong>(<var>?Source,
247288 ?Callable, -How</var>)</a></dt>
248289 <dd class="defbody">
249290 <var>Callable</var> is defined in <var>Source</var>. <var>How</var> is
250291 one of
251 <table border="0" frame="void" rules="groups" style="margin:auto">
252 <tr valign="top"><td><code>dynamic(Line)</code> </td><td>Declared
253 dynamic at <var>Line</var> </td></tr>
254 <tr valign="top"><td><code>thread_local(Line)</code> </td><td>Declared
255 thread local at <var>Line</var> </td></tr>
256 <tr valign="top"><td><code>multifile(Line)</code> </td><td>Declared
257 multifile at <var>Line</var> </td></tr>
258 <tr valign="top"><td><code>local(Line)</code> </td><td>First clause at <var>Line</var> </td></tr>
259 <tr valign="top"><td><code>foreign(Line)</code> </td><td>Foreign library
260 loaded at <var>Line</var> </td></tr>
261 <tr valign="top"><td><code>constraint(Line)</code> </td><td>CHR
262 Constraint at <var>Line</var> </td></tr>
263 <tr valign="top"><td><code>imported(File)</code> </td><td>Imported from <var>File</var> </td></tr>
292 <table class="latex frame-void center">
293 <tr><td><code>dynamic(Line)</code> </td><td>Declared dynamic at <var>Line</var> </td></tr>
294 <tr><td><code>thread_local(Line)</code> </td><td>Declared thread local
295 at <var>Line</var> </td></tr>
296 <tr><td><code>multifile(Line)</code> </td><td>Declared multifile at <var>Line</var> </td></tr>
297 <tr><td><code>local(Line)</code> </td><td>First clause at <var>Line</var> </td></tr>
298 <tr><td><code>foreign(Line)</code> </td><td>Foreign library loaded at <var>Line</var> </td></tr>
299 <tr><td><code>constraint(Line)</code> </td><td>CHR Constraint at <var>Line</var> </td></tr>
300 <tr><td><code>imported(File)</code> </td><td>Imported from <var>File</var> </td></tr>
264301 </table>
265302 </dd>
266 <dt class="pubdef"><a name="xref_called/3"><strong>xref_called</strong>(<var>?Source,
303 <dt class="pubdef"><a id="xref_called/3"><strong>xref_called</strong>(<var>?Source,
267304 ?Callable, ?By</var>)</a></dt>
268305 <dd class="defbody">
269306 <var>Callable</var> is called in <var>Source</var> by <var>By</var>.</dd>
270 <dt class="pubdef"><a name="xref_exported/2"><strong>xref_exported</strong>(<var>?Source,
307 <dt class="pubdef"><a id="xref_exported/2"><strong>xref_exported</strong>(<var>?Source,
271308 ?Callable</var>)</a></dt>
272309 <dd class="defbody">
273310 <var>Callable</var> is public (exported from the module).</dd>
274 <dt class="pubdef"><a name="xref_module/2"><strong>xref_module</strong>(<var>?Source,
311 <dt class="pubdef"><a id="xref_module/2"><strong>xref_module</strong>(<var>?Source,
275312 ?Module</var>)</a></dt>
276313 <dd class="defbody">
277314 <var>Source</var> is a module file defining the given module.</dd>
278 <dt class="pubdef"><a name="xref_built_in/1"><strong>xref_built_in</strong>(<var>?Callable</var>)</a></dt>
315 <dt class="pubdef"><a id="xref_built_in/1"><strong>xref_built_in</strong>(<var>?Callable</var>)</a></dt>
279316 <dd class="defbody">
280317 True if <var>Callable</var> is a built-in predicate. Currently this is
281318 assumed for all predicates defined in the <code>system</code> module and
284321 </dd>
285322 </dl>
286323
287 <p><h3 id="sec:xrefhooks"><a name="sec:A.27.1"><span class="sec-nr">A.27.1</span> <span class="sec-title">Extending
324 <p><h3 id="sec:xrefhooks"><a id="sec:A.27.1"><span class="sec-nr">A.27.1</span> <span class="sec-title">Extending
288325 the library</span></a></h3>
289326
290 <a name="sec:xrefhooks"></a>
327 <a id="sec:xrefhooks"></a>
291328
292329 <p>The library provides hooks for extending the rules it uses for
293330 finding predicates called by some programming construct.
294331
295332 <dl class="latex">
296 <dt class="pubdef"><a name="prolog:called_by/2"><strong>prolog:called_by</strong>(<var>+Goal,
333 <dt class="pubdef"><a id="prolog:called_by/2"><strong>prolog:called_by</strong>(<var>+Goal,
297334 -Called</var>)</a></dt>
298335 <dd class="defbody">
299336 <var>Goal</var> is a non-var subgoal appearing in the called object
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.26</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.26</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="predicate_options.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="prolog_xref.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:prologpack"><a name="sec:A.26"><span class="sec-nr">A.26</span> <span class="sec-title">library(prolog_pack):
235 <h2 id="sec:prologpack"><a id="sec:A.26"><span class="sec-nr">A.26</span> <span class="sec-title">library(prolog_pack):
195236 A package manager for Prolog</span></a></h2>
196237
197 <p><a name="sec:prologpack"></a>
238 <p><a id="sec:prologpack"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">See also</dt>
216257 that makes installed packages available as libaries.
217258
218259 <dl class="latex">
219 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_list_installed/0"><strong>pack_list_installed</strong></a></dt>
260 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_list_installed/0"><strong>pack_list_installed</strong></a></dt>
220261 <dd class="defbody">
221262 List currently installed packages. Unlike <a class="pred" href="prologpack.html#pack_list/1">pack_list/1</a>,
222263 only locally installed packages are displayed and no connection is made
231272 </dl>
232273
233274 </dd>
234 <dt class="pubdef"><a name="pack_info/1"><strong>pack_info</strong>(<var>+Pack</var>)</a></dt>
275 <dt class="pubdef"><a id="pack_info/1"><strong>pack_info</strong>(<var>+Pack</var>)</a></dt>
235276 <dd class="defbody">
236277 Print more detailed information about <var>Pack</var>.</dd>
237 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_search/1"><strong>pack_search</strong>(<var>+Query</var>)</a></dt>
238 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_list/1"><strong>pack_list</strong>(<var>+Query</var>)</a></dt>
278 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_search/1"><strong>pack_search</strong>(<var>+Query</var>)</a></dt>
279 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_list/1"><strong>pack_list</strong>(<var>+Query</var>)</a></dt>
239280 <dd class="defbody">
240281 <var>Query</var> package server and installed packages and display
241282 results.
278319 </dl>
279320
280321 </dd>
281 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_install/1"><strong>pack_install</strong>(<var>+Spec:atom</var>)</a></dt>
322 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_install/1"><strong>pack_install</strong>(<var>+Spec:atom</var>)</a></dt>
282323 <dd class="defbody">
283324 Install a package. <var>Spec</var> is one of
284325
295336
296337 <p>After resolving the type of package, <a class="pred" href="prologpack.html#pack_install/2">pack_install/2</a>
297338 is used to do the actual installation.</dd>
298 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_install/2"><strong>pack_install</strong>(<var>+Name,
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_install/2"><strong>pack_install</strong>(<var>+Name,
299340 +Options</var>)</a></dt>
300341 <dd class="defbody">
301342 Install package <var>Name</var>. Processes the options below. Default
337378 particular
338379 <i>trusted</i> URL instead of the plain pack name for unattented
339380 operation.</dd>
340 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_url_file/2"><strong>pack_url_file</strong>(<var>+URL,
381 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_url_file/2"><strong>pack_url_file</strong>(<var>+URL,
341382 -File</var>)</a></dt>
342383 <dd class="defbody">
343384 True if <var>File</var> is a unique id for the referenced pack and
344385 version. Normally, that is simply the base name, but GitHub archives
345386 destroy this picture. Needed by the pack manager.</dd>
346 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_rebuild/1"><strong>pack_rebuild</strong>(<var>+Pack</var>)</a></dt>
387 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_rebuild/1"><strong>pack_rebuild</strong>(<var>+Pack</var>)</a></dt>
347388 <dd class="defbody">
348389 Rebuilt possible foreign components of <var>Pack</var>.</dd>
349 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_rebuild/0"><strong>pack_rebuild</strong></a></dt>
390 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_rebuild/0"><strong>pack_rebuild</strong></a></dt>
350391 <dd class="defbody">
351392 Rebuild foreign components of all packages.</dd>
352 <dt class="multidef"><span class="pred-tag">[nondet,multifile]</span><a name="environment/2"><strong>environment</strong>(<var>-Name,
393 <dt class="multidef"><span class="pred-tag">[nondet,multifile]</span><a id="environment/2"><strong>environment</strong>(<var>-Name,
353394 -Value</var>)</a></dt>
354395 <dd class="defbody">
355396 Hook to define the environment for building packs. This Multifile hook
364405 </pre>
365406
366407 <table class="arglist">
367 <tr valign="top"><td><var>Name</var> </td><td>is an atom denoting a
368 valid variable name </td></tr>
369 <tr valign="top"><td><var>Value</var> </td><td>is either an atom or
370 number representing the value of the variable. </td></tr>
408 <tr><td><var>Name</var> </td><td>is an atom denoting a valid variable
409 name </td></tr>
410 <tr><td><var>Value</var> </td><td>is either an atom or number
411 representing the value of the variable. </td></tr>
371412 </table>
372413 </dd>
373 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="pack_upgrade/1"><strong>pack_upgrade</strong>(<var>+Pack</var>)</a></dt>
414 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="pack_upgrade/1"><strong>pack_upgrade</strong>(<var>+Pack</var>)</a></dt>
374415 <dd class="defbody">
375416 Try to upgrade the package <var>Pack</var>.
376417
382423 </dl>
383424
384425 </dd>
385 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_remove/1"><strong>pack_remove</strong>(<var>+Name</var>)</a></dt>
426 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_remove/1"><strong>pack_remove</strong>(<var>+Name</var>)</a></dt>
386427 <dd class="defbody">
387428 Remove the indicated package.</dd>
388 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="pack_property/2"><strong>pack_property</strong>(<var>?Pack,
429 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="pack_property/2"><strong>pack_property</strong>(<var>?Pack,
389430 ?Property</var>)</a></dt>
390431 <dd class="defbody">
391432 True when <var>Property</var> is a property of an installed <var>Pack</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.38</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.38</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="toplevel.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="debugger.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:protocol"><a name="sec:4.38"><span class="sec-nr">4.38</span> <span class="sec-title">Creating
235 <h2 id="sec:protocol"><a id="sec:4.38"><span class="sec-nr">4.38</span> <span class="sec-title">Creating
195236 a Protocol of the User Interaction</span></a></h2>
196237
197 <a name="sec:protocol"></a>
238 <a id="sec:protocol"></a>
198239
199240 <p>SWI-Prolog offers the possibility to log the interaction with the
200241 user on a file.<sup class="fn">138<span class="fn-text">A similar
203244 written to the protocol file.
204245
205246 <dl class="latex">
206 <dt class="pubdef"><a name="protocol/1"><strong>protocol</strong>(<var>+File</var>)</a></dt>
247 <dt class="pubdef"><a id="protocol/1"><strong>protocol</strong>(<var>+File</var>)</a></dt>
207248 <dd class="defbody">
208249 Start protocolling on file <var>File</var>. If there is already a
209250 protocol file open, then close it first. If <var>File</var> exists it is
210251 truncated.
211252 </dd>
212 <dt class="pubdef"><a name="protocola/1"><strong>protocola</strong>(<var>+File</var>)</a></dt>
213 <dd class="defbody">
214 Equivalent to <a name="idx:protocol1:1538"></a><a class="pred" href="protocol.html#protocol/1">protocol/1</a>,
253 <dt class="pubdef"><a id="protocola/1"><strong>protocola</strong>(<var>+File</var>)</a></dt>
254 <dd class="defbody">
255 Equivalent to <a id="idx:protocol1:1538"></a><a class="pred" href="protocol.html#protocol/1">protocol/1</a>,
215256 but does not truncate the <var>File</var> if it exists.
216257 </dd>
217 <dt class="pubdef"><a name="noprotocol/0"><strong>noprotocol</strong></a></dt>
258 <dt class="pubdef"><a id="noprotocol/0"><strong>noprotocol</strong></a></dt>
218259 <dd class="defbody">
219260 Stop making a protocol of the user interaction. Pending output is
220261 flushed on the file.
221262 </dd>
222 <dt class="pubdef"><a name="protocolling/1"><strong>protocolling</strong>(<var>-File</var>)</a></dt>
223 <dd class="defbody">
224 True if a protocol was started with <a name="idx:protocol1:1539"></a><a class="pred" href="protocol.html#protocol/1">protocol/1</a>
225 or <a name="idx:protocola1:1540"></a><a class="pred" href="protocol.html#protocola/1">protocola/1</a>
263 <dt class="pubdef"><a id="protocolling/1"><strong>protocolling</strong>(<var>-File</var>)</a></dt>
264 <dd class="defbody">
265 True if a protocol was started with <a id="idx:protocol1:1539"></a><a class="pred" href="protocol.html#protocol/1">protocol/1</a>
266 or <a id="idx:protocola1:1540"></a><a class="pred" href="protocol.html#protocola/1">protocola/1</a>
226267 and unifies <var>File</var> with the current protocol output file.
227268 </dd>
228269 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 12.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="qsavelimits.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="useresource.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:qsaveforeign"><a name="sec:12.2"><span class="sec-nr">12.2</span> <span class="sec-title">Runtimes
235 <h2 id="sec:qsaveforeign"><a id="sec:12.2"><span class="sec-nr">12.2</span> <span class="sec-title">Runtimes
195236 and Foreign Code</span></a></h2>
196237
197 <a name="sec:qsaveforeign"></a>
198
199 <p><a name="sec:qforeign"></a> Some applications may need to use the
238 <a id="sec:qsaveforeign"></a>
239
240 <p><a id="sec:qforeign"></a> Some applications may need to use the
200241 foreign language interface. Object code is by definition
201242 machine-dependent and thus cannot be part of the saved program file.
202243
223264 have a source file <code>myextension.c</code> defining the installation
224265 function install().
225266
226 <p>If this file is compiled into a shared library, <a name="idx:loadforeignlibrary1:2116"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
267 <p>If this file is compiled into a shared library, <a id="idx:loadforeignlibrary1:2120"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
227268 will load this library and call the installation function to initialise
228269 the foreign code. If it is loaded as a static extension, define
229270 install() as the predicate install/0 :
257298 :- initialization load_foreign_extensions.
258299 </pre>
259300
260 <p>The path alias <code>foreign</code> is defined by <a name="idx:filesearchpath2:2117"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
301 <p>The path alias <code>foreign</code> is defined by <a id="idx:filesearchpath2:2121"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
261302 By default it searches the directories <code>&lt;<var>home</var>&gt;/lib/&lt;<var>arch</var>&gt;</code>
262303 and
263304 <code>&lt;<var>home</var>&gt;/lib</code>. The application can specify
264305 additional rules for
265 <a name="idx:filesearchpath2:2118"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
306 <a id="idx:filesearchpath2:2122"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
266307
267308 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 12.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="runtime.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="qsaveforeign.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:qsavelimits"><a name="sec:12.1"><span class="sec-nr">12.1</span> <span class="sec-title">Limitations
235 <h2 id="sec:qsavelimits"><a id="sec:12.1"><span class="sec-nr">12.1</span> <span class="sec-title">Limitations
195236 of qsave_program</span></a></h2>
196237
197 <a name="sec:qsavelimits"></a>
238 <a id="sec:qsavelimits"></a>
198239
199240 <p>There are three areas that require special attention when using
200 <a name="idx:qsaveprogram12:2112"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.
241 <a id="idx:qsaveprogram12:2116"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.
201242
202243 <p>
203244 <ul class="latex">
204245 <li>If the program is an embedded Prolog application or uses the foreign
205246 language interface, care has to be taken to restore the appropriate
206 foreign context. See <a class="sec" href="qsaveforeign.html">section
247 foreign context. See <a class="sec" href="qsaveforeign.html#sec:12.2">section
207248 12.2</a> for details.
208249
209250 <p>
210251 <li>If the program uses directives (<code>:- goal.</code> lines) that
211252 perform other actions than setting predicate attributes (dynamic,
212253 volatile, etc.) or loading files (consult, etc.), the directive may need
213 to be prefixed with <a name="idx:initialization1:2113"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.
254 to be prefixed with <a id="idx:initialization1:2117"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.
214255
215256 <p>
216 <li>Database references as returned by <a name="idx:clause3:2114"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>, <a name="idx:recorded3:2115"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>,
257 <li>Database references as returned by <a id="idx:clause3:2118"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>, <a id="idx:recorded3:2119"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>,
217258 etc., are not preserved and may thus not be part of the database when
218259 saved.
219260 </ul>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.28</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.28</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="prolog_xref.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="random.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:quasiquotations"><a name="sec:A.28"><span class="sec-nr">A.28</span> <span class="sec-title">library(quasi_quotations):
235 <h2 id="sec:quasiquotations"><a id="sec:A.28"><span class="sec-nr">A.28</span> <span class="sec-title">library(quasi_quotations):
195236 Define Quasi Quotation syntax</span></a></h2>
196237
197 <p><a name="sec:quasiquotations"></a>
238 <p><a id="sec:quasiquotations"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">author</dt>
204245 </dd>
205246 <dt class="tag">See also</dt>
206247 <dd>
207 http://www.cs.tufts.edu/comp/150FP/archive/geoff-mainland/quasiquoting.pdfWhy
208 it's nice to be quoted: quasiquoting for haskell
248 <a class="url" href="http://www.cs.tufts.edu/comp/150FP/archive/geoff-mainland/quasiquoting.pdf">Why
249 it's nice to be quoted: quasiquoting for haskell</a>
209250 </dd>
210251 </dl>
211252
212253 <p>Inspired by
213 http://www.haskell.org/haskellwiki/QuasiquotationHaskell, SWI-Prolog
214 support <i>quasi quotation</i>. Quasi quotation allows for embedding
215 (long) strings using the syntax of an external language (e.g., HTML,
216 SQL) in Prolog text and syntax-aware embedding of Prolog variables in
217 this syntax. At the same time, quasi quotation provides an alternative
218 to represent long strings and atoms in Prolog.
254 <a class="url" href="http://www.haskell.org/haskellwiki/Quasiquotation">Haskell</a>,
255 SWI-Prolog support <i>quasi quotation</i>. Quasi quotation allows for
256 embedding (long) strings using the syntax of an external language (e.g.,
257 HTML, SQL) in Prolog text and syntax-aware embedding of Prolog variables
258 in this syntax. At the same time, quasi quotation provides an
259 alternative to represent long strings and atoms in Prolog.
219260
220261 <p>The basic form of a quasi quotation is defined below. Here, <var>Syntax</var>
221262 is an arbitrary Prolog term that must parse into a <i>callable</i> (atom
284325 the, suprisingly simple, quasi quotation parser for HTML.
285326
286327 <dl class="latex">
287 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="with_quasi_quotation_input/3"><strong>with_quasi_quotation_input</strong>(<var>+Content,
328 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="with_quasi_quotation_input/3"><strong>with_quasi_quotation_input</strong>(<var>+Content,
288329 -Stream, :Goal</var>)</a></dt>
289330 <dd class="defbody">
290331 Process the quasi-quoted <var>Content</var> using <var>Stream</var>
300341 <li>It will be closed after <var>Goal</var> completes.
301342 </ul>
302343 <table class="arglist">
303 <tr valign="top"><td><var>Goal</var> </td><td>is executed as <code>once(Goal)</code>. <var>Goal</var>
344 <tr><td><var>Goal</var> </td><td>is executed as <code>once(Goal)</code>. <var>Goal</var>
304345 must succeed. Failure or exceptions from <var>Goal</var> are interpreted
305346 as syntax errors. </td></tr>
306347 </table>
314355 </dl>
315356
316357 </dd>
317 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="phrase_from_quasi_quotation/2"><strong>phrase_from_quasi_quotation</strong>(<var>:Grammar,
358 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="phrase_from_quasi_quotation/2"><strong>phrase_from_quasi_quotation</strong>(<var>:Grammar,
318359 +Content</var>)</a></dt>
319360 <dd class="defbody">
320361 Process the quasi quotation using the DCG <var>Grammar</var>. Failure of
329370 </dl>
330371
331372 </dd>
332 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="quasi_quotation_syntax/1"><strong>quasi_quotation_syntax</strong>(<var>:SyntaxName</var>)</a></dt>
373 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="quasi_quotation_syntax/1"><strong>quasi_quotation_syntax</strong>(<var>:SyntaxName</var>)</a></dt>
333374 <dd class="defbody">
334375 Declare the predicate <var>SyntaxName</var>/4 to implement the the quasi
335376 quote syntax <var>SyntaxName</var>. Normally used as a directive.</dd>
336 <dt class="pubdef"><a name="quasi_quotation_syntax_error/1"><strong>quasi_quotation_syntax_error</strong>(<var>+Error</var>)</a></dt>
377 <dt class="pubdef"><a id="quasi_quotation_syntax_error/1"><strong>quasi_quotation_syntax_error</strong>(<var>+Error</var>)</a></dt>
337378 <dd class="defbody">
338379 Report <code>syntax_error(Error)</code> using the current location in
339380 the quasi quoted input parser.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="overview.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="initfile.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:quickstart"><a name="sec:2.1"><span class="sec-nr">2.1</span> <span class="sec-title">Getting
235 <h2 id="sec:quickstart"><a id="sec:2.1"><span class="sec-nr">2.1</span> <span class="sec-title">Getting
195236 started quickly</span></a></h2>
196237
197 <a name="sec:quickstart"></a>
198
199 <p><h3 id="sec:startpl"><a name="sec:2.1.1"><span class="sec-nr">2.1.1</span> <span class="sec-title">Starting
238 <a id="sec:quickstart"></a>
239
240 <p><h3 id="sec:startpl"><a id="sec:2.1.1"><span class="sec-nr">2.1.1</span> <span class="sec-title">Starting
200241 SWI-Prolog</span></a></h3>
201242
202 <a name="sec:startpl"></a>
203
204 <p><h4 id="sec:startunix"><a name="sec:2.1.1.1"><span class="sec-nr">2.1.1.1</span> <span class="sec-title">Starting
243 <a id="sec:startpl"></a>
244
245 <p><h4 id="sec:startunix"><a id="sec:2.1.1.1"><span class="sec-nr">2.1.1.1</span> <span class="sec-title">Starting
205246 SWI-Prolog on Unix</span></a></h4>
206247
207 <a name="sec:startunix"></a>
248 <a id="sec:startunix"></a>
208249
209250 <p>By default, SWI-Prolog is installed as `swipl'. The command line
210251 arguments of SWI-Prolog itself and its utility programs are documented
220261 </pre>
221262
222263 <p>After starting Prolog, one normally loads a program into it using
223 <a name="idx:consult1:6"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
264 <a id="idx:consult1:6"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
224265 which may be abbreviated by putting the name of the program file between
225266 square brackets. The following goal loads the file
226 https://raw.githubusercontent.com/SWI-Prolog/swipl-devel/master/demo/likes.pllikes.pl
267 <a class="url" href="https://raw.githubusercontent.com/SWI-Prolog/swipl-devel/master/demo/likes.pl">likes.pl</a>
227268 containing clauses for the predicates likes/2 :
228269
229270 <pre class="code">
245286 </pre>
246287
247288 <p>After this point, Unix and Windows users unite, so if you are using
248 Unix please continue at <a class="sec" href="quickstart.html">section
289 Unix please continue at <a class="sec" href="quickstart.html#sec:2.1.3">section
249290 2.1.3</a>.
250291
251 <p><h4 id="sec:startwin"><a name="sec:2.1.1.2"><span class="sec-nr">2.1.1.2</span> <span class="sec-title">Starting
292 <p><h4 id="sec:startwin"><a id="sec:2.1.1.2"><span class="sec-nr">2.1.1.2</span> <span class="sec-title">Starting
252293 SWI-Prolog on Windows</span></a></h4>
253294
254 <a name="sec:startwin"></a>
295 <a id="sec:startwin"></a>
255296
256297 <p>After SWI-Prolog has been installed on a Windows system, the
257298 following important new things are available to the user:
272313 </ul>
273314
274315 <p>The normal way to start the <code>likes.pl</code> file mentioned in
275 <a class="sec" href="quickstart.html">section 2.1.1.1</a> is by simply
276 double-clicking this file in the Windows explorer.
277
278 <p><h3 id="sec:consultuser"><a name="sec:2.1.2"><span class="sec-nr">2.1.2</span> <span class="sec-title">Adding
316 <a class="sec" href="quickstart.html#sec:2.1.1.1">section 2.1.1.1</a> is
317 by simply double-clicking this file in the Windows explorer.
318
319 <p><h3 id="sec:consultuser"><a id="sec:2.1.2"><span class="sec-nr">2.1.2</span> <span class="sec-title">Adding
279320 rules from the console</span></a></h3>
280321
281 <a name="sec:consultuser"></a>
322 <a id="sec:consultuser"></a>
282323
283324 <p>Although we strongly advice to put your program in a file, optionally
284 edit it and use <a name="idx:make0:7"></a><a class="pred" href="consulting.html#make/0">make/0</a>
285 to reload it (see <a class="sec" href="quickstart.html">section 2.1.4</a>),
286 it is possible to manage facts and rules from the terminal. The most
287 conveniant way to add a few clauses is by consulting the pseudo file
325 edit it and use <a id="idx:make0:7"></a><a class="pred" href="consulting.html#make/0">make/0</a>
326 to reload it (see <a class="sec" href="quickstart.html#sec:2.1.4">section
327 2.1.4</a>), it is possible to manage facts and rules from the terminal.
328 The most conveniant way to add a few clauses is by consulting the pseudo
329 file
288330 <code>user</code>. The input is ended using the system end-of-file
289331 character.
290332
299341 true.
300342 </pre>
301343
302 <p>The predicates <a name="idx:assertz1:8"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
303 and <a name="idx:retract1:9"></a><a class="pred" href="db.html#retract/1">retract/1</a>
344 <p>The predicates <a id="idx:assertz1:8"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
345 and <a id="idx:retract1:9"></a><a class="pred" href="db.html#retract/1">retract/1</a>
304346 are alternatives to add and remove rules and facts.
305347
306 <p><h3 id="sec:execquery"><a name="sec:2.1.3"><span class="sec-nr">2.1.3</span> <span class="sec-title">Executing
348 <p><h3 id="sec:execquery"><a id="sec:2.1.3"><span class="sec-nr">2.1.3</span> <span class="sec-title">Executing
307349 a query</span></a></h3>
308350
309 <a name="sec:execquery"></a>
351 <a id="sec:execquery"></a>
310352
311353 <p>After loading a program, one can ask Prolog queries about the
312354 program. The query below asks Prolog what food `sam' likes. The system
339381 differs in several ways from traditional Prolog top level. The current
340382 top level was designed in cooperation with Ulrich Neumerkel.</span></sup>
341383
342 <p><h3 id="sec:viewprogram"><a name="sec:2.1.4"><span class="sec-nr">2.1.4</span> <span class="sec-title">Examining
384 <p><h3 id="sec:viewprogram"><a id="sec:2.1.4"><span class="sec-nr">2.1.4</span> <span class="sec-title">Examining
343385 and modifying your program</span></a></h3>
344386
345 <a name="sec:viewprogram"></a>
346
347 <p>If properly configured, the predicate <a name="idx:edit1:10"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
387 <a id="sec:viewprogram"></a>
388
389 <p>If properly configured, the predicate <a id="idx:edit1:10"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
348390 starts the built-in or user configured editor on the argument. The
349391 argument can be anything that can be linked to a location: a file name,
350392 predicate name, module name, etc. If the argument resolves to only one
353395
354396 <p>If a graphical user interface is available, the editor normally
355397 creates a new window and the system prompts for the next command. The
356 user may edit the source file, save it and run <a name="idx:make0:11"></a><a class="pred" href="consulting.html#make/0">make/0</a>
398 user may edit the source file, save it and run <a id="idx:make0:11"></a><a class="pred" href="consulting.html#make/0">make/0</a>
357399 to update any modified source file. If the editor cannot be opened in a
358 window it the same console and leaving the editor runs <a name="idx:make0:12"></a><a class="pred" href="consulting.html#make/0">make/0</a>
400 window it the same console and leaving the editor runs <a id="idx:make0:12"></a><a class="pred" href="consulting.html#make/0">make/0</a>
359401 to reload any source files that have been modified.
360402
361403 <pre class="code">
369411 ...
370412 </pre>
371413
372 <p>The program can also be <em>decompiled</em> using <a name="idx:listing1:13"></a><a class="pred" href="listing.html#listing/1">listing/1</a>
373 as below. The argument is <a name="idx:listing1:14"></a><a class="pred" href="listing.html#listing/1">listing/1</a>
414 <p>The program can also be <em>decompiled</em> using <a id="idx:listing1:13"></a><a class="pred" href="listing.html#listing/1">listing/1</a>
415 as below. The argument is <a id="idx:listing1:14"></a><a class="pred" href="listing.html#listing/1">listing/1</a>
374416 is just a predicate name, a predicate
375417 <em>indicator</em> of the form <var>Name/Arity</var>, e.g., <code>?-
376 listing(<a name="idx:mild1:15"></a><span class="pred-ext">mild/1</span>).</code>
418 listing(<a id="idx:mild1:15"></a><span class="pred-ext">mild/1</span>).</code>
377419 or a <em>head</em>, e.g., <code>?- listing(likes(sam, _).</code>,
378 listing all <em>matching</em> clauses. The predicate <a name="idx:listing0:16"></a><a class="pred" href="listing.html#listing/0">listing/0</a>,
420 listing all <em>matching</em> clauses. The predicate <a id="idx:listing0:16"></a><a class="pred" href="listing.html#listing/0">listing/0</a>,
379421 i.e., without arguments lists the entire program.<sup class="fn">8<span class="fn-text">This
380422 lists several <em>hook</em> predicates that are defined by default and
381423 is typically not very informative.</span></sup>
389431 true.
390432 </pre>
391433
392 <p><h3 id="sec:halt"><a name="sec:2.1.5"><span class="sec-nr">2.1.5</span> <span class="sec-title">Stopping
434 <p><h3 id="sec:halt"><a id="sec:2.1.5"><span class="sec-nr">2.1.5</span> <span class="sec-title">Stopping
393435 Prolog</span></a></h3>
394436
395 <a name="sec:halt"></a>
437 <a id="sec:halt"></a>
396438
397439 <p>The interactive toplevel can be stopped in two ways: enter the system
398440 end-of-file character (typically <i>Control-D</i>) or by executing the
399 <a name="idx:halt0:17"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
441 <a id="idx:halt0:17"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
400442 predicate:
401443
402444 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.29</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.29</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="quasiquotations.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="readutil.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:random"><a name="sec:A.29"><span class="sec-nr">A.29</span> <span class="sec-title">library(random):
235 <h2 id="sec:random"><a id="sec:A.29"><span class="sec-nr">A.29</span> <span class="sec-title">library(random):
195236 Random numbers</span></a></h2>
196237
197 <p><a name="sec:random"></a>
238 <p><a id="sec:random"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">author</dt>
214255 are based on the GMP library.
215256
216257 <dl class="latex">
217 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random/1"><strong>random</strong>(<var>-R:float</var>)</a></dt>
258 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random/1"><strong>random</strong>(<var>-R:float</var>)</a></dt>
218259 <dd class="defbody">
219260 Binds <var>R</var> to a new random float in the <i>open</i> interval
220261 (0.0,1.0).
231272 </dl>
232273
233274 </dd>
234 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_between/3"><strong>random_between</strong>(<var>+L:int,
275 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_between/3"><strong>random_between</strong>(<var>+L:int,
235276 +U:int, -R:int</var>)</a></dt>
236277 <dd class="defbody">
237278 Binds <var>R</var> to a random integer in [<var>L</var>,<var>U</var>]
238279 (i.e., including both <var>L</var> and
239280 <var>U</var>). Fails silently if <var>U</var><var>&lt;</var><var>L</var>.</dd>
240 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random/3"><strong>random</strong>(<var>+L:int,
281 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random/3"><strong>random</strong>(<var>+L:int,
241282 +U:int, -R:int</var>)</a></dt>
242 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random/3"><strong>random</strong>(<var>+L:float,
283 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random/3"><strong>random</strong>(<var>+L:float,
243284 +U:float, -R:float</var>)</a></dt>
244285 <dd class="defbody">
245286 Generate a random integer or float in a range. If <var>L</var> and <var>U</var>
259300 </dl>
260301
261302 </dd>
262 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="setrand/1"><strong>setrand</strong>(<var>+State</var>)</a></dt>
263 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="getrand/1"><strong>getrand</strong>(<var>-State</var>)</a></dt>
303 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="setrand/1"><strong>setrand</strong>(<var>+State</var>)</a></dt>
304 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="getrand/1"><strong>getrand</strong>(<var>-State</var>)</a></dt>
264305 <dd class="defbody">
265306 Query/set the state of the random generator. This is intended for
266307 restarting the generator at a known state only. The predicate <a class="pred" href="random.html#setrand/1">setrand/1</a>
290331 </dl>
291332
292333 </dd>
293 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="maybe/0"><strong>maybe</strong></a></dt>
334 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="maybe/0"><strong>maybe</strong></a></dt>
294335 <dd class="defbody">
295336 Succeed/fail with equal probability (variant of <a class="pred" href="random.html#maybe/1">maybe/1</a>).</dd>
296 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="maybe/1"><strong>maybe</strong>(<var>+P</var>)</a></dt>
337 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="maybe/1"><strong>maybe</strong>(<var>+P</var>)</a></dt>
297338 <dd class="defbody">
298339 Succeed with probability <var>P</var>, fail with probability 1-<var>P</var></dd>
299 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="maybe/2"><strong>maybe</strong>(<var>+K,
340 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="maybe/2"><strong>maybe</strong>(<var>+K,
300341 +N</var>)</a></dt>
301342 <dd class="defbody">
302343 Succeed with probability <var>K</var>/<var>N</var> (variant of <a class="pred" href="random.html#maybe/1">maybe/1</a>)</dd>
303 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_perm2/4"><strong>random_perm2</strong>(<var>?A,
344 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_perm2/4"><strong>random_perm2</strong>(<var>?A,
304345 ?B, ?X, ?Y</var>)</a></dt>
305346 <dd class="defbody">
306347 Does <var>X</var>=<var>A</var>,<var>Y</var>=<var>B</var> or <var>X</var>=<var>B</var>,<var>Y</var>=<var>A</var>
307348 with equal probability.</dd>
308 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_member/2"><strong>random_member</strong>(<var>-X,
349 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_member/2"><strong>random_member</strong>(<var>-X,
309350 +List:list</var>)</a></dt>
310351 <dd class="defbody">
311352 <var>X</var> is a random member of <var>List</var>. Equivalent to
321362 </dl>
322363
323364 </dd>
324 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_select/3"><strong>random_select</strong>(<var>-X,
365 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_select/3"><strong>random_select</strong>(<var>-X,
325366 +List, -Rest</var>)</a></dt>
326 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_select/3"><strong>random_select</strong>(<var>+X,
367 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_select/3"><strong>random_select</strong>(<var>+X,
327368 -List, +Rest</var>)</a></dt>
328369 <dd class="defbody">
329370 Randomly select or insert an element. Either <var>List</var> or <var>Rest</var>
337378 </dl>
338379
339380 </dd>
340 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="randset/3"><strong>randset</strong>(<var>+K:int,
381 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="randset/3"><strong>randset</strong>(<var>+K:int,
341382 +N:int, -S:list(int)</var>)</a></dt>
342383 <dd class="defbody">
343384 <var>S</var> is a sorted list of <var>K</var> unique random integers in
364405 </dl>
365406
366407 </dd>
367 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="randseq/3"><strong>randseq</strong>(<var>+K:int,
408 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="randseq/3"><strong>randseq</strong>(<var>+K:int,
368409 +N:int, -List:list(int)</var>)</a></dt>
369410 <dd class="defbody">
370411 S is a list of <var>K</var> unique random integers in the range 1..<var>N</var>.
384425 </dl>
385426
386427 </dd>
387 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_permutation/2"><strong>random_permutation</strong>(<var>+List,
428 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_permutation/2"><strong>random_permutation</strong>(<var>+List,
388429 -Permutation</var>)</a></dt>
389 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_permutation/2"><strong>random_permutation</strong>(<var>-List,
430 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_permutation/2"><strong>random_permutation</strong>(<var>-List,
390431 +Permutation</var>)</a></dt>
391432 <dd class="defbody">
392433 <var>Permutation</var> is a random permutation of <var>List</var>. This
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.30</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.30</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="random.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="record.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:readutil"><a name="sec:A.30"><span class="sec-nr">A.30</span> <span class="sec-title">library(readutil):
235 <h2 id="sec:readutil"><a id="sec:A.30"><span class="sec-nr">A.30</span> <span class="sec-title">library(readutil):
195236 Reading lines, streams and files</span></a></h2>
196237
197 <a name="sec:readutil"></a>
238 <a id="sec:readutil"></a>
198239
199240 <p>This library contains primitives to read lines, files, multiple
200241 terms, etc. The package <code>clib</code> provides a shared object (DLL)
205246 shared object if performance of these predicates is critical.
206247
207248 <dl class="latex">
208 <dt class="pubdef"><a name="read_line_to_codes/2"><strong>read_line_to_codes</strong>(<var>+Stream,
249 <dt class="pubdef"><a id="read_line_to_codes/2"><strong>read_line_to_codes</strong>(<var>+Stream,
209250 -Codes</var>)</a></dt>
210251 <dd class="defbody">
211252 Read the next line of input from <var>Stream</var> and unify the result
212253 with
213254 <var>Codes</var> <em>after</em> the line has been read. A line is ended
214 by a newline character or end-of-file. Unlike <a name="idx:readlinetocodes3:2154"></a><a class="pred" href="readutil.html#read_line_to_codes/3">read_line_to_codes/3</a>,
255 by a newline character or end-of-file. Unlike <a id="idx:readlinetocodes3:2158"></a><a class="pred" href="readutil.html#read_line_to_codes/3">read_line_to_codes/3</a>,
215256 this predicate removes a trailing newline character.
216257
217258 <p>On end-of-file the atom <code>end_of_file</code> is returned. See
218259 also
219 <a name="idx:atendofstream01:2155"></a><a class="pred" href="chario.html#at_end_of_stream/0">at_end_of_stream/[0,1]</a>.</dd>
220 <dt class="pubdef"><a name="read_line_to_codes/3"><strong>read_line_to_codes</strong>(<var>+Stream,
260 <a id="idx:atendofstream01:2159"></a><a class="pred" href="chario.html#at_end_of_stream/0">at_end_of_stream/[0,1]</a>.</dd>
261 <dt class="pubdef"><a id="read_line_to_codes/3"><strong>read_line_to_codes</strong>(<var>+Stream,
221262 -Codes, ?Tail</var>)</a></dt>
222263 <dd class="defbody">
223264 Difference-list version to read an input line to a list of character
224 codes. Reading stops at the newline or end-of-file character, but unlike <a name="idx:readlinetocodes2:2156"></a><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a>,
265 codes. Reading stops at the newline or end-of-file character, but unlike <a id="idx:readlinetocodes2:2160"></a><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a>,
225266 the newline is retained in the output. This predicate is especially
226267 useful for reading a block of lines up to some delimiter. The following
227268 example reads an HTTP header ended by a blank line:
240281 </pre>
241282
242283 </dd>
243 <dt class="pubdef"><a name="read_stream_to_codes/2"><strong>read_stream_to_codes</strong>(<var>+Stream,
284 <dt class="pubdef"><a id="read_stream_to_codes/2"><strong>read_stream_to_codes</strong>(<var>+Stream,
244285 -Codes</var>)</a></dt>
245286 <dd class="defbody">
246287 Read all input until end-of-file and unify the result to <var>Codes</var>.</dd>
247 <dt class="pubdef"><a name="read_stream_to_codes/3"><strong>read_stream_to_codes</strong>(<var>+Stream,
288 <dt class="pubdef"><a id="read_stream_to_codes/3"><strong>read_stream_to_codes</strong>(<var>+Stream,
248289 -Codes, ?Tail</var>)</a></dt>
249290 <dd class="defbody">
250 Difference-list version of <a name="idx:readstreamtocodes2:2157"></a><a class="pred" href="readutil.html#read_stream_to_codes/2">read_stream_to_codes/2</a>.</dd>
251 <dt class="pubdef"><a name="read_file_to_codes/3"><strong>read_file_to_codes</strong>(<var>+Spec,
291 Difference-list version of <a id="idx:readstreamtocodes2:2161"></a><a class="pred" href="readutil.html#read_stream_to_codes/2">read_stream_to_codes/2</a>.</dd>
292 <dt class="pubdef"><a id="read_file_to_codes/3"><strong>read_file_to_codes</strong>(<var>+Spec,
252293 -Codes, +Options</var>)</a></dt>
253294 <dd class="defbody">
254295 Read a file to a list of character codes. <var>Spec</var> is a file
255 specification for <a name="idx:absolutefilename3:2158"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>. <var>Codes</var>
296 specification for <a id="idx:absolutefilename3:2162"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>. <var>Codes</var>
256297 is the resulting code list. <var>Options</var> is a list of options for
257 <a name="idx:absolutefilename3:2159"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
258 and <a name="idx:open4:2160"></a><a class="pred" href="IO.html#open/4">open/4</a>.
298 <a id="idx:absolutefilename3:2163"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
299 and <a id="idx:open4:2164"></a><a class="pred" href="IO.html#open/4">open/4</a>.
259300 In addition, the option
260301 <code>tail(Tail)</code> is defined, forming a difference-list.</dd>
261 <dt class="pubdef"><a name="read_file_to_terms/3"><strong>read_file_to_terms</strong>(<var>+Spec,
302 <dt class="pubdef"><a id="read_file_to_terms/3"><strong>read_file_to_terms</strong>(<var>+Spec,
262303 -Terms, +Options</var>)</a></dt>
263304 <dd class="defbody">
264 Read a file to a list of Prolog terms (see <a name="idx:read1:2161"></a><a class="pred" href="termrw.html#read/1">read/1</a>). <var>Spec</var>
265 is a file specification for <a name="idx:absolutefilename3:2162"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>. <var>Terms</var>
305 Read a file to a list of Prolog terms (see <a id="idx:read1:2165"></a><a class="pred" href="termrw.html#read/1">read/1</a>). <var>Spec</var>
306 is a file specification for <a id="idx:absolutefilename3:2166"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>. <var>Terms</var>
266307 is the resulting list of Prolog terms. <var>Options</var> is a list of
267308 options for
268 <a name="idx:absolutefilename3:2163"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
269 and <a name="idx:open4:2164"></a><a class="pred" href="IO.html#open/4">open/4</a>.
309 <a id="idx:absolutefilename3:2167"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
310 and <a id="idx:open4:2168"></a><a class="pred" href="IO.html#open/4">open/4</a>.
270311 In addition, the option
271312 <code>tail(Tail)</code> is defined, forming a difference-list.
272313 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.31</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.31</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="readutil.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="registry.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:record"><a name="sec:A.31"><span class="sec-nr">A.31</span> <span class="sec-title">library(record):
235 <h2 id="sec:record"><a id="sec:A.31"><span class="sec-nr">A.31</span> <span class="sec-title">library(record):
195236 Access named fields in a term</span></a></h2>
196237
197 <a name="sec:record"></a>
198 <a name="sec:lib:record"></a>
238 <a id="sec:record"></a>
239 <a id="sec:lib:record"></a>
199240
200241 <p>The library <code>library(record)</code> provides named access to
201242 fields in a record represented as a compound term such as <code>point(X,
210251 predicates, an optimizing compiler can easily inline them for optimal
211252 preformance.
212253
213 <p>A record is defined using the directive <a name="idx:record1:2165"></a><a class="pred" href="record.html#record/1">record/1</a>.
254 <p>A record is defined using the directive <a id="idx:record1:2169"></a><a class="pred" href="record.html#record/1">record/1</a>.
214255 We introduce the library with a short example:
215256
216257 <pre class="code">
233274
234275 <p>In this definition, &lt;<var>name</var>&gt; is an atom defining the
235276 name of the argument,
236 &lt;<var>type</var>&gt; is an optional type specification as defined by <a name="idx:mustbe2:2166"></a><a class="pred" href="error.html#must_be/2">must_be/2</a>
277 &lt;<var>type</var>&gt; is an optional type specification as defined by <a id="idx:mustbe2:2170"></a><a class="pred" href="error.html#must_be/2">must_be/2</a>
237278 from library <code>library(error)</code>, and &lt;<var>default</var>&gt;
238279 is the default initial value. The
239280 &lt;<var>type</var>&gt; defaults to <code>any</code>. If no default
269310 <p>
270311 <li><i>&lt;<var>constructor</var>&gt;_&lt;<var>name</var>&gt;(Record,
271312 Value)</i><br>
272 Unify <var>Value</var> with argument in <var>Record</var> named &lt;<var>name</var>&gt;.<sup class="fn">182<span class="fn-text">Note
313 Unify <var>Value</var> with argument in <var>Record</var> named &lt;<var>name</var>&gt;.<sup class="fn">183<span class="fn-text">Note
273314 this is not called `get_' as it performs unification and can perfectly
274315 well instantiate the argument.</span></sup>
275316
289330 !Record)</i><br>
290331 Destructively replace the argument &lt;<var>name</var>&gt; in <var>Record</var>
291332 by
292 <var>Value</var> based on <a name="idx:setarg3:2167"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>.
333 <var>Value</var> based on <a id="idx:setarg3:2171"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>.
293334 Use with care.
294335
295336 <p>
296337 <li><i>nb_set_&lt;<var>name</var>&gt;_of_&lt;<var>constructor</var>&gt;(+Value,
297338 !Record)</i><br>
298 As above, but using non-backtrackable assignment based on <a name="idx:nbsetarg3:2168"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
339 As above, but using non-backtrackable assignment based on <a id="idx:nbsetarg3:2172"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
299340 Use with <em>extreme</em> care.
300341
301342 <p>
318359 </ul>
319360
320361 <dl class="latex">
321 <dt class="pubdef"><a name="record/1"><strong>record</strong>(<var>+Spec</var>)</a></dt>
362 <dt class="pubdef"><a id="record/1"><strong>record</strong>(<var>+Spec</var>)</a></dt>
322363 <dd class="defbody">
323364 The construct <code>:- record Spec, ...</code> is used to define access
324365 to named fields in a compound. It is subject to term-expansion (see
325 <a name="idx:expandterm2:2169"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>)
366 <a id="idx:expandterm2:2173"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>)
326367 and cannot be called as a predicate. See
327 <a class="sec" href="record.html">section A.31</a> for details.
368 <a class="sec" href="record.html#sec:A.31">section A.31</a> for details.
328369 </dd>
329370 </dl>
330371
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="mtoplevel.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="moduleop.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:reexport"><a name="sec:6.7"><span class="sec-nr">6.7</span> <span class="sec-title">Composing
235 <h2 id="sec:reexport"><a id="sec:6.7"><span class="sec-nr">6.7</span> <span class="sec-title">Composing
195236 modules from other modules</span></a></h2>
196237
197 <a name="sec:reexport"></a>
238 <a id="sec:reexport"></a>
198239
199240 <p>The predicates in this section are intended to create new modules
200241 from the content of other modules. Below is an example to define a
201242 <em>composite</em> module. The example exports all public predicates of <code>module_1</code>, <code>module_2</code>
202 and <code>module_3</code>, <a name="idx:pred1:1710"></a><span class="pred-ext">pred/1</span>
243 and <code>module_3</code>, <a id="idx:pred1:1714"></a><span class="pred-ext">pred/1</span>
203244 from <code>module_4</code>, all predicates from <code>module_5</code>
204245 except
205 <a name="idx:donotuse1:1711"></a><span class="pred-ext">do_not_use/1</span>
246 <a id="idx:donotuse1:1715"></a><span class="pred-ext">do_not_use/1</span>
206247 and all predicates from <code>module_6</code> while renaming
207 <a name="idx:pred1:1712"></a><span class="pred-ext">pred/1</span> into <a name="idx:mypred1:1713"></a><span class="pred-ext">mypred/1</span>.
248 <a id="idx:pred1:1716"></a><span class="pred-ext">pred/1</span> into <a id="idx:mypred1:1717"></a><span class="pred-ext">mypred/1</span>.
208249
209250 <pre class="code">
210251 :- module(my_composite, []).
218259 </pre>
219260
220261 <dl class="latex">
221 <dt class="pubdef"><a name="reexport/1"><strong>reexport</strong>(<var>+Files</var>)</a></dt>
262 <dt class="pubdef"><a id="reexport/1"><strong>reexport</strong>(<var>+Files</var>)</a></dt>
222263 <dd class="defbody">
223 Load and import predicates as <a name="idx:usemodule1:1714"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
264 Load and import predicates as <a id="idx:usemodule1:1718"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
224265 and re-export all imported predicates. The reexport declarations must
225266 immediately follow the module declaration.</dd>
226 <dt class="pubdef"><a name="reexport/2"><strong>reexport</strong>(<var>+File,
267 <dt class="pubdef"><a id="reexport/2"><strong>reexport</strong>(<var>+File,
227268 +Import</var>)</a></dt>
228269 <dd class="defbody">
229 Import from <var>File</var> as <a name="idx:usemodule2:1715"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
270 Import from <var>File</var> as <a id="idx:usemodule2:1719"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
230271 and re-export the imported predicates. The reexport declarations must
231272 immediately follow the module declaration.
232273 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.32</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.32</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="record.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="simplex.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:registry"><a name="sec:A.32"><span class="sec-nr">A.32</span> <span class="sec-title">library(registry):
235 <h2 id="sec:registry"><a id="sec:A.32"><span class="sec-nr">A.32</span> <span class="sec-title">library(registry):
195236 Manipulating the Windows registry</span></a></h2>
196237
197 <a name="sec:registry"></a>
238 <a id="sec:registry"></a>
198239
199240 <p>The <code>library(registry)</code> is only available on the
200241 MS-Windows version of SWI-Prolog. It loads the foreign extension <code>plregtry.dll</code>,
214255 <code>users</code>.
215256
216257 <dl class="latex">
217 <dt class="pubdef"><a name="registry_get_key/2"><strong>registry_get_key</strong>(<var>+Path,
258 <dt class="pubdef"><a id="registry_get_key/2"><strong>registry_get_key</strong>(<var>+Path,
218259 -Value</var>)</a></dt>
219260 <dd class="defbody">
220261 Get the principal (default) value associated to this key. Fails silently
221262 if the key does not exist.</dd>
222 <dt class="pubdef"><a name="registry_get_key/3"><strong>registry_get_key</strong>(<var>+Path,
263 <dt class="pubdef"><a id="registry_get_key/3"><strong>registry_get_key</strong>(<var>+Path,
223264 +Name, -Value</var>)</a></dt>
224265 <dd class="defbody">
225266 Get a named value associated to this key.</dd>
226 <dt class="pubdef"><a name="registry_set_key/2"><strong>registry_set_key</strong>(<var>+Path,
267 <dt class="pubdef"><a id="registry_set_key/2"><strong>registry_set_key</strong>(<var>+Path,
227268 +Value</var>)</a></dt>
228269 <dd class="defbody">
229270 Set the principal (default) value of this key. Creates (a path to) the
230271 key if it does not already exist.</dd>
231 <dt class="pubdef"><a name="registry_set_key/3"><strong>registry_set_key</strong>(<var>+Path,
272 <dt class="pubdef"><a id="registry_set_key/3"><strong>registry_set_key</strong>(<var>+Path,
232273 +Name, +Value</var>)</a></dt>
233274 <dd class="defbody">
234275 Associate a named value to this key. Creates (a path to) the key if it
235276 does not already exist.</dd>
236 <dt class="pubdef"><a name="registry_delete_key/1"><strong>registry_delete_key</strong>(<var>+Path</var>)</a></dt>
277 <dt class="pubdef"><a id="registry_delete_key/1"><strong>registry_delete_key</strong>(<var>+Path</var>)</a></dt>
237278 <dd class="defbody">
238279 Delete the indicated key.</dd>
239 <dt class="pubdef"><a name="shell_register_file_type/4"><strong>shell_register_file_type</strong>(<var>+Ext,
280 <dt class="pubdef"><a id="shell_register_file_type/4"><strong>shell_register_file_type</strong>(<var>+Ext,
240281 +Type, +Name, +OpenAction</var>)</a></dt>
241282 <dd class="defbody">
242283 Register a file-type. <var>Ext</var> is the extension to associate.
244285 <var>Name</var> is the name visible in the Windows file-type browser.
245286 Finally, <var>OpenAction</var> defines the action to execute when a file
246287 with this extension is opened in the Windows explorer.</dd>
247 <dt class="pubdef"><a name="shell_register_dde/6"><strong>shell_register_dde</strong>(<var>+Type,
288 <dt class="pubdef"><a id="shell_register_dde/6"><strong>shell_register_dde</strong>(<var>+Type,
248289 +Action, +Service, +Topic, +Command, +IfNotRunning</var>)</a></dt>
249290 <dd class="defbody">
250291 Associate DDE actions to a type. <var>Type</var> is the same type as
251 used for the 2nd argument of <a name="idx:shellregisterfiletype4:2170"></a><a class="pred" href="registry.html#shell_register_file_type/4">shell_register_file_type/4</a>, <var>Action</var>
292 used for the 2nd argument of <a id="idx:shellregisterfiletype4:2174"></a><a class="pred" href="registry.html#shell_register_file_type/4">shell_register_file_type/4</a>, <var>Action</var>
252293 is the action to perform, <var>Service</var> and <var>Topic</var>
253294 specify the DDE topic to address, and <var>Command</var> is the command
254295 to execute on this topic. Finally, <var>IfNotRunning</var> defines the
255296 command to execute if the required DDE server is not present.</dd>
256 <dt class="pubdef"><a name="shell_register_prolog/1"><strong>shell_register_prolog</strong>(<var>+Ext</var>)</a></dt>
297 <dt class="pubdef"><a id="shell_register_prolog/1"><strong>shell_register_prolog</strong>(<var>+Ext</var>)</a></dt>
257298 <dd class="defbody">
258299 Default registration of SWI-Prolog, which is invoked as part of the
259300 initialisation process on Windows systems. As the source also includes
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.10</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="importmodule.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="altmoduleapi.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:resmodules"><a name="sec:6.10"><span class="sec-nr">6.10</span> <span class="sec-title">Reserved
235 <h2 id="sec:resmodules"><a id="sec:6.10"><span class="sec-nr">6.10</span> <span class="sec-title">Reserved
195236 Modules and using the `user' module</span></a></h2>
196237
197 <a name="sec:resmodules"></a>
238 <a id="sec:resmodules"></a>
198239
199240 <p>As mentioned above, SWI-Prolog contains two special modules. The
200241 first one is the module <code>system</code>. This module contains all
208249 implies they can use all predicates imported into <code>user</code>
209250 without explicitly importing them. If an application loads all modules
210251 from the
211 <code>user</code> module using <a name="idx:usemodule1:1725"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,
252 <code>user</code> module using <a id="idx:usemodule1:1729"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,
212253 one achieves a scoping system similar to the C-language, where every
213254 module can access all exported predicates without any special
214255 precautions.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="foreignnotes.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="qsavelimits.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:runtime"><a name="sec:12"><span class="sec-nr">12</span> <span class="sec-title">Generating
235 <h1 id="sec:runtime"><a id="sec:12"><span class="sec-nr">12</span> <span class="sec-title">Generating
195236 Runtime Applications</span></a></h1>
196237
197 <a name="sec:runtime"></a>
238 <a id="sec:runtime"></a>
198239
199240 <p>This chapter describes the features of SWI-Prolog for delivering
200241 applications that can run without the development version of the system
204245 The first part is the <em>emulator</em>, which is machine-dependent. The
205246 second part is the <em>resource archive</em>, which contains the
206247 compiled program in a machine-independent format, startup options and
207 possibly user-defined <em>resources</em>; see <a name="idx:resource3:2096"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>
248 possibly user-defined <em>resources</em>; see <a id="idx:resource3:2100"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>
208249 and
209 <a name="idx:openresource3:2097"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
250 <a id="idx:openresource3:2101"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
210251
211252 <p>These two parts can be connected in various ways. The most common way
212253 for distributed runtime applications is to <em>concatenate</em> the two
213254 parts. This can be achieved using external commands (Unix:
214255 <b>cat</b>, Windows: <b>copy</b>), or using the
215 <code>stand_alone</code> option to <a name="idx:qsaveprogram2:2098"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
256 <code>stand_alone</code> option to <a id="idx:qsaveprogram2:2102"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
216257 The second option is to attach a startup script in front of the resource
217258 that starts the emulator with the proper options. This is the default
218259 under Unix. Finally, an emulator can be told to use a specified resource
219260 file using the <strong>-x</strong> command line switch.
220261
221262 <dl class="latex">
222 <dt class="pubdef"><a name="qsave_program/2"><strong>qsave_program</strong>(<var>+File,
263 <dt class="pubdef"><a id="qsave_program/2"><strong>qsave_program</strong>(<var>+File,
223264 +Options</var>)</a></dt>
224265 <dd class="defbody">
225266 Saves the current state of the program to the file <var>File</var>. The
232273 <dl class="latex">
233274 <dt><strong>local</strong>(<var>+KBytes</var>)</dt>
234275 <dd class="defbody">
235 Limit for the local stack. See <a class="sec" href="cmdline.html">section
276 Limit for the local stack. See <a class="sec" href="cmdline.html#sec:2.4.3">section
236277 2.4.3</a>.
237278 </dd>
238279 <dt><strong>global</strong>(<var>+KBytes</var>)</dt>
239280 <dd class="defbody">
240 Limit for the global stack. See <a class="sec" href="cmdline.html">section
281 Limit for the global stack. See <a class="sec" href="cmdline.html#sec:2.4.3">section
241282 2.4.3</a>.
242283 </dd>
243284 <dt><strong>trail</strong>(<var>+KBytes</var>)</dt>
244285 <dd class="defbody">
245 Limit for the trail stack. See <a class="sec" href="cmdline.html">section
286 Limit for the trail stack. See <a class="sec" href="cmdline.html#sec:2.4.3">section
246287 2.4.3</a>.
247288 </dd>
248289 <dt><strong>goal</strong>(<var>:Callable</var>)</dt>
264305 If
265306 <code>kernel</code>, lock all predicates as system predicates. If
266307 <code>development</code>, save the predicates in their current state and
267 keep reading resources from their source (if present). See also <a name="idx:resource3:2099"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
308 keep reading resources from their source (if present). See also <a id="idx:resource3:2103"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
268309 </dd>
269310 <dt><strong>autoload</strong>(<var>+Boolean</var>)</dt>
270311 <dd class="defbody">
271 If <code>true</code> (default), run <a name="idx:autoload0:2100"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
312 If <code>true</code> (default), run <a id="idx:autoload0:2104"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
272313 first.
273314 </dd>
274315 <dt><strong>map</strong>(<var>+File</var>)</dt>
288329 application has all libraries loaded, the resulting executable is
289330 completely independent of the runtime environment or location where it
290331 was built. See also
291 <a class="sec" href="compilation.html">section 2.10.2.4</a>.
332 <a class="sec" href="compilation.html#sec:2.10.2.4">section 2.10.2.4</a>.
292333 </dd>
293334 <dt><strong>emulator</strong>(<var>+File</var>)</dt>
294335 <dd class="defbody">
298339 <dd class="defbody">
299340 If <code>save</code>, include shared objects (DLLs) into the saved
300341 state. See
301 <a name="idx:currentforeignlibrary2:2101"></a><a class="pred" href="foreignlink.html#current_foreign_library/2">current_foreign_library/2</a>.
342 <a id="idx:currentforeignlibrary2:2105"></a><a class="pred" href="foreignlink.html#current_foreign_library/2">current_foreign_library/2</a>.
302343 If the program <b>strip</b> is available, this is first used to reduce
303 the size of the shared object. If a state is started, <a name="idx:useforeignlibrary1:2102"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
344 the size of the shared object. If a state is started, <a id="idx:useforeignlibrary1:2106"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
304345 first tries to locate the foreign resource in the executable. When found
305346 it copies the content of the resource to a temporary file and loads it.
306347 If possible (Unix), the temporary object is deleted immediately after
307 opening.<sup class="fn">180<span class="fn-text">This option is
348 opening.<sup class="fn">181<span class="fn-text">This option is
308349 experimental and currently disabled by default. It will become the
309350 default if it proves robust.</span></sup>
310351 </dd>
311352 </dl>
312353
313354 </dd>
314 <dt class="pubdef"><a name="qsave_program/1"><strong>qsave_program</strong>(<var>+File</var>)</a></dt>
355 <dt class="pubdef"><a id="qsave_program/1"><strong>qsave_program</strong>(<var>+File</var>)</a></dt>
315356 <dd class="defbody">
316357 Equivalent to <code>qsave_program(File, [])</code>.</dd>
317 <dt class="pubdef"><a name="autoload/0"><strong>autoload</strong></a></dt>
358 <dt class="pubdef"><a id="autoload/0"><strong>autoload</strong></a></dt>
318359 <dd class="defbody">
319360 Check the current Prolog program for predicates that are referred to,
320361 are undefined and have a definition in the Prolog library. Load the
321362 appropriate libraries.
322363
323 <p>This predicate is used by <a name="idx:qsaveprogram12:2103"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
364 <p>This predicate is used by <a id="idx:qsaveprogram12:2107"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
324365 to ensure the saved state does not depend on availability of the
325366 libraries. The predicate
326 <a name="idx:autoload0:2104"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
367 <a id="idx:autoload0:2108"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
327368 examines all clauses of the loaded program (obtained with
328 <a name="idx:clause2:2105"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>)
369 <a id="idx:clause2:2109"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>)
329370 and analyzes the body for referenced goals. Such an analysis cannot be
330371 complete in Prolog, which allows for the creation of arbitrary terms at
331372 runtime and the use of them as a goal. The current analysis is limited
335376 <ul class="latex">
336377 <li>Direct goals appearing in the body
337378 <li>Arguments of declared meta-predicates that are marked with an
338 integer (0..9). See <a name="idx:metapredicate1:2106"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>.
379 integer (0..9). See <a id="idx:metapredicate1:2110"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>.
339380 </ul>
340381
341382 <p>The analysis of meta-predicate arguments is limited to cases where
352393
353394 <p>But, the calls to prove_simple/1 and prove_complex/1 in the example
354395 below are <em>not</em> discovered by the analysis and therefore the
355 modules that define these predicates must be loaded explicitly using <a name="idx:usemodule1:2107"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,2.
396 modules that define these predicates must be loaded explicitly using <a id="idx:usemodule1:2111"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,2.
356397
357398 <pre class="code">
358399 ...,
363404 Goal)),
364405 </pre>
365406
366 <p>It is good practice to use <a name="idx:gxref0:2108"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
407 <p>It is good practice to use <a id="idx:gxref0:2112"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
367408 to make sure that the program has sufficient declarations such that the
368409 analaysis tools can verify that all required predicates can be resolved
369 and that all code is called. See <a name="idx:metapredicate1:2109"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>, <a name="idx:dynamic1:2110"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>, <a name="idx:public1:2111"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
410 and that all code is called. See <a id="idx:metapredicate1:2113"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>, <a id="idx:dynamic1:2114"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>, <a id="idx:public1:2115"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
370411 and prolog:called_by/2.</dd>
371 <dt class="pubdef"><a name="volatile/1"><strong>volatile</strong> <var>+Name/Arity,
412 <dt class="pubdef"><a id="volatile/1"><strong>volatile</strong> <var>+Name/Arity,
372413 ...</var></a></dt>
373414 <dd class="defbody">
374415 Declare that the clauses of specified predicates should <strong>not</strong>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 8.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="examples.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="guidelines.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:sicstus-chr"><a name="sec:8.6"><span class="sec-nr">8.6</span> <span class="sec-title">Backwards
235 <h2 id="sec:sicstus-chr"><a id="sec:8.6"><span class="sec-nr">8.6</span> <span class="sec-title">Backwards
195236 Compatibility</span></a></h2>
196237
197 <a name="sec:sicstus-chr"></a>
198 <h3 id="sec:chr-sicstus"><a name="sec:8.6.1"><span class="sec-nr">8.6.1</span> <span class="sec-title">The
238 <a id="sec:sicstus-chr"></a>
239 <h3 id="sec:chr-sicstus"><a id="sec:8.6.1"><span class="sec-nr">8.6.1</span> <span class="sec-title">The
199240 Old SICStus CHR implemenation</span></a></h3>
200241
201 <a name="sec:chr-sicstus"></a>
242 <a id="sec:chr-sicstus"></a>
202243
203244 <p>There are small differences between the current K.U.Leuven CHR system
204245 in SWI-Prolog, older versions of the same system, and SICStus' CHR
216257 <ul class="latex">
217258 <li><i>The constraints/1 declaration</i><br>
218259 This declaration is deprecated. It has been replaced with the
219 <a name="idx:chrconstraint1:1823"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
260 <a id="idx:chrconstraint1:1827"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
220261 declaration.
221262
222263 <p>
223264 <li><i>The option/2 declaration</i><br>
224265 This declaration is deprecated. It has been replaced with the
225 <a name="idx:chroption2:1824"></a><a class="pred" href="SyntaxAndSemantics.html#chr_option/2">chr_option/2</a>
266 <a id="idx:chroption2:1828"></a><a class="pred" href="SyntaxAndSemantics.html#chr_option/2">chr_option/2</a>
226267 declaration.
227268
228269 <p>
242283 <li><i>Guard bindings</i><br>
243284 The <code>check_guard_bindings</code> option only turns invalid calls to
244285 unification into failure. In SICStus this option does more: it
245 intercepts instantiation errors from Prolog built-ins such as <a name="idx:is2:1825"></a><a class="pred" href="arith.html#is/2">is/2</a>
286 intercepts instantiation errors from Prolog built-ins such as <a id="idx:is2:1829"></a><a class="pred" href="arith.html#is/2">is/2</a>
246287 and turns them into failure. In SWI-Prolog, we do not go this far, as we
247288 like to separate concerns more. The CHR compiler is aware of the CHR
248289 code, the Prolog system, and the programmer should be aware of the
250291 rules.
251292 </ul>
252293
253 <p><h3 id="sec:chr-eclipse"><a name="sec:8.6.2"><span class="sec-nr">8.6.2</span> <span class="sec-title">The
294 <p><h3 id="sec:chr-eclipse"><a id="sec:8.6.2"><span class="sec-nr">8.6.2</span> <span class="sec-title">The
254295 Old ECLiPSe CHR implemenation</span></a></h3>
255296
256 <a name="sec:chr-eclipse"></a>
297 <a id="sec:chr-eclipse"></a>
257298
258299 <p>The old ECLiPSe CHR implementation features a label_with/1 construct
259300 for labeling variables in CHR constraints. This feature has long since
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.12</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="exception.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="DCG.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:signal"><a name="sec:4.12"><span class="sec-nr">4.12</span> <span class="sec-title">Handling
235 <h2 id="sec:signal"><a id="sec:4.12"><span class="sec-nr">4.12</span> <span class="sec-title">Handling
195236 signals</span></a></h2>
196237
197 <a name="sec:signal"></a>
238 <a id="sec:signal"></a>
198239
199240 <p>As of version 3.1.0, SWI-Prolog is able to handle software interrupts
200 (signals) in Prolog as well as in foreign (C) code (see <a class="sec" href="foreigninclude.html">section
241 (signals) in Prolog as well as in foreign (C) code (see <a class="sec" href="foreigninclude.html#sec:11.4.13">section
201242 11.4.13</a>).
202243
203244 <p>Signals are used to handle internal errors (execution of a
212253 communication (Unix kill() function).
213254
214255 <dl class="latex">
215 <dt class="pubdef"><a name="on_signal/3"><strong>on_signal</strong>(<var>+Signal,
256 <dt class="pubdef"><a id="on_signal/3"><strong>on_signal</strong>(<var>+Signal,
216257 -Old, :New</var>)</a></dt>
217258 <dd class="defbody">
218259 Determines the reaction on <var>Signal</var>. <var>Old</var> is unified
221262 retrieved using <code>on_signal(Signal, Current, Current)</code>.
222263
223264 <p>The action description is an atom denoting the name of the predicate
224 that will be called if <var>Signal</var> arrives. <a name="idx:onsignal3:773"></a><a class="pred" href="signal.html#on_signal/3">on_signal/3</a>
265 that will be called if <var>Signal</var> arrives. <a id="idx:onsignal3:773"></a><a class="pred" href="signal.html#on_signal/3">on_signal/3</a>
225266 is a meta-predicate, which implies that &lt;<var>Module</var>&gt;:&lt;<var>Name</var>&gt;
226267 refers to &lt;<var>Name</var>&gt;/1 in module &lt;<var>Module</var>&gt;.
227268 The handler is called with a single argument: the name of the signal as
229270
230271 <p>Two predicate names have special meaning. <code>throw</code> implies
231272 Prolog will map the signal onto a Prolog exception as described in
232 <a class="sec" href="exception.html">section 4.11</a>. <code>default</code>
273 <a class="sec" href="exception.html#sec:4.11">section 4.11</a>. <code>default</code>
233274 resets the handler to the settings active before SWI-Prolog manipulated
234275 the handler.
235276
243284
244285 <p>The signal names are defined by the POSIX standard as symbols of the
245286 form <code>SIG</code>&lt;SIGNAME&gt;. The Prolog name for a signal is
246 the lowercase version of &lt;SIGNAME&gt;. The predicate <a name="idx:currentsignal3:774"></a><a class="pred" href="signal.html#current_signal/3">current_signal/3</a>
287 the lowercase version of &lt;SIGNAME&gt;. The predicate <a id="idx:currentsignal3:774"></a><a class="pred" href="signal.html#current_signal/3">current_signal/3</a>
247288 may be used to map between names and signals.
248289
249290 <p>Initially, some signals are mapped to <code>throw</code>, while all
251292 exception:
252293 <code>fpe</code>, <code>alrm</code>, <code>xcpu</code>, <code>xfsz</code>
253294 and <code>vtalrm</code>.</dd>
254 <dt class="pubdef"><a name="current_signal/3"><strong>current_signal</strong>(<var>?Name,
295 <dt class="pubdef"><a id="current_signal/3"><strong>current_signal</strong>(<var>?Name,
255296 ?Id, ?Handler</var>)</a></dt>
256297 <dd class="defbody">
257298 Enumerate the currently defined signal handling. <var>Name</var> is the
258299 signal name, <var>Id</var> is the numerical identifier and <var>Handler</var>
259 is the currently defined handler (see <a name="idx:onsignal3:775"></a><a class="pred" href="signal.html#on_signal/3">on_signal/3</a>).
300 is the currently defined handler (see <a id="idx:onsignal3:775"></a><a class="pred" href="signal.html#on_signal/3">on_signal/3</a>).
260301 </dd>
261302 </dl>
262303
263 <p><h3 id="sec:signalhandling"><a name="sec:4.12.1"><span class="sec-nr">4.12.1</span> <span class="sec-title">Notes
304 <p><h3 id="sec:signalhandling"><a id="sec:4.12.1"><span class="sec-nr">4.12.1</span> <span class="sec-title">Notes
264305 on signal handling</span></a></h3>
265306
266 <a name="sec:signalhandling"></a>
307 <a id="sec:signalhandling"></a>
267308
268309 <p>Before deciding to deal with signals in your application, please
269310 consider the following:
285326 foreign functions called from a handler cannot safely use the SWI-Prolog
286327 API and cannot use C longjmp(). Handlers defined as <code>throw</code>
287328 are unsafe. Handlers defined to call a predicate are safe. Note that the
288 predicate can call <a name="idx:throw1:776"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
329 predicate can call <a id="idx:throw1:776"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
289330 but the delivery is delayed until Prolog is in a safe state.
290331
291 <p>The C-interface described in <a class="sec" href="foreigninclude.html">section
332 <p>The C-interface described in <a class="sec" href="foreigninclude.html#sec:11.4.13">section
292333 11.4.13</a> provides the option
293334 <code>PL_SIGSYNC</code> to select either safe synchronous or unsafe
294335 asynchronous delivery.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.33</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.33</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="registry.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="solutionsequences.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:simplex"><a name="sec:A.33"><span class="sec-nr">A.33</span> <span class="sec-title">library(simplex):
235 <h2 id="sec:simplex"><a id="sec:A.33"><span class="sec-nr">A.33</span> <span class="sec-title">library(simplex):
195236 Solve linear programming problems</span></a></h2>
196237
197 <a name="sec:simplex"></a>
198
199 <p><a name="sec:simplex"></a>
238 <a id="sec:simplex"></a>
239
240 <p><a id="sec:simplex"></a>
200241
201242 <dl class="tags">
202243 <dt class="tag">author</dt>
203244 <dd>
204 https://www.metalevel.atMarkus Triska
245 <a class="url" href="https://www.metalevel.at">Markus Triska</a>
205246 </dd>
206247 </dl>
207248
208 <p><h3 id="sec:simplex-intro"><a name="sec:A.33.1"><span class="sec-nr">A.33.1</span> <span class="sec-title">Introduction</span></a></h3>
209
210 <p><a name="sec:simplex-intro"></a>
249 <p><h3 id="sec:simplex-intro"><a id="sec:A.33.1"><span class="sec-nr">A.33.1</span> <span class="sec-title">Introduction</span></a></h3>
250
251 <p><a id="sec:simplex-intro"></a>
211252
212253 <p>A <b>linear programming problem</b> or simply <b>linear program</b>
213254 (LP) consists of:
253294 <p>The most frequently used predicates are thus:
254295
255296 <dl class="latex">
256 <dt class="pubdef"><a name="gen_state/1"><strong>gen_state</strong>(<var>-State</var>)</a></dt>
297 <dt class="pubdef"><a id="gen_state/1"><strong>gen_state</strong>(<var>-State</var>)</a></dt>
257298 <dd class="defbody">
258299 Generates an initial state corresponding to an empty linear program.</dd>
259 <dt class="pubdef"><a name="constraint/3"><strong>constraint</strong>(<var>+Constraint,
300 <dt class="pubdef"><a id="constraint/3"><strong>constraint</strong>(<var>+Constraint,
260301 +S0, -S</var>)</a></dt>
261302 <dd class="defbody">
262303 Adds a linear or integrality constraint to the linear program
268309 or <code>&gt;=</code>. The coefficient <code>1</code> can be omitted. An
269310 integrality constraint is of the form <code>integral(Variable)</code>
270311 and constrains Variable to an integral value.</dd>
271 <dt class="pubdef"><a name="maximize/3"><strong>maximize</strong>(<var>+Objective,
312 <dt class="pubdef"><a id="maximize/3"><strong>maximize</strong>(<var>+Objective,
272313 +S0, -S</var>)</a></dt>
273314 <dd class="defbody">
274315 Maximizes the objective function, stated as a list of
276317 elements, with respect to the linear program corresponding to state
277318 <var>S0</var>. <code>\</code>arg{<var>S</var>} is unified with an
278319 internal representation of the solved instance.</dd>
279 <dt class="pubdef"><a name="minimize/3"><strong>minimize</strong>(<var>+Objective,
320 <dt class="pubdef"><a id="minimize/3"><strong>minimize</strong>(<var>+Objective,
280321 +S0, -S</var>)</a></dt>
281322 <dd class="defbody">
282323 Analogous to <a class="pred" href="simplex.html#maximize/3">maximize/3</a>.</dd>
283 <dt class="pubdef"><a name="variable_value/3"><strong>variable_value</strong>(<var>+State,
324 <dt class="pubdef"><a id="variable_value/3"><strong>variable_value</strong>(<var>+State,
284325 +Variable, -Value</var>)</a></dt>
285326 <dd class="defbody">
286327 <var>Value</var> is unified with the value obtained for <var>Variable</var>. <var>State</var>
287328 must correspond to a solved instance.</dd>
288 <dt class="pubdef"><a name="objective/2"><strong>objective</strong>(<var>+State,
329 <dt class="pubdef"><a id="objective/2"><strong>objective</strong>(<var>+State,
289330 -Objective</var>)</a></dt>
290331 <dd class="defbody">
291332 Unifies <var>Objective</var> with the result of the objective function
300341 be <i>non-negative</i>. This may change in future versions, and
301342 non-negativity constraints should therefore be stated explicitly.
302343
303 <p><h3 id="sec:simplex-delayed-column"><a name="sec:A.33.2"><span class="sec-nr">A.33.2</span> <span class="sec-title">Delayed
344 <p><h3 id="sec:simplex-delayed-column"><a id="sec:A.33.2"><span class="sec-nr">A.33.2</span> <span class="sec-title">Delayed
304345 column generation</span></a></h3>
305346
306 <p><a name="sec:simplex-delayed-column"></a>
347 <p><a id="sec:simplex-delayed-column"></a>
307348
308349 <p><i>Delayed column generation</i> means that more constraint columns
309350 are added to an existing LP. The following predicates are frequently
310351 used when this method is applied:
311352
312353 <dl class="latex">
313 <dt class="pubdef"><a name="constraint/4"><strong>constraint</strong>(<var>+Name,
354 <dt class="pubdef"><a id="constraint/4"><strong>constraint</strong>(<var>+Name,
314355 +Constraint, +S0, -S</var>)</a></dt>
315356 <dd class="defbody">
316357 Like <a class="pred" href="simplex.html#constraint/3">constraint/3</a>,
317358 and attaches the name <var>Name</var> (an atom or compound term) to the
318359 new constraint.</dd>
319 <dt class="pubdef"><a name="shadow_price/3"><strong>shadow_price</strong>(<var>+State,
360 <dt class="pubdef"><a id="shadow_price/3"><strong>shadow_price</strong>(<var>+State,
320361 +Name, -Value</var>)</a></dt>
321362 <dd class="defbody">
322363 Unifies <var>Value</var> with the shadow price corresponding to the
323364 linear constraint whose name is <var>Name</var>. <var>State</var> must
324365 correspond to a solved instance.</dd>
325 <dt class="pubdef"><a name="constraint_add/4"><strong>constraint_add</strong>(<var>+Name,
366 <dt class="pubdef"><a id="constraint_add/4"><strong>constraint_add</strong>(<var>+Name,
326367 +Left, +S0, -S</var>)</a></dt>
327368 <dd class="defbody">
328369 <var>Left</var> is a list of <code>Coefficient*Variable</code> terms.
333374
334375 <p>An example application of <i>delayed column generation</i> to solve a <i>bin
335376 packing</i> task is available from:
336 https://www.metalevel.at/various/colgen/<b>metalevel.at/various/colgen/</b>
337
338 <p><h3 id="sec:simplex-special-structure"><a name="sec:A.33.3"><span class="sec-nr">A.33.3</span> <span class="sec-title">Solving
377 <a class="url" href="https://www.metalevel.at/various/colgen/"><b>metalevel.at/various/colgen/</b></a>
378
379 <p><h3 id="sec:simplex-special-structure"><a id="sec:A.33.3"><span class="sec-nr">A.33.3</span> <span class="sec-title">Solving
339380 LPs with special structure</span></a></h3>
340381
341 <p><a name="sec:simplex-special-structure"></a>
382 <p><a id="sec:simplex-special-structure"></a>
342383
343384 <p>The following predicates allow you to solve specific kinds of LPs
344385 more efficiently:
345386
346387 <dl class="latex">
347 <dt class="pubdef"><a name="transportation/4"><strong>transportation</strong>(<var>+Supplies,
388 <dt class="pubdef"><a id="transportation/4"><strong>transportation</strong>(<var>+Supplies,
348389 +Demands, +Costs, -Transport</var>)</a></dt>
349390 <dd class="defbody">
350391 Solves a transportation problem. <var>Supplies</var> and <var>Demands</var>
356397 the form of a list of lists that represents the transportation matrix,
357398 where element (<i>i</i>,<i>j</i>) denotes how many units to ship from <i>i</i>
358399 to <i>j</i>.</dd>
359 <dt class="pubdef"><a name="assignment/2"><strong>assignment</strong>(<var>+Cost,
400 <dt class="pubdef"><a id="assignment/2"><strong>assignment</strong>(<var>+Cost,
360401 -Assignment</var>)</a></dt>
361402 <dd class="defbody">
362403 Solves a linear assignment problem. <var>Cost</var> is a list of lists
368409 </dd>
369410 </dl>
370411
371 <p><h3 id="sec:simplex-examples"><a name="sec:A.33.4"><span class="sec-nr">A.33.4</span> <span class="sec-title">Examples</span></a></h3>
372
373 <p><a name="sec:simplex-examples"></a>
412 <p><h3 id="sec:simplex-examples"><a id="sec:A.33.4"><span class="sec-nr">A.33.4</span> <span class="sec-title">Examples</span></a></h3>
413
414 <p><a id="sec:simplex-examples"></a>
374415
375416 <p>We include a few examples for solving LPs with this library.
376417
377 <p><h4 id="sec:simplex-ex-1"><a name="sec:A.33.4.1"><span class="sec-nr">A.33.4.1</span> <span class="sec-title">Example
418 <p><h4 id="sec:simplex-ex-1"><a id="sec:A.33.4.1"><span class="sec-nr">A.33.4.1</span> <span class="sec-title">Example
378419 1</span></a></h4>
379420
380 <p><a name="sec:simplex-ex-1"></a>
421 <p><a id="sec:simplex-ex-1"></a>
381422
382423 <p>This is the "radiation therapy" example, taken from
383424 <i>Introduction to Operations Research</i> by Hillier and Lieberman.
384425
385 <p>https://www.metalevel.at/prolog/dcg<b>Prolog DCG notation</b> is used
386 to <i>implicitly</i> thread the state through posting the constraints:
426 <p><a class="url" href="https://www.metalevel.at/prolog/dcg"><b>Prolog
427 DCG notation</b></a> is used to <i>implicitly</i> thread the state
428 through posting the constraints:
387429
388430 <pre class="code">
389431 :- use_module(library(simplex)).
410452 Val2 = 9 rdiv 2.
411453 </pre>
412454
413 <p><h4 id="sec:simplex-ex-2"><a name="sec:A.33.4.2"><span class="sec-nr">A.33.4.2</span> <span class="sec-title">Example
455 <p><h4 id="sec:simplex-ex-2"><a id="sec:A.33.4.2"><span class="sec-nr">A.33.4.2</span> <span class="sec-title">Example
414456 2</span></a></h4>
415457
416 <p><a name="sec:simplex-ex-2"></a>
458 <p><a id="sec:simplex-ex-2"></a>
417459
418460 <p>Here is an instance of the knapsack problem described above, where
419461 <code>C = 8</code>, and we have two types of items: One item with value
475517 does not necessarily yield an optimal solution in the presence of
476518 integrality constraints.
477519
478 <p><h4 id="sec:simplex-ex-3"><a name="sec:A.33.4.3"><span class="sec-nr">A.33.4.3</span> <span class="sec-title">Example
520 <p><h4 id="sec:simplex-ex-3"><a id="sec:A.33.4.3"><span class="sec-nr">A.33.4.3</span> <span class="sec-title">Example
479521 3</span></a></h4>
480522
481 <p><a name="sec:simplex-ex-3"></a>
523 <p><a id="sec:simplex-ex-3"></a>
482524
483525 <p>We are given:
484526
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section E.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section E.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="contrib.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="otherlicenses.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:softlicense"><a name="sec:E.2"><span class="sec-nr">E.2</span> <span class="sec-title">Software
235 <h2 id="sec:softlicense"><a id="sec:E.2"><span class="sec-nr">E.2</span> <span class="sec-title">Software
195236 support to keep track of license conditions</span></a></h2>
196237
197 <a name="sec:softlicense"></a>
238 <a id="sec:softlicense"></a>
198239
199240 <p>Given the above, it is possible that SWI-Prolog packages and
200241 extensions rely on the GPL, LGPL or other licenses. The predicates below
201242 allow for registering license requirements for Prolog files and foreign
202 modules. The predicate <a name="idx:license0:2340"></a><a class="pred" href="softlicense.html#license/0">license/0</a>
243 modules. The predicate <a id="idx:license0:2344"></a><a class="pred" href="softlicense.html#license/0">license/0</a>
203244 reports which components from the currently configured system are
204245 distributed under non-permissive open source licenses and therefore may
205246 need to be replaced to suit your requirements.
206247
207248 <dl class="latex">
208 <dt class="pubdef"><a name="license/0"><strong>license</strong></a></dt>
249 <dt class="pubdef"><a id="license/0"><strong>license</strong></a></dt>
209250 <dd class="defbody">
210251 Evaluate the license conditions of all loaded components. If the system
211252 contains one or more components that are licenced under GPL-like
212253 restrictions the system indicates this program may only be distributed
213254 under the <code>GPL</code> license as well as which components prohibit
214255 the use of other license conditions. Likewise for for LGPL components.</dd>
215 <dt class="pubdef"><a name="license/2"><strong>license</strong>(<var>+LicenseId,
256 <dt class="pubdef"><a id="license/2"><strong>license</strong>(<var>+LicenseId,
216257 +Component</var>)</a></dt>
217258 <dd class="defbody">
218259 Register the fact that <var>Component</var> is distributed under a
219260 license identified by <var>LicenseId</var>. Known license identifiers
220 can be listed using <a name="idx:knownlicenses0:2341"></a><a class="pred" href="softlicense.html#known_licenses/0">known_licenses/0</a>.
261 can be listed using <a id="idx:knownlicenses0:2345"></a><a class="pred" href="softlicense.html#known_licenses/0">known_licenses/0</a>.
221262 A new license can be registered as a known language using a declaration
222263 like below. The second argument defines the
223264 <em>category</em> if the license, which is one of <code>gpl</code>,
235276 </pre>
236277
237278 </dd>
238 <dt class="pubdef"><a name="license/1"><strong>license</strong>(<var>+LicenseId</var>)</a></dt>
279 <dt class="pubdef"><a id="license/1"><strong>license</strong>(<var>+LicenseId</var>)</a></dt>
239280 <dd class="defbody">
240281 Intended as a directive in Prolog source files. It takes the current
241 filename and calls <a name="idx:license2:2342"></a><a class="pred" href="softlicense.html#license/2">license/2</a>.</dd>
242 <dt class="pubdef"><a name="PL_license()"><var>void</var> <strong>PL_license</strong>(<var>const
282 filename and calls <a id="idx:license2:2346"></a><a class="pred" href="softlicense.html#license/2">license/2</a>.</dd>
283 <dt class="pubdef"><a id="PL_license()"><var>void</var> <strong>PL_license</strong>(<var>const
243284 char *LicenseId, const char *Component</var>)</a></dt>
244285 <dd class="defbody">
245286 Intended for the install() procedure of foreign libraries. This call can
246287 be made <em>before</em> <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>.</dd>
247 <dt class="pubdef"><a name="known_licenses/0"><strong>known_licenses</strong></a></dt>
288 <dt class="pubdef"><a id="known_licenses/0"><strong>known_licenses</strong></a></dt>
248289 <dd class="defbody">
249290 List all licenses <em>known</em> to the system. This does not imply the
250 system contains code covered by the listed licenses. See <a name="idx:license2:2343"></a><a class="pred" href="softlicense.html#license/2">license/2</a>.
291 system contains code covered by the listed licenses. See <a id="idx:license2:2347"></a><a class="pred" href="softlicense.html#license/2">license/2</a>.
251292 </dd>
252293 </dl>
253294
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.34</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.34</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="simplex.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="tabling.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:solutionsequences"><a name="sec:A.34"><span class="sec-nr">A.34</span> <span class="sec-title">library(solution_sequences):
235 <h2 id="sec:solutionsequences"><a id="sec:A.34"><span class="sec-nr">A.34</span> <span class="sec-title">library(solution_sequences):
195236 Modify solution sequences</span></a></h2>
196237
197 <p><a name="sec:solutionsequences"></a>
238 <p><a id="sec:solutionsequences"></a>
198239
199240 <dl class="tags">
200241 <dt class="mtag">See also</dt>
211252 GROUP BY.
212253
213254 <p>These predicates were introduced in the context of the
214 http://swish.swi-prolog.orgSWISH Prolog browser-based shell, which can
215 represent the solutions to a predicate as a table. Notably wrapping a
216 goal in <a class="pred" href="solutionsequences.html#distinct/1">distinct/1</a>
255 <a class="url" href="http://swish.swi-prolog.org">SWISH</a> Prolog
256 browser-based shell, which can represent the solutions to a predicate as
257 a table. Notably wrapping a goal in <a class="pred" href="solutionsequences.html#distinct/1">distinct/1</a>
217258 avoids duplicates in the result table and using
218259 <a class="pred" href="solutionsequences.html#order_by/2">order_by/2</a>
219260 produces a nicely ordered table.
260301 </dl>
261302
262303 <dl class="latex">
263 <dt class="pubdef"><a name="distinct/1"><strong>distinct</strong>(<var>:Goal</var>)</a></dt>
264 <dt class="pubdef"><a name="distinct/2"><strong>distinct</strong>(<var>?Witness,
304 <dt class="pubdef"><a id="distinct/1"><strong>distinct</strong>(<var>:Goal</var>)</a></dt>
305 <dt class="pubdef"><a id="distinct/2"><strong>distinct</strong>(<var>?Witness,
265306 :Goal</var>)</a></dt>
266307 <dd class="defbody">
267308 True if <var>Goal</var> is true and no previous solution of <var>Goal</var>
283324 </pre>
284325
285326 </dd>
286 <dt class="pubdef"><a name="reduced/1"><strong>reduced</strong>(<var>:Goal</var>)</a></dt>
287 <dt class="pubdef"><a name="reduced/3"><strong>reduced</strong>(<var>?Witness,
327 <dt class="pubdef"><a id="reduced/1"><strong>reduced</strong>(<var>:Goal</var>)</a></dt>
328 <dt class="pubdef"><a id="reduced/3"><strong>reduced</strong>(<var>?Witness,
288329 :Goal, +Options</var>)</a></dt>
289330 <dd class="defbody">
290331 Similar to <a class="pred" href="solutionsequences.html#distinct/1">distinct/1</a>,
308349 </dl>
309350
310351 </dd>
311 <dt class="pubdef"><a name="limit/2"><strong>limit</strong>(<var>+Count,
352 <dt class="pubdef"><a id="limit/2"><strong>limit</strong>(<var>+Count,
312353 :Goal</var>)</a></dt>
313354 <dd class="defbody">
314355 Limit the number of solutions. True if <var>Goal</var> is true,
315356 returning at most <var>Count</var> solutions. Solutions are returned as
316357 soon as they become available.</dd>
317 <dt class="pubdef"><a name="offset/2"><strong>offset</strong>(<var>+Count,
358 <dt class="pubdef"><a id="offset/2"><strong>offset</strong>(<var>+Count,
318359 :Goal</var>)</a></dt>
319360 <dd class="defbody">
320361 Ignore the first <var>Count</var> solutions. True if <var>Goal</var> is
321362 true and produces more than <var>Count</var> solutions. This predicate
322363 computes and ignores the first <var>Count</var> solutions.</dd>
323 <dt class="pubdef"><a name="order_by/2"><strong>order_by</strong>(<var>Spec,
324 Goal</var>)</a></dt>
364 <dt class="pubdef"><a id="call_nth/2"><strong>call_nth</strong>(<var>:Goal,
365 ?Nth</var>)</a></dt>
366 <dd class="defbody">
367 True when <var>Goal</var> succeeded for the <var>Nth</var> time. If <var>Nth</var>
368 is bound on entry, the predicate succeeds deterministically if there are
369 at least <var>Nth</var> solutions for <var>Goal</var>.</dd>
370 <dt class="pubdef"><a id="order_by/2"><strong>order_by</strong>(<var>+Spec,
371 :Goal</var>)</a></dt>
325372 <dd class="defbody">
326373 Order solutions according to <var>Spec</var>. <var>Spec</var> is a list
327374 of terms, where each element is one of. The ordering of solutions of <var>Goal</var>
340387 </dl>
341388
342389 </dd>
343 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="group_by/4"><strong>group_by</strong>(<var>+By,
390 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="group_by/4"><strong>group_by</strong>(<var>+By,
344391 +Template, :Goal, -Bag</var>)</a></dt>
345392 <dd class="defbody">
346393 Group bindings of <var>Template</var> that have the same value for <var>By</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 1.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="swiorother.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="implhistory.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:sponsor"><a name="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Support
235 <h2 id="sec:sponsor"><a id="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Support
195236 the SWI-Prolog project</span></a></h2>
196237
197 <a name="sec:sponsor"></a>
238 <a id="sec:sponsor"></a>
198239
199240 <p>You can support the SWI-Prolog project in several ways. Academics are
200241 invited to cite one of the publications<sup class="fn">2<span class="fn-text"><a class="url" href="http://www.swi-prolog.org/Publications.html">http://www.swi-prolog.org/Publications.html</a></span></sup>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.40</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.40</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="debugger.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="profile.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:statistics"><a name="sec:4.40"><span class="sec-nr">4.40</span> <span class="sec-title">Obtaining
235 <h2 id="sec:statistics"><a id="sec:4.40"><span class="sec-nr">4.40</span> <span class="sec-title">Obtaining
195236 Runtime Statistics</span></a></h2>
196237
197 <a name="sec:statistics"></a>
238 <a id="sec:statistics"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="statistics/2"><strong>statistics</strong>(<var>+Key,
241 <dt class="pubdef"><a id="statistics/2"><strong>statistics</strong>(<var>+Key,
201242 -Value</var>)</a></dt>
202243 <dd class="defbody">
203244 Unify system statistics determined by <var>Key</var> with <var>Value</var>.
206247 reasons. These keys are described in <a class="tab" href="statistics.html#tab:qpstatistics">table
207248 7</a>.
208249
209 <p><table border="2" frame="box" rules="groups" style="margin:auto">
210 <tr valign="top"><td colspan=2 align=center>Native keys (times as float
211 in seconds)</tr>
212 <tbody>
213 <tr valign="top"><td>agc</td><td>Number of atom garbage collections
250 <p><table class="latex frame-box center">
251 <tr><td colspan=2 align=center>Native keys (times as float in seconds)</tr>
252 <tr class="hline"><td>agc</td><td>Number of atom garbage collections
214253 performed </td></tr>
215 <tr valign="top"><td>agc_gained</td><td>Number of atoms removed </td></tr>
216 <tr valign="top"><td>agc_time</td><td>Time spent in atom garbage
217 collections </td></tr>
218 <tr valign="top"><td>atoms</td><td>Total number of defined atoms </td></tr>
219 <tr valign="top"><td>c_stack</td><td>System (C-) stack limit. 0 if not
220 known. </td></tr>
221 <tr valign="top"><td>cgc</td><td>Number of clause garbage collections
222 performed </td></tr>
223 <tr valign="top"><td>cgc_gained</td><td>Number of clauses reclaimed </td></tr>
224 <tr valign="top"><td>cgc_time</td><td>Time spent in clause garbage
225 collections </td></tr>
226 <tr valign="top"><td>clauses</td><td>Total number of clauses in the
227 program </td></tr>
228 <tr valign="top"><td>codes</td><td>Total size of (virtual) executable
229 code in words </td></tr>
230 <tr valign="top"><td>cputime</td><td>(User) <span style="font-variant:small-caps">CPU</span>
254 <tr><td>agc_gained</td><td>Number of atoms removed </td></tr>
255 <tr><td>agc_time</td><td>Time spent in atom garbage collections </td></tr>
256 <tr><td>atoms</td><td>Total number of defined atoms </td></tr>
257 <tr><td>c_stack</td><td>System (C-) stack limit. 0 if not known. </td></tr>
258 <tr><td>cgc</td><td>Number of clause garbage collections performed </td></tr>
259 <tr><td>cgc_gained</td><td>Number of clauses reclaimed </td></tr>
260 <tr><td>cgc_time</td><td>Time spent in clause garbage collections </td></tr>
261 <tr><td>clauses</td><td>Total number of clauses in the program </td></tr>
262 <tr><td>codes</td><td>Total size of (virtual) executable code in words </td></tr>
263 <tr><td>cputime</td><td>(User) <span style="font-variant:small-caps">CPU</span>
231264 time since thread was started in seconds </td></tr>
232 <tr valign="top"><td>epoch</td><td>Time stamp when thread was started </td></tr>
233 <tr valign="top"><td>functors</td><td>Total number of defined name/arity
234 pairs </td></tr>
235 <tr valign="top"><td>global</td><td>Allocated size of the global stack
236 in bytes </td></tr>
237 <tr valign="top"><td>globalused</td><td>Number of bytes in use on the
238 global stack </td></tr>
239 <tr valign="top"><td>globallimit</td><td>Size to which the global stack
240 is allowed to grow </td></tr>
241 <tr valign="top"><td>global_shifts</td><td>Number of global stack
242 expansions </td></tr>
243 <tr valign="top"><td>heapused</td><td>Bytes of heap in use by Prolog (0
244 if not maintained) </td></tr>
245 <tr valign="top"><td>inferences</td><td>Total number of passes via the
246 call and redo ports since Prolog was started </td></tr>
247 <tr valign="top"><td>modules</td><td>Total number of defined modules </td></tr>
248 <tr valign="top"><td>local</td><td>Allocated size of the local stack in
249 bytes </td></tr>
250 <tr valign="top"><td>local_shifts</td><td>Number of local stack
251 expansions </td></tr>
252 <tr valign="top"><td>locallimit</td><td>Size to which the local stack is
253 allowed to grow </td></tr>
254 <tr valign="top"><td>localused</td><td>Number of bytes in use on the
255 local stack </td></tr>
256 <tr valign="top"><td>table_space_used</td><td>Amount of bytes in use by
257 the thread's answer tables </td></tr>
258 <tr valign="top"><td>trail</td><td>Allocated size of the trail stack in
259 bytes </td></tr>
260 <tr valign="top"><td>trail_shifts</td><td>Number of trail stack
261 expansions </td></tr>
262 <tr valign="top"><td>traillimit</td><td>Size to which the trail stack is
263 allowed to grow </td></tr>
264 <tr valign="top"><td>trailused</td><td>Number of bytes in use on the
265 trail stack </td></tr>
266 <tr valign="top"><td>shift_time</td><td>Time spent in stack-shifts </td></tr>
267 <tr valign="top"><td>stack</td><td>Total memory in use for stacks in all
268 threads </td></tr>
269 <tr valign="top"><td>predicates</td><td>Total number of predicates. This
270 includes predicates that are undefined or not yet resolved. </td></tr>
271 <tr valign="top"><td>process_epoch</td><td>Time stamp when Prolog was
272 started </td></tr>
273 <tr valign="top"><td>process_cputime</td><td>(User) <span style="font-variant:small-caps">CPU</span>
265 <tr><td>epoch</td><td>Time stamp when thread was started </td></tr>
266 <tr><td>functors</td><td>Total number of defined name/arity pairs </td></tr>
267 <tr><td>global</td><td>Allocated size of the global stack in bytes </td></tr>
268 <tr><td>globalused</td><td>Number of bytes in use on the global stack </td></tr>
269 <tr><td>globallimit</td><td>Size to which the global stack is allowed to
270 grow </td></tr>
271 <tr><td>global_shifts</td><td>Number of global stack expansions </td></tr>
272 <tr><td>heapused</td><td>Bytes of heap in use by Prolog (0 if not
273 maintained) </td></tr>
274 <tr><td>inferences</td><td>Total number of passes via the call and redo
275 ports since Prolog was started </td></tr>
276 <tr><td>modules</td><td>Total number of defined modules </td></tr>
277 <tr><td>local</td><td>Allocated size of the local stack in bytes </td></tr>
278 <tr><td>local_shifts</td><td>Number of local stack expansions </td></tr>
279 <tr><td>locallimit</td><td>Size to which the local stack is allowed to
280 grow </td></tr>
281 <tr><td>localused</td><td>Number of bytes in use on the local stack </td></tr>
282 <tr><td>table_space_used</td><td>Amount of bytes in use by the thread's
283 answer tables </td></tr>
284 <tr><td>trail</td><td>Allocated size of the trail stack in bytes </td></tr>
285 <tr><td>trail_shifts</td><td>Number of trail stack expansions </td></tr>
286 <tr><td>traillimit</td><td>Size to which the trail stack is allowed to
287 grow </td></tr>
288 <tr><td>trailused</td><td>Number of bytes in use on the trail stack </td></tr>
289 <tr><td>shift_time</td><td>Time spent in stack-shifts </td></tr>
290 <tr><td>stack</td><td>Total memory in use for stacks in all threads </td></tr>
291 <tr><td>predicates</td><td>Total number of predicates. This includes
292 predicates that are undefined or not yet resolved. </td></tr>
293 <tr><td>process_epoch</td><td>Time stamp when Prolog was started </td></tr>
294 <tr><td>process_cputime</td><td>(User) <span style="font-variant:small-caps">CPU</span>
274295 time since Prolog was started in seconds </td></tr>
275 <tr valign="top"><td>thread_cputime</td><td>MT-version: Seconds CPU time
276 used by finished threads. Basically non-portable. Works on Linux,
277 MacOSX, Windows and probably some more. </td></tr>
278 <tr valign="top"><td>threads</td><td>MT-version: number of active
279 threads </td></tr>
280 <tr valign="top"><td>threads_created</td><td>MT-version: number of
281 created threads </td></tr>
282 <tr valign="top"><td>engines</td><td>MT-version: number of existing
283 engines </td></tr>
284 <tr valign="top"><td>engines_created</td><td>MT-version: number of
285 created engines </td></tr>
296 <tr><td>thread_cputime</td><td>MT-version: Seconds CPU time used by
297 finished threads. Basically non-portable. Works on Linux, MacOSX,
298 Windows and probably some more. </td></tr>
299 <tr><td>threads</td><td>MT-version: number of active threads </td></tr>
300 <tr><td>threads_created</td><td>MT-version: number of created threads </td></tr>
301 <tr><td>engines</td><td>MT-version: number of existing engines </td></tr>
302 <tr><td>engines_created</td><td>MT-version: number of created engines </td></tr>
286303 </table>
287 <div class="caption"><b>Table 6 : </b>Keys for <a name="idx:statistics2:1562"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>.
304 <div class="caption"><b>Table 6 : </b>Keys for <a id="idx:statistics2:1562"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>.
288305 Space is expressed in bytes. Time is expressed in seconds, represented
289306 as a floating point number.</div>
290 <a name="tab:statistics"></a>
291
292 <p><table border="2" frame="box" rules="groups" style="margin:auto">
293 <tr valign="top"><td colspan=2 align=center>Compatibility keys (times in
307 <a id="tab:statistics"></a>
308
309 <p><table class="latex frame-box center">
310 <tr><td colspan=2 align=center>Compatibility keys (times in
294311 milliseconds)</tr>
295 <tbody>
296 <tr valign="top"><td>runtime</td><td>[ CPU time, CPU time since last ]
312 <tr class="hline"><td>runtime</td><td>[ CPU time, CPU time since last ]
297313 (milliseconds, excluding time spent in garbage collection) </td></tr>
298 <tr valign="top"><td>system_time</td><td>[ System CPU time, System CPU
299 time since last ] (milliseconds)</td></tr>
300 <tr valign="top"><td>real_time</td><td>[ Wall time, Wall time since last
301 ] (integer seconds. See <a name="idx:gettime1:1563"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>) </td></tr>
302 <tr valign="top"><td>walltime</td><td>[ Wall time since start, Wall time
303 since last] (milliseconds, SICStus compatibility) </td></tr>
304 <tr valign="top"><td>memory</td><td>[ Total unshared data, free memory ]
305 (Uses getrusage() if available, otherwise incomplete own statistics.) </td></tr>
306 <tr valign="top"><td>stacks</td><td>[ global use, local use ] </td></tr>
307 <tr valign="top"><td>program</td><td>[ heap, 0 ] </td></tr>
308 <tr valign="top"><td>global_stack</td><td>[ global use, global free ] </td></tr>
309 <tr valign="top"><td>local_stack</td><td>[ local use, local free ] </td></tr>
310 <tr valign="top"><td>trail</td><td>[ trail use, trail free ] </td></tr>
311 <tr valign="top"><td>garbage_collection</td><td>[ number of GC, bytes
312 gained, time spent, bytes left ] The last column is a SWI-Prolog
313 extension. It contains the sum of the memory left after each collection,
314 which can be divided by the count to find the average working set size
315 after GC. Use <code>[Count, Gained, Time|_]</code> for compatiblity. </td></tr>
316 <tr valign="top"><td>stack_shifts</td><td>[ global shifts, local shifts,
314 <tr><td>system_time</td><td>[ System CPU time, System CPU time since
315 last ] (milliseconds)</td></tr>
316 <tr><td>real_time</td><td>[ Wall time, Wall time since last ] (integer
317 seconds. See <a id="idx:gettime1:1563"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>) </td></tr>
318 <tr><td>walltime</td><td>[ Wall time since start, Wall time since last]
319 (milliseconds, SICStus compatibility) </td></tr>
320 <tr><td>memory</td><td>[ Total unshared data, free memory ] (Uses
321 getrusage() if available, otherwise incomplete own statistics.) </td></tr>
322 <tr><td>stacks</td><td>[ global use, local use ] </td></tr>
323 <tr><td>program</td><td>[ heap, 0 ] </td></tr>
324 <tr><td>global_stack</td><td>[ global use, global free ] </td></tr>
325 <tr><td>local_stack</td><td>[ local use, local free ] </td></tr>
326 <tr><td>trail</td><td>[ trail use, trail free ] </td></tr>
327 <tr><td>garbage_collection</td><td>[ number of GC, bytes gained, time
328 spent, bytes left ] The last column is a SWI-Prolog extension. It
329 contains the sum of the memory left after each collection, which can be
330 divided by the count to find the average working set size after GC. Use <code>[Count,
331 Gained, Time|_]</code> for compatiblity. </td></tr>
332 <tr><td>stack_shifts</td><td>[ global shifts, local shifts, time spent ] </td></tr>
333 <tr><td>atoms</td><td>[ number, memory use, 0 ] </td></tr>
334 <tr><td>atom_garbage_collection</td><td>[ number of AGC, bytes gained,
317335 time spent ] </td></tr>
318 <tr valign="top"><td>atoms</td><td>[ number, memory use, 0 ] </td></tr>
319 <tr valign="top"><td>atom_garbage_collection</td><td>[ number of AGC,
320 bytes gained, time spent ] </td></tr>
321 <tr valign="top"><td>clause_garbage_collection</td><td>[ number of CGC,
322 clauses gained, time spent ] </td></tr>
323 <tr valign="top"><td>core</td><td>Same as memory </td></tr>
336 <tr><td>clause_garbage_collection</td><td>[ number of CGC, clauses
337 gained, time spent ] </td></tr>
338 <tr><td>core</td><td>Same as memory </td></tr>
324339 </table>
325 <div class="caption"><b>Table 7 : </b>Compatibility keys for <a name="idx:statistics2:1564"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>.
340 <div class="caption"><b>Table 7 : </b>Compatibility keys for <a id="idx:statistics2:1564"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>.
326341 Time is expressed in milliseconds.</div>
327 <a name="tab:qpstatistics"></a>
342 <a id="tab:qpstatistics"></a>
328343 </dd>
329 <dt class="pubdef"><a name="statistics/0"><strong>statistics</strong></a></dt>
344 <dt class="pubdef"><a id="statistics/0"><strong>statistics</strong></a></dt>
330345 <dd class="defbody">
331346 Display a table of system statistics on the stream <code>user_error</code>.</dd>
332 <dt class="pubdef"><a name="time/1"><strong>time</strong>(<var>:Goal</var>)</a></dt>
347 <dt class="pubdef"><a id="time/1"><strong>time</strong>(<var>:Goal</var>)</a></dt>
333348 <dd class="defbody">
334 Execute <var>Goal</var> just like <a name="idx:call1:1565"></a><a class="pred" href="metacall.html#call/1">call/1</a>
349 Execute <var>Goal</var> just like <a id="idx:call1:1565"></a><a class="pred" href="metacall.html#call/1">call/1</a>
335350 and print time used, number of logical inferences and the average number
336351 of <var>lips</var> (logical inferences per second). Note that SWI-Prolog
337352 counts the actual executed number of inferences rather than the number
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 1.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="swiprolog.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="swiorother.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:status"><a name="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Status
235 <h2 id="sec:status"><a id="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Status
195236 and releases</span></a></h2>
196237
197 <a name="sec:status"></a>
198
199 <p>This manual describes version 7.6.2 of SWI-Prolog. SWI-Prolog is
238 <a id="sec:status"></a>
239
240 <p>This manual describes version 7.7.4 of SWI-Prolog. SWI-Prolog is
200241 widely considered to be a robust and scalable implementation of the
201242 Prolog language. It is widely used in education and research. In
202243 addition, it is in use for <var>24 &times; 7</var> mission critical
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.18</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.18</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="IO.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="chario.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:streamstat"><a name="sec:4.18"><span class="sec-nr">4.18</span> <span class="sec-title">Status
235 <h2 id="sec:streamstat"><a id="sec:4.18"><span class="sec-nr">4.18</span> <span class="sec-title">Status
195236 of streams</span></a></h2>
196237
197 <a name="sec:streamstat"></a>
238 <a id="sec:streamstat"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="wait_for_input/3"><strong>wait_for_input</strong>(<var>+ListOfStreams,
241 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="wait_for_input/3"><strong>wait_for_input</strong>(<var>+ListOfStreams,
201242 -ReadyList, +TimeOut</var>)</a></dt>
202243 <dd class="defbody">
203244 Wait for input on one of the streams in <var>ListOfStreams</var> and
204245 return a list of streams on which input is available in <var>ReadyList</var>.
205 <a name="idx:waitforinput3:1066"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
246 <a id="idx:waitforinput3:1066"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
206247 waits for at most <var>TimeOut</var> seconds. <var>TimeOut</var> may be
207248 specified as a floating point number to specify fractions of a second.
208 If <var>TimeOut</var> equals <code>infinite</code>, <a name="idx:waitforinput3:1067"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
249 If <var>TimeOut</var> equals <code>infinite</code>, <a id="idx:waitforinput3:1067"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
209250 waits indefinitely. If <var>Timeout</var> is 0 or 0.0 this predicate
210251 returns without waiting.<sup class="fn">91<span class="fn-text">Prior to
211252 7.3.23, the integer value `0' was the same as <code>infinite</code>.</span></sup>
227268 wait_for_input([user_input, P4], Inputs, 0).
228269 </pre>
229270
230 <p><a name="idx:select:1068"></a><a name="idx:poll:1069"></a>When
231 available, the implementation is based on the poll() system call. The
232 poll() puts no additional restriction on the number of open files the
233 process may have. It does limit the time to <var>2^31-1</var>
234 milliseconds (a bit less than 25 days). Specifying a too large timeout
235 raises a
271 <p><a id="idx:select:1068"></a><a id="idx:poll:1069"></a>When available,
272 the implementation is based on the poll() system call. The poll() puts
273 no additional restriction on the number of open files the process may
274 have. It does limit the time to <var>2^31-1</var> milliseconds (a bit
275 less than 25 days). Specifying a too large timeout raises a
236276 <code>representation_error(timeout)</code> exception. If poll() is not
237277 supported by the OS, select() is used. The select() call can only handle
238278 file descriptors up to <code>FD_SETSIZE</code>. If the set contains a
239279 descriptor that exceeds this limit a
240280 <code>representation_error('FD_SETSIZE')</code> is raised.
241281
242 <p>Note that <a name="idx:waitforinput3:1070"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
282 <p>Note that <a id="idx:waitforinput3:1070"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
243283 returns streams that have data waiting. This does not mean you can, for
244 example, call <a name="idx:read2:1071"></a><a class="pred" href="termrw.html#read/2">read/2</a>
284 example, call <a id="idx:read2:1071"></a><a class="pred" href="termrw.html#read/2">read/2</a>
245285 on the stream without blocking as the stream might hold an incomplete
246286 term. The predicate
247 <a name="idx:setstream2:1072"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
287 <a id="idx:setstream2:1072"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
248288 using the option <code>timeout(Seconds)</code> can be used to make the
249289 stream generate an exception if no new data arrives within the timeout
250290 period. Suppose two processes communicate by exchanging Prolog terms.
261301 </pre>
262302
263303 </dd>
264 <dt class="pubdef"><a name="byte_count/2"><strong>byte_count</strong>(<var>+Stream,
304 <dt class="pubdef"><a id="byte_count/2"><strong>byte_count</strong>(<var>+Stream,
265305 -Count</var>)</a></dt>
266306 <dd class="defbody">
267307 Byte position in <var>Stream</var>. For binary streams this is the same
268 as <a name="idx:charactercount2:1073"></a><a class="pred" href="streamstat.html#character_count/2">character_count/2</a>.
308 as <a id="idx:charactercount2:1073"></a><a class="pred" href="streamstat.html#character_count/2">character_count/2</a>.
269309 For text files the number may be different due to multi-byte encodings
270310 or additional record separators (such as Control-M in Windows).</dd>
271 <dt class="pubdef"><a name="character_count/2"><strong>character_count</strong>(<var>+Stream,
311 <dt class="pubdef"><a id="character_count/2"><strong>character_count</strong>(<var>+Stream,
272312 -Count</var>)</a></dt>
273313 <dd class="defbody">
274314 Unify <var>Count</var> with the current character index. For input
275315 streams this is the number of characters read since the open; for output
276316 streams this is the number of characters written. Counting starts at 0.</dd>
277 <dt class="pubdef"><a name="line_count/2"><strong>line_count</strong>(<var>+Stream,
317 <dt class="pubdef"><a id="line_count/2"><strong>line_count</strong>(<var>+Stream,
278318 -Count</var>)</a></dt>
279319 <dd class="defbody">
280320 Unify <var>Count</var> with the number of lines read or written.
281321 Counting starts at 1.</dd>
282 <dt class="pubdef"><a name="line_position/2"><strong>line_position</strong>(<var>+Stream,
322 <dt class="pubdef"><a id="line_position/2"><strong>line_position</strong>(<var>+Stream,
283323 -Count</var>)</a></dt>
284324 <dd class="defbody">
285325 Unify <var>Count</var> with the position on the current line. Note that
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 5.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ext-lists.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ext-syntax.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:strings"><a name="sec:5.2"><span class="sec-nr">5.2</span> <span class="sec-title">The
235 <h2 id="sec:strings"><a id="sec:5.2"><span class="sec-nr">5.2</span> <span class="sec-title">The
195236 string type and its double quoted syntax</span></a></h2>
196237
197 <a name="sec:strings"></a>
238 <a id="sec:strings"></a>
198239
199240 <p>As of SWI-Prolog version&nbsp;7, text enclosed in double quotes
200241 (e.g.,
203244 on the global (term) stack. Strings represent sequences of Unicode
204245 characters including the character code 0 (zero). The length strings is
205246 limited by the available space on the global (term) stack (see
206 <a name="idx:setprologstack2:1594"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>).
247 <a id="idx:setprologstack2:1594"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>).
207248 Strings are distinct from lists, which makes it possible to detect them
208249 at runtime and print them using the string syntax, as illustrated below:
209250
224265 Prolog flag and does not define the term that is produced by back quoted
225266 text.
226267
227 <p><table border="2" frame="hsides" rules="groups" style="margin:auto">
228 <tr valign="top"><td><b>Mode</b></td><td align=center><a class="flag" href="flags.html#flag:double_quotes">double_quotes</a> </td><td align=center><a class="flag" href="flags.html#flag:back_quotes">back_quotes</a> </td></tr>
229 <tbody>
230 <tr valign="top"><td>Version&nbsp;7 default</td><td align=center>string</td><td align=center>codes </td></tr>
231 <tr valign="top"><td><strong>--traditional</strong> </td><td align=center>codes</td><td align=center>symbol_char </td></tr>
268 <p><table class="latex frame-hsides center">
269 <tr><td><b>Mode</b></td><td align=center><a class="flag" href="flags.html#flag:double_quotes">double_quotes</a> </td><td align=center><a class="flag" href="flags.html#flag:back_quotes">back_quotes</a> </td></tr>
270 <tr class="hline"><td>Version&nbsp;7 default</td><td align=center>string</td><td align=center>codes </td></tr>
271 <tr><td><strong>--traditional</strong> </td><td align=center>codes</td><td align=center>symbol_char </td></tr>
232272 </table>
233273 <div class="caption"><b>Table 8 : </b>Mapping of double and back quoted
234274 text in the two modes.</div>
235 <a name="tab:quote-mapping"></a>
236
237 <p><a class="sec" href="strings.html">Section 5.2.4</a> motivates the
238 introduction of strings and mapping double quoted text to this type.
239
240 <p><h3 id="sec:string-predicates"><a name="sec:5.2.1"><span class="sec-nr">5.2.1</span> <span class="sec-title">Predicates
275 <a id="tab:quote-mapping"></a>
276
277 <p><a class="sec" href="strings.html#sec:5.2.4">Section 5.2.4</a>
278 motivates the introduction of strings and mapping double quoted text to
279 this type.
280
281 <p><h3 id="sec:string-predicates"><a id="sec:5.2.1"><span class="sec-nr">5.2.1</span> <span class="sec-title">Predicates
241282 that operate on strings</span></a></h3>
242283
243 <a name="sec:string-predicates"></a>
284 <a id="sec:string-predicates"></a>
244285
245286 <p>Strings may be manipulated by a set of predicates that is similar to
246 the manipulation of atoms. In addition to the list below, <a name="idx:string1:1595"></a><a class="pred" href="typetest.html#string/1">string/1</a>
247 performs the type check for this type and is described in <a class="sec" href="typetest.html">section
287 the manipulation of atoms. In addition to the list below, <a id="idx:string1:1595"></a><a class="pred" href="typetest.html#string/1">string/1</a>
288 performs the type check for this type and is described in <a class="sec" href="typetest.html#sec:4.6">section
248289 4.6</a>.
249290
250291 <p>SWI-Prolog's string primitives are being synchronized with
251 http://eclipseclp.org/wiki/Prolog/StringsECLiPSe. We expect the set of
252 predicates documented in this section to be stable, although it might be
253 expanded. In general, SWI-Prolog's text manipulation predicates accept
254 any form of text as input argument and produce the type indicated by the
255 predicate name as output. This policy simplifies migration and writing
256 programs that can run unmodified or with minor modifications on systems
257 that do not support strings. Code should avoid relying on this feature
258 as much as possible for clarity as well as to facilitate a more strict
259 mode and/or type checking in future releases.
292 <a class="url" href="http://eclipseclp.org/wiki/Prolog/Strings">ECLiPSe</a>.
293 We expect the set of predicates documented in this section to be stable,
294 although it might be expanded. In general, SWI-Prolog's text
295 manipulation predicates accept any form of text as input argument and
296 produce the type indicated by the predicate name as output. This policy
297 simplifies migration and writing programs that can run unmodified or
298 with minor modifications on systems that do not support strings. Code
299 should avoid relying on this feature as much as possible for clarity as
300 well as to facilitate a more strict mode and/or type checking in future
301 releases.
260302
261303 <dl class="latex">
262 <dt class="pubdef"><a name="atom_string/2"><strong>atom_string</strong>(<var>?Atom,
304 <dt class="pubdef"><a id="atom_string/2"><strong>atom_string</strong>(<var>?Atom,
263305 ?String</var>)</a></dt>
264306 <dd class="defbody">
265307 Bi-directional conversion between an atom and a string. At least one of
266308 the two arguments must be instantiated. <var>Atom</var> can also be an
267309 integer or floating point number.</dd>
268 <dt class="pubdef"><a name="number_string/2"><strong>number_string</strong>(<var>?Number,
310 <dt class="pubdef"><a id="number_string/2"><strong>number_string</strong>(<var>?Number,
269311 ?String</var>)</a></dt>
270312 <dd class="defbody">
271313 Bi-directional conversion between a number and a string. At least one of
286328 before exponent, i.e., <code>"1e10"</code> is a valid number.
287329 </ul>
288330 </dd>
289 <dt class="pubdef"><a name="term_string/2"><strong>term_string</strong>(<var>?Term,
331 <dt class="pubdef"><a id="term_string/2"><strong>term_string</strong>(<var>?Term,
290332 ?String</var>)</a></dt>
291333 <dd class="defbody">
292334 Bi-directional conversion between a term and a string. If <var>String</var>
293335 is instantiated, it is parsed and the result is unified with <var>Term</var>.
294336 Otherwise <var>Term</var> is `written' using the option <code>quoted(true)</code>
295337 and the result is converted to <var>String</var>.</dd>
296 <dt class="pubdef"><a name="term_string/3"><strong>term_string</strong>(<var>?Term,
338 <dt class="pubdef"><a id="term_string/3"><strong>term_string</strong>(<var>?Term,
297339 ?String, +Options</var>)</a></dt>
298340 <dd class="defbody">
299 As <a name="idx:termstring2:1596"></a><a class="pred" href="strings.html#term_string/2">term_string/2</a>,
300 passing <var>Options</var> to either <a name="idx:readterm2:1597"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
301 or <a name="idx:writeterm2:1598"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
341 As <a id="idx:termstring2:1596"></a><a class="pred" href="strings.html#term_string/2">term_string/2</a>,
342 passing <var>Options</var> to either <a id="idx:readterm2:1597"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
343 or <a id="idx:writeterm2:1598"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
302344 For example:
303345
304346 <pre class="code">
308350 </pre>
309351
310352 </dd>
311 <dt class="pubdef"><a name="string_chars/2"><strong>string_chars</strong>(<var>?String,
353 <dt class="pubdef"><a id="string_chars/2"><strong>string_chars</strong>(<var>?String,
312354 ?Chars</var>)</a></dt>
313355 <dd class="defbody">
314356 Bi-directional conversion between a string and a list of characters
315357 (one-character atoms). At least one of the two arguments must be
316358 instantiated.</dd>
317 <dt class="pubdef"><a name="string_codes/2"><strong>string_codes</strong>(<var>?String,
359 <dt class="pubdef"><a id="string_codes/2"><strong>string_codes</strong>(<var>?String,
318360 ?Codes</var>)</a></dt>
319361 <dd class="defbody">
320362 Bi-directional conversion between a string and a list of character
321363 codes. At least one of the two arguments must be instantiated.</dd>
322 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="text_to_string/2"><strong>text_to_string</strong>(<var>+Text,
364 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="text_to_string/2"><strong>text_to_string</strong>(<var>+Text,
323365 -String</var>)</a></dt>
324366 <dd class="defbody">
325367 Converts <var>Text</var> to a string. <var>Text</var> is an atom, string
326368 or list of characters (codes or chars). When running in
327369 <strong>--traditional</strong> mode, <code>'[]'</code> is ambiguous and
328370 interpreted as an empty string.</dd>
329 <dt class="pubdef"><a name="string_length/2"><strong>string_length</strong>(<var>+String,
371 <dt class="pubdef"><a id="string_length/2"><strong>string_length</strong>(<var>+String,
330372 -Length</var>)</a></dt>
331373 <dd class="defbody">
332374 Unify <var>Length</var> with the number of characters in <var>String</var>.
333 This predicate is functionally equivalent to <a name="idx:atomlength2:1599"></a><a class="pred" href="manipatom.html#atom_length/2">atom_length/2</a>
375 This predicate is functionally equivalent to <a id="idx:atomlength2:1599"></a><a class="pred" href="manipatom.html#atom_length/2">atom_length/2</a>
334376 and also accepts atoms, integers and floats as its first argument.</dd>
335 <dt class="pubdef"><a name="string_code/3"><strong>string_code</strong>(<var>?Index,
377 <dt class="pubdef"><a id="string_code/3"><strong>string_code</strong>(<var>?Index,
336378 +String, ?Code</var>)</a></dt>
337379 <dd class="defbody">
338380 True when <var>Code</var> represents the character at the 1-based <var>Index</var>
343385 <var>String</var>. The mode <code>string_code(-,+,+)</code> is
344386 deterministic if the searched-for <var>Code</var> appears only once in <var>String</var>.
345387 See also
346 <a name="idx:substring5:1600"></a><a class="pred" href="strings.html#sub_string/5">sub_string/5</a>.</dd>
347 <dt class="pubdef"><a name="get_string_code/3"><strong>get_string_code</strong>(<var>+Index,
388 <a id="idx:substring5:1600"></a><a class="pred" href="strings.html#sub_string/5">sub_string/5</a>.</dd>
389 <dt class="pubdef"><a id="get_string_code/3"><strong>get_string_code</strong>(<var>+Index,
348390 +String, -Code</var>)</a></dt>
349391 <dd class="defbody">
350 Semi-deterministic version of <a name="idx:stringcode3:1601"></a><a class="pred" href="strings.html#string_code/3">string_code/3</a>.
392 Semi-deterministic version of <a id="idx:stringcode3:1601"></a><a class="pred" href="strings.html#string_code/3">string_code/3</a>.
351393 In addition, this version provides strict range checking, throwing a
352394 domain error if <var>Index</var> is less than 1 or greater than the
353395 length of <var>String</var>. ECLiPSe provides this to support <code>String[Index]</code>
354396 notation.</dd>
355 <dt class="pubdef"><a name="string_concat/3"><strong>string_concat</strong>(<var>?String1,
397 <dt class="pubdef"><a id="string_concat/3"><strong>string_concat</strong>(<var>?String1,
356398 ?String2, ?String3</var>)</a></dt>
357399 <dd class="defbody">
358 Similar to <a name="idx:atomconcat3:1602"></a><a class="pred" href="manipatom.html#atom_concat/3">atom_concat/3</a>,
400 Similar to <a id="idx:atomconcat3:1602"></a><a class="pred" href="manipatom.html#atom_concat/3">atom_concat/3</a>,
359401 but the unbound argument will be unified with a string object rather
360402 than an atom. Also, if both <var>String1</var> and
361403 <var>String2</var> are unbound and <var>String3</var> is bound to text,
366408 particularly fast on long strings, as for each redo the system has to
367409 create two entirely new strings, while the list equivalent only creates
368410 a single new list-cell and moves some pointers around.</dd>
369 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="split_string/4"><strong>split_string</strong>(<var>+String,
411 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="split_string/4"><strong>split_string</strong>(<var>+String,
370412 +SepChars, +PadChars, -SubStrings</var>)</a></dt>
371413 <dd class="defbody">
372414 Break <var>String</var> into <var>SubStrings</var>. The <var>SepChars</var>
401443 <var>PadChars</var> or is equivalent to handle multiple adjacent
402444 separators as a single (often white space). The behaviour with partially
403445 overlapping sets of padding and separators should be considered
404 undefined. See also <a name="idx:readstring5:1603"></a><a class="pred" href="strings.html#read_string/5">read_string/5</a>.</dd>
405 <dt class="pubdef"><a name="sub_string/5"><strong>sub_string</strong>(<var>+String,
446 undefined. See also <a id="idx:readstring5:1603"></a><a class="pred" href="strings.html#read_string/5">read_string/5</a>.</dd>
447 <dt class="pubdef"><a id="sub_string/5"><strong>sub_string</strong>(<var>+String,
406448 ?Before, ?Length, ?After, ?SubString</var>)</a></dt>
407449 <dd class="defbody">
408450 <var>SubString</var> is a substring of <var>String</var>. There are <var>Before</var>
410452 contains <var>Length</var> character and is followed by <var>After</var>
411453 characters in <var>String</var>. If not enough information is provided
412454 to compute the start of the match, <var>String</var> is scanned
413 left-to-right. This predicate is functionally equivalent to <a name="idx:subatom5:1604"></a><a class="pred" href="manipatom.html#sub_atom/5">sub_atom/5</a>,
455 left-to-right. This predicate is functionally equivalent to <a id="idx:subatom5:1604"></a><a class="pred" href="manipatom.html#sub_atom/5">sub_atom/5</a>,
414456 but operates on strings. The following example splits a string of the
415457 form
416458 &lt;<var>name</var>&gt;=&lt;<var>value</var>&gt; into the name part (an
425467 </pre>
426468
427469 </dd>
428 <dt class="pubdef"><a name="atomics_to_string/2"><strong>atomics_to_string</strong>(<var>+List,
470 <dt class="pubdef"><a id="atomics_to_string/2"><strong>atomics_to_string</strong>(<var>+List,
429471 -String</var>)</a></dt>
430472 <dd class="defbody">
431473 <var>List</var> is a list of strings, atoms, integers or floating point
432474 numbers. Succeeds if <var>String</var> can be unified with the
433475 concatenated elements of <var>List</var>. Equivalent to <code>atomics_to_string(List,
434476 '', String)</code>.</dd>
435 <dt class="pubdef"><a name="atomics_to_string/3"><strong>atomics_to_string</strong>(<var>+List,
477 <dt class="pubdef"><a id="atomics_to_string/3"><strong>atomics_to_string</strong>(<var>+List,
436478 +Separator, -String</var>)</a></dt>
437479 <dd class="defbody">
438 Creates a string just like <a name="idx:atomicstostring2:1605"></a><a class="pred" href="strings.html#atomics_to_string/2">atomics_to_string/2</a>,
480 Creates a string just like <a id="idx:atomicstostring2:1605"></a><a class="pred" href="strings.html#atomics_to_string/2">atomics_to_string/2</a>,
439481 but inserts
440482 <var>Separator</var> between each pair of inputs. For example:
441483
446488 </pre>
447489
448490 </dd>
449 <dt class="pubdef"><a name="string_upper/2"><strong>string_upper</strong>(<var>+String,
491 <dt class="pubdef"><a id="string_upper/2"><strong>string_upper</strong>(<var>+String,
450492 -UpperCase</var>)</a></dt>
451493 <dd class="defbody">
452494 Convert <var>String</var> to upper case and unify the result with
453495 <var>UpperCase</var>.</dd>
454 <dt class="pubdef"><a name="string_lower/2"><strong>string_lower</strong>(<var>+String,
496 <dt class="pubdef"><a id="string_lower/2"><strong>string_lower</strong>(<var>+String,
455497 LowerCase</var>)</a></dt>
456498 <dd class="defbody">
457499 Convert <var>String</var> to lower case and unify the result with
458500 <var>LowerCase</var>.</dd>
459 <dt class="pubdef"><a name="read_string/3"><strong>read_string</strong>(<var>+Stream,
501 <dt class="pubdef"><a id="read_string/3"><strong>read_string</strong>(<var>+Stream,
460502 ?Length, -String</var>)</a></dt>
461503 <dd class="defbody">
462504 Read at most <var>Length</var> characters from <var>Stream</var> and
463505 return them in the string <var>String</var>. If <var>Length</var> is
464506 unbound, <var>Stream</var> is read to the end and <var>Length</var> is
465507 unified with the number of characters read.</dd>
466 <dt class="pubdef"><a name="read_string/5"><strong>read_string</strong>(<var>+Stream,
508 <dt class="pubdef"><a id="read_string/5"><strong>read_string</strong>(<var>+Stream,
467509 +SepChars, +PadChars, -Sep, -String</var>)</a></dt>
468510 <dd class="defbody">
469511 Read a string from <var>Stream</var>, providing functionality similar to
470 <a name="idx:splitstring4:1606"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>.
512 <a id="idx:splitstring4:1606"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>.
471513 The predicate performs the following steps:
472514
473515 <p>
482524 terminated by the end of the input, <var>Sep</var> is unified with -1.
483525 </ol>
484526
485 <p>The predicate <a name="idx:readstring5:1607"></a><a class="pred" href="strings.html#read_string/5">read_string/5</a>
527 <p>The predicate <a id="idx:readstring5:1607"></a><a class="pred" href="strings.html#read_string/5">read_string/5</a>
486528 called repeatedly on an input until
487529 <var>Sep</var> is -1 (end of file) is equivalent to reading the entire
488 file into a string and calling <a name="idx:splitstring4:1608"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>,
530 file into a string and calling <a id="idx:splitstring4:1608"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>,
489531 provided that <var>SepChars</var> and <var>PadChars</var> are not <em>partially
490532 overlapping</em>.<sup class="fn">144<span class="fn-text">Behaviour that
491533 is fully compatible would requite unlimited look-ahead.</span></sup>
501543 </pre>
502544
503545 </dd>
504 <dt class="pubdef"><a name="open_string/2"><strong>open_string</strong>(<var>+String,
546 <dt class="pubdef"><a id="open_string/2"><strong>open_string</strong>(<var>+String,
505547 -Stream</var>)</a></dt>
506548 <dd class="defbody">
507549 True when <var>Stream</var> is an input stream that accesses the content
511553 </dd>
512554 </dl>
513555
514 <p><h3 id="sec:text-representation"><a name="sec:5.2.2"><span class="sec-nr">5.2.2</span> <span class="sec-title">Representing
556 <p><h3 id="sec:text-representation"><a id="sec:5.2.2"><span class="sec-nr">5.2.2</span> <span class="sec-title">Representing
515557 text: strings, atoms and code lists</span></a></h3>
516558
517 <a name="sec:text-representation"></a>
559 <a id="sec:text-representation"></a>
518560
519561 <p>With the introduction of strings as a Prolog data type, there are
520562 three main ways to represent text: using strings, atoms or code lists.
527569 <dt><b>Lists of character codes</b></dt>
528570 <dd>
529571 is what you need if you want to <em>parse</em> text using Prolog grammar
530 rules (DCGs, see <a name="idx:phrase3:1609"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>).
572 rules (DCGs, see <a id="idx:phrase3:1609"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>).
531573 Most of the text reading predicates (e.g.,
532 <a name="idx:readlinetocodes2:1610"></a><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a>)
574 <a id="idx:readlinetocodes2:1610"></a><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a>)
533575 return a list of character codes because most applications need to parse
534576 these lines before the data can be processed.</dd>
535577 <dt><b>Atoms</b></dt>
547589 <dd>
548590 typically represents text that is processed as a unit most of the time,
549591 but which is not an identifier for something. Format specifications for
550 <a name="idx:format3:1611"></a><a class="pred" href="format.html#format/3">format/3</a>
592 <a id="idx:format3:1611"></a><a class="pred" href="format.html#format/3">format/3</a>
551593 is a good example. Another example is a descriptive text provided in an
552 application. Strings may be composed and decomposed using e.g., <a name="idx:stringconcat3:1612"></a><a class="pred" href="strings.html#string_concat/3">string_concat/3</a>
553 and <a name="idx:substring5:1613"></a><a class="pred" href="strings.html#sub_string/5">sub_string/5</a>
554 or converted for parsing using <a name="idx:stringcodes2:1614"></a><a class="pred" href="strings.html#string_codes/2">string_codes/2</a>
555 or created from codes generated by a generative grammar rule, also using <a name="idx:stringcodes2:1615"></a><a class="pred" href="strings.html#string_codes/2">string_codes/2</a>.
594 application. Strings may be composed and decomposed using e.g., <a id="idx:stringconcat3:1612"></a><a class="pred" href="strings.html#string_concat/3">string_concat/3</a>
595 and <a id="idx:substring5:1613"></a><a class="pred" href="strings.html#sub_string/5">sub_string/5</a>
596 or converted for parsing using <a id="idx:stringcodes2:1614"></a><a class="pred" href="strings.html#string_codes/2">string_codes/2</a>
597 or created from codes generated by a generative grammar rule, also using <a id="idx:stringcodes2:1615"></a><a class="pred" href="strings.html#string_codes/2">string_codes/2</a>.
556598 </dd>
557599 </dl>
558600
559 <p><h3 id="sec:ext-dquotes-port"><a name="sec:5.2.3"><span class="sec-nr">5.2.3</span> <span class="sec-title">Adapting
601 <p><h3 id="sec:ext-dquotes-port"><a id="sec:5.2.3"><span class="sec-nr">5.2.3</span> <span class="sec-title">Adapting
560602 code for double quoted strings</span></a></h3>
561603
562 <a name="sec:ext-dquotes-port"></a>
604 <a id="sec:ext-dquotes-port"></a>
563605
564606 <p>The predicates in this section can help adapting your program to the
565607 new convention for handling double quoted strings. We have adapted a
566608 huge code base with which we were not familiar in about half a day.
567609
568610 <dl class="latex">
569 <dt class="pubdef"><a name="list_strings/0"><strong>list_strings</strong></a></dt>
611 <dt class="pubdef"><a id="list_strings/0"><strong>list_strings</strong></a></dt>
570612 <dd class="defbody">
571613 This predicate may be used to assess compatibility issues due to the
572614 representation of double quoted text as string objects. See
573 <a class="sec" href="strings.html">section 5.2</a> and <a class="sec" href="strings.html">section
574 5.2.4</a>. To use it, load your program into Prolog and run <a name="idx:liststrings0:1616"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
615 <a class="sec" href="strings.html#sec:5.2">section 5.2</a> and <a class="sec" href="strings.html#sec:5.2.4">section
616 5.2.4</a>. To use it, load your program into Prolog and run <a id="idx:liststrings0:1616"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
575617 The predicate lists source locations of string objects encountered in
576618 the program that are not considered safe. Such string need to be
577619 examined manually, after which one of the actions below may be
595637 command line option and code exploiting this mapping is also not
596638 portable to ISO compliant systems.
597639 <li>If the strings appear in facts and usage is safe, add a clause to
598 the multifile predicate check:string_predicate/1 to silence <a name="idx:liststrings0:1617"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
640 the multifile predicate check:string_predicate/1 to silence <a id="idx:liststrings0:1617"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
599641 on all clauses of that predicate.
600642 <li>If the strings appear as an argument to a predicate that can handle
601643 string objects, add a clause to the multifile predicate
602 check:valid_string_goal/1 to silence <a name="idx:liststrings0:1618"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
644 check:valid_string_goal/1 to silence <a id="idx:liststrings0:1618"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
603645 </ul>
604646 </dd>
605 <dt class="pubdef"><a name="check:string_predicate/1"><strong>check:string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
647 <dt class="pubdef"><a id="check:string_predicate/1"><strong>check:string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
606648 <dd class="defbody">
607649 Declare that <var>PredicateIndicator</var> has clauses that contain
608650 strings, but that this is safe. For example, if there is a predicate
609651 help_info/2 , where the second argument contains a double quoted string
610652 that is handled properly by the predicates of the applications' help
611653 system, add the following declaration to stop
612 <a name="idx:liststrings0:1619"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
654 <a id="idx:liststrings0:1619"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
613655 from complaining:
614656
615657 <pre class="code">
619661 </pre>
620662
621663 </dd>
622 <dt class="pubdef"><a name="check:valid_string_goal/1"><strong>check:valid_string_goal</strong>(<var>:Goal</var>)</a></dt>
664 <dt class="pubdef"><a id="check:valid_string_goal/1"><strong>check:valid_string_goal</strong>(<var>:Goal</var>)</a></dt>
623665 <dd class="defbody">
624666 Declare that calls to <var>Goal</var> are safe. The module qualification
625667 is the actual module in which <var>Goal</var> is defined. For example, a
626 call to <a name="idx:format3:1620"></a><a class="pred" href="format.html#format/3">format/3</a>
668 call to <a id="idx:format3:1620"></a><a class="pred" href="format.html#format/3">format/3</a>
627669 is resolved by the predicate system:format/3. and the code below
628670 specifies that the second argument may be a string (system predicates
629671 that accept strings are defined in the library).
637679 <p></dd>
638680 </dl>
639681
640 <p><h3 id="sec:ext-dquotes-motivation"><a name="sec:5.2.4"><span class="sec-nr">5.2.4</span> <span class="sec-title">Why
682 <p><h3 id="sec:ext-dquotes-motivation"><a id="sec:5.2.4"><span class="sec-nr">5.2.4</span> <span class="sec-title">Why
641683 has the representation of double quoted text changed?</span></a></h3>
642684
643 <a name="sec:ext-dquotes-motivation"></a>
685 <a id="sec:ext-dquotes-motivation"></a>
644686
645687 <p>Prolog defines two forms of quoted text. Traditionally, single quoted
646688 text is mapped to atoms while double quoted text is mapped to a list of
681723
682724 <p>Lacking runtime information, debuggers and the toplevel can only use
683725 heuristics to decide whether to print a list of integers as such or as a
684 string (see <a name="idx:portraytext1:1621"></a><span class="pred-ext">portray_text/1</span>).
726 string (see <a id="idx:portraytext1:1621"></a><span class="pred-ext">portray_text/1</span>).
685727
686728 <p>While experienced Prolog programmers have learned to cope with this,
687729 we still consider this an unfortunate situation.
749791 my_class(_).
750792 </pre>
751793
752 <p>Finally, the predicate <a name="idx:stringcode3:1622"></a><a class="pred" href="strings.html#string_code/3">string_code/3</a>
753 can be exploited directly as a replacement for the <a name="idx:memberchk2:1623"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
794 <p>Finally, the predicate <a id="idx:stringcode3:1622"></a><a class="pred" href="strings.html#string_code/3">string_code/3</a>
795 can be exploited directly as a replacement for the <a id="idx:memberchk2:1623"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
754796 on a list of codes. Although the string is still pushed onto the stack,
755797 it is more compact and only a single entity.
756798 </dd>
757799 </dl>
758800
759 <p>We offer the predicate <a name="idx:liststrings0:1624"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
801 <p>We offer the predicate <a id="idx:liststrings0:1624"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
760802 to help porting your program.
761803
762804 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="otherlicenses.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="predsummary.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:summary"><a name="sec:F"><span class="sec-nr">F</span> <span class="sec-title">Summary</span></a></h1>
195
196 <a name="sec:summary"></a>
235 <h1 id="sec:summary"><a id="sec:F"><span class="sec-nr">F</span> <span class="sec-title">Summary</span></a></h1>
236
237 <a id="sec:summary"></a>
197238
198239 <p>
199240 <hr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 1.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="status.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="sponsor.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:swiorother"><a name="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Should
235 <h2 id="sec:swiorother"><a id="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Should
195236 I be using SWI-Prolog?</span></a></h2>
196237
197 <a name="sec:swiorother"></a>
238 <a id="sec:swiorother"></a>
198239
199240 <p>There are a number of reasons why it might be better to choose a
200241 commercial, or another free, Prolog system:
238279 SWI-Prolog provides a good command line environment, including `Do What
239280 I Mean', autocompletion, history and a tracer that operates on single
240281 key strokes. The system automatically recompiles modified parts of the
241 source code using the <a name="idx:make0:1"></a><a class="pred" href="consulting.html#make/0">make/0</a>
282 source code using the <a id="idx:make0:1"></a><a class="pred" href="consulting.html#make/0">make/0</a>
242283 command. The system can be instructed to open an arbitrary editor on the
243284 right file and line based on its source database. It ships with various
244285 graphical tools and can be combined with the SWI-Prolog editor, PDT
247288 <p>
248289 <li><i>Fast compiler</i><br>
249290 Even very large applications can be loaded in seconds on most machines.
250 If this is not enough, there is the Quick Load Format. See <a name="idx:qcompile1:2"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
251 and <a name="idx:qsaveprogram2:3"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
291 If this is not enough, there is the Quick Load Format. See <a id="idx:qcompile1:2"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
292 and <a id="idx:qsaveprogram2:3"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
252293
253294 <p>
254295 <li><i>Transparent compiled code</i><br>
275316 <p>
276317 <li><i>Flexibility</i><br>
277318 SWI-Prolog can easily be integrated with C, supporting non-determinism
278 in Prolog calling C as well as C calling Prolog (see <a class="sec" href="foreign.html">section
319 in Prolog calling C as well as C calling Prolog (see <a class="sec" href="foreign.html#sec:11">section
279320 11</a>). It can also be <em>embedded</em> in external programs (see
280 <a class="sec" href="plld.html">section 11.5</a>). System predicates can
281 be redefined locally to provide compatibility with other Prolog systems.
321 <a class="sec" href="plld.html#sec:11.5">section 11.5</a>). System
322 predicates can be redefined locally to provide compatibility with other
323 Prolog systems.
282324
283325 <p>
284326 <li><i>Threads</i><br>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 1.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="intro.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="status.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:swiprolog"><a name="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Positioning
235 <h2 id="sec:swiprolog"><a id="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Positioning
195236 SWI-Prolog</span></a></h2>
196237
197 <a name="sec:swiprolog"></a>
238 <a id="sec:swiprolog"></a>
198239
199240 <p>Most implementations of the Prolog language are designed to serve a
200241 limited set of use cases. SWI-Prolog is no exception to this rule.
237278 <cite><a class="cite" href="Bibliography.html#Demoen:CW350">Demoen, 2002</a></cite>.
238279 Some libraries are copied from the YAP<sup class="fn">1<span class="fn-text"><a class="url" href="http://www.dcc.fc.up.pt/\~{}vsc/Yap/">http://www.dcc.fc.up.pt/\~{}vsc/Yap/</a></span></sup>
239280 system. Together with YAP we developed a portability framework (see
240 <a class="sec" href="dialect.html">section C</a>). This framework has
241 been filled for SICStus Prolog, YAP, IF/Prolog and Ciao. SWI-Prolog
242 version&nbsp;7 introduces various extensions to the Prolog language (see <a class="sec" href="extensions.html">section
281 <a class="sec" href="dialect.html#sec:C">section C</a>). This framework
282 has been filled for SICStus Prolog, YAP, IF/Prolog and Ciao. SWI-Prolog
283 version&nbsp;7 introduces various extensions to the Prolog language (see <a class="sec" href="extensions.html#sec:5">section
243284 5</a>). The
244285 <em>string</em> data type and its supporting set of built-in predicates
245286 is compatibility with ECLiPSe.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.16</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.16</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="gc.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="cyclic.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:syntax"><a name="sec:2.16"><span class="sec-nr">2.16</span> <span class="sec-title">The
235 <h2 id="sec:syntax"><a id="sec:2.16"><span class="sec-nr">2.16</span> <span class="sec-title">The
195236 SWI-Prolog syntax</span></a></h2>
196237
197 <a name="sec:syntax"></a>
238 <a id="sec:syntax"></a>
198239
199240 <p>SWI-Prolog syntax is close to ISO-Prolog standard syntax, which is
200241 based on the Edinburgh Prolog syntax. A formal description can be found
201242 in the ISO standard document. For an informal introduction we refer to
202 Prolog text books (see <a class="sec" href="intro.html">section 1</a>)
243 Prolog text books (see <a class="sec" href="intro.html#sec:1">section 1</a>)
203244 and
204 http://www.swi-prolog.org/Links.htmlonline tutorials . In addition to
205 the differences from the ISO standard documented here, SWI-Prolog offers
206 several extensions, some of which also extend the syntax. See <a class="sec" href="extensions.html">section
245 <a class="url" href="http://www.swi-prolog.org/Links.html">online
246 tutorials</a>. In addition to the differences from the ISO standard
247 documented here, SWI-Prolog offers several extensions, some of which
248 also extend the syntax. See <a class="sec" href="extensions.html#sec:5">section
207249 5</a> for more information.
208250
209 <p><h3 id="sec:isosyntax"><a name="sec:2.16.1"><span class="sec-nr">2.16.1</span> <span class="sec-title">ISO
251 <p><h3 id="sec:isosyntax"><a id="sec:2.16.1"><span class="sec-nr">2.16.1</span> <span class="sec-title">ISO
210252 Syntax Support</span></a></h3>
211253
212 <a name="sec:isosyntax"></a>
254 <a id="sec:isosyntax"></a>
213255
214256 <p>This section lists various extensions w.r.t. the ISO Prolog syntax.
215257
216 <p><h4 id="sec:processorcharset"><a name="sec:2.16.1.1"><span class="sec-nr">2.16.1.1</span> <span class="sec-title">Processor
258 <p><h4 id="sec:processorcharset"><a id="sec:2.16.1.1"><span class="sec-nr">2.16.1.1</span> <span class="sec-title">Processor
217259 Character Set</span></a></h4>
218260
219 <a name="sec:processorcharset"></a>
220
221 <p><a name="idx:ISOLatin1:212"></a><a name="idx:characterset:213"></a>The
261 <a id="sec:processorcharset"></a>
262
263 <p><a id="idx:ISOLatin1:212"></a><a id="idx:characterset:213"></a>The
222264 processor character set specifies the class of each character used for
223265 parsing Prolog source text. Character classification is fixed to
224 http://www.unicode.org/Unicode. See also <a class="sec" href="widechars.html">section
266 <a class="url" href="http://www.unicode.org/">Unicode</a>. See also <a class="sec" href="widechars.html#sec:2.19">section
225267 2.19</a>.
226268
227 <p><h4 id="sec:nestedcomments"><a name="sec:2.16.1.2"><span class="sec-nr">2.16.1.2</span> <span class="sec-title">Nested
269 <p><h4 id="sec:nestedcomments"><a id="sec:2.16.1.2"><span class="sec-nr">2.16.1.2</span> <span class="sec-title">Nested
228270 comments</span></a></h4>
229271
230 <a name="sec:nestedcomments"></a>
272 <a id="sec:nestedcomments"></a>
231273
232274 <p>SWI-Prolog allows for nesting <code>/* ... */</code> comments. Where
233275 the ISO standard accepts <code>/* ... /* ... */</code> as a comment,
251293
252294 </pre>
253295
254 <p><h4 id="sec:charescapes"><a name="sec:2.16.1.3"><span class="sec-nr">2.16.1.3</span> <span class="sec-title">Character
296 <p><h4 id="sec:charescapes"><a id="sec:2.16.1.3"><span class="sec-nr">2.16.1.3</span> <span class="sec-title">Character
255297 Escape Syntax</span></a></h4>
256298
257 <a name="sec:charescapes"></a>
299 <a id="sec:charescapes"></a>
258300
259301 <p>Within quoted atoms (using single quotes: <code>'&lt;atom&gt;'</code>)
260302 special characters are represented using escape sequences. An escape
400442
401443 <p>Character escaping is only available if
402444 <code>current_prolog_flag(character_escapes, true)</code> is active
403 (default). See <a name="idx:currentprologflag2:214"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.
404 Character escapes conflict with <a name="idx:writef2:215"></a><a class="pred" href="format.html#writef/2">writef/2</a>
405 in two ways: <code>\40</code> is interpreted as decimal 40 by <a name="idx:writef2:216"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
406 but as octal 40 (decimal 32) by <code>read</code>. Also, the <a name="idx:writef2:217"></a><a class="pred" href="format.html#writef/2">writef/2</a>
445 (default). See <a id="idx:currentprologflag2:214"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.
446 Character escapes conflict with <a id="idx:writef2:215"></a><a class="pred" href="format.html#writef/2">writef/2</a>
447 in two ways: <code>\40</code> is interpreted as decimal 40 by <a id="idx:writef2:216"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
448 but as octal 40 (decimal 32) by <code>read</code>. Also, the <a id="idx:writef2:217"></a><a class="pred" href="format.html#writef/2">writef/2</a>
407449 sequence
408450 <code>\l</code> is illegal. It is advised to use the more widely
409451 supported
410 <a name="idx:format23:218"></a><a class="pred" href="format.html#format/2">format/[2,3]</a>
411 predicate instead. If you insist upon using <a name="idx:writef2:219"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
452 <a id="idx:format23:218"></a><a class="pred" href="format.html#format/2">format/[2,3]</a>
453 predicate instead. If you insist upon using <a id="idx:writef2:219"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
412454 either switch <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
413455 to <code>false</code>, or use double <code>\\</code>, as in <code>writef('\\l')</code>.
414456
415 <p><h4 id="sec:nondecsyntax"><a name="sec:2.16.1.4"><span class="sec-nr">2.16.1.4</span> <span class="sec-title">Syntax
457 <p><h4 id="sec:nondecsyntax"><a id="sec:2.16.1.4"><span class="sec-nr">2.16.1.4</span> <span class="sec-title">Syntax
416458 for non-decimal numbers</span></a></h4>
417459
418 <a name="sec:nondecsyntax"></a>
460 <a id="sec:nondecsyntax"></a>
419461
420462 <p>SWI-Prolog implements both Edinburgh and ISO representations for
421463 non-decimal numbers. According to Edinburgh syntax, such numbers are
425467 <code>0<em>[bxo]</em>&lt;<var>number</var>&gt;</code>. For example: <code>A is 0b100 \/ 0xf00</code>
426468 is a valid expression. Such numbers are always unsigned.
427469
428 <p><h4 id="sec:digitgroupsyntax"><a name="sec:2.16.1.5"><span class="sec-nr">2.16.1.5</span> <span class="sec-title">Using
470 <p><h4 id="sec:digitgroupsyntax"><a id="sec:2.16.1.5"><span class="sec-nr">2.16.1.5</span> <span class="sec-title">Using
429471 digit groups in large integers</span></a></h4>
430472
431 <a name="sec:digitgroupsyntax"></a>
473 <a id="sec:digitgroupsyntax"></a>
432474
433475 <p>SWI-Prolog supports splitting long integers into <em>digit groups</em>.
434476 Digit groups can be separated with the sequence &lt;<var>underscore</var>&gt;,
442484 1_000_/*more*/000
443485 </pre>
444486
445 <p>Integers can be printed using this notation with <a name="idx:format2:220"></a><a class="pred" href="format.html#format/2">format/2</a>,
487 <p>Integers can be printed using this notation with <a id="idx:format2:220"></a><a class="pred" href="format.html#format/2">format/2</a>,
446488 using the
447489 <code>~I</code> format specifier. For example:
448490
454496 <p>The current syntax has been proposed by Ulrich Neumerkel on the
455497 SWI-Prolog mailinglist.
456498
457 <p><h4 id="sec:floatsyntax"><a name="sec:2.16.1.6"><span class="sec-nr">2.16.1.6</span> <span class="sec-title">NaN
499 <p><h4 id="sec:floatsyntax"><a id="sec:2.16.1.6"><span class="sec-nr">2.16.1.6</span> <span class="sec-title">NaN
458500 and Infinity floats and their syntax</span></a></h4>
459501
460 <a name="sec:floatsyntax"></a>
502 <a id="sec:floatsyntax"></a>
461503
462504 <p>SWI-Prolog supports reading an printing `special' floating point
463505 values according to
464 http://eclipseclp.org/Specs/core_update_float.htmlProposal for Prolog
465 Standard core update wrt floating point arithmetic by Joachim Schimpf
466 and available in ECLiPSe Prolog. In particular,
506 <a class="url" href="http://eclipseclp.org/Specs/core_update_float.html">Proposal
507 for Prolog Standard core update wrt floating point arithmetic</a> by
508 Joachim Schimpf and available in ECLiPSe Prolog. In particular,
467509
468510 <p>
469511 <ul class="latex">
489531
490532 <p>Note that, compliant with the ISO standard, SWI-Prolog arithmetic
491533 (see
492 <a class="sec" href="arith.html">section 4.27</a>) never returns one of
493 the above values but instead raises an <em>exception</em>, e.g.,
534 <a class="sec" href="arith.html#sec:4.27">section 4.27</a>) never
535 returns one of the above values but instead raises an <em>exception</em>,
536 e.g.,
494537
495538 <pre class="code">
496539 ?- A is 1/0.
504547 exchange data with languages that can represent the full range of IEEE
505548 doubles.
506549
507 <p><h4 id="sec:varprefix"><a name="sec:2.16.1.7"><span class="sec-nr">2.16.1.7</span> <span class="sec-title">Force
550 <p><h4 id="sec:varprefix"><a id="sec:2.16.1.7"><span class="sec-nr">2.16.1.7</span> <span class="sec-title">Force
508551 only underscore to introduce a variable</span></a></h4>
509552
510 <a name="sec:varprefix"></a>
553 <a id="sec:varprefix"></a>
511554
512555 <p>According to the ISO standard and most Prolog systems, identifiers
513556 that start with an uppercase letter or an underscore are variables. In
530573 uppercase letter is another category were the readability of the code
531574 improves using this option.
532575
533 <p><h4 id="sec:unicodesyntax"><a name="sec:2.16.1.8"><span class="sec-nr">2.16.1.8</span> <span class="sec-title">Unicode
576 <p><h4 id="sec:unicodesyntax"><a id="sec:2.16.1.8"><span class="sec-nr">2.16.1.8</span> <span class="sec-title">Unicode
534577 Prolog source</span></a></h4>
535578
536 <a name="sec:unicodesyntax"></a>
579 <a id="sec:unicodesyntax"></a>
537580
538581 <p>The ISO standard specifies the Prolog syntax in ASCII characters. As
539582 SWI-Prolog supports Unicode in source files we must extend the syntax.
540583 This section describes the implication for the source files, while
541 writing international source files is described in <a class="sec" href="projectfiles.html">section
584 writing international source files is described in <a class="sec" href="projectfiles.html#sec:3.1.3">section
542585 3.1.3</a>.
543586
544587 <p>The SWI-Prolog Unicode character classification is based on version
545 6.0.0 of the Unicode standard. Please note that <a name="idx:chartype2:221"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
588 6.0.0 of the Unicode standard. Please note that <a id="idx:chartype2:221"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
546589 and friends, intended to be used with all text except Prolog source
547590 code, is based on the C library locale-based classification routines.
548591
551594 <li><i>Quoted atoms and strings</i><br>
552595 Any character of any script can be used in quoted atoms and strings. The
553596 escape sequences <code>\uXXXX</code> and <code>\UXXXXXXXX</code> (see
554 <a class="sec" href="syntax.html">section 2.16.1.3</a>) were introduced
555 to specify Unicode code points in ASCII files.
597 <a class="sec" href="syntax.html#sec:2.16.1.3">section 2.16.1.3</a>)
598 were introduced to specify Unicode code points in ASCII files.
556599
557600 <p>
558601 <li><i>Atoms and Variables</i><br>
588631 character of other type</i>) are currently handled as `solo'.
589632 </ul>
590633
591 <p><h4 id="sec:singleton"><a name="sec:2.16.1.9"><span class="sec-nr">2.16.1.9</span> <span class="sec-title">Singleton
634 <p><h4 id="sec:singleton"><a id="sec:2.16.1.9"><span class="sec-nr">2.16.1.9</span> <span class="sec-title">Singleton
592635 variable checking</span></a></h4>
593636
594 <a name="sec:singleton"></a>
595
596 <p><a name="idx:singletonvariable:222"></a><a name="idx:anonymousvariable:223"></a>A <em>singleton
637 <a id="sec:singleton"></a>
638
639 <p><a id="idx:singletonvariable:222"></a><a id="idx:anonymousvariable:223"></a>A <em>singleton
597640 variable</em> is a variable that appears only one time in a clause. It
598641 can always be replaced by <code>_</code>, the
599642 <em>anonymous</em> variable. In some cases, however, people prefer to
600643 give the variable a name. As mistyping a variable is a common mistake,
601 Prolog systems generally give a warning (controlled by <a name="idx:stylecheck1:224"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>)
644 Prolog systems generally give a warning (controlled by <a id="idx:stylecheck1:224"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>)
602645 if a variable is used only once. The system can be informed that a
603646 variable is meant to appear once by <em>starting</em> it with an
604647 underscore, e.g.,
630673 <p>Any normal variable appearing exactly once in the clause <em>and</em>
631674 any named singleton variables appearing more than once are reported.
632675 Below are some examples with warnings in the right column. Singleton
633 messages can be suppressed using the <a name="idx:stylecheck1:225"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>
676 messages can be suppressed using the <a id="idx:stylecheck1:225"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>
634677 directive.
635678
636 <p><table border="2" frame="box" rules="groups" style="margin:auto">
637 <tr valign="top"><td>test(_).</td></tr>
638 <tr valign="top"><td>test(_a).</td><td>Singleton variables: [_a] </td></tr>
639 <tr valign="top"><td>test(_12).</td><td>Singleton variables: [_12] </td></tr>
640 <tr valign="top"><td>test(A).</td><td>Singleton variables: [A] </td></tr>
641 <tr valign="top"><td>test(_A).</td></tr>
642 <tr valign="top"><td>test(__a).</td></tr>
643 <tr valign="top"><td>test(_, _).</td></tr>
644 <tr valign="top"><td>test(_a, _a).</td></tr>
645 <tr valign="top"><td>test(__a, __a).</td><td>Singleton-marked variables
646 appearing more than once: [__a] </td></tr>
647 <tr valign="top"><td>test(_A, _A).</td><td>Singleton-marked variables
648 appearing more than once: [_A] </td></tr>
649 <tr valign="top"><td>test(A, A).</td></tr>
679 <p><table class="latex frame-box center">
680 <tr><td>test(_).</td></tr>
681 <tr><td>test(_a).</td><td>Singleton variables: [_a] </td></tr>
682 <tr><td>test(_12).</td><td>Singleton variables: [_12] </td></tr>
683 <tr><td>test(A).</td><td>Singleton variables: [A] </td></tr>
684 <tr><td>test(_A).</td></tr>
685 <tr><td>test(__a).</td></tr>
686 <tr><td>test(_, _).</td></tr>
687 <tr><td>test(_a, _a).</td></tr>
688 <tr><td>test(__a, __a).</td><td>Singleton-marked variables appearing
689 more than once: [__a] </td></tr>
690 <tr><td>test(_A, _A).</td><td>Singleton-marked variables appearing more
691 than once: [_A] </td></tr>
692 <tr><td>test(A, A).</td></tr>
650693 </table>
651694
652695 <p><b>Semantic singletons</b>
653696
654697 <p>Starting with version 6.5.1, SWI-Prolog has <em>syntactic singletons</em>
655698 and <em>semantic singletons</em>. The first are checked by
656 <a name="idx:readclause3:226"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a>
657 (and <a name="idx:readterm3:227"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
699 <a id="idx:readclause3:226"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a>
700 (and <a id="idx:readterm3:227"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
658701 using the option
659702 <code>singletons(warning)</code>). The latter are generated by the
660703 compiler for variables that appear alone in a <em>branch</em>. For
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.35</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.35</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="tty.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="files.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:system"><a name="sec:4.35"><span class="sec-nr">4.35</span> <span class="sec-title">Operating
235 <h2 id="sec:system"><a id="sec:4.35"><span class="sec-nr">4.35</span> <span class="sec-title">Operating
195236 System Interaction</span></a></h2>
196237
197 <a name="sec:system"></a>
238 <a id="sec:system"></a>
198239
199240 <p>The predicates in this section provide basic access to the operating
200241 system that has been part of the Prolog legacy tradition. Note that more
203244 <code>library(socket)</code>, <code>library(unix)</code> and <code>library(filesex)</code>.
204245
205246 <dl class="latex">
206 <dt class="pubdef"><a name="shell/1"><strong>shell</strong>(<var>+Command</var>)</a></dt>
207 <dd class="defbody">
208 Equivalent to `<code>shell(Command, 0)</code>'. See <a name="idx:shell2:1440"></a><a class="pred" href="system.html#shell/2">shell/2</a>
247 <dt class="pubdef"><a id="shell/1"><strong>shell</strong>(<var>+Command</var>)</a></dt>
248 <dd class="defbody">
249 Equivalent to `<code>shell(Command, 0)</code>'. See <a id="idx:shell2:1440"></a><a class="pred" href="system.html#shell/2">shell/2</a>
209250 for details.</dd>
210 <dt class="pubdef"><a name="shell/2"><strong>shell</strong>(<var>+Command,
251 <dt class="pubdef"><a id="shell/2"><strong>shell</strong>(<var>+Command,
211252 -Status</var>)</a></dt>
212253 <dd class="defbody">
213254 Execute <var>Command</var> on the operating system. <var>Command</var>
214255 is given to the Bourne shell (/bin/sh). <var>Status</var> is unified
215256 with the exit status of the command.
216257
217 <p>On Windows, <a name="idx:shell12:1441"></a><a class="pred" href="system.html#shell/1">shell/[1,2]</a>
258 <p>On Windows, <a id="idx:shell12:1441"></a><a class="pred" href="system.html#shell/1">shell/[1,2]</a>
218259 executes the command using the CreateProcess() API and waits for the
219260 command to terminate. If the command ends with a
220261 <code>&amp;</code> sign, the command is handed to the WinExec() API,
221 which does not wait for the new task to terminate. See also <a name="idx:winexec2:1442"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
262 which does not wait for the new task to terminate. See also <a id="idx:winexec2:1442"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
222263 and
223 <a name="idx:winshell2:1443"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>.
264 <a id="idx:winshell2:1443"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>.
224265 Please note that the CreateProcess() API does <b>not</b> imply the
225266 Windows command interpreter (<b>cmd.exe</b> and therefore commands that
226267 are built in the command interpreter can only be activated using the
233274
234275 <p>Note that many of the operations that can be achieved using the shell
235276 built-in commands can easily be achieved using Prolog primitives. See
236 <a name="idx:makedirectory1:1444"></a><a class="pred" href="files.html#make_directory/1">make_directory/1</a>, <a name="idx:deletefile1:1445"></a><a class="pred" href="files.html#delete_file/1">delete_file/1</a>, <a name="idx:renamefile2:1446"></a><a class="pred" href="files.html#rename_file/2">rename_file/2</a>,
277 <a id="idx:makedirectory1:1444"></a><a class="pred" href="files.html#make_directory/1">make_directory/1</a>, <a id="idx:deletefile1:1445"></a><a class="pred" href="files.html#delete_file/1">delete_file/1</a>, <a id="idx:renamefile2:1446"></a><a class="pred" href="files.html#rename_file/2">rename_file/2</a>,
237278 etc. The clib package provides <code>library(filesex)</code>,
238 implementing various high level file operations such as <a name="idx:copyfile2:1447"></a><span class="pred-ext">copy_file/2</span>.
279 implementing various high level file operations such as <a id="idx:copyfile2:1447"></a><span class="pred-ext">copy_file/2</span>.
239280 Using Prolog primitives instead of shell commands improves the
240281 portability of your program.
241282
242 <p>The library <code>library(process)</code> provides <a name="idx:processcreate3:1448"></a><span class="pred-ext">process_create/3</span>
283 <p>The library <code>library(process)</code> provides <a id="idx:processcreate3:1448"></a><span class="pred-ext">process_create/3</span>
243284 and several related primitives that support more fine-grained
244285 interaction with processes, including I/O redirection and management of
245286 asynchronous processes.</dd>
246 <dt class="pubdef"><a name="getenv/2"><strong>getenv</strong>(<var>+Name,
287 <dt class="pubdef"><a id="getenv/2"><strong>getenv</strong>(<var>+Name,
247288 -Value</var>)</a></dt>
248289 <dd class="defbody">
249290 Get environment variable. Fails silently if the variable does not exist.
250291 Please note that environment variable names are case-sensitive on Unix
251292 systems and case-insensitive on Windows.</dd>
252 <dt class="pubdef"><a name="setenv/2"><strong>setenv</strong>(<var>+Name,
293 <dt class="pubdef"><a id="setenv/2"><strong>setenv</strong>(<var>+Name,
253294 +Value</var>)</a></dt>
254295 <dd class="defbody">
255296 Set an environment variable. <var>Name</var> and <var>Value</var> must
256297 be instantiated to atoms or integers. The environment variable will be
257 passed to <a name="idx:shell02:1449"></a><a class="pred" href="system.html#shell/1">shell/[0-2]</a>
258 and can be requested using <a name="idx:getenv2:1450"></a><a class="pred" href="system.html#getenv/2">getenv/2</a>.
259 They also influence <a name="idx:expandfilename2:1451"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.
298 passed to <a id="idx:shell02:1449"></a><a class="pred" href="system.html#shell/1">shell/[0-2]</a>
299 and can be requested using <a id="idx:getenv2:1450"></a><a class="pred" href="system.html#getenv/2">getenv/2</a>.
300 They also influence <a id="idx:expandfilename2:1451"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.
260301 Environment variables are shared between threads. Depending on the
261 underlying C library, <a name="idx:setenv2:1452"></a><a class="pred" href="system.html#setenv/2">setenv/2</a>
262 and <a name="idx:unsetenv1:1453"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
302 underlying C library, <a id="idx:setenv2:1452"></a><a class="pred" href="system.html#setenv/2">setenv/2</a>
303 and <a id="idx:unsetenv1:1453"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
263304 may not be thread-safe and may cause memory leaks. Only changing the
264305 environment once and before starting threads is safe in all versions of
265306 SWI-Prolog.</dd>
266 <dt class="pubdef"><a name="unsetenv/1"><strong>unsetenv</strong>(<var>+Name</var>)</a></dt>
307 <dt class="pubdef"><a id="unsetenv/1"><strong>unsetenv</strong>(<var>+Name</var>)</a></dt>
267308 <dd class="defbody">
268309 Remove an environment variable from the environment. Some systems lack
269 the underlying unsetenv() library function. On these systems <a name="idx:unsetenv1:1454"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
310 the underlying unsetenv() library function. On these systems <a id="idx:unsetenv1:1454"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
270311 sets the variable to the empty string.</dd>
271 <dt class="pubdef"><a name="setlocale/3"><strong>setlocale</strong>(<var>+Category,
312 <dt class="pubdef"><a id="setlocale/3"><strong>setlocale</strong>(<var>+Category,
272313 -Old, +New</var>)</a></dt>
273314 <dd class="defbody">
274315 Set/Query the <em>locale</em> setting which tells the C library how to
275316 interpret text files, write numbers, dates, etc. Category is one of
276317 <code>all</code>, <code>collate</code>, <code>ctype</code>, <code>messages</code>,
277318 <code>monetary</code>, <code>numeric</code> or <code>time</code>. For
278 details, please consult the C library locale documentation. See also <a class="sec" href="widechars.html">section
319 details, please consult the C library locale documentation. See also <a class="sec" href="widechars.html#sec:2.19.1">section
279320 2.19.1</a>. Please note that the locale is shared between all threads
280 and thread-safe usage of <a name="idx:setlocale3:1455"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>
321 and thread-safe usage of <a id="idx:setlocale3:1455"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>
281322 is in general not possible. Do locale operations before starting threads
282323 or thoroughly study threading aspects of locale support in your
283324 environment before using in multithreaded environments. Locale settings
284 are used by <a name="idx:formattime3:1456"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>, <a name="idx:collationkey2:1457"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
285 and <a name="idx:localesort2:1458"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>.</dd>
286 <dt class="pubdef"><a name="unix/1"><strong>unix</strong>(<var>+Command</var>)</a></dt>
325 are used by <a id="idx:formattime3:1456"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>, <a id="idx:collationkey2:1457"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
326 and <a id="idx:localesort2:1458"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>.</dd>
327 <dt class="pubdef"><a id="unix/1"><strong>unix</strong>(<var>+Command</var>)</a></dt>
287328 <dd class="defbody">
288329 This predicate comes from the Quintus compatibility library and provides
289330 a partial implementation thereof. It provides access to some operating
293334 <dl class="latex">
294335 <dt><strong>system</strong>(<var>+Command</var>)</dt>
295336 <dd class="defbody">
296 Equivalent to calling <a name="idx:shell1:1459"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
337 Equivalent to calling <a id="idx:shell1:1459"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
297338 Use for compatibility only.</dd>
298339 <dt><strong>shell</strong>(<var>+Command</var>)</dt>
299340 <dd class="defbody">
300 Equivalent to calling <a name="idx:shell1:1460"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
341 Equivalent to calling <a id="idx:shell1:1460"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
301342 Use for compatibility only.</dd>
302343 <dt><strong>shell</strong></dt>
303344 <dd class="defbody">
304 Equivalent to calling <a name="idx:shell0:1461"></a><span class="pred-ext">shell/0</span>.
345 Equivalent to calling <a id="idx:shell0:1461"></a><span class="pred-ext">shell/0</span>.
305346 Use for compatibility only.</dd>
306347 <dt><strong>cd</strong></dt>
307348 <dd class="defbody">
308 Equivalent to calling <a name="idx:workingdirectory2:1462"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>
349 Equivalent to calling <a id="idx:workingdirectory2:1462"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>
309350 to the expansion (see
310 <a name="idx:expandfilename2:1463"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>)
351 <a id="idx:expandfilename2:1463"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>)
311352 of <code><code>~</code></code>. For compatibility only.</dd>
312353 <dt><strong>cd</strong>(<var>+Directory</var>)</dt>
313354 <dd class="defbody">
314 Equivalent to calling <a name="idx:workingdirectory2:1464"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
355 Equivalent to calling <a id="idx:workingdirectory2:1464"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
315356 Use for compatibility only.</dd>
316357 <dt><strong>argv</strong>(<var>-Argv</var>)</dt>
317358 <dd class="defbody">
329370 </dd>
330371 </dl>
331372
332 <p><h3 id="sec:winsystem"><a name="sec:4.35.1"><span class="sec-nr">4.35.1</span> <span class="sec-title">Windows-specific
373 <p><h3 id="sec:winsystem"><a id="sec:4.35.1"><span class="sec-nr">4.35.1</span> <span class="sec-title">Windows-specific
333374 Operating System Interaction</span></a></h3>
334375
335 <a name="sec:winsystem"></a>
376 <a id="sec:winsystem"></a>
336377
337378 <p>The predicates in this section are only available on the Windows
338379 version of SWI-Prolog. Their use is discouraged if there are portably
339 alternatives. For example, <a name="idx:winexec2:1465"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
340 and <a name="idx:winshell2:1466"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>
341 can often be replaced by the more portable <a name="idx:shell2:1467"></a><a class="pred" href="system.html#shell/2">shell/2</a>
380 alternatives. For example, <a id="idx:winexec2:1465"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
381 and <a id="idx:winshell2:1466"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>
382 can often be replaced by the more portable <a id="idx:shell2:1467"></a><a class="pred" href="system.html#shell/2">shell/2</a>
342383 or the more powerful
343 <a name="idx:processcreate3:1468"></a><span class="pred-ext">process_create/3</span>.
384 <a id="idx:processcreate3:1468"></a><span class="pred-ext">process_create/3</span>.
344385
345386 <dl class="latex">
346 <dt class="pubdef"><a name="win_exec/2"><strong>win_exec</strong>(<var>+Command,
387 <dt class="pubdef"><a id="win_exec/2"><strong>win_exec</strong>(<var>+Command,
347388 +Show</var>)</a></dt>
348389 <dd class="defbody">
349390 Windows only. Spawns a Windows task without waiting for its completion. <var>Show</var>
363404 <code>shownormal</code>. In addition, <code>iconic</code> is a synonym
364405 for <code>minimize</code> and
365406 <code>normal</code> for <code>shownormal</code>.</dd>
366 <dt class="pubdef"><a name="win_shell/3"><strong>win_shell</strong>(<var>+Operation,
407 <dt class="pubdef"><a id="win_shell/3"><strong>win_shell</strong>(<var>+Operation,
367408 +File, +Show</var>)</a></dt>
368409 <dd class="defbody">
369410 Windows only. Opens the document <var>File</var> using the Windows shell
370411 rules for doing so. <var>Operation</var> is one of <code>open</code>,
371412 <code>print</code> or <code>explore</code> or another operation
372413 registered with the shell for the given document type. On modern systems
373 it is also possible to pass a <a name="idx:URL:1469"></a>URL as <var>File</var>,
414 it is also possible to pass a <a id="idx:URL:1469"></a>URL as <var>File</var>,
374415 opening the URL in Windows default browser. This call interfaces to the
375416 Win32 API ShellExecute(). The <var>Show</var> argument determines the
376 initial state of the opened window (if any). See <a name="idx:winexec2:1470"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
417 initial state of the opened window (if any). See <a id="idx:winexec2:1470"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
377418 for defined values.</dd>
378 <dt class="pubdef"><a name="win_shell/2"><strong>win_shell</strong>(<var>+Operation,
419 <dt class="pubdef"><a id="win_shell/2"><strong>win_shell</strong>(<var>+Operation,
379420 +File</var>)</a></dt>
380421 <dd class="defbody">
381422 Same as <code>win_shell(Operation, File, normal)</code></dd>
382 <dt class="pubdef"><a name="win_registry_get_value/3"><strong>win_registry_get_value</strong>(<var>+Key,
423 <dt class="pubdef"><a id="win_registry_get_value/3"><strong>win_registry_get_value</strong>(<var>+Key,
383424 +Name, -Value</var>)</a></dt>
384425 <dd class="defbody">
385426 Windows only. Fetches the value of a Windows registry key. <var>Key</var>
405446 </pre>
406447
407448 </dd>
408 <dt class="pubdef"><a name="win_folder/2"><strong>win_folder</strong>(<var>?Name,
449 <dt class="pubdef"><a id="win_folder/2"><strong>win_folder</strong>(<var>?Name,
409450 -Directory</var>)</a></dt>
410451 <dd class="defbody">
411452 True if <var>Name</var> is the Windows `CSIDL' of <var>Directory</var>.
424465 </pre>
425466
426467 </dd>
427 <dt class="pubdef"><a name="win_add_dll_directory/1"><strong>win_add_dll_directory</strong>(<var>+AbsDir</var>)</a></dt>
468 <dt class="pubdef"><a id="win_add_dll_directory/1"><strong>win_add_dll_directory</strong>(<var>+AbsDir</var>)</a></dt>
428469 <dd class="defbody">
429470 This predicate adds a directory to the search path for dependent DLL
430 files. If possible, this is achieved with <a name="idx:winadddlldirectory2:1471"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
471 files. If possible, this is achieved with <a id="idx:winadddlldirectory2:1471"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
431472 Otherwise, <code>%PATH%</code> is extended with the provided directory.
432473 <var>AbsDir</var> may be specified in the Prolog canonical syntax. See
433 <a name="idx:prologtoosfilename2:1472"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.
434 Note that <a name="idx:useforeignlibrary1:1473"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
474 <a id="idx:prologtoosfilename2:1472"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.
475 Note that <a id="idx:useforeignlibrary1:1473"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
435476 passes an absolute path to the DLL if the destination DLL can be located
436 from the specification using <a name="idx:absolutefilename3:1474"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
437 <dt class="pubdef"><a name="win_add_dll_directory/2"><strong>win_add_dll_directory</strong>(<var>+AbsDir,
477 from the specification using <a id="idx:absolutefilename3:1474"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
478 <dt class="pubdef"><a id="win_add_dll_directory/2"><strong>win_add_dll_directory</strong>(<var>+AbsDir,
438479 -Cookie</var>)</a></dt>
439480 <dd class="defbody">
440481 This predicate adds a directory to the search path for dependent DLL
441482 files. If the call is successful it unifies <var>Cookie</var> with a
442 handle that must be passed to <a name="idx:winremovedlldirectory1:1475"></a><a class="pred" href="system.html#win_remove_dll_directory/1">win_remove_dll_directory/1</a>
483 handle that must be passed to <a id="idx:winremovedlldirectory1:1475"></a><a class="pred" href="system.html#win_remove_dll_directory/1">win_remove_dll_directory/1</a>
443484 to remove the directory from the search path. Error conditions:
444485
445486 <p>
453494 or the underlying Windows API returns an error.
454495 </ul>
455496
456 <p>If <a name="idx:opensharedobject2:1476"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
497 <p>If <a id="idx:opensharedobject2:1476"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
457498 is passed an <em>absolute</em> path to a DLL on a Windows installation
458499 that supports AddDllDirectory() and friends,<sup class="fn">130<span class="fn-text">Windows&nbsp;7
459500 with up-to-date patches or Windows&nbsp;8.</span></sup> SWI-Prolog uses
461502 <code>LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR</code> and
462503 <code>LOAD_LIBRARY_SEARCH_DEFAULT_DIRS</code>. In this scenario,
463504 directories from <code>%PATH%</code> and <em>not</em> searched.
464 Additional directories can be added using <a name="idx:winadddlldirectory2:1477"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.</dd>
465 <dt class="pubdef"><a name="win_remove_dll_directory/1"><strong>win_remove_dll_directory</strong>(<var>-Cookie</var>)</a></dt>
466 <dd class="defbody">
467 Remove a DLL search directory installed using <a name="idx:winadddlldirectory2:1478"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
505 Additional directories can be added using <a id="idx:winadddlldirectory2:1477"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.</dd>
506 <dt class="pubdef"><a id="win_remove_dll_directory/1"><strong>win_remove_dll_directory</strong>(<var>-Cookie</var>)</a></dt>
507 <dd class="defbody">
508 Remove a DLL search directory installed using <a id="idx:winadddlldirectory2:1478"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
468509 </dd>
469510 </dl>
470511
471 <p><h3 id="sec:timedate"><a name="sec:4.35.2"><span class="sec-nr">4.35.2</span> <span class="sec-title">Dealing
512 <p><h3 id="sec:timedate"><a id="sec:4.35.2"><span class="sec-nr">4.35.2</span> <span class="sec-title">Dealing
472513 with time and date</span></a></h3>
473514
474 <a name="sec:timedate"></a>
515 <a id="sec:timedate"></a>
475516
476517 <p>Representing time in a computer system is surprisingly complicated.
477518 There are a large number of time representations in use, and the correct
509550
510551 <p>Where older versions of SWI-Prolog relied on the POSIX conversion
511552 functions, the current implementation uses
512 http://cr.yp.to/libtai.htmllibtai to realise conversion between
513 time-stamps and calendar dates for a period of 10 million years.
514
515 <p><h4 id="sec:dattimedata"><a name="sec:4.35.2.1"><span class="sec-nr">4.35.2.1</span> <span class="sec-title">Time
553 <a class="url" href="http://cr.yp.to/libtai.html">libtai</a> to realise
554 conversion between time-stamps and calendar dates for a period of 10
555 million years.
556
557 <p><h4 id="sec:dattimedata"><a id="sec:4.35.2.1"><span class="sec-nr">4.35.2.1</span> <span class="sec-title">Time
516558 and date data structures</span></a></h4>
517559
518 <a name="sec:dattimedata"></a>
560 <a id="sec:dattimedata"></a>
519561
520562 <p>We use the following time representations
521563
531573 and minute (0..59). The <var>S</var> field holds the seconds as a
532574 floating point number between 0.0 and 60.0. <var>Off</var> is an integer
533575 representing the offset relative to UTC in seconds, where positive
534 values are west of Greenwich. If converted from local time (see <a name="idx:stampdatetime3:1479"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>),
576 values are west of Greenwich. If converted from local time (see <a id="idx:stampdatetime3:1479"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>),
535577 <var>TZ</var> holds the name of the local timezone. If the timezone is
536578 not known, <var>TZ</var> is the atom <code><code>-</code></code>. <var>DST</var>
537579 is <code>true</code> if daylight saving time applies to the current
541583 <dt><strong>date</strong>(<var>Y,M,D</var>)</dt>
542584 <dd class="defbody">
543585 Date using the same values as described above. Extracted using
544 <a name="idx:datetimevalue3:1480"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.</dd>
586 <a id="idx:datetimevalue3:1480"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.</dd>
545587 <dt><strong>time</strong>(<var>H,Mn,S</var>)</dt>
546588 <dd class="defbody">
547589 Time using the same values as described above. Extracted using
548 <a name="idx:datetimevalue3:1481"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.
590 <a id="idx:datetimevalue3:1481"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.
549591 </dd>
550592 </dl>
551593
552 <p><h4 id="sec:datimepreds"><a name="sec:4.35.2.2"><span class="sec-nr">4.35.2.2</span> <span class="sec-title">Time
594 <p><h4 id="sec:datimepreds"><a id="sec:4.35.2.2"><span class="sec-nr">4.35.2.2</span> <span class="sec-title">Time
553595 and date predicates</span></a></h4>
554596
555 <a name="sec:datimepreds"></a>
597 <a id="sec:datimepreds"></a>
556598
557599 <dl class="latex">
558 <dt class="pubdef"><a name="get_time/1"><strong>get_time</strong>(<var>-TimeStamp</var>)</a></dt>
600 <dt class="pubdef"><a id="get_time/1"><strong>get_time</strong>(<var>-TimeStamp</var>)</a></dt>
559601 <dd class="defbody">
560602 Return the current time as a <var>TimeStamp</var>. The granularity is
561 system-dependent. See <a class="sec" href="system.html">section 4.35.2.1</a>.</dd>
562 <dt class="pubdef"><a name="stamp_date_time/3"><strong>stamp_date_time</strong>(<var>+TimeStamp,
603 system-dependent. See <a class="sec" href="system.html#sec:4.35.2.1">section
604 4.35.2.1</a>.</dd>
605 <dt class="pubdef"><a id="stamp_date_time/3"><strong>stamp_date_time</strong>(<var>+TimeStamp,
563606 -DateTime, +TimeZone</var>)</a></dt>
564607 <dd class="defbody">
565608 Convert a <var>TimeStamp</var> to a <var>DateTime</var> in the given
566 timezone. See <a class="sec" href="system.html">section 4.35.2.1</a> for
567 details on the data types. <var>TimeZone</var> describes the timezone
568 for the conversion. It is one of <code>local</code> to extract the local
569 time, <code>'UTC'</code> to extract a UTC time or an integer describing
570 the seconds west of Greenwich.</dd>
571 <dt class="pubdef"><a name="date_time_stamp/2"><strong>date_time_stamp</strong>(<var>+DateTime,
609 timezone. See <a class="sec" href="system.html#sec:4.35.2.1">section
610 4.35.2.1</a> for details on the data types. <var>TimeZone</var>
611 describes the timezone for the conversion. It is one of <code>local</code>
612 to extract the local time, <code>'UTC'</code> to extract a UTC time or
613 an integer describing the seconds west of Greenwich.</dd>
614 <dt class="pubdef"><a id="date_time_stamp/2"><strong>date_time_stamp</strong>(<var>+DateTime,
572615 -TimeStamp</var>)</a></dt>
573616 <dd class="defbody">
574617 Compute the timestamp from a date/9 term. Values for month, day, hour,
575618 minute or second need not be normalized. This flexibility allows for
576619 easy computation of the time at any given number of these units from a
577 given timestamp. Normalization can be achieved following this call with <a name="idx:stampdatetime3:1482"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>.
620 given timestamp. Normalization can be achieved following this call with <a id="idx:stampdatetime3:1482"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>.
578621 This example computes the date 200 days after 2006-7-14:
579622
580623 <pre class="code">
617660 <p>Note that DST and offset calculation are based on the POSIX function
618661 mktime(). If mktime() returns an error, a representation_error
619662 <code>dst</code> is generated.</dd>
620 <dt class="pubdef"><a name="date_time_value/3"><strong>date_time_value</strong>(<var>?Key,
663 <dt class="pubdef"><a id="date_time_value/3"><strong>date_time_value</strong>(<var>?Key,
621664 +DateTime, ?Value</var>)</a></dt>
622665 <dd class="defbody">
623666 Extract values from a date/9 term. Provided keys are:
624667
625 <p><table border="2" frame="hsides" rules="groups" style="margin:auto">
626 <tr valign="top"><td><b>key</b></td><td><b>value </b></td></tr>
627 <tbody>
628 <tr valign="top"><td><code>year</code> </td><td>Calendar year as an
668 <p><table class="latex frame-hsides center">
669 <tr><td><b>key</b></td><td><b>value </b></td></tr>
670 <tr class="hline"><td><code>year</code> </td><td>Calendar year as an
629671 integer </td></tr>
630 <tr valign="top"><td><code>month</code> </td><td>Calendar month as an
631 integer 1..12 </td></tr>
632 <tr valign="top"><td><code>day</code> </td><td>Calendar day as an
633 integer 1..31 </td></tr>
634 <tr valign="top"><td><code>hour</code> </td><td>Clock hour as an integer
635 0..23 </td></tr>
636 <tr valign="top"><td><code>minute</code> </td><td>Clock minute as an
637 integer 0..59 </td></tr>
638 <tr valign="top"><td><code>second</code> </td><td>Clock second as a
639 float 0.0..60.0 </td></tr>
640 <tr valign="top"><td><code>utc_offset</code> </td><td>Offset to UTC in
641 seconds (positive is west) </td></tr>
642 <tr valign="top"><td><code>time_zone</code> </td><td>Name of timezone;
643 fails if unknown </td></tr>
644 <tr valign="top"><td><code>daylight_saving</code> </td><td>Bool <code>daylight_saving</code>true)
672 <tr><td><code>month</code> </td><td>Calendar month as an integer 1..12 </td></tr>
673 <tr><td><code>day</code> </td><td>Calendar day as an integer 1..31 </td></tr>
674 <tr><td><code>hour</code> </td><td>Clock hour as an integer 0..23 </td></tr>
675 <tr><td><code>minute</code> </td><td>Clock minute as an integer 0..59 </td></tr>
676 <tr><td><code>second</code> </td><td>Clock second as a float 0.0..60.0 </td></tr>
677 <tr><td><code>utc_offset</code> </td><td>Offset to UTC in seconds
678 (positive is west) </td></tr>
679 <tr><td><code>time_zone</code> </td><td>Name of timezone; fails if
680 unknown </td></tr>
681 <tr><td><code>daylight_saving</code> </td><td>Bool <code>daylight_saving</code>true)
645682 if dst is in effect </td></tr>
646 <tr valign="top"><td><code>date</code> </td><td>Term <code>date(Y,M,D)</code> </td></tr>
647 <tr valign="top"><td><code>time</code> </td><td>Term <code>time(H,M,S)</code> </td></tr>
683 <tr><td><code>date</code> </td><td>Term <code>date(Y,M,D)</code> </td></tr>
684 <tr><td><code>time</code> </td><td>Term <code>time(H,M,S)</code> </td></tr>
648685 </table>
649686 </dd>
650 <dt class="pubdef"><a name="format_time/3"><strong>format_time</strong>(<var>+Out,
687 <dt class="pubdef"><a id="format_time/3"><strong>format_time</strong>(<var>+Out,
651688 +Format, +StampOrDateTime</var>)</a></dt>
652689 <dd class="defbody">
653690 Modelled after POSIX strftime(), using GNU extensions. <var>Out</var> is
654 a destination as specified with <a name="idx:withoutputto2:1483"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>. <var>Format</var>
691 a destination as specified with <a id="idx:withoutputto2:1483"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>. <var>Format</var>
655692 is an atom or string with the following conversions. Conversions start
656693 with a percent (%) character.<sup class="fn">132<span class="fn-text">Descriptions
657694 taken from Linux Programmer's Manual</span></sup>
662699 <ul class="latex">
663700 <li><code>a</code><br>
664701 The abbreviated weekday name according to the current locale. Use
665 <a name="idx:formattime4:1484"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
702 <a id="idx:formattime4:1484"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
666703 for POSIX locale.
667704 <li><code>A</code><br>
668705 The full weekday name according to the current locale. Use
669 <a name="idx:formattime4:1485"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
706 <a id="idx:formattime4:1485"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
670707 for POSIX locale.
671708 <li><code>b</code><br>
672709 The abbreviated month name according to the current locale. Use
673 <a name="idx:formattime4:1486"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
710 <a id="idx:formattime4:1486"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
674711 for POSIX locale.
675712 <li><code>B</code><br>
676713 The full month name according to the current locale. Use
677 <a name="idx:formattime4:1487"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
714 <a id="idx:formattime4:1487"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
678715 for POSIX locale.
679716 <li><code>c</code><br>
680717 The preferred date and time representation for the current locale.
797834
798835 <p>The table below gives some format strings for popular time
799836 representations. RFC1123 is used by HTTP. The full implementation of
800 <a name="idx:httptimestamp2:1488"></a><span class="pred-ext">http_timestamp/2</span>
837 <a id="idx:httptimestamp2:1488"></a><span class="pred-ext">http_timestamp/2</span>
801838 as available from <code>library(http/http_header)</code> is here.
802839
803840 <pre class="code">
808845 Date, posix).
809846 </pre>
810847
811 <p><table border="2" frame="hsides" rules="groups" style="margin:auto">
812 <tr valign="top"><td><b>Standard</b> </td><td><b>Format string</b> </td></tr>
813 <tbody>
814 <tr valign="top"><td><b>xsd</b> </td><td><code>'%FT%T%:z'</code> </td></tr>
815 <tr valign="top"><td><b>ISO8601</b> </td><td><code>'%FT%T%z'</code> </td></tr>
816 <tr valign="top"><td><b>RFC822</b> </td><td><code>'%a, %d %b %Y %T %z'</code> </td></tr>
817 <tr valign="top"><td><b>RFC1123</b> </td><td><code>'%a, %d %b %Y %T GMT'</code> </td></tr>
848 <p><table class="latex frame-hsides center">
849 <tr><td><b>Standard</b> </td><td><b>Format string</b> </td></tr>
850 <tr class="hline"><td><b>xsd</b> </td><td><code>'%FT%T%:z'</code> </td></tr>
851 <tr><td><b>ISO8601</b> </td><td><code>'%FT%T%z'</code> </td></tr>
852 <tr><td><b>RFC822</b> </td><td><code>'%a, %d %b %Y %T %z'</code> </td></tr>
853 <tr><td><b>RFC1123</b> </td><td><code>'%a, %d %b %Y %T GMT'</code> </td></tr>
818854 </table>
819855 </dd>
820 <dt class="pubdef"><a name="format_time/4"><strong>format_time</strong>(<var>+Out,
856 <dt class="pubdef"><a id="format_time/4"><strong>format_time</strong>(<var>+Out,
821857 +Format, +StampOrDateTime, +Locale</var>)</a></dt>
822858 <dd class="defbody">
823859 Format time given a specified <var>Locale</var>. This predicate is a
828864 and <code>B</code> format specifiers. The predicate is used to be able
829865 to emit POSIX locale week and month names for emitting standardised
830866 time-stamps such as RFC1123.</dd>
831 <dt class="pubdef"><a name="parse_time/2"><strong>parse_time</strong>(<var>+Text,
867 <dt class="pubdef"><a id="parse_time/2"><strong>parse_time</strong>(<var>+Text,
832868 -Stamp</var>)</a></dt>
833869 <dd class="defbody">
834 Same as <code>parse_time(Text, _Format, Stamp)</code>. See <a name="idx:parsetime3:1489"></a><a class="pred" href="system.html#parse_time/3">parse_time/3</a>.</dd>
835 <dt class="pubdef"><a name="parse_time/3"><strong>parse_time</strong>(<var>+Text,
870 Same as <code>parse_time(Text, _Format, Stamp)</code>. See <a id="idx:parsetime3:1489"></a><a class="pred" href="system.html#parse_time/3">parse_time/3</a>.</dd>
871 <dt class="pubdef"><a id="parse_time/3"><strong>parse_time</strong>(<var>+Text,
836872 ?Format, -Stamp</var>)</a></dt>
837873 <dd class="defbody">
838874 Parse a textual time representation, producing a time-stamp. Supported
841877 Otherwise,
842878 <var>Format</var> is unified with the format encountered.
843879
844 <p><table border="2" frame="box" rules="groups" style="margin:auto">
845 <tr valign="top"><td><b>Name</b></td><td><b>Example </b></td></tr>
846 <tbody>
847 <tr valign="top"><td>rfc_1123</td><td><code>Fri, 08 Dec 2006 15:29:44
880 <p><table class="latex frame-box center">
881 <tr><td><b>Name</b></td><td><b>Example </b></td></tr>
882 <tr class="hline"><td>rfc_1123</td><td><code>Fri, 08 Dec 2006 15:29:44
848883 GMT </code></td></tr>
849 <tr valign="top"><td></td><td><code>Fri, 08 Dec 2006 15:29:44 +0000 </code></td></tr>
850 <tbody>
851 <tr valign="top"><td>iso_8601</td><td><code>2006-12-08T17:29:44+02:00 </code></td></tr>
852 <tr valign="top"><td></td><td><code>20061208T172944+0200 </code></td></tr>
853 <tr valign="top"><td></td><td><code>2006-12-08T15:29Z </code></td></tr>
854 <tr valign="top"><td></td><td><code>2006-12-08 </code></td></tr>
855 <tr valign="top"><td></td><td><code>20061208 </code></td></tr>
856 <tr valign="top"><td></td><td><code>2006-12 </code></td></tr>
857 <tr valign="top"><td></td><td><code>2006-W49-5 </code></td></tr>
858 <tr valign="top"><td></td><td><code>2006-342 </code></td></tr>
884 <tr><td></td><td><code>Fri, 08 Dec 2006 15:29:44 +0000 </code></td></tr>
885 <tr class="hline"><td>iso_8601</td><td><code>2006-12-08T17:29:44+02:00 </code></td></tr>
886 <tr><td></td><td><code>20061208T172944+0200 </code></td></tr>
887 <tr><td></td><td><code>2006-12-08T15:29Z </code></td></tr>
888 <tr><td></td><td><code>2006-12-08 </code></td></tr>
889 <tr><td></td><td><code>20061208 </code></td></tr>
890 <tr><td></td><td><code>2006-12 </code></td></tr>
891 <tr><td></td><td><code>2006-W49-5 </code></td></tr>
892 <tr><td></td><td><code>2006-342 </code></td></tr>
859893 </table>
860894 </dd>
861 <dt class="pubdef"><a name="day_of_the_week/2"><strong>day_of_the_week</strong>(<var>+Date,-DayOfTheWeek</var>)</a></dt>
895 <dt class="pubdef"><a id="day_of_the_week/2"><strong>day_of_the_week</strong>(<var>+Date,-DayOfTheWeek</var>)</a></dt>
862896 <dd class="defbody">
863897 Computes the day of the week for a given date.
864898 <code><var>Date</var> = date(<var>Year</var>,<var>Month</var>,<var>Day</var>)</code>.
867901 </dd>
868902 </dl>
869903
870 <p><h3 id="sec:plwin"><a name="sec:4.35.3"><span class="sec-nr">4.35.3</span> <span class="sec-title">Controlling
904 <p><h3 id="sec:plwin"><a id="sec:4.35.3"><span class="sec-nr">4.35.3</span> <span class="sec-title">Controlling
871905 the <b>swipl-win.exe</b> console window</span></a></h3>
872906
873 <a name="sec:plwin"></a>
907 <a id="sec:plwin"></a>
874908
875909 <p>The Windows executable <b>swipl-win.exe</b> console has a number of
876910 predicates to control the appearance of the console. Being totally
879913 predicates for reference here.
880914
881915 <dl class="latex">
882 <dt class="pubdef"><a name="window_title/2"><strong>window_title</strong>(<var>-Old,
916 <dt class="pubdef"><a id="window_title/2"><strong>window_title</strong>(<var>-Old,
883917 +New</var>)</a></dt>
884918 <dd class="defbody">
885919 Unify <var>Old</var> with the title displayed in the console and change
886920 the title to <var>New</var>.<sup class="fn">bug<span class="fn-text">This
887921 predicate should have been called <code>win_window_title</code> for
888922 consistent naming.</span></sup></dd>
889 <dt class="pubdef"><a name="win_window_pos/1"><strong>win_window_pos</strong>(<var>+ListOfOptions</var>)</a></dt>
923 <dt class="pubdef"><a id="win_window_pos/1"><strong>win_window_pos</strong>(<var>+ListOfOptions</var>)</a></dt>
890924 <dd class="defbody">
891925 Interface to the MS-Windows SetWindowPos() function, controlling size,
892926 position and stacking order of the window. <var>ListOfOptions</var> is a
921955 </dl>
922956
923957 </dd>
924 <dt class="pubdef"><a name="win_has_menu/0"><strong>win_has_menu</strong></a></dt>
925 <dd class="defbody">
926 True if <a name="idx:wininsertmenu2:1490"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>
927 and <a name="idx:wininsertmenuitem4:1491"></a><a class="pred" href="system.html#win_insert_menu_item/4">win_insert_menu_item/4</a>
958 <dt class="pubdef"><a id="win_has_menu/0"><strong>win_has_menu</strong></a></dt>
959 <dd class="defbody">
960 True if <a id="idx:wininsertmenu2:1490"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>
961 and <a id="idx:wininsertmenuitem4:1491"></a><a class="pred" href="system.html#win_insert_menu_item/4">win_insert_menu_item/4</a>
928962 are present.</dd>
929 <dt class="pubdef"><a name="win_insert_menu/2"><strong>win_insert_menu</strong>(<var>+Label,
963 <dt class="pubdef"><a id="win_insert_menu/2"><strong>win_insert_menu</strong>(<var>+Label,
930964 +Before</var>)</a></dt>
931965 <dd class="defbody">
932966 Insert a new entry (pulldown) in the menu. If the menu already contains
942976 </pre>
943977
944978 </dd>
945 <dt class="pubdef"><a name="win_insert_menu_item/4"><strong>win_insert_menu_item</strong>(<var>+Pulldown,
979 <dt class="pubdef"><a id="win_insert_menu_item/4"><strong>win_insert_menu_item</strong>(<var>+Pulldown,
946980 +Label, +Before, :Goal</var>)</a></dt>
947981 <dd class="defbody">
948982 Add an item to the named <var>Pulldown</var> menu. <var>Label</var> and
949 <var>Before</var> are handled as in <a name="idx:wininsertmenu2:1492"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>,
983 <var>Before</var> are handled as in <a id="idx:wininsertmenu2:1492"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>,
950984 but the label <code><code>-</code></code> inserts a <em>separator</em>. <var>Goal</var>
951985 is called if the user selects the item.
952986 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.35</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.35</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="solutionsequences.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="threadpool.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:tabling"><a name="sec:A.35"><span class="sec-nr">A.35</span> <span class="sec-title">library(tabling):
235 <h2 id="sec:tabling"><a id="sec:A.35"><span class="sec-nr">A.35</span> <span class="sec-title">library(tabling):
195236 Tabled execution (SLG)</span></a></h2>
196237
197 <a name="sec:tabling"></a>
198
199 <p><a name="idx:SLGresolution:2171"></a>The library <code>library(tabling)</code>
238 <a id="sec:tabling"></a>
239
240 <p><a id="idx:SLGresolution:2175"></a>The library <code>library(tabling)</code>
200241 provides support for <em>Tabled execution</em> of one or more Prolog
201242 predicates, also called <em>SLG resolution</em>. Tabling a predicate
202243 provides two properties:
206247 <li>Re-evaluation of a tabled predicate is avoided by
207248 <em>memoizing</em> the answers. This can realise huge performance
208249 enhancements as illustrated in
209 <a class="sec" href="tabling.html">section A.35.1</a>. It also comes
210 with two downsides: the memoized answers are not automatically updated
211 or invalidated if the world (set of predicates on which the answers
212 depend) changes and the answer tables must be stored (in memory).
250 <a class="sec" href="tabling.html#sec:A.35.1">section A.35.1</a>. It
251 also comes with two downsides: the memoized answers are not
252 automatically updated or invalidated if the world (set of predicates on
253 which the answers depend) changes and the answer tables must be stored
254 (in memory).
213255
214256 <p>
215257 <li><em>Left recursion</em>, a goal calling a <em>variant</em> of itself
216258 recursively and thus <i>looping</i> under the normal Prolog SLD
217259 resolution is avoided by suspending the variant call and resuming it
218 with answers from the table. This is illustrated in <a class="sec" href="tabling.html">section
260 with answers from the table. This is illustrated in <a class="sec" href="tabling.html#sec:A.35.2">section
219261 A.35.2</a>.
220262 </ol>
221263
227269 evaluation, i.e., applying rules on the axioms and derived facts until a
228270 fixed point is reached. However, bottom-up evaluation typically derives
229271 many facts that are never used. Tabling provides a <em>goal oriented</em>
230 resolution strategy for such problems and is enabled simply by adding a <a name="idx:table1:2172"></a><a class="pred" href="tabling.html#table/1">table/1</a>
272 resolution strategy for such problems and is enabled simply by adding a <a id="idx:table1:2176"></a><a class="pred" href="tabling.html#table/1">table/1</a>
231273 directive to the program.
232274
233 <p><h4 id="sec:tabling-memoize"><a name="sec:A.35.1"><span class="sec-nr">A.35.1</span> <span class="sec-title">Example
275 <p><h4 id="sec:tabling-memoize"><a id="sec:A.35.1"><span class="sec-nr">A.35.1</span> <span class="sec-title">Example
234276 1: using tabling for memoizing</span></a></h4>
235277
236 <a name="sec:tabling-memoize"></a>
278 <a id="sec:tabling-memoize"></a>
237279
238280 <p>As a first classical example we use tabling for <em>memoizing</em>
239281 intermediate results. We use Fibonacci numbers to illustrate the
318360 fib(F1, F2, I2, N, F).
319361 </pre>
320362
321 <p><h4 id="sec:tabling-non-termination"><a name="sec:A.35.2"><span class="sec-nr">A.35.2</span> <span class="sec-title">Example
363 <p><h4 id="sec:tabling-non-termination"><a id="sec:A.35.2"><span class="sec-nr">A.35.2</span> <span class="sec-title">Example
322364 2: avoiding non-termination</span></a></h4>
323365
324 <a name="sec:tabling-non-termination"></a>
366 <a id="sec:tabling-non-termination"></a>
325367
326368 <p>SLD resolution easily results in an infinite loop due to <em>left
327369 recursion</em>, a goal that (indirectly) calls a variant of itself or
370412 X = 'Leiden'.
371413 </pre>
372414
373 <p>Again, the fact that a simple <a name="idx:table1:2173"></a><a class="pred" href="tabling.html#table/1">table/1</a>
415 <p>Again, the fact that a simple <a id="idx:table1:2177"></a><a class="pred" href="tabling.html#table/1">table/1</a>
374416 directive turns the pure logical specification into a fairly efficient
375417 algorithm is a clear advantage. Without tabling the program needs to be <em>stratified</em>,
376418 introducing a base layer with the raw connections, a second layer that
386428 and does not need to deal with maintaining consistency between the
387429 tables and ground facts.
388430
389 <p><h4 id="sec:tabling-mode-directed"><a name="sec:A.35.3"><span class="sec-nr">A.35.3</span> <span class="sec-title">Mode
431 <p><h4 id="sec:tabling-mode-directed"><a id="sec:A.35.3"><span class="sec-nr">A.35.3</span> <span class="sec-title">Mode
390432 directed tabling</span></a></h4>
391433
392 <a name="sec:tabling-mode-directed"></a>
393
394 <p><a name="idx:answersubsumptiontabling:2174"></a>Tabling as defined
434 <a id="sec:tabling-mode-directed"></a>
435
436 <p><a id="idx:answersubsumptiontabling:2178"></a>Tabling as defined
395437 above has a serious limitation. Although the definition of connection/2
396438 from section
397 <a class="sec" href="tabling.html">section A.35.2</a> can compute the
398 transitive closure of connected cities, it cannot provide you with a
399 route to travel. The reason is that there are infinitely many routes if
400 there are cycles in the network and each new route found will be added
401 to the answer table and cause the tabled execution's completion
439 <a class="sec" href="tabling.html#sec:A.35.2">section A.35.2</a> can
440 compute the transitive closure of connected cities, it cannot provide
441 you with a route to travel. The reason is that there are infinitely many
442 routes if there are cycles in the network and each new route found will
443 be added to the answer table and cause the tabled execution's completion
402444 algorithm to search for more routes, eventually running out of memory.
403445
404446 <p>The solution to this problem is called <em>mode directed tabling</em>
405447 or
406 <em>answer subsumption</em>.<sup class="fn">183<span class="fn-text">The
448 <em>answer subsumption</em>.<sup class="fn">184<span class="fn-text">The
407449 term <em>answer subsumption</em> is used by XSB and <em>mode directed
408450 tabling</em> by YAP and B-Prolog. The idea is that some arguments are
409451 considered `outputs', where multiple values for the same `input' are
411453 name.</span></sup> In this execution model one or more arguments are <em>not</em>
412454 added to the table. Instead, we remember a single <em>aggregated</em>
413455 value for these arguments. The example below is derived from
414 <a class="sec" href="tabling.html">section A.35.2</a> and returns the
415 connection as a list of cities. This argument is defined as a <em>moded</em>
416 argument using the
417 <code>lattice(PI)</code> mode.<sup class="fn">184<span class="fn-text">This
456 <a class="sec" href="tabling.html#sec:A.35.2">section A.35.2</a> and
457 returns the connection as a list of cities. This argument is defined as
458 a <em>moded</em> argument using the
459 <code>lattice(PI)</code> mode.<sup class="fn">185<span class="fn-text">This
418460 mode is compatible to XSB Prolog.</span></sup> This causes the tabling
419461 engine each time that it finds an new path to call shortest/3 and keep
420462 the shortest route.
493535 </dd>
494536 </dl>
495537
496 <p><h3 id="sec:tabling-memoize"><a name="sec:A.35.1"><span class="sec-nr">A.35.1</span> <span class="sec-title">Tabling
538 <p><h3 id="sec:tabling-memoize"><a id="sec:A.35.1"><span class="sec-nr">A.35.1</span> <span class="sec-title">Tabling
497539 predicate reference</span></a></h3>
498540
499541 <dl class="latex">
500 <dt class="pubdef"><a name="table/1"><strong>table</strong> <var>+PredicateIndicators</var></a></dt>
542 <dt class="pubdef"><a id="table/1"><strong>table</strong> <var>+PredicateIndicators</var></a></dt>
501543 <dd class="defbody">
502544 Prepare the given <var>PredicateIndicators</var> for tabling. Can only
503545 be used as a directive. The example below prepares the predicate
504 <span class="pred-ext">edge/2</span> and the non-terminal <span class="pred-ext">statement/3</span>
546 <span class="pred-ext">edge/2</span> and the non-terminal <span class="pred-ext">statement//1</span>
505547 for tabled execution.
506548
507549 <pre class="code">
518560
519561 <p><i>Mode directed tabling</i> is discussed in the general introduction
520562 section about tabling.</dd>
521 <dt class="pubdef"><a name="abolish_all_tables/0"><strong>abolish_all_tables</strong></a></dt>
563 <dt class="pubdef"><a id="abolish_all_tables/0"><strong>abolish_all_tables</strong></a></dt>
522564 <dd class="defbody">
523565 Remove all tables. This is normally used to free up the space or
524566 recompute the result after predicates on which the result for some
533575 </dl>
534576
535577 </dd>
536 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="abolish_table_subgoals/1"><strong>abolish_table_subgoals</strong>(<var>:Subgoal</var>)</a></dt>
578 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="abolish_table_subgoals/1"><strong>abolish_table_subgoals</strong>(<var>:Subgoal</var>)</a></dt>
537579 <dd class="defbody">
538580 Abolish all tables that unify with SubGoal.
539581 </dd>
540582 </dl>
541583
542 <p><h4 id="sec:tabling-about"><a name="sec:A.35.1.1"><span class="sec-nr">A.35.1.1</span> <span class="sec-title">About
584 <p><h4 id="sec:tabling-about"><a id="sec:A.35.1.1"><span class="sec-nr">A.35.1.1</span> <span class="sec-title">About
543585 the tabling implementation</span></a></h4>
544586
545 <a name="sec:tabling-about"></a>
587 <a id="sec:tabling-about"></a>
546588
547589 <p>The SWI-Prolog implementation uses <em>Delimited continuations</em>
548590 (see
549 <a class="sec" href="delcont.html">section 4.10</a> to realise
591 <a class="sec" href="delcont.html#sec:4.10">section 4.10</a> to realise
550592 suspension of variant calls. The initial version was written by Benoit
551593 Desouter and described in
552594 <cite><a class="cite" href="Bibliography.html#DBLP:journals/tplp/DesouterDS15">Desouter <em>et
553595 al.</em>, 2015</a></cite>. We moved the main data structures required
554596 for tabling, the <em>answer tables</em> (see
555 <a class="sec" href="db.html">section 4.14.4</a>) and the <em>worklist</em>
597 <a class="sec" href="db.html#sec:4.14.4">section 4.14.4</a>) and the <em>worklist</em>
556598 to SWI-Prolog's C&nbsp;core.
557 <em>Mode directed tabling</em> (<a class="sec" href="tabling.html">section
599 <em>Mode directed tabling</em> (<a class="sec" href="tabling.html#sec:A.35.3">section
558600 A.35.3</a>) is based on a prototype implementation by Fabrizio Riguzzi.
559601
560 <p>The <a name="idx:table1:2175"></a><a class="pred" href="tabling.html#table/1">table/1</a>
602 <p>The <a id="idx:table1:2179"></a><a class="pred" href="tabling.html#table/1">table/1</a>
561603 directive causes the creation of a wrapper calling the renamed original
562604 predicate. For example, the program in
563 <a class="sec" href="tabling.html">section A.35.2</a> is translated into
564 the following program. We give this information to improve your
565 understanding of the current tabling implementation. Future versions are
566 likely to use a more low-level translation that is not based on
567 wrappers.
605 <a class="sec" href="tabling.html#sec:A.35.2">section A.35.2</a> is
606 translated into the following program. We give this information to
607 improve your understanding of the current tabling implementation. Future
608 versions are likely to use a more low-level translation that is not
609 based on wrappers.
568610
569611 <pre class="code">
570612 connection(A, B) :-
583625 'connection tabled'('Haarlem', 'Leiden').
584626 </pre>
585627
586 <p><h4 id="sec:tabling-status"><a name="sec:A.35.1.2"><span class="sec-nr">A.35.1.2</span> <span class="sec-title">Status
628 <p><h4 id="sec:tabling-status"><a id="sec:A.35.1.2"><span class="sec-nr">A.35.1.2</span> <span class="sec-title">Status
587629 of tabling</span></a></h4>
588630
589 <a name="sec:tabling-status"></a>
631 <a id="sec:tabling-status"></a>
590632
591633 <p>The current implementation is merely a first prototype. It needs
592634 several enhancements before we can consider it a serious competitor to
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.20</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.20</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="chario.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="manipterm.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:termrw"><a name="sec:4.20"><span class="sec-nr">4.20</span> <span class="sec-title">Term
235 <h2 id="sec:termrw"><a id="sec:4.20"><span class="sec-nr">4.20</span> <span class="sec-title">Term
195236 reading and writing</span></a></h2>
196237
197 <a name="sec:termrw"></a>
238 <a id="sec:termrw"></a>
198239
199240 <p>This section describes the basic term reading and writing predicates.
200 The predicates <a name="idx:format12:1114"></a><a class="pred" href="format.html#format/1">format/[1,2]</a>
201 and <a name="idx:writef2:1115"></a><a class="pred" href="format.html#writef/2">writef/2</a>
241 The predicates <a id="idx:format12:1114"></a><a class="pred" href="format.html#format/1">format/[1,2]</a>
242 and <a id="idx:writef2:1115"></a><a class="pred" href="format.html#writef/2">writef/2</a>
202243 provide formatted output. Writing to Prolog data structures such as
203 atoms or code-lists is supported by <a name="idx:withoutputto2:1116"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
204 and <a name="idx:format3:1117"></a><a class="pred" href="format.html#format/3">format/3</a>.
244 atoms or code-lists is supported by <a id="idx:withoutputto2:1116"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
245 and <a id="idx:format3:1117"></a><a class="pred" href="format.html#format/3">format/3</a>.
205246
206247 <p>Reading is sensitive to the Prolog flag <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>,
207248 which controls the interpretation of the <code><code>\</code></code>
208249 character in quoted atoms and strings.
209250
210251 <dl class="latex">
211 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_term/2"><strong>write_term</strong>(<var>+Term,
252 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_term/2"><strong>write_term</strong>(<var>+Term,
212253 +Options</var>)</a></dt>
213254 <dd class="defbody">
214 The predicate <a name="idx:writeterm2:1118"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
255 The predicate <a id="idx:writeterm2:1118"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
215256 is the generic form of all Prolog term-write predicates. Valid options
216257 are:
217258
218259 <dl class="latex">
219260 <dt><strong>attributes</strong>(<var>Atom</var>)</dt>
220261 <dd class="defbody">
221 Define how attributed variables (see <a class="sec" href="attvar.html">section
262 Define how attributed variables (see <a class="sec" href="attvar.html#sec:7.1">section
222263 7.1</a>) are written. The default is determined by the Prolog flag <a class="flag" href="flags.html#flag:write_attributes">write_attributes</a>.
223264 Defined values are <code>ignore</code> (ignore the attribute), <code>dots</code>
224265 (write the attributes as <code>{...}</code>), <code>write</code> (simply
225 hand the attributes recursively to <a name="idx:writeterm2:1119"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>)
226 and <code>portray</code> (hand the attributes to <a name="idx:attrportrayhook2:1120"></a><a class="pred" href="attvar.html#attr_portray_hook/2">attr_portray_hook/2</a>).</dd>
266 hand the attributes recursively to <a id="idx:writeterm2:1119"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>)
267 and <code>portray</code> (hand the attributes to <a id="idx:attrportrayhook2:1120"></a><a class="pred" href="attvar.html#attr_portray_hook/2">attr_portray_hook/2</a>).</dd>
227268 <dt><strong>back_quotes</strong>(<var>Atom</var>)</dt>
228269 <dd class="defbody">
229270 Fulfills the same role as the <a class="flag" href="flags.html#flag:back_quotes">back_quotes</a>
240281 <dd class="defbody">
241282 Define how non-text blobs are handled. By default, this is left to the
242283 write handler specified with the blob type. Using <code>portray</code>,
243 <a name="idx:portray1:1121"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
244 is called for each blob encountered. See <a class="sec" href="foreigninclude.html">section
284 <a id="idx:portray1:1121"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
285 is called for each blob encountered. See <a class="sec" href="foreigninclude.html#sec:11.4.7">section
245286 11.4.7</a>.</dd>
246287 <dt><strong>character_escapes</strong>(<var>Bool</var>)</dt>
247288 <dd class="defbody">
254295 <code>@(Template, Substitutions)</code>, where <var>Substitutions</var>
255296 is a list
256297 <var>Var</var> = <var>Value</var>. If <code>cycles</code> is <code>false</code>,
257 <code>max_depth</code> is not given, and <var>Term</var> is cyclic, <a name="idx:writeterm2:1122"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
298 <code>max_depth</code> is not given, and <var>Term</var> is cyclic, <a id="idx:writeterm2:1122"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
258299 raises a <code>domain_error</code>.<sup class="fn">92<span class="fn-text">The
259300 cycles option and the cyclic term representation using the @-term are
260301 copied from SICStus Prolog. However, the default in SICStus is set to <code>false</code>
261302 and SICStus writes an infinite term if not protected by, e.g., the <code>depth_limit</code>
262303 option.</span></sup> See also the <code>cycles</code> option in
263 <a name="idx:readterm2:1123"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.</dd>
304 <a id="idx:readterm2:1123"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.</dd>
264305 <dt><strong>dotlists</strong>(<var>Bool</var>)</dt>
265306 <dd class="defbody">
266307 If <code>true</code> (default <code>false</code>), write lists using the
267308 dotted term notation rather than the list notation.<sup class="fn">93<span class="fn-text">Copied
268309 from ECLiPSe.</span></sup> Note that as of version&nbsp;7, the list
269310 constructor is
270 <code>'[|]'</code>. Using <code>dotlists(true)</code>, <a name="idx:writeterm2:1124"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
311 <code>'[|]'</code>. Using <code>dotlists(true)</code>, <a id="idx:writeterm2:1124"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
271312 writes a list using `.' as constructor. This is intended for
272313 communication with programs such as other Prolog systems, that rely on
273314 this notation.</dd>
276317 If <code>true</code> (default <code>false</code>), add a fullstop token
277318 to the output. The dot is preceeded by a space if needed and followed by
278319 a space (default) or newline if the <code>nl(true)</code> option is also
279 given.<sup class="fn">94<span class="fn-text">Compatible with http://eclipseclp.org/doc/bips/kernel/ioterm/write_term-3.htmlECLiPSe</span></sup></dd>
320 given.<sup class="fn">94<span class="fn-text">Compatible with <a class="url" href="http://eclipseclp.org/doc/bips/kernel/ioterm/write_term-3.html">ECLiPSe</a></span></sup></dd>
280321 <dt><strong>ignore_ops</strong>(<var>Bool</var>)</dt>
281322 <dd class="defbody">
282323 If <code>true</code>, the generic term representation (&lt;<var>functor</var>&gt;(&lt;<var>args</var>&gt;
307348 <dd class="defbody">
308349 Define the reference module (default <code>user</code>). This defines
309350 the default value for the <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
310 option as well as the operator definitions to use. See also <a name="idx:op3:1125"></a><a class="pred" href="operators.html#op/3">op/3</a>.</dd>
351 option as well as the operator definitions to use. See also <a id="idx:op3:1125"></a><a class="pred" href="operators.html#op/3">op/3</a>.</dd>
311352 <dt><strong>nl</strong>(<var>Bool</var>)</dt>
312353 <dd class="defbody">
313354 Add a newline to the output. See also the <code>fullstop</code> option.</dd>
317358 is a non-negative integer, will be written as a variable name. If <var>N</var>
318359 is an atom it is written without quotes. This extension allows for
319360 writing variables with user-provided names. The default is <code>false</code>.
320 See also <a name="idx:numbervars3:1126"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
361 See also <a id="idx:numbervars3:1126"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
321362 and the option <code>variable_names</code>.</dd>
322363 <dt><strong>partial</strong>(<var>Bool</var>)</dt>
323364 <dd class="defbody">
326367 is intended to solve the problems with the code below. Calling <code>write_value(<code>.</code>)</code>
327368 writes <code>..</code>, which cannot be read. By adding <code>partial(true)</code>
328369 to the option list, it correctly emits <code>. .</code>. Similar
329 problems appear when emitting operators using multiple calls to <a name="idx:writeterm3:1127"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
370 problems appear when emitting operators using multiple calls to <a id="idx:writeterm3:1127"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
330371
331372 <pre class="code">
332373 write_value(Value) :-
341382 <dt><strong>portray_goal</strong>(<var>:Goal</var>)</dt>
342383 <dd class="defbody">
343384 Implies <code>portray(true)</code>, but calls <var>Goal</var> rather
344 than the predefined hook <a name="idx:portray1:1128"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>. <var>Goal</var>
345 is called through <a name="idx:call3:1129"></a><span class="pred-ext">call/3</span>,
385 than the predefined hook <a id="idx:portray1:1128"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>. <var>Goal</var>
386 is called through <a id="idx:call3:1129"></a><span class="pred-ext">call/3</span>,
346387 where the first argument is <var>Goal</var>, the second is the term to
347388 be printed and the 3rd argument is the current write option list. The
348389 write option list is copied from the write_term call, but the list is
350391 current priority.</dd>
351392 <dt><strong>portrayed</strong>(<var>Bool</var>)</dt>
352393 <dd class="defbody">
353 If <code>true</code>, the hook <a name="idx:portray1:1130"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
354 is called before printing a term that is not a variable. If <a name="idx:portray1:1131"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
355 succeeds, the term is considered printed. See also <a name="idx:print1:1132"></a><a class="pred" href="termrw.html#print/1">print/1</a>.
394 If <code>true</code>, the hook <a id="idx:portray1:1130"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
395 is called before printing a term that is not a variable. If <a id="idx:portray1:1131"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
396 succeeds, the term is considered printed. See also <a id="idx:print1:1132"></a><a class="pred" href="termrw.html#print/1">print/1</a>.
356397 The default is <code>false</code>. This option is an extension to the
357398 ISO write_term options.</dd>
358399 <dt><strong>priority</strong>(<var>Integer</var>)</dt>
375416 <dd class="defbody">
376417 Determines whether and where extra white space is added to enhance
377418 readability. The default is <code>standard</code>, adding only space
378 where needed for proper tokenization by <a name="idx:readterm3:1133"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
419 where needed for proper tokenization by <a id="idx:readterm3:1133"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
379420 Currently, the only other value is <code>next_argument</code>, adding a
380421 space after a comma used to separate arguments in a term or list.</dd>
381422 <dt><strong>variable_names</strong>(<var>+List</var>)</dt>
391432 <var>Name</var> does not represent a valid Prolog variable name.
392433
393434 <p>The implementation binds the variables from <var>List</var> to a term
394 <code>'$VAR'</code>(<var>Name</var>). Like <a name="idx:writecanonical1:1134"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>,
435 <code>'$VAR'</code>(<var>Name</var>). Like <a id="idx:writecanonical1:1134"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>,
395436 terms that where already bound to <code>'$VAR'</code>(<var>X</var>)
396 before <a name="idx:writeterm2:1135"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
437 before <a id="idx:writeterm2:1135"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
397438 are printed normally, unless the option <code>numbervars(true)</code> is
398439 also provided. If the option <code>numbervars(true)</code> is used, the
399440 user is responsible for avoiding collisions between assigned names and
400441 numbered names. See also the <code>variable_names</code> option of
401 <a name="idx:readterm2:1136"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
402
403 <p>Possible variable attributes (see <a class="sec" href="attvar.html">section
404 7.1</a>) are ignored. In most cases one should use <a name="idx:copyterm3:1137"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>
442 <a id="idx:readterm2:1136"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
443
444 <p>Possible variable attributes (see <a class="sec" href="attvar.html#sec:7.1">section
445 7.1</a>) are ignored. In most cases one should use <a id="idx:copyterm3:1137"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>
405446 to obtain a copy that is free of attributed variables and handle the
406447 associated constraints as appropriate for the use-case.
407448 </dd>
408449 </dl>
409450
410451 </dd>
411 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_term/3"><strong>write_term</strong>(<var>+Stream,
452 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_term/3"><strong>write_term</strong>(<var>+Stream,
412453 +Term, +Options</var>)</a></dt>
413454 <dd class="defbody">
414 As <a name="idx:writeterm2:1138"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
455 As <a id="idx:writeterm2:1138"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
415456 but output is sent to <var>Stream</var> rather than the current output.</dd>
416 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="write_length/3"><strong>write_length</strong>(<var>+Term,
457 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="write_length/3"><strong>write_length</strong>(<var>+Term,
417458 -Length, +Options</var>)</a></dt>
418459 <dd class="defbody">
419460 True when <var>Length</var> is the number of characters emitted for
420461 <var>write_term</var>Term, Options . In addition to valid options for
421 <a name="idx:writeterm2:1139"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
462 <a id="idx:writeterm2:1139"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
422463 it processes the option:
423464
424465 <dl class="latex">
431472 </dl>
432473
433474 </dd>
434 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_canonical/1"><strong>write_canonical</strong>(<var>+Term</var>)</a></dt>
475 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_canonical/1"><strong>write_canonical</strong>(<var>+Term</var>)</a></dt>
435476 <dd class="defbody">
436477 Write <var>Term</var> on the current output stream using standard
437478 parenthesised prefix notation (i.e., ignoring operator declarations).
438479 Atoms that need quotes are quoted. Terms written with this predicate can
439480 always be read back, regardless of current operator declarations.
440 Equivalent to <a name="idx:writeterm2:1140"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
481 Equivalent to <a id="idx:writeterm2:1140"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
441482 using the options <code>ignore_ops</code>,
442 <code>quoted</code> and <code>numbervars</code> after <a name="idx:numbervars4:1141"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>
483 <code>quoted</code> and <code>numbervars</code> after <a id="idx:numbervars4:1141"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>
443484 using the
444485 <code>singletons</code> option.
445486
446 <p>Note that due to the use of <a name="idx:numbervars4:1142"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>,
447 non-ground terms must be written using a <em>single</em> <a name="idx:writecanonical1:1143"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>
487 <p>Note that due to the use of <a id="idx:numbervars4:1142"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>,
488 non-ground terms must be written using a <em>single</em> <a id="idx:writecanonical1:1143"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>
448489 call. This used to be the case anyhow, as garbage collection between
449490 multiple calls to one of the write predicates can change the <code>_G</code>&lt;NNN&gt;
450491 identity of the variables.</dd>
451 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_canonical/2"><strong>write_canonical</strong>(<var>+Stream,
492 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_canonical/2"><strong>write_canonical</strong>(<var>+Stream,
452493 +Term</var>)</a></dt>
453494 <dd class="defbody">
454495 Write <var>Term</var> in canonical form on <var>Stream</var>.</dd>
455 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write/1"><strong>write</strong>(<var>+Term</var>)</a></dt>
496 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write/1"><strong>write</strong>(<var>+Term</var>)</a></dt>
456497 <dd class="defbody">
457498 Write <var>Term</var> to the current output, using brackets and
458499 operators where appropriate.</dd>
459 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write/2"><strong>write</strong>(<var>+Stream,
500 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write/2"><strong>write</strong>(<var>+Stream,
460501 +Term</var>)</a></dt>
461502 <dd class="defbody">
462503 Write <var>Term</var> to <var>Stream</var>.</dd>
463 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="writeq/1"><strong>writeq</strong>(<var>+Term</var>)</a></dt>
504 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="writeq/1"><strong>writeq</strong>(<var>+Term</var>)</a></dt>
464505 <dd class="defbody">
465506 Write <var>Term</var> to the current output, using brackets and
466507 operators where appropriate. Atoms that need quotes are quoted. Terms
467 written with this predicate can be read back with <a name="idx:read1:1144"></a><a class="pred" href="termrw.html#read/1">read/1</a>
508 written with this predicate can be read back with <a id="idx:read1:1144"></a><a class="pred" href="termrw.html#read/1">read/1</a>
468509 provided the currently active operator declarations are identical.</dd>
469 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="writeq/2"><strong>writeq</strong>(<var>+Stream,
510 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="writeq/2"><strong>writeq</strong>(<var>+Stream,
470511 +Term</var>)</a></dt>
471512 <dd class="defbody">
472513 Write <var>Term</var> to <var>Stream</var>, inserting quotes.</dd>
473 <dt class="pubdef"><a name="writeln/1"><strong>writeln</strong>(<var>+Term</var>)</a></dt>
514 <dt class="pubdef"><a id="writeln/1"><strong>writeln</strong>(<var>+Term</var>)</a></dt>
474515 <dd class="defbody">
475516 Equivalent to <code>write(Term), nl.</code>. The output stream is
476517 locked, which implies no output from other threads can appear between
477518 the term and newline.</dd>
478 <dt class="pubdef"><a name="writeln/2"><strong>writeln</strong>(<var>+Stream,
519 <dt class="pubdef"><a id="writeln/2"><strong>writeln</strong>(<var>+Stream,
479520 +Term</var>)</a></dt>
480521 <dd class="defbody">
481522 Equivalent to <code>write(Stream, Term), nl(Stream).</code>. The output
482523 stream is locked, which implies no output from other threads can appear
483524 between the term and newline.</dd>
484 <dt class="pubdef"><a name="print/1"><strong>print</strong>(<var>+Term</var>)</a></dt>
485 <dd class="defbody">
486 Print a term for debugging purposes. The predicate <a name="idx:print1:1145"></a><a class="pred" href="termrw.html#print/1">print/1</a>
525 <dt class="pubdef"><a id="print/1"><strong>print</strong>(<var>+Term</var>)</a></dt>
526 <dd class="defbody">
527 Print a term for debugging purposes. The predicate <a id="idx:print1:1145"></a><a class="pred" href="termrw.html#print/1">print/1</a>
487528 acts as if defined as below.
488529
489530 <pre class="code">
497538 ]).
498539 </pre>
499540
500 <p>The <a name="idx:print1:1146"></a><a class="pred" href="termrw.html#print/1">print/1</a>
541 <p>The <a id="idx:print1:1146"></a><a class="pred" href="termrw.html#print/1">print/1</a>
501542 predicate is used primarily through the <code>~p</code> escape sequence
502 of <a name="idx:format2:1147"></a><a class="pred" href="format.html#format/2">format/2</a>,
543 of <a id="idx:format2:1147"></a><a class="pred" href="format.html#format/2">format/2</a>,
503544 which is commonly used in the recipies used by
504 <a name="idx:printmessage2:1148"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
545 <a id="idx:printmessage2:1148"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
505546 to emit messages.
506547
507548 <p>The classical definition of this predicate is equivalent to the ISO
508 predicate <a name="idx:writeterm2:1149"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
549 predicate <a id="idx:writeterm2:1149"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
509550 using the options <code>portray(true)</code> and
510551 <code>numbervars(true)</code>. The <code>portray(true)</code> option
511552 allows the user to implement application-specific printing of terms
512553 printed during debugging to facilitate easy understanding of the output.
513554 See also
514 <a name="idx:portray1:1150"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
555 <a id="idx:portray1:1150"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
515556 and <code>library(portray_text)</code>. SWI-Prolog adds <code>quoted(true)</code>
516557 to (1) facilitate the copying/pasting of terms that are not affected by
517 <a name="idx:portray1:1151"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
558 <a id="idx:portray1:1151"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
518559 and to (2) allow numbers, atoms and strings to be more easily
519560 distinguished, e.g., <code>42</code>, <code>'42'</code> and <code>"42"</code>.</dd>
520 <dt class="pubdef"><a name="print/2"><strong>print</strong>(<var>+Stream,
561 <dt class="pubdef"><a id="print/2"><strong>print</strong>(<var>+Stream,
521562 +Term</var>)</a></dt>
522563 <dd class="defbody">
523564 Print <var>Term</var> to <var>Stream</var>.</dd>
524 <dt class="pubdef"><a name="portray/1"><strong>portray</strong>(<var>+Term</var>)</a></dt>
565 <dt class="pubdef"><a id="portray/1"><strong>portray</strong>(<var>+Term</var>)</a></dt>
525566 <dd class="defbody">
526567 A dynamic predicate, which can be defined by the user to change the
527 behaviour of <a name="idx:print1:1152"></a><a class="pred" href="termrw.html#print/1">print/1</a>
528 on (sub)terms. For each subterm encountered that is not a variable <a name="idx:print1:1153"></a><a class="pred" href="termrw.html#print/1">print/1</a>
529 first calls <a name="idx:portray1:1154"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
568 behaviour of <a id="idx:print1:1152"></a><a class="pred" href="termrw.html#print/1">print/1</a>
569 on (sub)terms. For each subterm encountered that is not a variable <a id="idx:print1:1153"></a><a class="pred" href="termrw.html#print/1">print/1</a>
570 first calls <a id="idx:portray1:1154"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
530571 using the term as argument. For lists, only the list as a whole is given
531 to <a name="idx:portray1:1155"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>.
572 to <a id="idx:portray1:1155"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>.
532573 If
533 <a name="idx:portray1:1156"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
534 succeeds <a name="idx:print1:1157"></a><a class="pred" href="termrw.html#print/1">print/1</a>
574 <a id="idx:portray1:1156"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
575 succeeds <a id="idx:print1:1157"></a><a class="pred" href="termrw.html#print/1">print/1</a>
535576 assumes the term has been written.</dd>
536 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="read/1"><strong>read</strong>(<var>-Term</var>)</a></dt>
577 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="read/1"><strong>read</strong>(<var>-Term</var>)</a></dt>
537578 <dd class="defbody">
538579 Read the next Prolog term from the current input stream and unify it
539 with <var>Term</var>. On a syntax error <a name="idx:read1:1158"></a><a class="pred" href="termrw.html#read/1">read/1</a>
580 with <var>Term</var>. On a syntax error <a id="idx:read1:1158"></a><a class="pred" href="termrw.html#read/1">read/1</a>
540581 displays an error message, attempts to skip the erroneous term and
541582 fails. On reaching end-of-file
542583 <var>Term</var> is unified with the atom <code>end_of_file</code>.</dd>
543 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="read/2"><strong>read</strong>(<var>+Stream,
584 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="read/2"><strong>read</strong>(<var>+Stream,
544585 -Term</var>)</a></dt>
545586 <dd class="defbody">
546587 Read <var>Term</var> from <var>Stream</var>.</dd>
547 <dt class="pubdef"><a name="read_clause/3"><strong>read_clause</strong>(<var>+Stream,
588 <dt class="pubdef"><a id="read_clause/3"><strong>read_clause</strong>(<var>+Stream,
548589 -Term, +Options</var>)</a></dt>
549590 <dd class="defbody">
550 Equivalent to <a name="idx:readterm3:1159"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
591 Equivalent to <a id="idx:readterm3:1159"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
551592 but sets options according to the current compilation context and
552593 optionally processes comments. Defined options:
553594
554595 <dl class="latex">
555596 <dt><strong>syntax_errors</strong>(<var>+Atom</var>)</dt>
556597 <dd class="defbody">
557 See <a name="idx:readterm3:1160"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
598 See <a id="idx:readterm3:1160"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
558599 but the default is <code>dec10</code> (report and restart).</dd>
559600 <dt><strong>term_position</strong>(<var>-TermPos</var>)</dt>
560601 <dd class="defbody">
561 Same as for <a name="idx:readterm3:1161"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
602 Same as for <a id="idx:readterm3:1161"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
562603 <dt><strong>subterm_positions</strong>(<var>-TermPos</var>)</dt>
563604 <dd class="defbody">
564 Same as for <a name="idx:readterm3:1162"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
605 Same as for <a id="idx:readterm3:1162"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
565606 <dt><strong>variable_names</strong>(<var>-Bindings</var>)</dt>
566607 <dd class="defbody">
567 Same as for <a name="idx:readterm3:1163"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
608 Same as for <a id="idx:readterm3:1163"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
568609 <dt><strong>process_comment</strong>(<var>+Boolean</var>)</dt>
569610 <dd class="defbody">
570611 If <code>true</code> (default), call
579620 </dd>
580621 </dl>
581622
582 <p>The <code>singletons</code> option of <a name="idx:readterm3:1164"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
623 <p>The <code>singletons</code> option of <a id="idx:readterm3:1164"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
583624 is initialised from the active style-checking mode. The <code>module</code>
584 option is initialised to the current compilation module (see <a name="idx:prologloadcontext2:1165"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>).</dd>
585 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="read_term/2"><strong>read_term</strong>(<var>-Term,
625 option is initialised to the current compilation module (see <a id="idx:prologloadcontext2:1165"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>).</dd>
626 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="read_term/2"><strong>read_term</strong>(<var>-Term,
586627 +Options</var>)</a></dt>
587628 <dd class="defbody">
588629 Read a term from the current input stream and unify the term with
589630 <var>Term</var>. The reading is controlled by options from the list of
590631 <var>Options</var>. If this list is empty, the behaviour is the same as
591632 for
592 <a name="idx:read1:1166"></a><a class="pred" href="termrw.html#read/1">read/1</a>.
633 <a id="idx:read1:1166"></a><a class="pred" href="termrw.html#read/1">read/1</a>.
593634 The options are upward compatible with Quintus Prolog. The argument
594635 order is according to the ISO standard. Syntax errors are always
595 reported using exception-handling (see <a name="idx:catch3:1167"></a><a class="pred" href="exception.html#catch/3">catch/3</a>).
636 reported using exception-handling (see <a id="idx:catch3:1167"></a><a class="pred" href="exception.html#catch/3">catch/3</a>).
596637 Options:
597638
598639 <dl class="latex">
600641 <dd class="defbody">
601642 If <code>true</code>, read <code>`</code>...<code>`</code> to a string
602643 object (see
603 <a class="sec" href="strings.html">section 5.2</a>). The default depends
604 on the Prolog flag
644 <a class="sec" href="strings.html#sec:5.2">section 5.2</a>). The default
645 depends on the Prolog flag
605646 <a class="flag" href="flags.html#flag:back_quotes">back_quotes</a>.</dd>
606647 <dt><strong>character_escapes</strong>(<var>Bool</var>)</dt>
607648 <dd class="defbody">
608649 Defines how to read <code>\</code> escape sequences in quoted atoms. See
609650 the Prolog flag <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
610 in <a name="idx:currentprologflag2:1168"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.
651 in <a id="idx:currentprologflag2:1168"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.
611652 (SWI-Prolog).</dd>
612653 <dt><strong>comments</strong>(<var>-Comments</var>)</dt>
613654 <dd class="defbody">
614655 Unify <var>Comments</var> with a list of <var>Position</var>-<var>Comment</var>,
615656 where
616 <var>Position</var> is a stream position object (see <a name="idx:streampositiondata3:1169"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>)
657 <var>Position</var> is a stream position object (see <a id="idx:streampositiondata3:1169"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>)
617658 indicating the start of a comment and <var>Comment</var> is a string
618659 object containing the text including delimiters of a comment. It returns
619 all comments from where the <a name="idx:readterm2:1170"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
660 all comments from where the <a id="idx:readterm2:1170"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
620661 call started up to the end of the term read.</dd>
621662 <dt><strong>cycles</strong>(<var>Bool</var>)</dt>
622663 <dd class="defbody">
623664 If <code>true</code> (default <code>false</code>), re-instantiate
624 templates as produced by the corresponding <a name="idx:writeterm2:1171"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
665 templates as produced by the corresponding <a id="idx:writeterm2:1171"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
625666 option. Note that the default is <code>false</code> to avoid
626667 misinterpretation of <code>@(Template, Substutions)</code>, while the
627 default of <a name="idx:writeterm2:1172"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
668 default of <a id="idx:writeterm2:1172"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
628669 is <code>true</code> because emitting cyclic terms without using the
629670 template construct produces an infinitely large term (read: it will
630671 generate an error after producing a huge amount of output).</dd>
632673 <dd class="defbody">
633674 If <code>true</code> (default <code>false</code>), read <code>.(a,[])</code>
634675 as a list, even if lists are internally nor constructed using the dot as
635 functor. This is primarily intended to read the output from <a name="idx:writecanonical1:1173"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>
636 from other Prolog systems. See <a class="sec" href="ext-lists.html">section
676 functor. This is primarily intended to read the output from <a id="idx:writecanonical1:1173"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>
677 from other Prolog systems. See <a class="sec" href="ext-lists.html#sec:5.1">section
637678 5.1</a>.</dd>
638679 <dt><strong>double_quotes</strong>(<var>Atom</var>)</dt>
639680 <dd class="defbody">
644685 <dd class="defbody">
645686 Specify <var>Module</var> for operators, <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
646687 flag and <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>
647 flag. The value of the latter two is overruled if the corresponding <a name="idx:readterm3:1174"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
688 flag. The value of the latter two is overruled if the corresponding <a id="idx:readterm3:1174"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
648689 option is provided. If no module is specified, the current `source
649690 module' is used. (SWI-Prolog).</dd>
650691 <dt><strong>quasi_quotations</strong>(<var>-List</var>)</dt>
651692 <dd class="defbody">
652693 If present, unify <var>List</var> with the quasi quotations (see
653 <a class="sec" href="quasiquotations.html">section A.28</a>) instead of
654 evaluating quasi quotations. Each quasi quotation is a term <code>quasi_quotation(+Syntax,
694 <a class="sec" href="quasiquotations.html#sec:A.28">section A.28</a>)
695 instead of evaluating quasi quotations. Each quasi quotation is a term <code>quasi_quotation(+Syntax,
655696 +Quotation, +VarDict, -Result)</code>, where <var>Syntax</var> is the
656697 term in
657698 <code>{|Syntax||..|}</code>, <var>Quotation</var> is a list of character
666707 underscore (`<code>_</code>') are not included in this list. (ISO). If <var>Vars</var>
667708 is the constant <code>warning</code>, singleton variables are reported
668709 using
669 <a name="idx:printmessage2:1175"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
710 <a id="idx:printmessage2:1175"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
670711 The variables appear in the order they have been read.</dd>
671712 <dt><strong>syntax_errors</strong>(<var>Atom</var>)</dt>
672713 <dd class="defbody">
673714 If <code>error</code> (default), throw an exception on a syntax error.
674715 Other values are <code>fail</code>, which causes a message to be printed
675716 using
676 <a name="idx:printmessage2:1176"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>,
717 <a id="idx:printmessage2:1176"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>,
677718 after which the predicate fails, <code>quiet</code> which causes the
678719 predicate to fail silently, and <code>dec10</code> which causes syntax
679 errors to be printed, after which <a name="idx:readterm23:1177"></a><a class="pred" href="termrw.html#read_term/2">read_term/[2,3]</a>
680 continues reading the next term. Using <code>dec10</code>, <a name="idx:readterm23:1178"></a><a class="pred" href="termrw.html#read_term/2">read_term/[2,3]</a>
720 errors to be printed, after which <a id="idx:readterm23:1177"></a><a class="pred" href="termrw.html#read_term/2">read_term/[2,3]</a>
721 continues reading the next term. Using <code>dec10</code>, <a id="idx:readterm23:1178"></a><a class="pred" href="termrw.html#read_term/2">read_term/[2,3]</a>
681722 never fails. (Quintus, SICStus).</dd>
682723 <dt><strong>subterm_positions</strong>(<var>TermPos</var>)</dt>
683724 <dd class="defbody">
711752 corresponding subterm.</dd>
712753 <dt><strong>dict_position</strong>(<var><var>From</var>, <var>To</var>, <var>TagFrom</var>, <var>TagTo</var>, <var>KeyValuePosList</var></var>)</dt>
713754 <dd class="defbody">
714 Used for a dict (see <a class="sec" href="dicts.html">section 5.4</a>).
715 The position of the key-value pairs is described by <var>KeyValuePosList</var>,
755 Used for a dict (see <a class="sec" href="dicts.html#sec:5.4">section
756 5.4</a>). The position of the key-value pairs is described by <var>KeyValuePosList</var>,
716757 which is a list of
717758 <code>key_value_position/7</code> terms. The <code>key_value_position/7</code>
718759 terms appear in the order of the input. Because maps to not preserve
719760 ordering, the key is provided in the position description.</dd>
720761 <dt><strong>key_value_position</strong>(<var><var>From</var>, <var>To</var>, <var>SepFrom</var>, <var>SepTo</var>, <var>Key</var>, <var>KeyPos</var>, <var>ValuePos</var></var>)</dt>
721762 <dd class="defbody">
722 Used for key-value pairs in a map (see <a class="sec" href="dicts.html">section
763 Used for key-value pairs in a map (see <a class="sec" href="dicts.html#sec:5.4">section
723764 5.4</a>). It is similar to the <code>term_position/5</code> that would
724765 be created, except that the key and value positions do not need an
725766 intermediate list and the key is provided in <var>Key</var> to enable
739780 <dt><strong>term_position</strong>(<var>Pos</var>)</dt>
740781 <dd class="defbody">
741782 Unifies <var>Pos</var> with the starting position of the term read. <var>Pos</var>
742 is of the same format as used by <a name="idx:streamproperty2:1179"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.</dd>
783 is of the same format as used by <a id="idx:streamproperty2:1179"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.</dd>
743784 <dt><strong>var_prefix</strong>(<var>Bool</var>)</dt>
744785 <dd class="defbody">
745786 If <code>true</code>, demand variables to start with an underscore. See
746 <a class="sec" href="syntax.html">section 2.16.1.7</a>.</dd>
787 <a class="sec" href="syntax.html#sec:2.16.1.7">section 2.16.1.7</a>.</dd>
747788 <dt><strong>variables</strong>(<var>Vars</var>)</dt>
748789 <dd class="defbody">
749790 Unify <var>Vars</var> with a list of variables in the term. The
750 variables appear in the order they have been read. See also <a name="idx:termvariables2:1180"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.
791 variables appear in the order they have been read. See also <a id="idx:termvariables2:1180"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.
751792 (ISO).</dd>
752793 <dt><strong>variable_names</strong>(<var>Vars</var>)</dt>
753794 <dd class="defbody">
760801 </dl>
761802
762803 </dd>
763 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="read_term/3"><strong>read_term</strong>(<var>+Stream,
804 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="read_term/3"><strong>read_term</strong>(<var>+Stream,
764805 -Term, +Options</var>)</a></dt>
765806 <dd class="defbody">
766 Read term with options from <var>Stream</var>. See <a name="idx:readterm2:1181"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.</dd>
767 <dt class="pubdef"><a name="read_term_from_atom/3"><strong>read_term_from_atom</strong>(<var>+Atom,
807 Read term with options from <var>Stream</var>. See <a id="idx:readterm2:1181"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.</dd>
808 <dt class="pubdef"><a id="read_term_from_atom/3"><strong>read_term_from_atom</strong>(<var>+Atom,
768809 -Term, +Options</var>)</a></dt>
769810 <dd class="defbody">
770 Use <a name="idx:readterm3:1182"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
811 Use <a id="idx:readterm3:1182"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
771812 to read the next term from <var>Atom</var>. <var>Atom</var> is either an
772 atom or a string object (see <a class="sec" href="strings.html">section
813 atom or a string object (see <a class="sec" href="strings.html#sec:5.2">section
773814 5.2</a>). It is not required for <var>Atom</var> to end with a
774 full-stop. This predicate supersedes <a name="idx:atomtoterm3:1183"></a><a class="pred" href="manipatom.html#atom_to_term/3">atom_to_term/3</a>.</dd>
775 <dt class="pubdef"><a name="read_history/6"><strong>read_history</strong>(<var>+Show,
815 full-stop. This predicate supersedes <a id="idx:atomtoterm3:1183"></a><a class="pred" href="manipatom.html#atom_to_term/3">atom_to_term/3</a>.</dd>
816 <dt class="pubdef"><a id="read_history/6"><strong>read_history</strong>(<var>+Show,
776817 +Help, +Special, +Prompt, -Term, -Bindings</var>)</a></dt>
777818 <dd class="defbody">
778 Similar to <a name="idx:readterm2:1184"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
819 Similar to <a id="idx:readterm2:1184"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
779820 using the option <code>variable_names</code>, but allows for history
780 substitutions. <a name="idx:readhistory6:1185"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
821 substitutions. <a id="idx:readhistory6:1185"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
781822 is used by the top level to read the user's actions. <var>Show</var> is
782823 the command the user should type to show the saved events. <var>Help</var>
783824 is the command to get an overview of the capabilities. <var>Special</var>
784825 is a list of commands that are not saved in the history. <var>Prompt</var>
785826 is the first prompt given. Continuation prompts for more lines are
786 determined by <a name="idx:prompt2:1186"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
827 determined by <a id="idx:prompt2:1186"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
787828 A
788829 <code>%w</code> in the prompt is substituted by the event number. See
789 <a class="sec" href="history.html">section 2.7</a> for available
830 <a class="sec" href="history.html#sec:2.7">section 2.7</a> for available
790831 substitutions.
791832
792 <p>SWI-Prolog calls <a name="idx:readhistory6:1187"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
833 <p>SWI-Prolog calls <a id="idx:readhistory6:1187"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
793834 as follows:
794835
795836 <pre class="code">
797838 </pre>
798839
799840 </dd>
800 <dt class="pubdef"><a name="prompt/2"><strong>prompt</strong>(<var>-Old,
841 <dt class="pubdef"><a id="prompt/2"><strong>prompt</strong>(<var>-Old,
801842 +New</var>)</a></dt>
802843 <dd class="defbody">
803 Set prompt associated with <a name="idx:read1:1188"></a><a class="pred" href="termrw.html#read/1">read/1</a>
844 Set prompt associated with <a id="idx:read1:1188"></a><a class="pred" href="termrw.html#read/1">read/1</a>
804845 and its derivatives. <var>Old</var> is first unified with the current
805846 prompt. On success the prompt will be set to <var>New</var> if this is
806847 an atom. Otherwise an error message is displayed. A prompt is printed if
808849 margin. It is also printed whenever a newline is given and the term has
809850 not been terminated. Prompts are only printed when the current input
810851 stream is <var>user</var>.</dd>
811 <dt class="pubdef"><a name="prompt1/1"><strong>prompt1</strong>(<var>+Prompt</var>)</a></dt>
852 <dt class="pubdef"><a id="prompt1/1"><strong>prompt1</strong>(<var>+Prompt</var>)</a></dt>
812853 <dd class="defbody">
813854 Sets the prompt for the next line to be read. Continuation lines will be
814 read using the prompt defined by <a name="idx:prompt2:1189"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
855 read using the prompt defined by <a id="idx:prompt2:1189"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
815856 </dd>
816857 </dl>
817858
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 9.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="threadcreate.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="threadcom.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:thmonitor"><a name="sec:9.2"><span class="sec-nr">9.2</span> <span class="sec-title">Monitoring
235 <h2 id="sec:thmonitor"><a id="sec:9.2"><span class="sec-nr">9.2</span> <span class="sec-title">Monitoring
195236 threads</span></a></h2>
196237
197 <a name="sec:thmonitor"></a>
238 <a id="sec:thmonitor"></a>
198239
199240 <p>Normal multithreaded applications should not need the predicates from
200241 this section because almost any usage of these predicates is unsafe. For
201242 example checking the existence of a thread before signalling it is of no
202 use as it may vanish between the two calls. Catching exceptions using <a name="idx:catch3:1872"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
243 use as it may vanish between the two calls. Catching exceptions using <a id="idx:catch3:1876"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
203244 is the only safe way to deal with thread-existence errors.
204245
205246 <p>These predicates are provided for diagnosis and monitoring tasks. See
206 also <a class="sec" href="thutil.html">section 9.5</a>, describing more
207 high-level primitives.
247 also <a class="sec" href="thutil.html#sec:9.5">section 9.5</a>,
248 describing more high-level primitives.
208249
209250 <dl class="latex">
210 <dt class="pubdef"><a name="is_thread/1"><strong>is_thread</strong>(<var>@Term</var>)</a></dt>
251 <dt class="pubdef"><a id="is_thread/1"><strong>is_thread</strong>(<var>@Term</var>)</a></dt>
211252 <dd class="defbody">
212253 True if <var>Term</var> is a handle to an existing thread.</dd>
213 <dt class="pubdef"><a name="thread_property/2"><strong>thread_property</strong>(<var>?Id,
254 <dt class="pubdef"><a id="thread_property/2"><strong>thread_property</strong>(<var>?Id,
214255 ?Property</var>)</a></dt>
215256 <dd class="defbody">
216257 True if thread <var>Id</var> has <var>Property</var>. Either or both
217258 arguments may be unbound, enumerating all relations on backtracking.
218 Calling <a name="idx:threadproperty2:1873"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>
259 Calling <a id="idx:threadproperty2:1877"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>
219260 does not influence any thread. See also
220 <a name="idx:threadjoin2:1874"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
261 <a id="idx:threadjoin2:1878"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
221262 For threads that have an alias name, this name is returned in <var>Id</var>
222263 instead of the opaque thread identifier. Defined properties are:
223264
244285 note that threads waiting for something are considered running too.</dd>
245286 <dt><strong>suspended</strong></dt>
246287 <dd class="defbody">
247 Only if the thread is an engine (see <a class="sec" href="engines.html">section
288 Only if the thread is an engine (see <a class="sec" href="engines.html#sec:10">section
248289 10</a>). Indicates that the engine is currently not associated with an
249290 OS thread.</dd>
250291 <dt><strong>false</strong></dt>
255296 The <var>Goal</var> of the thread has been completed and succeeded.</dd>
256297 <dt><strong>exited</strong>(<var>Term</var>)</dt>
257298 <dd class="defbody">
258 The <var>Goal</var> of the thread has been terminated using <a name="idx:threadexit1:1875"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
299 The <var>Goal</var> of the thread has been terminated using <a id="idx:threadexit1:1879"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
259300 with <var>Term</var> as argument. If the underlying native thread has
260301 exited (using pthread_exit()) <var>Term</var> is unbound.</dd>
261302 <dt><strong>exception</strong>(<var>Term</var>)</dt>
262303 <dd class="defbody">
263304 The <var>Goal</var> of the thread has been terminated due to an uncaught
264 exception (see <a name="idx:throw1:1876"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
265 and <a name="idx:catch3:1877"></a><a class="pred" href="exception.html#catch/3">catch/3</a>).
305 exception (see <a id="idx:throw1:1880"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
306 and <a id="idx:catch3:1881"></a><a class="pred" href="exception.html#catch/3">catch/3</a>).
266307 </dd>
267308 </dl>
268309
269310 </dd>
270311 <dt><strong>engine</strong>(<var>Boolean</var>)</dt>
271312 <dd class="defbody">
272 If the thread is an engine (see <a class="sec" href="engines.html">chapter
313 If the thread is an engine (see <a class="sec" href="engines.html#sec:10">chapter
273314 10</a>), <var>Boolean</var> is
274315 <code>true</code>. Othwerwise the property is not present.</dd>
275316 <dt><strong>thread</strong>(<var>ThreadId</var>)</dt>
287328 </dd>
288329 </dl>
289330
290 <p>See also <a name="idx:threadstatistics3:1878"></a><a class="pred" href="thmonitor.html#thread_statistics/3">thread_statistics/3</a>
331 <p>See also <a id="idx:threadstatistics3:1882"></a><a class="pred" href="thmonitor.html#thread_statistics/3">thread_statistics/3</a>
291332 to obtain resource usage information and
292 <a name="idx:messagequeueproperty2:1879"></a><a class="pred" href="threadcom.html#message_queue_property/2">message_queue_property/2</a>
333 <a id="idx:messagequeueproperty2:1883"></a><a class="pred" href="threadcom.html#message_queue_property/2">message_queue_property/2</a>
293334 to get the number of queued messages for a thread.</dd>
294 <dt class="pubdef"><a name="thread_statistics/3"><strong>thread_statistics</strong>(<var>+Id,
335 <dt class="pubdef"><a id="thread_statistics/3"><strong>thread_statistics</strong>(<var>+Id,
295336 +Key, -Value</var>)</a></dt>
296337 <dd class="defbody">
297 Obtains statistical information on thread <var>Id</var> as <a name="idx:statistics2:1880"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>
298 does in single-threaded applications. This call supports all keys of <a name="idx:statistics2:1881"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>,
338 Obtains statistical information on thread <var>Id</var> as <a id="idx:statistics2:1884"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>
339 does in single-threaded applications. This call supports all keys of <a id="idx:statistics2:1885"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>,
299340 although only stack sizes, <code>cputime</code>,
300341 <code>inferences</code> and <code>epoch</code> yield different values
301 for each thread.<sup class="fn">159<span class="fn-text">There is no
342 for each thread.<sup class="fn">160<span class="fn-text">There is no
302343 portable interface to obtain thread-specific CPU time and some operating
303344 systems provide no access to this information at all. On such systems
304345 the total process CPU is returned. Thread CPU time is supported on
305346 MS-Windows, Linux and MacOSX.</span></sup></dd>
306 <dt class="pubdef"><a name="mutex_statistics/0"><strong>mutex_statistics</strong></a></dt>
347 <dt class="pubdef"><a id="mutex_statistics/0"><strong>mutex_statistics</strong></a></dt>
307348 <dd class="defbody">
308349 Print usage statistics on internal mutexes and mutexes associated with
309350 dynamic predicates. For each mutex two numbers are printed: the number
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 9.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="thmonitor.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="threadsync.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:threadcom"><a name="sec:9.3"><span class="sec-nr">9.3</span> <span class="sec-title">Thread
235 <h2 id="sec:threadcom"><a id="sec:9.3"><span class="sec-nr">9.3</span> <span class="sec-title">Thread
195236 communication</span></a></h2>
196237
197 <a name="sec:threadcom"></a>
198
199 <p><h3 id="sec:msgqueue"><a name="sec:9.3.1"><span class="sec-nr">9.3.1</span> <span class="sec-title">Message
238 <a id="sec:threadcom"></a>
239
240 <p><h3 id="sec:msgqueue"><a id="sec:9.3.1"><span class="sec-nr">9.3.1</span> <span class="sec-title">Message
200241 queues</span></a></h3>
201242
202 <a name="sec:msgqueue"></a>
243 <a id="sec:msgqueue"></a>
203244
204245 <p>Prolog threads can exchange data using dynamic predicates, database
205246 records, and other globally shared data. These provide no suitable means
208249 threads to wait for data or conditions without using the CPU.
209250
210251 <p>Each thread has a message queue attached to it that is identified by
211 the thread. Additional queues are created using <a name="idx:messagequeuecreate1:1882"></a><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a>.
252 the thread. Additional queues are created using <a id="idx:messagequeuecreate1:1886"></a><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a>.
212253 Explicitly created queues come in two flavours. When given an
213254 <em>alias</em>, they must be destroyed by the user. <em>Anonymous</em>
214 message queues are identified by a <em>blob</em> (see <a class="sec" href="foreigninclude.html">section
255 message queues are identified by a <em>blob</em> (see <a class="sec" href="foreigninclude.html#sec:11.4.7">section
215256 11.4.7</a>) and subject to garbage collection.
216257
217258 <dl class="latex">
218 <dt class="pubdef"><a name="thread_send_message/2"><strong>thread_send_message</strong>(<var>+QueueOrThreadId,
259 <dt class="pubdef"><a id="thread_send_message/2"><strong>thread_send_message</strong>(<var>+QueueOrThreadId,
219260 +Term</var>)</a></dt>
220261 <dd class="defbody">
221262 Place <var>Term</var> in the given queue or default queue of the
222263 indicated thread (which can even be the message queue of itself, see
223 <a name="idx:threadself1:1883"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>).
264 <a id="idx:threadself1:1887"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>).
224265 Any term can be placed in a message queue, but note that the term is
225266 copied to the receiving thread and variable bindings are thus lost. This
226267 call returns immediately.
233274 the same queue as all-but-the-winner perform a useless scan of the
234275 queue. If there is only one waiting thread or all waiting threads wait
235276 with an unbound variable, an arbitrary thread is restarted to scan the
236 queue.<sup class="fn">160<span class="fn-text">See the documentation for
277 queue.<sup class="fn">161<span class="fn-text">See the documentation for
237278 the POSIX thread functions pthread_cond_signal() v.s. pthread_cond_broadcast()
238279 for background information.</span></sup></dd>
239 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="thread_send_message/3"><strong>thread_send_message</strong>(<var>+Queue,
280 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="thread_send_message/3"><strong>thread_send_message</strong>(<var>+Queue,
240281 +Term, +Options</var>)</a></dt>
241282 <dd class="defbody">
242 As <a name="idx:threadsendmessage2:1884"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>,
283 As <a id="idx:threadsendmessage2:1888"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>,
243284 but providing additional <var>Options</var>. These are to deal with the
244 case that the queue has a finite maximum size and is full: whereas <a name="idx:threadsendmessage2:1885"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
285 case that the queue has a finite maximum size and is full: whereas <a id="idx:threadsendmessage2:1889"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
245286 will block until the queue has drained sufficiently to accept a new
246 message, <a name="idx:threadsendmessage3:1886"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
247 can accept a time-out or deadline analogously to <a name="idx:threadgetmessage3:1887"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>.
287 message, <a id="idx:threadsendmessage3:1890"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
288 can accept a time-out or deadline analogously to <a id="idx:threadgetmessage3:1891"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>.
248289 The options are:
249290
250291 <dl class="latex">
251292 <dt><strong>deadline</strong>(<var>+AbsTime</var>)</dt>
252293 <dd class="defbody">
253294 The call fails (silently) if no space has become available before
254 <var>AbsTime</var>. See <a name="idx:gettime1:1888"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
295 <var>AbsTime</var>. See <a id="idx:gettime1:1892"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
255296 for the representation of absolute time. If <var>AbsTime</var> is
256 earlier then the current time, <a name="idx:threadsendmessage3:1889"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
297 earlier then the current time, <a id="idx:threadsendmessage3:1893"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
257298 fails immediately. Both resolution and maximum wait time is
258 platform-dependent.<sup class="fn">161<span class="fn-text">The
299 platform-dependent.<sup class="fn">162<span class="fn-text">The
259300 implementation uses MsgWaitForMultipleObjects() on MS-Windows and
260301 pthread_cond_timedwait() on other systems.</span></sup></dd>
261302 <dt><strong>timeout</strong>(<var>+Time</var>)</dt>
264305 wait in seconds. This is a relative-time version of the <code>deadline</code>
265306 option. If both options are provided, the earlier time is effective.
266307
267 <p>If <var>Time</var> is 0 or 0.0, <a name="idx:threadsendmessage3:1890"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
308 <p>If <var>Time</var> is 0 or 0.0, <a id="idx:threadsendmessage3:1894"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
268309 examines the queue and sends the message if space is availabel, but does
269310 not suspend if no space is available, failing immediately instead.
270311
271 <p>If <var>Time</var> <var>&lt; 0</var>, <a name="idx:threadsendmessage3:1891"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
312 <p>If <var>Time</var> <var>&lt; 0</var>, <a id="idx:threadsendmessage3:1895"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
272313 fails immediately without sending the message.
273314 </dd>
274315 </dl>
275316
276317 </dd>
277 <dt class="pubdef"><a name="thread_get_message/1"><strong>thread_get_message</strong>(<var>?Term</var>)</a></dt>
318 <dt class="pubdef"><a id="thread_get_message/1"><strong>thread_get_message</strong>(<var>?Term</var>)</a></dt>
278319 <dd class="defbody">
279320 Examines the thread message queue and if necessary blocks execution
280321 until a term that unifies to <var>Term</var> arrives in the queue. After
294335 thread_send_message(Thread_1, a(gnat)),
295336 </pre>
296337
297 <p>See also <a name="idx:threadpeekmessage1:1892"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>.</dd>
298 <dt class="pubdef"><a name="thread_peek_message/1"><strong>thread_peek_message</strong>(<var>?Term</var>)</a></dt>
338 <p>See also <a id="idx:threadpeekmessage1:1896"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>.</dd>
339 <dt class="pubdef"><a id="thread_peek_message/1"><strong>thread_peek_message</strong>(<var>?Term</var>)</a></dt>
299340 <dd class="defbody">
300341 Examines the thread message queue and compares the queued terms with <var>Term</var>
301342 until one unifies or the end of the queue has been reached. In the first
302343 case the call succeeds, possibly instantiating
303344 <var>Term</var>. If no term from the queue unifies, this call fails.
304345 I.e.,
305 <a name="idx:threadpeekmessage1:1893"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>
306 never waits and does not remove any term from the queue. See also <a name="idx:threadgetmessage3:1894"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>.</dd>
307 <dt class="pubdef"><a name="message_queue_create/1"><strong>message_queue_create</strong>(<var>?Queue</var>)</a></dt>
346 <a id="idx:threadpeekmessage1:1897"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>
347 never waits and does not remove any term from the queue. See also <a id="idx:threadgetmessage3:1898"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>.</dd>
348 <dt class="pubdef"><a id="message_queue_create/1"><strong>message_queue_create</strong>(<var>?Queue</var>)</a></dt>
308349 <dd class="defbody">
309350 Equivalent to <code>message_queue_create(Queue,[])</code>. For
310351 compatibility, calling <code>message_queue_create(+Atom)</code> is
311352 equivalent to
312353 <code>message_queue_create(Queue, [alias(Atom)])</code>. New code should
313354 use
314 <a name="idx:messagequeuecreate2:1895"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>
355 <a id="idx:messagequeuecreate2:1899"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>
315356 to create a named queue.</dd>
316 <dt class="pubdef"><a name="message_queue_create/2"><strong>message_queue_create</strong>(<var>-Queue,
357 <dt class="pubdef"><a id="message_queue_create/2"><strong>message_queue_create</strong>(<var>-Queue,
317358 +Options</var>)</a></dt>
318359 <dd class="defbody">
319360 Create a message queue from <var>Options</var>. Defined options are:
324365 Create a message queue that is identified by the atom <var>Alias</var>.
325366 Message queues created this way must be explicitly destroyed by the
326367 user. If the alias option is omitted, an <em>Anonymous</em> queue is
327 created that is indentified by a <em>blob</em> (see <a class="sec" href="foreigninclude.html">section
328 11.4.7</a>) and subject to garbage collection.<sup class="fn">162<span class="fn-text">Garbage
368 created that is indentified by a <em>blob</em> (see <a class="sec" href="foreigninclude.html#sec:11.4.7">section
369 11.4.7</a>) and subject to garbage collection.<sup class="fn">163<span class="fn-text">Garbage
329370 collecting anonymous message queues is not part of the ISO proposal and
330371 most likely not a widely implemented feature.</span></sup></dd>
331372 <dt><strong>max_size</strong>(<var>+Size</var>)</dt>
332373 <dd class="defbody">
333374 Maximum number of terms in the queue. If this number is reached,
334 <a name="idx:threadsendmessage2:1896"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
375 <a id="idx:threadsendmessage2:1900"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
335376 will suspend until the queue is drained. The option can be used if the
336377 source, sending messages to the queue, is faster than the drain,
337378 consuming the messages.
339380 </dl>
340381
341382 </dd>
342 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="message_queue_destroy/1"><strong>message_queue_destroy</strong>(<var>+Queue</var>)</a></dt>
343 <dd class="defbody">
344 Destroy a message queue created with <a name="idx:messagequeuecreate1:1897"></a><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a>.
383 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="message_queue_destroy/1"><strong>message_queue_destroy</strong>(<var>+Queue</var>)</a></dt>
384 <dd class="defbody">
385 Destroy a message queue created with <a id="idx:messagequeuecreate1:1901"></a><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a>.
345386 A permission error is raised if <var>Queue</var> refers to (the default
346387 queue of) a thread. Other threads that are waiting for <var>Queue</var>
347388 using
348 <a name="idx:threadgetmessage2:1898"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>
389 <a id="idx:threadgetmessage2:1902"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>
349390 receive an existence error.</dd>
350 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="thread_get_message/2"><strong>thread_get_message</strong>(<var>+Queue,
391 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="thread_get_message/2"><strong>thread_get_message</strong>(<var>+Queue,
351392 ?Term</var>)</a></dt>
352393 <dd class="defbody">
353 As <a name="idx:threadgetmessage1:1899"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>,
394 As <a id="idx:threadgetmessage1:1903"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>,
354395 operating on a given queue. It is allowed (but not advised) to get
355396 messages from the queue of other threads. This predicate raises an
356397 existence error exception if <var>Queue</var> doesn't exist or is
357 destroyed using <a name="idx:messagequeuedestroy1:1900"></a><a class="pred" href="threadcom.html#message_queue_destroy/1">message_queue_destroy/1</a>
398 destroyed using <a id="idx:messagequeuedestroy1:1904"></a><a class="pred" href="threadcom.html#message_queue_destroy/1">message_queue_destroy/1</a>
358399 while this predicate is waiting.</dd>
359 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="thread_get_message/3"><strong>thread_get_message</strong>(<var>+Queue,
400 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="thread_get_message/3"><strong>thread_get_message</strong>(<var>+Queue,
360401 ?Term, +Options</var>)</a></dt>
361402 <dd class="defbody">
362 As <a name="idx:threadgetmessage2:1901"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>,
403 As <a id="idx:threadgetmessage2:1905"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>,
363404 but providing additional <var>Options</var>:
364405
365406 <dl class="latex">
366407 <dt><strong>deadline</strong>(<var>+AbsTime</var>)</dt>
367408 <dd class="defbody">
368409 The call fails (silently) if no message has arrived before
369 <var>AbsTime</var>. See <a name="idx:gettime1:1902"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
410 <var>AbsTime</var>. See <a id="idx:gettime1:1906"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
370411 for the representation of absolute time. If <var>AbsTime</var> is
371 earlier then the current time, <a name="idx:threadgetmessage3:1903"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
412 earlier then the current time, <a id="idx:threadgetmessage3:1907"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
372413 fails immediately. Both resolution and maximum wait time is
373 platform-dependent.<sup class="fn">163<span class="fn-text">The
414 platform-dependent.<sup class="fn">164<span class="fn-text">The
374415 implementation uses MsgWaitForMultipleObjects() on MS-Windows and
375416 pthread_cond_timedwait() on other systems.</span></sup></dd>
376417 <dt><strong>timeout</strong>(<var>+Time</var>)</dt>
379420 wait in seconds. This is a relative-time version of the <code>deadline</code>
380421 option. If both options are provided, the earlier time is effective.
381422
382 <p>If <var>Time</var> is 0 or 0.0, <a name="idx:threadgetmessage3:1904"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
423 <p>If <var>Time</var> is 0 or 0.0, <a id="idx:threadgetmessage3:1908"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
383424 examines the queue but does not suspend if no matching term is
384425 available. Note that unlike
385 <a name="idx:threadpeekmessage2:1905"></a><a class="pred" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a>,
426 <a id="idx:threadpeekmessage2:1909"></a><a class="pred" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a>,
386427 a matching term is removed from the queue.
387428
388 <p>If <var>Time</var> <var>&lt; 0</var>, <a name="idx:threadgetmessage3:1906"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
429 <p>If <var>Time</var> <var>&lt; 0</var>, <a id="idx:threadgetmessage3:1910"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
389430 fails immediately without removing any message from the queue.
390431 </dd>
391432 </dl>
392433
393434 </dd>
394 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="thread_peek_message/2"><strong>thread_peek_message</strong>(<var>+Queue,
435 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="thread_peek_message/2"><strong>thread_peek_message</strong>(<var>+Queue,
395436 ?Term</var>)</a></dt>
396437 <dd class="defbody">
397 As <a name="idx:threadpeekmessage1:1907"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>,
438 As <a id="idx:threadpeekmessage1:1911"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>,
398439 operating on a given queue. It is allowed to peek into another thread's
399440 message queue, an operation that can be used to check whether a thread
400441 has swallowed a message sent to it.</dd>
401 <dt class="pubdef"><a name="message_queue_property/2"><strong>message_queue_property</strong>(<var>?Queue,
442 <dt class="pubdef"><a id="message_queue_property/2"><strong>message_queue_property</strong>(<var>?Queue,
402443 ?Property</var>)</a></dt>
403444 <dd class="defbody">
404445 True if <var>Property</var> is a property of <var>Queue</var>. Defined
412453 <dt><strong>max_size</strong>(<var>Size</var>)</dt>
413454 <dd class="defbody">
414455 Maximum number of terms that can be in the queue. See
415 <a name="idx:messagequeuecreate2:1908"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>.
456 <a id="idx:messagequeuecreate2:1912"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>.
416457 This property is not present if there is no limit (default).
417458 </dd>
418459 <dt><strong>size</strong>(<var>Size</var>)</dt>
468509 thread_send_message(Id, Goal).
469510 </pre>
470511
471 <p><h3 id="sec:thread-signal"><a name="sec:9.3.2"><span class="sec-nr">9.3.2</span> <span class="sec-title">Signalling
512 <p><h3 id="sec:thread-signal"><a id="sec:9.3.2"><span class="sec-nr">9.3.2</span> <span class="sec-title">Signalling
472513 threads</span></a></h3>
473514
474 <a name="sec:thread-signal"></a>
515 <a id="sec:thread-signal"></a>
475516
476517 <p>These predicates provide a mechanism to make another thread execute
477518 some goal as an <em>interrupt</em>. Signalling threads is safe as these
478519 interrupts are only checked at safe points in the virtual machine.
479520 Nevertheless, signalling in multithreaded environments should be handled
480 with care as the receiving thread may hold a <em>mutex</em> (see <a name="idx:withmutex2:1909"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>).
521 with care as the receiving thread may hold a <em>mutex</em> (see <a id="idx:withmutex2:1913"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>).
481522 Signalling probably only makes sense to start debugging threads and to
482 cancel no-longer-needed threads with <a name="idx:throw1:1910"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
523 cancel no-longer-needed threads with <a id="idx:throw1:1914"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
483524 where the receiving thread should be designed carefully to handle
484525 exceptions at any point.
485526
486527 <dl class="latex">
487 <dt class="pubdef"><a name="thread_signal/2"><strong>thread_signal</strong>(<var>+ThreadId,
528 <dt class="pubdef"><a id="thread_signal/2"><strong>thread_signal</strong>(<var>+ThreadId,
488529 :Goal</var>)</a></dt>
489530 <dd class="defbody">
490531 Make thread <var>ThreadId</var> execute <var>Goal</var> at the first
491532 opportunity. In the current implementation, this implies at the first
492 pass through the <em>Call port</em>. The predicate <a name="idx:threadsignal2:1911"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>
533 pass through the <em>Call port</em>. The predicate <a id="idx:threadsignal2:1915"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>
493534 itself places <var>Goal</var> into the signalled thread's signal queue
494535 and returns immediately.
495536
498539 guaranteed easily. At the call port, the Prolog virtual machine holds no
499540 locks and therefore the asynchronous execution is safe.
500541
501 <p><var>Goal</var> can be any valid Prolog goal, including <a name="idx:throw1:1912"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
502 to make the receiving thread generate an exception, and <a name="idx:trace0:1913"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
542 <p><var>Goal</var> can be any valid Prolog goal, including <a id="idx:throw1:1916"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
543 to make the receiving thread generate an exception, and <a id="idx:trace0:1917"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
503544 to start tracing the receiving thread.
504545
505546 <p>In the Windows version, the receiving thread immediately executes the
508549 </dd>
509550 </dl>
510551
511 <p><h3 id="sec:threadlocal"><a name="sec:9.3.3"><span class="sec-nr">9.3.3</span> <span class="sec-title">Threads
552 <p><h3 id="sec:threadlocal"><a id="sec:9.3.3"><span class="sec-nr">9.3.3</span> <span class="sec-title">Threads
512553 and dynamic predicates</span></a></h3>
513554
514 <a name="sec:threadlocal"></a>
515
516 <p>Besides queues (<a class="sec" href="threadcom.html">section 9.3.1</a>)
517 threads can share and exchange data using dynamic predicates. The
518 multithreaded version knows about two types of dynamic predicates. By
519 default, a predicate declared
520 <em>dynamic</em> (see <a name="idx:dynamic1:1914"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>)
555 <a id="sec:threadlocal"></a>
556
557 <p>Besides queues (<a class="sec" href="threadcom.html#sec:9.3.1">section
558 9.3.1</a>) threads can share and exchange data using dynamic predicates.
559 The multithreaded version knows about two types of dynamic predicates.
560 By default, a predicate declared
561 <em>dynamic</em> (see <a id="idx:dynamic1:1918"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>)
521562 is shared by all threads. Each thread may assert, retract and run the
522563 dynamic predicate. Synchronisation inside Prolog guarantees the
523564 consistency of the predicate. Updates are
524565 <em>logical</em>: visible clauses are not affected by assert/retract
525566 after a query started on the predicate. In many cases primitives from
526 <a class="sec" href="threadsync.html">section 9.4</a> should be used to
527 ensure that application invariants on the predicate are maintained.
567 <a class="sec" href="threadsync.html#sec:9.4">section 9.4</a> should be
568 used to ensure that application invariants on the predicate are
569 maintained.
528570
529571 <p>Besides shared predicates, dynamic predicates can be declared with
530572 the
531 <a name="idx:threadlocal1:1915"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>
573 <a id="idx:threadlocal1:1919"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>
532574 directive. Such predicates share their attributes, but the clause list
533575 is different in each thread.
534576
535577 <dl class="latex">
536 <dt class="pubdef"><a name="thread_local/1"><strong>thread_local</strong> <var>+Functor/+Arity,
578 <dt class="pubdef"><a id="thread_local/1"><strong>thread_local</strong> <var>+Functor/+Arity,
537579 ...</var></a></dt>
538580 <dd class="defbody">
539 This directive is related to the <a name="idx:dynamic1:1916"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
540 directive. It tells the system that the predicate may be modified using <a name="idx:assert1:1917"></a><a class="pred" href="db.html#assert/1">assert/1</a>, <a name="idx:retract1:1918"></a><a class="pred" href="db.html#retract/1">retract/1</a>,
581 This directive is related to the <a id="idx:dynamic1:1920"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
582 directive. It tells the system that the predicate may be modified using <a id="idx:assert1:1921"></a><a class="pred" href="db.html#assert/1">assert/1</a>, <a id="idx:retract1:1922"></a><a class="pred" href="db.html#retract/1">retract/1</a>,
541583 etc., during execution of the program. Unlike normal shared dynamic
542584 data, however, each thread has its own clause list for the predicate. As
543585 a thread starts, this clause list is empty. If there are still clauses
544586 when the thread terminates, these are automatically reclaimed by the
545 system (see also <a name="idx:volatile1:1919"></a><a class="pred" href="runtime.html#volatile/1">volatile/1</a>).
587 system (see also <a id="idx:volatile1:1923"></a><a class="pred" href="runtime.html#volatile/1">volatile/1</a>).
546588 The thread_local property implies the properties <em>dynamic</em> and <em>volatile</em>.
547589
548590 <p>Thread-local dynamic predicates are intended for maintaining
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 9.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="threads.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="thmonitor.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:threadcreate"><a name="sec:9.1"><span class="sec-nr">9.1</span> <span class="sec-title">Creating
235 <h2 id="sec:threadcreate"><a id="sec:9.1"><span class="sec-nr">9.1</span> <span class="sec-title">Creating
195236 and destroying Prolog threads</span></a></h2>
196237
197 <a name="sec:threadcreate"></a>
238 <a id="sec:threadcreate"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="thread_create/2"><strong>thread_create</strong>(<var>:Goal,
241 <dt class="pubdef"><a id="thread_create/2"><strong>thread_create</strong>(<var>:Goal,
201242 -Id</var>)</a></dt>
202243 <dd class="defbody">
203 Shorthand for <code>thread_create(Goal, Id, [])</code>. See <a name="idx:threadcreate3:1827"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>.</dd>
204 <dt class="pubdef"><a name="thread_create/3"><strong>thread_create</strong>(<var>:Goal,
244 Shorthand for <code>thread_create(Goal, Id, [])</code>. See <a id="idx:threadcreate3:1831"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>.</dd>
245 <dt class="pubdef"><a id="thread_create/3"><strong>thread_create</strong>(<var>:Goal,
205246 -Id, +Options</var>)</a></dt>
206247 <dd class="defbody">
207248 Create a new Prolog thread (and underlying operating system thread) and
212253 is given. Otherwise it is a <em>blob</em> of type <code>thread</code>.
213254 The anonymous blobs are subject to atom garbage collection. If a thread
214255 handle is garbage collected and the thread is not <em>detached</em>, it
215 is <em>joined</em> if it has already terminated (see <a name="idx:threadjoin2:1828"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>)
216 and detached otherwise (see <a name="idx:threaddetach1:1829"></a><a class="pred" href="threadcreate.html#thread_detach/1">thread_detach/1</a>).<sup class="fn">156<span class="fn-text">Up
256 is <em>joined</em> if it has already terminated (see <a id="idx:threadjoin2:1832"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>)
257 and detached otherwise (see <a id="idx:threaddetach1:1833"></a><a class="pred" href="threadcreate.html#thread_detach/1">thread_detach/1</a>).<sup class="fn">157<span class="fn-text">Up
217258 to version 7.3.23, anonymous thread handles were integers. Using
218259 integers did not allow for safe checking of the thread's status as the
219260 thread may have died and the handle may have been reused and did not
222263 where <var>I</var> is the internal thread identifier and <var>Ptr</var>
223264 is the unique address of the identifier. The <var>I</var> is accepted as
224265 input argument for all thread APIs that accept a thread identifier for
225 convenient interaction from the toplevel. See also <a name="idx:threadproperty2:1830"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
266 convenient interaction from the toplevel. See also <a id="idx:threadproperty2:1834"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
226267
227268 <p><var>Options</var> is a list of options. The currently defined
228269 options are below. Stack size options can also take the value <code>inf</code>
235276 <dd class="defbody">
236277 Associate an `alias name' with the thread. This name may be used to
237278 refer to the thread and remains valid until the thread is joined (see
238 <a name="idx:threadjoin2:1831"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>).
279 <a id="idx:threadjoin2:1835"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>).
239280 If the OS supports it (e.g., Linux), the operating system thread is
240281 named as well.</dd>
241282 <dt><strong>at_exit</strong>(<var>:AtExit</var>)</dt>
242283 <dd class="defbody">
243 Register <var>AtExit</var> as using <a name="idx:threadatexit1:1832"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
244 before entering the thread goal. Unlike calling <a name="idx:threadatexit1:1833"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
284 Register <var>AtExit</var> as using <a id="idx:threadatexit1:1836"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
285 before entering the thread goal. Unlike calling <a id="idx:threadatexit1:1837"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
245286 as part of the normal
246287 <var>Goal</var>, this <em>ensures</em> the <var>AtExit</var> is called.
247288 Using
248 <a name="idx:threadatexit1:1834"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>,
249 the thread may be signalled or run out of resources before <a name="idx:threadatexit1:1835"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
289 <a id="idx:threadatexit1:1838"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>,
290 the thread may be signalled or run out of resources before <a id="idx:threadatexit1:1839"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
250291 is reached.</dd>
251292 <dt><strong>debug</strong>(<var>+Bool</var>)</dt>
252293 <dd class="defbody">
253294 Enable/disable debugging the new thread. If <code>false</code> (default
254295 <code>true</code>), the new thread is created with the property
255296 <code>debug(false)</code> and debugging is disabled before the new
256 thread is started. The thread debugging predicates such as <a name="idx:tspy1:1836"></a><a class="pred" href="thutil.html#tspy/1">tspy/1</a>
257 and <a name="idx:tdebug0:1837"></a><a class="pred" href="thutil.html#tdebug/0">tdebug/0</a>
297 thread is started. The thread debugging predicates such as <a id="idx:tspy1:1840"></a><a class="pred" href="thutil.html#tspy/1">tspy/1</a>
298 and <a id="idx:tdebug0:1841"></a><a class="pred" href="thutil.html#tdebug/0">tdebug/0</a>
258299 do not signal threads with the debug property set to
259 <code>false</code>.<sup class="fn">157<span class="fn-text">Currently,
300 <code>false</code>.<sup class="fn">158<span class="fn-text">Currently,
260301 the flag is only used as a hint for the the various debugging
261302 primitives, i.e., the system does not really enforce that the target
262303 thread stays in <em>nodebug</em> mode.</span></sup></dd>
263304 <dt><strong>detached</strong>(<var>Bool</var>)</dt>
264305 <dd class="defbody">
265306 If <code>false</code> (default), the thread can be waited for using
266 <a name="idx:threadjoin2:1838"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>. <a name="idx:threadjoin2:1839"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
307 <a id="idx:threadjoin2:1842"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>. <a id="idx:threadjoin2:1843"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
267308 must be called on this thread to reclaim all resources associated with
268309 the thread. If <code>true</code>, the system will reclaim all associated
269310 resources automatically after the thread finishes. Please note that
270311 thread identifiers are freed for reuse after a detached thread finishes
271 or a normal thread has been joined. See also <a name="idx:threadjoin2:1840"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
272 and <a name="idx:threaddetach1:1841"></a><a class="pred" href="threadcreate.html#thread_detach/1">thread_detach/1</a>.
312 or a normal thread has been joined. See also <a id="idx:threadjoin2:1844"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
313 and <a id="idx:threaddetach1:1845"></a><a class="pred" href="threadcreate.html#thread_detach/1">thread_detach/1</a>.
273314
274315 <p>If a detached thread dies due to failure or exception of the initial
275 goal, the thread prints a message using <a name="idx:printmessage2:1842"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
316 goal, the thread prints a message using <a id="idx:printmessage2:1846"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
276317 If such termination is considered normal, the code must be wrapped using
277 <a name="idx:ignore1:1843"></a><a class="pred" href="metacall.html#ignore/1">ignore/1</a>
278 and/or <a name="idx:catch3:1844"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
318 <a id="idx:ignore1:1847"></a><a class="pred" href="metacall.html#ignore/1">ignore/1</a>
319 and/or <a id="idx:catch3:1848"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
279320 to ensure successful completion.</dd>
280321 <dt><strong>inherit_from</strong>(<var>+ThreadId</var>)</dt>
281322 <dd class="defbody">
282323 Inherit defaults from the given <var>ThreadId</var> instead of the
283324 calling thread. This option was added to ensure that the
284 <code>__thread_pool_manager</code> (see <a name="idx:threadcreateinpool4:1845"></a><a class="pred" href="threadpool.html#thread_create_in_pool/4">thread_create_in_pool/4</a>),
325 <code>__thread_pool_manager</code> (see <a id="idx:threadcreateinpool4:1849"></a><a class="pred" href="threadpool.html#thread_create_in_pool/4">thread_create_in_pool/4</a>),
285326 which is created lazily, has a predictable state. The following
286327 properties are inherited:
287328
288329 <p>
289330 <ul class="latex">
290 <li>The prompt (see <a name="idx:prompt2:1846"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>)
291 <li>The <em>typein</em> module (see <a name="idx:module1:1847"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>)
331 <li>The prompt (see <a id="idx:prompt2:1850"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>)
332 <li>The <em>typein</em> module (see <a id="idx:module1:1851"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>)
292333 <li>The standard streams (<code>user_input</code>, etc.)
293334 <li>The default encoding (see <a class="flag" href="flags.html#flag:encoding">encoding</a>)
294 <li>The default locale (see <a name="idx:setlocale1:1848"></a><span class="pred-ext">setlocale/1</span>)
335 <li>The default locale (see <a id="idx:setlocale1:1852"></a><span class="pred-ext">setlocale/1</span>)
295336 <li>All prolog flags
296 <li>The limits of Prolog stacks (see <a name="idx:setprologstack2:1849"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>)
337 <li>The limits of Prolog stacks (see <a id="idx:setprologstack2:1853"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>)
297338 </ul>
298339 </dd>
299340 <dt><strong>global</strong>(<var>K-Bytes</var>)</dt>
309350 <dt><strong>c_stack</strong>(<var>K-Bytes</var>)</dt>
310351 <dd class="defbody">
311352 Set the limit to which the system stack of this thread may grow. The
312 default, minimum and maximum values are system-dependent.<sup class="fn">158<span class="fn-text">Older
353 default, minimum and maximum values are system-dependent.<sup class="fn">159<span class="fn-text">Older
313354 versions used <code>stack</code>. This is still accepted as a synonym.</span></sup></dd>
314355 <dt><strong>trail</strong>(<var>K-Bytes</var>)</dt>
315356 <dd class="defbody">
323364 engine. This implies that further instantiation of this term in either
324365 thread does not have consequences for the other thread: Prolog threads
325366 do not share data from their stacks.</dd>
326 <dt class="pubdef"><a name="thread_self/1"><strong>thread_self</strong>(<var>-Id</var>)</a></dt>
367 <dt class="pubdef"><a id="thread_self/1"><strong>thread_self</strong>(<var>-Id</var>)</a></dt>
327368 <dd class="defbody">
328369 Get the Prolog thread identifier of the running thread. If the thread
329370 has an alias, the alias name is returned.</dd>
330 <dt class="pubdef"><a name="thread_join/2"><strong>thread_join</strong>(<var>+Id</var>)</a></dt>
331 <dd class="defbody">
332 Calls <a name="idx:threadjoin2:1850"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
371 <dt class="pubdef"><a id="thread_join/2"><strong>thread_join</strong>(<var>+Id</var>)</a></dt>
372 <dd class="defbody">
373 Calls <a id="idx:threadjoin2:1854"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
333374 and succeeds if thread <var>Id</var> terminated with success. Otherwise
334375 the exception
335376 <code>error(<code>thread_error(Status)</code>, _)</code> is raised.</dd>
336 <dt class="pubdef"><a name="thread_join/2"><strong>thread_join</strong>(<var>+Id,
377 <dt class="pubdef"><a id="thread_join/2"><strong>thread_join</strong>(<var>+Id,
337378 -Status</var>)</a></dt>
338379 <dd class="defbody">
339380 Wait for the termination of the thread with the given <var>Id</var>.
340381 Then unify the result status of the thread with <var>Status</var>. After
341382 this call, <var>Id</var> becomes invalid and all resources associated
342383 with the thread are reclaimed. Note that threads with the attribute
343 <code>detached(true)</code> cannot be joined. See also <a name="idx:threadproperty2:1851"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
344
345 <p>A thread that has been completed without <a name="idx:threadjoin2:1852"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
384 <code>detached(true)</code> cannot be joined. See also <a id="idx:threadproperty2:1855"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
385
386 <p>A thread that has been completed without <a id="idx:threadjoin2:1856"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
346387 being called on it is partly reclaimed: the Prolog stacks are released
347388 and the C thread is destroyed. A small data structure representing the
348 exit status of the thread is retained until <a name="idx:threadjoin2:1853"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
389 exit status of the thread is retained until <a id="idx:threadjoin2:1857"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
349390 is called on the thread. Defined values for <var>Status</var> are:
350391
351392 <dl class="latex">
357398 The goal has failed.</dd>
358399 <dt><strong>exception</strong>(<var>Term</var>)</dt>
359400 <dd class="defbody">
360 The thread is terminated on an exception. See <a name="idx:printmessage2:1854"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
401 The thread is terminated on an exception. See <a id="idx:printmessage2:1858"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
361402 to turn system exceptions into readable messages.</dd>
362403 <dt><strong>exited</strong>(<var>Term</var>)</dt>
363404 <dd class="defbody">
364 The thread is terminated on <a name="idx:threadexit1:1855"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
405 The thread is terminated on <a id="idx:threadexit1:1859"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
365406 using the argument <var>Term</var>.
366407 </dd>
367408 </dl>
368409
369410 </dd>
370 <dt class="pubdef"><a name="thread_detach/1"><strong>thread_detach</strong>(<var>+Id</var>)</a></dt>
411 <dt class="pubdef"><a id="thread_detach/1"><strong>thread_detach</strong>(<var>+Id</var>)</a></dt>
371412 <dd class="defbody">
372413 Switch thread into detached state (see <code>detached(Bool)</code>
373414 option at
374 <a name="idx:threadcreate3:1856"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>)
415 <a id="idx:threadcreate3:1860"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>)
375416 at runtime. <var>Id</var> is the identifier of the thread placed in
376 detached state. This may be the result of <a name="idx:threadself1:1857"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>.
417 detached state. This may be the result of <a id="idx:threadself1:1861"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>.
377418
378419 <p>One of the possible applications is to simplify debugging. Threads
379420 that are created as <em>detached</em> leave no traces if they crash. For
380421 non-detached threads the status can be inspected using
381 <a name="idx:threadproperty2:1858"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
422 <a id="idx:threadproperty2:1862"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
382423 Threads nobody is waiting for may be created normally and detach
383424 themselves just before completion. This way they leave no traces on
384425 normal completion and their reason for failure can be inspected.</dd>
385 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="thread_exit/1"><strong>thread_exit</strong>(<var>+Term</var>)</a></dt>
426 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="thread_exit/1"><strong>thread_exit</strong>(<var>+Term</var>)</a></dt>
386427 <dd class="defbody">
387428 Terminates the thread immediately, leaving <code>exited(Term)</code> as
388 result state for <a name="idx:threadjoin2:1859"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
429 result state for <a id="idx:threadjoin2:1863"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
389430 If the thread has the attribute
390431 <code>detached(true)</code> it terminates, but its exit status cannot be
391 retrieved using <a name="idx:threadjoin2:1860"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>,
432 retrieved using <a id="idx:threadjoin2:1864"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>,
392433 making the value of <var>Term</var> irrelevant. The Prolog stacks and C
393434 thread are reclaimed.
394435
395436 <p>The current implementation does not guarantee proper releasing of all
396 mutexes and proper cleanup in <a name="idx:setupcallcleanup3:1861"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>,
397 etc. Please use the exception mechanism (<a name="idx:throw1:1862"></a><a class="pred" href="exception.html#throw/1">throw/1</a>)
437 mutexes and proper cleanup in <a id="idx:setupcallcleanup3:1865"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>,
438 etc. Please use the exception mechanism (<a id="idx:throw1:1866"></a><a class="pred" href="exception.html#throw/1">throw/1</a>)
398439 to abort execution using non-standard control.</dd>
399 <dt class="pubdef"><a name="thread_initialization/1"><strong>thread_initialization</strong>(<var>:Goal</var>)</a></dt>
440 <dt class="pubdef"><a id="thread_initialization/1"><strong>thread_initialization</strong>(<var>:Goal</var>)</a></dt>
400441 <dd class="defbody">
401442 Run <var>Goal</var> when thread is started. This predicate is similar to
402 <a name="idx:initialization1:1863"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
443 <a id="idx:initialization1:1867"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
403444 but is intended for initialization operations of the runtime stacks,
404445 such as setting global variables as described in
405 <a class="sec" href="gvar.html">section 4.33</a>. <var>Goal</var> is run
406 on four occasions: at the call to this predicate, after loading a saved
407 state, on starting a new thread and on creating a Prolog engine through
408 the C interface. On loading a saved state, <var>Goal</var> is executed <em>after</em>
409 running the
410 <a name="idx:initialization1:1864"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
446 <a class="sec" href="gvar.html#sec:4.33">section 4.33</a>. <var>Goal</var>
447 is run on four occasions: at the call to this predicate, after loading a
448 saved state, on starting a new thread and on creating a Prolog engine
449 through the C interface. On loading a saved state, <var>Goal</var> is
450 executed <em>after</em> running the
451 <a id="idx:initialization1:1868"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
411452 hooks.</dd>
412 <dt class="pubdef"><a name="thread_at_exit/1"><strong>thread_at_exit</strong>(<var>:Goal</var>)</a></dt>
453 <dt class="pubdef"><a id="thread_at_exit/1"><strong>thread_at_exit</strong>(<var>:Goal</var>)</a></dt>
413454 <dd class="defbody">
414455 Run <var>Goal</var> just before releasing the thread resources. This is
415 to be compared to <a name="idx:athalt1:1865"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>,
456 to be compared to <a id="idx:athalt1:1869"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>,
416457 but only for the current thread. These hooks are run regardless of why
417458 the execution of the thread has been completed. When these hooks are
418459 run, the return code is already available through
419 <a name="idx:threadproperty2:1866"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>
420 using the result of <a name="idx:threadself1:1867"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>
460 <a id="idx:threadproperty2:1870"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>
461 using the result of <a id="idx:threadself1:1871"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>
421462 as thread identifier. Note that there are two scenarios for using exit
422 hooks. Using <a name="idx:threadatexit1:1868"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
463 hooks. Using <a id="idx:threadatexit1:1872"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
423464 is typically used if the thread creates a side-effect that must be
424465 reverted if the thread dies. Another scenario is where the creator of
425466 the thread wants to be informed when the thread ends. That cannot be
426 guaranteed by means of <a name="idx:threadatexit1:1869"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
467 guaranteed by means of <a id="idx:threadatexit1:1873"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
427468 because it is possible that the thread cannot be created or dies almost
428469 instantly due to a signal or resource error. The <code>at_exit(Goal)</code>
429470 option of
430 <a name="idx:threadcreate3:1870"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
471 <a id="idx:threadcreate3:1874"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
431472 is designed to deal with this scenario.</dd>
432 <dt class="pubdef"><a name="thread_setconcurrency/2"><strong>thread_setconcurrency</strong>(<var>-Old,
473 <dt class="pubdef"><a id="thread_setconcurrency/2"><strong>thread_setconcurrency</strong>(<var>-Old,
433474 +New</var>)</a></dt>
434475 <dd class="defbody">
435 <a name="idx:Solaris:1871"></a>Determine the concurrency of the process,
476 <a id="idx:Solaris:1875"></a>Determine the concurrency of the process,
436477 which is defined as the maximum number of concurrently active threads.
437478 `Active' here means they are using CPU time. This option is provided if
438479 the thread implementation provides pthread_setconcurrency(). Solaris is
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.36</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.36</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="tabling.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="ugraphs.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:threadpool"><a name="sec:A.36"><span class="sec-nr">A.36</span> <span class="sec-title">library(thread_pool):
235 <h2 id="sec:threadpool"><a id="sec:A.36"><span class="sec-nr">A.36</span> <span class="sec-title">library(thread_pool):
195236 Resource bounded thread management</span></a></h2>
196237
197 <p><a name="sec:threadpool"></a>
238 <p><a id="sec:threadpool"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">See also</dt>
237278 directive or otherwise during startup of the application.
238279
239280 <dl class="latex">
240 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="thread_pool_create/3"><strong>thread_pool_create</strong>(<var>+Pool,
281 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="thread_pool_create/3"><strong>thread_pool_create</strong>(<var>+Pool,
241282 +Size, +Options</var>)</a></dt>
242283 <dd class="defbody">
243284 Create a pool of threads. A pool of threads is a declaration for
264305 state of a thread. Threads can be created both <code>detached</code> and
265306 normal and must be joined using <a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
266307 if they are not detached.</dd>
267 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="thread_pool_destroy/1"><strong>thread_pool_destroy</strong>(<var>+Name</var>)</a></dt>
308 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="thread_pool_destroy/1"><strong>thread_pool_destroy</strong>(<var>+Name</var>)</a></dt>
268309 <dd class="defbody">
269310 Destroy the thread pool named <var>Name</var>.
270311
276317 </dl>
277318
278319 </dd>
279 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_thread_pool/1"><strong>current_thread_pool</strong>(<var>?Name</var>)</a></dt>
320 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_thread_pool/1"><strong>current_thread_pool</strong>(<var>?Name</var>)</a></dt>
280321 <dd class="defbody">
281322 True if <var>Name</var> refers to a defined thread pool.</dd>
282 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="thread_pool_property/2"><strong>thread_pool_property</strong>(<var>?Name,
323 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="thread_pool_property/2"><strong>thread_pool_property</strong>(<var>?Name,
283324 ?Property</var>)</a></dt>
284325 <dd class="defbody">
285326 True if <var>Property</var> is a property of thread pool <var>Name</var>.
313354 </dl>
314355
315356 </dd>
316 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="thread_create_in_pool/4"><strong>thread_create_in_pool</strong>(<var>+Pool,
357 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="thread_create_in_pool/4"><strong>thread_create_in_pool</strong>(<var>+Pool,
317358 :Goal, -Id, +Options</var>)</a></dt>
318359 <dd class="defbody">
319360 Create a thread in <var>Pool</var>. <var>Options</var> overrule default
339380 </dl>
340381
341382 </dd>
342 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="create_pool/1"><strong>create_pool</strong>(<var>+PoolName</var>)</a></dt>
383 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="create_pool/1"><strong>create_pool</strong>(<var>+PoolName</var>)</a></dt>
343384 <dd class="defbody">
344385 Hook to create a thread pool lazily. The hook is called if
345386 <a class="pred" href="threadpool.html#thread_create_in_pool/4">thread_create_in_pool/4</a>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="errors.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="threadcreate.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h1 id="sec:threads"><a name="sec:9"><span class="sec-nr">9</span> <span class="sec-title">Multithreaded
235 <h1 id="sec:threads"><a id="sec:9"><span class="sec-nr">9</span> <span class="sec-title">Multithreaded
195236 applications</span></a></h1>
196237
197 <a name="sec:threads"></a>
238 <a id="sec:threads"></a>
198239
199240 <p>SWI-Prolog multithreading is based on standard C language
200241 multithreading support. It is not like <em>ParLog</em> or other parallel
210251 applications. Such applications often have need for communication
211252 between services and/or fast non-blocking service to multiple concurrent
212253 clients. The shared heap provides fast communication, and thread
213 creation is relatively cheap.<sup class="fn">154<span class="fn-text">On
254 creation is relatively cheap.<sup class="fn">155<span class="fn-text">On
214255 an Intel i7-2600K, running Ubuntu Linux 12.04, SWI-Prolog 6.2 creates
215256 and joins 32,000 threads per second elapsed time.</span></sup>
216257
220261 such computations are executed in a new thread, the main thread can
221262 process events and allow the user to cancel the ongoing computation.
222263 User interfaces can also use multiple threads, each thread dealing with
223 input from a distinct group of windows. See also <a class="sec" href="mt-xpce.html">section
264 input from a distinct group of windows. See also <a class="sec" href="mt-xpce.html#sec:9.7">section
224265 9.7</a>.
225266
226267 <p>
235276 <cite><a class="cite" href="Bibliography.html#Butenhof:1997:PPT">Butenhof,
236277 1997</a></cite> used on most popular systems except for MS-Windows. On
237278 Windows it uses the
238 http://sources.redhat.com/pthreads-win32/pthread-win32 emulation of
239 POSIX threads mixed with the Windows native API for smoother and faster
240 operation. The SWI-Prolog thread implementation has been discussed in
241 the ISO WG17 working group and is largely addopted by YAP and XSB
242 Prolog.<sup class="fn">155<span class="fn-text">The latest version of
243 the ISO draft can be found at <a class="url" href="http://logtalk.org/plstd/threads.pdf">http://logtalk.org/plstd/threads.pdf</a>.
279 <a class="url" href="http://sources.redhat.com/pthreads-win32/">pthread-win32</a>
280 emulation of POSIX threads mixed with the Windows native API for
281 smoother and faster operation. The SWI-Prolog thread implementation has
282 been discussed in the ISO WG17 working group and is largely addopted by
283 YAP and XSB Prolog.<sup class="fn">156<span class="fn-text">The latest
284 version of the ISO draft can be found at <a class="url" href="http://logtalk.org/plstd/threads.pdf">http://logtalk.org/plstd/threads.pdf</a>.
244285 It appears to have dropped from the ISO WG17 agenda.</span></sup>
245286
246287 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 9.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.4</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="threadcom.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="thutil.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:threadsync"><a name="sec:9.4"><span class="sec-nr">9.4</span> <span class="sec-title">Thread
235 <h2 id="sec:threadsync"><a id="sec:9.4"><span class="sec-nr">9.4</span> <span class="sec-title">Thread
195236 synchronisation</span></a></h2>
196237
197 <a name="sec:threadsync"></a>
238 <a id="sec:threadsync"></a>
198239
199240 <p>All internal Prolog operations are thread-safe. This implies that two
200241 Prolog threads can operate on the same dynamic predicate without
215256 assert/retract order.
216257
217258 <p>The code below provides a solution to this problem based on
218 <a name="idx:withmutex2:1920"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>.
259 <a id="idx:withmutex2:1924"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>.
219260 It also illustrates the problem of mutexes. The predicate
220 <a name="idx:withmutex2:1921"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
221 behaves as <a name="idx:once1:1922"></a><a class="pred" href="metacall.html#once/1">once/1</a>
261 <a id="idx:withmutex2:1925"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
262 behaves as <a id="idx:once1:1926"></a><a class="pred" href="metacall.html#once/1">once/1</a>
222263 with respect to the guarded goal. This means that our predicate
223264 address/2 is no longer a nice logical non-deterministic relation. This
224 could be solved by explicit locking and unlocking a mutex using <a name="idx:setupcallcleanup2:1923"></a><span class="pred-ext">setup_call_cleanup/2</span>,
265 could be solved by explicit locking and unlocking a mutex using <a id="idx:setupcallcleanup2:1927"></a><span class="pred-ext">setup_call_cleanup/2</span>,
225266 but at the risk of deadlocking the program if the choice point is left
226267 open by accident.
227268
237278 address_db(Id, Address)).
238279 </pre>
239280
240 <p>Message queues (see <a name="idx:messagequeuecreate3:1924"></a><span class="pred-ext">message_queue_create/3</span>)
281 <p>Message queues (see <a id="idx:messagequeuecreate3:1928"></a><span class="pred-ext">message_queue_create/3</span>)
241282 often provide simpler and more robust ways for threads to communicate.
242283 Still, mutexes can be a sensible solution and are therefore provided.
243284
244285 <dl class="latex">
245 <dt class="pubdef"><a name="mutex_create/1"><strong>mutex_create</strong>(<var>?MutexId</var>)</a></dt>
286 <dt class="pubdef"><a id="mutex_create/1"><strong>mutex_create</strong>(<var>?MutexId</var>)</a></dt>
246287 <dd class="defbody">
247288 Create a mutex. If <var>MutexId</var> is an atom, a <em>named</em> mutex
248289 is created. If it is a variable, an anonymous mutex reference is
249290 returned. Anonymous mutexes are subject to (atom) garbage collection.</dd>
250 <dt class="pubdef"><a name="mutex_create/2"><strong>mutex_create</strong>(<var>-MutexId,
291 <dt class="pubdef"><a id="mutex_create/2"><strong>mutex_create</strong>(<var>-MutexId,
251292 +Options</var>)</a></dt>
252293 <dd class="defbody">
253294 Create a mutex using options. Defined options are:
261302 </dl>
262303
263304 </dd>
264 <dt class="pubdef"><a name="mutex_destroy/1"><strong>mutex_destroy</strong>(<var>+MutexId</var>)</a></dt>
305 <dt class="pubdef"><a id="mutex_destroy/1"><strong>mutex_destroy</strong>(<var>+MutexId</var>)</a></dt>
265306 <dd class="defbody">
266307 Destroy a mutex. If the mutex is not locked, it is destroyed and further
267308 access yields an <code>existence_error</code> exception. As of version
268309 7.1.19, this behaviour is reliable. If the mutex is locked, the mutex is
269310 sheduled for <em>delayed destruction</em>: it will be destroyed when it
270311 becomes unlocked.</dd>
271 <dt class="pubdef"><a name="with_mutex/2"><strong>with_mutex</strong>(<var>+MutexId,
312 <dt class="pubdef"><a id="with_mutex/2"><strong>with_mutex</strong>(<var>+MutexId,
272313 :Goal</var>)</a></dt>
273314 <dd class="defbody">
274315 Execute <var>Goal</var> while holding <var>MutexId</var>. If <var>Goal</var>
275 leaves choice points, these are destroyed (as in <a name="idx:once1:1925"></a><a class="pred" href="metacall.html#once/1">once/1</a>).
316 leaves choice points, these are destroyed (as in <a id="idx:once1:1929"></a><a class="pred" href="metacall.html#once/1">once/1</a>).
276317 The mutex is unlocked regardless of whether <var>Goal</var> succeeds,
277318 fails or raises an exception. An exception thrown by <var>Goal</var> is
278 re-thrown after the mutex has been successfully unlocked. See also <a name="idx:mutexcreate1:1926"></a><a class="pred" href="threadsync.html#mutex_create/1">mutex_create/1</a>
279 and <a name="idx:setupcallcleanup3:1927"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>.
319 re-thrown after the mutex has been successfully unlocked. See also <a id="idx:mutexcreate1:1930"></a><a class="pred" href="threadsync.html#mutex_create/1">mutex_create/1</a>
320 and <a id="idx:setupcallcleanup3:1931"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>.
280321
281322 <p>Although described in the thread section, this predicate is also
282323 available in the single-threaded version, where it behaves simply as
283 <a name="idx:once1:1928"></a><a class="pred" href="metacall.html#once/1">once/1</a>.</dd>
284 <dt class="pubdef"><a name="mutex_lock/1"><strong>mutex_lock</strong>(<var>+MutexId</var>)</a></dt>
324 <a id="idx:once1:1932"></a><a class="pred" href="metacall.html#once/1">once/1</a>.</dd>
325 <dt class="pubdef"><a id="mutex_lock/1"><strong>mutex_lock</strong>(<var>+MutexId</var>)</a></dt>
285326 <dd class="defbody">
286327 Lock the mutex. Prolog mutexes are <em>recursive</em> mutexes: they can
287328 be locked multiple times by the same thread. Only after unlocking it as
290331 thread is suspended until the mutex is unlocked.
291332
292333 <p>If <var>MutexId</var> is an atom, and there is no current mutex with
293 that name, the mutex is created automatically using <a name="idx:mutexcreate1:1929"></a><a class="pred" href="threadsync.html#mutex_create/1">mutex_create/1</a>.
334 that name, the mutex is created automatically using <a id="idx:mutexcreate1:1933"></a><a class="pred" href="threadsync.html#mutex_create/1">mutex_create/1</a>.
294335 This implies named mutexes need not be declared explicitly.
295336
296337 <p>Please note that locking and unlocking mutexes should be paired
297338 carefully. Especially make sure to unlock mutexes even if the protected
298339 code fails or raises an exception. For most common cases, use
299 <a name="idx:withmutex2:1930"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>,
340 <a id="idx:withmutex2:1934"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>,
300341 which provides a safer way for handling Prolog-level mutexes. The
301 predicate <a name="idx:setupcallcleanup3:1931"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
342 predicate <a id="idx:setupcallcleanup3:1935"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
302343 is another way to guarantee that the mutex is unlocked while retaining
303344 non-determinism.</dd>
304 <dt class="pubdef"><a name="mutex_trylock/1"><strong>mutex_trylock</strong>(<var>+MutexId</var>)</a></dt>
305 <dd class="defbody">
306 As <a name="idx:mutexlock1:1932"></a><a class="pred" href="threadsync.html#mutex_lock/1">mutex_lock/1</a>,
345 <dt class="pubdef"><a id="mutex_trylock/1"><strong>mutex_trylock</strong>(<var>+MutexId</var>)</a></dt>
346 <dd class="defbody">
347 As <a id="idx:mutexlock1:1936"></a><a class="pred" href="threadsync.html#mutex_lock/1">mutex_lock/1</a>,
307348 but if the mutex is held by another thread, this predicates fails
308349 immediately.</dd>
309 <dt class="pubdef"><a name="mutex_unlock/1"><strong>mutex_unlock</strong>(<var>+MutexId</var>)</a></dt>
350 <dt class="pubdef"><a id="mutex_unlock/1"><strong>mutex_unlock</strong>(<var>+MutexId</var>)</a></dt>
310351 <dd class="defbody">
311352 Unlock the mutex. This can only be called if the mutex is held by the
312353 calling thread. If this is not the case, a <code>permission_error</code>
313354 exception is raised.</dd>
314 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="mutex_unlock_all/0"><strong>mutex_unlock_all</strong></a></dt>
355 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="mutex_unlock_all/0"><strong>mutex_unlock_all</strong></a></dt>
315356 <dd class="defbody">
316357 Unlock all mutexes held by the current thread. This predicate should not
317 be needed if mutex unlocking is guaranteed with <a name="idx:withmutex2:1933"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
358 be needed if mutex unlocking is guaranteed with <a id="idx:withmutex2:1937"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
318359 or
319 <a name="idx:setupcallcleanup3:1934"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>.<sup class="fn">164<span class="fn-text">The
320 also deprecated <a name="idx:threadexit1:1935"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
360 <a id="idx:setupcallcleanup3:1938"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>.<sup class="fn">165<span class="fn-text">The
361 also deprecated <a id="idx:threadexit1:1939"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
321362 bypasses the automatic cleanup.</span></sup></dd>
322 <dt class="pubdef"><a name="mutex_property/2"><strong>mutex_property</strong>(<var>?MutexId,
363 <dt class="pubdef"><a id="mutex_property/2"><strong>mutex_property</strong>(<var>?MutexId,
323364 ?Property</var>)</a></dt>
324365 <dd class="defbody">
325366 True if <var>Property</var> is a property of <var>MutexId</var>. Defined
328369 <dl class="latex">
329370 <dt><strong>alias</strong>(<var>Alias</var>)</dt>
330371 <dd class="defbody">
331 Mutex has the defined alias name. See <a name="idx:mutexcreate2:1936"></a><a class="pred" href="threadsync.html#mutex_create/2">mutex_create/2</a>
372 Mutex has the defined alias name. See <a id="idx:mutexcreate2:1940"></a><a class="pred" href="threadsync.html#mutex_create/2">mutex_create/2</a>
332373 using the `alias' option.</dd>
333374 <dt><strong>status</strong>(<var>Status</var>)</dt>
334375 <dd class="defbody">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 9.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.5</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="threadsync.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="foreignthread.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:thutil"><a name="sec:9.5"><span class="sec-nr">9.5</span> <span class="sec-title">Thread
235 <h2 id="sec:thutil"><a id="sec:9.5"><span class="sec-nr">9.5</span> <span class="sec-title">Thread
195236 support library(threadutil)</span></a></h2>
196237
197 <a name="sec:thutil"></a>
238 <a id="sec:thutil"></a>
198239
199240 <p>This library defines a couple of useful predicates for demonstrating
200241 and debugging multithreaded applications. This library is certainly not
201242 complete.
202243
203244 <dl class="latex">
204 <dt class="pubdef"><a name="threads/0"><strong>threads</strong></a></dt>
245 <dt class="pubdef"><a id="threads/0"><strong>threads</strong></a></dt>
205246 <dd class="defbody">
206247 Lists all current threads and their status.</dd>
207 <dt class="pubdef"><a name="join_threads/0"><strong>join_threads</strong></a></dt>
248 <dt class="pubdef"><a id="join_threads/0"><strong>join_threads</strong></a></dt>
208249 <dd class="defbody">
209250 Join all terminated threads. For normal applications, dealing with
210251 terminated threads must be part of the application logic, either
211252 detaching the thread before termination or making sure it will be
212 joined. The predicate <a name="idx:jointhreads0:1937"></a><a class="pred" href="thutil.html#join_threads/0">join_threads/0</a>
253 joined. The predicate <a id="idx:jointhreads0:1941"></a><a class="pred" href="thutil.html#join_threads/0">join_threads/0</a>
213254 is intended for interactive sessions to reclaim resources from threads
214255 that died unexpectedly during development.</dd>
215 <dt class="pubdef"><a name="interactor/0"><strong>interactor</strong></a></dt>
256 <dt class="pubdef"><a id="interactor/0"><strong>interactor</strong></a></dt>
216257 <dd class="defbody">
217258 Create a new console and run the Prolog top level in this new console.
218 See also <a name="idx:attachconsole0:1938"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.
259 See also <a id="idx:attachconsole0:1942"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.
219260 In the Windows version a new interactor can also be created from the <b>Run/New
220261 thread</b> menu.
221262 </dd>
222263 </dl>
223264
224 <p><h3 id="sec:threaddebug"><a name="sec:9.5.1"><span class="sec-nr">9.5.1</span> <span class="sec-title">Debugging
265 <p><h3 id="sec:threaddebug"><a id="sec:9.5.1"><span class="sec-nr">9.5.1</span> <span class="sec-title">Debugging
225266 threads</span></a></h3>
226267
227 <a name="sec:threaddebug"></a>
268 <a id="sec:threaddebug"></a>
228269
229270 <p>Support for debugging threads is still very limited. Debug and trace
230271 mode are flags that are local to each thread. Individual threads can be
231272 debugged either using the graphical debugger described in
232 <a class="sec" href="guitracer.html">section 3.5</a> (see <a name="idx:tspy1:1939"></a><a class="pred" href="thutil.html#tspy/1">tspy/1</a>
273 <a class="sec" href="guitracer.html#sec:3.5">section 3.5</a> (see <a id="idx:tspy1:1943"></a><a class="pred" href="thutil.html#tspy/1">tspy/1</a>
233274 and friends) or by attaching a console to the thread and running the
234275 traditional command line debugger (see
235 <a name="idx:attachconsole0:1940"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>).
276 <a id="idx:attachconsole0:1944"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>).
236277 When using the graphical debugger, the debugger must be <em>loaded</em>
237 from the main thread (for example using guitracer) before <a name="idx:gtrace0:1941"></a><a class="pred" href="guitracer.html#gtrace/0">gtrace/0</a>
278 from the main thread (for example using guitracer) before <a id="idx:gtrace0:1945"></a><a class="pred" href="guitracer.html#gtrace/0">gtrace/0</a>
238279 can be called from a thread.
239280
240281 <dl class="latex">
241 <dt class="pubdef"><a name="attach_console/0"><strong>attach_console</strong></a></dt>
282 <dt class="pubdef"><a id="attach_console/0"><strong>attach_console</strong></a></dt>
242283 <dd class="defbody">
243284 If the current thread has no console attached yet, attach one and
244285 redirect the user streams (input, output, and error) to the new console
256297 </pre>
257298
258299 </dd>
259 <dt class="pubdef"><a name="tdebug/1"><strong>tdebug</strong>(<var>+ThreadId</var>)</a></dt>
300 <dt class="pubdef"><a id="tdebug/1"><strong>tdebug</strong>(<var>+ThreadId</var>)</a></dt>
260301 <dd class="defbody">
261302 Prepare <var>ThreadId</var> for debugging using the graphical tracer.
262303 This implies installing the tracer hooks in the thread and switching the
263 thread to debug mode using <a name="idx:debug0:1942"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.
264 The call is injected into the thread using <a name="idx:threadsignal2:1943"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.
304 thread to debug mode using <a id="idx:debug0:1946"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.
305 The call is injected into the thread using <a id="idx:threadsignal2:1947"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.
265306 We refer to the documentation of this predicate for asynchronous
266307 interaction with threads. New threads created inherit their debug mode
267308 from the thread that created them.</dd>
268 <dt class="pubdef"><a name="tdebug/0"><strong>tdebug</strong></a></dt>
269 <dd class="defbody">
270 Call <a name="idx:tdebug1:1944"></a><a class="pred" href="thutil.html#tdebug/1">tdebug/1</a>
309 <dt class="pubdef"><a id="tdebug/0"><strong>tdebug</strong></a></dt>
310 <dd class="defbody">
311 Call <a id="idx:tdebug1:1948"></a><a class="pred" href="thutil.html#tdebug/1">tdebug/1</a>
271312 in all running threads.</dd>
272 <dt class="pubdef"><a name="tnodebug/1"><strong>tnodebug</strong>(<var>+ThreadId</var>)</a></dt>
313 <dt class="pubdef"><a id="tnodebug/1"><strong>tnodebug</strong>(<var>+ThreadId</var>)</a></dt>
273314 <dd class="defbody">
274315 Disable debugging thread <var>ThreadId</var>.</dd>
275 <dt class="pubdef"><a name="tnodebug/0"><strong>tnodebug</strong></a></dt>
316 <dt class="pubdef"><a id="tnodebug/0"><strong>tnodebug</strong></a></dt>
276317 <dd class="defbody">
277318 Disable debugging in all threads.</dd>
278 <dt class="pubdef"><a name="tspy/2"><strong>tspy</strong>(<var>:Spec,
319 <dt class="pubdef"><a id="tspy/2"><strong>tspy</strong>(<var>:Spec,
279320 +ThreadId</var>)</a></dt>
280321 <dd class="defbody">
281 Set a spy point as <a name="idx:spy1:1945"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
322 Set a spy point as <a id="idx:spy1:1949"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
282323 and enable the thread for debugging using
283 <a name="idx:tdebug1:1946"></a><a class="pred" href="thutil.html#tdebug/1">tdebug/1</a>.
324 <a id="idx:tdebug1:1950"></a><a class="pred" href="thutil.html#tdebug/1">tdebug/1</a>.
284325 Note that a spy point is a global flag on a predicate that is visible
285326 from all threads. Spy points are honoured in all threads that are in
286327 debug mode and ignored in threads that are in nodebug mode.</dd>
287 <dt class="pubdef"><a name="tspy/1"><strong>tspy</strong>(<var>:Spec</var>)</a></dt>
288 <dd class="defbody">
289 Set a spy point as <a name="idx:spy1:1947"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
328 <dt class="pubdef"><a id="tspy/1"><strong>tspy</strong>(<var>:Spec</var>)</a></dt>
329 <dd class="defbody">
330 Set a spy point as <a id="idx:spy1:1951"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
290331 and enable debugging in all threads using
291 <a name="idx:tdebug0:1948"></a><a class="pred" href="thutil.html#tdebug/0">tdebug/0</a>.
292 Note that removing spy points can be done using <a name="idx:nospy1:1949"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
293 Disabling spy points in a specific thread is achieved by <a name="idx:tnodebug1:1950"></a><a class="pred" href="thutil.html#tnodebug/1">tnodebug/1</a>.
332 <a id="idx:tdebug0:1952"></a><a class="pred" href="thutil.html#tdebug/0">tdebug/0</a>.
333 Note that removing spy points can be done using <a id="idx:nospy1:1953"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
334 Disabling spy points in a specific thread is achieved by <a id="idx:tnodebug1:1954"></a><a class="pred" href="thutil.html#tnodebug/1">tnodebug/1</a>.
294335 </dd>
295336 </dl>
296337
297 <p><h3 id="sec:tprofile"><a name="sec:9.5.2"><span class="sec-nr">9.5.2</span> <span class="sec-title">Profiling
338 <p><h3 id="sec:tprofile"><a id="sec:9.5.2"><span class="sec-nr">9.5.2</span> <span class="sec-title">Profiling
298339 threads</span></a></h3>
299340
300 <a name="sec:tprofile"></a>
341 <a id="sec:tprofile"></a>
301342
302343 <p>In the current implementation, at most one thread can be profiled at
303 any moment. Any thread can call <a name="idx:profile1:1951"></a><a class="pred" href="profile.html#profile/1">profile/1</a>
304 to profile the execution of some part of its code. The predicate <a name="idx:tprofile1:1952"></a><a class="pred" href="thutil.html#tprofile/1">tprofile/1</a>
344 any moment. Any thread can call <a id="idx:profile1:1955"></a><a class="pred" href="profile.html#profile/1">profile/1</a>
345 to profile the execution of some part of its code. The predicate <a id="idx:tprofile1:1956"></a><a class="pred" href="thutil.html#tprofile/1">tprofile/1</a>
305346 allows for profiling the execution of another thread until the user
306347 stops collecting profile data.
307348
308349 <dl class="latex">
309 <dt class="pubdef"><a name="tprofile/1"><strong>tprofile</strong>(<var>+ThreadId</var>)</a></dt>
350 <dt class="pubdef"><a id="tprofile/1"><strong>tprofile</strong>(<var>+ThreadId</var>)</a></dt>
310351 <dd class="defbody">
311352 Start collecting profile data in <var>ThreadId</var> and ask the user to
312353 hit
313 &lt;<var>return</var>&gt; to stop the profiler. See <a class="sec" href="profile.html">section
354 &lt;<var>return</var>&gt; to stop the profiler. See <a class="sec" href="profile.html#sec:4.41">section
314355 4.41</a> for details on the execution profiler.
315356 </dd>
316357 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.37</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.37</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="files.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="protocol.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:toplevel"><a name="sec:4.37"><span class="sec-nr">4.37</span> <span class="sec-title">User
235 <h2 id="sec:toplevel"><a id="sec:4.37"><span class="sec-nr">4.37</span> <span class="sec-title">User
195236 Top-level Manipulation</span></a></h2>
196237
197 <a name="sec:toplevel"></a>
238 <a id="sec:toplevel"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="break/0"><strong>break</strong></a></dt>
241 <dt class="pubdef"><a id="break/0"><strong>break</strong></a></dt>
201242 <dd class="defbody">
202243 Recursively start a new Prolog top level. This Prolog top level shares
203244 everything from the environment it was started in. Debugging is switched
207248 <code>end_of_file.</code> can be entered to return from the break
208249 environment. If the <strong>-t</strong> <var>toplevel</var> command line
209250 option is given, this goal is started instead of entering the default
210 interactive top level (<a name="idx:prolog0:1525"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
251 interactive top level (<a id="idx:prolog0:1525"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
211252
212253 <p>Notably the gui based versions (<b>swipl-win</b> on Windows and
213254 MacOS) provide the menu <b>Run/New thread</b> that opens a new toplevel
214255 that runs concurrently with the initial toplevel. The concurrent
215256 toplevel can be used to examine the program, in particular global
216257 dynamic predicates. It can not access <em>global variables</em> or
217 thread-local dynamic predicates (see <a name="idx:threadlocal1:1526"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>)
258 thread-local dynamic predicates (see <a id="idx:threadlocal1:1526"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>)
218259 of the main thread.</dd>
219 <dt class="pubdef"><a name="abort/0"><strong>abort</strong></a></dt>
260 <dt class="pubdef"><a id="abort/0"><strong>abort</strong></a></dt>
220261 <dd class="defbody">
221262 Abort the Prolog execution and restart the top level. If the
222263 <strong>-t</strong> <var>toplevel</var> command line option is given,
224265 level.
225266
226267 <p>Aborting is implemented by throwing the reserved exception
227 <code>'$aborted'</code>. This exception can be caught using <a name="idx:catch3:1527"></a><a class="pred" href="exception.html#catch/3">catch/3</a>,
268 <code>'$aborted'</code>. This exception can be caught using <a id="idx:catch3:1527"></a><a class="pred" href="exception.html#catch/3">catch/3</a>,
228269 but the recovery goal is wrapped with a predicate that prunes the choice
229 points of the recovery goal (i.e., as <a name="idx:once1:1528"></a><a class="pred" href="metacall.html#once/1">once/1</a>)
270 points of the recovery goal (i.e., as <a id="idx:once1:1528"></a><a class="pred" href="metacall.html#once/1">once/1</a>)
230271 and re-throws the exception. This is illustrated in the example below,
231 where we press control-C and `a'. See also <a class="sec" href="exception.html">section
272 where we press control-C and `a'. See also <a class="sec" href="exception.html#sec:4.11.1">section
232273 4.11.1</a>.
233274
234275 <pre class="code">
238279 </pre>
239280
240281 </dd>
241 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="halt/0"><strong>halt</strong></a></dt>
282 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="halt/0"><strong>halt</strong></a></dt>
242283 <dd class="defbody">
243284 Terminate Prolog execution. This is the same as <code>halt(0)</code>.
244285 See
245 <a name="idx:halt1:1529"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>
286 <a id="idx:halt1:1529"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>
246287 for details.</dd>
247 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="halt/1"><strong>halt</strong>(<var>+Status</var>)</a></dt>
288 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="halt/1"><strong>halt</strong>(<var>+Status</var>)</a></dt>
248289 <dd class="defbody">
249290 Terminate Prolog execution with <var>Status</var>. This predicate calls
250291 <a class="func" href="foreigninclude.html#PL_halt()">PL_halt()</a> which
256297 to <var>Status</var>.
257298
258299 <p>
259 <li>Call all hooks registered using <a name="idx:athalt1:1530"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>.
260 If <var>Status</var> equals 0 (zero), any of these hooks calls <a name="idx:cancelhalt1:1531"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>,
300 <li>Call all hooks registered using <a id="idx:athalt1:1530"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>.
301 If <var>Status</var> equals 0 (zero), any of these hooks calls <a id="idx:cancelhalt1:1531"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>,
261302 termination is cancelled.
262303
263304 <p>
270311
271312 <p>
272313 <ul class="latex">
273 <li>Cancel all threads, calling <a name="idx:threadatexit1:1532"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
314 <li>Cancel all threads, calling <a id="idx:threadatexit1:1532"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
274315 registered termination hooks. Threads not responding within 1 second are
275316 cancelled forcefully.
276317 <li>Flush I/O and close all streams except for standard I/O.
283324 <li>Call exit(Status) to terminate the process
284325 </ol>
285326 </dd>
286 <dt class="pubdef"><a name="prolog/0"><strong>prolog</strong></a></dt>
327 <dt class="pubdef"><a id="prolog/0"><strong>prolog</strong></a></dt>
287328 <dd class="defbody">
288329 This goal starts the default interactive top level. Queries are read
289330 from the stream <code>user_input</code>. See also the Prolog flag
290 <a class="flag" href="flags.html#flag:history">history</a>. The <a name="idx:prolog0:1533"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
331 <a class="flag" href="flags.html#flag:history">history</a>. The <a id="idx:prolog0:1533"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
291332 predicate is terminated (succeeds) by typing the end-of-file character
292333 (typically control-D).
293334 </dd>
295336
296337 <p>The following two hooks allow for expanding queries and handling the
297338 result of a query. These hooks are used by the top level variable
298 expansion mechanism described in <a class="sec" href="topvars.html">section
339 expansion mechanism described in <a class="sec" href="topvars.html#sec:2.8">section
299340 2.8</a>.
300341
301342 <dl class="latex">
302 <dt class="pubdef"><a name="expand_query/4"><strong>expand_query</strong>(<var>+Query,
343 <dt class="pubdef"><a id="expand_query/4"><strong>expand_query</strong>(<var>+Query,
303344 -Expanded, +Bindings, -ExpandedBindings</var>)</a></dt>
304345 <dd class="defbody">
305346 Hook in module <code>user</code>, normally not defined. <var>Query</var>
306347 and
307348 <var>Bindings</var> represents the query read from the user and the
308 names of the free variables as obtained using <a name="idx:readterm3:1534"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
349 names of the free variables as obtained using <a id="idx:readterm3:1534"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
309350 If this predicate succeeds, it should bind <var>Expanded</var> and <var>ExpandedBindings</var>
310351 to the query and bindings to be executed by the top level. This
311 predicate is used by the top level (<a name="idx:prolog0:1535"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
312 See also <a name="idx:expandanswer2:1536"></a><a class="pred" href="toplevel.html#expand_answer/2">expand_answer/2</a>
352 predicate is used by the top level (<a id="idx:prolog0:1535"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
353 See also <a id="idx:expandanswer2:1536"></a><a class="pred" href="toplevel.html#expand_answer/2">expand_answer/2</a>
313354 and
314 <a name="idx:termexpansion2:1537"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>.</dd>
315 <dt class="pubdef"><a name="expand_answer/2"><strong>expand_answer</strong>(<var>+Bindings,
355 <a id="idx:termexpansion2:1537"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>.</dd>
356 <dt class="pubdef"><a id="expand_answer/2"><strong>expand_answer</strong>(<var>+Bindings,
316357 -ExpandedBindings</var>)</a></dt>
317358 <dd class="defbody">
318359 Hook in module <code>user</code>, normally not defined. Expand the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.8</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="history.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="debugoverview.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:topvars"><a name="sec:2.8"><span class="sec-nr">2.8</span> <span class="sec-title">Reuse
235 <h2 id="sec:topvars"><a id="sec:2.8"><span class="sec-nr">2.8</span> <span class="sec-title">Reuse
195236 of top-level bindings</span></a></h2>
196237
197 <a name="sec:topvars"></a>
238 <a id="sec:topvars"></a>
198239
199240 <p>Bindings resulting from the successful execution of a top-level goal
200241 are asserted in a database <em>if they are not too large</em>. These
214255 </pre>
215256
216257 <div class="caption"><b>Figure 1 : </b>Reusing top-level bindings</div>
217 <a name="fig:topevelvars"></a>
258 <a id="fig:topevelvars"></a>
218259
219260 <p>Note that variables may be set by executing <a class="pred" href="compare.html#=/2">=/2</a>:
220261
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section B.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ancestral-cut.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="breakpoint.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:tracehook"><a name="sec:B.3"><span class="sec-nr">B.3</span> <span class="sec-title">Intercepting
235 <h2 id="sec:tracehook"><a id="sec:B.3"><span class="sec-nr">B.3</span> <span class="sec-title">Intercepting
195236 the Tracer</span></a></h2>
196237
197 <a name="sec:tracehook"></a>
238 <a id="sec:tracehook"></a>
198239
199240 <dl class="latex">
200 <dt class="pubdef"><a name="prolog_trace_interception/4"><strong>prolog_trace_interception</strong>(<var>+Port,
241 <dt class="pubdef"><a id="prolog_trace_interception/4"><strong>prolog_trace_interception</strong>(<var>+Port,
201242 +Frame, +Choice, -Action</var>)</a></dt>
202243 <dd class="defbody">
203244 Dynamic predicate, normally not defined. This predicate is called from
228269 <dd class="defbody">
229270 The unify port represents the <em>neck</em> instruction, signalling the
230271 end of the head-matching process. This port is normally invisible. See
231 <a name="idx:leash1:2189"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>
232 and <a name="idx:visible1:2190"></a><a class="pred" href="debugger.html#visible/1">visible/1</a>.</dd>
272 <a id="idx:leash1:2193"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>
273 and <a id="idx:visible1:2194"></a><a class="pred" href="debugger.html#visible/1">visible/1</a>.</dd>
233274 <dt><strong>exit</strong></dt>
234275 <dd class="defbody">
235276 The exit port signals the goal is proved. It is possible for the goal to
236 have alternatives. See <a name="idx:prologframeattribute3:2191"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>
277 have alternatives. See <a id="idx:prologframeattribute3:2195"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>
237278 to examine the goal stack.</dd>
238279 <dt><strong>fail</strong></dt>
239280 <dd class="defbody">
260301 </dl>
261302
262303 <p><var>Frame</var> is a reference to the current local stack frame,
263 which can be examined using <a name="idx:prologframeattribute3:2192"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>. <var>Choice</var>
304 which can be examined using <a id="idx:prologframeattribute3:2196"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>. <var>Choice</var>
264305 is a reference to the last choice point and can be examined using
265 <a name="idx:prologchoiceattribute3:2193"></a><a class="pred" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a>. <var>Action</var>
306 <a id="idx:prologchoiceattribute3:2197"></a><a class="pred" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a>. <var>Action</var>
266307 must be unified with a term that specifies how execution must continue.
267308 The following actions are defined:
268309
269310 <dl class="latex">
270311 <dt><strong>abort</strong></dt>
271312 <dd class="defbody">
272 Abort execution. See <a name="idx:abort0:2194"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
313 Abort execution. See <a id="idx:abort0:2198"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
273314 </dd>
274315 <dt><strong>continue</strong></dt>
275316 <dd class="defbody">
285326 </dd>
286327 <dt><strong>nodebug</strong></dt>
287328 <dd class="defbody">
288 Continue execution in normal nodebugging mode. See <a name="idx:nodebug0:2195"></a><a class="pred" href="debugger.html#nodebug/0">nodebug/0</a>.
329 Continue execution in normal nodebugging mode. See <a id="idx:nodebug0:2199"></a><a class="pred" href="debugger.html#nodebug/0">nodebug/0</a>.
289330 </dd>
290331 <dt><strong>retry</strong></dt>
291332 <dd class="defbody">
307348 </dd>
308349 </dl>
309350
310 <p>Together with the predicates described in <a class="sec" href="debugger.html">section
351 <p>Together with the predicates described in <a class="sec" href="debugger.html#sec:4.39">section
311352 4.39</a> and the other predicates of this chapter, this predicate
312353 enables the Prolog user to define a complete new debugger in Prolog.
313354 Besides this, it enables the Prolog programmer to monitor the execution
329370 </pre>
330371
331372 </dd>
332 <dt class="pubdef"><a name="prolog_skip_frame/1"><strong>prolog_skip_frame</strong>(<var>-Frame</var>)</a></dt>
373 <dt class="pubdef"><a id="prolog_skip_frame/1"><strong>prolog_skip_frame</strong>(<var>-Frame</var>)</a></dt>
333374 <dd class="defbody">
334375 Indicate <var>Frame</var> as a skipped frame and set the `skip level'
335376 (see
336 <a name="idx:prologskiplevel2:2196"></a><a class="pred" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a>
377 <a id="idx:prologskiplevel2:2200"></a><a class="pred" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a>
337378 to the recursion depth of <var>Frame</var>. The effect of the skipped
338379 flag is that a redo on a child of this frame is handled differently.
339380 First, a <code>redo</code> trace is called for the child, where the skip
340381 level is set to <code>redo_in_skip</code>. Next, the skip level is set
341382 to skip level of the skipped frame.</dd>
342 <dt class="pubdef"><a name="prolog_skip_level/2"><strong>prolog_skip_level</strong>(<var>-Old,
383 <dt class="pubdef"><a id="prolog_skip_level/2"><strong>prolog_skip_level</strong>(<var>-Old,
343384 +New</var>)</a></dt>
344385 <dd class="defbody">
345386 Unify <var>Old</var> with the old value of `skip level' and then set
346387 this level according to <var>New</var>. <var>New</var> is an integer,
347388 the atom
348389 <code>very_deep</code> (meaning don't skip) or the atom <code>skip_in_redo</code>
349 (see <a name="idx:prologskipframe1:2197"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>).
390 (see <a id="idx:prologskipframe1:2201"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>).
350391 The `skip level' is a setting of each Prolog thread that disables the
351392 debugger on all recursion levels deeper than the level of the variable.
352 See also <a name="idx:prologskipframe1:2198"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>.
393 See also <a id="idx:prologskipframe1:2202"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>.
353394 </dd>
354395 </dl>
355396
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.34</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.34</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="gvar.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="system.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:tty"><a name="sec:4.34"><span class="sec-nr">4.34</span> <span class="sec-title">Terminal
235 <h2 id="sec:tty"><a id="sec:4.34"><span class="sec-nr">4.34</span> <span class="sec-title">Terminal
195236 Control</span></a></h2>
196237
197 <a name="sec:tty"></a>
238 <a id="sec:tty"></a>
198239
199240 <p>The following predicates form a simple access mechanism to the Unix
200241 termcap library to provide terminal-independent I/O for screen
202243 SWI-Prolog Windows console accepts the ANSI escape sequences.
203244
204245 <dl class="latex">
205 <dt class="pubdef"><a name="tty_get_capability/3"><strong>tty_get_capability</strong>(<var>+Name,
246 <dt class="pubdef"><a id="tty_get_capability/3"><strong>tty_get_capability</strong>(<var>+Name,
206247 +Type, -Result</var>)</a></dt>
207248 <dd class="defbody">
208249 Get the capability named <var>Name</var> from the termcap library. See
215256 are only computed once. Successive queries on the same capability are
216257 fast.
217258 </dd>
218 <dt class="pubdef"><a name="tty_goto/2"><strong>tty_goto</strong>(<var>+X,
259 <dt class="pubdef"><a id="tty_goto/2"><strong>tty_goto</strong>(<var>+X,
219260 +Y</var>)</a></dt>
220261 <dd class="defbody">
221262 Goto position (<var>X</var>, <var>Y</var>) on the screen. Note that the
222263 predicates
223 <a name="idx:linecount2:1435"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>
224 and <a name="idx:lineposition2:1436"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>
264 <a id="idx:linecount2:1435"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>
265 and <a id="idx:lineposition2:1436"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>
225266 will not have a well-defined behaviour while using this predicate.
226267 </dd>
227 <dt class="pubdef"><a name="tty_put/2"><strong>tty_put</strong>(<var>+Atom,
268 <dt class="pubdef"><a id="tty_put/2"><strong>tty_put</strong>(<var>+Atom,
228269 +Lines</var>)</a></dt>
229270 <dd class="defbody">
230271 Put an atom via the termcap library function tputs(). This function
231 decodes padding information in the strings returned by <a name="idx:ttygetcapability3:1437"></a><a class="pred" href="tty.html#tty_get_capability/3">tty_get_capability/3</a>
272 decodes padding information in the strings returned by <a id="idx:ttygetcapability3:1437"></a><a class="pred" href="tty.html#tty_get_capability/3">tty_get_capability/3</a>
232273 and should be used to output these strings. <var>Lines</var> is the
233274 number of lines affected by the operation, or 1 if not applicable (as in
234275 almost all cases).
235276 </dd>
236 <dt class="pubdef"><a name="tty_size/2"><strong>tty_size</strong>(<var>-Rows,
277 <dt class="pubdef"><a id="tty_size/2"><strong>tty_size</strong>(<var>-Rows,
237278 -Columns</var>)</a></dt>
238279 <dd class="defbody">
239280 Determine the size of the terminal. Platforms:
241282 <dl class="latex">
242283 <dt><b>Unix</b></dt>
243284 <dd>
244 If the system provides <em>ioctl</em> calls for this, these are used and <a name="idx:ttysize2:1438"></a><a class="pred" href="tty.html#tty_size/2">tty_size/2</a>
285 If the system provides <em>ioctl</em> calls for this, these are used and <a id="idx:ttysize2:1438"></a><a class="pred" href="tty.html#tty_size/2">tty_size/2</a>
245286 properly reflects the actual size after a user resize of the window. The <em>ioctl</em>
246287 is issued on teh file descriptor associated with the <code>user_input</code>
247 stream. As a fallback, the system uses <a name="idx:ttygetcapability3:1439"></a><a class="pred" href="tty.html#tty_get_capability/3">tty_get_capability/3</a>
288 stream. As a fallback, the system uses <a id="idx:ttygetcapability3:1439"></a><a class="pred" href="tty.html#tty_get_capability/3">tty_get_capability/3</a>
248289 using <code>li</code> and <code>co</code> capabilities. In this case the
249290 reported size reflects the size at the first call and is not updated
250291 after a user-initiated resize of the terminal.</dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 4.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.6</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="listing.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="compare.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:typetest"><a name="sec:4.6"><span class="sec-nr">4.6</span> <span class="sec-title">Verify
235 <h2 id="sec:typetest"><a id="sec:4.6"><span class="sec-nr">4.6</span> <span class="sec-title">Verify
195236 Type of a Term</span></a></h2>
196237
197 <a name="sec:typetest"></a>
238 <a id="sec:typetest"></a>
198239
199240 <p>Type tests are semi-deterministic predicates that succeed if the
200241 argument satisfies the requested type. Type-test predicates have no
202243 <code>library(error)</code>.
203244
204245 <dl class="latex">
205 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="var/1"><strong>var</strong>(<var>@Term</var>)</a></dt>
246 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="var/1"><strong>var</strong>(<var>@Term</var>)</a></dt>
206247 <dd class="defbody">
207248 True if <var>Term</var> currently is a free variable.
208249 </dd>
209 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="nonvar/1"><strong>nonvar</strong>(<var>@Term</var>)</a></dt>
250 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="nonvar/1"><strong>nonvar</strong>(<var>@Term</var>)</a></dt>
210251 <dd class="defbody">
211252 True if <var>Term</var> currently is not a free variable.
212253 </dd>
213 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="integer/1"><strong>integer</strong>(<var>@Term</var>)</a></dt>
254 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="integer/1"><strong>integer</strong>(<var>@Term</var>)</a></dt>
214255 <dd class="defbody">
215256 True if <var>Term</var> is bound to an integer.
216257 </dd>
217 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="float/1"><strong>float</strong>(<var>@Term</var>)</a></dt>
258 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="float/1"><strong>float</strong>(<var>@Term</var>)</a></dt>
218259 <dd class="defbody">
219260 True if <var>Term</var> is bound to a floating point number.
220261 </dd>
221 <dt class="pubdef"><a name="rational/1"><strong>rational</strong>(<var>@Term</var>)</a></dt>
262 <dt class="pubdef"><a id="rational/1"><strong>rational</strong>(<var>@Term</var>)</a></dt>
222263 <dd class="defbody">
223264 True if <var>Term</var> is bound to a rational number. Rational numbers
224265 include integers.
225266 </dd>
226 <dt class="pubdef"><a name="rational/3"><strong>rational</strong>(<var>@Term,
267 <dt class="pubdef"><a id="rational/3"><strong>rational</strong>(<var>@Term,
227268 -Numerator, -Denominator</var>)</a></dt>
228269 <dd class="defbody">
229270 True if <var>Term</var> is a rational number with given <var>Numerator</var>
233274 integer and there are no common divisors between <var>Numerator</var>
234275 and <var>Denominator</var>.
235276 </dd>
236 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="number/1"><strong>number</strong>(<var>@Term</var>)</a></dt>
277 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="number/1"><strong>number</strong>(<var>@Term</var>)</a></dt>
237278 <dd class="defbody">
238279 True if <var>Term</var> is bound to an integer or floating point number.<sup class="fn">55<span class="fn-text">As
239280 rational numbers are not atomic in the current implementation and we do
240 not want to break the rule that <a name="idx:number1:601"></a><a class="pred" href="typetest.html#number/1">number/1</a>
241 implies <a name="idx:atomic1:602"></a><a class="pred" href="typetest.html#atomic/1">atomic/1</a>, <a name="idx:number1:603"></a><a class="pred" href="typetest.html#number/1">number/1</a>
281 not want to break the rule that <a id="idx:number1:601"></a><a class="pred" href="typetest.html#number/1">number/1</a>
282 implies <a id="idx:atomic1:602"></a><a class="pred" href="typetest.html#atomic/1">atomic/1</a>, <a id="idx:number1:603"></a><a class="pred" href="typetest.html#number/1">number/1</a>
242283 fails on rational numbers. This will change if rational numbers become
243284 atomic.</span></sup></dd>
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom/1"><strong>atom</strong>(<var>@Term</var>)</a></dt>
285 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom/1"><strong>atom</strong>(<var>@Term</var>)</a></dt>
245286 <dd class="defbody">
246287 True if <var>Term</var> is bound to an atom.</dd>
247 <dt class="pubdef"><a name="blob/2"><strong>blob</strong>(<var>@Term,
288 <dt class="pubdef"><a id="blob/2"><strong>blob</strong>(<var>@Term,
248289 ?Type</var>)</a></dt>
249290 <dd class="defbody">
250291 True if <var>Term</var> is a <em>blob</em> of type <var>Type</var>. See
251 <a class="sec" href="foreigninclude.html">section 11.4.7</a>.</dd>
252 <dt class="pubdef"><a name="string/1"><strong>string</strong>(<var>@Term</var>)</a></dt>
292 <a class="sec" href="foreigninclude.html#sec:11.4.7">section 11.4.7</a>.</dd>
293 <dt class="pubdef"><a id="string/1"><strong>string</strong>(<var>@Term</var>)</a></dt>
253294 <dd class="defbody">
254295 True if <var>Term</var> is bound to a string. Note that string here
255 refers to the built-in atomic type string as described in <a class="sec" href="strings.html">section
296 refers to the built-in atomic type string as described in <a class="sec" href="strings.html#sec:5.2">section
256297 5.2</a>. Starting with version&nbsp;7, the syntax for a string object is
257298 text between double quotes, such as <code>"hello"</code>.<sup class="fn">56<span class="fn-text">In
258299 traditional Prolog systems, double quoted text is often mapped to a list
259300 of <em>character codes</em>.</span></sup> See also the Prolog flag
260301 <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>.</dd>
261 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atomic/1"><strong>atomic</strong>(<var>@Term</var>)</a></dt>
302 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atomic/1"><strong>atomic</strong>(<var>@Term</var>)</a></dt>
262303 <dd class="defbody">
263304 True if <var>Term</var> is bound (i.e., not a variable) and is not
264305 compound. Thus, atomic acts as if defined by:
269310 \+ compound(Term).
270311 </pre>
271312
272 <p>SWI-Prolog defines the following atomic datatypes: atom (<a name="idx:atom1:604"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>),
273 string (<a name="idx:string1:605"></a><a class="pred" href="typetest.html#string/1">string/1</a>),
274 integer (<a name="idx:integer1:606"></a><a class="pred" href="typetest.html#integer/1">integer/1</a>),
275 floating point number (<a name="idx:float1:607"></a><a class="pred" href="typetest.html#float/1">float/1</a>)
276 and blob (<a name="idx:blob2:608"></a><a class="pred" href="typetest.html#blob/2">blob/2</a>).
313 <p>SWI-Prolog defines the following atomic datatypes: atom (<a id="idx:atom1:604"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>),
314 string (<a id="idx:string1:605"></a><a class="pred" href="typetest.html#string/1">string/1</a>),
315 integer (<a id="idx:integer1:606"></a><a class="pred" href="typetest.html#integer/1">integer/1</a>),
316 floating point number (<a id="idx:float1:607"></a><a class="pred" href="typetest.html#float/1">float/1</a>)
317 and blob (<a id="idx:blob2:608"></a><a class="pred" href="typetest.html#blob/2">blob/2</a>).
277318 In addition, the symbol <code>[]</code> (empty list) is atomic, but not
278 an atom. See <a class="sec" href="ext-lists.html">section 5.1</a>.</dd>
279 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="compound/1"><strong>compound</strong>(<var>@Term</var>)</a></dt>
280 <dd class="defbody">
281 True if <var>Term</var> is bound to a compound term. See also <a name="idx:functor3:609"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
282 =../2, <a name="idx:compoundnamearity3:610"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
283 and <a name="idx:compoundnamearguments3:611"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.</dd>
284 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="callable/1"><strong>callable</strong>(<var>@Term</var>)</a></dt>
319 an atom. See <a class="sec" href="ext-lists.html#sec:5.1">section 5.1</a>.</dd>
320 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="compound/1"><strong>compound</strong>(<var>@Term</var>)</a></dt>
321 <dd class="defbody">
322 True if <var>Term</var> is bound to a compound term. See also <a id="idx:functor3:609"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
323 =../2, <a id="idx:compoundnamearity3:610"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
324 and <a id="idx:compoundnamearguments3:611"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>.</dd>
325 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="callable/1"><strong>callable</strong>(<var>@Term</var>)</a></dt>
285326 <dd class="defbody">
286327 True if <var>Term</var> is bound to an atom or a compound term. This was
287 intended as a type-test for arguments to <a name="idx:call1:612"></a><a class="pred" href="metacall.html#call/1">call/1</a>
288 and <a name="idx:call2:613"></a><a class="pred" href="metacall.html#call/2">call/2</a>..
328 intended as a type-test for arguments to <a id="idx:call1:612"></a><a class="pred" href="metacall.html#call/1">call/1</a>
329 and <a id="idx:call2:613"></a><a class="pred" href="metacall.html#call/2">call/2</a>..
289330 Note that callable only tests the <em>surface term</em>. Terms such as
290 (22,true) are considered callable, but cause <a name="idx:call1:614"></a><a class="pred" href="metacall.html#call/1">call/1</a>
291 to raise a type error. Module-qualification of meta-argument (see <a name="idx:metapredicate1:615"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>)
331 (22,true) are considered callable, but cause <a id="idx:call1:614"></a><a class="pred" href="metacall.html#call/1">call/1</a>
332 to raise a type error. Module-qualification of meta-argument (see <a id="idx:metapredicate1:615"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>)
292333 using
293334 <code><code>:</code>/2</code> causes callable to succeed on any
294 meta-argument.<sup class="fn">57<span class="fn-text">We think that <a name="idx:callable1:616"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>
335 meta-argument.<sup class="fn">57<span class="fn-text">We think that <a id="idx:callable1:616"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>
295336 should be deprecated and there should be two new predicates, one
296337 performing a test for callable that is minimally module aware and
297 possibly consistent with type-checking in <a name="idx:call1:617"></a><a class="pred" href="metacall.html#call/1">call/1</a>
338 possibly consistent with type-checking in <a id="idx:call1:617"></a><a class="pred" href="metacall.html#call/1">call/1</a>
298339 and a second predicate that tests for atom or compound.</span></sup>
299340 Consider the program and query below:
300341
310351 </pre>
311352
312353 </dd>
313 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="ground/1"><strong>ground</strong>(<var>@Term</var>)</a></dt>
314 <dd class="defbody">
315 True if <var>Term</var> holds no free variables. See also <a name="idx:nonground2:618"></a><a class="pred" href="manipterm.html#nonground/2">nonground/2</a>
316 and <a name="idx:termvariables2:619"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.</dd>
317 <dt class="pubdef"><a name="cyclic_term/1"><strong>cyclic_term</strong>(<var>@Term</var>)</a></dt>
354 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="ground/1"><strong>ground</strong>(<var>@Term</var>)</a></dt>
355 <dd class="defbody">
356 True if <var>Term</var> holds no free variables. See also <a id="idx:nonground2:618"></a><a class="pred" href="manipterm.html#nonground/2">nonground/2</a>
357 and <a id="idx:termvariables2:619"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.</dd>
358 <dt class="pubdef"><a id="cyclic_term/1"><strong>cyclic_term</strong>(<var>@Term</var>)</a></dt>
318359 <dd class="defbody">
319360 True if <var>Term</var> contains cycles, i.e. is an infinite term. See
320 also <a name="idx:acyclicterm1:620"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
321 and <a class="sec" href="cyclic.html">section 2.17</a>.<sup class="fn">58<span class="fn-text">The
322 predicates <a name="idx:cyclicterm1:621"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>
323 and <a name="idx:acyclicterm1:622"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
361 also <a id="idx:acyclicterm1:620"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
362 and <a class="sec" href="cyclic.html#sec:2.17">section 2.17</a>.<sup class="fn">58<span class="fn-text">The
363 predicates <a id="idx:cyclicterm1:621"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>
364 and <a id="idx:acyclicterm1:622"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
324365 are compatible with SICStus Prolog. Some Prolog systems supporting
325366 cyclic terms use is_cyclic/1 .</span></sup></dd>
326 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="acyclic_term/1"><strong>acyclic_term</strong>(<var>@Term</var>)</a></dt>
367 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="acyclic_term/1"><strong>acyclic_term</strong>(<var>@Term</var>)</a></dt>
327368 <dd class="defbody">
328369 True if <var>Term</var> does not contain cycles, i.e. can be processed
329 recursively in finite time. See also <a name="idx:cyclicterm1:623"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>
330 and <a class="sec" href="cyclic.html">section 2.17</a>.
370 recursively in finite time. See also <a id="idx:cyclicterm1:623"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>
371 and <a class="sec" href="cyclic.html#sec:2.17">section 2.17</a>.
331372 </dd>
332373 </dl>
333374
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.37</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.37</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="threadpool.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="url.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:ugraphs"><a name="sec:A.37"><span class="sec-nr">A.37</span> <span class="sec-title">library(ugraphs):
235 <h2 id="sec:ugraphs"><a id="sec:A.37"><span class="sec-nr">A.37</span> <span class="sec-title">library(ugraphs):
195236 Unweighted Graphs</span></a></h2>
196237
197 <a name="sec:ugraphs"></a>
198 <a name="sec:lib:ugraphs"></a> Authors: <em>Richard O'Keefe &amp; Vitor
238 <a id="sec:ugraphs"></a>
239 <a id="sec:lib:ugraphs"></a> Authors: <em>Richard O'Keefe &amp; Vitor
199240 Santos Costa</em>
200241 <blockquote><i>Implementation and documentation are copied from YAP
201242 5.0.1. The
226267 has no neighbors.
227268
228269 <dl class="latex">
229 <dt class="pubdef"><a name="vertices_edges_to_ugraph/3"><strong>vertices_edges_to_ugraph</strong>(<var>+Vertices,
270 <dt class="pubdef"><a id="vertices_edges_to_ugraph/3"><strong>vertices_edges_to_ugraph</strong>(<var>+Vertices,
230271 +Edges, -Graph</var>)</a></dt>
231272 <dd class="defbody">
232273 Given a graph with a set of <var>Vertices</var> and a set of <var>Edges</var>,
250291 </pre>
251292
252293 </dd>
253 <dt class="pubdef"><a name="vertices/2"><strong>vertices</strong>(<var>+Graph,
294 <dt class="pubdef"><a id="vertices/2"><strong>vertices</strong>(<var>+Graph,
254295 -Vertices</var>)</a></dt>
255296 <dd class="defbody">
256297 Unify <var>Vertices</var> with all vertices appearing in <var>Graph</var>.
262303 </pre>
263304
264305 </dd>
265 <dt class="pubdef"><a name="edges/2"><strong>edges</strong>(<var>+Graph,
306 <dt class="pubdef"><a id="edges/2"><strong>edges</strong>(<var>+Graph,
266307 -Edges</var>)</a></dt>
267308 <dd class="defbody">
268309 Unify <var>Edges</var> with all edges appearing in <var>Graph</var>.
274315 </pre>
275316
276317 </dd>
277 <dt class="pubdef"><a name="add_vertices/3"><strong>add_vertices</strong>(<var>+Graph,
318 <dt class="pubdef"><a id="add_vertices/3"><strong>add_vertices</strong>(<var>+Graph,
278319 +Vertices, -NewGraph</var>)</a></dt>
279320 <dd class="defbody">
280321 Unify <var>NewGraph</var> with a new graph obtained by adding the list
287328 </pre>
288329
289330 </dd>
290 <dt class="pubdef"><a name="del_vertices/3"><strong>del_vertices</strong>(<var>+Graph,
331 <dt class="pubdef"><a id="del_vertices/3"><strong>del_vertices</strong>(<var>+Graph,
291332 +Vertices, -NewGraph</var>)</a></dt>
292333 <dd class="defbody">
293334 Unify <var>NewGraph</var> with a new graph obtained by deleting the list
304345 </pre>
305346
306347 </dd>
307 <dt class="pubdef"><a name="add_edges/3"><strong>add_edges</strong>(<var>+Graph,
348 <dt class="pubdef"><a id="add_edges/3"><strong>add_edges</strong>(<var>+Graph,
308349 +Edges, -NewGraph</var>)</a></dt>
309350 <dd class="defbody">
310351 Unify <var>NewGraph</var> with a new graph obtained by adding the list
321362 </pre>
322363
323364 </dd>
324 <dt class="pubdef"><a name="del_edges/3"><strong>del_edges</strong>(<var>+Graph,
365 <dt class="pubdef"><a id="del_edges/3"><strong>del_edges</strong>(<var>+Graph,
325366 +Edges, -NewGraph</var>)</a></dt>
326367 <dd class="defbody">
327368 Unify <var>NewGraph</var> with a new graph obtained by removing the list
337378 </pre>
338379
339380 </dd>
340 <dt class="pubdef"><a name="transpose_ugraph/2"><strong>transpose_ugraph</strong>(<var>+Graph,
381 <dt class="pubdef"><a id="transpose_ugraph/2"><strong>transpose_ugraph</strong>(<var>+Graph,
341382 -NewGraph</var>)</a></dt>
342383 <dd class="defbody">
343384 Unify <var>NewGraph</var> with a new graph obtained from <var>Graph</var>
352393 </pre>
353394
354395 </dd>
355 <dt class="pubdef"><a name="neighbours/3"><strong>neighbours</strong>(<var>+Vertex,
396 <dt class="pubdef"><a id="neighbours/3"><strong>neighbours</strong>(<var>+Vertex,
356397 +Graph, -Vertices</var>)</a></dt>
357398 <dd class="defbody">
358399 Unify <var>Vertices</var> with the list of neighbours of vertex <var>Vertex</var>
365406 </pre>
366407
367408 </dd>
368 <dt class="pubdef"><a name="neighbors/3"><strong>neighbors</strong>(<var>+Vertex,
409 <dt class="pubdef"><a id="neighbors/3"><strong>neighbors</strong>(<var>+Vertex,
369410 +Graph, -Vertices</var>)</a></dt>
370411 <dd class="defbody">
371 American version of <a name="idx:neighbours3:2176"></a><a class="pred" href="ugraphs.html#neighbours/3">neighbours/3</a>.</dd>
372 <dt class="pubdef"><a name="complement/2"><strong>complement</strong>(<var>+Graph,
412 American version of <a id="idx:neighbours3:2180"></a><a class="pred" href="ugraphs.html#neighbours/3">neighbours/3</a>.</dd>
413 <dt class="pubdef"><a id="complement/2"><strong>complement</strong>(<var>+Graph,
373414 -NewGraph</var>)</a></dt>
374415 <dd class="defbody">
375416 Unify <var>NewGraph</var> with the graph complementary to <var>Graph</var>.
384425 </pre>
385426
386427 </dd>
387 <dt class="pubdef"><a name="compose/3"><strong>compose</strong>(<var>+LeftGraph,
428 <dt class="pubdef"><a id="compose/3"><strong>compose</strong>(<var>+LeftGraph,
388429 +RightGraph, -NewGraph</var>)</a></dt>
389430 <dd class="defbody">
390431 Compose <var>NewGraph</var> by connecting the <em>drains</em> of <var>LeftGraph</var>
396437 </pre>
397438
398439 </dd>
399 <dt class="pubdef"><a name="ugraph_union/3"><strong>ugraph_union</strong>(<var>+Graph1,
440 <dt class="pubdef"><a id="ugraph_union/3"><strong>ugraph_union</strong>(<var>+Graph1,
400441 +Graph2, -NewGraph</var>)</a></dt>
401442 <dd class="defbody">
402443 <var>NewGraph</var> is the union of <var>Graph1</var> and <var>Graph2</var>.
408449 </pre>
409450
410451 </dd>
411 <dt class="pubdef"><a name="top_sort/2"><strong>top_sort</strong>(<var>+Graph,
452 <dt class="pubdef"><a id="top_sort/2"><strong>top_sort</strong>(<var>+Graph,
412453 -Sort</var>)</a></dt>
413454 <dd class="defbody">
414455 Generate the set of nodes <var>Sort</var> as a topological sorting of
422463 </pre>
423464
424465 </dd>
425 <dt class="pubdef"><a name="top_sort/3"><strong>top_sort</strong>(<var>+Graph,
466 <dt class="pubdef"><a id="top_sort/3"><strong>top_sort</strong>(<var>+Graph,
426467 -Sort0, -Sort</var>)</a></dt>
427468 <dd class="defbody">
428469 Generate the difference list Sort-Sort0 as a topological sorting of
429470 <var>Graph</var>, if one is possible.</dd>
430 <dt class="pubdef"><a name="transitive_closure/2"><strong>transitive_closure</strong>(<var>+Graph,
471 <dt class="pubdef"><a id="transitive_closure/2"><strong>transitive_closure</strong>(<var>+Graph,
431472 -Closure</var>)</a></dt>
432473 <dd class="defbody">
433474 Generate the graph Closure as the transitive closure of
439480 </pre>
440481
441482 </dd>
442 <dt class="pubdef"><a name="reachable/3"><strong>reachable</strong>(<var>+Vertex,
483 <dt class="pubdef"><a id="reachable/3"><strong>reachable</strong>(<var>+Vertex,
443484 +Graph, -Vertices</var>)</a></dt>
444485 <dd class="defbody">
445486 Unify <var>Vertices</var> with the set of all vertices in <var>Graph</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.38</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.38</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="ugraphs.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="varnumbers.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:url"><a name="sec:A.38"><span class="sec-nr">A.38</span> <span class="sec-title">library(url):
235 <h2 id="sec:url"><a id="sec:A.38"><span class="sec-nr">A.38</span> <span class="sec-title">library(url):
195236 Analysing and constructing URL</span></a></h2>
196237
197 <p><a name="sec:url"></a>
238 <p><a id="sec:url"></a>
198239
199240 <dl class="tags">
200241 <dt class="mtag">author</dt>
221262 of the standard encountered in practical use.
222263
223264 <dl class="latex">
224 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="global_url/3"><strong>global_url</strong>(<var>+URL,
265 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="global_url/3"><strong>global_url</strong>(<var>+URL,
225266 +Base, -Global</var>)</a></dt>
226267 <dd class="defbody">
227268 Translate a possibly relative <var>URL</var> into an absolute one.
234275 </dl>
235276
236277 </dd>
237 <dt class="pubdef"><a name="is_absolute_url/1"><strong>is_absolute_url</strong>(<var>+URL</var>)</a></dt>
278 <dt class="pubdef"><a id="is_absolute_url/1"><strong>is_absolute_url</strong>(<var>+URL</var>)</a></dt>
238279 <dd class="defbody">
239280 True if <var>URL</var> is an absolute <var>URL</var>. That is, a <var>URL</var>
240281 that starts with a protocol identifier.</dd>
241 <dt class="pubdef"><a name="http_location/2"><strong>http_location</strong>(<var>?Parts,
282 <dt class="pubdef"><a id="http_location/2"><strong>http_location</strong>(<var>?Parts,
242283 ?Location</var>)</a></dt>
243284 <dd class="defbody">
244285 Construct or analyze an HTTP location. This is similar to
252293 </pre>
253294
254295 <table class="arglist">
255 <tr valign="top"><td><var>Location</var> </td><td>Atom or list of
256 character codes. </td></tr>
296 <tr><td><var>Location</var> </td><td>Atom or list of character codes. </td></tr>
257297 </table>
258298 </dd>
259 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="parse_url/2"><strong>parse_url</strong>(<var>?URL,
299 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="parse_url/2"><strong>parse_url</strong>(<var>?URL,
260300 ?Attributes</var>)</a></dt>
261301 <dd class="defbody">
262302 Construct or analyse a <var>URL</var>. <var>URL</var> is an atom holding
324364
325365 <p>By instantiating the parts-list this predicate can be used to create
326366 a <var>URL</var>.</dd>
327 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="parse_url/3"><strong>parse_url</strong>(<var>+URL,
367 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="parse_url/3"><strong>parse_url</strong>(<var>+URL,
328368 +BaseURL, -Attributes</var>)</a></dt>
329369 <dd class="defbody">
330370 Similar to <a class="pred" href="url.html#parse_url/2">parse_url/2</a>
331371 for relative URLs. If <var>URL</var> is relative, it is resolved using
332372 the absolute <var>URL</var> <var>BaseURL</var>.</dd>
333 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="www_form_encode/2"><strong>www_form_encode</strong>(<var>+Value,
373 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="www_form_encode/2"><strong>www_form_encode</strong>(<var>+Value,
334374 -XWWWFormEncoded</var>)</a></dt>
335 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="www_form_encode/2"><strong>www_form_encode</strong>(<var>-Value,
375 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="www_form_encode/2"><strong>www_form_encode</strong>(<var>-Value,
336376 +XWWWFormEncoded</var>)</a></dt>
337377 <dd class="defbody">
338378 En/decode to/from application/x-www-form-encoded. Encoding encodes all
353393 </dl>
354394
355395 </dd>
356 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="set_url_encoding/2"><strong>set_url_encoding</strong>(<var>?Old,
396 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="set_url_encoding/2"><strong>set_url_encoding</strong>(<var>?Old,
357397 +New</var>)</a></dt>
358398 <dd class="defbody">
359399 Query and set the encoding for URLs. The default is <code>utf8</code>.
368408 </dl>
369409
370410 </dd>
371 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="url_iri/2"><strong>url_iri</strong>(<var>+Encoded,
411 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="url_iri/2"><strong>url_iri</strong>(<var>+Encoded,
372412 -Decoded</var>)</a></dt>
373 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="url_iri/2"><strong>url_iri</strong>(<var>-Encoded,
413 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="url_iri/2"><strong>url_iri</strong>(<var>-Encoded,
374414 +Decoded</var>)</a></dt>
375415 <dd class="defbody">
376416 Convert between a URL, encoding in US-ASCII and an IRI. An IRI is a
377417 fully expanded Unicode string. Unicode strings are first encoded into
378418 UTF-8, after which %-encoding takes place.</dd>
379 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="parse_url_search/2"><strong>parse_url_search</strong>(<var>?Spec,
419 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="parse_url_search/2"><strong>parse_url_search</strong>(<var>?Spec,
380420 ?Fields:list(Name=Value)</var>)</a></dt>
381421 <dd class="defbody">
382422 Construct or analyze an HTTP search specification. This deals with form
383423 data using the MIME-type
384424 <code>application/x-www-form-urlencoded</code> as used in HTTP GET
385425 requests.</dd>
386 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="file_name_to_url/2"><strong>file_name_to_url</strong>(<var>+File,
426 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="file_name_to_url/2"><strong>file_name_to_url</strong>(<var>+File,
387427 -URL</var>)</a></dt>
388 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="file_name_to_url/2"><strong>file_name_to_url</strong>(<var>-File,
428 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="file_name_to_url/2"><strong>file_name_to_url</strong>(<var>-File,
389429 +URL</var>)</a></dt>
390430 <dd class="defbody">
391431 Translate between a filename and a file:<code>//</code> <var>URL</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 12.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.3</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="qsaveforeign.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="findappfile.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:useresource"><a name="sec:12.3"><span class="sec-nr">12.3</span> <span class="sec-title">Using
235 <h2 id="sec:useresource"><a id="sec:12.3"><span class="sec-nr">12.3</span> <span class="sec-title">Using
195236 program resources</span></a></h2>
196237
197 <a name="sec:useresource"></a>
238 <a id="sec:useresource"></a>
198239
199240 <p>A <em>resource</em> is very similar to a file. Resources, however,
200241 can be represented in two different formats: on files, as well as part
201 of the resource <em>archive</em> of a saved state (see <a name="idx:qsaveprogram2:2119"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>).
242 of the resource <em>archive</em> of a saved state (see <a id="idx:qsaveprogram2:2123"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>).
202243
203244 <p>A resource has a <em>name</em> and a <em>class</em>. The <em>source</em>
204245 data of the resource is a file. Resources are declared by declaring the
205 predicate <a name="idx:resource3:2120"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
246 predicate <a id="idx:resource3:2124"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
206247 They are accessed using the predicate
207 <a name="idx:openresource3:2121"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
248 <a id="idx:openresource3:2125"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
208249
209250 <p>Before going into details, let us start with an example. Short texts
210251 can easily be expressed in Prolog source code, but long texts are
223264 close(In)).
224265 </pre>
225266
226 <p>The predicate <a name="idx:help0:2122"></a><a class="pred" href="help.html#help/0">help/0</a>
267 <p>The predicate <a id="idx:help0:2126"></a><a class="pred" href="help.html#help/0">help/0</a>
227268 opens the resource as a Prolog stream. If we are executing this from the
228269 development environment, this will actually return a stream to the file <code>help.txt</code>
229270 itself. When executed from the saved state, the stream will actually be
230271 a stream opened on the program resource file, taking care of the offset
231272 and length of the resource.
232273
233 <p><h3 id="sec:runtime-predicates"><a name="sec:12.3.1"><span class="sec-nr">12.3.1</span> <span class="sec-title">Resource
274 <p><h3 id="sec:runtime-predicates"><a id="sec:12.3.1"><span class="sec-nr">12.3.1</span> <span class="sec-title">Resource
234275 manipulation predicates</span></a></h3>
235276
236 <a name="sec:runtime-predicates"></a>
277 <a id="sec:runtime-predicates"></a>
237278
238279 <dl class="latex">
239 <dt class="pubdef"><a name="resource/3"><strong>resource</strong>(<var>+Name,
280 <dt class="pubdef"><a id="resource/3"><strong>resource</strong>(<var>+Name,
240281 +Class, +FileSpec</var>)</a></dt>
241282 <dd class="defbody">
242283 This predicate is defined as a dynamic predicate in the module
246287 :, which are reserved for internal usage by the resource library. <var>Class</var>
247288 describes the kind of object stored in the resource. In the current
248289 implementation, it is just an atom. <var>FileSpec</var> is a file
249 specification that may exploit <a name="idx:filesearchpath2:2123"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
290 specification that may exploit <a id="idx:filesearchpath2:2127"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
250291 (see
251 <a name="idx:absolutefilename2:2124"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
292 <a id="idx:absolutefilename2:2128"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
252293
253294 <p>Normally, resources are defined as unit clauses (facts), but the
254295 definition of this predicate also allows for rules. For proper
258299
259300 <p>Dynamic rules are useful to turn all files in a certain directory
260301 into resources, without specifying a resource for each file. For
261 example, assume the <a name="idx:filesearchpath2:2125"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a> <code>icons</code>
302 example, assume the <a id="idx:filesearchpath2:2129"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a> <code>icons</code>
262303 refers to the resource directory containing icon files. The following
263304 definition makes all these images available as resources:
264305
275316 </pre>
276317
277318 </dd>
278 <dt class="pubdef"><a name="open_resource/3"><strong>open_resource</strong>(<var>+Name,
319 <dt class="pubdef"><a id="open_resource/3"><strong>open_resource</strong>(<var>+Name,
279320 ?Class, -Stream</var>)</a></dt>
280321 <dd class="defbody">
281322 Opens the resource specified by <var>Name</var> and <var>Class</var>. If
284325 <var>Stream</var> becomes a handle to a binary input stream, providing
285326 access to the content of the resource.
286327
287 <p>The predicate <a name="idx:openresource3:2126"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
288 first checks <a name="idx:resource3:2127"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
328 <p>The predicate <a id="idx:openresource3:2130"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
329 first checks <a id="idx:resource3:2131"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
289330 When successful it will open the returned resource source file.
290331 Otherwise it will look in the program's resource database. When creating
291332 a saved state, the system normally saves the resource contents into the
292333 resource archive, but does not save the resource clauses.
293334
294335 <p>This way, the development environment uses the files (and
295 modifications) to the <a name="idx:resource3:2128"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>
336 modifications) to the <a id="idx:resource3:2132"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>
296337 declarations and/or files containing resource info, thus immediately
297338 affecting the running environment, while the runtime system quickly
298339 accesses the system resources.
299340 </dd>
300341 </dl>
301342
302 <p><h3 id="sec:swiplrc"><a name="sec:12.3.2"><span class="sec-nr">12.3.2</span> <span class="sec-title">The <b>swipl-rc</b>
343 <p><h3 id="sec:swiplrc"><a id="sec:12.3.2"><span class="sec-nr">12.3.2</span> <span class="sec-title">The <b>swipl-rc</b>
303344 program</span></a></h3>
304345
305 <a name="sec:swiplrc"></a>
346 <a id="sec:swiplrc"></a>
306347
307348 <p>The utility program <b>swipl-rc</b> can be used to examine and
308349 manipulate the contents of a SWI-Prolog resource file. The options are
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.2</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="projectfiles.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="editreload.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:usingmodules"><a name="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Using
235 <h2 id="sec:usingmodules"><a id="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Using
195236 modules</span></a></h2>
196237
197 <a name="sec:usingmodules"></a>
238 <a id="sec:usingmodules"></a>
198239
199240 <p>Modules have been debated fiercely in the Prolog world. Despite all
200241 counter-arguments we feel they are extremely useful because:
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.39</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.39</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="url.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="yall.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:varnumbers"><a name="sec:A.39"><span class="sec-nr">A.39</span> <span class="sec-title">library(varnumbers):
235 <h2 id="sec:varnumbers"><a id="sec:A.39"><span class="sec-nr">A.39</span> <span class="sec-title">library(varnumbers):
195236 Utilities for numbered terms</span></a></h2>
196237
197 <p><a name="sec:varnumbers"></a>
238 <p><a id="sec:varnumbers"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">See also</dt>
226267 </pre>
227268
228269 <dl class="latex">
229 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="numbervars/1"><strong>numbervars</strong>(<var>+Term</var>)</a></dt>
270 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="numbervars/1"><strong>numbervars</strong>(<var>+Term</var>)</a></dt>
230271 <dd class="defbody">
231272 Number variables in <var>Term</var> using $VAR(N). Equivalent to
232273 <code>numbervars(Term, 0, _)</code>.
239280 </dl>
240281
241282 </dd>
242 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="varnumbers/2"><strong>varnumbers</strong>(<var>+Term,
283 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="varnumbers/2"><strong>varnumbers</strong>(<var>+Term,
243284 -Copy</var>)</a></dt>
244285 <dd class="defbody">
245286 Inverse of <a class="pred" href="varnumbers.html#numbervars/1">numbervars/1</a>.
246287 Equivalent to <code>varnumbers(Term, 0, Copy)</code>.</dd>
247 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="varnumbers/3"><strong>varnumbers</strong>(<var>+Term,
288 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="varnumbers/3"><strong>varnumbers</strong>(<var>+Term,
248289 +Start, -Copy</var>)</a></dt>
249290 <dd class="defbody">
250291 Inverse of <a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>.
266307 </dl>
267308
268309 </dd>
269 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="max_var_number/3"><strong>max_var_number</strong>(<var>+Term,
310 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="max_var_number/3"><strong>max_var_number</strong>(<var>+Term,
270311 +Start, -Max</var>)</a></dt>
271312 <dd class="defbody">
272313 True when <var>Max</var> is the max of <var>Start</var> and the highest
285326 </dl>
286327
287328 </dd>
288 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="varnumbers_names/3"><strong>varnumbers_names</strong>(<var>+Term,
329 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="varnumbers_names/3"><strong>varnumbers_names</strong>(<var>+Term,
289330 -Copy, -VariableNames</var>)</a></dt>
290331 <dd class="defbody">
291332 If <var>Term</var> is a term with numbered and named variables using the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 6.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.1</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="modules.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="defmodule.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:whymodules"><a name="sec:6.1"><span class="sec-nr">6.1</span> <span class="sec-title">Why
235 <h2 id="sec:whymodules"><a id="sec:6.1"><span class="sec-nr">6.1</span> <span class="sec-title">Why
195236 Use Modules?</span></a></h2>
196237
197 <a name="sec:whymodules"></a>
238 <a id="sec:whymodules"></a>
198239
199240 <p>In classic Prolog systems, all predicates are organised in a single
200241 namespace and any predicate can call any predicate. Because each
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 2.19</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.19</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="jitindex.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="limits.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:widechars"><a name="sec:2.19"><span class="sec-nr">2.19</span> <span class="sec-title">Wide
235 <h2 id="sec:widechars"><a id="sec:2.19"><span class="sec-nr">2.19</span> <span class="sec-title">Wide
195236 character support</span></a></h2>
196237
197 <a name="sec:widechars"></a>
198
199 <p><a name="idx:UTF8:262"></a><a name="idx:Unicode:263"></a><a name="idx:UCS:264"></a><a name="idx:internationalization:265"></a>SWI-Prolog
238 <a id="sec:widechars"></a>
239
240 <p><a id="idx:UTF8:262"></a><a id="idx:Unicode:263"></a><a id="idx:UCS:264"></a><a id="idx:internationalization:265"></a>SWI-Prolog
200241 supports <em>wide characters</em>, characters with character codes above
201242 255 that cannot be represented in a single <em>byte</em>.
202243 <em>Universal Character Set</em> (UCS) is the ISO/IEC 10646 standard
208249 as case conversion are unambiguously defined.
209250
210251 <p>For this reason SWI-Prolog has two representations for atoms and
211 string objects (see <a class="sec" href="strings.html">section 5.2</a>).
212 If the text fits in ISO Latin-1, it is represented as an array of 8-bit
213 characters. Otherwise the text is represented as an array of 32-bit
214 numbers. This representational issue is completely transparent to the
215 Prolog user. Users of the foreign language interface as described in <a class="sec" href="foreign.html">chapter
252 string objects (see <a class="sec" href="strings.html#sec:5.2">section
253 5.2</a>). If the text fits in ISO Latin-1, it is represented as an array
254 of 8-bit characters. Otherwise the text is represented as an array of
255 32-bit numbers. This representational issue is completely transparent to
256 the Prolog user. Users of the foreign language interface as described in <a class="sec" href="foreign.html#sec:11">chapter
216257 11</a> sometimes need to be aware of these issues though.
217258
218259 <p>Character coding comes into view when characters of strings need to
221262 section we only deal with I/O through streams, which includes file I/O
222263 as well as I/O through network sockets.
223264
224 <p><h3 id="sec:encoding"><a name="sec:2.19.1"><span class="sec-nr">2.19.1</span> <span class="sec-title">Wide
265 <p><h3 id="sec:encoding"><a id="sec:2.19.1"><span class="sec-nr">2.19.1</span> <span class="sec-title">Wide
225266 character encodings on streams</span></a></h3>
226267
227 <a name="sec:encoding"></a>
268 <a id="sec:encoding"></a>
228269
229270 <p>Although characters are uniquely coded using the UCS standard
230271 internally, streams and files are byte (8-bit) oriented and there are a
237278 pairs of bytes, is also popular.
238279
239280 <p>Prolog I/O streams have a property called <em>encoding</em> which
240 specifies the used encoding that influences <a name="idx:getcode2:266"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
241 and <a name="idx:putcode2:267"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>
281 specifies the used encoding that influences <a id="idx:getcode2:266"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
282 and <a id="idx:putcode2:267"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>
242283 as well as all the other text I/O predicates.
243284
244285 <p>The default encoding for files is derived from the Prolog flag
248289 and the translation is left to the wide-character functions of the C
249290 library.<sup class="fn">34<span class="fn-text">The Prolog native UTF-8
250291 mode is considerably faster than the generic mbrtowc() one.</span></sup>
251 The encoding can be specified explicitly in <a name="idx:loadfiles2:268"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
252 for loading Prolog source with an alternative encoding, <a name="idx:open4:269"></a><a class="pred" href="IO.html#open/4">open/4</a>
253 when opening files or using <a name="idx:setstream2:270"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
254 on any open stream. For Prolog source files we also provide the <a name="idx:encoding1:271"></a><a class="pred" href="consulting.html#encoding/1">encoding/1</a>
292 The encoding can be specified explicitly in <a id="idx:loadfiles2:268"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
293 for loading Prolog source with an alternative encoding, <a id="idx:open4:269"></a><a class="pred" href="IO.html#open/4">open/4</a>
294 when opening files or using <a id="idx:setstream2:270"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
295 on any open stream. For Prolog source files we also provide the <a id="idx:encoding1:271"></a><a class="pred" href="consulting.html#encoding/1">encoding/1</a>
255296 directive that can be used to switch between encodings that are
256297 compatible with US-ASCII (<code>ascii</code>, <code>iso_latin_1</code>, <code>utf8</code>
257 and many locales). See also <a class="sec" href="projectfiles.html">section
258 3.1.3</a> for writing Prolog files with non-US-ASCII characters and <a class="sec" href="syntax.html">section
298 and many locales). See also <a class="sec" href="projectfiles.html#sec:3.1.3">section
299 3.1.3</a> for writing Prolog files with non-US-ASCII characters and <a class="sec" href="syntax.html#sec:2.16.1.8">section
259300 2.16.1.8</a> for syntax issues. For additional information and Unicode
260301 resources, please visit
261302 <a class="url" href="http://www.unicode.org/">http://www.unicode.org/</a>.
299340 <p>Note that not all encodings can represent all characters. This
300341 implies that writing text to a stream may cause errors because the
301342 stream cannot represent these characters. The behaviour of a stream on
302 these errors can be controlled using <a name="idx:setstream2:272"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
343 these errors can be controlled using <a id="idx:setstream2:272"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
303344 Initially the terminal stream writes the characters using Prolog escape
304345 sequences while other streams generate an I/O exception.
305346
306 <p><h4 id="sec:bom"><a name="sec:2.19.1.1"><span class="sec-nr">2.19.1.1</span> <span class="sec-title">BOM:
347 <p><h4 id="sec:bom"><a id="sec:2.19.1.1"><span class="sec-nr">2.19.1.1</span> <span class="sec-title">BOM:
307348 Byte Order Mark</span></a></h4>
308349
309 <a name="sec:bom"></a>
310
311 <p><a name="idx:BOM:273"></a><a name="idx:ByteOrderMark:274"></a>From <a class="sec" href="widechars.html">section
350 <a id="sec:bom"></a>
351
352 <p><a id="idx:BOM:273"></a><a id="idx:ByteOrderMark:274"></a>From <a class="sec" href="widechars.html#sec:2.19.1">section
312353 2.19.1</a>, you may have got the impression that text files are
313354 complicated. This section deals with a related topic, making life often
314355 easier for the user, but providing another worry to the programmer.
325366 additional information revealing the encoding, making the use of a BOM
326367 redundant or even illegal.
327368
328 <p>The BOM is handled by SWI-Prolog <a name="idx:open4:275"></a><a class="pred" href="IO.html#open/4">open/4</a>
369 <p>The BOM is handled by SWI-Prolog <a id="idx:open4:275"></a><a class="pred" href="IO.html#open/4">open/4</a>
329370 predicate. By default, text files are probed for the BOM when opened for
330371 reading. If a BOM is found, the encoding is set accordingly and the
331 property <code>bom(true)</code> is available through <a name="idx:streamproperty2:276"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.
372 property <code>bom(true)</code> is available through <a id="idx:streamproperty2:276"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.
332373 When opening a file for writing, writing a BOM can be requested using
333374 the option <code>bom(true)</code> with
334 <a name="idx:open4:277"></a><a class="pred" href="IO.html#open/4">open/4</a>.
375 <a id="idx:open4:277"></a><a class="pred" href="IO.html#open/4">open/4</a>.
335376
336377 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.18</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.18</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="nb_set.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="option.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:www_browser"><a name="sec:A.18"><span class="sec-nr">A.18</span> <span class="sec-title">library(www_browser):
235 <h2 id="sec:www_browser"><a id="sec:A.18"><span class="sec-nr">A.18</span> <span class="sec-title">library(www_browser):
195236 Activating your Web-browser</span></a></h2>
196237
197 <a name="sec:www_browser"></a>
238 <a id="sec:www_browser"></a>
198239
199240 <p>This library deals with the very system-dependent task of opening a
200241 web page in a browser. See also <code>library(url)</code> and the HTTP
201242 package.
202243
203244 <dl class="latex">
204 <dt class="pubdef"><a name="www_open_url/1"><strong>www_open_url</strong>(<var>+URL</var>)</a></dt>
245 <dt class="pubdef"><a id="www_open_url/1"><strong>www_open_url</strong>(<var>+URL</var>)</a></dt>
205246 <dd class="defbody">
206247 Open <var>URL</var> in an external web browser. The reason to place this
207248 in the library is to centralise the maintenance on this highly platform-
210251 <p>
211252 <ul class="latex">
212253 <li><i>MS-Windows</i><br>
213 If it detects MS-Windows it uses <a name="idx:winshell2:2148"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>
254 If it detects MS-Windows it uses <a id="idx:winshell2:2152"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>
214255 to open the <var>URL</var>. The behaviour and browser started depends on
215256 the version of Windows and Windows-shell configuration, but in general
216257 it should be the behaviour expected by the user.
217258
218259 <p>
219260 <li><i>Other platforms</i><br>
220 On other platforms it tests the environment variable (see <a name="idx:getenv2:2149"></a><a class="pred" href="system.html#getenv/2">getenv/2</a>)
261 On other platforms it tests the environment variable (see <a id="idx:getenv2:2153"></a><a class="pred" href="system.html#getenv/2">getenv/2</a>)
221262 named <code>BROWSER</code> or uses <b>netscape</b> if this variable is
222263 not set. If the browser is either <code>mozilla</code> or <code>netscape</code>,
223 <a name="idx:wwwopenurl1:2150"></a><a class="pred" href="www_browser.html#www_open_url/1">www_open_url/1</a>
264 <a id="idx:wwwopenurl1:2154"></a><a class="pred" href="www_browser.html#www_open_url/1">www_open_url/1</a>
224265 first tries to open a new window on a running browser using the <code>-remote</code>
225266 option of Netscape. If this fails or the browser is not <code>mozilla</code>
226267 or <code>netscape</code> the system simply passes the URL as first
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section 3.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.7</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="navigator.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="idepreds.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:xref"><a name="sec:3.7"><span class="sec-nr">3.7</span> <span class="sec-title">Cross-referencer</span></a></h2>
195
196 <a name="sec:xref"></a>
235 <h2 id="sec:xref"><a id="sec:3.7"><span class="sec-nr">3.7</span> <span class="sec-title">Cross-referencer</span></a></h2>
236
237 <a id="sec:xref"></a>
197238
198239 <p>A cross-referencer is a tool that examines the caller-callee relation
199240 between predicates, and, using this information to explicate dependency
201242 and predicates for which no callers can be found. Cross-referencing is
202243 useful during program development, reorganisation, clean-up, porting and
203244 other program maintenance tasks. The dynamic nature of Prolog makes the
204 task non-trivial. Goals can be created dynamically using <a name="idx:call1:322"></a><a class="pred" href="metacall.html#call/1">call/1</a>
245 task non-trivial. Goals can be created dynamically using <a id="idx:call1:322"></a><a class="pred" href="metacall.html#call/1">call/1</a>
205246 after construction of a goal term. Abstract interpretation can find some
206247 of these calls, but they can also come from external communication,
207248 making it impossible to predict the callee. In other words, the
211252
212253 <p>SWI-Prolog's cross-referencer is split into two parts. The standard
213254 Prolog library <code>library(prolog_xref)</code> is an extensible
214 library for information gathering described in <a class="sec" href="prolog_xref.html">section
255 library for information gathering described in <a class="sec" href="prolog_xref.html#sec:A.27">section
215256 A.27</a>, and the XPCE library <code>library(pce_xref)</code> provides a
216257 graphical front-end for the cross-referencer described here. We
217258 demonstrate the tool on CHAT80, a natural language question and answer
218259 system by Fernando C.N. Pereira and David H.D. Warren.
219260
220261 <dl class="latex">
221 <dt class="pubdef"><a name="gxref/0"><strong>gxref</strong></a></dt>
262 <dt class="pubdef"><a id="gxref/0"><strong>gxref</strong></a></dt>
222263 <dd class="defbody">
223264 Run cross-referencer on all currently loaded files and present a
224265 graphical overview of the result. As the predicate operates on the
227268 </dd>
228269 </dl>
229270
230 <p><a name="fig:xrefchatfile"></a><div style="text-align:center"><img src="xrefchatfile.gif"></div>
271 <p><a id="fig:xrefchatfile"></a><div style="text-align:center"><img src="xrefchatfile.gif"></div>
231272 <div class="caption"><b>Figure 3 : </b>File info for <code>chattop.pl</code>,
232273 part of CHAT80</div>
233274
235276 3</a>) provides browsers for loaded files and predicates. To avoid long
236277 file paths, the file hierarchy has three main branches. The first is the
237278 current directory holding the sources. The second is marked <code>alias</code>,
238 and below it are the file-search-path aliases (see <a name="idx:filesearchpath2:323"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
279 and below it are the file-search-path aliases (see <a id="idx:filesearchpath2:323"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
239280 and
240 <a name="idx:absolutefilename3:324"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>).
281 <a id="idx:absolutefilename3:324"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>).
241282 Here you find files loaded from the system as well as modules of the
242283 program loaded from other locations using the file search path. All
243284 loaded files that fall outside these categories are below the last
262303 file. Left-clicking opens a menu to open the definition or select one of
263304 the callers.
264305
265 <p><a name="fig:xrefchatdep"></a><div style="text-align:center"><img src="xrefchatdep.gif"></div>
306 <p><a id="fig:xrefchatdep"></a><div style="text-align:center"><img src="xrefchatdep.gif"></div>
266307 <div class="caption"><b>Figure 4 : </b>Dependencies between source files
267308 of CHAT80</div>
268309
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.6.2 Reference Manual: Section A.40</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.40</title><link rel="home" href="index.html">
55 <link rel="contents" href="Contents.html">
66 <link rel="index" href="DocIndex.html">
77 <link rel="summary" href="summary.html">
1717 { margin-bottom: 1em;
1818 }
1919
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
20 dt.pubdef, dt.multidef
21 { color: #fff;
22 padding: 2px 10px 0px 10px;
23 margin-bottom: 5px;
24 font-size: 18px;
25 vertical-align: middle;
26 overflow: hidden;
27 }
28
29 dt.pubdef { background-color: #0c3d6e; }
30 dt.multidef { background-color: #ef9439; }
2731
2832 .bib dd
2933 { margin-bottom: 1em;
117121 padding-top: 0.2em;
118122 font-size: 80%;
119123 font-style: italic;
120 color: #202020;
124 color: #fff;
121125 }
122126
123127 div.caption
127131 }
128132
129133 /* Footnotes */
130
131 sup.fn { color: blue; text-decoration: underline; }
132 span.fn-text { display: none; }
133 sup.fn span {display: none;}
134 sup:hover span
135 { display: block !important;
136 position: absolute; top: auto; left: auto; width: 80%;
137 color: #000; background: white;
138 border: 2px solid;
139 padding: 5px; margin: 10px; z-index: 100;
140 font-size: smaller;
134 .fn {
135 color: red;
136 font-size: 70%;
137 }
138
139 .fn-text, .fnp {
140 position: absolute;
141 top: auto;
142 left: 10%;
143 border: 1px solid #000;
144 box-shadow: 5px 5px 5px #888;
145 display: none;
146 background: #fff;
147 color: #000;
148 margin-top: 25px;
149 padding: 8px 12px;
150 font-size: larger;
151 }
152
153 sup:hover span.fn-text
154 { display: block;
141155 }
142156
143157 /* Lists */
181195 font-size: +1;
182196 margin-top: 1ex;
183197 }
198
199 /* Tables */
200
201 table.center
202 { margin: auto;
203 }
204
205 table.latex
206 { border-collapse:collapse;
207 }
208
209 table.latex tr
210 { vertical-align: text-top;
211 }
212
213 table.latex td,th
214 { padding: 2px 1em;
215 }
216
217 table.latex tr.hline td,th
218 { border-top: 1px solid black;
219 }
220
221 table.frame-box
222 { border: 2px solid black;
223 }
224
184225 </style>
185226 </head>
186227 <body style="background:white">
191232 <a class="nav" href="varnumbers.html"><img src="prev.gif" alt="Previous"></a>
192233 <a class="nav" href="hack.html"><img src="next.gif" alt="Next"></a>
193234 </div>
194 <h2 id="sec:yall"><a name="sec:A.40"><span class="sec-nr">A.40</span> <span class="sec-title">library(yall):
235 <h2 id="sec:yall"><a id="sec:A.40"><span class="sec-nr">A.40</span> <span class="sec-title">library(yall):
195236 Lambda expressions</span></a></h2>
196237
197 <p><a name="sec:yall"></a>
238 <p><a id="sec:yall"></a>
198239
199240 <dl class="tags">
200241 <dt class="tag">author</dt>
282323 development of this module was sponsored by Kyndi, Inc.
283324
284325 <dl class="latex">
285 <dt class="pubdef"><a name=">>/2"><var>+Parameters</var> <strong>&gt;&gt;</strong> <var>+Lambda</var></a></dt>
286 <dt class="pubdef"><a name=">>/3"><strong>&gt;&gt;</strong>(<var>+Parameters,
326 <dt class="pubdef"><a id=">>/2"><var>+Parameters</var> <strong>&gt;&gt;</strong> <var>+Lambda</var></a></dt>
327 <dt class="pubdef"><a id=">>/3"><strong>&gt;&gt;</strong>(<var>+Parameters,
287328 +Lambda, ?A1</var>)</a></dt>
288 <dt class="pubdef"><a name=">>/4"><strong>&gt;&gt;</strong>(<var>+Parameters,
329 <dt class="pubdef"><a id=">>/4"><strong>&gt;&gt;</strong>(<var>+Parameters,
289330 +Lambda, ?A1, ?A2</var>)</a></dt>
290 <dt class="pubdef"><a name=">>/5"><strong>&gt;&gt;</strong>(<var>+Parameters,
331 <dt class="pubdef"><a id=">>/5"><strong>&gt;&gt;</strong>(<var>+Parameters,
291332 +Lambda, ?A1, ?A2, ?A3</var>)</a></dt>
292 <dt class="pubdef"><a name=">>/6"><strong>&gt;&gt;</strong>(<var>+Parameters,
333 <dt class="pubdef"><a id=">>/6"><strong>&gt;&gt;</strong>(<var>+Parameters,
293334 +Lambda, ?A1, ?A2, ?A3, ?A4</var>)</a></dt>
294 <dt class="pubdef"><a name=">>/7"><strong>&gt;&gt;</strong>(<var>+Parameters,
335 <dt class="pubdef"><a id=">>/7"><strong>&gt;&gt;</strong>(<var>+Parameters,
295336 +Lambda, ?A1, ?A2, ?A3, ?A4, ?A5</var>)</a></dt>
296 <dt class="pubdef"><a name=">>/8"><strong>&gt;&gt;</strong>(<var>+Parameters,
337 <dt class="pubdef"><a id=">>/8"><strong>&gt;&gt;</strong>(<var>+Parameters,
297338 +Lambda, ?A1, ?A2, ?A3, ?A4, ?A5, ?A6</var>)</a></dt>
298 <dt class="pubdef"><a name=">>/9"><strong>&gt;&gt;</strong>(<var>+Parameters,
339 <dt class="pubdef"><a id=">>/9"><strong>&gt;&gt;</strong>(<var>+Parameters,
299340 +Lambda, ?A1, ?A2, ?A3, ?A4, ?A5, ?A6, ?A7</var>)</a></dt>
300341 <dd class="defbody">
301342 Calls a copy of <var>Lambda</var>. This is similar to <code>call(Lambda,A1,...)</code>,
309350 <li>Possible excess arguments are passed by position.
310351 </ul>
311352 <table class="arglist">
312 <tr valign="top"><td><var>Parameters</var> </td><td>is either a plain
313 list of parameters or a term
353 <tr><td><var>Parameters</var> </td><td>is either a plain list of
354 parameters or a term
314355 <code>{Free}/List</code>. <var>Free</var> represents variables that are
315356 shared between the context and the <var>Lambda</var> term. This is
316357 needed for compiling <var>Lambda</var> expressions. </td></tr>
317358 </table>
318359 </dd>
319 <dt class="pubdef"><a name="//2"><var>+Free</var> <strong>/</strong> <var>:Lambda</var></a></dt>
320 <dt class="pubdef"><a name="//3"><strong>/</strong>(<var>+Free, :Lambda,
360 <dt class="pubdef"><a id="//2"><var>+Free</var> <strong>/</strong> <var>:Lambda</var></a></dt>
361 <dt class="pubdef"><a id="//3"><strong>/</strong>(<var>+Free, :Lambda,
321362 ?A1</var>)</a></dt>
322 <dt class="pubdef"><a name="//4"><strong>/</strong>(<var>+Free, :Lambda,
363 <dt class="pubdef"><a id="//4"><strong>/</strong>(<var>+Free, :Lambda,
323364 ?A1, ?A2</var>)</a></dt>
324 <dt class="pubdef"><a name="//5"><strong>/</strong>(<var>+Free, :Lambda,
365 <dt class="pubdef"><a id="//5"><strong>/</strong>(<var>+Free, :Lambda,
325366 ?A1, ?A2, ?A3</var>)</a></dt>
326 <dt class="pubdef"><a name="//6"><strong>/</strong>(<var>+Free, :Lambda,
367 <dt class="pubdef"><a id="//6"><strong>/</strong>(<var>+Free, :Lambda,
327368 ?A1, ?A2, ?A3, ?A4</var>)</a></dt>
328 <dt class="pubdef"><a name="//7"><strong>/</strong>(<var>+Free, :Lambda,
369 <dt class="pubdef"><a id="//7"><strong>/</strong>(<var>+Free, :Lambda,
329370 ?A1, ?A2, ?A3, ?A4, ?A5</var>)</a></dt>
330 <dt class="pubdef"><a name="//8"><strong>/</strong>(<var>+Free, :Lambda,
371 <dt class="pubdef"><a id="//8"><strong>/</strong>(<var>+Free, :Lambda,
331372 ?A1, ?A2, ?A3, ?A4, ?A5, ?A6</var>)</a></dt>
332 <dt class="pubdef"><a name="//9"><strong>/</strong>(<var>+Free, :Lambda,
373 <dt class="pubdef"><a id="//9"><strong>/</strong>(<var>+Free, :Lambda,
333374 ?A1, ?A2, ?A3, ?A4, ?A5, ?A6, ?A7</var>)</a></dt>
334375 <dd class="defbody">
335376 Shorthand for <code>Free/[]&gt;&gt;Lambda</code>. This is the same as
357398 </pre>
358399
359400 </dd>
360 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_lambda/1"><strong>is_lambda</strong>(<var>@Term</var>)</a></dt>
401 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_lambda/1"><strong>is_lambda</strong>(<var>@Term</var>)</a></dt>
361402 <dd class="defbody">
362403 True if <var>Term</var> is a valid Lambda expression.</dd>
363 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="lambda_calls/2"><strong>lambda_calls</strong>(<var>+LambdaExpression,
404 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="lambda_calls/2"><strong>lambda_calls</strong>(<var>+LambdaExpression,
364405 -Goal</var>)</a></dt>
365 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="lambda_calls/3"><strong>lambda_calls</strong>(<var>+LambdaExpression,
406 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="lambda_calls/3"><strong>lambda_calls</strong>(<var>+LambdaExpression,
366407 +ExtraArgs, -Goal</var>)</a></dt>
367408 <dd class="defbody">
368409 <var>Goal</var> is the goal called if call/N is applied to
5858
5959 \newcommand{\vmajor}{7}
6060 \newcommand{\vminor}{6}
61 \newcommand{\vpatch}{2}
61 \newcommand{\vpatch}{3}
6262 \newcommand{\vtag}{}
6363 \newcommand{\vmonth}{November}
6464 \newcommand{\vyear}{2017}
1111 { margin-bottom: 1em;
1212 }
1313
14 dt.pubdef
15 { background-color: #c5e1ff;
16 }
17
18 dt.multidef
19 { background-color: #c8ffc7;
20 }
14 dt.pubdef, dt.multidef
15 { color: #fff;
16 padding: 2px 10px 0px 10px;
17 margin-bottom: 5px;
18 font-size: 18px;
19 vertical-align: middle;
20 overflow: hidden;
21 }
22
23 dt.pubdef { background-color: #0c3d6e; }
24 dt.multidef { background-color: #ef9439; }
2125
2226 .bib dd
2327 { margin-bottom: 1em;
111115 padding-top: 0.2em;
112116 font-size: 80%;
113117 font-style: italic;
114 color: #202020;
118 color: #fff;
115119 }
116120
117121 div.caption
121125 }
122126
123127 /* Footnotes */
124
125 sup.fn { color: blue; text-decoration: underline; }
126 span.fn-text { display: none; }
127 sup.fn span {display: none;}
128 sup:hover span
129 { display: block !important;
130 position: absolute; top: auto; left: auto; width: 80%;
131 color: #000; background: white;
132 border: 2px solid;
133 padding: 5px; margin: 10px; z-index: 100;
134 font-size: smaller;
128 .fn {
129 color: red;
130 font-size: 70%;
131 }
132
133 .fn-text, .fnp {
134 position: absolute;
135 top: auto;
136 left: 10%;
137 border: 1px solid #000;
138 box-shadow: 5px 5px 5px #888;
139 display: none;
140 background: #fff;
141 color: #000;
142 margin-top: 25px;
143 padding: 8px 12px;
144 font-size: larger;
145 }
146
147 sup:hover span.fn-text
148 { display: block;
135149 }
136150
137151 /* Lists */
175189 font-size: +1;
176190 margin-top: 1ex;
177191 }
192
193 /* Tables */
194
195 table.center
196 { margin: auto;
197 }
198
199 table.latex
200 { border-collapse:collapse;
201 }
202
203 table.latex tr
204 { vertical-align: text-top;
205 }
206
207 table.latex td,th
208 { padding: 2px 1em;
209 }
210
211 table.latex tr.hline td,th
212 { border-top: 1px solid black;
213 }
214
215 table.frame-box
216 { border: 2px solid black;
217 }
218
178219 </style>
179220 </head>
180221 <body style="background:white">
189230 started using SWI-Prolog on MS-Windows. It also describes the components
190231 and issues that are specific to MS-Windows. It is by no means a manual
191232 or Prolog tutorial. The reference manual is available online or can be
192 downloaded in HTML and PDF format from the http://www.swi-prolog.org/SWI-Prolog
193 website , which also provides links to books, online tutorials and other
194 Prolog-related material.
233 downloaded in HTML and PDF format from the <a class="url" href="http://www.swi-prolog.org/">SWI-Prolog
234 website</a>, which also provides links to books, online tutorials and
235 other Prolog-related material.
195236 </div>
196237
197 <h1><a name="document-contents">Table of Contents</a></h1>
238 <h1><a id="document-contents">Table of Contents</a></h1>
198239
199240 <div class="toc">
200241 <div class="toc-h2"><a class="sec" href="#sec:1"><span class="sec-nr">1</span> <span class="sec-title">Using
239280 SWI-Prolog</span></a></div>
240281 </div>
241282
242 <h2><a name="sec:1"><span class="sec-nr">1</span> <span class="sec-title">Using
283 <h2><a id="sec:1"><span class="sec-nr">1</span> <span class="sec-title">Using
243284 SWI-Prolog</span></a></h2>
244285
245286 <p>
246287
247 <h3><a name="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Starting
288 <h3><a id="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Starting
248289 Prolog and loading a program</span></a></h3>
249290
250291 <p>The SWI-Prolog executable <b>swipl-win.exe</b> can be started from
270311 <code>MyDocuments\Prolog</code>. This folder is created if it does not
271312 exist.
272313
273 <p><h3 id="sec:execquery"><a name="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Executing
314 <p><h3 id="sec:execquery"><a id="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Executing
274315 a query</span></a></h3>
275316
276 <a name="sec:execquery"></a>
317 <a id="sec:execquery"></a>
277318
278319 <p>After loading a program, one can ask Prolog queries about the
279320 program. The query below asks Prolog what food `sam' likes. The system
302343 that, when executed, produces the same set of answers as the original
303344 program.
304345
305 <p><h3 id="sec:menu"><a name="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Menu
346 <p><h3 id="sec:menu"><a id="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Menu
306347 commands</span></a></h3>
307348
308 <a name="sec:menu"></a>
349 <a id="sec:menu"></a>
309350
310351 <p>The SWI-Prolog console provided by <b>swipl-win.exe</b> has a menu
311352 for accessing the most commonly used commands. We assume not all menu
315356 <dt><b>File/Reload modified files</b></dt>
316357 <dd class="defbody">
317358 This menu reloads all loaded source files that have been modified using
318 the <a name="idx:make0:1"></a><a class="pred" href="#make/0">make/0</a>
359 the <a id="idx:make0:1"></a><a class="pred" href="#make/0">make/0</a>
319360 command described in <a class="sec" href="#sec:1.5">section 1.5</a>.</dd>
320361 <dt><b>File/Navigator ...</b></dt>
321362 <dd class="defbody">
367408 </dd>
368409 </dl>
369410
370 <p><h3 id="sec:edit"><a name="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Editing
411 <p><h3 id="sec:edit"><a id="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Editing
371412 Prolog programs</span></a></h3>
372413
373 <a name="sec:edit"></a>
414 <a id="sec:edit"></a>
374415
375416 <p>There are three options for editing. One is to run an editor of
376 choice in a separate window and use the <a name="idx:make0:2"></a><a class="pred" href="#make/0">make/0</a>
417 choice in a separate window and use the <a id="idx:make0:2"></a><a class="pred" href="#make/0">make/0</a>
377418 command described below to reload modified files. In addition to this
378419 option Prolog can be used to locate predicates, modules and loaded files
379 by specifying the editor of choice for use with the <a name="idx:edit1:3"></a><a class="pred" href="#edit/1">edit/1</a>
420 by specifying the editor of choice for use with the <a id="idx:edit1:3"></a><a class="pred" href="#edit/1">edit/1</a>
380421 command, described below. This is achieved by editing the
381422 personalisation file (see <a class="sec" href="#sec:1.3">section 1.3</a>)
382423 and following the instructions in the comments.
390431 <a class="url" href="http://www.swi-prolog.org/IDE.html">http://www.swi-prolog.org/IDE.html</a>
391432 for an up-to-date overview.
392433
393 <p><h3 id="sec:commands"><a name="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Some
434 <p><h3 id="sec:commands"><a id="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Some
394435 useful commands</span></a></h3>
395436
396 <a name="sec:commands"></a>
437 <a id="sec:commands"></a>
397438
398439 <p>This section provides a very brief overview of important or commonly
399440 used SWI-Prolog predicates to control the environment.
400441
401442 <dl class="latex">
402 <dt class="pubdef"><a name="consult/1"><strong>consult</strong>(<var>:File</var>)</a></dt>
443 <dt class="pubdef"><a id="consult/1"><strong>consult</strong>(<var>:File</var>)</a></dt>
403444 <dd class="defbody">
404445 Load a source file. On Windows, folders may be specified with the
405446 DOS/Windows <code><code>\</code></code>, which must be escaped, or by
410451 as well as the selected alternative) can be omitted. Here are some
411452 examples:
412453
413 <p><table border="0" frame="void" rules="groups" style="margin:auto">
414 <tr valign="top"><td><code>?- consult(likes).</code></td><td>Load <code>likes.pl</code>
415 from the current folder (see <a name="idx:pwd0:4"></a><a class="pred" href="#pwd/0">pwd/0</a>). </td></tr>
416 <tr valign="top"><td><code>?- ['C:/Program Files/pl/demo/likes']</code></td><td>Load <code>likes.pl</code>
454 <p><table class="latex frame-void center">
455 <tr><td><code>?- consult(likes).</code></td><td>Load <code>likes.pl</code>
456 from the current folder (see <a id="idx:pwd0:4"></a><a class="pred" href="#pwd/0">pwd/0</a>). </td></tr>
457 <tr><td><code>?- ['C:/Program Files/pl/demo/likes']</code></td><td>Load <code>likes.pl</code>
417458 using absolute path. </td></tr>
418 <tr valign="top"><td><code>?- ['C:<code>\</code><code>\</code>Program&nbsp;Files<code>\</code><code>\</code>pl<code>\</code><code>\</code>demo<code>\</code><code>\</code>likes']</code></td><td>Same
459 <tr><td><code>?- ['C:<code>\</code><code>\</code>Program&nbsp;Files<code>\</code><code>\</code>pl<code>\</code><code>\</code>demo<code>\</code><code>\</code>likes']</code></td><td>Same
419460 using Windows-style path name </td></tr>
420461 </table>
421462 </dd>
422 <dt class="pubdef"><a name="pwd/0"><strong>pwd</strong></a></dt>
463 <dt class="pubdef"><a id="pwd/0"><strong>pwd</strong></a></dt>
423464 <dd class="defbody">
424465 Print working directory (folder).</dd>
425 <dt class="pubdef"><a name="ls/0"><strong>ls</strong></a></dt>
466 <dt class="pubdef"><a id="ls/0"><strong>ls</strong></a></dt>
426467 <dd class="defbody">
427468 List files in current directory.</dd>
428 <dt class="pubdef"><a name="edit/0"><strong>edit</strong></a></dt>
469 <dt class="pubdef"><a id="edit/0"><strong>edit</strong></a></dt>
429470 <dd class="defbody">
430471 If Prolog is started by opening a <code>.pl</code> file in the explorer,
431472 edit this file. Also available from the menu.</dd>
432 <dt class="pubdef"><a name="edit/1"><strong>edit</strong>(<var>+Spec</var>)</a></dt>
473 <dt class="pubdef"><a id="edit/1"><strong>edit</strong>(<var>+Spec</var>)</a></dt>
433474 <dd class="defbody">
434475 Edit file, predicate, module, etc., with the given name. If multiple
435476 items are named <var>Spec</var> it prompts for the desired alternative.</dd>
436 <dt class="pubdef"><a name="make/0"><strong>make</strong></a></dt>
477 <dt class="pubdef"><a id="make/0"><strong>make</strong></a></dt>
437478 <dd class="defbody">
438479 Reload all files that have been changed since they were last loaded.
439480 Normally used after editing one or more files.</dd>
440 <dt class="pubdef"><a name="gtrace/0"><strong>gtrace</strong></a></dt>
481 <dt class="pubdef"><a id="gtrace/0"><strong>gtrace</strong></a></dt>
441482 <dd class="defbody">
442483 Start the graphical debugger. There are three ways to use this. Entered
443484 as a single goal at the top level, the next query will be traced.
453494 </pre>
454495
455496 </dd>
456 <dt class="pubdef"><a name="trace/0"><strong>trace</strong></a></dt>
497 <dt class="pubdef"><a id="trace/0"><strong>trace</strong></a></dt>
457498 <dd class="defbody">
458499 Same as gtrace, but text-based on the console.</dd>
459 <dt class="pubdef"><a name="apropos/1"><strong>apropos</strong>(<var>+Keyword</var>)</a></dt>
500 <dt class="pubdef"><a id="apropos/1"><strong>apropos</strong>(<var>+Keyword</var>)</a></dt>
460501 <dd class="defbody">
461502 Search for all predicates that contain <var>Keyword</var> in their name
462503 or short description. If a GUI environment is available the results are
463 hyperlinks. Otherwise use <a name="idx:help1:5"></a><a class="pred" href="#help/1">help/1</a>
504 hyperlinks. Otherwise use <a id="idx:help1:5"></a><a class="pred" href="#help/1">help/1</a>
464505 to get details on selected hits.</dd>
465 <dt class="pubdef"><a name="help/1"><strong>help</strong>(<var>+Spec</var>)</a></dt>
506 <dt class="pubdef"><a id="help/1"><strong>help</strong>(<var>+Spec</var>)</a></dt>
466507 <dd class="defbody">
467508 Give help on <var>Spec</var>, which is normally the name of a predicate
468509 or C interface function.
471512
472513 <p>
473514
474 <h2><a name="sec:2"><span class="sec-nr">2</span> <span class="sec-title">Using
515 <h2><a id="sec:2"><span class="sec-nr">2</span> <span class="sec-title">Using
475516 SWI-Prolog with C/C++</span></a></h2>
476517
477 <p>Using http://www.mingw.orgMinGW or a compiler with a compatible
478 calling format you can write C or C++ code that can be loaded into
479 SWI-Prolog and called as a predicate. You can also embed SWI-Prolog in
480 C/C++ applications.
518 <p>Using <a class="url" href="http://www.mingw.org">MinGW</a> or a
519 compiler with a compatible calling format you can write C or C++ code
520 that can be loaded into SWI-Prolog and called as a predicate. You can
521 also embed SWI-Prolog in C/C++ applications.
481522
482523 <p>Details on how to interact with Prolog are in the
483 http://www.swi-prolog.org/pldoc/refman/SWI-Prolog reference manual . The
484 mailing list archives and TWiki web provide problems and solutions to
485 the many problems that may occur. Documentation of the
524 <a class="url" href="http://www.swi-prolog.org/pldoc/refman/">SWI-Prolog
525 reference manual</a>. The mailing list archives and TWiki web provide
526 problems and solutions to the many problems that may occur.
527 Documentation of the
486528 <code>SWI-cpp.h</code> C++ include file is available from the
487 http://www.swi-prolog.org/pldoc/package/pl2cpp.htmlpackage documentation
488 . This section only discusses some Windows-specific issues.
489
490 <p>
491
492 <h3><a name="sec:2.1"><span class="sec-nr">2.1</span> <span class="sec-title">Using
529 <a class="url" href="http://www.swi-prolog.org/pldoc/package/pl2cpp.html">package
530 documentation</a>. This section only discusses some Windows-specific
531 issues.
532
533 <p>
534
535 <h3><a id="sec:2.1"><span class="sec-nr">2.1</span> <span class="sec-title">Using
493536 MSVC</span></a></h3>
494537
495538 <blockquote> Because the current versions of SWI-Prolog are compiled and
529572
530573 <p>To create an executable that does not rely on Prolog one must create
531574 a saved state of the required Prolog code and attach this to the
532 executable. Creating saved states is described with <a name="idx:qsaveprogram2:6"></a><span class="pred-ext">qsave_program/2</span>
575 executable. Creating saved states is described with <a id="idx:qsaveprogram2:6"></a><span class="pred-ext">qsave_program/2</span>
533576 in the reference manual. This can be attached to a state using the DOS
534577 command below to create <code>final.exe</code> from the executable
535578 produced by MSVC and the generated saved state.
540583
541584 <p>
542585
543 <h3><a name="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">Using
586 <h3><a id="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">Using
544587 swipl-ld.exe</span></a></h3>
545588
546589 <p>The <b>swipl-ld.exe</b> automates most of the above complications and
564607
565608 <p>
566609
567 <h2><a name="sec:3"><span class="sec-nr">3</span> <span class="sec-title">The
610 <h2><a id="sec:3"><span class="sec-nr">3</span> <span class="sec-title">The
568611 installation</span></a></h2>
569612
570 <p><h3 id="sec:winver"><a name="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">Supported
613 <p><h3 id="sec:winver"><a id="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">Supported
571614 Windows versions</span></a></h3>
572615
573 <a name="sec:winver"></a>
616 <a id="sec:winver"></a>
574617
575618 <p>SWI-Prolog requiring Windows XP or later (XP, Vista, Windows-7). The
576619 download site of SWI-Prolog contains older binaries that run on older
577620 versions of Windows. We provide both 32-bit and 64-bit installers.
578621
579 <p><h3 id="sec:ext"><a name="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Choosing
622 <p><h3 id="sec:ext"><a id="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Choosing
580623 the file extension</span></a></h3>
581624
582 <a name="sec:ext"></a>
625 <a id="sec:ext"></a>
583626
584627 <p>By default, Prolog uses the <code>.pl</code> extension to indicate
585628 Prolog source files. Unfortunately this extension conflicts with the
594637
595638 <p>
596639
597 <h3><a name="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">Installed
640 <h3><a id="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">Installed
598641 programs</span></a></h3>
599642
600643 <p>The table below lists the installed components. Some components are
603646 of required libraries using different naming conventions. This will
604647 probably be synchronised in the future.
605648
606 <p><table border="2" frame="box" rules="groups" style="margin:auto">
607 <tr valign="top"><td colspan=2 align=center>Programs</tr>
608 <tbody>
609 <tr valign="top"><td><code>bin\swipl-win.exe</code> </td><td>Default
649 <p><table class="latex frame-box center">
650 <tr><td colspan=2 align=center>Programs</tr>
651 <tr class="hline"><td><code>bin\swipl-win.exe</code> </td><td>Default
610652 Windows application for interactive use. </td></tr>
611 <tr valign="top"><td><code>bin\swipl.exe</code> </td><td>Console-based
612 version for scripting purposes. </td></tr>
613 <tbody>
614 <tr valign="top"><td colspan=2 align=center>Utilities</tr>
615 <tbody>
616 <tr valign="top"><td><code>bin\swipl-ld.exe</code> </td><td>Linker
653 <tr><td><code>bin\swipl.exe</code> </td><td>Console-based version for
654 scripting purposes. </td></tr>
655 <tr class="hline"><td colspan=2 align=center>Utilities</tr>
656 <tr class="hline"><td><code>bin\swipl-ld.exe</code> </td><td>Linker
617657 front-end to make single-file mixed Prolog/C/C++ executables. </td></tr>
618 <tr valign="top"><td><code>bin\swipl-rc.exe</code> </td><td>Manipulate
619 Prolog resource files. </td></tr>
620 <tbody>
621 <tr valign="top"><td colspan=2 align=center>Important directories</tr>
622 <tbody>
623 <tr valign="top"><td><code>bin</code> </td><td>Executables and DLL files </td></tr>
624 <tr valign="top"><td><code>library</code> </td><td>Prolog library </td></tr>
625 <tr valign="top"><td><code>boot</code> </td><td>Sources for system
626 predicates </td></tr>
627 <tr valign="top"><td><code>include</code> </td><td>C/C++ header files
628 for embedding or to create extensions </td></tr>
629 <tr valign="top"><td><code>xpce</code> </td><td>XPCE graphics system </td></tr>
630 <tr valign="top"><td><code>xpce\prolog\lib</code> </td><td>XPCE/Prolog
631 library </td></tr>
632 <tbody>
633 <tr valign="top"><td colspan=2 align=center>DLLs and other supporting
658 <tr><td><code>bin\swipl-rc.exe</code> </td><td>Manipulate Prolog
659 resource files. </td></tr>
660 <tr class="hline"><td colspan=2 align=center>Important directories</tr>
661 <tr class="hline"><td><code>bin</code> </td><td>Executables and DLL
662 files </td></tr>
663 <tr><td><code>library</code> </td><td>Prolog library </td></tr>
664 <tr><td><code>boot</code> </td><td>Sources for system predicates </td></tr>
665 <tr><td><code>include</code> </td><td>C/C++ header files for embedding
666 or to create extensions </td></tr>
667 <tr><td><code>xpce</code> </td><td>XPCE graphics system </td></tr>
668 <tr><td><code>xpce\prolog\lib</code> </td><td>XPCE/Prolog library </td></tr>
669 <tr class="hline"><td colspan=2 align=center>DLLs and other supporting
634670 files</tr>
635 <tbody>
636 <tr valign="top"><td><code>boot32.prc</code> </td><td>Initial Prolog
671 <tr class="hline"><td><code>boot32.prc</code> </td><td>Initial Prolog
637672 state (32-bits) </td></tr>
638 <tr valign="top"><td><code>boot64.prc</code> </td><td>Initial Prolog
639 state (64-bits) </td></tr>
640 <tr valign="top"><td><code>\bin\libswipl.dll</code> </td><td>The Prolog
641 kernel </td></tr>
642 <tr valign="top"><td><code>\bin\plterm.dll</code> </td><td>The window
643 for <b>swipl-win.exe</b> </td></tr>
644 <tr valign="top"><td><code>\bin\pthreadVC2.dll</code></td><td>POSIX
645 thread runtime library (64-bits) </td></tr>
646 <tbody>
647 <tr valign="top"><td colspan=2 align=center>Extension DLLs (plugins)</tr>
648 <tbody>
649 <tr valign="top"><td><code>\bin\cgi.dll</code> </td><td>Gather CGI GET
673 <tr><td><code>boot64.prc</code> </td><td>Initial Prolog state (64-bits) </td></tr>
674 <tr><td><code>\bin\libswipl.dll</code> </td><td>The Prolog kernel </td></tr>
675 <tr><td><code>\bin\plterm.dll</code> </td><td>The window for <b>swipl-win.exe</b> </td></tr>
676 <tr><td><code>\bin\pthreadVC2.dll</code></td><td>POSIX thread runtime
677 library (64-bits) </td></tr>
678 <tr class="hline"><td colspan=2 align=center>Extension DLLs (plugins)</tr>
679 <tr class="hline"><td><code>\bin\cgi.dll</code> </td><td>Gather CGI GET
650680 and POST arguments </td></tr>
651 <tr valign="top"><td><code>\bin\double_metaphone.dll</code> </td><td>Soundex
652 (sounds similar) </td></tr>
653 <tr valign="top"><td><code>\bin\memfile.dll</code> </td><td>In-memory
654 temporary `files' </td></tr>
655 <tr valign="top"><td><code>\bin\odbc4pl.dll</code> </td><td>ODBC
681 <tr><td><code>\bin\double_metaphone.dll</code> </td><td>Soundex (sounds
682 similar) </td></tr>
683 <tr><td><code>\bin\memfile.dll</code> </td><td>In-memory temporary
684 `files' </td></tr>
685 <tr><td><code>\bin\odbc4pl.dll</code> </td><td>ODBC interface </td></tr>
686 <tr><td><code>\bin\plregtry.dll</code> </td><td>Windows registry
656687 interface </td></tr>
657 <tr valign="top"><td><code>\bin\plregtry.dll</code> </td><td>Windows
658 registry interface </td></tr>
659 <tr valign="top"><td><code>\bin\porter_stem.dll</code> </td><td>Porter
660 stemming implementation </td></tr>
661 <tr valign="top"><td><code>\bin\random.dll</code> </td><td>Portable
662 random number generator </td></tr>
663 <tr valign="top"><td><code>\bin\rdf_db.dll</code> </td><td>RDF database </td></tr>
664 <tr valign="top"><td><code>\bin\readutil.dll</code> </td><td>Fast
665 reading utility </td></tr>
666 <tr valign="top"><td><code>\bin\sgml2pl.dll</code> </td><td>SGML/XML
667 parser </td></tr>
668 <tr valign="top"><td><code>\bin\socket.dll</code> </td><td>Prolog socket
688 <tr><td><code>\bin\porter_stem.dll</code> </td><td>Porter stemming
689 implementation </td></tr>
690 <tr><td><code>\bin\random.dll</code> </td><td>Portable random number
691 generator </td></tr>
692 <tr><td><code>\bin\rdf_db.dll</code> </td><td>RDF database </td></tr>
693 <tr><td><code>\bin\readutil.dll</code> </td><td>Fast reading utility </td></tr>
694 <tr><td><code>\bin\sgml2pl.dll</code> </td><td>SGML/XML parser </td></tr>
695 <tr><td><code>\bin\socket.dll</code> </td><td>Prolog socket interface </td></tr>
696 <tr><td><code>\bin\table.dll</code> </td><td>Access structured files as
697 tables </td></tr>
698 <tr><td><code>\bin\time.dll</code> </td><td>Timing and alarm library </td></tr>
699 <tr><td><code>\bin\xpce2pl.dll</code> </td><td>The XPCE graphics system </td></tr>
700 <tr><td><code>\bin\zlib1.dll</code> </td><td>Compression library
701 (32-bits) </td></tr>
702 <tr><td><code>\bin\zlibwapi.dll</code> </td><td>Compression library
703 (64-bits) </td></tr>
704 <tr><td><code>\bin\zlib4pl.dll</code> </td><td>Compression library
669705 interface </td></tr>
670 <tr valign="top"><td><code>\bin\table.dll</code> </td><td>Access
671 structured files as tables </td></tr>
672 <tr valign="top"><td><code>\bin\time.dll</code> </td><td>Timing and
673 alarm library </td></tr>
674 <tr valign="top"><td><code>\bin\xpce2pl.dll</code> </td><td>The XPCE
675 graphics system </td></tr>
676 <tr valign="top"><td><code>\bin\zlib1.dll</code> </td><td>Compression
677 library (32-bits) </td></tr>
678 <tr valign="top"><td><code>\bin\zlibwapi.dll</code> </td><td>Compression
679 library (64-bits) </td></tr>
680 <tr valign="top"><td><code>\bin\zlib4pl.dll</code> </td><td>Compression
681 library interface </td></tr>
682706 </table>
683707
684708 <p>
685709
686 <h3><a name="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Installed
710 <h3><a id="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Installed
687711 Registry keys and menus</span></a></h3>
688712
689713 <p>The filetype <code>.pl</code> or chosen alternative (see <a class="sec" href="#sec:3.2">section
696720 <code>.pl</code> file can be associated with one of the installed Prolog
697721 versions only.
698722
699 <p><table border="2" frame="box" rules="groups" style="margin:auto">
700 <tr valign="top"><td colspan=2 align=center><code>HKEY_LOCAL_MACHINE<code>\</code>Software<code>\</code>SWI<code>\</code>Prolog</code></tr>
701 <tbody>
702 <tr valign="top"><td><code>fileExtension</code> </td><td>Extension used
723 <p><table class="latex frame-box center">
724 <tr><td colspan=2 align=center><code>HKEY_LOCAL_MACHINE<code>\</code>Software<code>\</code>SWI<code>\</code>Prolog</code></tr>
725 <tr class="hline"><td><code>fileExtension</code> </td><td>Extension used
703726 for Prolog files </td></tr>
704 <tr valign="top"><td><code>group</code> </td><td>Start menu group </td></tr>
705 <tr valign="top"><td><code>home</code> </td><td>Installation directory </td></tr>
706 <tbody>
707 <tr valign="top"><td colspan=2 align=center><code>HKEY_CURRENT_USER<code>\</code>Software<code>\</code>SWI<code>\</code>Plwin<code>\</code>Console</code></tr>
708 <tr valign="top"><td colspan=2 align=center>Note: thread-windows store
709 the same info in sub-keys</tr>
710 <tbody>
711 <tr valign="top"><td><code>Height</code> </td><td>Height of window in
727 <tr><td><code>group</code> </td><td>Start menu group </td></tr>
728 <tr><td><code>home</code> </td><td>Installation directory </td></tr>
729 <tr class="hline"><td colspan=2 align=center><code>HKEY_CURRENT_USER<code>\</code>Software<code>\</code>SWI<code>\</code>Plwin<code>\</code>Console</code></tr>
730 <tr><td colspan=2 align=center>Note: thread-windows store the same info
731 in sub-keys</tr>
732 <tr class="hline"><td><code>Height</code> </td><td>Height of window in
712733 character units </td></tr>
713 <tr valign="top"><td><code>Width</code> </td><td>Width of window in
714 character units </td></tr>
715 <tr valign="top"><td><code>X</code> </td><td>Left edge of window in
716 pixel units </td></tr>
717 <tr valign="top"><td><code>Y</code> </td><td>Top edge of window in pixel
718 units </td></tr>
719 <tr valign="top"><td><code>SaveLines</code> </td><td>Number of lines
720 available for scrollback </td></tr>
734 <tr><td><code>Width</code> </td><td>Width of window in character units </td></tr>
735 <tr><td><code>X</code> </td><td>Left edge of window in pixel units </td></tr>
736 <tr><td><code>Y</code> </td><td>Top edge of window in pixel units </td></tr>
737 <tr><td><code>SaveLines</code> </td><td>Number of lines available for
738 scrollback </td></tr>
721739 </table>
722740
723741 <p>
724742
725 <h3><a name="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">Execution
743 <h3><a id="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">Execution
726744 level</span></a></h3>
727745
728746 <p>The installer asks for the <code>admin</code> execution level (Vista
730748
731749 <p>
732750
733 <h3><a name="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">Creating
751 <h3><a id="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">Creating
734752 a desktop menu item</span></a></h3>
735753
736754 <p>If you want a desktop entry for SWI-Prolog, right-drag
740758
741759 <p>
742760
743 <h2><a name="sec:4"><span class="sec-nr">4</span> <span class="sec-title">The
761 <h2><a id="sec:4"><span class="sec-nr">4</span> <span class="sec-title">The
744762 SWI-Prolog community and foundation</span></a></h2>
745763
746764 <p>
747765
748 <h3><a name="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Website
766 <h3><a id="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Website
749767 and mailing lists</span></a></h3>
750768
751769 <p>The SWI-Prolog website is located at <a class="url" href="http://www.swi-prolog.org/">http://www.swi-prolog.org/</a>.
752770
753771 <p>
754772
755 <h3><a name="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">About
773 <h3><a id="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">About
756774 license conditions</span></a></h3>
757775
758776 <p>The SWI-Prolog license allows it to be used in a wide variety of
778796
779797 <p>
780798
781 <h3><a name="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Supporting
799 <h3><a id="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Supporting
782800 SWI-Prolog</span></a></h3>
783801
784802 <p>There are several ways to support SWI-Prolog:
803821 programmers.
804822 </ul>
805823
806 <h1><a name="document-index">Index</a></h1>
824 <h1><a id="document-index">Index</a></h1>
807825
808826 <dl>
809827 <dt class="index-sep">?</dt>
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
6767 /* PLVERSION_TAG: a string, normally "", but for example "rc1" */
6868
6969 #ifndef PLVERSION
70 #define PLVERSION 70602
70 #define PLVERSION 70603
7171 #endif
7272 #ifndef PLVERSION_TAG
7373 #define PLVERSION_TAG ""
338338 { const char *s = stringAtom(val);
339339 if ( strlen(s) > 10 )
340340 { strncpy(o, s, 10);
341 strcat(o, "...");
341 strcpy(o+10, "...");
342342 } else
343343 { strcpy(o, s);
344344 }
17381738 case C_LCUT:
17391739 case C_SOFTCUT:
17401740 case C_LCUTIFTHEN:
1741 case C_FASTCUT:
17411742 mark_choice_mark(state, PC[0]);
17421743 break;
17431744 /* variable access */
39783979 if ( gc_status.blocked || !truePrologFlag(PLFLAG_GC) )
39793980 return FALSE;
39803981
3982 assert(LD->fast_condition == NULL);
3983
39813984 #ifdef O_MAINTENANCE
39823985 save_backtrace("GC");
39833986 #endif
27262726
27272727 VMI(S_VIRGIN, 0, 0, ())
27282728 { lTop = (LocalFrame)argFrameP(FR, FR->predicate->functor->arity);
2729 SAVE_REGISTERS(qid);
2730 DEF = getProcDefinedDefinition(DEF PASS_LD);
2731 LOAD_REGISTERS(qid);
2732
2733 if ( FR->predicate != DEF ) /* auto imported/loaded */
2734 { FR->predicate = DEF;
2729
2730 if ( !DEF->impl.any && false(DEF, PROC_DEFINED) )
2731 { SAVE_REGISTERS(qid);
2732 DEF = getProcDefinedDefinition(DEF PASS_LD);
2733 LOAD_REGISTERS(qid);
2734
2735 FR->predicate = DEF;
27352736 #ifdef O_PROFILE
27362737 if ( FR->prof_node )
27372738 profSetHandle(FR->prof_node, DEF);
27382739 #endif
27392740 goto retry_continue;
2741 #ifdef O_PLMT
2742 } else if ( true(DEF, P_THREAD_LOCAL) )
2743 { DEF = getProcDefinition__LD(DEF PASS_LD);
2744 FR->predicate = DEF;
2745 #endif
27402746 }
27412747
27422748 if ( createSupervisor(DEF) )
30853091 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
30863092
30873093 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3088 A_ENTER: Ensure the alignment of ARGP allows for efficient pushing of
3089 the number structure. We must check for availaible space to support
3090 bindConst() (wakeup and trail) because the resulting value may possibly
3091 not be shifted. See is/2 in pl-arith.c for details.
3094 A_ENTER: Prepare for arithmetic operations.
30923095 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
30933096
30943097 VMI(A_ENTER, 0, 0, ())
3095 { if ( !hasGlobalSpace(0) )
3096 { int rc;
3097
3098 SAVE_REGISTERS(qid);
3099 rc = ensureGlobalSpace(0, ALLOW_GC);
3100 LOAD_REGISTERS(qid);
3101 if ( rc != TRUE )
3102 { raiseStackOverflow(rc);
3103 THROW_EXCEPTION;
3104 }
3105 }
3106
3107 AR_BEGIN();
3098 { AR_BEGIN();
31083099 NEXT_INSTRUCTION;
31093100 }
31103101