Codebase list swi-prolog / d8a8066
New upstream version 7.6.4+dfsg Lev Lamberov 6 years ago
316 changed file(s) with 16164 addition(s) and 23479 deletion(s). Raw diff Collapse all Expand all
4949 #
5050 # UBUNTU PACKAGES
5151 #
52 # Tested on Ubuntu 12.04 on AMD64. Installing wine in this version is
53 # broken, but can be get te work using the following commands. In
54 # particular WINE-GECKO MUST BE INSTALLED FIRST.
55 #
56 # - Remove all wine and wingw packages
57 # - apt-get install wine-gecko1.5
58 # - apt-get install wine
52 # Tested on Ubuntu 17.10 on AMD64.
53 #
54 # - apt-get install wine-stable wine-binfmt
5955 # - apt-get install mingw-w64
60 #
61 # If you cannot run Win64 executables with your wine, .wine is out of
62 # date. The only working advice I found sofar is to (re)move .wine and
63 # start wine to create a fresh installation.
64 #
65 # Linux must be configured such that Windows .exe files can be executed
66 # directly without explicit invocation of wine. See
67 # https://www.kernel.org/doc/Documentation/binfmt_misc.txt
68 #
69 # Updated for Ubuntu 14.04. This version ships with MinGW 4.8, which
70 # provides winpthread. If you upgrade, you must remove pthreads-w32 and
71 # recompile the prerequisites to depend on MinGW's native pthreads:
72 #
73 # - Remove pthreads-w32 and all traces from $install/bin, $install/lib
74 # and $install/include
75 # - Copy the new libgcc_s_sjlj-1.dll and libwinpthread-1.dll from the
76 # GCC installation to $install/bin
77 # - Run clean_prerequisites (function in this script)
78 # - Run build_prerequisites (function in this script)
7956
8057 TARGETHOST="$1"
8158 MAKE="make -j 4"
0 7.6.3
0 7.6.4
109109 b_setval('$term', Term),
110110 '$def_modules'([term_expansion/4,term_expansion/2], MList),
111111 call_term_expansion(MList, Term, Pos0, Term1, Pos1),
112 expand_term_2(Term1, Pos1, Term2, Pos),
112 expand_terms(expand_term_2, Term1, Pos1, Term2, Pos),
113113 rename(Term2, Expanded),
114114 b_setval('$term', []).
115115
4343
4444 gc_loop :-
4545 repeat,
46 '$thread_sigwait'(Signal),
47 ( Signal == 'prolog:abort'
46 '$gc_wait'(Action),
47 ( Action == abort
4848 -> true
49 ; process(Signal)
50 -> fail
51 ; print_message(warning, gc(ignored(Signal)))
49 ; process(Action)
50 -> '$gc_clear'(Action),
51 fail
52 ; print_message(warning, gc(ignored(Action))),
53 fail
5254 ).
5355
54 process('prolog:atom_gc') :-
56 process(garbage_collect_atoms) :-
5557 garbage_collect_atoms.
56 process('prolog:clause_gc') :-
58 process(garbage_collect_clauses) :-
5759 garbage_collect_clauses.
8080 term_string/3, % ?Term, ?String, +Options
8181 nb_setval/2, % +Var, +Value
8282 thread_create/2, % :Goal, -Id
83 thread_join/1 % +Id
83 thread_join/1, % +Id
84 set_prolog_gc_thread/1 % +Status
8485 ]).
8586
8687 /********************************
13161317 stack_property(limit).
13171318 stack_property(spare).
13181319 stack_property(min_free).
1320 stack_property(low).
1321 stack_property(factor).
13191322
13201323
13211324 /*******************************
13941397 -> true
13951398 ; throw(error(thread_error(Status), _))
13961399 ).
1400
1401 %! set_prolog_gc_thread(+Status)
1402 %
1403 % Control the GC thread. Status is one of
1404 %
1405 % - false
1406 % Disable the separate GC thread, running atom and clause
1407 % garbage collection in the triggering thread.
1408 % - true
1409 % Enable the separate GC thread. All implicit atom and clause
1410 % garbage collection is executed by the thread `gc`.
1411 % - stop
1412 % Stop the `gc` thread it it is running. The thread is recreated
1413 % on the next implicit atom or clause garbage collection. Used
1414 % by fork/1 to avoid forking a multi-threaded application.
1415
1416 set_prolog_gc_thread(Status) :-
1417 var(Status),
1418 !,
1419 '$instantiation_error'(Status).
1420 :- if(current_prolog_flag(threads,true)).
1421 set_prolog_gc_thread(false) :-
1422 !,
1423 set_prolog_flag(gc_thread, false),
1424 ( '$gc_stop'
1425 -> thread_join(gc)
1426 ; true
1427 ).
1428 set_prolog_gc_thread(true) :-
1429 !,
1430 set_prolog_flag(gc_thread, true).
1431 set_prolog_gc_thread(stop) :-
1432 !,
1433 ( '$gc_stop'
1434 -> thread_join(gc)
1435 ; true
1436 ).
1437 :- else.
1438 set_prolog_gc_thread(false) :- !.
1439 set_prolog_gc_thread(true) :- !.
1440 set_prolog_gc_thread(stop) :- !.
1441 :- endif.
1442 set_prolog_gc_thread(Status) :-
1443 '$domain_error'(gc_thread, Status).
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_-_3_, _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_-_4_, _J_a_n_u_a_r_y _2_0_1_8
99
1010 _J_a_n _W_i_e_l_e_m_a_k_e_r
1111 J.Wielemaker@vu.nl
670670 desirable for embedded applications. This option sets the flag
671671 signals to false. See section ???? for details. Note that the
672672 handler to unblock system calls is still installed. This can be
673 prevented using --sigalert=0 additionally. See --sigalert. This
674 flag also sets gc_thread to false as synchronization with the
675 garbage collect thread is based on signals.
673 prevented using --sigalert=0 additionally. See --sigalert.
676674
677675 --pldoc _[_=_p_o_r_t_]
678676 Start the PlDoc documentation system on a free network port and
686684 immediately when the target thread is blocked on an interruptable
687685 system call (e.g., sleep/1, read/write to most devices). The
688686 default is to use SIGUSR2. If _N_U_M is 0 (zero), this handler is not
689 installed.
687 installed. See prolog_alert_signal/2to query or modify this value
688 at runtime.
690689
691690 -tty
692691 Unix only. Switches controlling the terminal for allowing
17451744 neither garbage collection, nor stack shifts will take place,
17461745 even not on explicit request. May be changed.
17471746
1748 rrcc__tthhrreeaadd _(_b_o_o_l_, _c_h_a_n_g_e_a_b_l_e_)
1747 ggcc__tthhrreeaadd _(_b_o_o_l_)
17491748 If true (default if threading is enabled), atom and clause
17501749 garbage collection are executed in a seperate thread with
17511750 the _a_l_i_a_s gc. Otherwise the thread the detect sufficient
17521751 garbage executes the garbage collector. As running these
17531752 global collectors may take relatively using a seperate thread
1754 improves real time behaviour.
1753 improves real time behaviour. The gc thread can be controlled
1754 using set_prolog_gc_thread/1.
17551755
17561756 ggeenneerraattee__ddeebbuugg__iinnffoo _(_b_o_o_l_, _c_h_a_n_g_e_a_b_l_e_)
17571757 If true (default) generate code that can be debugged using
53615361 content to the new.
53625362
53635363
5364 ggaarrbbaaggee__ccoolllleecctt__ccllaauusseess
5365 Reclaim retracted clauses. During normal operation, retracting
5366 a clause implies setting the _e_r_a_s_e_d _g_e_n_e_r_a_t_i_o_n to the current
5367 _g_e_n_e_r_a_t_i_o_n of the database and increment the generation. Keeping
5368 the clause around is both needed to realise the _l_o_g_i_c_a_l _u_p_d_a_t_e _v_i_e_w
5369 and deal with the fact that other threads may be executing the
5370 clause. Both static and dynamic code is processed this way..
5371
5372 The clause garbage collector (CGC) scans the environment stacks of
5373 all threads for referenced dirty predicates and at which generation
5374 this reference accesses the predicate. It then removes the
5375 references for clauses that have been retracted before the oldest
5376 access generation from the clause list as well as the secondary
5377 clauses indexes of the predicate. If the clause list is not being
5378 scanned, the clause references and ultimately the clause itself is
5379 reclaimed.
5380
5381 The clause garbage collector is called under three conditions,
5382 (1) after _r_e_l_o_a_d_i_n_g a source file, (2) if the memory occupied
5383 by retracted but not yet reclaimed clauses exceeds 12.5% of the
5384 program store, or (3) if skipping dead clauses in the clause lists
5385 becomes too costly. The cost of clause garbage collection is
5386 proportional with the total size of the local stack of all threads
5387 (the scanning phase) and the number of clauses in all `dirty'
5388 predicates (the reclaiming phase).
5389
5390
53915364 44..33..22..11 CCoommppiillaattiioonn ooff mmuuttuuaallllyy ddeeppeennddeenntt ccooddee
53925365
53935366 Large programs are generally split into multiple files. If file
69206893 Enumerate the currently defined signal handling. _N_a_m_e is the
69216894 signal name, _I_d is the numerical identifier and _H_a_n_d_l_e_r is the
69226895 currently defined handler (see on_signal/3).
6896
6897
6898 pprroolloogg__aalleerrtt__ssiiggnnaall((_?_O_l_d_, _+_N_e_w))
6899 Query or set the signal used to unblock blocking system calls on
6900 Unix systems and process pending Prolog signals. The default is
6901 SIGUSR2. See also --sigalert.
69236902
69246903
69256904 44..1122..11 NNootteess oonn ssiiggnnaall hhaannddlliinngg
1375613735 collection.
1375713736
1375813737
13738 ggaarrbbaaggee__ccoolllleecctt__ccllaauusseess
13739 Reclaim retracted clauses. During normal operation, retracting
13740 a clause implies setting the _e_r_a_s_e_d _g_e_n_e_r_a_t_i_o_n to the current
13741 _g_e_n_e_r_a_t_i_o_n of the database and increment the generation. Keeping
13742 the clause around is both needed to realise the _l_o_g_i_c_a_l _u_p_d_a_t_e _v_i_e_w
13743 and deal with the fact that other threads may be executing the
13744 clause. Both static and dynamic code is processed this way..
13745
13746 The clause garbage collector (CGC) scans the environment stacks of
13747 all threads for referenced dirty predicates and at which generation
13748 this reference accesses the predicate. It then removes the
13749 references for clauses that have been retracted before the oldest
13750 access generation from the clause list as well as the secondary
13751 clauses indexes of the predicate. If the clause list is not being
13752 scanned, the clause references and ultimately the clause itself is
13753 reclaimed.
13754
13755 The clause garbage collector is called under three conditions,
13756 (1) after _r_e_l_o_a_d_i_n_g a source file, (2) if the memory occupied
13757 by retracted but not yet reclaimed clauses exceeds 12.5% of the
13758 program store, or (3) if skipping dead clauses in the clause lists
13759 becomes too costly. The cost of clause garbage collection is
13760 proportional with the total size of the local stack of all threads
13761 (the scanning phase) and the number of clauses in all `dirty'
13762 predicates (the reclaiming phase).
13763
13764
13765 sseett__pprroolloogg__ggcc__tthhrreeaadd((_C))
13766 ontrol whether or not atom and clause garbage collection are
13767 executed in a dedicated thread. The default is true. Values for
13768 _S_t_a_t_u_s are true, false and stop. The latter stops the gc thread
13769 but allows is to be recreated lazily. This is use by e.g., fork/1
13770 to avoid forking a multi-threaded application. See also gc_thread.
13771
13772
1375913773 ttrriimm__ssttaacckkss
1376013774 Release stack memory resources that are not in use at this moment,
1376113775 returning them to the operating system. It can be used to release
1380313817 specified in `cells'. A cell is 4 bytes in the 32-bit version
1380413818 and 8 bytes on the 64-bit version. See address_bits. See also
1380513819 trim_stacks/0 and debug/0.
13820
13821 llooww((_+_C_e_l_l_s))
13822 ffaaccttoorr((_+_N_u_m_b_e_r))
13823 These two figures determine whether, if the stacks are
13824 low, a stack _s_h_i_f_t (expansion) or garbage collection is
13825 performed. This depends on these two parameters, the current
13826 stack usage and the amount of stack used after the last
13827 garbage collection. A garbage collection is started if
13828 used> factorl* astused+low.
1380613829
1380713830 ssppaarree((_+_C_e_l_l_s))
1380813831 All stacks trigger overflow before actually reaching the
2550025523 |Rows|=_[[9,_8,_7,_6,_5,_4,_3,_2|...],_..._,_[...|...]].________________ | |
2550125524
2550225525 In this concrete case, the constraint solver is strong enough to find
25503 the unique solution without any search.
25526 the unique solution without any search. For the general case, see
25527 search (section ????).
2550425528
2550525529
2550625530 1133..88..88 RReessiidduuaall ggooaallss
2556325587 Using CLP(FD) constraints to solve combinatorial tasks typically
2556425588 consists of two phases:
2556525589
25566 1. First, all relevant constraints are stated.
25567
25568 2. Second, if the domain of each involved variable is _f_i_n_i_t_e,
25569 then _e_n_u_m_e_r_a_t_i_o_n _p_r_e_d_i_c_a_t_e_s can be used to search for concrete
25570 solutions.
25590 1. MMooddeelliinngg. In this phase, all relevant constraints are stated.
25591
25592 2. SSeeaarrcchh. In this phase, _e_n_u_m_e_r_a_t_i_o_n _p_r_e_d_i_c_a_t_e_s are used to search
25593 for concrete solutions.
2557125594
2557225595 It is good practice to keep the modeling part, via a dedicated
2557325596 predicate called the ccoorree rreellaattiioonn, separate from the actual search for
2716027183 existing (external) resource that is represented by it.
2716127184
2716227185
27186 eexxiisstteennccee__eerrrroorr((_+_T_y_p_e_, _+_T_e_r_m_, _+_S_e_t))
27187 _T_e_r_m is of the correct type and correct domain, but there is
27188 no existing (external) resource that is represented by it in the
27189 provided set.
27190
27191 CCoommppaattiibbiilliittyy This error is not in ISO.
27192
27193
2716327194 ppeerrmmiissssiioonn__eerrrroorr((_+_A_c_t_i_o_n_, _+_T_y_p_e_, _+_T_e_r_m))
2716427195 It is not allowed to perform _A_c_t_i_o_n on the object _T_e_r_m that is of
2716527196 the given _T_y_p_e.
2805928090 not as --flagvalue); short flags as -f val or -fval (but not
2806028091 -f=val)
2806128092
28062 2. boolean long flags can be specified as --bool-flag or
28063 --bool-flag=true or --bool-flag true; and they can be negated as
28093 2. boolean long flags can be specified as --bool-flag or --bool-
28094 flag=true or --bool-flag true; and they can be negated as
2806428095 --no-bool-flag or --bool-flag=false or --bool-flag false.
2806528096
2806628097 Except that shortflags must be single characters, the distinction
2916829199
2916929200 1133..2266 lliibbrraarryy((pprroolloogg__ppaacckk)):: AA ppaacckkaaggee mmaannaaggeerr ffoorr PPrroolloogg
2917029201
29171 SSeeee aallssoo Installed packages can be inspected using
29172 ?- doc_browser.
29202 SSeeee aallssoo Installed packages can be inspected using ?-
29203 doc_browser.
2917329204
2917429205 TToo bbee ddoonnee
2917529206 - Version logic
3035730388 ignores the first _C_o_u_n_t solutions.
3035830389
3035930390
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))
30391 oorrddeerr__bbyy((_S_p_e_c_, _G_o_a_l))
3036730392 Order solutions according to _S_p_e_c. _S_p_e_c is a list of terms, where
3036830393 each element is one of. The ordering of solutions of _G_o_a_l that
3036930394 only differ in variables that are _n_o_t shared with _S_p_e_c is not
3331833343 profiler/2 Obtain/change status of the profiler
3331933344
3332033345 prolog/0 Run interactive top level
33346 prolog_alert_signal/2 Query/set unblock signal
3332133347 prolog_choice_attribute/3 Examine the choice point stack
3332233348 prolog_current_choice/1 Reference to most recent choice point
3332333349 prolog_current_frame/1 Reference to goal's environment stack
3332433350 prolog_cut_to/1 Realise global cuts
3332533351 prolog_edit:locate/2 Locate targets for edit/1
33352
3332633353 prolog_edit:locate/3 Locate targets for edit/1
33327
3332833354 prolog_edit:edit_source/1 Call editor for edit/1
3332933355 prolog_edit:edit_command/2 Specify editor activation
3333033356 prolog_edit:load/0 Load edit/1 extensions
3333233358 prolog_file_type/2 Define meaning of file extension
3333333359 prolog_frame_attribute/3 Obtain information on a goal environment
3333433360 prolog_ide/1 Program access to the development environment
33361
3333533362 prolog_list_goal/1 (hook) Intercept tracer 'L' command
33336
3333733363 prolog_load_context/2 Context information for directives
3333833364 prolog_load_file/2 (hook) Program load_files/2
3333933365 prolog_skip_level/2 Indicate deepest recursion to trace
3334033366 prolog_skip_frame/1 Perform `skip' on a frame
3334133367 prolog_stack_property/2 Query properties of the stacks
3334233368 prolog_to_os_filename/2 Convert between Prolog and OS filenames
33369
3334333370 prolog_trace_interception/4 user Intercept the Prolog tracer
33344
3334533371 project_attributes/2 Project constraints to query variables
3334633372 prompt1/1 Change prompt for 1 line
3334733373 prompt/2 Change the prompt used by read/1
3334933375 protocola/1 Append log of the user interaction to file
3335033376 protocolling/1 On what file is user interaction logged
3335133377 public/1 Declaration that a predicate may be called
33378
3335233379 put/1 Write a character
33353
3335433380 put/2 Write a character on a stream
3335533381 put_assoc/4 Add Key-Value to association tree
3335633382 put_attr/3 Put attribute on a variable
3335733383 put_attrs/2 Set/replace all attributes on a variable
3335833384 put_byte/1 Write a byte
3335933385 put_byte/2 Write a byte on a stream
33386
3336033387 put_char/1 Write a character
33361
3336233388 put_char/2 Write a character on a stream
3336333389 put_code/1 Write a character-code
3336433390 put_code/2 Write a character-code on a stream
3336633392 put_dict/4 Add/replace a single key in a dict
3336733393 qcompile/1 Compile source to Quick Load File
3336833394 qcompile/2 Compile source to Quick Load File
33395
3336933396 qsave_program/1 Create runtime application
33370
3337133397 qsave_program/2 Create runtime application
3337233398 quasi_quotation_syntax/1 Declare quasi quotation syntax
3337333399 quasi_quotation_syntax_error/1 Raise syntax error
3337433400 random_property/1 Query properties of random generation
3337533401 rational/1 Type check for a rational number
3337633402 rational/3 Decompose a rational
33403
3337733404 read/1 Read Prolog term
33378
3337933405 read/2 Read Prolog term from stream
3338033406 read_clause/3 Read clause from stream
3338133407 read_history/6 Read using history substitution
3338333409 read_pending_codes/3 Fetch buffered input from a stream
3338433410 read_pending_chars/3 Fetch buffered input from a stream
3338533411 read_string/3 Read a number of characters into a string
33412
3338633413 read_string/5 Read string upto a delimiter
33387
3338833414 read_term/2 Read term with options
3338933415 read_term/3 Read term with options from stream
3339033416 read_term_from_atom/3 Read term with options from atom
3339133417 recorda/2 Record term in the database (first)
3339233418 recorda/3 Record term in the database (first)
3339333419 recorded/2 Obtain term from the database
33420
3339433421 recorded/3 Obtain term from the database
33395
3339633422 recordz/2 Record term in the database (last)
3339733423 recordz/3 Record term in the database (last)
3339833424 redefine_system_predicate/1 Abolish system definition
3340033426 reexport/2 Load predicates from a file and re-export it
3340133427 reload_foreign_libraries/0 Reload DLLs/shared objects
3340233428 reload_library_index/0 Force reloading the autoload index
33429
3340333430 rename_file/2 Change name of file
33404
3340533431 repeat/0 Succeed, leaving infinite backtrack points
3340633432 require/1 This file requires these predicates
3340733433 reset/3 Wrapper for delimited continuations
3340833434 reset_gensym/1 Reset a gensym key
3340933435 reset_gensym/0 Reset all gensym keys
3341033436 reset_profiler/0 Clear statistics obtained by the profiler
33437
3341133438 resource/3 Declare a program resource
33412
3341333439 retract/1 Remove clause from the database
3341433440 retractall/1 Remove unifying clauses from the database
3341533441 same_file/2 Succeeds if arguments refer to same file
3341733443 see/1 Change the current input stream
3341833444 seeing/1 Query the current input stream
3341933445 seek/4 Modify the current position in a stream
33446
3342033447 seen/0 Close the current input stream
33421
3342233448 select_dict/2 Select matching attributes from a dict
3342333449 select_dict/3 Select matching attributes from a dict
3342433450 set_end_of_stream/1 Set physical end of an open file
3342533451 set_flag/2 Set value of a flag
3342633452 set_input/1 Set current input stream from a stream
3342733453 set_locale/1 Set the default local
33454
3342833455 set_module/1 Set properties of a module
33429
3343033456 set_output/1 Set current output stream from a stream
3343133457 set_prolog_IO/3 Prepare streams for interactive session
3343233458 set_prolog_flag/2 Define a system feature
33459 set_prolog_gc_thread/1 Control the gc thread
3343333460 set_prolog_stack/2 Modify stack characteristics
3343433461 set_random/1 Control random number generation
3343533462 set_stream/2 Set stream attribute
33463
3343633464 set_stream_position/2 Seek stream to position
3343733465 setup_call_cleanup/3 Undo side-effects safely
33438
3343933466 setup_call_catcher_cleanup/4 Undo side-effects safely
3344033467 setarg/3 Destructive assignment on term
3344133468 setenv/2 Set shell environment variable
3344233469 setlocale/3 Set/query C-library regional information
3344333470 setof/3 Find all unique solutions to a goal
33471
3344433472 shell/1 Execute OS command
3344533473 shell/2 Execute OS command
33446
3344733474 shift/1 Shift control to the closest reset/3
3344833475 show_profile/1 Show results of the profiler
3344933476 size_file/2 Get size of a file in characters
3345033477 size_nb_set/2 Determine size of non-backtrackable set
3345133478 skip/1 Skip to character in current input
3345233479 skip/2 Skip to character on stream
33480
3345333481 sleep/1 Suspend execution for specified time
3345433482 sort/2 Sort elements in a list
33455
3345633483 sort/4 Sort elements in a list
3345733484 source_exports/2 Check whether source exports a predicate
3345833485 source_file/1 Examine currently loaded source files
3345933486 source_file/2 Obtain source file of predicate
3346033487 source_file_property/2 Information about loaded files
33488
3346133489 source_location/2 Location of last read term
3346233490 split_string/4 Break a string into substrings
33463
3346433491 spy/1 Force tracer on specified predicate
3346533492 stamp_date_time/3 Convert time-stamp to date structure
3346633493 statistics/0 Show execution statistics
3346733494 statistics/2 Obtain collected statistics
3346833495 stream_pair/3 Create/examine a bi-directional stream
3346933496 stream_position_data/3 Access fields from stream position
33497
3347033498 stream_property/2 Get stream properties
3347133499 string/1 Type check for string
33472
3347333500 string_concat/3 atom_concat/3 for strings
3347433501 string_length/2 Determine length of a string
3347533502 string_chars/2 Conversion between string and list of characters
3347633503 string_codes/2 Conversion between string and list of character codes
3347733504 string_code/3 Get or find a character code in a string
33505
3347833506 string_lower/2 Case conversion to lower case
3347933507 string_upper/2 Case conversion to upper case
33480
3348133508 string_predicate/1 (hook) Predicate contains strings
3348233509 strip_module/3 Extract context module and term
3348333510 style_check/1 Change level of warnings
3348433511 sub_atom/5 Take a substring from an atom
3348533512 sub_atom_icasechk/3 Case insensitive substring match
3348633513 sub_string/5 Take a substring from a string
33514
3348733515 subsumes_term/2 One-sided unification test
3348833516 succ/2 Logical integer successor relation
33489
3349033517 swritef/2 Formatted write on a string
3349133518 swritef/3 Formatted write on a string
3349233519 tab/1 Output number of spaces
3349333520 tab/2 Output number of spaces on a stream
3349433521 table/1 Declare predicate to be tabled
33522
3349533523 tdebug/0 Switch all threads into debug mode
3349633524 tdebug/1 Switch a thread into debug mode
33497
3349833525 tell/1 Change current output stream
3349933526 telling/1 Query current output stream
3350033527 term_expansion/2 (hook) Convert term before compilation
3350133528 term_expansion/4 (hook) Convert term before compilation
3350233529 term_singletons/2 Find singleton variables in a term
3350333530 term_string/2 Read/write a term from/to a string
33531
3350433532 term_string/3 Read/write a term from/to a string
3350533533 term_subsumer/3 Most specific generalization of two terms
33506
3350733534 term_to_atom/2 Convert between term and atom
3350833535 thread_at_exit/1 Register goal to be called at exit
3350933536 thread_create/2 Create a new Prolog task
3351033537 thread_create/3 Create a new Prolog task
3351133538 thread_detach/1 Make thread cleanup after completion
33539
3351233540 thread_exit/1 Terminate Prolog task with value
3351333541 thread_get_message/1 Wait for message
33514
3351533542 thread_get_message/2 Wait for message in a queue
3351633543 thread_get_message/3 Wait for message in a queue
3351733544 thread_initialization/1 Run action at start of thread
3351833545 thread_join/1 Wait for Prolog task-completion
3351933546 thread_join/2 Wait for Prolog task-completion
3352033547 thread_local/1 Declare thread-specific clauses for a predicate
33548
3352133549 thread_message_hook/3 Thread local message_hook/3
3352233550 thread_peek_message/1 Test for message
33523
3352433551 thread_peek_message/2 Test for message in a queue
3352533552 thread_property/2 Examine Prolog threads
3352633553 thread_self/1 Get identifier of current thread
3352733554 thread_send_message/2 Send message to another thread
3352833555 thread_send_message/3 Send message to another thread
33556
3352933557 thread_setconcurrency/2 Number of active threads
3353033558 thread_signal/2 Execute goal in another thread
33531
3353233559 thread_statistics/3 Get statistics of another thread
3353333560 threads/0 List running threads
3353433561 throw/1 Raise an exception (see catch/3)
3353533562 time/1 Determine time needed to execute goal
3353633563 time_file/2 Get last modification time of file
3353733564 tmp_file/2 Create a temporary filename
33565
3353833566 tmp_file_stream/3 Create a temporary file and open it
3353933567 tnodebug/0 Switch off debug mode in all threads
33540
3354133568 tnodebug/1 Switch off debug mode in a thread
3354233569 told/0 Close current output
3354333570 tprofile/1 Profile a thread for some period
3354433571 trace/0 Start the tracer
3354533572 trace/1 Set trace point on predicate
33573
3354633574 trace/2 Set/Clear trace point on ports
3354733575 tracing/0 Query status of the tracer
33548
3354933576 trie_delete/3 Remove term from trie
3355033577 trie_destroy/1 Destroy a trie
3355133578 trie_gen/3 Get all terms from a trie
3355233579 trie_insert/3 Insert term into a trie
3355333580 trie_insert/4 Insert term into a trie
3355433581 trie_lookup/3 Lookup a term in a trie
33582
3355533583 trie_new/1 Create a trie
3355633584 trie_property/2 Examine a trie's properties
33557
3355833585 trie_update/3 Update associated value in trie
3355933586 trie_term/2 Get term from a trie by handle
3356033587 trim_stacks/0 Release unused memory resources
3356133588 true/0 Succeed
3356233589 tspy/1 Set spy point and enable debugging in all threads
33590
3356333591 tspy/2 Set spy point and enable debugging in a thread
3356433592 tty_get_capability/3 Get terminal parameter
33565
3356633593 tty_goto/2 Goto position on screen
3356733594 tty_put/2 Write control string to terminal
3356833595 tty_size/2 Get row/column size of the terminal
3356933596 ttyflush/0 Flush output on terminal
3357033597 unify_with_occurs_check/2 Logically sound unification
3357133598 unifiable/3 Determining binding required for unification
33599
3357233600 unix/1 OS interaction
3357333601 unknown/2 Trap undefined predicates
33574
3357533602 unload_file/1 Unload a source file
3357633603 unload_foreign_library/1 shlib Detach shared library (.so file)
3357733604 unload_foreign_library/2 shlib Detach shared library (.so file)
3357833605 unsetenv/1 Delete shell environment variable
3357933606 upcase_atom/2 Convert atom to upper-case
33607
3358033608 use_foreign_library/1 Load DLL/shared object (directive)
3358133609 use_foreign_library/2 Load DLL/shared object (directive)
33582
3358333610 use_module/1 Import a module
3358433611 use_module/2 Import predicates from a module
3358533612 valid_string_goal/1 (hook) Goal handles strings
3358633613 var/1 Type check for unbound variable
3358733614 var_number/2 Check that var is numbered by numbervars
3358833615 var_property/2 Variable properties during macro expansion
33616
3358933617 variant_sha1/2 Term-hash for term-variants
3359033618 variant_hash/2 Term-hash for term-variants
33591
3359233619 version/0 Print system banner message
3359333620 version/1 Add messages to the system banner
3359433621 visible/1 Ports that are visible in the tracer
3359533622 volatile/1 Predicates that are not saved
3359633623 wait_for_input/3 Wait for input with optional timeout
33624
3359733625 when/2 Execute goal when condition becomes true
3359833626 wildcard_match/2 Csh(1) style wildcard match
33599
3360033627 win_add_dll_directory/1 Add directory to DLL search path
3360133628 win_add_dll_directory/2 Add directory to DLL search path
3360233629 win_remove_dll_directory/1 Remove directory from DLL search path
3360333630 win_exec/2 Win32: spawn Windows task
3360433631 win_has_menu/0 Win32: true if console menu is available
3360533632 win_folder/2 Win32: get special folder by CSIDL
33633
3360633634 win_insert_menu/2 swipl-win.exe: add menu
3360733635 win_insert_menu_item/4 swipl-win.exe: add item to menu
33608
3360933636 win_shell/2 Win32: open document through Shell
3361033637 win_shell/3 Win32: open document through Shell
3361133638 win_registry_get_value/3 Win32: get registry value
3361233639 win_window_pos/1 Win32: change size and position of window
3361333640 window_title/2 Win32: change title of window
33641
3361433642 with_mutex/2 Run goal while holding mutex
3361533643 with_output_to/2 Write to strings and more
33616
3361733644 with_quasi_quotation_input/3 Parse quasi quotation from stream
3361833645 working_directory/2 Query/change CWD
3361933646 write/1 Write term
3362033647 write/2 Write term to stream
3362133648 writeln/1 Write term, followed by a newline
3362233649 writeln/2 Write term, followed by a newline to a stream
33650
3362333651 write_canonical/1 Write a term with quotes, ignore operators
3362433652 write_canonical/2 Write a term with quotes, ignore operators on a stream
33625
3362633653 write_length/3 Dermine #characters to output a term
3362733654 write_term/2 Write term with options
3362833655 write_term/3 Write term with options to stream
3362933656 writef/1 Formatted write
3363033657 writef/2 Formatted write on stream
33658
3363133659 writeq/1 Write term, insert quotes
3363233660 writeq/2 Write term, insert quotes on stream
3363333661
3384733875 current_type/3 True when Type is a currently defined type and Var satisfies Type of the body term Body succeeds.
3384833876 domain_error/2 The argument is of the proper type, but has a value that is outside the supported values.
3384933877 existence_error/2 Term is of the correct type and correct domain, but there is no existing (external) resource that is represented by it.
33878 existence_error/3 Term is of the correct type and correct domain, but there is no existing (external) resource that is represented by it in the p@
3385033879 has_type/2 True if Term satisfies Type.
3385133880 instantiation_error/1 An argument is under-instantiated.
3385233881 is_of_type/2 True if Term satisfies Type.
3385333882 must_be/2 True if Term satisfies the type constraints for Type.
33883
3385433884 permission_error/3 It is not allowed to perform Action on the object Term that is of the given Type.
33855
3385633885 representation_error/1 A representation error indicates a limitation of the implementation.
3385733886 resource_error/1 A goal cannot be completed due to lack of resources.
3385833887 syntax_error/1 A text has invalid syntax.
3415034179
3415134180 1188..22..3344 lliibbrraarryy((ssoolluuttiioonn__sseeqquueenncceess))
3415234181
34153 call_nth/2 True when Goal succeeded for the Nth time.
3415434182 distinct/1 True if Goal is true and no previous solution of Goal bound Witness to the same value.
3415534183 distinct/2 True if Goal is true and no previous solution of Goal bound Witness to the same value.
3415634184 group_by/4 Group bindings of Template that have the same value for By.
3415834186 offset/2 Ignore the first Count solutions.
3415934187 order_by/2 Order solutions according to Spec.
3416034188 reduced/1 Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.
34161
3416234189 reduced/3 Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.
3416334190
3416434191
3444834475 _A_r_t _o_f _P_r_o_l_o_g. MIT Press, Cambridge,
3444934476 Massachusetts, 1986.
3445034477
34451 1967
34478 1969
0 :- encoding(utf8).
1
02 /* Part of SWI-Prolog
13
24 Author: Markus Triska
543545 ==
544546
545547 In this concrete case, the constraint solver is strong enough to find
546 the unique solution without any search.
548 the unique solution without any search. For the general case, see
549 [search](<#clpfd-search>).
547550
548551
549552 ## Residual goals {#clpfd-residual-goals}
603606 Using CLP(FD) constraints to solve combinatorial tasks typically
604607 consists of two phases:
605608
606 1. First, all relevant constraints are stated.
607 2. Second, if the domain of each involved variable is _finite_,
608 then _enumeration predicates_ can be used to search for
609 concrete solutions.
609 1. **Modeling**. In this phase, all relevant constraints are stated.
610 2. **Search**. In this phase, _enumeration predicates_ are used
611 to search for concrete solutions.
610612
611613 It is good practice to keep the modeling part, via a dedicated
612614 predicate called the *core relation*, separate from the actual
122122 % redirects debug information on this topic to the given output.
123123
124124 debug(Topic) :-
125 debug(Topic, true).
125 with_mutex(prolog_debug, debug(Topic, true)).
126126 nodebug(Topic) :-
127 debug(Topic, false).
127 with_mutex(prolog_debug, debug(Topic, false)).
128128
129129 debug(Spec, Val) :-
130130 debug_target(Spec, Topic, Out),
22 Author: Jan Wielemaker
33 E-mail: J.Wielemaker@vu.nl
44 WWW: http://www.swi-prolog.org
5 Copyright (c) 2006-2016, University of Amsterdam
5 Copyright (c) 2006-2017, University of Amsterdam
66 VU University Amsterdam
77 All rights reserved.
88
3636 [ type_error/2, % +Type, +Term
3737 domain_error/2, % +Domain, +Term
3838 existence_error/2, % +Type, +Term
39 existence_error/3, % +Type, +Term, +Set
3940 permission_error/3, % +Action, +Type, +Term
4041 instantiation_error/1, % +Term
4142 uninstantiation_error/1, % +Term
109110
110111 existence_error(Type, Term) :-
111112 throw(error(existence_error(Type, Term), _)).
113
114 %! existence_error(+Type, +Term, +Set).
115 %
116 % Term is of the correct type and correct domain, but there is no
117 % existing (external) resource that is represented by it in the
118 % provided set.
119 %
120 % @compat This error is not in ISO.
121
122 existence_error(Type, Term, Set) :-
123 throw(error(existence_error(Type, Term, Set), _)).
112124
113125 %! permission_error(+Action, +Type, +Term).
114126 %
1111 % Predicate predicate/5
1212
1313 predicate(~,0,'',41,48).
14 predicate(help,0,'Give help on help',893,895).
15 predicate(help,1,'Give help on predicates and show parts of manual',897,922).
16 predicate(apropos,1,'library(online_help) Search manual',924,933).
17 predicate(explain,1,'library(explain) Explain argument',935,941).
18 predicate(explain,2,'library(explain) 2nd argument is explanation of first',943,946).
19 predicate(current_prolog_flag,2,'Get system configuration parameters',1399,2277).
14 predicate(help,0,'Give help on help',892,894).
15 predicate(help,1,'Give help on predicates and show parts of manual',896,921).
16 predicate(apropos,1,'library(online_help) Search manual',923,932).
17 predicate(explain,1,'library(explain) Explain argument',934,940).
18 predicate(explain,2,'library(explain) 2nd argument is explanation of first',942,945).
19 predicate(current_prolog_flag,2,'Get system configuration parameters',1398,2277).
2020 predicate(set_prolog_flag,2,'Define a system feature',2279,2301).
2121 predicate(create_prolog_flag,3,'Create a new Prolog flag',2303,2322).
2222 predicate(autoload_path,1,'Add directories for autoloading',2451,2463).
7373 predicate(elif,1,'Part of conditional compilation (directive)',5232,5248).
7474 predicate(else,0,'Part of conditional compilation (directive)',5250,5252).
7575 predicate(endif,0,'End of conditional compilation (directive)',5254,5256).
76 predicate(garbage_collect_clauses,0,'Invoke clause garbage collector',5365,5390).
77 predicate(qcompile,1,'Compile source to Quick Load File',5467,5487).
78 predicate(qcompile,2,'Compile source to Quick Load File',5489,5492).
79 predicate(edit,1,'Edit a file, predicate, module (extensible)',5519,5526).
80 predicate(edit,0,'Edit current script- or associated file',5528,5532).
81 predicate(locate,3,'Locate targets for edit/1',5541,5554).
82 predicate(locate,2,'Locate targets for edit/1',5556,5559).
83 predicate(edit_source,1,'Call editor for edit/1',5561,5578).
84 predicate(edit_command,2,'Specify editor activation',5580,5606).
85 predicate(load,0,'Load edit/1 extensions',5608,5621).
86 predicate(listing,1,'List predicate',5626,5637).
87 predicate(listing,0,'List program in current module',5639,5643).
88 predicate(portray_clause,1,'Pretty print a clause',5645,5650).
89 predicate(portray_clause,2,'Pretty print a clause to a stream',5652,5654).
90 predicate(var,1,'Type check for unbound variable',5664,5666).
91 predicate(nonvar,1,'Type check for bound term',5668,5670).
92 predicate(integer,1,'Type check for integer',5672,5674).
93 predicate(float,1,'Type check for a floating point number',5676,5678).
94 predicate(rational,1,'Type check for a rational number',5680,5683).
95 predicate(rational,3,'Decompose a rational',5685,5690).
96 predicate(number,1,'Type check for integer or float',5692,5694).
97 predicate(atom,1,'Type check for an atom',5696,5698).
98 predicate(blob,2,'Type check for a blob',5700,5702).
99 predicate(string,1,'Type check for string',5704,5710).
100 predicate(atomic,1,'Type check for primitive',5712,5726).
101 predicate(compound,1,'Test for compound term',5728,5731).
102 predicate(callable,1,'Test for atom or compound term',5733,5752).
103 predicate(ground,1,'Verify term holds no unbound variables',5754,5757).
104 predicate(cyclic_term,1,'Test term for cycles',5759,5762).
105 predicate(acyclic_term,1,'Test term for cycles',5764,5767).
106 predicate(=,2,'True when arguments are unified',5775,5782).
107 predicate(\=,2,'True if arguments cannot be unified',5784,5794).
108 predicate(==,2,'Test for strict equality',5852,5855).
109 predicate(\==,2,'True if arguments are not strictly equal',5857,5859).
110 predicate(@<,2,'Standard order smaller',5861,5863).
111 predicate(@=<,2,'Standard order smaller or equal',5865,5868).
112 predicate(@>,2,'Standard order larger',5870,5872).
113 predicate(@>=,2,'Standard order larger or equal',5874,5877).
114 predicate(compare,3,'Compare, using a predicate to determine the order',5879,5882).
115 predicate(unify_with_occurs_check,2,'Logically sound unification',5895,5932).
116 predicate(=@=,2,'Test for structural equality (variant)',5934,5975).
117 predicate(\=@=,2,'Not structural identical',5977,5979).
118 predicate(subsumes_term,2,'One-sided unification test',5981,5987).
119 predicate(term_subsumer,3,'Most specific generalization of two terms',5989,5992).
120 predicate(unifiable,3,'Determining binding required for unification',5994,5999).
121 predicate(?=,2,'Test of terms can be compared now',6001,6006).
122 predicate(fail,0,'Always false',6024,6027).
123 predicate(false,0,'Always false',6029,6031).
124 predicate(true,0,'Succeed',6033,6036).
125 predicate(repeat,0,'Succeed, leaving infinite backtrack points',6038,6040).
126 predicate(!,0,'Cut (discard choicepoints)',6042,6061).
127 predicate(',',2,'Conjunction of goals',6063,6070).
128 predicate(;,2,'Disjunction of two goals',6072,6078).
129 predicate('|',2,'Disjunction in DCGs. Same as ;/2',6080,6083).
130 predicate(->,2,'If-then-else',6085,6108).
131 predicate(*->,2,'Soft-cut',6110,6139).
132 predicate(\+,1,'Negation by failure. Same as not/1',6141,6145).
133 predicate(call,1,'Call a goal',6157,6160).
134 predicate(call,_122,'Call with additional arguments',6162,6173).
135 predicate(apply,2,'Call goal with additional arguments',6175,6180).
136 predicate(not,1,'Negation by failure (argument not provable). Same as \\+/1',6182,6185).
137 predicate(once,1,'Call a goal deterministically',6187,6207).
138 predicate(ignore,1,'Call the argument, but always succeed',6209,6217).
139 predicate(call_with_depth_limit,3,'Prove goal with bounded depth',6219,6248).
140 predicate(call_with_inference_limit,3,'Prove goal in limited inferences',6250,6282).
141 predicate(setup_call_cleanup,3,'Undo side-effects safely',6284,6341).
142 predicate(setup_call_catcher_cleanup,4,'Undo side-effects safely',6343,6374).
143 predicate(call_cleanup,2,'Guard a goal with a cleaup-handler',6376,6383).
144 predicate(call_cleanup,3,'Guard a goal with a cleaup-handler',6385,6388).
145 predicate(reset,3,'Wrapper for delimited continuations',6403,6410).
146 predicate(shift,1,'Shift control to the closest reset/3',6412,6418).
147 predicate(catch,3,'Call goal, watching for exceptions',6426,6440).
148 predicate(throw,1,'Raise an exception (see catch/3)',6442,6474).
149 predicate(print_message,2,'Print message from (exception) term',6610,6675).
150 predicate(print_message_lines,3,'Print message to stream',6677,6718).
151 predicate(message_hook,3,'Intercept print_message/2',6720,6728).
152 predicate(thread_message_hook,3,'Thread local message_hook/3',6730,6736).
153 predicate(message_property,2,'Hook (user) Define display of a message',6738,6775).
154 predicate(message_line_element,2,'Hook (prolog) Intercept print_message_lines/3',6777,6781).
155 predicate(message_to_string,2,'Translate message-term to string',6783,6785).
156 predicate(version,0,'Print system banner message',6787,6791).
157 predicate(version,1,'Add messages to the system banner',6793,6798).
158 predicate(on_signal,3,'Handle a software signal',6884,6918).
159 predicate(current_signal,3,'Current software signal mapping',6920,6924).
160 predicate(phrase,2,'Activate grammar-rule set',7007,7009).
161 predicate(phrase,3,'Activate grammar-rule set (returning rest)',7011,7067).
162 predicate(call_dcg,3,'As phrase/3 without type checking',7069,7095).
163 predicate(abolish,1,'Remove predicate definition from the database',7165,7181).
164 predicate(abolish,2,'Remove predicate definition from the database',7183,7186).
165 predicate(copy_predicate_clauses,2,'Copy clauses between predicates',7188,7211).
166 predicate(redefine_system_predicate,1,'Abolish system definition',7213,7223).
167 predicate(retract,1,'Remove clause from the database',7225,7257).
168 predicate(retractall,1,'Remove unifying clauses from the database',7259,7264).
169 predicate(asserta,1,'Add a clause to the database (first)',7266,7267).
170 predicate(assertz,1,'Add a clause to the database (last)',7269,7270).
171 predicate(assert,1,'Add a clause to the database',7272,7288).
172 predicate(asserta,2,'Add a clause to the database (first)',7290,7291).
173 predicate(assertz,2,'Add a clause to the database (last)',7293,7294).
174 predicate(assert,2,'Add a clause to the database, give reference',7296,7300).
175 predicate(recorda,3,'Record term in the database (first)',7305,7311).
176 predicate(recorda,2,'Record term in the database (first)',7313,7315).
177 predicate(recordz,3,'Record term in the database (last)',7317,7320).
178 predicate(recordz,2,'Record term in the database (last)',7322,7324).
179 predicate(recorded,3,'Obtain term from the database',7326,7337).
180 predicate(recorded,2,'Obtain term from the database',7339,7341).
181 predicate(erase,1,'Erase a database record or clause',7343,7350).
182 predicate(instance,2,'Fetch clause or record from reference',7352,7355).
183 predicate(get_flag,2,'Get value of a flag',7367,7370).
184 predicate(flag,3,'Simple global variable system',7377,7387).
185 predicate(trie_new,1,'Create a trie',7414,7418).
186 predicate(trie_destroy,1,'Destroy a trie',7420,7424).
187 predicate(is_trie,1,'Type check for a trie handle',7426,7428).
188 predicate(current_trie,1,'Enumerate known tries',7430,7434).
189 predicate(trie_insert,3,'Insert term into a trie',7436,7441).
190 predicate(trie_update,3,'Update associated value in trie',7443,7446).
191 predicate(trie_insert,4,'Insert term into a trie',7448,7453).
192 predicate(trie_delete,3,'Remove term from trie',7455,7458).
193 predicate(trie_lookup,3,'Lookup a term in a trie',7460,7462).
194 predicate(trie_term,2,'Get term from a trie by handle',7464,7469).
195 predicate(trie_gen,3,'Get all terms from a trie',7471,7476).
196 predicate(trie_property,2,'Examine a trie\'s properties',7478,7494).
197 predicate(term_hash,2,'Hash-value of ground term',7530,7545).
198 predicate(term_hash,4,'Hash-value of term with depth limit',7547,7556).
199 predicate(variant_sha1,2,'Term-hash for term-variants',7558,7577).
200 predicate(variant_hash,2,'Term-hash for term-variants',7579,7585).
201 predicate(dynamic,1,'Indicate predicate definition may change',7606,7614).
202 predicate(compile_predicates,1,'Compile dynamic code to static',7616,7624).
203 predicate(multifile,1,'Indicate distributed definition of predicate',7626,7630).
204 predicate(discontiguous,1,'Indicate distributed definition of a predicate',7632,7635).
205 predicate(public,1,'Declaration that a predicate may be called',7637,7646).
206 predicate(current_atom,1,'Examine existing atoms',7651,7655).
207 predicate(current_blob,2,'Examine typed blobs',7657,7662).
208 predicate(current_functor,2,'Examine existing name/arity pairs',7664,7682).
209 predicate(current_flag,1,'Examine existing flags',7684,7687).
210 predicate(current_key,1,'Examine existing database keys',7689,7692).
211 predicate(current_predicate,1,'Examine existing predicates (ISO)',7694,7710).
212 predicate(current_predicate,2,'Examine existing predicates',7712,7729).
213 predicate(predicate_property,2,'Query predicate attributes',7731,7908).
214 predicate(dwim_predicate,2,'Find predicate in ``Do What I Mean\'\' sense',7910,7919).
215 predicate(clause,2,'Get clauses of a predicate',7921,7925).
216 predicate(clause,3,'Get clauses of a predicate',7927,7932).
217 predicate(nth_clause,3,'N-th clause of a predicate',7934,7953).
218 predicate(clause_property,2,'Get properties of a clause',7955,8008).
219 predicate(open,4,'Open a file (creating a stream)',8086,8223).
220 predicate(open,3,'Open a file (creating a stream)',8225,8227).
221 predicate(open_null_stream,1,'Open a stream to discard output',8229,8247).
222 predicate(close,1,'Close stream',8249,8259).
223 predicate(close,2,'Close stream (forced)',8261,8265).
224 predicate(stream_property,2,'Get stream properties',8267,8391).
225 predicate(current_stream,3,'Examine open streams',8393,8400).
226 predicate(is_stream,1,'Type check for a stream handle',8402,8406).
227 predicate(stream_pair,3,'Create/examine a bi-directional stream',8408,8425).
228 predicate(set_stream_position,2,'Seek stream to position',8427,8431).
229 predicate(stream_position_data,3,'Access fields from stream position',8433,8439).
230 predicate(seek,4,'Modify the current position in a stream',8441,8469).
231 predicate(set_stream,2,'Set stream attribute',8471,8572).
232 predicate(set_prolog_IO,3,'Prepare streams for interactive session',8574,8585).
233 predicate(see,1,'Change the current input stream',8664,8668).
234 predicate(tell,1,'Change current output stream',8670,8675).
235 predicate(append,1,'Append to a file',8677,8681).
236 predicate(seeing,1,'Query the current input stream',8683,8688).
237 predicate(telling,1,'Query current output stream',8690,8695).
238 predicate(seen,0,'Close the current input stream',8697,8700).
239 predicate(told,0,'Close current output',8702,8705).
240 predicate(set_input,1,'Set current input stream from a stream',8713,8717).
241 predicate(set_output,1,'Set current output stream from a stream',8719,8722).
242 predicate(current_input,1,'Get current input stream',8724,8727).
243 predicate(current_output,1,'Get the current output stream',8729,8731).
244 predicate(with_output_to,2,'Write to strings and more',8736,8786).
245 predicate(fast_term_serialized,2,'Fast term (de-)serialization',8817,8819).
246 predicate(fast_write,2,'Write binary term serialization',8821,8824).
247 predicate(fast_read,2,'Read binary term serialization',8826,8829).
248 predicate(wait_for_input,3,'Wait for input with optional timeout',8834,8887).
249 predicate(byte_count,2,'Byte-position in a stream',8889,8894).
250 predicate(character_count,2,'Get character index on a stream',8896,8901).
251 predicate(line_count,2,'Line number on stream',8903,8906).
252 predicate(line_position,2,'Character position in line on stream',8908,8913).
253 predicate(nl,0,'Generate a newline',8920,8923).
254 predicate(nl,1,'Generate a newline on a stream',8925,8927).
255 predicate(put,1,'Write a character',8929,8934).
256 predicate(put,2,'Write a character on a stream',8936,8938).
257 predicate(put_byte,1,'Write a byte',8940,8943).
258 predicate(put_byte,2,'Write a byte on a stream',8945,8948).
259 predicate(put_char,1,'Write a character',8950,8955).
260 predicate(put_char,2,'Write a character on a stream',8957,8961).
261 predicate(put_code,1,'Write a character-code',8963,8967).
262 predicate(put_code,2,'Write a character-code on a stream',8969,8971).
263 predicate(tab,1,'Output number of spaces',8973,8977).
264 predicate(tab,2,'Output number of spaces on a stream',8979,8981).
265 predicate(flush_output,0,'Output pending characters on current stream',8983,8987).
266 predicate(flush_output,1,'Output pending characters on specified stream',8989,8992).
267 predicate(ttyflush,0,'Flush output on terminal',8994,8996).
268 predicate(get_byte,1,'Read next byte (ISO)',8998,9002).
269 predicate(get_byte,2,'Read next byte from a stream (ISO)',9004,9007).
270 predicate(get_code,1,'Read next character (ISO)',9009,9013).
271 predicate(get_code,2,'Read next character from a stream (ISO)',9015,9017).
272 predicate(get_char,1,'Read next character as an atom (ISO)',9019,9023).
273 predicate(get_char,2,'Read next character from a stream (ISO)',9025,9028).
274 predicate(get0,1,'Read next character',9030,9035).
275 predicate(get0,2,'Read next character from a stream',9037,9040).
276 predicate(get,1,'Read first non-blank character',9042,9046).
277 predicate(get,2,'Read first non-blank character from a stream',9048,9051).
278 predicate(peek_byte,1,'Read byte without removing',9053,9054).
279 predicate(peek_byte,2,'Read byte without removing',9056,9057).
280 predicate(peek_code,1,'Read character-code without removing',9059,9060).
281 predicate(peek_code,2,'Read character-code without removing',9062,9063).
282 predicate(peek_char,1,'Read character without removing',9065,9066).
283 predicate(peek_char,2,'Read character without removing',9068,9075).
284 predicate(peek_string,3,'Read a string without removing',9077,9084).
285 predicate(skip,1,'Skip to character in current input',9086,9090).
286 predicate(skip,2,'Skip to character on stream',9092,9094).
287 predicate(get_single_char,1,'Read next character from the terminal',9096,9105).
288 predicate(at_end_of_stream,0,'Test for end of file on input',9107,9111).
289 predicate(at_end_of_stream,1,'Test for end of file on stream',9113,9118).
290 predicate(set_end_of_stream,1,'Set physical end of an open file',9120,9124).
291 predicate(copy_stream_data,3,'Copy n bytes from stream to stream',9126,9131).
292 predicate(copy_stream_data,2,'Copy all data from stream to stream',9133,9135).
293 predicate(fill_buffer,1,'Fill the input buffer of a stream',9137,9142).
294 predicate(read_pending_codes,3,'Fetch buffered input from a stream',9144,9179).
295 predicate(read_pending_chars,3,'Fetch buffered input from a stream',9181,9184).
296 predicate(write_term,2,'Write term with options',9198,9365).
297 predicate(write_term,3,'Write term with options to stream',9367,9370).
298 predicate(write_length,3,'Dermine #characters to output a term',9372,9381).
299 predicate(write_canonical,1,'Write a term with quotes, ignore operators',9383,9397).
300 predicate(write_canonical,2,'Write a term with quotes, ignore operators on a stream',9399,9401).
301 predicate(write,1,'Write term',9403,9406).
302 predicate(write,2,'Write term to stream',9408,9410).
303 predicate(writeq,1,'Write term, insert quotes',9412,9417).
304 predicate(writeq,2,'Write term, insert quotes on stream',9419,9421).
305 predicate(writeln,1,'Write term, followed by a newline',9423,9427).
306 predicate(writeln,2,'Write term, followed by a newline to a stream',9429,9433).
307 predicate(print,1,'Print a term',9435,9463).
308 predicate(print,2,'Print a term on a stream',9465,9467).
309 predicate(portray,1,'Hook (user) Modify behaviour of print/1',9469,9476).
310 predicate(read,1,'Read Prolog term',9478,9483).
311 predicate(read,2,'Read Prolog term from stream',9485,9487).
312 predicate(read_clause,3,'Read clause from stream',9489,9519).
313 predicate(read_term,2,'Read term with options',9521,9674).
314 predicate(read_term,3,'Read term with options from stream',9676,9678).
315 predicate(read_term_from_atom,3,'Read term with options from atom',9680,9685).
316 predicate(read_history,6,'Read using history substitution',9687,9702).
317 predicate(prompt,2,'Change the prompt used by read/1',9704,9712).
318 predicate(prompt1,1,'Change prompt for 1 line',9714,9717).
319 predicate(functor,3,'Get name and arity of a term or construct a term ',9722,9742).
320 predicate(arg,3,'Access argument of a term',9744,9753).
321 predicate(=..,2,'``Univ.\'\' Term to list conversion',9755,9777).
322 predicate(compound_name_arity,3,'Name and arity of a compound term',9779,9783).
323 predicate(compound_name_arguments,3,'Name and arguments of a compound term',9785,9788).
324 predicate(numbervars,3,'Number unbound variables of a term',9790,9810).
325 predicate(numbervars,4,'Number unbound variables of a term',9812,9831).
326 predicate(var_number,2,'Check that var is numbered by numbervars',9833,9839).
327 predicate(term_variables,2,'Find unbound variables in a term',9841,9851).
328 predicate(nonground,2,'Term is not ground due to witness',9853,9862).
329 predicate(term_variables,3,'Find unbound variables in a term',9864,9867).
330 predicate(term_singletons,2,'Find singleton variables in a term',9869,9881).
331 predicate(copy_term,2,'Make a copy of a term',9883,9892).
332 predicate(setarg,3,'Destructive assignment on term',9904,9921).
333 predicate(nb_setarg,3,'Non-backtrackable assignment to term',9923,9953).
334 predicate(nb_linkarg,3,'Non-backtrackable assignment to term',9955,9959).
335 predicate(duplicate_term,2,'Create a copy of a term',9961,9966).
336 predicate(same_term,2,'Test terms to be at the same address',9968,9973).
337 predicate(atom_codes,2,'Convert between atom and list of characters codes',9996,10002).
338 predicate(atom_chars,2,'Convert between atom and list of characters',10004,10012).
339 predicate(char_code,2,'Convert between character and character code',10014,10017).
340 predicate(number_chars,2,'Convert between number and one-char atoms',10019,10032).
341 predicate(number_codes,2,'Convert between number and character codes',10034,10038).
342 predicate(atom_number,2,'Convert between atom and number',10040,10047).
343 predicate(name,2,'Convert between atom and list of character codes',10049,10067).
344 predicate(term_to_atom,2,'Convert between term and atom',10069,10076).
345 predicate(atom_to_term,3,'Convert between atom and term',10078,10085).
346 predicate(atom_concat,3,'Contatenate two atoms',10087,10094).
347 predicate(atomic_concat,3,'Concatenate two atomic values to an atom',10096,10104).
348 predicate(atomic_list_concat,2,'Append a list of atomics',10106,10111).
349 predicate(atomic_list_concat,3,'Append a list of atomics with separator',10113,10134).
350 predicate(atom_length,2,'Determine length of an atom',10136,10142).
351 predicate(atom_prefix,2,'Test for start of atom',10144,10147).
352 predicate(sub_atom,5,'Take a substring from an atom',10149,10163).
353 predicate(sub_atom_icasechk,3,'Case insensitive substring match',10165,10171).
354 predicate(locale_create,3,'Create a new locale object',10201,10235).
355 predicate(locale_destroy,1,'Destroy a locale object',10237,10241).
356 predicate(locale_property,2,'Query properties of locale objects',10243,10246).
357 predicate(set_locale,1,'Set the default local',10248,10254).
358 predicate(current_locale,1,'Get the current locale',10256,10258).
359 predicate(char_type,2,'Classify characters',10273,10387).
360 predicate(code_type,2,'Classify a character-code',10389,10396).
361 predicate(downcase_atom,2,'Convert atom to lower-case',10406,10411).
362 predicate(upcase_atom,2,'Convert atom to upper-case',10413,10415).
363 predicate(normalize_space,2,'Normalize white space',10420,10425).
364 predicate(collation_key,2,'Sort key for locale dependent ordering',10433,10446).
365 predicate(locale_sort,2,'Language dependent sort of atoms',10448,10453).
366 predicate(op,3,'Declare an operator',10492,10560).
367 predicate(current_op,3,'Examine current operator declarations',10562,10565).
368 predicate(char_conversion,2,'Provide mapping of input characters',10573,10579).
369 predicate(current_char_conversion,2,'Query input character mapping',10581,10584).
370 predicate(between,3,'Integer range checking/generating',10604,10611).
371 predicate(succ,2,'Logical integer successor relation',10613,10619).
372 predicate(plus,3,'Logical integer addition',10621,10624).
373 predicate(divmod,4,'Compute quotient and remainder of two integers',10626,10643).
374 predicate(nth_integer_root_and_remainder,4,'Integer root and remainder',10645,10662).
375 predicate(>,2,'Arithmetic larger',10673,10675).
376 predicate(<,2,'Arithmetic smaller',10677,10679).
377 predicate(=<,2,'Arithmetic smaller or equal',10681,10684).
378 predicate(>=,2,'Arithmetic larger or equal',10686,10689).
379 predicate(=\=,2,'Arithmetic not equal',10691,10693).
380 predicate(=:=,2,'Arithmetic equality',10695,10697).
381 predicate(is,2,'Evaluate arithmetic expression',10699,10708).
382 predicate(-,1,'Unary minus',10826,10828).
383 predicate(+,1,'Unary plus (No-op)',10830,10833).
384 predicate(+,2,'Addition',10835,10837).
385 predicate(-,2,'Subtraction',10839,10841).
386 predicate(*,2,'Multiplication',10843,10845).
387 predicate(/,2,'Shorthand for `Free/[]Srshift{}Lambda`.',10847,10855).
388 predicate(mod,2,'Remainder of division',10857,10860).
389 predicate(rem,2,'Remainder of division',10862,10865).
390 predicate(//,2,'Integer division',10867,10872).
391 predicate(div,2,'Integer division',10874,10887).
392 predicate(rdiv,2,'Ration number division',10889,10893).
393 predicate(gcd,2,'Greatest common divisor',10895,10897).
394 predicate(abs,1,'Absolute value',10899,10901).
395 predicate(sign,1,'Extract sign of value',10903,10908).
396 predicate(copysign,2,'Apply sign of N2 to N1',10910,10921).
397 predicate(max,2,'Maximum of two numbers',10923,10928).
398 predicate(min,2,'Minimum of two numbers',10930,10933).
399 predicate('.',2,'Consult. Also functional notation',10935,10944).
400 predicate(random,1,'Binds R to a new random float in the _open_ interval (0.0,1.0).',10946,10964).
401 predicate(random_float,0,'Generate random number',10966,10972).
402 predicate(round,1,'Round to nearest integer',10974,10981).
403 predicate(integer,1,'Type check for integer',10983,10985).
404 predicate(float,1,'Type check for a floating point number',10987,10992).
405 predicate(rational,1,'Type check for a rational number',10994,11011).
406 predicate(rationalize,1,'Convert to rational number',11013,11027).
407 predicate(float_fractional_part,1,'Fractional part of a float',11029,11034).
408 predicate(float_integer_part,1,'Integer part of a float',11036,11039).
409 predicate(truncate,1,'Truncate float to integer',11041,11045).
410 predicate(floor,1,'Largest integer below argument',11047,11050).
411 predicate(ceiling,1,'Smallest integer larger than arg',11052,11055).
412 predicate(ceil,1,'Smallest integer larger than arg',11057,11059).
413 predicate(>>,2,'Calls a copy of Lambda.',11061,11066).
414 predicate(<<,2,'Bitwise left shift',11068,11070).
415 predicate(\/,2,'Bitwise or',11072,11074).
416 predicate(/\,2,'Bitwise and',11076,11078).
417 predicate(xor,2,'Bitwise exclusive or',11080,11082).
418 predicate(\,1,'Bitwise negation',11084,11087).
419 predicate(sqrt,1,'Square root',11089,11091).
420 predicate(sin,1,'Sine',11093,11095).
421 predicate(cos,1,'Cosine',11097,11099).
422 predicate(tan,1,'Tangent',11101,11103).
423 predicate(asin,1,'Inverse (arc) sine',11105,11107).
424 predicate(acos,1,'Inverse (arc) cosine',11109,11111).
425 predicate(atan,1,'Inverse hyperbolic sine',11113,11115).
426 predicate(atan2,2,'Rectangular to polar conversion',11117,11125).
427 predicate(atan,2,'Rectangular to polar conversion',11127,11129).
428 predicate(sinh,1,'Hyperbolic sine',11131,11134).
429 predicate(cosh,1,'Hyperbolic cosine',11136,11139).
430 predicate(tanh,1,'Hyperbolic tangent',11141,11144).
431 predicate(asinh,1,'Inverse (arc) sine',11146,11148).
432 predicate(acosh,1,'Inverse hyperbolic cosine',11150,11152).
433 predicate(atanh,1,'Inverse hyperbolic tangent',11154,11156).
434 predicate(log,1,'Natural logarithm',11158,11160).
435 predicate(log10,1,'10 base logarithm',11162,11164).
436 predicate(exp,1,'Exponent (base $e$)',11166,11168).
437 predicate(**,2,'Power function',11170,11185).
438 predicate(^,2,'Existential quantification (bagof/3, setof/3)',11187,11207).
439 predicate(powm,3,'Integer exponent and modulo',11209,11216).
440 predicate(lgamma,1,'Log of gamma function',11218,11221).
441 predicate(erf,1,'Gauss error function',11223,11229).
442 predicate(erfc,1,'Complementary error function',11231,11234).
443 predicate(pi,0,'Mathematical constant',11236,11238).
444 predicate(e,0,'Mathematical constant',11240,11242).
445 predicate(epsilon,0,'Floating point precision',11244,11247).
446 predicate(inf,0,'Positive infinity',11249,11252).
447 predicate(nan,0,'Not a Number (NaN)',11254,11256).
448 predicate(cputime,0,'Get CPU time',11258,11262).
449 predicate(eval,1,'Evaluate term as expression',11264,11279).
450 predicate(msb,1,'Most significant bit',11281,11286).
451 predicate(lsb,1,'Least significant bit',11288,11293).
452 predicate(popcount,1,'Count 1s in a bitvector',11295,11298).
453 predicate(getbit,2,'Get bit at index from large integer',11300,11307).
454 predicate(set_random,1,'Control random number generation',11312,11334).
455 predicate(random_property,1,'Query properties of random generation',11336,11348).
456 predicate(current_arithmetic_function,1,'Examine evaluable functions',11350,11357).
457 predicate(is_list,1,'Type check for a list',11366,11381).
458 predicate(memberchk,2,'Deterministic member/2',11383,11391).
459 predicate(length,2,'Length of a list',11393,11410).
460 predicate(sort,2,'Sort elements in a list',11412,11425).
461 predicate(sort,4,'Sort elements in a list',11427,11478).
462 predicate(msort,2,'Sort, do not remove duplicates',11480,11483).
463 predicate(keysort,2,'Sort, using a key',11485,11507).
464 predicate(predsort,3,'Sort, using a predicate to determine the order',11509,11514).
465 predicate(findall,3,'Find all solutions to a goal',11519,11526).
466 predicate(findall,4,'Difference list version of findall/3',11528,11536).
467 predicate(findnsols,4,'Find first solutions',11538,11539).
468 predicate(findnsols,5,'Difference list version of findnsols/4',11541,11574).
469 predicate(bagof,3,'Find all solutions to a goal',11576,11608).
470 predicate(setof,3,'Find all unique solutions to a goal',11610,11613).
471 predicate(forall,2,'Prove goal for all solutions of another goal',11618,11659).
472 predicate(writef,1,'Formatted write',11674,11676).
473 predicate(writef,2,'Formatted write on stream',11678,11737).
474 predicate(swritef,3,'Formatted write on a string',11739,11747).
475 predicate(swritef,2,'Formatted write on a string',11749,11751).
476 predicate(format,1,'Formatted output',11759,11762).
477 predicate(format,2,'Formatted output with arguments',11764,11932).
478 predicate(format,3,'Formatted output on a stream',11934,11944).
479 predicate(format_predicate,2,'Program format/[1,2]',11949,11978).
480 predicate(current_format_predicate,2,'Enumerate user-defined format codes',11980,11983).
481 predicate(b_setval,2,'Assign backtrackable global variable',12024,12030).
482 predicate(b_getval,2,'Fetch backtrackable global variable',12032,12039).
483 predicate(nb_setval,2,'Assign non-backtrackable global variable',12041,12045).
484 predicate(nb_getval,2,'Fetch non-backtrackable global variable',12047,12057).
485 predicate(nb_linkval,2,'Assign non-backtrackable global variable',12059,12080).
486 predicate(nb_current,2,'Enumerate non-backtrackable global variables',12082,12087).
487 predicate(nb_delete,1,'Delete a non-backtrackable global variable',12089,12092).
488 predicate(tty_get_capability,3,'Get terminal parameter',12117,12125).
489 predicate(tty_goto,2,'Goto position on screen',12127,12131).
490 predicate(tty_put,2,'Write control string to terminal',12133,12139).
491 predicate(tty_size,2,'Get row/column size of the terminal',12141,12157).
492 predicate(shell,1,'Execute OS command',12168,12170).
493 predicate(shell,2,'Execute OS command',12172,12201).
494 predicate(getenv,2,'Get shell environment variable',12203,12207).
495 predicate(setenv,2,'Set shell environment variable',12209,12218).
496 predicate(unsetenv,1,'Delete shell environment variable',12220,12224).
497 predicate(setlocale,3,'Set/query C-library regional information',12226,12238).
498 predicate(unix,1,'OS interaction',12240,12271).
499 predicate(win_exec,2,'Win32: spawn Windows task',12282,12289).
500 predicate(win_shell,3,'Win32: open document through Shell',12291,12300).
501 predicate(win_shell,2,'Win32: open document through Shell',12302,12304).
502 predicate(win_registry_get_value,3,'Win32: get registry value',12306,12327).
503 predicate(win_folder,2,'Win32: get special folder by CSIDL',12329,12342).
504 predicate(win_add_dll_directory,1,'Add directory to DLL search path',12344,12353).
505 predicate(win_add_dll_directory,2,'Add directory to DLL search path',12355,12378).
506 predicate(win_remove_dll_directory,1,'Remove directory from DLL search path',12380,12383).
507 predicate(get_time,1,'Get current time',12457,12460).
508 predicate(stamp_date_time,3,'Convert time-stamp to date structure',12462,12468).
509 predicate(date_time_stamp,2,'Convert date structure to time-stamp',12470,12521).
510 predicate(date_time_value,3,'Extract info from a date structure',12523,12540).
511 predicate(format_time,3,'C strftime() like date/time formatter',12542,12704).
512 predicate(format_time,4,'date/time formatter with explicit locale',12706,12715).
513 predicate(parse_time,2,'Parse text to a time-stamp',12717,12719).
514 predicate(parse_time,3,'Parse text to a time-stamp',12721,12741).
515 predicate(day_of_the_week,2,'Determine ordinal-day from date',12743,12748).
516 predicate(window_title,2,'Win32: change title of window',12759,12762).
517 predicate(win_window_pos,1,'Win32: change size and position of window',12764,12787).
518 predicate(win_has_menu,0,'Win32: true if console menu is available',12789,12791).
519 predicate(win_insert_menu,2,'swipl-win.exe: add menu',12793,12804).
520 predicate(win_insert_menu_item,4,'swipl-win.exe: add item to menu',12806,12810).
521 predicate(access_file,2,'Check access permissions of a file',12815,12835).
522 predicate(exists_file,1,'Check existence of file',12837,12841).
523 predicate(file_directory_name,2,'Get directory part of path',12843,12863).
524 predicate(file_base_name,2,'Get file part of path',12865,12870).
525 predicate(same_file,2,'Succeeds if arguments refer to same file',12872,12881).
526 predicate(exists_directory,1,'Check existence of directory',12883,12886).
527 predicate(delete_file,1,'Remove a file from the file system',12888,12890).
528 predicate(rename_file,2,'Change name of file',12892,12898).
529 predicate(size_file,2,'Get size of a file in characters',12900,12902).
530 predicate(time_file,2,'Get last modification time of file',12904,12908).
531 predicate(absolute_file_name,2,'Get absolute path name',12910,12918).
532 predicate(absolute_file_name,3,'Get absolute path name with options',12920,12981).
533 predicate(is_absolute_file_name,1,'True if arg defines an absolute path',12983,12989).
534 predicate(file_name_extension,3,'Add, remove or test file extensions',12991,12999).
535 predicate(directory_files,2,'Get entries of a directory/folder',13001,13007).
536 predicate(expand_file_name,2,'Wildcard expansion of file names',13009,13026).
537 predicate(prolog_to_os_filename,2,'Convert between Prolog and OS filenames',13028,13034).
538 predicate(read_link,3,'Read a symbolic link',13036,13042).
539 predicate(tmp_file,2,'Create a temporary filename',13044,13054).
540 predicate(tmp_file_stream,3,'Create a temporary file and open it',13056,13083).
541 predicate(make_directory,1,'Create a folder on the file system',13085,13089).
542 predicate(delete_directory,1,'Remove a folder from the file system',13091,13095).
543 predicate(working_directory,2,'Query/change CWD',13097,13103).
544 predicate(chdir,1,'Compatibility: change working directory',13105,13107).
545 predicate(break,0,'Start interactive top level',13112,13129).
546 predicate(abort,0,'Abort execution, return to top level',13131,13148).
547 predicate(halt,0,'Exit from Prolog',13150,13153).
548 predicate(halt,1,'Exit from Prolog with status',13155,13184).
549 predicate(prolog,0,'Run interactive top level',13186,13195).
550 predicate(expand_query,4,'Expanded entered query',13197,13205).
551 predicate(expand_answer,2,'Expand answer of query',13207,13212).
552 predicate(protocol,1,'Make a log of the user interaction',13221,13224).
553 predicate(protocola,1,'Append log of the user interaction to file',13226,13229).
554 predicate(noprotocol,0,'Disable logging of user interaction',13231,13234).
555 predicate(protocolling,1,'On what file is user interaction logged',13236,13239).
556 predicate(trace,0,'Start the tracer',13250,13254).
557 predicate(tracing,0,'Query status of the tracer',13256,13259).
558 predicate(notrace,0,'Stop tracing',13261,13263).
559 predicate(guitracer,0,'Install hooks for the graphical debugger',13265,13270).
560 predicate(noguitracer,0,'Disable the graphical debugger',13272,13274).
561 predicate(trace,1,'Set trace point on predicate',13276,13278).
562 predicate(trace,2,'Set/Clear trace point on ports',13280,13300).
563 predicate(notrace,1,'Do not debug argument goal',13302,13307).
564 predicate(debug,0,'Test for debugging mode',13309,13322).
565 predicate(nodebug,0,'Disable debugging',13324,13327).
566 predicate(debugging,0,'Show debugger status',13329,13332).
567 predicate(spy,1,'Force tracer on specified predicate',13334,13337).
568 predicate(nospy,1,'Remove spy point',13339,13342).
569 predicate(nospyall,0,'Remove all spy points',13344,13346).
570 predicate(leash,1,'Change ports visited by the tracer',13348,13356).
571 predicate(visible,1,'Ports that are visible in the tracer',13358,13361).
572 predicate(unknown,2,'Trap undefined predicates',13363,13368).
573 predicate(style_check,1,'Change level of warnings',13370,13444).
574 predicate(statistics,2,'Obtain collected statistics',13449,13545).
575 predicate(statistics,0,'Show execution statistics',13547,13549).
576 predicate(time,1,'Determine time needed to execute goal',13551,13559).
577 predicate(profile,1,'Obtain execution statistics',13577,13581).
578 predicate(profile,2,'Obtain execution statistics',13583,13596).
579 predicate(show_profile,1,'Show results of the profiler',13598,13610).
580 predicate(profiler,2,'Obtain/change status of the profiler',13612,13626).
581 predicate(reset_profiler,0,'Clear statistics obtained by the profiler',13628,13630).
582 predicate(noprofile,1,'Hide (meta-) predicate for the profiler',13632,13638).
583 predicate(garbage_collect,0,'Invoke the garbage collector',13741,13748).
584 predicate(garbage_collect_atoms,0,'Invoke the atom garbage collector',13750,13758).
585 predicate(trim_stacks,0,'Release unused memory resources',13760,13778).
586 predicate(set_prolog_stack,2,'Modify stack characteristics',13780,13819).
587 predicate(prolog_stack_property,2,'Query properties of the stacks',13821,13824).
588 predicate(open_dde_conversation,3,'Win32: Open DDE channel',13870,13875).
589 predicate(close_dde_conversation,1,'Win32: Close DDE channel',13877,13882).
590 predicate(dde_request,3,'Win32: Make a DDE request',13884,13888).
591 predicate(dde_execute,2,'Win32: Execute command on DDE server',13890,13894).
592 predicate(dde_poke,3,'Win32: POKE operation on DDE server',13896,13899).
593 predicate(dde_register_service,2,'Win32: Become a DDE server',13910,13947).
594 predicate(dde_unregister_service,1,'Win32: Terminate a DDE service',13949,13952).
595 predicate(dde_current_service,2,'Win32: Examine DDE services provided',13954,13956).
596 predicate(dde_current_connection,2,'Win32: Examine open DDE connections',13958,13960).
597 predicate(dwim_match,2,'Atoms match in ``Do What I Mean\'\' sense',13965,13983).
598 predicate(dwim_match,3,'Atoms match in ``Do What I Mean\'\' sense',13985,13990).
599 predicate(wildcard_match,2,'Csh(1) style wildcard match',13992,14008).
600 predicate(sleep,1,'Suspend execution for specified time',14010,14020).
601 predicate(atom_string,2,'Conversion between atom and string',14165,14169).
602 predicate(number_string,2,'Convert between number and string',14171,14189).
603 predicate(term_string,2,'Read/write a term from/to a string',14191,14196).
604 predicate(term_string,3,'Read/write a term from/to a string',14198,14207).
605 predicate(string_chars,2,'Conversion between string and list of characters',14209,14213).
606 predicate(string_codes,2,'Conversion between string and list of character codes',14215,14218).
607 predicate(text_to_string,2,'Convert arbitrary text to a string',14220,14224).
608 predicate(string_length,2,'Determine length of a string',14226,14230).
609 predicate(string_code,3,'Get or find a character code in a string',14232,14239).
610 predicate(get_string_code,3,'Get character code at index in string',14241,14246).
611 predicate(string_concat,3,'atom_concat/3 for strings',14248,14257).
612 predicate(split_string,4,'Break a string into substrings',14259,14291).
613 predicate(sub_string,5,'Take a substring from a string',14293,14310).
614 predicate(atomics_to_string,2,'Concatenate list of inputs to a string',14312,14317).
615 predicate(atomics_to_string,3,'Concatenate list of inputs to a string',14319,14328).
616 predicate(string_upper,2,'Case conversion to upper case',14330,14332).
617 predicate(read_string,3,'Read a number of characters into a string',14338,14342).
618 predicate(read_string,5,'Read string upto a delimiter',14344,14373).
619 predicate(open_string,2,'Open a string as a stream',14375,14379).
620 predicate(list_strings,0,'Help porting to version 7',14423,14455).
621 predicate(string_predicate,1,'Hook (check) Predicate contains strings',14457,14470).
622 predicate(valid_string_goal,1,'Hook (check) Goal handles strings',14472,14484).
623 predicate('.',3,'',14801,14808).
624 predicate(get,1,'Read first non-blank character',14855,14868).
625 predicate(put,1,'Write a character',14870,14873).
626 predicate(put,2,'Write a character on a stream',14875,14899).
627 predicate(is_dict,1,'Type check for a dict',14907,14909).
628 predicate(is_dict,2,'Type check for a dict in a class',14911,14913).
629 predicate(get_dict,3,'Get the value associated to a key from a dict',14915,14925).
630 predicate(get_dict,5,'Replace existing value in a dict',14927,14939).
631 predicate(dict_create,3,'Create a dict from data',14941,14947).
632 predicate(dict_pairs,3,'Convert between dict and list of pairs',14949,14952).
633 predicate(put_dict,3,'Add/replace multiple keys in a dict',14954,14970).
634 predicate(put_dict,4,'Add/replace a single key in a dict',14972,14988).
635 predicate(del_dict,4,'Delete Key-Value pair from a dict',14990,14993).
636 predicate(:<,2,'Select keys from a dict',14995,15013).
637 predicate(select_dict,3,'Select matching attributes from a dict',15015,15031).
638 predicate(>:<,2,'Partial dict unification',15033,15047).
639 predicate(b_set_dict,3,'Destructive assignment on a dict',15073,15078).
640 predicate(nb_set_dict,3,'Non-backtrackable assignment to dict',15080,15085).
641 predicate(nb_link_dict,3,'Non-backtrackable assignment to dict',15087,15094).
642 predicate(module,2,'Declare a module',15451,15464).
643 predicate(module,3,'Declare a module with language options',15466,15475).
644 predicate(use_module,1,'Import a module',15491,15535).
645 predicate(use_module,2,'Import predicates from a module',15537,15570).
646 predicate(meta_predicate,1,'Declare access to other predicates',15623,15700).
647 predicate(@,2,'Call using calling context',15744,15759).
648 predicate(module,1,'Query/set current type-in module',15777,15789).
649 predicate(reexport,1,'Load files and re-export the imported predicates',15812,15816).
650 predicate(reexport,2,'Load predicates from a file and re-export it',15818,15822).
651 predicate(import_module,2,'Query import modules',15877,15882).
652 predicate(default_module,2,'Query module inheritance',15884,15889).
653 predicate(add_import_module,3,'Add module to the auto-import list',15891,15895).
654 predicate(delete_import_module,2,'Remove module from import list',15897,15904).
655 predicate(export,1,'Export a predicate from a module',15933,15939).
656 predicate(import,1,'Import a predicate from a module',15941,15948).
657 predicate(module_transparent,1,'Indicate module based meta-predicate',16059,16063).
658 predicate(context_module,1,'Get context module of current goal',16065,16068).
659 predicate(strip_module,3,'Extract context module and term',16070,16076).
660 predicate(current_module,1,'Examine existing modules',16084,16089).
661 predicate(module_property,2,'Find properties of a module',16091,16147).
662 predicate(set_module,1,'Set properties of a module',16149,16168).
663 predicate(attvar,1,'Type test for attributed variable',16429,16433).
664 predicate(put_attr,3,'Put attribute on a variable',16435,16443).
665 predicate(get_attr,3,'Fetch named attribute from a variable',16445,16450).
666 predicate(del_attr,2,'Delete attribute from variable',16452,16458).
667 predicate(attr_unify_hook,2,'Attributed variable unification hook',16467,16487).
668 predicate(attribute_goals,3,'Project attributes to goals',16489,16523).
669 predicate(project_attributes,2,'Project constraints to query variables',16525,16534).
670 predicate(attr_portray_hook,2,'Attributed variable print hook',16536,16544).
671 predicate(copy_term,3,'Copy a term and obtain attribute-goals',16549,16564).
672 predicate(copy_term_nat,2,'Make a copy of a term without attributes',16566,16569).
673 predicate(term_attvars,2,'Find attributed variables in a term',16571,16578).
674 predicate(get_attrs,2,'Fetch all attributes of a variable',16588,16592).
675 predicate(put_attrs,2,'Set/replace all attributes on a variable',16594,16597).
676 predicate(del_attrs,1,'Delete all attributes from variable',16599,16602).
677 predicate(dif,2,'Constrain two terms to be different',16662,16678).
678 predicate(freeze,2,'Delay execution until variable is bound',16680,16687).
679 predicate(frozen,2,'Query delayed goals on var',16689,16692).
680 predicate(when,2,'Execute goal when condition becomes true',16694,16703).
681 predicate(call_residue_vars,2,'Find residual attributed variables',16705,16720).
682 predicate(chr_option,2,'Specify CHR compilation options',16912,16950).
683 predicate(chr_constraint,1,'CHR Constraint declaration',16965,17040).
684 predicate(chr_type,1,'CHR Type declaration',17042,17171).
685 predicate(chr_trace,0,'Start CHR tracer',17308,17312).
686 predicate(chr_notrace,0,'Stop CHR tracer',17314,17318).
687 predicate(chr_leash,1,'Define CHR leashed ports',17320,17327).
688 predicate(chr_show_store,1,'List suspended CHR constraints',17329,17336).
689 predicate(find_chr_constraint,1,'Returns a constraint from the store',17338,17341).
690 predicate(thread_create,2,'Create a new Prolog task',17642,17644).
691 predicate(thread_create,3,'Create a new Prolog task',17646,17751).
692 predicate(thread_self,1,'Get identifier of current thread',17753,17756).
693 predicate(thread_join,1,'Wait for Prolog task-completion',17758,17762).
694 predicate(thread_join,2,'Wait for Prolog task-completion',17764,17790).
695 predicate(thread_detach,1,'Make thread cleanup after completion',17792,17804).
696 predicate(thread_exit,1,'Terminate Prolog task with value',17806,17817).
697 predicate(thread_initialization,1,'Run action at start of thread',17819,17828).
698 predicate(thread_at_exit,1,'Register goal to be called at exit',17830,17845).
699 predicate(thread_setconcurrency,2,'Number of active threads',17847,17854).
700 predicate(is_thread,1,'Type check for an thread handle',17869,17871).
701 predicate(thread_property,2,'Examine Prolog threads',17873,17940).
702 predicate(thread_statistics,3,'Get statistics of another thread',17942,17947).
703 predicate(mutex_statistics,0,'Print statistics on mutex usage',17949,17956).
704 predicate(thread_send_message,2,'Send message to another thread',17977,17993).
705 predicate(thread_send_message,3,'Send message to another thread',17995,18022).
706 predicate(thread_get_message,1,'Wait for message',18024,18044).
707 predicate(thread_peek_message,1,'Test for message',18046,18053).
708 predicate(message_queue_create,1,'Create queue for thread communication',18055,18060).
709 predicate(message_queue_create,2,'Create queue for thread communication',18062,18078).
710 predicate(message_queue_destroy,1,'Destroy queue for thread communication',18080,18085).
711 predicate(thread_get_message,2,'Wait for message in a queue',18087,18093).
712 predicate(thread_get_message,3,'Wait for message in a queue',18095,18118).
713 predicate(thread_peek_message,2,'Test for message in a queue',18120,18125).
714 predicate(message_queue_property,2,'Query message queue properties',18127,18186).
715 predicate(thread_signal,2,'Execute goal in another thread',18201,18219).
716 predicate(thread_local,1,'Declare thread-specific clauses for a predicate',18239,18268).
717 predicate(mutex_create,1,'Create a thread-synchronisation device',18314,18318).
718 predicate(mutex_create,2,'Create a thread-synchronisation device',18320,18326).
719 predicate(mutex_destroy,1,'Destroy a mutex',18328,18334).
720 predicate(with_mutex,2,'Run goal while holding mutex',18336,18347).
721 predicate(mutex_lock,1,'Become owner of a mutex',18349,18367).
722 predicate(mutex_trylock,1,'Become owner of a mutex (non-blocking)',18369,18372).
723 predicate(mutex_unlock,1,'Release ownership of mutex',18374,18378).
724 predicate(mutex_unlock_all,0,'Release ownership of all mutexes',18380,18384).
725 predicate(mutex_property,2,'Query mutex properties',18386,18400).
726 predicate(threads,0,'List running threads',18409,18411).
727 predicate(join_threads,0,'Join all terminated threads interactively',18413,18420).
728 predicate(interactor,0,'Start new thread with console and top level',18422,18426).
729 predicate(attach_console,0,'Attach I/O console to thread',18440,18455).
730 predicate(tdebug,1,'Switch a thread into debug mode',18457,18465).
731 predicate(tdebug,0,'Switch all threads into debug mode',18467,18469).
732 predicate(tnodebug,1,'Switch off debug mode in a thread',18471,18473).
733 predicate(tnodebug,0,'Switch off debug mode in all threads',18475,18477).
734 predicate(tspy,2,'Set spy point and enable debugging in a thread',18479,18485).
735 predicate(tspy,1,'Set spy point and enable debugging in all threads',18487,18492).
736 predicate(tprofile,1,'Profile a thread for some period',18503,18507).
737 predicate(in_pce_thread,1,'Run goal in XPCE thread',18703,18710).
738 predicate(in_pce_thread_sync,1,'Run goal in XPCE thread',18712,18725).
739 predicate(pce_dispatch,1,'Run XPCE GUI in separate thread',18727,18734).
740 predicate(engine_create,3,'Create an interactor',19024,19025).
741 predicate(engine_create,4,'Create an interactor',19027,19050).
742 predicate(engine_destroy,1,'Destroy an interactor',19052,19054).
743 predicate(engine_next,2,'Ask interactor for next term',19056,19063).
744 predicate(engine_next_reified,2,'Ask interactor for next term',19065,19080).
745 predicate(engine_post,2,'Send term to an interactor',19082,19086).
746 predicate(engine_post,3,'Send term to an interactor and wait for reply',19088,19090).
747 predicate(engine_yield,1,'Make term available to caller',19092,19100).
748 predicate(engine_fetch,1,'Get term from caller',19102,19106).
749 predicate(engine_self,1,'Get handle to running interactor',19108,19111).
750 predicate(is_engine,1,'Type check for an engine handle',19113,19116).
751 predicate(current_engine,1,'Enumerate known engines',19118,19120).
752 predicate(load_foreign_library,1,'library(shlib) Load shared library (.so file)',19263,19264).
753 predicate(load_foreign_library,2,'library(shlib) Load shared library (.so file)',19266,19292).
754 predicate(use_foreign_library,1,'Load DLL/shared object (directive)',19294,19295).
755 predicate(use_foreign_library,2,'Load DLL/shared object (directive)',19297,19310).
756 predicate(unload_foreign_library,1,'library(shlib) Detach shared library (.so file)',19312,19313).
757 predicate(unload_foreign_library,2,'library(shlib) Detach shared library (.so file)',19315,19320).
758 predicate(current_foreign_library,2,'library(shlib) Examine loaded shared libraries (.so files)',19322,19324).
759 predicate(reload_foreign_libraries,0,'Reload DLLs/shared objects',19326,19329).
760 predicate(open_shared_object,2,'UNIX: Open shared library (.so file)',19341,19350).
761 predicate(open_shared_object,3,'UNIX: Open shared library (.so file)',19352,19361).
762 predicate(close_shared_object,1,'UNIX: Close shared library (.so file)',19363,19365).
763 predicate(call_shared_object_function,2,'UNIX: Call C-function in shared (.so) file',19367,19372).
764 predicate(prolog_debug,1,'',23337,23338).
765 predicate(prolog_nodebug,1,'',23340,23352).
766 predicate(qsave_program,2,'Create runtime application',23529,23594).
767 predicate(qsave_program,1,'Create runtime application',23596,23598).
768 predicate(autoload,0,'Autoload all predicates now',23600,23649).
769 predicate(volatile,1,'Predicates that are not saved',23651,23656).
770 predicate(resource,3,'Declare a program resource',23780,23814).
771 predicate(open_resource,3,'Open a program resource as a stream',23816,23835).
772 predicate(aggregate,3,'Aggregate bindings in Goal according to Template.',24027,24030).
773 predicate(aggregate,4,'Aggregate bindings in Goal according to Template.',24032,24035).
774 predicate(aggregate_all,3,'Aggregate bindings in Goal according to Template.',24037,24043).
775 predicate(aggregate_all,4,'Aggregate bindings in Goal according to Template.',24045,24050).
776 predicate(foreach,2,'True if conjunction of results is true.',24052,24074).
777 predicate(free_variables,4,'Find free variables in bagof/setof template.',24076,24100).
778 predicate(safe_meta,2,'',24102,24105).
779 predicate(include,3,'Filter elements for which Goal succeeds.',24120,24126).
780 predicate(exclude,3,'Filter elements for which Goal fails.',24128,24131).
781 predicate(partition,4,'Filter elements of List according to Pred.',24133,24137).
782 predicate(partition,5,'Filter List according to Pred in three sets.',24139,24144).
783 predicate(maplist,2,'True if Goal can successfully be applied on all elements of List.',24146,24150).
784 predicate(maplist,3,'As maplist/2, operating on pairs of elements from two lists.',24152,24154).
785 predicate(maplist,4,'As maplist/2, operating on triples of elements from three lists.',24156,24158).
786 predicate(maplist,5,'As maplist/2, operating on quadruples of elements from four lists.',24160,24162).
787 predicate(convlist,3,'Similar to maplist/3, but elements for which call(Goal, ElemIn, _) fails are omitted from ListOut.',24164,24176).
788 predicate(foldl,4,'Fold a list, using arguments of the list as left argument.',24178,24179).
789 predicate(foldl,5,'Fold a list, using arguments of the list as left argument.',24181,24182).
790 predicate(foldl,6,'Fold a list, using arguments of the list as left argument.',24184,24185).
791 predicate(foldl,7,'Fold a list, using arguments of the list as left argument.',24187,24197).
792 predicate(scanl,4,'Left scan of list.',24199,24200).
793 predicate(scanl,5,'Left scan of list.',24202,24203).
794 predicate(scanl,6,'Left scan of list.',24205,24206).
795 predicate(scanl,7,'Left scan of list.',24208,24219).
796 predicate(empty_assoc,1,'Create/test empty association tree',24265,24267).
797 predicate(list_to_assoc,2,'Create association tree from list',24269,24275).
798 predicate(ord_list_to_assoc,2,'Convert ordered list to assoc',24277,24283).
799 predicate(get_assoc,3,'Fetch key from association tree',24290,24295).
800 predicate(get_assoc,5,'Fetch key from association tree',24297,24299).
801 predicate(max_assoc,3,'Highest key in association tree',24301,24303).
802 predicate(min_assoc,3,'Lowest key in association tree',24305,24307).
803 predicate(gen_assoc,3,'Enumerate members of association tree',24309,24314).
804 predicate(put_assoc,4,'Add Key-Value to association tree',24321,24324).
805 predicate(del_assoc,4,'',24326,24329).
806 predicate(del_min_assoc,4,'',24331,24335).
807 predicate(del_max_assoc,4,'',24337,24341).
808 predicate(assoc_to_list,2,'Convert association tree to list',24348,24351).
809 predicate(assoc_to_keys,2,'Translate assoc into a key list',24353,24356).
810 predicate(assoc_to_values,2,'Translate assoc into a value list',24358,24362).
811 predicate(is_assoc,1,'Verify association list',24370,24375).
812 predicate(map_assoc,2,'Map association tree',24377,24379).
813 predicate(map_assoc,3,'Map association tree',24381,24384).
814 predicate(broadcast,1,'Send event notification',24408,24414).
815 predicate(broadcast_request,1,'Request all agents',24416,24430).
816 predicate(listen,2,'Listen to event notifications',24432,24444).
817 predicate(listen,3,'Listen to event notifications',24446,24481).
818 predicate(unlisten,1,'Stop listening to event notifications',24483,24485).
819 predicate(unlisten,2,'Stop listening to event notifications',24487,24490).
820 predicate(unlisten,3,'Stop listening to event notifications',24492,24495).
821 predicate(listening,3,'Who is listening to event notifications?',24497,24500).
822 predicate(format_to_chars,3,'Use format/2 to write to a list of character codes.',24515,24517).
823 predicate(format_to_chars,4,'Use format/2 to write to a difference list of character codes.',24519,24521).
824 predicate(write_to_chars,2,'Write a term to a code list.',24523,24526).
825 predicate(write_to_chars,3,'Write a term to a code list.',24528,24531).
826 predicate(atom_to_chars,2,'Convert Atom into a list of character codes.',24533,24537).
827 predicate(atom_to_chars,3,'Convert Atom into a difference list of character codes.',24539,24541).
828 predicate(number_to_chars,2,'Convert Atom into a list of character codes.',24543,24547).
829 predicate(number_to_chars,3,'Convert Number into a difference list of character codes.',24549,24551).
830 predicate(read_from_chars,2,'Read Codes into Term.',24553,24558).
831 predicate(read_term_from_chars,3,'Read Codes into Term.',24560,24564).
832 predicate(open_chars_stream,2,'Open Codes as an input stream.',24566,24570).
833 predicate(with_output_to_chars,2,'Run Goal as with once/1.',24572,24575).
834 predicate(with_output_to_chars,3,'Run Goal as with once/1.',24577,24580).
835 predicate(with_output_to_chars,4,'Same as with_output_to_chars/3 using an explicit stream.',24582,24586).
836 predicate(check,0,'Run all consistency checks defined by checker/2.',24603,24618).
837 predicate(list_undefined,0,'Report undefined predicates.',24620,24621).
838 predicate(list_undefined,1,'Report undefined predicates.',24623,24636).
839 predicate(list_autoload,0,'Report predicates that may be auto-loaded.',24638,24647).
840 predicate(list_redefined,0,'Lists predicates that are defined in the global module =user= as well as in a normal module; that is, predicates for which the local definition overrules the global default definition.',24649,24653).
841 predicate(list_void_declarations,0,'List predicates that have declared attributes, but no clauses.',24655,24657).
842 predicate(list_trivial_fails,0,'List goals that trivially fail because there is no matching clause.',24659,24660).
843 predicate(list_trivial_fails,1,'List goals that trivially fail because there is no matching clause.',24662,24670).
844 predicate(trivial_fail_goal,1,'Multifile hook that tells list_trivial_fails/0 to accept Goal as valid.',24672,24675).
845 predicate(list_strings,0,'Help porting to version 7',24677,24678).
846 predicate(list_strings,1,'List strings that appear in clauses.',24680,24691).
847 predicate(string_predicate,1,'Hook (check) Predicate contains strings',24693,24696).
848 predicate(valid_string_goal,1,'Hook (check) Goal handles strings',24698,24702).
849 predicate(checker,2,'Register code validation routines.',24704,24721).
850 predicate(sat,1,'True iff Expr is a satisfiable Boolean expression.',25026,25028).
851 predicate(taut,2,'Tautology check.',25030,25034).
852 predicate(labeling,1,'Enumerate concrete solutions.',25036,25039).
853 predicate(sat_count,2,'Count the number of admissible assignments.',25041,25067).
854 predicate(weighted_maximum,3,'Enumerate weighted optima over admissible assignments.',25069,25087).
855 predicate(random_labeling,2,'Select a single random solution.',25089,25094).
856 predicate(#=,2,'The arithmetic expression X equals Y.',25904,25909).
857 predicate(#\=,2,'The arithmetic expressions X and Y evaluate to distinct integers.',25911,25916).
858 predicate(#>=,2,'Same as Y Scle{} X.',25918,25922).
859 predicate(#=<,2,'The arithmetic expression X is less than or equal to Y.',25924,25929).
860 predicate(#>,2,'Same as Y Sclt{} X.',25931,25935).
861 predicate(#<,2,'The arithmetic expression X is less than Y.',25937,25956).
862 predicate(in,2,'Var is an element of Domain.',25965,25979).
863 predicate(ins,2,'The variables in the list Vars are elements of Domain.',25981,25984).
864 predicate(indomain,1,'Bind Var to all feasible values of its domain on backtracking.',25993,25996).
865 predicate(label,1,'Equivalent to labeling([], Vars).',25998,26000).
866 predicate(labeling,2,'Assign a value to each variable in Vars.',26002,26088).
867 predicate(all_distinct,1,'True iff Vars are pairwise distinct.',26098,26109).
868 predicate(all_different,1,'Like all_distinct/1, but with weaker propagation.',26111,26115).
869 predicate(sum,3,'The sum of elements of the list Vars is in relation Rel to Expr.',26117,26128).
870 predicate(scalar_product,4,'True iff the scalar product of Cs and Vs is in relation Rel to Expr.',26130,26134).
871 predicate(lex_chain,1,'Lists are lexicographically non-decreasing.',26136,26138).
872 predicate(tuples_in,2,'True iff all Tuples are elements of Relation.',26140,26183).
873 predicate(serialized,2,'Describes a set of non-overlapping tasks.',26185,26204).
874 predicate(element,3,'The N-th element of the list of finite domain variables Vs is V.',26206,26209).
875 predicate(global_cardinality,2,'Global Cardinality constraint.',26211,26223).
876 predicate(global_cardinality,3,'Global Cardinality constraint.',26225,26242).
877 predicate(circuit,1,'True iff the list Vs of finite domain variables induces a Hamiltonian circuit.',26244,26258).
878 predicate(cumulative,1,'Equivalent to cumulative(Tasks, [limit(1)]).',26260,26262).
879 predicate(cumulative,2,'Schedule with a limited resource.',26264,26297).
880 predicate(disjoint2,1,'True iff Rectangles are not overlapping.',26299,26305).
881 predicate(automaton,3,'Describes a list of finite domain variables with a finite automaton.',26307,26329).
882 predicate(automaton,8,'Describes a list of finite domain variables with a finite automaton.',26331,26397).
883 predicate(chain,2,'Zs form a chain with respect to Relation.',26399,26410).
884 predicate(#\,1,'Q does _not_ hold.',26420,26429).
885 predicate(#<==>,2,'P and Q are equivalent.',26431,26470).
886 predicate(#==>,2,'P implies Q.',26472,26474).
887 predicate(#<==,2,'Q implies P.',26476,26478).
888 predicate(#/\,2,'P and Q hold.',26480,26482).
889 predicate(#\/,2,'P or Q holds.',26484,26498).
890 predicate(#\,2,'Either P holds or Q holds, but not both.',26500,26503).
891 predicate(zcompare,3,'Analogous to compare/3, with finite domain variables A and B.',26505,26559).
892 predicate(fd_var,1,'True iff Var is a CLP(FD) variable.',26570,26572).
893 predicate(fd_inf,2,'Inf is the infimum of the current domain of Var.',26574,26576).
894 predicate(fd_sup,2,'Sup is the supremum of the current domain of Var.',26578,26580).
895 predicate(fd_size,2,'Reflect the current size of a domain.',26582,26586).
896 predicate(fd_dom,2,'Dom is the current domain (see in/2) of Var.',26588,26616).
897 predicate({},1,'DCG escape; constraints',26678,26680).
898 predicate(entailed,1,'Check if constraint is entailed',26682,26686).
899 predicate(inf,2,'Find the infimum of an expression',26688,26692).
900 predicate(sup,2,'Find the supremum of an expression',26694,26698).
901 predicate(minimize,1,'Minimizes an expression',26700,26704).
902 predicate(maximize,1,'Maximizes an expression',26706,26710).
903 predicate(bb_inf,5,'Infimum of expression for mixed-integer problems',26712,26721).
904 predicate(bb_inf,4,'Infimum of expression for mixed-integer problems',26723,26726).
905 predicate(bb_inf,3,'Infimum of expression for mixed-integer problems',26728,26731).
906 predicate(dump,3,'Dump constraints on variables',26733,26743).
907 predicate(csv_read_file,2,'Read a CSV file into a list of rows.',26878,26879).
908 predicate(csv_read_file,3,'Read a CSV file into a list of rows.',26881,26897).
909 predicate(csv,3,'Prolog DCG to `read/write\' CSV data.',26899,26900).
910 predicate(csv,4,'Prolog DCG to `read/write\' CSV data.',26902,26939).
911 predicate(csv_read_file_row,3,'True when Row is a row in File.',26941,26961).
912 predicate(csv_read_row,3,'Read the next CSV record from Stream and unify the result with Row.',26963,26968).
913 predicate(csv_options,2,'Compiled is the compiled representation of the CSV processing options as they may be passed into csvSidiv{}2, etc.',26970,26975).
914 predicate(csv_write_file,2,'Write a list of Prolog terms to a CSV file.',26977,26978).
915 predicate(csv_write_file,3,'Write a list of Prolog terms to a CSV file.',26980,26985).
916 predicate(csv_write_stream,3,'Write the rows in Data to Stream.',26987,27001).
917 predicate(debugging,1,'Test where we are debugging topic',27023,27024).
918 predicate(debugging,1,'Test where we are debugging topic',27026,27027).
919 predicate(debugging,2,'Examine debug topics.',27029,27043).
920 predicate(debug,1,'Select topic for debugging',27045,27046).
921 predicate(nodebug,1,'Disable debug-topic',27048,27057).
922 predicate(list_debug_topics,0,'List registered topics for debugging',27059,27061).
923 predicate(debug_message_context,1,'Specify additional context for debug messages.',27063,27069).
924 predicate(debug,3,'Print debugging message on topic',27071,27084).
925 predicate(debug_print_hook,3,'Hook called by debug/3.',27086,27092).
926 predicate(assertion,1,'Make assertions about your program',27094,27107).
927 predicate(assertion_failed,2,'This hook is called if the Goal of assertion/1 fails.',27109,27115).
928 predicate(type_error,2,'Tell the user that Term is not of the expected Type.',27136,27151).
929 predicate(domain_error,2,'The argument is of the proper type, but has a value that is outside the supported values.',27153,27157).
930 predicate(existence_error,2,'Term is of the correct type and correct domain, but there is no existing (external) resource that is represented by it.',27159,27162).
931 predicate(permission_error,3,'It is not allowed to perform Action on the object Term that is of the given Type.',27164,27167).
932 predicate(instantiation_error,1,'An argument is under-instantiated.',27169,27180).
933 predicate(uninstantiation_error,1,'An argument is over-instantiated.',27182,27188).
934 predicate(representation_error,1,'A representation error indicates a limitation of the implementation.',27190,27196).
935 predicate(syntax_error,1,'A text has invalid syntax.',27198,27206).
936 predicate(resource_error,1,'A goal cannot be completed due to lack of resources.',27208,27210).
937 predicate(must_be,2,'True if Term satisfies the type constraints for Type.',27212,27259).
938 predicate(is_of_type,2,'True if Term satisfies Type.',27261,27263).
939 predicate(has_type,2,'True if Term satisfies Type.',27265,27267).
940 predicate(current_type,3,'True when Type is a currently defined type and Var satisfies Type of the body term Body succeeds.',27269,27272).
941 predicate(gensym,2,'Generate unique atoms from a base',27287,27292).
942 predicate(reset_gensym,1,'Reset a gensym key',27294,27298).
943 predicate(reset_gensym,0,'Reset all gensym keys',27300,27305).
944 predicate(open_any,5,'',27335,27382).
945 predicate(close_any,1,'',27384,27388).
946 predicate(open_hook,6,'',27390,27400).
947 predicate(member,2,'True if Elem is a member of List.',27420,27430).
948 predicate(append,3,'List1AndList2 is the concatenation of List1 and List2.',27432,27434).
949 predicate(append,2,'Concatenate a list of lists.',27436,27442).
950 predicate(prefix,2,'True iff Part is a leading substring of Whole.',27444,27447).
951 predicate(select,3,'Is true when List1, with Elem removed, results in List2.',27449,27451).
952 predicate(selectchk,3,'Semi-deterministic removal of first element in List that unifies with Elem.',27453,27456).
953 predicate(select,4,'Select from two lists at the same positon.',27458,27474).
954 predicate(selectchk,4,'Semi-deterministic version of select/4.',27476,27478).
955 predicate(nextto,3,'True if Y directly follows X in List.',27480,27482).
956 predicate(delete,3,'Delete matching elements from a list.',27484,27496).
957 predicate(nth0,3,'True when Elem is the Index\'th element of List.',27498,27506).
958 predicate(nth1,3,'Is true when Elem is the Index\'th element of List.',27508,27513).
959 predicate(nth0,4,'Select/insert element at index.',27515,27532).
960 predicate(nth1,4,'As nth0/4, but counting starts at 1.',27534,27536).
961 predicate(last,2,'Last element of a list',27538,27546).
962 predicate(proper_length,2,'True when Length is the number of elements in the proper list List.',27548,27557).
963 predicate(same_length,2,'Is true when List1 and List2 are lists with the same number of elements.',27559,27566).
964 predicate(reverse,2,'Is true when the elements of List2 are in reverse order compared to List1.',27568,27571).
965 predicate(permutation,2,'True when Xs is a permutation of Ys.',27573,27604).
966 predicate(flatten,2,'Is true if FlatList is a non-nested version of NestedList.',27606,27618).
967 predicate(max_member,2,'True when Max is the largest member in the standard order of terms.',27620,27627).
968 predicate(min_member,2,'True when Min is the smallest member in the standard order of terms.',27629,27636).
969 predicate(sum_list,2,'Sum is the result of adding all numbers in List.',27638,27640).
970 predicate(max_list,2,'True if Max is the largest number in List.',27642,27646).
971 predicate(min_list,2,'True if Min is the smallest number in List.',27648,27653).
972 predicate(numlist,3,'List is a list [Low, Low+1, ... High].',27655,27661).
973 predicate(is_set,1,'True if Set is a proper list without duplicates.',27663,27668).
974 predicate(list_to_set,2,'Remove duplicates from a list',27670,27686).
975 predicate(intersection,3,'True if Set3 unifies with the intersection of Set1 and Set2.',27688,27695).
976 predicate(union,3,'True if Set3 unifies with the union of the lists Set1 and Set2.',27697,27704).
977 predicate(subset,2,'True if all elements of SubSet belong to Set as well.',27706,27713).
978 predicate(subtract,3,'Delete all elements in Delete from Set.',27715,27722).
979 predicate(main,0,'Call main/1 using the passed command-line arguments.',27754,27758).
980 predicate(argv_options,3,'Generic transformation of long commandline arguments to options.',27760,27771).
981 predicate(empty_nb_set,1,'Test/create an empty non-backtrackable set',27800,27802).
982 predicate(add_nb_set,2,'Add term to a non-backtrackable set',27804,27807).
983 predicate(add_nb_set,3,'Add term to a non-backtrackable set',27809,27817).
984 predicate(gen_nb_set,2,'Generate members of non-backtrackable set',27819,27822).
985 predicate(size_nb_set,2,'Determine size of non-backtrackable set',27824,27826).
986 predicate(nb_set_to_list,2,'Convert non-backtrackable set to list',27828,27831).
987 predicate(www_open_url,1,'Open a web-page in a browser',27839,27859).
988 predicate(option,3,'Get an Option from OptionList.',27914,27920).
989 predicate(option,2,'Get an Option from OptionList.',27922,27929).
990 predicate(select_option,3,'Get and remove Option from an option list.',27931,27935).
991 predicate(select_option,4,'Get and remove Option with default value.',27937,27941).
992 predicate(merge_options,3,'Merge two option lists.',27943,27950).
993 predicate(meta_options,3,'Perform meta-expansion on options that are module-sensitive.',27952,27969).
994 predicate(dict_options,2,'Convert between an option list and a dictionary.',27971,27991).
995 predicate(opt_arguments,3,'Extract commandline options according to a specification.',28298,28314).
996 predicate(opt_parse,4,'Equivalent to opt_parse(OptsSpec, ApplArgs, Opts, PositionalArgs, Snil{}).',28316,28318).
997 predicate(opt_parse,5,'Parse the arguments Args (as list of atoms) according to OptsSpec.',28320,28355).
998 predicate(opt_help,2,'True when Help is a help string synthesized from OptsSpec.',28357,28359).
999 predicate(parse_type,3,'Hook to parse option text Codes to an object of type Type.',28361,28363).
1000 predicate(is_ordset,1,'True if Term is an ordered set.',28394,28399).
1001 predicate(ord_empty,1,'True when List is the empty ordered set.',28401,28404).
1002 predicate(ord_seteq,2,'True if Set1 and Set2 have the same elements.',28406,28411).
1003 predicate(list_to_ord_set,2,'Transform a list into an ordered set.',28413,28416).
1004 predicate(ord_intersect,2,'True if both ordered sets have a non-empty intersection.',28418,28420).
1005 predicate(ord_disjoint,2,'True if Set1 and Set2 have no common elements.',28422,28425).
1006 predicate(ord_intersect,3,'Intersection holds the common elements of Set1 and Set2.',28427,28431).
1007 predicate(ord_intersection,2,'Intersection of a powerset.',28433,28438).
1008 predicate(ord_intersection,3,'Intersection holds the common elements of Set1 and Set2.',28440,28443).
1009 predicate(ord_intersection,4,'Intersection and difference between two ordered sets.',28445,28451).
1010 predicate(ord_add_element,3,'Insert an element into the set.',28453,28456).
1011 predicate(ord_del_element,3,'Delete an element from an ordered set.',28458,28461).
1012 predicate(ord_selectchk,3,'Selectchk/3, specialised for ordered sets.',28463,28473).
1013 predicate(ord_memberchk,2,'True if Element is a member of OrdSet, compared using ==.',28475,28486).
1014 predicate(ord_subset,2,'Is true if all elements of Sub are in Super.',28488,28490).
1015 predicate(ord_subtract,3,'Diff is the set holding all elements of InOSet that are not in NotInOSet.',28492,28495).
1016 predicate(ord_union,2,'True if Union is the union of all elements in the superset SetOfSets.',28497,28504).
1017 predicate(ord_union,3,'Union is the union of Set1 and Set2.',28506,28508).
1018 predicate(ord_union,4,'True iff ord_union(Set1, Set2, Union) and ord_subtract(Set2, Set1, New).',28510,28513).
1019 predicate(ord_symdiff,3,'Is true when Difference is the symmetric difference of Set1 and Set2.',28515,28533).
1020 predicate(pairs_keys_values,3,'True if Keys holds the keys of Pairs and Values the values.',28550,28558).
1021 predicate(pairs_values,2,'Remove the keys from a list of Key-Value pairs.',28560,28563).
1022 predicate(pairs_keys,2,'Remove the values from a list of Key-Value pairs.',28565,28568).
1023 predicate(group_pairs_by_key,2,'Group values with equivalent (==/2) consecutive keys.',28570,28598).
1024 predicate(transpose_pairs,2,'Swap Key-Value to Value-Key.',28600,28603).
1025 predicate(map_list_to_pairs,3,'Create a Key-Value list by mapping each element of List.',28605,28612).
1026 predicate(persistent,1,'Declare dynamic database terms.',28682,28700).
1027 predicate(current_persistent_predicate,1,'True if PI is a predicate that provides access to the persistent database DB.',28702,28705).
1028 predicate(db_attach,2,'Use File as persistent database for the calling module.',28707,28719).
1029 predicate(db_attached,1,'True if the context module attached to the persistent database File.',28721,28724).
1030 predicate(db_detach,0,'Detach persistency from the calling module and delete all persistent clauses from the Prolog database.',28726,28731).
1031 predicate(db_sync,1,'Synchronise database with the associated file.',28733,28766).
1032 predicate(db_sync_all,1,'Sync all registered databases.',28768,28770).
1033 predicate(phrase_from_file,2,'Process the content of File using the DCG rule Grammar.',28801,28833).
1034 predicate(phrase_from_file,3,'As phrase_from_file/2, providing additional Options.',28835,28838).
1035 predicate(phrase_from_stream,2,'Run Grammer against the character codes on Stream.',28840,28843).
1036 predicate(syntax_error,3,'Throw the syntax error Error at the current location of the input.',28845,28851).
1037 predicate(lazy_list_location,3,'Determine current (error) location in a lazy list.',28853,28868).
1038 predicate(lazy_list_character_count,3,'True when CharCount is the current character count in the Lazy list.',28870,28881).
1039 predicate(stream_to_lazy_list,2,'Create a lazy list representing the character codes in Stream.',28883,28894).
1040 predicate(predicate_options,3,'Declare that the predicate PI processes options on Arg.',29036,29070).
1041 predicate(assert_predicate_options,4,'As predicate_options(:PI, +Arg, +Options).',29072,29080).
1042 predicate(current_predicate_option,3,'True when Arg of PI processes Option.',29082,29093).
1043 predicate(check_predicate_option,3,'Verify predicate options at runtime.',29095,29110).
1044 predicate(current_option_arg,2,'True when Arg of PI processes predicate options.',29112,29115).
1045 predicate(current_predicate_options,3,'True when Options is the current active option declaration for PI on Arg.',29117,29125).
1046 predicate(check_predicate_options,0,'Analyse loaded program for erroneous options.',29127,29143).
1047 predicate(derive_predicate_options,0,'Derive new predicate option declarations.',29145,29154).
1048 predicate(retractall_predicate_options,0,'Remove all dynamically (derived) predicate options.',29156,29158).
1049 predicate(derived_predicate_options,3,'Derive option arguments using static analysis.',29160,29163).
1050 predicate(derived_predicate_options,1,'Derive predicate option declarations for a module.',29165,29168).
1051 predicate(pack_list_installed,0,'List currently installed packages.',29188,29194).
1052 predicate(pack_info,1,'Print more detailed information about Pack.',29196,29198).
1053 predicate(pack_search,1,'Query package server and installed packages and display results.',29200,29201).
1054 predicate(pack_list,1,'Query package server and installed packages and display results.',29203,29235).
1055 predicate(pack_install,1,'Install a package.',29237,29255).
1056 predicate(pack_install,2,'Install package Name.',29257,29288).
1057 predicate(pack_url_file,2,'True if File is a unique id for the referenced pack and version.',29290,29294).
1058 predicate(pack_rebuild,1,'Rebuilt possible foreign components of Pack.',29296,29298).
1059 predicate(pack_rebuild,0,'Rebuild foreign components of all packages.',29300,29302).
1060 predicate(environment,2,'Hook to define the environment for building packs.',29304,29320).
1061 predicate(pack_upgrade,1,'Try to upgrade the package Pack.',29322,29327).
1062 predicate(pack_remove,1,'Remove the indicated package.',29329,29331).
1063 predicate(pack_property,2,'True when Property is a property of an installed Pack.',29333,29358).
1064 predicate(xref_source,1,'Cross-reference analysis of source',29393,29398).
1065 predicate(xref_current_source,1,'Examine cross-referenced sources',29400,29402).
1066 predicate(xref_clean,1,'Remove analysis of source',29404,29406).
1067 predicate(xref_defined,3,'Examine defined predicates',29408,29419).
1068 predicate(xref_called,3,'Examine called predicates',29421,29423).
1069 predicate(xref_exported,2,'Examine exported predicates',29425,29427).
1070 predicate(xref_module,2,'Module defined by source',29429,29431).
1071 predicate(xref_built_in,1,'Examine defined built-ins',29433,29438).
1072 predicate(called_by,2,'Hook (prolog) Extend cross-referencer',29446,29459).
1073 predicate(with_quasi_quotation_input,3,'Parse quasi quotation from stream',29541,29561).
1074 predicate(phrase_from_quasi_quotation,2,'Parse quasi quotation with DCG',29563,29569).
1075 predicate(quasi_quotation_syntax,1,'Declare quasi quotation syntax',29571,29574).
1076 predicate(quasi_quotation_syntax_error,1,'Raise syntax error',29576,29581).
1077 predicate(random,1,'Binds R to a new random float in the _open_ interval (0.0,1.0).',29595,29603).
1078 predicate(random_between,3,'Binds R to a random integer in [L,U] (i.e., including both L and U).',29605,29608).
1079 predicate(random,3,'Generate a random integer or float in a range.',29610,29611).
1080 predicate(random,3,'Generate a random integer or float in a range.',29613,29622).
1081 predicate(setrand,1,'Query/set the state of the random generator.',29624,29625).
1082 predicate(getrand,1,'Query/set the state of the random generator.',29627,29646).
1083 predicate(maybe,0,'Succeed/fail with equal probability (variant of maybe/1).',29648,29650).
1084 predicate(maybe,1,'Succeed with probability P, fail with probability 1-P.',29652,29654).
1085 predicate(maybe,2,'Succeed with probability K/N (variant of maybe/1).',29656,29658).
1086 predicate(random_perm2,4,'Does X=A,Y=B or X=B,Y=A with equal probability.',29660,29662).
1087 predicate(random_member,2,'X is a random member of List.',29664,29669).
1088 predicate(random_select,3,'Randomly select or insert an element.',29671,29672).
1089 predicate(random_select,3,'Randomly select or insert an element.',29674,29679).
1090 predicate(randset,3,'S is a sorted list of K unique random integers in the range 1..N.',29681,29696).
1091 predicate(randseq,3,'S is a list of K unique random integers in the range 1..N.',29698,29709).
1092 predicate(random_permutation,2,'Permutation is a random permutation of List.',29711,29712).
1093 predicate(random_permutation,2,'Permutation is a random permutation of List.',29714,29720).
1094 predicate(read_line_to_codes,2,'Read line from a stream',29733,29741).
1095 predicate(read_line_to_codes,3,'Read line from a stream',29743,29764).
1096 predicate(read_stream_to_codes,2,'Read contents of stream',29766,29768).
1097 predicate(read_stream_to_codes,3,'Read contents of stream',29770,29772).
1098 predicate(read_file_to_codes,3,'Read contents of file',29774,29780).
1099 predicate(read_file_to_terms,3,'Read contents of file to Prolog terms',29782,29788).
1100 predicate(record,1,'Define named fields in a term',29882,29887).
1101 predicate(registry_get_key,2,'Get principal value of key',29906,29909).
1102 predicate(registry_get_key,3,'Get associated value of key',29911,29913).
1103 predicate(registry_set_key,2,'Set principal value of key',29915,29918).
1104 predicate(registry_set_key,3,'Set associated value of key',29920,29923).
1105 predicate(registry_delete_key,1,'Remove a key',29925,29927).
1106 predicate(shell_register_file_type,4,'Register a file-type',29929,29935).
1107 predicate(shell_register_dde,6,'Register DDE action',29937,29944).
1108 predicate(shell_register_prolog,1,'Register Prolog',29946,29965).
1109 predicate(gen_state,1,'Create empty linear program',30013,30016).
1110 predicate(constraint,3,'Add linear constraint to state',30018,30028).
1111 predicate(maximize,3,'Maximize objective function in to linear constraints',30030,30036).
1112 predicate(minimize,3,'Minimize objective function in to linear constraints',30038,30040).
1113 predicate(variable_value,3,'Fetch value of variable in solved state',30042,30045).
1114 predicate(objective,2,'Fetch value of objective function',30047,30056).
1115 predicate(constraint,4,'Add named linear constraint to state',30065,30068).
1116 predicate(shadow_price,3,'Fetch shadow price in solved state',30070,30074).
1117 predicate(constraint_add,4,'Extend a named constraint',30076,30084).
1118 predicate(transportation,4,'Solve transportation problem',30092,30101).
1119 predicate(assignment,2,'Solve assignment problem',30103,30109).
1120 predicate(distinct,1,'True if Goal is true and no previous solution of Goal bound Witness to the same value.',30311,30312).
1121 predicate(distinct,2,'True if Goal is true and no previous solution of Goal bound Witness to the same value.',30314,30330).
1122 predicate(reduced,1,'Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.',30332,30333).
1123 predicate(reduced,3,'Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.',30335,30347).
1124 predicate(limit,2,'Limit the number of solutions.',30349,30353).
1125 predicate(offset,2,'Ignore the first Count solutions.',30355,30359).
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).
76 predicate(qcompile,1,'Compile source to Quick Load File',5440,5460).
77 predicate(qcompile,2,'Compile source to Quick Load File',5462,5465).
78 predicate(edit,1,'Edit a file, predicate, module (extensible)',5492,5499).
79 predicate(edit,0,'Edit current script- or associated file',5501,5505).
80 predicate(locate,3,'Locate targets for edit/1',5514,5527).
81 predicate(locate,2,'Locate targets for edit/1',5529,5532).
82 predicate(edit_source,1,'Call editor for edit/1',5534,5551).
83 predicate(edit_command,2,'Specify editor activation',5553,5579).
84 predicate(load,0,'Load edit/1 extensions',5581,5594).
85 predicate(listing,1,'List predicate',5599,5610).
86 predicate(listing,0,'List program in current module',5612,5616).
87 predicate(portray_clause,1,'Pretty print a clause',5618,5623).
88 predicate(portray_clause,2,'Pretty print a clause to a stream',5625,5627).
89 predicate(var,1,'Type check for unbound variable',5637,5639).
90 predicate(nonvar,1,'Type check for bound term',5641,5643).
91 predicate(integer,1,'Type check for integer',5645,5647).
92 predicate(float,1,'Type check for a floating point number',5649,5651).
93 predicate(rational,1,'Type check for a rational number',5653,5656).
94 predicate(rational,3,'Decompose a rational',5658,5663).
95 predicate(number,1,'Type check for integer or float',5665,5667).
96 predicate(atom,1,'Type check for an atom',5669,5671).
97 predicate(blob,2,'Type check for a blob',5673,5675).
98 predicate(string,1,'Type check for string',5677,5683).
99 predicate(atomic,1,'Type check for primitive',5685,5699).
100 predicate(compound,1,'Test for compound term',5701,5704).
101 predicate(callable,1,'Test for atom or compound term',5706,5725).
102 predicate(ground,1,'Verify term holds no unbound variables',5727,5730).
103 predicate(cyclic_term,1,'Test term for cycles',5732,5735).
104 predicate(acyclic_term,1,'Test term for cycles',5737,5740).
105 predicate(=,2,'True when arguments are unified',5748,5755).
106 predicate(\=,2,'True if arguments cannot be unified',5757,5767).
107 predicate(==,2,'Test for strict equality',5825,5828).
108 predicate(\==,2,'True if arguments are not strictly equal',5830,5832).
109 predicate(@<,2,'Standard order smaller',5834,5836).
110 predicate(@=<,2,'Standard order smaller or equal',5838,5841).
111 predicate(@>,2,'Standard order larger',5843,5845).
112 predicate(@>=,2,'Standard order larger or equal',5847,5850).
113 predicate(compare,3,'Compare, using a predicate to determine the order',5852,5855).
114 predicate(unify_with_occurs_check,2,'Logically sound unification',5868,5905).
115 predicate(=@=,2,'Test for structural equality (variant)',5907,5948).
116 predicate(\=@=,2,'Not structural identical',5950,5952).
117 predicate(subsumes_term,2,'One-sided unification test',5954,5960).
118 predicate(term_subsumer,3,'Most specific generalization of two terms',5962,5965).
119 predicate(unifiable,3,'Determining binding required for unification',5967,5972).
120 predicate(?=,2,'Test of terms can be compared now',5974,5979).
121 predicate(fail,0,'Always false',5997,6000).
122 predicate(false,0,'Always false',6002,6004).
123 predicate(true,0,'Succeed',6006,6009).
124 predicate(repeat,0,'Succeed, leaving infinite backtrack points',6011,6013).
125 predicate(!,0,'Cut (discard choicepoints)',6015,6034).
126 predicate(',',2,'Conjunction of goals',6036,6043).
127 predicate(;,2,'Disjunction of two goals',6045,6051).
128 predicate('|',2,'Disjunction in DCGs. Same as ;/2',6053,6056).
129 predicate(->,2,'If-then-else',6058,6081).
130 predicate(*->,2,'Soft-cut',6083,6112).
131 predicate(\+,1,'Negation by failure. Same as not/1',6114,6118).
132 predicate(call,1,'Call a goal',6130,6133).
133 predicate(call,_122,'Call with additional arguments',6135,6146).
134 predicate(apply,2,'Call goal with additional arguments',6148,6153).
135 predicate(not,1,'Negation by failure (argument not provable). Same as \\+/1',6155,6158).
136 predicate(once,1,'Call a goal deterministically',6160,6180).
137 predicate(ignore,1,'Call the argument, but always succeed',6182,6190).
138 predicate(call_with_depth_limit,3,'Prove goal with bounded depth',6192,6221).
139 predicate(call_with_inference_limit,3,'Prove goal in limited inferences',6223,6255).
140 predicate(setup_call_cleanup,3,'Undo side-effects safely',6257,6314).
141 predicate(setup_call_catcher_cleanup,4,'Undo side-effects safely',6316,6347).
142 predicate(call_cleanup,2,'Guard a goal with a cleaup-handler',6349,6356).
143 predicate(call_cleanup,3,'Guard a goal with a cleaup-handler',6358,6361).
144 predicate(reset,3,'Wrapper for delimited continuations',6376,6383).
145 predicate(shift,1,'Shift control to the closest reset/3',6385,6391).
146 predicate(catch,3,'Call goal, watching for exceptions',6399,6413).
147 predicate(throw,1,'Raise an exception (see catch/3)',6415,6447).
148 predicate(print_message,2,'Print message from (exception) term',6583,6648).
149 predicate(print_message_lines,3,'Print message to stream',6650,6691).
150 predicate(message_hook,3,'Intercept print_message/2',6693,6701).
151 predicate(thread_message_hook,3,'Thread local message_hook/3',6703,6709).
152 predicate(message_property,2,'Hook (user) Define display of a message',6711,6748).
153 predicate(message_line_element,2,'Hook (prolog) Intercept print_message_lines/3',6750,6754).
154 predicate(message_to_string,2,'Translate message-term to string',6756,6758).
155 predicate(version,0,'Print system banner message',6760,6764).
156 predicate(version,1,'Add messages to the system banner',6766,6771).
157 predicate(on_signal,3,'Handle a software signal',6857,6891).
158 predicate(current_signal,3,'Current software signal mapping',6893,6897).
159 predicate(prolog_alert_signal,2,'Query/set unblock signal',6899,6903).
160 predicate(phrase,2,'Activate grammar-rule set',6986,6988).
161 predicate(phrase,3,'Activate grammar-rule set (returning rest)',6990,7046).
162 predicate(call_dcg,3,'As phrase/3 without type checking',7048,7074).
163 predicate(abolish,1,'Remove predicate definition from the database',7144,7160).
164 predicate(abolish,2,'Remove predicate definition from the database',7162,7165).
165 predicate(copy_predicate_clauses,2,'Copy clauses between predicates',7167,7190).
166 predicate(redefine_system_predicate,1,'Abolish system definition',7192,7202).
167 predicate(retract,1,'Remove clause from the database',7204,7236).
168 predicate(retractall,1,'Remove unifying clauses from the database',7238,7243).
169 predicate(asserta,1,'Add a clause to the database (first)',7245,7246).
170 predicate(assertz,1,'Add a clause to the database (last)',7248,7249).
171 predicate(assert,1,'Add a clause to the database',7251,7267).
172 predicate(asserta,2,'Add a clause to the database (first)',7269,7270).
173 predicate(assertz,2,'Add a clause to the database (last)',7272,7273).
174 predicate(assert,2,'Add a clause to the database, give reference',7275,7279).
175 predicate(recorda,3,'Record term in the database (first)',7284,7290).
176 predicate(recorda,2,'Record term in the database (first)',7292,7294).
177 predicate(recordz,3,'Record term in the database (last)',7296,7299).
178 predicate(recordz,2,'Record term in the database (last)',7301,7303).
179 predicate(recorded,3,'Obtain term from the database',7305,7316).
180 predicate(recorded,2,'Obtain term from the database',7318,7320).
181 predicate(erase,1,'Erase a database record or clause',7322,7329).
182 predicate(instance,2,'Fetch clause or record from reference',7331,7334).
183 predicate(get_flag,2,'Get value of a flag',7346,7349).
184 predicate(flag,3,'Simple global variable system',7356,7366).
185 predicate(trie_new,1,'Create a trie',7393,7397).
186 predicate(trie_destroy,1,'Destroy a trie',7399,7403).
187 predicate(is_trie,1,'Type check for a trie handle',7405,7407).
188 predicate(current_trie,1,'Enumerate known tries',7409,7413).
189 predicate(trie_insert,3,'Insert term into a trie',7415,7420).
190 predicate(trie_update,3,'Update associated value in trie',7422,7425).
191 predicate(trie_insert,4,'Insert term into a trie',7427,7432).
192 predicate(trie_delete,3,'Remove term from trie',7434,7437).
193 predicate(trie_lookup,3,'Lookup a term in a trie',7439,7441).
194 predicate(trie_term,2,'Get term from a trie by handle',7443,7448).
195 predicate(trie_gen,3,'Get all terms from a trie',7450,7455).
196 predicate(trie_property,2,'Examine a trie\'s properties',7457,7473).
197 predicate(term_hash,2,'Hash-value of ground term',7509,7524).
198 predicate(term_hash,4,'Hash-value of term with depth limit',7526,7535).
199 predicate(variant_sha1,2,'Term-hash for term-variants',7537,7556).
200 predicate(variant_hash,2,'Term-hash for term-variants',7558,7564).
201 predicate(dynamic,1,'Indicate predicate definition may change',7585,7593).
202 predicate(compile_predicates,1,'Compile dynamic code to static',7595,7603).
203 predicate(multifile,1,'Indicate distributed definition of predicate',7605,7609).
204 predicate(discontiguous,1,'Indicate distributed definition of a predicate',7611,7614).
205 predicate(public,1,'Declaration that a predicate may be called',7616,7625).
206 predicate(current_atom,1,'Examine existing atoms',7630,7634).
207 predicate(current_blob,2,'Examine typed blobs',7636,7641).
208 predicate(current_functor,2,'Examine existing name/arity pairs',7643,7661).
209 predicate(current_flag,1,'Examine existing flags',7663,7666).
210 predicate(current_key,1,'Examine existing database keys',7668,7671).
211 predicate(current_predicate,1,'Examine existing predicates (ISO)',7673,7689).
212 predicate(current_predicate,2,'Examine existing predicates',7691,7708).
213 predicate(predicate_property,2,'Query predicate attributes',7710,7887).
214 predicate(dwim_predicate,2,'Find predicate in ``Do What I Mean\'\' sense',7889,7898).
215 predicate(clause,2,'Get clauses of a predicate',7900,7904).
216 predicate(clause,3,'Get clauses of a predicate',7906,7911).
217 predicate(nth_clause,3,'N-th clause of a predicate',7913,7932).
218 predicate(clause_property,2,'Get properties of a clause',7934,7987).
219 predicate(open,4,'Open a file (creating a stream)',8065,8202).
220 predicate(open,3,'Open a file (creating a stream)',8204,8206).
221 predicate(open_null_stream,1,'Open a stream to discard output',8208,8226).
222 predicate(close,1,'Close stream',8228,8238).
223 predicate(close,2,'Close stream (forced)',8240,8244).
224 predicate(stream_property,2,'Get stream properties',8246,8370).
225 predicate(current_stream,3,'Examine open streams',8372,8379).
226 predicate(is_stream,1,'Type check for a stream handle',8381,8385).
227 predicate(stream_pair,3,'Create/examine a bi-directional stream',8387,8404).
228 predicate(set_stream_position,2,'Seek stream to position',8406,8410).
229 predicate(stream_position_data,3,'Access fields from stream position',8412,8418).
230 predicate(seek,4,'Modify the current position in a stream',8420,8448).
231 predicate(set_stream,2,'Set stream attribute',8450,8551).
232 predicate(set_prolog_IO,3,'Prepare streams for interactive session',8553,8564).
233 predicate(see,1,'Change the current input stream',8643,8647).
234 predicate(tell,1,'Change current output stream',8649,8654).
235 predicate(append,1,'Append to a file',8656,8660).
236 predicate(seeing,1,'Query the current input stream',8662,8667).
237 predicate(telling,1,'Query current output stream',8669,8674).
238 predicate(seen,0,'Close the current input stream',8676,8679).
239 predicate(told,0,'Close current output',8681,8684).
240 predicate(set_input,1,'Set current input stream from a stream',8692,8696).
241 predicate(set_output,1,'Set current output stream from a stream',8698,8701).
242 predicate(current_input,1,'Get current input stream',8703,8706).
243 predicate(current_output,1,'Get the current output stream',8708,8710).
244 predicate(with_output_to,2,'Write to strings and more',8715,8765).
245 predicate(fast_term_serialized,2,'Fast term (de-)serialization',8796,8798).
246 predicate(fast_write,2,'Write binary term serialization',8800,8803).
247 predicate(fast_read,2,'Read binary term serialization',8805,8808).
248 predicate(wait_for_input,3,'Wait for input with optional timeout',8813,8866).
249 predicate(byte_count,2,'Byte-position in a stream',8868,8873).
250 predicate(character_count,2,'Get character index on a stream',8875,8880).
251 predicate(line_count,2,'Line number on stream',8882,8885).
252 predicate(line_position,2,'Character position in line on stream',8887,8892).
253 predicate(nl,0,'Generate a newline',8899,8902).
254 predicate(nl,1,'Generate a newline on a stream',8904,8906).
255 predicate(put,1,'Write a character',8908,8913).
256 predicate(put,2,'Write a character on a stream',8915,8917).
257 predicate(put_byte,1,'Write a byte',8919,8922).
258 predicate(put_byte,2,'Write a byte on a stream',8924,8927).
259 predicate(put_char,1,'Write a character',8929,8934).
260 predicate(put_char,2,'Write a character on a stream',8936,8940).
261 predicate(put_code,1,'Write a character-code',8942,8946).
262 predicate(put_code,2,'Write a character-code on a stream',8948,8950).
263 predicate(tab,1,'Output number of spaces',8952,8956).
264 predicate(tab,2,'Output number of spaces on a stream',8958,8960).
265 predicate(flush_output,0,'Output pending characters on current stream',8962,8966).
266 predicate(flush_output,1,'Output pending characters on specified stream',8968,8971).
267 predicate(ttyflush,0,'Flush output on terminal',8973,8975).
268 predicate(get_byte,1,'Read next byte (ISO)',8977,8981).
269 predicate(get_byte,2,'Read next byte from a stream (ISO)',8983,8986).
270 predicate(get_code,1,'Read next character (ISO)',8988,8992).
271 predicate(get_code,2,'Read next character from a stream (ISO)',8994,8996).
272 predicate(get_char,1,'Read next character as an atom (ISO)',8998,9002).
273 predicate(get_char,2,'Read next character from a stream (ISO)',9004,9007).
274 predicate(get0,1,'Read next character',9009,9014).
275 predicate(get0,2,'Read next character from a stream',9016,9019).
276 predicate(get,1,'Read first non-blank character',9021,9025).
277 predicate(get,2,'Read first non-blank character from a stream',9027,9030).
278 predicate(peek_byte,1,'Read byte without removing',9032,9033).
279 predicate(peek_byte,2,'Read byte without removing',9035,9036).
280 predicate(peek_code,1,'Read character-code without removing',9038,9039).
281 predicate(peek_code,2,'Read character-code without removing',9041,9042).
282 predicate(peek_char,1,'Read character without removing',9044,9045).
283 predicate(peek_char,2,'Read character without removing',9047,9054).
284 predicate(peek_string,3,'Read a string without removing',9056,9063).
285 predicate(skip,1,'Skip to character in current input',9065,9069).
286 predicate(skip,2,'Skip to character on stream',9071,9073).
287 predicate(get_single_char,1,'Read next character from the terminal',9075,9084).
288 predicate(at_end_of_stream,0,'Test for end of file on input',9086,9090).
289 predicate(at_end_of_stream,1,'Test for end of file on stream',9092,9097).
290 predicate(set_end_of_stream,1,'Set physical end of an open file',9099,9103).
291 predicate(copy_stream_data,3,'Copy n bytes from stream to stream',9105,9110).
292 predicate(copy_stream_data,2,'Copy all data from stream to stream',9112,9114).
293 predicate(fill_buffer,1,'Fill the input buffer of a stream',9116,9121).
294 predicate(read_pending_codes,3,'Fetch buffered input from a stream',9123,9158).
295 predicate(read_pending_chars,3,'Fetch buffered input from a stream',9160,9163).
296 predicate(write_term,2,'Write term with options',9177,9344).
297 predicate(write_term,3,'Write term with options to stream',9346,9349).
298 predicate(write_length,3,'Dermine #characters to output a term',9351,9360).
299 predicate(write_canonical,1,'Write a term with quotes, ignore operators',9362,9376).
300 predicate(write_canonical,2,'Write a term with quotes, ignore operators on a stream',9378,9380).
301 predicate(write,1,'Write term',9382,9385).
302 predicate(write,2,'Write term to stream',9387,9389).
303 predicate(writeq,1,'Write term, insert quotes',9391,9396).
304 predicate(writeq,2,'Write term, insert quotes on stream',9398,9400).
305 predicate(writeln,1,'Write term, followed by a newline',9402,9406).
306 predicate(writeln,2,'Write term, followed by a newline to a stream',9408,9412).
307 predicate(print,1,'Print a term',9414,9442).
308 predicate(print,2,'Print a term on a stream',9444,9446).
309 predicate(portray,1,'Hook (user) Modify behaviour of print/1',9448,9455).
310 predicate(read,1,'Read Prolog term',9457,9462).
311 predicate(read,2,'Read Prolog term from stream',9464,9466).
312 predicate(read_clause,3,'Read clause from stream',9468,9498).
313 predicate(read_term,2,'Read term with options',9500,9653).
314 predicate(read_term,3,'Read term with options from stream',9655,9657).
315 predicate(read_term_from_atom,3,'Read term with options from atom',9659,9664).
316 predicate(read_history,6,'Read using history substitution',9666,9681).
317 predicate(prompt,2,'Change the prompt used by read/1',9683,9691).
318 predicate(prompt1,1,'Change prompt for 1 line',9693,9696).
319 predicate(functor,3,'Get name and arity of a term or construct a term ',9701,9721).
320 predicate(arg,3,'Access argument of a term',9723,9732).
321 predicate(=..,2,'``Univ.\'\' Term to list conversion',9734,9756).
322 predicate(compound_name_arity,3,'Name and arity of a compound term',9758,9762).
323 predicate(compound_name_arguments,3,'Name and arguments of a compound term',9764,9767).
324 predicate(numbervars,3,'Number unbound variables of a term',9769,9789).
325 predicate(numbervars,4,'Number unbound variables of a term',9791,9810).
326 predicate(var_number,2,'Check that var is numbered by numbervars',9812,9818).
327 predicate(term_variables,2,'Find unbound variables in a term',9820,9830).
328 predicate(nonground,2,'Term is not ground due to witness',9832,9841).
329 predicate(term_variables,3,'Find unbound variables in a term',9843,9846).
330 predicate(term_singletons,2,'Find singleton variables in a term',9848,9860).
331 predicate(copy_term,2,'Make a copy of a term',9862,9871).
332 predicate(setarg,3,'Destructive assignment on term',9883,9900).
333 predicate(nb_setarg,3,'Non-backtrackable assignment to term',9902,9932).
334 predicate(nb_linkarg,3,'Non-backtrackable assignment to term',9934,9938).
335 predicate(duplicate_term,2,'Create a copy of a term',9940,9945).
336 predicate(same_term,2,'Test terms to be at the same address',9947,9952).
337 predicate(atom_codes,2,'Convert between atom and list of characters codes',9975,9981).
338 predicate(atom_chars,2,'Convert between atom and list of characters',9983,9991).
339 predicate(char_code,2,'Convert between character and character code',9993,9996).
340 predicate(number_chars,2,'Convert between number and one-char atoms',9998,10011).
341 predicate(number_codes,2,'Convert between number and character codes',10013,10017).
342 predicate(atom_number,2,'Convert between atom and number',10019,10026).
343 predicate(name,2,'Convert between atom and list of character codes',10028,10046).
344 predicate(term_to_atom,2,'Convert between term and atom',10048,10055).
345 predicate(atom_to_term,3,'Convert between atom and term',10057,10064).
346 predicate(atom_concat,3,'Contatenate two atoms',10066,10073).
347 predicate(atomic_concat,3,'Concatenate two atomic values to an atom',10075,10083).
348 predicate(atomic_list_concat,2,'Append a list of atomics',10085,10090).
349 predicate(atomic_list_concat,3,'Append a list of atomics with separator',10092,10113).
350 predicate(atom_length,2,'Determine length of an atom',10115,10121).
351 predicate(atom_prefix,2,'Test for start of atom',10123,10126).
352 predicate(sub_atom,5,'Take a substring from an atom',10128,10142).
353 predicate(sub_atom_icasechk,3,'Case insensitive substring match',10144,10150).
354 predicate(locale_create,3,'Create a new locale object',10180,10214).
355 predicate(locale_destroy,1,'Destroy a locale object',10216,10220).
356 predicate(locale_property,2,'Query properties of locale objects',10222,10225).
357 predicate(set_locale,1,'Set the default local',10227,10233).
358 predicate(current_locale,1,'Get the current locale',10235,10237).
359 predicate(char_type,2,'Classify characters',10252,10366).
360 predicate(code_type,2,'Classify a character-code',10368,10375).
361 predicate(downcase_atom,2,'Convert atom to lower-case',10385,10390).
362 predicate(upcase_atom,2,'Convert atom to upper-case',10392,10394).
363 predicate(normalize_space,2,'Normalize white space',10399,10404).
364 predicate(collation_key,2,'Sort key for locale dependent ordering',10412,10425).
365 predicate(locale_sort,2,'Language dependent sort of atoms',10427,10432).
366 predicate(op,3,'Declare an operator',10471,10539).
367 predicate(current_op,3,'Examine current operator declarations',10541,10544).
368 predicate(char_conversion,2,'Provide mapping of input characters',10552,10558).
369 predicate(current_char_conversion,2,'Query input character mapping',10560,10563).
370 predicate(between,3,'Integer range checking/generating',10583,10590).
371 predicate(succ,2,'Logical integer successor relation',10592,10598).
372 predicate(plus,3,'Logical integer addition',10600,10603).
373 predicate(divmod,4,'Compute quotient and remainder of two integers',10605,10622).
374 predicate(nth_integer_root_and_remainder,4,'Integer root and remainder',10624,10641).
375 predicate(>,2,'Arithmetic larger',10652,10654).
376 predicate(<,2,'Arithmetic smaller',10656,10658).
377 predicate(=<,2,'Arithmetic smaller or equal',10660,10663).
378 predicate(>=,2,'Arithmetic larger or equal',10665,10668).
379 predicate(=\=,2,'Arithmetic not equal',10670,10672).
380 predicate(=:=,2,'Arithmetic equality',10674,10676).
381 predicate(is,2,'Evaluate arithmetic expression',10678,10687).
382 predicate(-,1,'Unary minus',10805,10807).
383 predicate(+,1,'Unary plus (No-op)',10809,10812).
384 predicate(+,2,'Addition',10814,10816).
385 predicate(-,2,'Subtraction',10818,10820).
386 predicate(*,2,'Multiplication',10822,10824).
387 predicate(/,2,'Shorthand for `Free/[]Srshift{}Lambda`.',10826,10834).
388 predicate(mod,2,'Remainder of division',10836,10839).
389 predicate(rem,2,'Remainder of division',10841,10844).
390 predicate(//,2,'Integer division',10846,10851).
391 predicate(div,2,'Integer division',10853,10866).
392 predicate(rdiv,2,'Ration number division',10868,10872).
393 predicate(gcd,2,'Greatest common divisor',10874,10876).
394 predicate(abs,1,'Absolute value',10878,10880).
395 predicate(sign,1,'Extract sign of value',10882,10887).
396 predicate(copysign,2,'Apply sign of N2 to N1',10889,10900).
397 predicate(max,2,'Maximum of two numbers',10902,10907).
398 predicate(min,2,'Minimum of two numbers',10909,10912).
399 predicate('.',2,'Consult. Also functional notation',10914,10923).
400 predicate(random,1,'Binds R to a new random float in the _open_ interval (0.0,1.0).',10925,10943).
401 predicate(random_float,0,'Generate random number',10945,10951).
402 predicate(round,1,'Round to nearest integer',10953,10960).
403 predicate(integer,1,'Type check for integer',10962,10964).
404 predicate(float,1,'Type check for a floating point number',10966,10971).
405 predicate(rational,1,'Type check for a rational number',10973,10990).
406 predicate(rationalize,1,'Convert to rational number',10992,11006).
407 predicate(float_fractional_part,1,'Fractional part of a float',11008,11013).
408 predicate(float_integer_part,1,'Integer part of a float',11015,11018).
409 predicate(truncate,1,'Truncate float to integer',11020,11024).
410 predicate(floor,1,'Largest integer below argument',11026,11029).
411 predicate(ceiling,1,'Smallest integer larger than arg',11031,11034).
412 predicate(ceil,1,'Smallest integer larger than arg',11036,11038).
413 predicate(>>,2,'Calls a copy of Lambda.',11040,11045).
414 predicate(<<,2,'Bitwise left shift',11047,11049).
415 predicate(\/,2,'Bitwise or',11051,11053).
416 predicate(/\,2,'Bitwise and',11055,11057).
417 predicate(xor,2,'Bitwise exclusive or',11059,11061).
418 predicate(\,1,'Bitwise negation',11063,11066).
419 predicate(sqrt,1,'Square root',11068,11070).
420 predicate(sin,1,'Sine',11072,11074).
421 predicate(cos,1,'Cosine',11076,11078).
422 predicate(tan,1,'Tangent',11080,11082).
423 predicate(asin,1,'Inverse (arc) sine',11084,11086).
424 predicate(acos,1,'Inverse (arc) cosine',11088,11090).
425 predicate(atan,1,'Inverse hyperbolic sine',11092,11094).
426 predicate(atan2,2,'Rectangular to polar conversion',11096,11104).
427 predicate(atan,2,'Rectangular to polar conversion',11106,11108).
428 predicate(sinh,1,'Hyperbolic sine',11110,11113).
429 predicate(cosh,1,'Hyperbolic cosine',11115,11118).
430 predicate(tanh,1,'Hyperbolic tangent',11120,11123).
431 predicate(asinh,1,'Inverse (arc) sine',11125,11127).
432 predicate(acosh,1,'Inverse hyperbolic cosine',11129,11131).
433 predicate(atanh,1,'Inverse hyperbolic tangent',11133,11135).
434 predicate(log,1,'Natural logarithm',11137,11139).
435 predicate(log10,1,'10 base logarithm',11141,11143).
436 predicate(exp,1,'Exponent (base $e$)',11145,11147).
437 predicate(**,2,'Power function',11149,11164).
438 predicate(^,2,'Existential quantification (bagof/3, setof/3)',11166,11186).
439 predicate(powm,3,'Integer exponent and modulo',11188,11195).
440 predicate(lgamma,1,'Log of gamma function',11197,11200).
441 predicate(erf,1,'Gauss error function',11202,11208).
442 predicate(erfc,1,'Complementary error function',11210,11213).
443 predicate(pi,0,'Mathematical constant',11215,11217).
444 predicate(e,0,'Mathematical constant',11219,11221).
445 predicate(epsilon,0,'Floating point precision',11223,11226).
446 predicate(inf,0,'Positive infinity',11228,11231).
447 predicate(nan,0,'Not a Number (NaN)',11233,11235).
448 predicate(cputime,0,'Get CPU time',11237,11241).
449 predicate(eval,1,'Evaluate term as expression',11243,11258).
450 predicate(msb,1,'Most significant bit',11260,11265).
451 predicate(lsb,1,'Least significant bit',11267,11272).
452 predicate(popcount,1,'Count 1s in a bitvector',11274,11277).
453 predicate(getbit,2,'Get bit at index from large integer',11279,11286).
454 predicate(set_random,1,'Control random number generation',11291,11313).
455 predicate(random_property,1,'Query properties of random generation',11315,11327).
456 predicate(current_arithmetic_function,1,'Examine evaluable functions',11329,11336).
457 predicate(is_list,1,'Type check for a list',11345,11360).
458 predicate(memberchk,2,'Deterministic member/2',11362,11370).
459 predicate(length,2,'Length of a list',11372,11389).
460 predicate(sort,2,'Sort elements in a list',11391,11404).
461 predicate(sort,4,'Sort elements in a list',11406,11457).
462 predicate(msort,2,'Sort, do not remove duplicates',11459,11462).
463 predicate(keysort,2,'Sort, using a key',11464,11486).
464 predicate(predsort,3,'Sort, using a predicate to determine the order',11488,11493).
465 predicate(findall,3,'Find all solutions to a goal',11498,11505).
466 predicate(findall,4,'Difference list version of findall/3',11507,11515).
467 predicate(findnsols,4,'Find first solutions',11517,11518).
468 predicate(findnsols,5,'Difference list version of findnsols/4',11520,11553).
469 predicate(bagof,3,'Find all solutions to a goal',11555,11587).
470 predicate(setof,3,'Find all unique solutions to a goal',11589,11592).
471 predicate(forall,2,'Prove goal for all solutions of another goal',11597,11638).
472 predicate(writef,1,'Formatted write',11653,11655).
473 predicate(writef,2,'Formatted write on stream',11657,11716).
474 predicate(swritef,3,'Formatted write on a string',11718,11726).
475 predicate(swritef,2,'Formatted write on a string',11728,11730).
476 predicate(format,1,'Formatted output',11738,11741).
477 predicate(format,2,'Formatted output with arguments',11743,11911).
478 predicate(format,3,'Formatted output on a stream',11913,11923).
479 predicate(format_predicate,2,'Program format/[1,2]',11928,11957).
480 predicate(current_format_predicate,2,'Enumerate user-defined format codes',11959,11962).
481 predicate(b_setval,2,'Assign backtrackable global variable',12003,12009).
482 predicate(b_getval,2,'Fetch backtrackable global variable',12011,12018).
483 predicate(nb_setval,2,'Assign non-backtrackable global variable',12020,12024).
484 predicate(nb_getval,2,'Fetch non-backtrackable global variable',12026,12036).
485 predicate(nb_linkval,2,'Assign non-backtrackable global variable',12038,12059).
486 predicate(nb_current,2,'Enumerate non-backtrackable global variables',12061,12066).
487 predicate(nb_delete,1,'Delete a non-backtrackable global variable',12068,12071).
488 predicate(tty_get_capability,3,'Get terminal parameter',12096,12104).
489 predicate(tty_goto,2,'Goto position on screen',12106,12110).
490 predicate(tty_put,2,'Write control string to terminal',12112,12118).
491 predicate(tty_size,2,'Get row/column size of the terminal',12120,12136).
492 predicate(shell,1,'Execute OS command',12147,12149).
493 predicate(shell,2,'Execute OS command',12151,12180).
494 predicate(getenv,2,'Get shell environment variable',12182,12186).
495 predicate(setenv,2,'Set shell environment variable',12188,12197).
496 predicate(unsetenv,1,'Delete shell environment variable',12199,12203).
497 predicate(setlocale,3,'Set/query C-library regional information',12205,12217).
498 predicate(unix,1,'OS interaction',12219,12250).
499 predicate(win_exec,2,'Win32: spawn Windows task',12261,12268).
500 predicate(win_shell,3,'Win32: open document through Shell',12270,12279).
501 predicate(win_shell,2,'Win32: open document through Shell',12281,12283).
502 predicate(win_registry_get_value,3,'Win32: get registry value',12285,12306).
503 predicate(win_folder,2,'Win32: get special folder by CSIDL',12308,12321).
504 predicate(win_add_dll_directory,1,'Add directory to DLL search path',12323,12332).
505 predicate(win_add_dll_directory,2,'Add directory to DLL search path',12334,12357).
506 predicate(win_remove_dll_directory,1,'Remove directory from DLL search path',12359,12362).
507 predicate(get_time,1,'Get current time',12436,12439).
508 predicate(stamp_date_time,3,'Convert time-stamp to date structure',12441,12447).
509 predicate(date_time_stamp,2,'Convert date structure to time-stamp',12449,12500).
510 predicate(date_time_value,3,'Extract info from a date structure',12502,12519).
511 predicate(format_time,3,'C strftime() like date/time formatter',12521,12683).
512 predicate(format_time,4,'date/time formatter with explicit locale',12685,12694).
513 predicate(parse_time,2,'Parse text to a time-stamp',12696,12698).
514 predicate(parse_time,3,'Parse text to a time-stamp',12700,12720).
515 predicate(day_of_the_week,2,'Determine ordinal-day from date',12722,12727).
516 predicate(window_title,2,'Win32: change title of window',12738,12741).
517 predicate(win_window_pos,1,'Win32: change size and position of window',12743,12766).
518 predicate(win_has_menu,0,'Win32: true if console menu is available',12768,12770).
519 predicate(win_insert_menu,2,'swipl-win.exe: add menu',12772,12783).
520 predicate(win_insert_menu_item,4,'swipl-win.exe: add item to menu',12785,12789).
521 predicate(access_file,2,'Check access permissions of a file',12794,12814).
522 predicate(exists_file,1,'Check existence of file',12816,12820).
523 predicate(file_directory_name,2,'Get directory part of path',12822,12842).
524 predicate(file_base_name,2,'Get file part of path',12844,12849).
525 predicate(same_file,2,'Succeeds if arguments refer to same file',12851,12860).
526 predicate(exists_directory,1,'Check existence of directory',12862,12865).
527 predicate(delete_file,1,'Remove a file from the file system',12867,12869).
528 predicate(rename_file,2,'Change name of file',12871,12877).
529 predicate(size_file,2,'Get size of a file in characters',12879,12881).
530 predicate(time_file,2,'Get last modification time of file',12883,12887).
531 predicate(absolute_file_name,2,'Get absolute path name',12889,12897).
532 predicate(absolute_file_name,3,'Get absolute path name with options',12899,12960).
533 predicate(is_absolute_file_name,1,'True if arg defines an absolute path',12962,12968).
534 predicate(file_name_extension,3,'Add, remove or test file extensions',12970,12978).
535 predicate(directory_files,2,'Get entries of a directory/folder',12980,12986).
536 predicate(expand_file_name,2,'Wildcard expansion of file names',12988,13005).
537 predicate(prolog_to_os_filename,2,'Convert between Prolog and OS filenames',13007,13013).
538 predicate(read_link,3,'Read a symbolic link',13015,13021).
539 predicate(tmp_file,2,'Create a temporary filename',13023,13033).
540 predicate(tmp_file_stream,3,'Create a temporary file and open it',13035,13062).
541 predicate(make_directory,1,'Create a folder on the file system',13064,13068).
542 predicate(delete_directory,1,'Remove a folder from the file system',13070,13074).
543 predicate(working_directory,2,'Query/change CWD',13076,13082).
544 predicate(chdir,1,'Compatibility: change working directory',13084,13086).
545 predicate(break,0,'Start interactive top level',13091,13108).
546 predicate(abort,0,'Abort execution, return to top level',13110,13127).
547 predicate(halt,0,'Exit from Prolog',13129,13132).
548 predicate(halt,1,'Exit from Prolog with status',13134,13163).
549 predicate(prolog,0,'Run interactive top level',13165,13174).
550 predicate(expand_query,4,'Expanded entered query',13176,13184).
551 predicate(expand_answer,2,'Expand answer of query',13186,13191).
552 predicate(protocol,1,'Make a log of the user interaction',13200,13203).
553 predicate(protocola,1,'Append log of the user interaction to file',13205,13208).
554 predicate(noprotocol,0,'Disable logging of user interaction',13210,13213).
555 predicate(protocolling,1,'On what file is user interaction logged',13215,13218).
556 predicate(trace,0,'Start the tracer',13229,13233).
557 predicate(tracing,0,'Query status of the tracer',13235,13238).
558 predicate(notrace,0,'Stop tracing',13240,13242).
559 predicate(guitracer,0,'Install hooks for the graphical debugger',13244,13249).
560 predicate(noguitracer,0,'Disable the graphical debugger',13251,13253).
561 predicate(trace,1,'Set trace point on predicate',13255,13257).
562 predicate(trace,2,'Set/Clear trace point on ports',13259,13279).
563 predicate(notrace,1,'Do not debug argument goal',13281,13286).
564 predicate(debug,0,'Test for debugging mode',13288,13301).
565 predicate(nodebug,0,'Disable debugging',13303,13306).
566 predicate(debugging,0,'Show debugger status',13308,13311).
567 predicate(spy,1,'Force tracer on specified predicate',13313,13316).
568 predicate(nospy,1,'Remove spy point',13318,13321).
569 predicate(nospyall,0,'Remove all spy points',13323,13325).
570 predicate(leash,1,'Change ports visited by the tracer',13327,13335).
571 predicate(visible,1,'Ports that are visible in the tracer',13337,13340).
572 predicate(unknown,2,'Trap undefined predicates',13342,13347).
573 predicate(style_check,1,'Change level of warnings',13349,13423).
574 predicate(statistics,2,'Obtain collected statistics',13428,13524).
575 predicate(statistics,0,'Show execution statistics',13526,13528).
576 predicate(time,1,'Determine time needed to execute goal',13530,13538).
577 predicate(profile,1,'Obtain execution statistics',13556,13560).
578 predicate(profile,2,'Obtain execution statistics',13562,13575).
579 predicate(show_profile,1,'Show results of the profiler',13577,13589).
580 predicate(profiler,2,'Obtain/change status of the profiler',13591,13605).
581 predicate(reset_profiler,0,'Clear statistics obtained by the profiler',13607,13609).
582 predicate(noprofile,1,'Hide (meta-) predicate for the profiler',13611,13617).
583 predicate(garbage_collect,0,'Invoke the garbage collector',13720,13727).
584 predicate(garbage_collect_atoms,0,'Invoke the atom garbage collector',13729,13737).
585 predicate(garbage_collect_clauses,0,'Invoke clause garbage collector',13739,13764).
586 predicate(trim_stacks,0,'Release unused memory resources',13774,13792).
587 predicate(set_prolog_stack,2,'Modify stack characteristics',13794,13842).
588 predicate(prolog_stack_property,2,'Query properties of the stacks',13844,13847).
589 predicate(open_dde_conversation,3,'Win32: Open DDE channel',13893,13898).
590 predicate(close_dde_conversation,1,'Win32: Close DDE channel',13900,13905).
591 predicate(dde_request,3,'Win32: Make a DDE request',13907,13911).
592 predicate(dde_execute,2,'Win32: Execute command on DDE server',13913,13917).
593 predicate(dde_poke,3,'Win32: POKE operation on DDE server',13919,13922).
594 predicate(dde_register_service,2,'Win32: Become a DDE server',13933,13970).
595 predicate(dde_unregister_service,1,'Win32: Terminate a DDE service',13972,13975).
596 predicate(dde_current_service,2,'Win32: Examine DDE services provided',13977,13979).
597 predicate(dde_current_connection,2,'Win32: Examine open DDE connections',13981,13983).
598 predicate(dwim_match,2,'Atoms match in ``Do What I Mean\'\' sense',13988,14006).
599 predicate(dwim_match,3,'Atoms match in ``Do What I Mean\'\' sense',14008,14013).
600 predicate(wildcard_match,2,'Csh(1) style wildcard match',14015,14031).
601 predicate(sleep,1,'Suspend execution for specified time',14033,14043).
602 predicate(atom_string,2,'Conversion between atom and string',14188,14192).
603 predicate(number_string,2,'Convert between number and string',14194,14212).
604 predicate(term_string,2,'Read/write a term from/to a string',14214,14219).
605 predicate(term_string,3,'Read/write a term from/to a string',14221,14230).
606 predicate(string_chars,2,'Conversion between string and list of characters',14232,14236).
607 predicate(string_codes,2,'Conversion between string and list of character codes',14238,14241).
608 predicate(text_to_string,2,'Convert arbitrary text to a string',14243,14247).
609 predicate(string_length,2,'Determine length of a string',14249,14253).
610 predicate(string_code,3,'Get or find a character code in a string',14255,14262).
611 predicate(get_string_code,3,'Get character code at index in string',14264,14269).
612 predicate(string_concat,3,'atom_concat/3 for strings',14271,14280).
613 predicate(split_string,4,'Break a string into substrings',14282,14314).
614 predicate(sub_string,5,'Take a substring from a string',14316,14333).
615 predicate(atomics_to_string,2,'Concatenate list of inputs to a string',14335,14340).
616 predicate(atomics_to_string,3,'Concatenate list of inputs to a string',14342,14351).
617 predicate(string_upper,2,'Case conversion to upper case',14353,14355).
618 predicate(read_string,3,'Read a number of characters into a string',14361,14365).
619 predicate(read_string,5,'Read string upto a delimiter',14367,14396).
620 predicate(open_string,2,'Open a string as a stream',14398,14402).
621 predicate(list_strings,0,'Help porting to version 7',14446,14478).
622 predicate(string_predicate,1,'Hook (check) Predicate contains strings',14480,14493).
623 predicate(valid_string_goal,1,'Hook (check) Goal handles strings',14495,14507).
624 predicate('.',3,'',14824,14831).
625 predicate(get,1,'Read first non-blank character',14878,14891).
626 predicate(put,1,'Write a character',14893,14896).
627 predicate(put,2,'Write a character on a stream',14898,14922).
628 predicate(is_dict,1,'Type check for a dict',14930,14932).
629 predicate(is_dict,2,'Type check for a dict in a class',14934,14936).
630 predicate(get_dict,3,'Get the value associated to a key from a dict',14938,14948).
631 predicate(get_dict,5,'Replace existing value in a dict',14950,14962).
632 predicate(dict_create,3,'Create a dict from data',14964,14970).
633 predicate(dict_pairs,3,'Convert between dict and list of pairs',14972,14975).
634 predicate(put_dict,3,'Add/replace multiple keys in a dict',14977,14993).
635 predicate(put_dict,4,'Add/replace a single key in a dict',14995,15011).
636 predicate(del_dict,4,'Delete Key-Value pair from a dict',15013,15016).
637 predicate(:<,2,'Select keys from a dict',15018,15036).
638 predicate(select_dict,3,'Select matching attributes from a dict',15038,15054).
639 predicate(>:<,2,'Partial dict unification',15056,15070).
640 predicate(b_set_dict,3,'Destructive assignment on a dict',15096,15101).
641 predicate(nb_set_dict,3,'Non-backtrackable assignment to dict',15103,15108).
642 predicate(nb_link_dict,3,'Non-backtrackable assignment to dict',15110,15117).
643 predicate(module,2,'Declare a module',15474,15487).
644 predicate(module,3,'Declare a module with language options',15489,15498).
645 predicate(use_module,1,'Import a module',15514,15558).
646 predicate(use_module,2,'Import predicates from a module',15560,15593).
647 predicate(meta_predicate,1,'Declare access to other predicates',15646,15723).
648 predicate(@,2,'Call using calling context',15767,15782).
649 predicate(module,1,'Query/set current type-in module',15800,15812).
650 predicate(reexport,1,'Load files and re-export the imported predicates',15835,15839).
651 predicate(reexport,2,'Load predicates from a file and re-export it',15841,15845).
652 predicate(import_module,2,'Query import modules',15900,15905).
653 predicate(default_module,2,'Query module inheritance',15907,15912).
654 predicate(add_import_module,3,'Add module to the auto-import list',15914,15918).
655 predicate(delete_import_module,2,'Remove module from import list',15920,15927).
656 predicate(export,1,'Export a predicate from a module',15956,15962).
657 predicate(import,1,'Import a predicate from a module',15964,15971).
658 predicate(module_transparent,1,'Indicate module based meta-predicate',16082,16086).
659 predicate(context_module,1,'Get context module of current goal',16088,16091).
660 predicate(strip_module,3,'Extract context module and term',16093,16099).
661 predicate(current_module,1,'Examine existing modules',16107,16112).
662 predicate(module_property,2,'Find properties of a module',16114,16170).
663 predicate(set_module,1,'Set properties of a module',16172,16191).
664 predicate(attvar,1,'Type test for attributed variable',16452,16456).
665 predicate(put_attr,3,'Put attribute on a variable',16458,16466).
666 predicate(get_attr,3,'Fetch named attribute from a variable',16468,16473).
667 predicate(del_attr,2,'Delete attribute from variable',16475,16481).
668 predicate(attr_unify_hook,2,'Attributed variable unification hook',16490,16510).
669 predicate(attribute_goals,3,'Project attributes to goals',16512,16546).
670 predicate(project_attributes,2,'Project constraints to query variables',16548,16557).
671 predicate(attr_portray_hook,2,'Attributed variable print hook',16559,16567).
672 predicate(copy_term,3,'Copy a term and obtain attribute-goals',16572,16587).
673 predicate(copy_term_nat,2,'Make a copy of a term without attributes',16589,16592).
674 predicate(term_attvars,2,'Find attributed variables in a term',16594,16601).
675 predicate(get_attrs,2,'Fetch all attributes of a variable',16611,16615).
676 predicate(put_attrs,2,'Set/replace all attributes on a variable',16617,16620).
677 predicate(del_attrs,1,'Delete all attributes from variable',16622,16625).
678 predicate(dif,2,'Constrain two terms to be different',16685,16701).
679 predicate(freeze,2,'Delay execution until variable is bound',16703,16710).
680 predicate(frozen,2,'Query delayed goals on var',16712,16715).
681 predicate(when,2,'Execute goal when condition becomes true',16717,16726).
682 predicate(call_residue_vars,2,'Find residual attributed variables',16728,16743).
683 predicate(chr_option,2,'Specify CHR compilation options',16935,16973).
684 predicate(chr_constraint,1,'CHR Constraint declaration',16988,17063).
685 predicate(chr_type,1,'CHR Type declaration',17065,17194).
686 predicate(chr_trace,0,'Start CHR tracer',17331,17335).
687 predicate(chr_notrace,0,'Stop CHR tracer',17337,17341).
688 predicate(chr_leash,1,'Define CHR leashed ports',17343,17350).
689 predicate(chr_show_store,1,'List suspended CHR constraints',17352,17359).
690 predicate(find_chr_constraint,1,'Returns a constraint from the store',17361,17364).
691 predicate(thread_create,2,'Create a new Prolog task',17665,17667).
692 predicate(thread_create,3,'Create a new Prolog task',17669,17774).
693 predicate(thread_self,1,'Get identifier of current thread',17776,17779).
694 predicate(thread_join,1,'Wait for Prolog task-completion',17781,17785).
695 predicate(thread_join,2,'Wait for Prolog task-completion',17787,17813).
696 predicate(thread_detach,1,'Make thread cleanup after completion',17815,17827).
697 predicate(thread_exit,1,'Terminate Prolog task with value',17829,17840).
698 predicate(thread_initialization,1,'Run action at start of thread',17842,17851).
699 predicate(thread_at_exit,1,'Register goal to be called at exit',17853,17868).
700 predicate(thread_setconcurrency,2,'Number of active threads',17870,17877).
701 predicate(is_thread,1,'Type check for an thread handle',17892,17894).
702 predicate(thread_property,2,'Examine Prolog threads',17896,17963).
703 predicate(thread_statistics,3,'Get statistics of another thread',17965,17970).
704 predicate(mutex_statistics,0,'Print statistics on mutex usage',17972,17979).
705 predicate(thread_send_message,2,'Send message to another thread',18000,18016).
706 predicate(thread_send_message,3,'Send message to another thread',18018,18045).
707 predicate(thread_get_message,1,'Wait for message',18047,18067).
708 predicate(thread_peek_message,1,'Test for message',18069,18076).
709 predicate(message_queue_create,1,'Create queue for thread communication',18078,18083).
710 predicate(message_queue_create,2,'Create queue for thread communication',18085,18101).
711 predicate(message_queue_destroy,1,'Destroy queue for thread communication',18103,18108).
712 predicate(thread_get_message,2,'Wait for message in a queue',18110,18116).
713 predicate(thread_get_message,3,'Wait for message in a queue',18118,18141).
714 predicate(thread_peek_message,2,'Test for message in a queue',18143,18148).
715 predicate(message_queue_property,2,'Query message queue properties',18150,18209).
716 predicate(thread_signal,2,'Execute goal in another thread',18224,18242).
717 predicate(thread_local,1,'Declare thread-specific clauses for a predicate',18262,18291).
718 predicate(mutex_create,1,'Create a thread-synchronisation device',18337,18341).
719 predicate(mutex_create,2,'Create a thread-synchronisation device',18343,18349).
720 predicate(mutex_destroy,1,'Destroy a mutex',18351,18357).
721 predicate(with_mutex,2,'Run goal while holding mutex',18359,18370).
722 predicate(mutex_lock,1,'Become owner of a mutex',18372,18390).
723 predicate(mutex_trylock,1,'Become owner of a mutex (non-blocking)',18392,18395).
724 predicate(mutex_unlock,1,'Release ownership of mutex',18397,18401).
725 predicate(mutex_unlock_all,0,'Release ownership of all mutexes',18403,18407).
726 predicate(mutex_property,2,'Query mutex properties',18409,18423).
727 predicate(threads,0,'List running threads',18432,18434).
728 predicate(join_threads,0,'Join all terminated threads interactively',18436,18443).
729 predicate(interactor,0,'Start new thread with console and top level',18445,18449).
730 predicate(attach_console,0,'Attach I/O console to thread',18463,18478).
731 predicate(tdebug,1,'Switch a thread into debug mode',18480,18488).
732 predicate(tdebug,0,'Switch all threads into debug mode',18490,18492).
733 predicate(tnodebug,1,'Switch off debug mode in a thread',18494,18496).
734 predicate(tnodebug,0,'Switch off debug mode in all threads',18498,18500).
735 predicate(tspy,2,'Set spy point and enable debugging in a thread',18502,18508).
736 predicate(tspy,1,'Set spy point and enable debugging in all threads',18510,18515).
737 predicate(tprofile,1,'Profile a thread for some period',18526,18530).
738 predicate(in_pce_thread,1,'Run goal in XPCE thread',18726,18733).
739 predicate(in_pce_thread_sync,1,'Run goal in XPCE thread',18735,18748).
740 predicate(pce_dispatch,1,'Run XPCE GUI in separate thread',18750,18757).
741 predicate(engine_create,3,'Create an interactor',19047,19048).
742 predicate(engine_create,4,'Create an interactor',19050,19073).
743 predicate(engine_destroy,1,'Destroy an interactor',19075,19077).
744 predicate(engine_next,2,'Ask interactor for next term',19079,19086).
745 predicate(engine_next_reified,2,'Ask interactor for next term',19088,19103).
746 predicate(engine_post,2,'Send term to an interactor',19105,19109).
747 predicate(engine_post,3,'Send term to an interactor and wait for reply',19111,19113).
748 predicate(engine_yield,1,'Make term available to caller',19115,19123).
749 predicate(engine_fetch,1,'Get term from caller',19125,19129).
750 predicate(engine_self,1,'Get handle to running interactor',19131,19134).
751 predicate(is_engine,1,'Type check for an engine handle',19136,19139).
752 predicate(current_engine,1,'Enumerate known engines',19141,19143).
753 predicate(load_foreign_library,1,'library(shlib) Load shared library (.so file)',19286,19287).
754 predicate(load_foreign_library,2,'library(shlib) Load shared library (.so file)',19289,19315).
755 predicate(use_foreign_library,1,'Load DLL/shared object (directive)',19317,19318).
756 predicate(use_foreign_library,2,'Load DLL/shared object (directive)',19320,19333).
757 predicate(unload_foreign_library,1,'library(shlib) Detach shared library (.so file)',19335,19336).
758 predicate(unload_foreign_library,2,'library(shlib) Detach shared library (.so file)',19338,19343).
759 predicate(current_foreign_library,2,'library(shlib) Examine loaded shared libraries (.so files)',19345,19347).
760 predicate(reload_foreign_libraries,0,'Reload DLLs/shared objects',19349,19352).
761 predicate(open_shared_object,2,'UNIX: Open shared library (.so file)',19364,19373).
762 predicate(open_shared_object,3,'UNIX: Open shared library (.so file)',19375,19384).
763 predicate(close_shared_object,1,'UNIX: Close shared library (.so file)',19386,19388).
764 predicate(call_shared_object_function,2,'UNIX: Call C-function in shared (.so) file',19390,19395).
765 predicate(prolog_debug,1,'',23360,23361).
766 predicate(prolog_nodebug,1,'',23363,23375).
767 predicate(qsave_program,2,'Create runtime application',23552,23617).
768 predicate(qsave_program,1,'Create runtime application',23619,23621).
769 predicate(autoload,0,'Autoload all predicates now',23623,23672).
770 predicate(volatile,1,'Predicates that are not saved',23674,23679).
771 predicate(resource,3,'Declare a program resource',23803,23837).
772 predicate(open_resource,3,'Open a program resource as a stream',23839,23858).
773 predicate(aggregate,3,'Aggregate bindings in Goal according to Template.',24050,24053).
774 predicate(aggregate,4,'Aggregate bindings in Goal according to Template.',24055,24058).
775 predicate(aggregate_all,3,'Aggregate bindings in Goal according to Template.',24060,24066).
776 predicate(aggregate_all,4,'Aggregate bindings in Goal according to Template.',24068,24073).
777 predicate(foreach,2,'True if conjunction of results is true.',24075,24097).
778 predicate(free_variables,4,'Find free variables in bagof/setof template.',24099,24123).
779 predicate(safe_meta,2,'',24125,24128).
780 predicate(include,3,'Filter elements for which Goal succeeds.',24143,24149).
781 predicate(exclude,3,'Filter elements for which Goal fails.',24151,24154).
782 predicate(partition,4,'Filter elements of List according to Pred.',24156,24160).
783 predicate(partition,5,'Filter List according to Pred in three sets.',24162,24167).
784 predicate(maplist,2,'True if Goal can successfully be applied on all elements of List.',24169,24173).
785 predicate(maplist,3,'As maplist/2, operating on pairs of elements from two lists.',24175,24177).
786 predicate(maplist,4,'As maplist/2, operating on triples of elements from three lists.',24179,24181).
787 predicate(maplist,5,'As maplist/2, operating on quadruples of elements from four lists.',24183,24185).
788 predicate(convlist,3,'Similar to maplist/3, but elements for which call(Goal, ElemIn, _) fails are omitted from ListOut.',24187,24199).
789 predicate(foldl,4,'Fold a list, using arguments of the list as left argument.',24201,24202).
790 predicate(foldl,5,'Fold a list, using arguments of the list as left argument.',24204,24205).
791 predicate(foldl,6,'Fold a list, using arguments of the list as left argument.',24207,24208).
792 predicate(foldl,7,'Fold a list, using arguments of the list as left argument.',24210,24220).
793 predicate(scanl,4,'Left scan of list.',24222,24223).
794 predicate(scanl,5,'Left scan of list.',24225,24226).
795 predicate(scanl,6,'Left scan of list.',24228,24229).
796 predicate(scanl,7,'Left scan of list.',24231,24242).
797 predicate(empty_assoc,1,'Create/test empty association tree',24288,24290).
798 predicate(list_to_assoc,2,'Create association tree from list',24292,24298).
799 predicate(ord_list_to_assoc,2,'Convert ordered list to assoc',24300,24306).
800 predicate(get_assoc,3,'Fetch key from association tree',24313,24318).
801 predicate(get_assoc,5,'Fetch key from association tree',24320,24322).
802 predicate(max_assoc,3,'Highest key in association tree',24324,24326).
803 predicate(min_assoc,3,'Lowest key in association tree',24328,24330).
804 predicate(gen_assoc,3,'Enumerate members of association tree',24332,24337).
805 predicate(put_assoc,4,'Add Key-Value to association tree',24344,24347).
806 predicate(del_assoc,4,'',24349,24352).
807 predicate(del_min_assoc,4,'',24354,24358).
808 predicate(del_max_assoc,4,'',24360,24364).
809 predicate(assoc_to_list,2,'Convert association tree to list',24371,24374).
810 predicate(assoc_to_keys,2,'Translate assoc into a key list',24376,24379).
811 predicate(assoc_to_values,2,'Translate assoc into a value list',24381,24385).
812 predicate(is_assoc,1,'Verify association list',24393,24398).
813 predicate(map_assoc,2,'Map association tree',24400,24402).
814 predicate(map_assoc,3,'Map association tree',24404,24407).
815 predicate(broadcast,1,'Send event notification',24431,24437).
816 predicate(broadcast_request,1,'Request all agents',24439,24453).
817 predicate(listen,2,'Listen to event notifications',24455,24467).
818 predicate(listen,3,'Listen to event notifications',24469,24504).
819 predicate(unlisten,1,'Stop listening to event notifications',24506,24508).
820 predicate(unlisten,2,'Stop listening to event notifications',24510,24513).
821 predicate(unlisten,3,'Stop listening to event notifications',24515,24518).
822 predicate(listening,3,'Who is listening to event notifications?',24520,24523).
823 predicate(format_to_chars,3,'Use format/2 to write to a list of character codes.',24538,24540).
824 predicate(format_to_chars,4,'Use format/2 to write to a difference list of character codes.',24542,24544).
825 predicate(write_to_chars,2,'Write a term to a code list.',24546,24549).
826 predicate(write_to_chars,3,'Write a term to a code list.',24551,24554).
827 predicate(atom_to_chars,2,'Convert Atom into a list of character codes.',24556,24560).
828 predicate(atom_to_chars,3,'Convert Atom into a difference list of character codes.',24562,24564).
829 predicate(number_to_chars,2,'Convert Atom into a list of character codes.',24566,24570).
830 predicate(number_to_chars,3,'Convert Number into a difference list of character codes.',24572,24574).
831 predicate(read_from_chars,2,'Read Codes into Term.',24576,24581).
832 predicate(read_term_from_chars,3,'Read Codes into Term.',24583,24587).
833 predicate(open_chars_stream,2,'Open Codes as an input stream.',24589,24593).
834 predicate(with_output_to_chars,2,'Run Goal as with once/1.',24595,24598).
835 predicate(with_output_to_chars,3,'Run Goal as with once/1.',24600,24603).
836 predicate(with_output_to_chars,4,'Same as with_output_to_chars/3 using an explicit stream.',24605,24609).
837 predicate(check,0,'Run all consistency checks defined by checker/2.',24626,24641).
838 predicate(list_undefined,0,'Report undefined predicates.',24643,24644).
839 predicate(list_undefined,1,'Report undefined predicates.',24646,24659).
840 predicate(list_autoload,0,'Report predicates that may be auto-loaded.',24661,24670).
841 predicate(list_redefined,0,'Lists predicates that are defined in the global module =user= as well as in a normal module; that is, predicates for which the local definition overrules the global default definition.',24672,24676).
842 predicate(list_void_declarations,0,'List predicates that have declared attributes, but no clauses.',24678,24680).
843 predicate(list_trivial_fails,0,'List goals that trivially fail because there is no matching clause.',24682,24683).
844 predicate(list_trivial_fails,1,'List goals that trivially fail because there is no matching clause.',24685,24693).
845 predicate(trivial_fail_goal,1,'Multifile hook that tells list_trivial_fails/0 to accept Goal as valid.',24695,24698).
846 predicate(list_strings,0,'Help porting to version 7',24700,24701).
847 predicate(list_strings,1,'List strings that appear in clauses.',24703,24714).
848 predicate(string_predicate,1,'Hook (check) Predicate contains strings',24716,24719).
849 predicate(valid_string_goal,1,'Hook (check) Goal handles strings',24721,24725).
850 predicate(checker,2,'Register code validation routines.',24727,24744).
851 predicate(sat,1,'True iff Expr is a satisfiable Boolean expression.',25049,25051).
852 predicate(taut,2,'Tautology check.',25053,25057).
853 predicate(labeling,1,'Enumerate concrete solutions.',25059,25062).
854 predicate(sat_count,2,'Count the number of admissible assignments.',25064,25090).
855 predicate(weighted_maximum,3,'Enumerate weighted optima over admissible assignments.',25092,25110).
856 predicate(random_labeling,2,'Select a single random solution.',25112,25117).
857 predicate(#=,2,'The arithmetic expression X equals Y.',25927,25932).
858 predicate(#\=,2,'The arithmetic expressions X and Y evaluate to distinct integers.',25934,25939).
859 predicate(#>=,2,'Same as Y Scle{} X.',25941,25945).
860 predicate(#=<,2,'The arithmetic expression X is less than or equal to Y.',25947,25952).
861 predicate(#>,2,'Same as Y Sclt{} X.',25954,25958).
862 predicate(#<,2,'The arithmetic expression X is less than Y.',25960,25979).
863 predicate(in,2,'Var is an element of Domain.',25988,26002).
864 predicate(ins,2,'The variables in the list Vars are elements of Domain.',26004,26007).
865 predicate(indomain,1,'Bind Var to all feasible values of its domain on backtracking.',26016,26019).
866 predicate(label,1,'Equivalent to labeling([], Vars).',26021,26023).
867 predicate(labeling,2,'Assign a value to each variable in Vars.',26025,26111).
868 predicate(all_distinct,1,'True iff Vars are pairwise distinct.',26121,26132).
869 predicate(all_different,1,'Like all_distinct/1, but with weaker propagation.',26134,26138).
870 predicate(sum,3,'The sum of elements of the list Vars is in relation Rel to Expr.',26140,26151).
871 predicate(scalar_product,4,'True iff the scalar product of Cs and Vs is in relation Rel to Expr.',26153,26157).
872 predicate(lex_chain,1,'Lists are lexicographically non-decreasing.',26159,26161).
873 predicate(tuples_in,2,'True iff all Tuples are elements of Relation.',26163,26206).
874 predicate(serialized,2,'Describes a set of non-overlapping tasks.',26208,26227).
875 predicate(element,3,'The N-th element of the list of finite domain variables Vs is V.',26229,26232).
876 predicate(global_cardinality,2,'Global Cardinality constraint.',26234,26246).
877 predicate(global_cardinality,3,'Global Cardinality constraint.',26248,26265).
878 predicate(circuit,1,'True iff the list Vs of finite domain variables induces a Hamiltonian circuit.',26267,26281).
879 predicate(cumulative,1,'Equivalent to cumulative(Tasks, [limit(1)]).',26283,26285).
880 predicate(cumulative,2,'Schedule with a limited resource.',26287,26320).
881 predicate(disjoint2,1,'True iff Rectangles are not overlapping.',26322,26328).
882 predicate(automaton,3,'Describes a list of finite domain variables with a finite automaton.',26330,26352).
883 predicate(automaton,8,'Describes a list of finite domain variables with a finite automaton.',26354,26420).
884 predicate(chain,2,'Zs form a chain with respect to Relation.',26422,26433).
885 predicate(#\,1,'Q does _not_ hold.',26443,26452).
886 predicate(#<==>,2,'P and Q are equivalent.',26454,26493).
887 predicate(#==>,2,'P implies Q.',26495,26497).
888 predicate(#<==,2,'Q implies P.',26499,26501).
889 predicate(#/\,2,'P and Q hold.',26503,26505).
890 predicate(#\/,2,'P or Q holds.',26507,26521).
891 predicate(#\,2,'Either P holds or Q holds, but not both.',26523,26526).
892 predicate(zcompare,3,'Analogous to compare/3, with finite domain variables A and B.',26528,26582).
893 predicate(fd_var,1,'True iff Var is a CLP(FD) variable.',26593,26595).
894 predicate(fd_inf,2,'Inf is the infimum of the current domain of Var.',26597,26599).
895 predicate(fd_sup,2,'Sup is the supremum of the current domain of Var.',26601,26603).
896 predicate(fd_size,2,'Reflect the current size of a domain.',26605,26609).
897 predicate(fd_dom,2,'Dom is the current domain (see in/2) of Var.',26611,26639).
898 predicate({},1,'DCG escape; constraints',26701,26703).
899 predicate(entailed,1,'Check if constraint is entailed',26705,26709).
900 predicate(inf,2,'Find the infimum of an expression',26711,26715).
901 predicate(sup,2,'Find the supremum of an expression',26717,26721).
902 predicate(minimize,1,'Minimizes an expression',26723,26727).
903 predicate(maximize,1,'Maximizes an expression',26729,26733).
904 predicate(bb_inf,5,'Infimum of expression for mixed-integer problems',26735,26744).
905 predicate(bb_inf,4,'Infimum of expression for mixed-integer problems',26746,26749).
906 predicate(bb_inf,3,'Infimum of expression for mixed-integer problems',26751,26754).
907 predicate(dump,3,'Dump constraints on variables',26756,26766).
908 predicate(csv_read_file,2,'Read a CSV file into a list of rows.',26901,26902).
909 predicate(csv_read_file,3,'Read a CSV file into a list of rows.',26904,26920).
910 predicate(csv,3,'Prolog DCG to `read/write\' CSV data.',26922,26923).
911 predicate(csv,4,'Prolog DCG to `read/write\' CSV data.',26925,26962).
912 predicate(csv_read_file_row,3,'True when Row is a row in File.',26964,26984).
913 predicate(csv_read_row,3,'Read the next CSV record from Stream and unify the result with Row.',26986,26991).
914 predicate(csv_options,2,'Compiled is the compiled representation of the CSV processing options as they may be passed into csvSidiv{}2, etc.',26993,26998).
915 predicate(csv_write_file,2,'Write a list of Prolog terms to a CSV file.',27000,27001).
916 predicate(csv_write_file,3,'Write a list of Prolog terms to a CSV file.',27003,27008).
917 predicate(csv_write_stream,3,'Write the rows in Data to Stream.',27010,27024).
918 predicate(debugging,1,'Test where we are debugging topic',27046,27047).
919 predicate(debugging,1,'Test where we are debugging topic',27049,27050).
920 predicate(debugging,2,'Examine debug topics.',27052,27066).
921 predicate(debug,1,'Select topic for debugging',27068,27069).
922 predicate(nodebug,1,'Disable debug-topic',27071,27080).
923 predicate(list_debug_topics,0,'List registered topics for debugging',27082,27084).
924 predicate(debug_message_context,1,'Specify additional context for debug messages.',27086,27092).
925 predicate(debug,3,'Print debugging message on topic',27094,27107).
926 predicate(debug_print_hook,3,'Hook called by debug/3.',27109,27115).
927 predicate(assertion,1,'Make assertions about your program',27117,27130).
928 predicate(assertion_failed,2,'This hook is called if the Goal of assertion/1 fails.',27132,27138).
929 predicate(type_error,2,'Tell the user that Term is not of the expected Type.',27159,27174).
930 predicate(domain_error,2,'The argument is of the proper type, but has a value that is outside the supported values.',27176,27180).
931 predicate(existence_error,2,'Term is of the correct type and correct domain, but there is no existing (external) resource that is represented by it.',27182,27185).
932 predicate(existence_error,3,'Term is of the correct type and correct domain, but there is no existing (external) resource that is represented by it in the provided set.',27187,27193).
933 predicate(permission_error,3,'It is not allowed to perform Action on the object Term that is of the given Type.',27195,27198).
934 predicate(instantiation_error,1,'An argument is under-instantiated.',27200,27211).
935 predicate(uninstantiation_error,1,'An argument is over-instantiated.',27213,27219).
936 predicate(representation_error,1,'A representation error indicates a limitation of the implementation.',27221,27227).
937 predicate(syntax_error,1,'A text has invalid syntax.',27229,27237).
938 predicate(resource_error,1,'A goal cannot be completed due to lack of resources.',27239,27241).
939 predicate(must_be,2,'True if Term satisfies the type constraints for Type.',27243,27290).
940 predicate(is_of_type,2,'True if Term satisfies Type.',27292,27294).
941 predicate(has_type,2,'True if Term satisfies Type.',27296,27298).
942 predicate(current_type,3,'True when Type is a currently defined type and Var satisfies Type of the body term Body succeeds.',27300,27303).
943 predicate(gensym,2,'Generate unique atoms from a base',27318,27323).
944 predicate(reset_gensym,1,'Reset a gensym key',27325,27329).
945 predicate(reset_gensym,0,'Reset all gensym keys',27331,27336).
946 predicate(open_any,5,'',27366,27413).
947 predicate(close_any,1,'',27415,27419).
948 predicate(open_hook,6,'',27421,27431).
949 predicate(member,2,'True if Elem is a member of List.',27451,27461).
950 predicate(append,3,'List1AndList2 is the concatenation of List1 and List2.',27463,27465).
951 predicate(append,2,'Concatenate a list of lists.',27467,27473).
952 predicate(prefix,2,'True iff Part is a leading substring of Whole.',27475,27478).
953 predicate(select,3,'Is true when List1, with Elem removed, results in List2.',27480,27482).
954 predicate(selectchk,3,'Semi-deterministic removal of first element in List that unifies with Elem.',27484,27487).
955 predicate(select,4,'Select from two lists at the same positon.',27489,27505).
956 predicate(selectchk,4,'Semi-deterministic version of select/4.',27507,27509).
957 predicate(nextto,3,'True if Y directly follows X in List.',27511,27513).
958 predicate(delete,3,'Delete matching elements from a list.',27515,27527).
959 predicate(nth0,3,'True when Elem is the Index\'th element of List.',27529,27537).
960 predicate(nth1,3,'Is true when Elem is the Index\'th element of List.',27539,27544).
961 predicate(nth0,4,'Select/insert element at index.',27546,27563).
962 predicate(nth1,4,'As nth0/4, but counting starts at 1.',27565,27567).
963 predicate(last,2,'Last element of a list',27569,27577).
964 predicate(proper_length,2,'True when Length is the number of elements in the proper list List.',27579,27588).
965 predicate(same_length,2,'Is true when List1 and List2 are lists with the same number of elements.',27590,27597).
966 predicate(reverse,2,'Is true when the elements of List2 are in reverse order compared to List1.',27599,27602).
967 predicate(permutation,2,'True when Xs is a permutation of Ys.',27604,27635).
968 predicate(flatten,2,'Is true if FlatList is a non-nested version of NestedList.',27637,27649).
969 predicate(max_member,2,'True when Max is the largest member in the standard order of terms.',27651,27658).
970 predicate(min_member,2,'True when Min is the smallest member in the standard order of terms.',27660,27667).
971 predicate(sum_list,2,'Sum is the result of adding all numbers in List.',27669,27671).
972 predicate(max_list,2,'True if Max is the largest number in List.',27673,27677).
973 predicate(min_list,2,'True if Min is the smallest number in List.',27679,27684).
974 predicate(numlist,3,'List is a list [Low, Low+1, ... High].',27686,27692).
975 predicate(is_set,1,'True if Set is a proper list without duplicates.',27694,27699).
976 predicate(list_to_set,2,'Remove duplicates from a list',27701,27717).
977 predicate(intersection,3,'True if Set3 unifies with the intersection of Set1 and Set2.',27719,27726).
978 predicate(union,3,'True if Set3 unifies with the union of the lists Set1 and Set2.',27728,27735).
979 predicate(subset,2,'True if all elements of SubSet belong to Set as well.',27737,27744).
980 predicate(subtract,3,'Delete all elements in Delete from Set.',27746,27753).
981 predicate(main,0,'Call main/1 using the passed command-line arguments.',27785,27789).
982 predicate(argv_options,3,'Generic transformation of long commandline arguments to options.',27791,27802).
983 predicate(empty_nb_set,1,'Test/create an empty non-backtrackable set',27831,27833).
984 predicate(add_nb_set,2,'Add term to a non-backtrackable set',27835,27838).
985 predicate(add_nb_set,3,'Add term to a non-backtrackable set',27840,27848).
986 predicate(gen_nb_set,2,'Generate members of non-backtrackable set',27850,27853).
987 predicate(size_nb_set,2,'Determine size of non-backtrackable set',27855,27857).
988 predicate(nb_set_to_list,2,'Convert non-backtrackable set to list',27859,27862).
989 predicate(www_open_url,1,'Open a web-page in a browser',27870,27890).
990 predicate(option,3,'Get an Option from OptionList.',27945,27951).
991 predicate(option,2,'Get an Option from OptionList.',27953,27960).
992 predicate(select_option,3,'Get and remove Option from an option list.',27962,27966).
993 predicate(select_option,4,'Get and remove Option with default value.',27968,27972).
994 predicate(merge_options,3,'Merge two option lists.',27974,27981).
995 predicate(meta_options,3,'Perform meta-expansion on options that are module-sensitive.',27983,28000).
996 predicate(dict_options,2,'Convert between an option list and a dictionary.',28002,28022).
997 predicate(opt_arguments,3,'Extract commandline options according to a specification.',28329,28345).
998 predicate(opt_parse,4,'Equivalent to opt_parse(OptsSpec, ApplArgs, Opts, PositionalArgs, Snil{}).',28347,28349).
999 predicate(opt_parse,5,'Parse the arguments Args (as list of atoms) according to OptsSpec.',28351,28386).
1000 predicate(opt_help,2,'True when Help is a help string synthesized from OptsSpec.',28388,28390).
1001 predicate(parse_type,3,'Hook to parse option text Codes to an object of type Type.',28392,28394).
1002 predicate(is_ordset,1,'True if Term is an ordered set.',28425,28430).
1003 predicate(ord_empty,1,'True when List is the empty ordered set.',28432,28435).
1004 predicate(ord_seteq,2,'True if Set1 and Set2 have the same elements.',28437,28442).
1005 predicate(list_to_ord_set,2,'Transform a list into an ordered set.',28444,28447).
1006 predicate(ord_intersect,2,'True if both ordered sets have a non-empty intersection.',28449,28451).
1007 predicate(ord_disjoint,2,'True if Set1 and Set2 have no common elements.',28453,28456).
1008 predicate(ord_intersect,3,'Intersection holds the common elements of Set1 and Set2.',28458,28462).
1009 predicate(ord_intersection,2,'Intersection of a powerset.',28464,28469).
1010 predicate(ord_intersection,3,'Intersection holds the common elements of Set1 and Set2.',28471,28474).
1011 predicate(ord_intersection,4,'Intersection and difference between two ordered sets.',28476,28482).
1012 predicate(ord_add_element,3,'Insert an element into the set.',28484,28487).
1013 predicate(ord_del_element,3,'Delete an element from an ordered set.',28489,28492).
1014 predicate(ord_selectchk,3,'Selectchk/3, specialised for ordered sets.',28494,28504).
1015 predicate(ord_memberchk,2,'True if Element is a member of OrdSet, compared using ==.',28506,28517).
1016 predicate(ord_subset,2,'Is true if all elements of Sub are in Super.',28519,28521).
1017 predicate(ord_subtract,3,'Diff is the set holding all elements of InOSet that are not in NotInOSet.',28523,28526).
1018 predicate(ord_union,2,'True if Union is the union of all elements in the superset SetOfSets.',28528,28535).
1019 predicate(ord_union,3,'Union is the union of Set1 and Set2.',28537,28539).
1020 predicate(ord_union,4,'True iff ord_union(Set1, Set2, Union) and ord_subtract(Set2, Set1, New).',28541,28544).
1021 predicate(ord_symdiff,3,'Is true when Difference is the symmetric difference of Set1 and Set2.',28546,28564).
1022 predicate(pairs_keys_values,3,'True if Keys holds the keys of Pairs and Values the values.',28581,28589).
1023 predicate(pairs_values,2,'Remove the keys from a list of Key-Value pairs.',28591,28594).
1024 predicate(pairs_keys,2,'Remove the values from a list of Key-Value pairs.',28596,28599).
1025 predicate(group_pairs_by_key,2,'Group values with equivalent (==/2) consecutive keys.',28601,28629).
1026 predicate(transpose_pairs,2,'Swap Key-Value to Value-Key.',28631,28634).
1027 predicate(map_list_to_pairs,3,'Create a Key-Value list by mapping each element of List.',28636,28643).
1028 predicate(persistent,1,'Declare dynamic database terms.',28713,28731).
1029 predicate(current_persistent_predicate,1,'True if PI is a predicate that provides access to the persistent database DB.',28733,28736).
1030 predicate(db_attach,2,'Use File as persistent database for the calling module.',28738,28750).
1031 predicate(db_attached,1,'True if the context module attached to the persistent database File.',28752,28755).
1032 predicate(db_detach,0,'Detach persistency from the calling module and delete all persistent clauses from the Prolog database.',28757,28762).
1033 predicate(db_sync,1,'Synchronise database with the associated file.',28764,28797).
1034 predicate(db_sync_all,1,'Sync all registered databases.',28799,28801).
1035 predicate(phrase_from_file,2,'Process the content of File using the DCG rule Grammar.',28832,28864).
1036 predicate(phrase_from_file,3,'As phrase_from_file/2, providing additional Options.',28866,28869).
1037 predicate(phrase_from_stream,2,'Run Grammer against the character codes on Stream.',28871,28874).
1038 predicate(syntax_error,3,'Throw the syntax error Error at the current location of the input.',28876,28882).
1039 predicate(lazy_list_location,3,'Determine current (error) location in a lazy list.',28884,28899).
1040 predicate(lazy_list_character_count,3,'True when CharCount is the current character count in the Lazy list.',28901,28912).
1041 predicate(stream_to_lazy_list,2,'Create a lazy list representing the character codes in Stream.',28914,28925).
1042 predicate(predicate_options,3,'Declare that the predicate PI processes options on Arg.',29067,29101).
1043 predicate(assert_predicate_options,4,'As predicate_options(:PI, +Arg, +Options).',29103,29111).
1044 predicate(current_predicate_option,3,'True when Arg of PI processes Option.',29113,29124).
1045 predicate(check_predicate_option,3,'Verify predicate options at runtime.',29126,29141).
1046 predicate(current_option_arg,2,'True when Arg of PI processes predicate options.',29143,29146).
1047 predicate(current_predicate_options,3,'True when Options is the current active option declaration for PI on Arg.',29148,29156).
1048 predicate(check_predicate_options,0,'Analyse loaded program for erroneous options.',29158,29174).
1049 predicate(derive_predicate_options,0,'Derive new predicate option declarations.',29176,29185).
1050 predicate(retractall_predicate_options,0,'Remove all dynamically (derived) predicate options.',29187,29189).
1051 predicate(derived_predicate_options,3,'Derive option arguments using static analysis.',29191,29194).
1052 predicate(derived_predicate_options,1,'Derive predicate option declarations for a module.',29196,29199).
1053 predicate(pack_list_installed,0,'List currently installed packages.',29219,29225).
1054 predicate(pack_info,1,'Print more detailed information about Pack.',29227,29229).
1055 predicate(pack_search,1,'Query package server and installed packages and display results.',29231,29232).
1056 predicate(pack_list,1,'Query package server and installed packages and display results.',29234,29266).
1057 predicate(pack_install,1,'Install a package.',29268,29286).
1058 predicate(pack_install,2,'Install package Name.',29288,29319).
1059 predicate(pack_url_file,2,'True if File is a unique id for the referenced pack and version.',29321,29325).
1060 predicate(pack_rebuild,1,'Rebuilt possible foreign components of Pack.',29327,29329).
1061 predicate(pack_rebuild,0,'Rebuild foreign components of all packages.',29331,29333).
1062 predicate(environment,2,'Hook to define the environment for building packs.',29335,29351).
1063 predicate(pack_upgrade,1,'Try to upgrade the package Pack.',29353,29358).
1064 predicate(pack_remove,1,'Remove the indicated package.',29360,29362).
1065 predicate(pack_property,2,'True when Property is a property of an installed Pack.',29364,29389).
1066 predicate(xref_source,1,'Cross-reference analysis of source',29424,29429).
1067 predicate(xref_current_source,1,'Examine cross-referenced sources',29431,29433).
1068 predicate(xref_clean,1,'Remove analysis of source',29435,29437).
1069 predicate(xref_defined,3,'Examine defined predicates',29439,29450).
1070 predicate(xref_called,3,'Examine called predicates',29452,29454).
1071 predicate(xref_exported,2,'Examine exported predicates',29456,29458).
1072 predicate(xref_module,2,'Module defined by source',29460,29462).
1073 predicate(xref_built_in,1,'Examine defined built-ins',29464,29469).
1074 predicate(called_by,2,'Hook (prolog) Extend cross-referencer',29477,29490).
1075 predicate(with_quasi_quotation_input,3,'Parse quasi quotation from stream',29572,29592).
1076 predicate(phrase_from_quasi_quotation,2,'Parse quasi quotation with DCG',29594,29600).
1077 predicate(quasi_quotation_syntax,1,'Declare quasi quotation syntax',29602,29605).
1078 predicate(quasi_quotation_syntax_error,1,'Raise syntax error',29607,29612).
1079 predicate(random,1,'Binds R to a new random float in the _open_ interval (0.0,1.0).',29626,29634).
1080 predicate(random_between,3,'Binds R to a random integer in [L,U] (i.e., including both L and U).',29636,29639).
1081 predicate(random,3,'Generate a random integer or float in a range.',29641,29642).
1082 predicate(random,3,'Generate a random integer or float in a range.',29644,29653).
1083 predicate(setrand,1,'Query/set the state of the random generator.',29655,29656).
1084 predicate(getrand,1,'Query/set the state of the random generator.',29658,29677).
1085 predicate(maybe,0,'Succeed/fail with equal probability (variant of maybe/1).',29679,29681).
1086 predicate(maybe,1,'Succeed with probability P, fail with probability 1-P.',29683,29685).
1087 predicate(maybe,2,'Succeed with probability K/N (variant of maybe/1).',29687,29689).
1088 predicate(random_perm2,4,'Does X=A,Y=B or X=B,Y=A with equal probability.',29691,29693).
1089 predicate(random_member,2,'X is a random member of List.',29695,29700).
1090 predicate(random_select,3,'Randomly select or insert an element.',29702,29703).
1091 predicate(random_select,3,'Randomly select or insert an element.',29705,29710).
1092 predicate(randset,3,'S is a sorted list of K unique random integers in the range 1..N.',29712,29727).
1093 predicate(randseq,3,'S is a list of K unique random integers in the range 1..N.',29729,29740).
1094 predicate(random_permutation,2,'Permutation is a random permutation of List.',29742,29743).
1095 predicate(random_permutation,2,'Permutation is a random permutation of List.',29745,29751).
1096 predicate(read_line_to_codes,2,'Read line from a stream',29764,29772).
1097 predicate(read_line_to_codes,3,'Read line from a stream',29774,29795).
1098 predicate(read_stream_to_codes,2,'Read contents of stream',29797,29799).
1099 predicate(read_stream_to_codes,3,'Read contents of stream',29801,29803).
1100 predicate(read_file_to_codes,3,'Read contents of file',29805,29811).
1101 predicate(read_file_to_terms,3,'Read contents of file to Prolog terms',29813,29819).
1102 predicate(record,1,'Define named fields in a term',29913,29918).
1103 predicate(registry_get_key,2,'Get principal value of key',29937,29940).
1104 predicate(registry_get_key,3,'Get associated value of key',29942,29944).
1105 predicate(registry_set_key,2,'Set principal value of key',29946,29949).
1106 predicate(registry_set_key,3,'Set associated value of key',29951,29954).
1107 predicate(registry_delete_key,1,'Remove a key',29956,29958).
1108 predicate(shell_register_file_type,4,'Register a file-type',29960,29966).
1109 predicate(shell_register_dde,6,'Register DDE action',29968,29975).
1110 predicate(shell_register_prolog,1,'Register Prolog',29977,29996).
1111 predicate(gen_state,1,'Create empty linear program',30044,30047).
1112 predicate(constraint,3,'Add linear constraint to state',30049,30059).
1113 predicate(maximize,3,'Maximize objective function in to linear constraints',30061,30067).
1114 predicate(minimize,3,'Minimize objective function in to linear constraints',30069,30071).
1115 predicate(variable_value,3,'Fetch value of variable in solved state',30073,30076).
1116 predicate(objective,2,'Fetch value of objective function',30078,30087).
1117 predicate(constraint,4,'Add named linear constraint to state',30096,30099).
1118 predicate(shadow_price,3,'Fetch shadow price in solved state',30101,30105).
1119 predicate(constraint_add,4,'Extend a named constraint',30107,30115).
1120 predicate(transportation,4,'Solve transportation problem',30123,30132).
1121 predicate(assignment,2,'Solve assignment problem',30134,30140).
1122 predicate(distinct,1,'True if Goal is true and no previous solution of Goal bound Witness to the same value.',30342,30343).
1123 predicate(distinct,2,'True if Goal is true and no previous solution of Goal bound Witness to the same value.',30345,30361).
1124 predicate(reduced,1,'Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.',30363,30364).
1125 predicate(reduced,3,'Similar to distinct/1, but does not guarantee unique results in return for using a limited amount of memory.',30366,30378).
1126 predicate(limit,2,'Limit the number of solutions.',30380,30384).
1127 predicate(offset,2,'Ignore the first Count solutions.',30386,30390).
1128 predicate(group_by,4,'Group bindings of Template that have the same value for By.',30405,30411).
1129 predicate(table,1,'Declare predicate to be tabled',30687,30705).
1130 predicate(abolish_all_tables,0,'Abolish computed tables',30707,30714).
1131 predicate(abolish_table_subgoals,1,'Abolish tables for a goal',30716,30718).
1132 predicate(thread_pool_create,3,'Create a pool of threads.',30812,30829).
1133 predicate(thread_pool_destroy,1,'Destroy the thread pool named Name.',30831,30835).
1134 predicate(current_thread_pool,1,'True if Name refers to a defined thread pool.',30837,30839).
1135 predicate(thread_pool_property,2,'True if Property is a property of thread pool Name.',30841,30862).
1136 predicate(thread_create_in_pool,4,'Create a thread in Pool.',30864,30878).
1137 predicate(create_pool,1,'Hook to create a thread pool lazily.',30880,30894).
1138 predicate(vertices_edges_to_ugraph,3,'Create unweighted graph',30925,30943).
1139 predicate(vertices,2,'Find vertices in graph',30945,30951).
1140 predicate(edges,2,'Find edges in graph',30953,30960).
1141 predicate(add_vertices,3,'Add vertices to graph',30962,30970).
1142 predicate(del_vertices,3,'Delete vertices from graph',30972,30984).
1143 predicate(add_edges,3,'Add edges to graph',30986,30998).
1144 predicate(del_edges,3,'Delete edges from graph',31000,31010).
1145 predicate(transpose_ugraph,2,'Invert the direction of all edges',31012,31023).
1146 predicate(neighbours,3,'Find neighbors of vertice',31025,31034).
1147 predicate(neighbors,3,'Find neighbors of vertice',31036,31038).
1148 predicate(complement,2,'Inverse presense of edges',31040,31050).
1149 predicate(compose,3,'',31052,31060).
1150 predicate(ugraph_union,3,'Union of two graphs',31062,31069).
1151 predicate(top_sort,2,'Sort graph topologically',31071,31081).
1152 predicate(top_sort,3,'Sort graph topologically',31083,31086).
1153 predicate(transitive_closure,2,'Create transitive closure of graph',31088,31096).
1154 predicate(reachable,3,'Find all reachable vertices',31098,31106).
1155 predicate(global_url,3,'Translate a possibly relative URL into an absolute one.',31129,31133).
1156 predicate(is_absolute_url,1,'True if URL is an absolute URL.',31135,31138).
1157 predicate(http_location,2,'Construct or analyze an HTTP location.',31140,31151).
1158 predicate(parse_url,2,'Construct or analyse a URL.',31153,31210).
1159 predicate(parse_url,3,'Similar to parse_url/2 for relative URLs.',31212,31215).
1160 predicate(www_form_encode,2,'En/decode to/from application/x-www-form-encoded.',31217,31218).
1161 predicate(www_form_encode,2,'En/decode to/from application/x-www-form-encoded.',31220,31231).
1162 predicate(set_url_encoding,2,'Query and set the encoding for URLs.',31233,31240).
1163 predicate(url_iri,2,'Convert between a URL, encoding in US-ASCII and an IRI.',31242,31243).
1164 predicate(url_iri,2,'Convert between a URL, encoding in US-ASCII and an IRI.',31245,31249).
1165 predicate(parse_url_search,2,'Construct or analyze an HTTP search specification.',31251,31255).
1166 predicate(file_name_to_url,2,'Translate between a filename and a file:Sidiv{} URL.',31257,31258).
1167 predicate(file_name_to_url,2,'Translate between a filename and a file:Sidiv{} URL.',31260,31265).
1168 predicate(numbervars,1,'Number variables in Term using $VAR(N).',31291,31296).
1169 predicate(varnumbers,2,'Inverse of numbervars/1.',31298,31300).
1170 predicate(varnumbers,3,'Inverse of numbervars/3.',31302,31313).
1171 predicate(max_var_number,3,'True when Max is the max of Start and the highest numbered $VAR(N) term.',31315,31322).
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.',31324,31333).
1173 predicate(>>,2,'Calls a copy of Lambda.',31408,31409).
1174 predicate(>>,3,'Calls a copy of Lambda.',31411,31412).
1175 predicate(>>,4,'Calls a copy of Lambda.',31414,31415).
1176 predicate(>>,5,'Calls a copy of Lambda.',31417,31418).
1177 predicate(>>,6,'Calls a copy of Lambda.',31420,31421).
1178 predicate(>>,7,'Calls a copy of Lambda.',31423,31424).
1179 predicate(>>,8,'Calls a copy of Lambda.',31426,31427).
1180 predicate(>>,9,'Calls a copy of Lambda.',31429,31446).
1181 predicate(/,2,'Shorthand for `Free/[]Srshift{}Lambda`.',31448,31449).
1182 predicate(/,3,'Shorthand for `Free/[]Srshift{}Lambda`.',31451,31452).
1183 predicate(/,4,'Shorthand for `Free/[]Srshift{}Lambda`.',31454,31455).
1184 predicate(/,5,'Shorthand for `Free/[]Srshift{}Lambda`.',31457,31458).
1185 predicate(/,6,'Shorthand for `Free/[]Srshift{}Lambda`.',31460,31461).
1186 predicate(/,7,'Shorthand for `Free/[]Srshift{}Lambda`.',31463,31464).
1187 predicate(/,8,'Shorthand for `Free/[]Srshift{}Lambda`.',31466,31467).
1188 predicate(/,9,'Shorthand for `Free/[]Srshift{}Lambda`.',31469,31492).
1189 predicate(is_lambda,1,'True if Term is a valid Lambda expression.',31494,31496).
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.',31498,31499).
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.',31501,31506).
1192 predicate(prolog_current_frame,1,'Reference to goal\'s environment stack',31521,31527).
1193 predicate(prolog_current_choice,1,'Reference to most recent choice point',31529,31533).
1194 predicate(prolog_frame_attribute,3,'Obtain information on a goal environment',31535,31618).
1195 predicate(prolog_choice_attribute,3,'Examine the choice point stack',31620,31642).
1196 predicate(deterministic,1,'Test deterministicy of current clause',31644,31651).
1197 predicate(prolog_cut_to,1,'Realise global cuts',31656,31669).
1198 predicate(prolog_trace_interception,4,'library(user) Intercept the Prolog tracer',31674,31787).
1199 predicate(prolog_skip_frame,1,'Perform `skip\' on a frame',31789,31796).
1200 predicate(prolog_skip_level,2,'Indicate deepest recursion to trace',31798,31805).
1201 predicate(break_hook,6,'Hook (prolog) Debugger hook',31817,31894).
1202 predicate(prolog_exception_hook,4,'Rewrite exceptions',31904,31948).
1203 predicate(exception,3,'Hook (user) Handle runtime exceptions',31963,31989).
1204 predicate(prolog_list_goal,1,'Hook (user) Intercept tracer \'L\' command',32001,32007).
1205 predicate(debug_control_hook,1,'Hook (prolog) Extend spy/1, etc.',32009,32035).
1206 predicate(help_hook,1,'Hook (prolog) User-hook in the help-system',32037,32052).
1207 predicate(prolog_load_file,2,'Hook (user) Program load_files/2',32061,32072).
1208 predicate(comment_hook,3,'Hook (prolog) handle comments in sources',32074,32093).
1209 predicate(expects_dialect,1,'For which Prolog dialect is this code written?',32136,32162).
1210 predicate(exists_source,1,'Check existence of a Prolog source',32164,32168).
1211 predicate(source_exports,2,'Check whether source exports a predicate',32170,32173).
1212 predicate(license,0,'Evaluate licenses of loaded modules',32721,32728).
1213 predicate(license,2,'Define license for named module',32730,32748).
1214 predicate(license,1,'Define license for current file',32750,32753).
1215 predicate(known_licenses,0,'Print known licenses',32760,32764).
12161216
12171217
12181218 % Predicate section/4
12351235 section([2,1,5],'Stopping Prolog',501,511).
12361236 section([2,2],'The user\'s initialisation file',513,545).
12371237 section([2,3],'Initialisation files and goals',547,589).
1238 section([2,4],'Command line options',591,858).
1238 section([2,4],'Command line options',591,857).
12391239 section([2,4,1],'Informational command line options',626,654).
1240 section([2,4,2],'Command line options for running Prolog',656,767).
1241 section([2,4,3],'Controlling the stack sizes',769,804).
1242 section([2,4,4],'Running goals from the command line',806,832).
1243 section([2,4,5],'Compilation options',834,842).
1244 section([2,4,6],'Maintenance options',844,858).
1245 section([2,5],'GNU Emacs Interface',860,877).
1246 section([2,6],'Online Help',879,946).
1247 section([2,7],'Command line history',948,973).
1248 section([2,8],'Reuse of top-level bindings',975,1014).
1249 section([2,9],'Overview of the Debugger',1016,1185).
1250 section([2,10],'Compilation',1187,1386).
1251 section([2,10,1],'During program development',1190,1217).
1252 section([2,10,2],'For running the result',1219,1386).
1253 section([2,10,2,1],'Using PrologScript',1227,1302).
1254 section([2,10,2,2],'Creating a shell script',1304,1337).
1255 section([2,10,2,3],'Creating a saved state',1339,1350).
1256 section([2,10,2,4],'Compilation using the -c command line option',1352,1386).
1257 section([2,11],'Environment Control (Prolog flags)',1388,2322).
1240 section([2,4,2],'Command line options for running Prolog',656,766).
1241 section([2,4,3],'Controlling the stack sizes',768,803).
1242 section([2,4,4],'Running goals from the command line',805,831).
1243 section([2,4,5],'Compilation options',833,841).
1244 section([2,4,6],'Maintenance options',843,857).
1245 section([2,5],'GNU Emacs Interface',859,876).
1246 section([2,6],'Online Help',878,945).
1247 section([2,7],'Command line history',947,972).
1248 section([2,8],'Reuse of top-level bindings',974,1013).
1249 section([2,9],'Overview of the Debugger',1015,1184).
1250 section([2,10],'Compilation',1186,1385).
1251 section([2,10,1],'During program development',1189,1216).
1252 section([2,10,2],'For running the result',1218,1385).
1253 section([2,10,2,1],'Using PrologScript',1226,1301).
1254 section([2,10,2,2],'Creating a shell script',1303,1336).
1255 section([2,10,2,3],'Creating a saved state',1338,1349).
1256 section([2,10,2,4],'Compilation using the -c command line option',1351,1385).
1257 section([2,11],'Environment Control (Prolog flags)',1387,2322).
12581258 section([2,12],'An overview of hook predicates',2324,2395).
12591259 section([2,13],'Automatic loading of libraries',2397,2509).
12601260 section([2,14],'Packs: community add-ons',2511,2557).
13111311 section([3,7],'Cross-referencer',4026,4107).
13121312 section([3,8],'Accessing the IDE from your program',4109,4146).
13131313 section([3,9],'Summary of the IDE',4148,4184).
1314 section([4],'BUILT-IN PREDICATES',4186,14020).
1314 section([4],'BUILT-IN PREDICATES',4186,14043).
13151315 section([4,1],'Notation of Predicate Descriptions',4189,4246).
13161316 section([4,2],'Character representation',4248,4303).
1317 section([4,3],'Loading Prolog source files',4305,5492).
1317 section([4,3],'Loading Prolog source files',4305,5465).
13181318 section([4,3,1],'Conditional compilation and program transformation',5033,5256).
13191319 section([4,3,1,1],'Program transformation with source layout info',5161,5192).
13201320 section([4,3,1,2],'Conditional compilation',5194,5256).
1321 section([4,3,2],'Reloading files, active code and threads',5258,5445).
1322 section([4,3,2,1],'Compilation of mutually dependent code',5392,5412).
1323 section([4,3,2,2],'Compilation with multiple threads',5414,5445).
1324 section([4,3,3],'Quick load files',5447,5492).
1325 section([4,4],'Editor Interface',5494,5621).
1326 section([4,4,1],'Customizing the editor interface',5534,5621).
1327 section([4,5],'List the program, predicates or clauses',5623,5654).
1328 section([4,6],'Verify Type of a Term',5656,5767).
1329 section([4,7],'Comparison and Unification of Terms',5769,6006).
1330 section([4,7,1],'Standard Order of Terms',5796,5882).
1331 section([4,7,2],'Special unification and comparison predicates',5884,6006).
1332 section([4,8],'Control Predicates',6008,6145).
1333 section([4,9],'Meta-Call Predicates',6147,6388).
1334 section([4,10],'Delimited continuations',6390,6418).
1335 section([4,11],'Exception handling',6420,6865).
1336 section([4,11,1],'Urgency of exceptions',6476,6530).
1337 section([4,11,2],'Debugging and exceptions',6532,6571).
1338 section([4,11,3],'The exception term',6573,6585).
1339 section([4,11,4],'Printing messages',6587,6865).
1340 section([4,11,4,1],'Printing from libraries',6800,6865).
1341 section([4,12],'Handling signals',6867,6959).
1342 section([4,12,1],'Notes on signal handling',6926,6959).
1343 section([4,13],'DCG Grammar rules',6961,7095).
1344 section([4,14],'Database',7097,7585).
1345 section([4,14,1],'Managing (dynamic) predicates',7162,7300).
1346 section([4,14,2],'The recorded database',7302,7355).
1347 section([4,14,3],'Flags',7357,7387).
1348 section([4,14,4],'Tries',7389,7494).
1349 section([4,14,5],'Update view',7496,7515).
1350 section([4,14,6],'Indexing databases',7517,7585).
1351 section([4,15],'Declaring predicate properties',7587,7646).
1352 section([4,16],'Examining the program',7648,8008).
1353 section([4,17],'Input and output',8010,8829).
1354 section([4,17,1],'Predefined stream aliases',8024,8060).
1355 section([4,17,2],'ISO Input and Output Streams',8062,8585).
1356 section([4,17,3],'Edinburgh-style I/O',8587,8705).
1357 section([],'Compatibility notes',8635,34452).
1358 section([4,17,4],'Switching between Edinburgh and ISO I/O',8707,8731).
1359 section([4,17,5],'Write onto atoms, code-lists, etc.',8733,8786).
1360 section([4,17,6],'Fast binary term I/O',8788,8829).
1361 section([4,18],'Status of streams',8831,8913).
1362 section([4,19],'Primitive character I/O',8915,9184).
1363 section([4,20],'Term reading and writing',9186,9717).
1364 section([4,21],'Analysing and Constructing Terms',9719,9973).
1365 section([4,21,1],'Non-logical operations on terms',9894,9973).
1366 section([4,22],'Analysing and Constructing Atoms',9975,10171).
1367 section([4,23],'Localization (locale) support',10173,10258).
1368 section([4,24],'Character properties',10260,10453).
1369 section([4,24,1],'Case conversion',10398,10415).
1370 section([4,24,2],'White space normalization',10417,10425).
1371 section([4,24,3],'Language-specific comparison',10427,10453).
1372 section([4,25],'Operators',10455,10565).
1373 section([4,26],'Character Conversion',10567,10584).
1374 section([4,27],'Arithmetic',10586,11307).
1375 section([4,27,1],'Special purpose integer arithmetic',10596,10662).
1376 section([4,27,2],'General purpose arithmetic',10664,11307).
1377 section([4,27,2,1],'Arithmetic types',10710,10762).
1378 section([4,27,2,2],'Rational number examples',10764,10795).
1379 section([4,27,2,3],'Arithmetic Functions',10797,11307).
1380 section([4,28],'Misc arithmetic support predicates',11309,11357).
1381 section([4,29],'Built-in list operations',11359,11514).
1382 section([4,30],'Finding all Solutions to a Goal',11516,11613).
1383 section([4,31],'Forall',11615,11659).
1384 section([4,32],'Formatted Write',11661,11983).
1385 section([4,32,1],'Writef',11671,11751).
1386 section([4,32,2],'Format',11753,11944).
1387 section([4,32,3],'Programming Format',11946,11983).
1388 section([4,33],'Global variables',11985,12107).
1389 section([4,33,1],'Compatibility of SWI-Prolog Global Variables',12094,12107).
1390 section([4,34],'Terminal Control',12109,12157).
1391 section([4,35],'Operating System Interaction',12159,12810).
1392 section([4,35,1],'Windows-specific Operating System Interaction',12273,12383).
1393 section([4,35,2],'Dealing with time and date',12385,12748).
1394 section([4,35,2,1],'Time and date data structures',12424,12452).
1395 section([4,35,2,2],'Time and date predicates',12454,12748).
1396 section([4,35,3],'Controlling the swipl-win.exe console window',12750,12810).
1397 section([4,36],'File System Interaction',12812,13107).
1398 section([4,37],'User Top-level Manipulation',13109,13212).
1399 section([4,38],'Creating a Protocol of the User Interaction',13214,13239).
1400 section([4,39],'Debugging and Tracing Programs',13241,13444).
1401 section([4,40],'Obtaining Runtime Statistics',13446,13559).
1402 section([4,41],'Execution profiling',13561,13736).
1403 section([4,41,1],'Profiling predicates',13572,13638).
1404 section([4,41,2],'Visualizing profiling data',13640,13687).
1405 section([4,41,3],'Information gathering',13689,13736).
1406 section([4,41,3,1],'Profiling in the Windows Implementation',13721,13736).
1407 section([4,42],'Memory Management',13738,13824).
1408 section([4,43],'Windows DDE interface',13826,13960).
1409 section([4,43,1],'DDE client interface',13842,13899).
1410 section([4,43,2],'DDE server mode',13901,13960).
1411 section([4,44],'Miscellaneous',13962,14020).
1412 section([5],'SWI-PROLOG EXTENSIONS',14022,15370).
1413 section([5,1],'Lists are special',14042,14106).
1414 section([5,1,1],'Motivating \'[|]\' and [] for lists',14076,14106).
1415 section([5,2],'The string type and its double quoted syntax',14108,14591).
1416 section([5,2,1],'Predicates that operate on strings',14146,14379).
1417 section([5,2,2],'Representing text: strings, atoms and code lists',14381,14414).
1418 section([5,2,3],'Adapting code for double quoted strings',14416,14484).
1419 section([5,2,4],'Why has the representation of double quoted text changed?',14486,14591).
1420 section([5,3],'Syntax changes',14593,14700).
1421 section([5,3,1],'Operators and quoted atoms',14596,14610).
1422 section([5,3,2],'Compound terms with zero arguments',14612,14668).
1423 section([5,3,3],'Block operators',14670,14700).
1424 section([5,4],'Dicts: structures with named arguments',14702,15244).
1425 section([5,4,1],'Functions on dicts',14753,14899).
1426 section([5,4,1,1],'User defined functions on dicts',14810,14848).
1427 section([5,4,1,2],'Predefined functions on dicts',14850,14899).
1428 section([5,4,2],'Predicates for managing dicts',14901,15094).
1429 section([5,4,2,1],'Destructive assignment in dicts',15049,15094).
1430 section([5,4,3],'When to use dicts?',15096,15191).
1431 section([5,4,4],'A motivation for dicts as primary citizens',15193,15223).
1432 section([5,4,5],'Implementation notes about dicts',15225,15244).
1433 section([5,5],'Integration of strings and dicts in the libraries',15246,15326).
1434 section([5,5,1],'Dicts and option processing',15261,15265).
1435 section([5,5,2],'Dicts in core data structures',15267,15277).
1436 section([5,5,3],'Dicts, strings and XML',15279,15293).
1437 section([5,5,4],'Dicts, strings and JSON',15295,15310).
1438 section([5,5,5],'Dicts, strings and HTTP',15312,15326).
1439 section([5,6],'Remaining issues',15328,15370).
1440 section([6],'MODULES',15372,16225).
1441 section([6,1],'Why Use Modules?',15399,15419).
1442 section([6,2],'Defining a Module',15421,15475).
1443 section([6,3],'Importing Predicates into a Module',15477,15570).
1444 section([6,4],'Defining a meta-predicate',15572,15700).
1445 section([6,5],'Overruling Module Boundaries',15702,15759).
1446 section([6,5,1],'Explicit manipulation of the calling context',15734,15759).
1447 section([6,6],'Interacting with modules from the top level',15761,15789).
1448 section([6,7],'Composing modules from other modules',15791,15822).
1449 section([6,8],'Operators and modules',15824,15854).
1450 section([6,9],'Dynamic importing using import modules',15856,15904).
1451 section([6,10],'Reserved Modules and using the `user\' module',15906,15921).
1452 section([6,11],'An alternative import/export interface',15923,15948).
1453 section([6,12],'Dynamic Modules',15950,15983).
1454 section([6,13],'Transparent predicates: definition and context module',15985,16076).
1455 section([6,14],'Module properties',16078,16168).
1456 section([6,15],'Compatibility of the Module System',16170,16225).
1457 section([7],'CONSTRAINT LOGIC PROGRAMMING',16227,16720).
1458 section([7,1],'Attributed variables',16330,16602).
1459 section([7,1,1],'Attribute manipulation predicates',16426,16458).
1460 section([7,1,2],'Attributed variable hooks',16460,16544).
1461 section([7,1,3],'Operations on terms with attributed variables',16546,16578).
1462 section([7,1,4],'Special purpose predicates for attributes',16580,16602).
1463 section([7,2],'Coroutining',16604,16720).
1464 section([8],'CHR: CONSTRAINT HANDLING RULES',16722,17598).
1465 section([8,1],'Introduction',16744,16771).
1466 section([8,2],'Syntax and Semantics',16773,16950).
1467 section([8,2,1],'Syntax of CHR rules',16776,16828).
1468 section([8,2,2],'Semantics',16830,16950).
1469 section([8,3],'CHR in SWI-Prolog Programs',16952,17198).
1470 section([8,3,1],'Embedding in Prolog Programs',16955,16960).
1471 section([8,3,2],'Constraint declaration',16962,17171).
1472 section([8,3,3],'Compilation',17173,17198).
1473 section([8,4],'Debugging',17200,17341).
1474 section([8,4,1],'Ports',17210,17251).
1475 section([8,4,2],'Tracing',17253,17300).
1476 section([8,4,3],'CHR Debugging Predicates',17302,17341).
1477 section([8,5],'Examples',17343,17402).
1478 section([8,6],'Backwards Compatibility',17404,17482).
1479 section([8,6,1],'The Old SICStus CHR implemenation',17407,17450).
1480 section([8,6,2],'The Old ECLiPSe CHR implemenation',17452,17482).
1481 section([8,7],'Programming Tips and Tricks',17484,17527).
1482 section([8,8],'Compiler Errors and Warnings',17529,17598).
1483 section([8,8,1],'CHR Compiler Errors',17535,17598).
1484 section([9],'MULTITHREADED APPLICATIONS',17600,18734).
1485 section([9,1],'Creating and destroying Prolog threads',17639,17854).
1486 section([9,2],'Monitoring threads',17856,17956).
1487 section([9,3],'Thread communication',17958,18268).
1488 section([9,3,1],'Message queues',17961,18186).
1489 section([9,3,2],'Signalling threads',18188,18219).
1490 section([9,3,3],'Threads and dynamic predicates',18221,18268).
1491 section([9,4],'Thread synchronisation',18270,18400).
1492 section([9,5],'Thread support library(threadutil)',18402,18507).
1493 section([9,5,1],'Debugging threads',18428,18492).
1494 section([9,5,2],'Profiling threads',18494,18507).
1495 section([9,6],'Multithreaded mixed C and Prolog applications',18509,18678).
1496 section([9,6,1],'A Prolog thread for each native thread (one-to-one)',18531,18611).
1497 section([9,6,2],'Pooling Prolog engines (many-to-many)',18613,18678).
1498 section([9,7],'Multithreading and the XPCE graphics system',18680,18734).
1499 section([10],'COROUTINING USING PROLOG ENGINES',18736,19120).
1500 section([10,1],'Examples using engines',18764,18996).
1501 section([10,1,1],'Aggregation using engines',18781,18893).
1502 section([10,1,2],'State accumulation using engines',18895,18970).
1503 section([10,1,3],'Scalable many-agent applications',18972,18996).
1504 section([10,2],'Engine resource usage',18998,19015).
1505 section([10,3],'Engine predicate reference',19017,19120).
1506 section([11],'FOREIGN LANGUAGE INTERFACE',19122,23505).
1507 section([11,1],'Overview of the Interface',19140,19165).
1508 section([11,2],'Linking Foreign Modules',19167,19431).
1509 section([11,2,1],'What linking is provided?',19178,19186).
1510 section([11,2,2],'What kind of loading should I be using?',19188,19204).
1511 section([11,2,3],'library(shlib): Utility library for loading foreign objects',19206,19329).
1512 section([11,2,4],'Low-level operations on shared libraries',19331,19372).
1513 section([11,2,5],'Static Linking',19374,19431).
1514 section([11,3],'Interface Data Types',19433,19649).
1515 section([11,3,1],'Type term_t: a reference to a Prolog term',19436,19575).
1516 section([11,3,1,1],'Interaction with the garbage collector and stack-shifter',19564,19575).
1517 section([11,3,2],'Other foreign interface types',19577,19649).
1518 section([11,3,2,1],'PL_ARITY_AS_SIZE',19626,19649).
1519 section([11,4],'The Foreign Include File',19651,22934).
1520 section([11,4,1],'Argument Passing and Control',19654,19802).
1521 section([11,4,1,1],'Non-deterministic Foreign Predicates',19673,19802).
1522 section([11,4,2],'Atoms and functors',19804,19897).
1523 section([11,4,2,1],'Atoms and atom garbage collection',19863,19897).
1524 section([11,4,3],'Analysing Terms via the Foreign Interface',19899,20470).
1525 section([11,4,3,1],'Testing the type of a term',19912,20026).
1526 section([11,4,3,2],'Reading data from a term',20028,20223).
1527 section([11,4,3,3],'Exchanging text using length and string',20225,20289).
1528 section([11,4,3,4],'Wide-character versions',20291,20338).
1529 section([11,4,3,5],'Reading a list',20340,20416).
1530 section([11,4,3,6],'An example: defining write/1 in C',20418,20470).
1531 section([11,4,4],'Constructing Terms',20472,20629).
1532 section([11,4,5],'Unifying data',20631,21031).
1533 section([11,4,6],'Convenient functions to generate Prolog exceptions',21033,21192).
1534 section([11,4,7],'BLOBS: Using atoms to store arbitrary binary data',21194,21342).
1535 section([11,4,7,1],'Defining a BLOB type',21216,21303).
1536 section([11,4,7,2],'Accessing blobs',21305,21342).
1537 section([11,4,8],'Exchanging GMP numbers',21344,21428).
1538 section([11,4,9],'Calling Prolog from C',21430,21599).
1539 section([11,4,9,1],'Predicate references',21443,21470).
1540 section([11,4,9,2],'Initiating a query from C',21472,21599).
1541 section([11,4,10],'Discarding Data',21601,21661).
1542 section([11,4,11],'Foreign Code and Modules',21663,21702).
1543 section([11,4,12],'Prolog exceptions in foreign code',21704,21831).
1544 section([11,4,13],'Catching Signals (Software Interrupts)',21833,21929).
1545 section([11,4,14],'Miscellaneous',21931,22123).
1546 section([11,4,14,1],'Term Comparison',21934,21945).
1547 section([11,4,14,2],'Recorded database',21947,22045).
1548 section([11,4,14,3],'Getting file names',22047,22096).
1549 section([11,4,14,4],'Dealing with Prolog flags from C',22098,22123).
1550 section([11,4,15],'Errors and warnings',22125,22138).
1551 section([11,4,16],'Environment Control from Foreign Code',22140,22201).
1552 section([11,4,17],'Querying Prolog',22203,22240).
1553 section([11,4,18],'Registering Foreign Predicates',22242,22366).
1554 section([11,4,19],'Foreign Code Hooks',22368,22453).
1555 section([11,4,20],'Storing foreign data',22455,22646).
1556 section([11,4,20,1],'Examples for storing foreign data',22524,22646).
1557 section([11,4,21],'Embedding SWI-Prolog in other applications',22648,22934).
1558 section([11,4,21,1],'Threading, Signals and embedded Prolog',22880,22934).
1559 section([11,5],'Linking embedded applications using swipl-ld',22936,23155).
1560 section([11,5,1],'A simple example',23069,23155).
1561 section([11,6],'The Prolog `home\' directory',23157,23191).
1562 section([11,7],'Example of Using the Foreign Interface',23193,23252).
1563 section([11,8],'Notes on Using Foreign Code',23254,23505).
1564 section([11,8,1],'Foreign debugging functions',23257,23352).
1565 section([11,8,2],'Memory Allocation',23354,23421).
1566 section([11,8,2,1],'Boehm-GC support',23386,23421).
1567 section([11,8,3],'Compatibility between Prolog versions',23423,23435).
1568 section([11,8,4],'Debugging and profiling foreign code (valgrind)',23437,23457).
1569 section([11,8,5],'Name Conflicts in C modules',23459,23476).
1570 section([11,8,6],'Compatibility of the Foreign Interface',23478,23505).
1571 section([12],'GENERATING RUNTIME APPLICATIONS',23507,23913).
1572 section([12,1],'Limitations of qsave_program',23658,23674).
1573 section([12,2],'Runtimes and Foreign Code',23676,23742).
1574 section([12,3],'Using program resources',23744,23866).
1575 section([12,3,1],'Resource manipulation predicates',23777,23835).
1576 section([12,3,2],'The swipl-rc program',23837,23866).
1577 section([12,4],'Finding Application files',23868,23913).
1578 section([12,4,1],'Specifying a file search path from the command line',23900,23913).
1579 section([13],'THE SWI-PROLOG LIBRARY',23915,31481).
1580 section([13,1],'library(aggregate): Aggregation operators on backtrackable',23939,24105).
1581 section([13,2],'library(apply): Apply predicates on a list',24107,24219).
1582 section([13,3],'library(assoc): Association lists',24221,24384).
1583 section([13,3,1],'Introduction',24226,24258).
1584 section([13,3,2],'Creating association lists',24260,24283).
1585 section([13,3,3],'Querying association lists',24285,24314).
1586 section([13,3,4],'Modifying association lists',24316,24341).
1587 section([13,3,5],'Conversion predicates',24343,24362).
1588 section([13,3,6],'Reasoning about association lists and their elements',24364,24384).
1589 section([13,4],'library(broadcast): Broadcast and receive event notifications',24386,24500).
1590 section([13,5],'library(charsio): I/O on Lists of Character Codes',24502,24586).
1591 section([13,6],'library(check): Consistency checking',24588,24721).
1592 section([13,7],'library(clpb): CLP(B): Constraint Logic Programming over Boolean',24723,25094).
1593 section([13,7,1],'Introduction',24729,24763).
1594 section([13,7,2],'Boolean expressions',24765,24805).
1595 section([13,7,3],'Interface predicates',24807,24825).
1596 section([13,7,4],'Examples',24827,24870).
1597 section([13,7,5],'Obtaining BDDs',24872,24905).
1598 section([13,7,6],'Enabling monotonic CLP(B)',24907,24936).
1599 section([13,7,7],'Example: Pigeons',24938,24980).
1600 section([13,7,8],'Example: Boolean circuit',24982,25007).
1601 section([13,7,9],'Acknowledgments',25009,25015).
1602 section([13,7,10],'CLP(B) predicate index',25017,25094).
1603 section([13,8],'library(clpfd): CLP(FD): Constraint Logic Programming over Finite',25096,26637).
1604 section([13,8,1],'Introduction',25105,25204).
1605 section([13,8,2],'Arithmetic constraints',25206,25254).
1606 section([13,8,3],'Declarative integer arithmetic',25256,25338).
1607 section([13,8,4],'Example: Factorial relation',25340,25421).
1608 section([13,8,5],'Combinatorial constraints',25423,25432).
1609 section([13,8,6],'Domains',25434,25449).
1610 section([13,8,7],'Example: Sudoku',25451,25505).
1611 section([13,8,8],'Residual goals',25507,25560).
1612 section([13,8,9],'Core relations and search',25562,25636).
1613 section([13,8,10],'Example: Eight queens puzzle',25638,25712).
1614 section([13,8,11],'Optimisation',25714,25738).
1615 section([13,8,12],'Reification',25740,25762).
1616 section([13,8,13],'Enabling monotonic CLP(FD)',25764,25799).
1617 section([13,8,14],'Custom constraints',25801,25849).
1618 section([13,8,15],'Applications',25851,25862).
1619 section([13,8,16],'Acknowledgments',25864,25884).
1620 section([13,8,17],'CLP(FD) predicate index',25886,26616).
1621 section([13,8,17,1],'Arithmetic constraints',25895,25956).
1622 section([13,8,17,2],'Membership constraints',25958,25984).
1623 section([13,8,17,3],'Enumeration predicates',25986,26088).
1624 section([13,8,17,4],'Global constraints',26090,26410).
1625 section([13,8,17,5],'Reification predicates',26412,26559).
1626 section([13,8,17,6],'Reflection predicates',26561,26616).
1627 section([13,8,18],'Closing and opening words about CLP(FD)',26618,26637).
1628 section([13,9],'library(clpqr): Constraint Logic Programming over Rationals and',26639,26861).
1629 section([13,9,1],'Solver predicates',26673,26743).
1630 section([13,9,2],'Syntax of the predicate arguments',26745,26784).
1631 section([13,9,3],'Use of unification',26786,26803).
1632 section([13,9,4],'Non-linear constraints',26805,26830).
1633 section([13,9,5],'Status and known problems',26832,26861).
1634 section([13,10],'library(csv): Process CSV (Comma-Separated Values) data',26863,27001).
1635 section([13,11],'library(debug): Print debug messages and test assertions',27003,27115).
1636 section([13,12],'library(error): Error generating support',27117,27272).
1637 section([13,13],'library(gensym): Generate unique identifiers',27274,27305).
1638 section([13,14],'library(iostream): Utilities to deal with streams',27307,27400).
1639 section([13,15],'library(lists): List Manipulation',27402,27722).
1640 section([13,16],'library(main): Provide entry point for scripts',27724,27771).
1641 section([13,17],'library(nb_set): Non-backtrackable set',27773,27831).
1642 section([13,18],'library(www_browser): Activating your Web-browser',27833,27859).
1643 section([13,19],'library(option): Option list processing',27861,27991).
1644 section([13,20],'library(optparse): command line parsing',27993,28363).
1645 section([13,20,1],'Notes and tips',28257,28363).
1646 section([13,21],'library(ordsets): Ordered set manipulation',28365,28533).
1647 section([13,22],'library(pairs): Operations on key-value lists',28535,28612).
1648 section([13,23],'library(persistency): Provide persistent dynamic predicates',28614,28770).
1649 section([13,24],'library(pio): Pure I/O',28772,28894).
1650 section([13,24,1],'library(pure_input): Pure Input from files and streams',28780,28894).
1651 section([13,25],'library(predicate_options): Declare option-processing of predi-',28896,29168).
1652 section([13,25,1],'The strength and weakness of predicate options',28902,28952).
1653 section([13,25,2],'Options as arguments or environment?',28954,28986).
1654 section([13,25,3],'Improving on the current situation',28988,29168).
1655 section([13,25,3,1],'Options as types',28998,29025).
1656 section([13,25,3,2],'Reflective access to options',29027,29168).
1657 section([13,26],'library(prolog_pack): A package manager for Prolog',29170,29358).
1658 section([13,27],'library(prolog_xref): Cross-reference data collection library',29360,29459).
1659 section([13,27,1],'Extending the library',29440,29459).
1660 section([13,28],'library(quasi_quotations): Define Quasi Quotation syntax',29461,29581).
1661 section([13,29],'library(random): Random numbers',29583,29720).
1662 section([13,30],'library(readutil): Reading lines, streams and files',29722,29788).
1663 section([13,31],'library(record): Access named fields in a term',29790,29887).
1664 section([13,32],'library(registry): Manipulating the Windows registry',29889,29965).
1665 section([13,33],'library(simplex): Solve linear programming problems',29967,30261).
1666 section([13,33,1],'Introduction',29972,30056).
1667 section([13,33,2],'Delayed column generation',30058,30084).
1668 section([13,33,3],'Solving LPs with special structure',30086,30109).
1669 section([13,33,4],'Examples',30111,30261).
1670 section([13,33,4,1],'Example 1',30116,30149).
1671 section([13,33,4,2],'Example 2',30151,30211).
1672 section([13,33,4,3],'Example 3',30213,30261).
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).
1321 section([4,3,2],'Reloading files, active code and threads',5258,5418).
1322 section([4,3,2,1],'Compilation of mutually dependent code',5365,5385).
1323 section([4,3,2,2],'Compilation with multiple threads',5387,5418).
1324 section([4,3,3],'Quick load files',5420,5465).
1325 section([4,4],'Editor Interface',5467,5594).
1326 section([4,4,1],'Customizing the editor interface',5507,5594).
1327 section([4,5],'List the program, predicates or clauses',5596,5627).
1328 section([4,6],'Verify Type of a Term',5629,5740).
1329 section([4,7],'Comparison and Unification of Terms',5742,5979).
1330 section([4,7,1],'Standard Order of Terms',5769,5855).
1331 section([4,7,2],'Special unification and comparison predicates',5857,5979).
1332 section([4,8],'Control Predicates',5981,6118).
1333 section([4,9],'Meta-Call Predicates',6120,6361).
1334 section([4,10],'Delimited continuations',6363,6391).
1335 section([4,11],'Exception handling',6393,6838).
1336 section([4,11,1],'Urgency of exceptions',6449,6503).
1337 section([4,11,2],'Debugging and exceptions',6505,6544).
1338 section([4,11,3],'The exception term',6546,6558).
1339 section([4,11,4],'Printing messages',6560,6838).
1340 section([4,11,4,1],'Printing from libraries',6773,6838).
1341 section([4,12],'Handling signals',6840,6938).
1342 section([4,12,1],'Notes on signal handling',6905,6938).
1343 section([4,13],'DCG Grammar rules',6940,7074).
1344 section([4,14],'Database',7076,7564).
1345 section([4,14,1],'Managing (dynamic) predicates',7141,7279).
1346 section([4,14,2],'The recorded database',7281,7334).
1347 section([4,14,3],'Flags',7336,7366).
1348 section([4,14,4],'Tries',7368,7473).
1349 section([4,14,5],'Update view',7475,7494).
1350 section([4,14,6],'Indexing databases',7496,7564).
1351 section([4,15],'Declaring predicate properties',7566,7625).
1352 section([4,16],'Examining the program',7627,7987).
1353 section([4,17],'Input and output',7989,8808).
1354 section([4,17,1],'Predefined stream aliases',8003,8039).
1355 section([4,17,2],'ISO Input and Output Streams',8041,8564).
1356 section([4,17,3],'Edinburgh-style I/O',8566,8684).
1357 section([],'Compatibility notes',8614,34479).
1358 section([4,17,4],'Switching between Edinburgh and ISO I/O',8686,8710).
1359 section([4,17,5],'Write onto atoms, code-lists, etc.',8712,8765).
1360 section([4,17,6],'Fast binary term I/O',8767,8808).
1361 section([4,18],'Status of streams',8810,8892).
1362 section([4,19],'Primitive character I/O',8894,9163).
1363 section([4,20],'Term reading and writing',9165,9696).
1364 section([4,21],'Analysing and Constructing Terms',9698,9952).
1365 section([4,21,1],'Non-logical operations on terms',9873,9952).
1366 section([4,22],'Analysing and Constructing Atoms',9954,10150).
1367 section([4,23],'Localization (locale) support',10152,10237).
1368 section([4,24],'Character properties',10239,10432).
1369 section([4,24,1],'Case conversion',10377,10394).
1370 section([4,24,2],'White space normalization',10396,10404).
1371 section([4,24,3],'Language-specific comparison',10406,10432).
1372 section([4,25],'Operators',10434,10544).
1373 section([4,26],'Character Conversion',10546,10563).
1374 section([4,27],'Arithmetic',10565,11286).
1375 section([4,27,1],'Special purpose integer arithmetic',10575,10641).
1376 section([4,27,2],'General purpose arithmetic',10643,11286).
1377 section([4,27,2,1],'Arithmetic types',10689,10741).
1378 section([4,27,2,2],'Rational number examples',10743,10774).
1379 section([4,27,2,3],'Arithmetic Functions',10776,11286).
1380 section([4,28],'Misc arithmetic support predicates',11288,11336).
1381 section([4,29],'Built-in list operations',11338,11493).
1382 section([4,30],'Finding all Solutions to a Goal',11495,11592).
1383 section([4,31],'Forall',11594,11638).
1384 section([4,32],'Formatted Write',11640,11962).
1385 section([4,32,1],'Writef',11650,11730).
1386 section([4,32,2],'Format',11732,11923).
1387 section([4,32,3],'Programming Format',11925,11962).
1388 section([4,33],'Global variables',11964,12086).
1389 section([4,33,1],'Compatibility of SWI-Prolog Global Variables',12073,12086).
1390 section([4,34],'Terminal Control',12088,12136).
1391 section([4,35],'Operating System Interaction',12138,12789).
1392 section([4,35,1],'Windows-specific Operating System Interaction',12252,12362).
1393 section([4,35,2],'Dealing with time and date',12364,12727).
1394 section([4,35,2,1],'Time and date data structures',12403,12431).
1395 section([4,35,2,2],'Time and date predicates',12433,12727).
1396 section([4,35,3],'Controlling the swipl-win.exe console window',12729,12789).
1397 section([4,36],'File System Interaction',12791,13086).
1398 section([4,37],'User Top-level Manipulation',13088,13191).
1399 section([4,38],'Creating a Protocol of the User Interaction',13193,13218).
1400 section([4,39],'Debugging and Tracing Programs',13220,13423).
1401 section([4,40],'Obtaining Runtime Statistics',13425,13538).
1402 section([4,41],'Execution profiling',13540,13715).
1403 section([4,41,1],'Profiling predicates',13551,13617).
1404 section([4,41,2],'Visualizing profiling data',13619,13666).
1405 section([4,41,3],'Information gathering',13668,13715).
1406 section([4,41,3,1],'Profiling in the Windows Implementation',13700,13715).
1407 section([4,42],'Memory Management',13717,13847).
1408 section([4,43],'Windows DDE interface',13849,13983).
1409 section([4,43,1],'DDE client interface',13865,13922).
1410 section([4,43,2],'DDE server mode',13924,13983).
1411 section([4,44],'Miscellaneous',13985,14043).
1412 section([5],'SWI-PROLOG EXTENSIONS',14045,15393).
1413 section([5,1],'Lists are special',14065,14129).
1414 section([5,1,1],'Motivating \'[|]\' and [] for lists',14099,14129).
1415 section([5,2],'The string type and its double quoted syntax',14131,14614).
1416 section([5,2,1],'Predicates that operate on strings',14169,14402).
1417 section([5,2,2],'Representing text: strings, atoms and code lists',14404,14437).
1418 section([5,2,3],'Adapting code for double quoted strings',14439,14507).
1419 section([5,2,4],'Why has the representation of double quoted text changed?',14509,14614).
1420 section([5,3],'Syntax changes',14616,14723).
1421 section([5,3,1],'Operators and quoted atoms',14619,14633).
1422 section([5,3,2],'Compound terms with zero arguments',14635,14691).
1423 section([5,3,3],'Block operators',14693,14723).
1424 section([5,4],'Dicts: structures with named arguments',14725,15267).
1425 section([5,4,1],'Functions on dicts',14776,14922).
1426 section([5,4,1,1],'User defined functions on dicts',14833,14871).
1427 section([5,4,1,2],'Predefined functions on dicts',14873,14922).
1428 section([5,4,2],'Predicates for managing dicts',14924,15117).
1429 section([5,4,2,1],'Destructive assignment in dicts',15072,15117).
1430 section([5,4,3],'When to use dicts?',15119,15214).
1431 section([5,4,4],'A motivation for dicts as primary citizens',15216,15246).
1432 section([5,4,5],'Implementation notes about dicts',15248,15267).
1433 section([5,5],'Integration of strings and dicts in the libraries',15269,15349).
1434 section([5,5,1],'Dicts and option processing',15284,15288).
1435 section([5,5,2],'Dicts in core data structures',15290,15300).
1436 section([5,5,3],'Dicts, strings and XML',15302,15316).
1437 section([5,5,4],'Dicts, strings and JSON',15318,15333).
1438 section([5,5,5],'Dicts, strings and HTTP',15335,15349).
1439 section([5,6],'Remaining issues',15351,15393).
1440 section([6],'MODULES',15395,16248).
1441 section([6,1],'Why Use Modules?',15422,15442).
1442 section([6,2],'Defining a Module',15444,15498).
1443 section([6,3],'Importing Predicates into a Module',15500,15593).
1444 section([6,4],'Defining a meta-predicate',15595,15723).
1445 section([6,5],'Overruling Module Boundaries',15725,15782).
1446 section([6,5,1],'Explicit manipulation of the calling context',15757,15782).
1447 section([6,6],'Interacting with modules from the top level',15784,15812).
1448 section([6,7],'Composing modules from other modules',15814,15845).
1449 section([6,8],'Operators and modules',15847,15877).
1450 section([6,9],'Dynamic importing using import modules',15879,15927).
1451 section([6,10],'Reserved Modules and using the `user\' module',15929,15944).
1452 section([6,11],'An alternative import/export interface',15946,15971).
1453 section([6,12],'Dynamic Modules',15973,16006).
1454 section([6,13],'Transparent predicates: definition and context module',16008,16099).
1455 section([6,14],'Module properties',16101,16191).
1456 section([6,15],'Compatibility of the Module System',16193,16248).
1457 section([7],'CONSTRAINT LOGIC PROGRAMMING',16250,16743).
1458 section([7,1],'Attributed variables',16353,16625).
1459 section([7,1,1],'Attribute manipulation predicates',16449,16481).
1460 section([7,1,2],'Attributed variable hooks',16483,16567).
1461 section([7,1,3],'Operations on terms with attributed variables',16569,16601).
1462 section([7,1,4],'Special purpose predicates for attributes',16603,16625).
1463 section([7,2],'Coroutining',16627,16743).
1464 section([8],'CHR: CONSTRAINT HANDLING RULES',16745,17621).
1465 section([8,1],'Introduction',16767,16794).
1466 section([8,2],'Syntax and Semantics',16796,16973).
1467 section([8,2,1],'Syntax of CHR rules',16799,16851).
1468 section([8,2,2],'Semantics',16853,16973).
1469 section([8,3],'CHR in SWI-Prolog Programs',16975,17221).
1470 section([8,3,1],'Embedding in Prolog Programs',16978,16983).
1471 section([8,3,2],'Constraint declaration',16985,17194).
1472 section([8,3,3],'Compilation',17196,17221).
1473 section([8,4],'Debugging',17223,17364).
1474 section([8,4,1],'Ports',17233,17274).
1475 section([8,4,2],'Tracing',17276,17323).
1476 section([8,4,3],'CHR Debugging Predicates',17325,17364).
1477 section([8,5],'Examples',17366,17425).
1478 section([8,6],'Backwards Compatibility',17427,17505).
1479 section([8,6,1],'The Old SICStus CHR implemenation',17430,17473).
1480 section([8,6,2],'The Old ECLiPSe CHR implemenation',17475,17505).
1481 section([8,7],'Programming Tips and Tricks',17507,17550).
1482 section([8,8],'Compiler Errors and Warnings',17552,17621).
1483 section([8,8,1],'CHR Compiler Errors',17558,17621).
1484 section([9],'MULTITHREADED APPLICATIONS',17623,18757).
1485 section([9,1],'Creating and destroying Prolog threads',17662,17877).
1486 section([9,2],'Monitoring threads',17879,17979).
1487 section([9,3],'Thread communication',17981,18291).
1488 section([9,3,1],'Message queues',17984,18209).
1489 section([9,3,2],'Signalling threads',18211,18242).
1490 section([9,3,3],'Threads and dynamic predicates',18244,18291).
1491 section([9,4],'Thread synchronisation',18293,18423).
1492 section([9,5],'Thread support library(threadutil)',18425,18530).
1493 section([9,5,1],'Debugging threads',18451,18515).
1494 section([9,5,2],'Profiling threads',18517,18530).
1495 section([9,6],'Multithreaded mixed C and Prolog applications',18532,18701).
1496 section([9,6,1],'A Prolog thread for each native thread (one-to-one)',18554,18634).
1497 section([9,6,2],'Pooling Prolog engines (many-to-many)',18636,18701).
1498 section([9,7],'Multithreading and the XPCE graphics system',18703,18757).
1499 section([10],'COROUTINING USING PROLOG ENGINES',18759,19143).
1500 section([10,1],'Examples using engines',18787,19019).
1501 section([10,1,1],'Aggregation using engines',18804,18916).
1502 section([10,1,2],'State accumulation using engines',18918,18993).
1503 section([10,1,3],'Scalable many-agent applications',18995,19019).
1504 section([10,2],'Engine resource usage',19021,19038).
1505 section([10,3],'Engine predicate reference',19040,19143).
1506 section([11],'FOREIGN LANGUAGE INTERFACE',19145,23528).
1507 section([11,1],'Overview of the Interface',19163,19188).
1508 section([11,2],'Linking Foreign Modules',19190,19454).
1509 section([11,2,1],'What linking is provided?',19201,19209).
1510 section([11,2,2],'What kind of loading should I be using?',19211,19227).
1511 section([11,2,3],'library(shlib): Utility library for loading foreign objects',19229,19352).
1512 section([11,2,4],'Low-level operations on shared libraries',19354,19395).
1513 section([11,2,5],'Static Linking',19397,19454).
1514 section([11,3],'Interface Data Types',19456,19672).
1515 section([11,3,1],'Type term_t: a reference to a Prolog term',19459,19598).
1516 section([11,3,1,1],'Interaction with the garbage collector and stack-shifter',19587,19598).
1517 section([11,3,2],'Other foreign interface types',19600,19672).
1518 section([11,3,2,1],'PL_ARITY_AS_SIZE',19649,19672).
1519 section([11,4],'The Foreign Include File',19674,22957).
1520 section([11,4,1],'Argument Passing and Control',19677,19825).
1521 section([11,4,1,1],'Non-deterministic Foreign Predicates',19696,19825).
1522 section([11,4,2],'Atoms and functors',19827,19920).
1523 section([11,4,2,1],'Atoms and atom garbage collection',19886,19920).
1524 section([11,4,3],'Analysing Terms via the Foreign Interface',19922,20493).
1525 section([11,4,3,1],'Testing the type of a term',19935,20049).
1526 section([11,4,3,2],'Reading data from a term',20051,20246).
1527 section([11,4,3,3],'Exchanging text using length and string',20248,20312).
1528 section([11,4,3,4],'Wide-character versions',20314,20361).
1529 section([11,4,3,5],'Reading a list',20363,20439).
1530 section([11,4,3,6],'An example: defining write/1 in C',20441,20493).
1531 section([11,4,4],'Constructing Terms',20495,20652).
1532 section([11,4,5],'Unifying data',20654,21054).
1533 section([11,4,6],'Convenient functions to generate Prolog exceptions',21056,21215).
1534 section([11,4,7],'BLOBS: Using atoms to store arbitrary binary data',21217,21365).
1535 section([11,4,7,1],'Defining a BLOB type',21239,21326).
1536 section([11,4,7,2],'Accessing blobs',21328,21365).
1537 section([11,4,8],'Exchanging GMP numbers',21367,21451).
1538 section([11,4,9],'Calling Prolog from C',21453,21622).
1539 section([11,4,9,1],'Predicate references',21466,21493).
1540 section([11,4,9,2],'Initiating a query from C',21495,21622).
1541 section([11,4,10],'Discarding Data',21624,21684).
1542 section([11,4,11],'Foreign Code and Modules',21686,21725).
1543 section([11,4,12],'Prolog exceptions in foreign code',21727,21854).
1544 section([11,4,13],'Catching Signals (Software Interrupts)',21856,21952).
1545 section([11,4,14],'Miscellaneous',21954,22146).
1546 section([11,4,14,1],'Term Comparison',21957,21968).
1547 section([11,4,14,2],'Recorded database',21970,22068).
1548 section([11,4,14,3],'Getting file names',22070,22119).
1549 section([11,4,14,4],'Dealing with Prolog flags from C',22121,22146).
1550 section([11,4,15],'Errors and warnings',22148,22161).
1551 section([11,4,16],'Environment Control from Foreign Code',22163,22224).
1552 section([11,4,17],'Querying Prolog',22226,22263).
1553 section([11,4,18],'Registering Foreign Predicates',22265,22389).
1554 section([11,4,19],'Foreign Code Hooks',22391,22476).
1555 section([11,4,20],'Storing foreign data',22478,22669).
1556 section([11,4,20,1],'Examples for storing foreign data',22547,22669).
1557 section([11,4,21],'Embedding SWI-Prolog in other applications',22671,22957).
1558 section([11,4,21,1],'Threading, Signals and embedded Prolog',22903,22957).
1559 section([11,5],'Linking embedded applications using swipl-ld',22959,23178).
1560 section([11,5,1],'A simple example',23092,23178).
1561 section([11,6],'The Prolog `home\' directory',23180,23214).
1562 section([11,7],'Example of Using the Foreign Interface',23216,23275).
1563 section([11,8],'Notes on Using Foreign Code',23277,23528).
1564 section([11,8,1],'Foreign debugging functions',23280,23375).
1565 section([11,8,2],'Memory Allocation',23377,23444).
1566 section([11,8,2,1],'Boehm-GC support',23409,23444).
1567 section([11,8,3],'Compatibility between Prolog versions',23446,23458).
1568 section([11,8,4],'Debugging and profiling foreign code (valgrind)',23460,23480).
1569 section([11,8,5],'Name Conflicts in C modules',23482,23499).
1570 section([11,8,6],'Compatibility of the Foreign Interface',23501,23528).
1571 section([12],'GENERATING RUNTIME APPLICATIONS',23530,23936).
1572 section([12,1],'Limitations of qsave_program',23681,23697).
1573 section([12,2],'Runtimes and Foreign Code',23699,23765).
1574 section([12,3],'Using program resources',23767,23889).
1575 section([12,3,1],'Resource manipulation predicates',23800,23858).
1576 section([12,3,2],'The swipl-rc program',23860,23889).
1577 section([12,4],'Finding Application files',23891,23936).
1578 section([12,4,1],'Specifying a file search path from the command line',23923,23936).
1579 section([13],'THE SWI-PROLOG LIBRARY',23938,31506).
1580 section([13,1],'library(aggregate): Aggregation operators on backtrackable',23962,24128).
1581 section([13,2],'library(apply): Apply predicates on a list',24130,24242).
1582 section([13,3],'library(assoc): Association lists',24244,24407).
1583 section([13,3,1],'Introduction',24249,24281).
1584 section([13,3,2],'Creating association lists',24283,24306).
1585 section([13,3,3],'Querying association lists',24308,24337).
1586 section([13,3,4],'Modifying association lists',24339,24364).
1587 section([13,3,5],'Conversion predicates',24366,24385).
1588 section([13,3,6],'Reasoning about association lists and their elements',24387,24407).
1589 section([13,4],'library(broadcast): Broadcast and receive event notifications',24409,24523).
1590 section([13,5],'library(charsio): I/O on Lists of Character Codes',24525,24609).
1591 section([13,6],'library(check): Consistency checking',24611,24744).
1592 section([13,7],'library(clpb): CLP(B): Constraint Logic Programming over Boolean',24746,25117).
1593 section([13,7,1],'Introduction',24752,24786).
1594 section([13,7,2],'Boolean expressions',24788,24828).
1595 section([13,7,3],'Interface predicates',24830,24848).
1596 section([13,7,4],'Examples',24850,24893).
1597 section([13,7,5],'Obtaining BDDs',24895,24928).
1598 section([13,7,6],'Enabling monotonic CLP(B)',24930,24959).
1599 section([13,7,7],'Example: Pigeons',24961,25003).
1600 section([13,7,8],'Example: Boolean circuit',25005,25030).
1601 section([13,7,9],'Acknowledgments',25032,25038).
1602 section([13,7,10],'CLP(B) predicate index',25040,25117).
1603 section([13,8],'library(clpfd): CLP(FD): Constraint Logic Programming over Finite',25119,26660).
1604 section([13,8,1],'Introduction',25128,25227).
1605 section([13,8,2],'Arithmetic constraints',25229,25277).
1606 section([13,8,3],'Declarative integer arithmetic',25279,25361).
1607 section([13,8,4],'Example: Factorial relation',25363,25444).
1608 section([13,8,5],'Combinatorial constraints',25446,25455).
1609 section([13,8,6],'Domains',25457,25472).
1610 section([13,8,7],'Example: Sudoku',25474,25529).
1611 section([13,8,8],'Residual goals',25531,25584).
1612 section([13,8,9],'Core relations and search',25586,25659).
1613 section([13,8,10],'Example: Eight queens puzzle',25661,25735).
1614 section([13,8,11],'Optimisation',25737,25761).
1615 section([13,8,12],'Reification',25763,25785).
1616 section([13,8,13],'Enabling monotonic CLP(FD)',25787,25822).
1617 section([13,8,14],'Custom constraints',25824,25872).
1618 section([13,8,15],'Applications',25874,25885).
1619 section([13,8,16],'Acknowledgments',25887,25907).
1620 section([13,8,17],'CLP(FD) predicate index',25909,26639).
1621 section([13,8,17,1],'Arithmetic constraints',25918,25979).
1622 section([13,8,17,2],'Membership constraints',25981,26007).
1623 section([13,8,17,3],'Enumeration predicates',26009,26111).
1624 section([13,8,17,4],'Global constraints',26113,26433).
1625 section([13,8,17,5],'Reification predicates',26435,26582).
1626 section([13,8,17,6],'Reflection predicates',26584,26639).
1627 section([13,8,18],'Closing and opening words about CLP(FD)',26641,26660).
1628 section([13,9],'library(clpqr): Constraint Logic Programming over Rationals and',26662,26884).
1629 section([13,9,1],'Solver predicates',26696,26766).
1630 section([13,9,2],'Syntax of the predicate arguments',26768,26807).
1631 section([13,9,3],'Use of unification',26809,26826).
1632 section([13,9,4],'Non-linear constraints',26828,26853).
1633 section([13,9,5],'Status and known problems',26855,26884).
1634 section([13,10],'library(csv): Process CSV (Comma-Separated Values) data',26886,27024).
1635 section([13,11],'library(debug): Print debug messages and test assertions',27026,27138).
1636 section([13,12],'library(error): Error generating support',27140,27303).
1637 section([13,13],'library(gensym): Generate unique identifiers',27305,27336).
1638 section([13,14],'library(iostream): Utilities to deal with streams',27338,27431).
1639 section([13,15],'library(lists): List Manipulation',27433,27753).
1640 section([13,16],'library(main): Provide entry point for scripts',27755,27802).
1641 section([13,17],'library(nb_set): Non-backtrackable set',27804,27862).
1642 section([13,18],'library(www_browser): Activating your Web-browser',27864,27890).
1643 section([13,19],'library(option): Option list processing',27892,28022).
1644 section([13,20],'library(optparse): command line parsing',28024,28394).
1645 section([13,20,1],'Notes and tips',28288,28394).
1646 section([13,21],'library(ordsets): Ordered set manipulation',28396,28564).
1647 section([13,22],'library(pairs): Operations on key-value lists',28566,28643).
1648 section([13,23],'library(persistency): Provide persistent dynamic predicates',28645,28801).
1649 section([13,24],'library(pio): Pure I/O',28803,28925).
1650 section([13,24,1],'library(pure_input): Pure Input from files and streams',28811,28925).
1651 section([13,25],'library(predicate_options): Declare option-processing of predi-',28927,29199).
1652 section([13,25,1],'The strength and weakness of predicate options',28933,28983).
1653 section([13,25,2],'Options as arguments or environment?',28985,29017).
1654 section([13,25,3],'Improving on the current situation',29019,29199).
1655 section([13,25,3,1],'Options as types',29029,29056).
1656 section([13,25,3,2],'Reflective access to options',29058,29199).
1657 section([13,26],'library(prolog_pack): A package manager for Prolog',29201,29389).
1658 section([13,27],'library(prolog_xref): Cross-reference data collection library',29391,29490).
1659 section([13,27,1],'Extending the library',29471,29490).
1660 section([13,28],'library(quasi_quotations): Define Quasi Quotation syntax',29492,29612).
1661 section([13,29],'library(random): Random numbers',29614,29751).
1662 section([13,30],'library(readutil): Reading lines, streams and files',29753,29819).
1663 section([13,31],'library(record): Access named fields in a term',29821,29918).
1664 section([13,32],'library(registry): Manipulating the Windows registry',29920,29996).
1665 section([13,33],'library(simplex): Solve linear programming problems',29998,30292).
1666 section([13,33,1],'Introduction',30003,30087).
1667 section([13,33,2],'Delayed column generation',30089,30115).
1668 section([13,33,3],'Solving LPs with special structure',30117,30140).
1669 section([13,33,4],'Examples',30142,30292).
1670 section([13,33,4,1],'Example 1',30147,30180).
1671 section([13,33,4,2],'Example 2',30182,30242).
1672 section([13,33,4,3],'Example 3',30244,30292).
1673 section([13,34],'library(solution_sequences): Modify solution sequences',30294,30411).
1674 section([13,35],'library(tabling): Tabled execution (SLG)',30413,30774).
1675 section([13,35,0,1],'Example 1: using tabling for memoizing',30443,30528).
1676 section([13,35,0,2],'Example 2: avoiding non-termination',30530,30591).
1677 section([13,35,0,3],'Mode directed tabling',30593,30682).
1678 section([13,35,1],'Tabling predicate reference',30684,30774).
1679 section([13,35,1,1],'About the tabling implementation',30720,30754).
1680 section([13,35,1,2],'Status of tabling',30756,30774).
1681 section([13,36],'library(thread_pool): Resource bounded thread management',30776,30894).
1682 section([13,37],'library(ugraphs): Unweighted Graphs',30896,31106).
1683 section([13,38],'library(url): Analysing and constructing URL',31108,31265).
1684 section([13,39],'library(varnumbers): Utilities for numbered terms',31267,31333).
1685 section([13,40],'library(yall): Lambda expressions',31335,31506).
1686 section([14],'HACKERS CORNER',31508,32093).
1687 section([14,1],'Examining the Environment Stack',31518,31651).
1688 section([14,2],'Ancestral cuts',31653,31669).
1689 section([14,3],'Intercepting the Tracer',31671,31805).
1690 section([14,4],'Breakpoint and watchpoint handling',31807,31894).
1691 section([14,5],'Adding context to errors: prolog_exception_hook',31896,31948).
1692 section([14,6],'Hooks using the exception predicate',31950,31989).
1693 section([14,7],'Hooks for integrating libraries',31991,32052).
1694 section([14,8],'Hooks for loading files',32054,32093).
1695 section([15],'COMPATIBILITY WITH OTHER PROLOG DIALECTS',32095,32291).
1696 section([15,1],'Some considerations for writing portable code',32175,32291).
1697 section([16],'GLOSSARY OF TERMS',32293,32637).
1698 section([17],'SWI-PROLOG LICENSE CONDITIONS AND TOOLS',32639,32800).
1699 section([17,1],'Contributing to the SWI-Prolog project',32699,32708).
1700 section([17,2],'Software support to keep track of license conditions',32710,32764).
1701 section([17,3],'License conditions inherited from used code',32766,32800).
1702 section([17,3,1],'Cryptographic routines',32769,32800).
1703 section([18],'SUMMARY',32802,34388).
1704 section([18,1],'Predicates',32805,33662).
1705 section([18,2],'Library predicates',33664,34235).
1706 section([18,2,1],'library(aggregate)',33667,33675).
1707 section([18,2,2],'library(apply)',33677,33698).
1708 section([18,2,3],'library(assoc)',33700,33717).
1709 section([18,2,4],'library(broadcast)',33719,33729).
1710 section([18,2,5],'library(charsio)',33731,33748).
1711 section([18,2,6],'library(check)',33750,33767).
1712 section([18,2,7],'library(clpb)',33769,33777).
1713 section([18,2,8],'library(clpfd)',33779,33828).
1714 section([18,2,9],'library(clpqr)',33830,33842).
1715 section([18,2,10],'library(csv)',33844,33857).
1716 section([18,2,11],'library(debug)',33859,33872).
1717 section([18,2,12],'library(error)',33874,33891).
1718 section([18,2,13],'library(iostream)',33893,33894).
1719 section([18,2,14],'library(summaries.d/iostream/tex)',33896,33897).
1720 section([18,2,15],'library(lists)',33899,33937).
1721 section([18,2,16],'library(main)',33939,33943).
1722 section([18,2,17],'library(option)',33945,33954).
1723 section([18,2,18],'library(optparse)',33956,33963).
1724 section([18,2,19],'library(ordsets)',33965,33989).
1725 section([18,2,20],'library(persistency)',33991,34000).
1726 section([18,2,21],'library(predicate_options)',34002,34016).
1727 section([18,2,22],'library(prologpack)',34018,34034).
1728 section([18,2,23],'library(prologxref)',34036,34048).
1729 section([18,2,24],'library(pairs)',34050,34058).
1730 section([18,2,25],'library(pio)',34060,34072).
1731 section([18,2,25,1],'library(pure_input)',34063,34072).
1732 section([18,2,26],'library(random)',34074,34091).
1733 section([18,2,27],'library(readutil)',34093,34101).
1734 section([18,2,28],'library(record)',34103,34106).
1735 section([18,2,29],'library(registry)',34108,34120).
1736 section([18,2,30],'library(simplex)',34122,34136).
1737 section([18,2,31],'library(ugraphs)',34138,34159).
1738 section([18,2,32],'library(url)',34161,34174).
1739 section([18,2,33],'library(www_browser)',34176,34179).
1740 section([18,2,34],'library(solution_sequences)',34181,34191).
1741 section([18,2,35],'library(thread_pool)',34193,34201).
1742 section([18,2,36],'library(varnumbers)',34203,34210).
1743 section([18,2,37],'library(yall)',34212,34235).
1744 section([18,3],'Arithmetic Functions',34237,34321).
1745 section([18,4],'Operators',34323,34388).
1746 section([19],'Bibliography',34390,34479).
17471747
17481748
17491749 % Predicate function/3
17501750
1751 function('PL_thread_self',18542,18547).
1752 function('PL_unify_thread_id',18549,18553).
1753 function('PL_thread_attach_engine',18555,18589).
1754 function('PL_thread_destroy_engine',18591,18601).
1755 function('PL_thread_at_exit',18603,18611).
1756 function('PL_create_engine',18640,18649).
1757 function('PL_destroy_engine',18651,18656).
1758 function('PL_set_engine',18658,18678).
1759 function('PL_new_term_ref',19521,19527).
1760 function('PL_new_term_refs',19529,19544).
1761 function('PL_copy_term_ref',19546,19550).
1762 function('PL_reset_term_refs',19552,19562).
1763 function('PL_succeed',19664,19666).
1764 function('PL_fail',19668,19671).
1765 function('PL_retry',19722,19731).
1766 function('PL_retry_address',19733,19737).
1767 function('PL_foreign_control',19739,19744).
1768 function('PL_foreign_context',19746,19751).
1769 function('PL_foreign_context_address',19753,19755).
1770 function('PL_foreign_context_predicate',19757,19802).
1771 function('PL_new_atom',19810,19818).
1772 function('PL_new_atom_mbchars',19833,19838).
1773 function('PL_atom_chars',19840,19848).
1774 function('PL_new_functor',19850,19853).
1775 function('PL_functor_name',19855,19857).
1776 function('PL_functor_arity',19859,19861).
1777 function('PL_register_atom',19876,19880).
1778 function('PL_unregister_atom',19882,19897).
1779 function('PL_term_type',19915,19963).
1780 function('PL_is_variable',19965,19967).
1781 function('PL_is_ground',19969,19972).
1782 function('PL_is_atom',19974,19976).
1783 function('PL_is_string',19978,19980).
1784 function('PL_is_integer',19982,19984).
1785 function('PL_is_float',19986,19988).
1786 function('PL_is_callable',19990,19993).
1787 function('PL_is_compound',19995,19997).
1788 function('PL_is_functor',19999,20003).
1789 function('PL_is_list',20005,20009).
1790 function('PL_is_pair',20011,20014).
1791 function('PL_is_atomic',20016,20018).
1792 function('PL_is_number',20020,20022).
1793 function('PL_is_acyclic',20024,20026).
1794 function('PL_get_atom',20035,20042).
1795 function('PL_get_atom_chars',20044,20049).
1796 function('PL_get_string_chars',20051,20057).
1797 function('PL_get_chars',20059,20141).
1798 function('PL_get_list_chars',20143,20146).
1799 function('PL_get_integer',20148,20152).
1800 function('PL_get_long',20154,20160).
1801 function('PL_get_int64',20162,20165).
1802 function('PL_get_intptr',20167,20172).
1803 function('PL_get_bool',20174,20177).
1804 function('PL_get_pointer',20179,20185).
1805 function('PL_get_float',20187,20189).
1806 function('PL_get_functor',20191,20195).
1807 function('PL_get_name_arity',20197,20201).
1808 function('PL_get_compound_name_arity',20203,20207).
1809 function('PL_get_module',20209,20213).
1810 function('PL_get_arg',20215,20218).
1811 function('_PL_get_arg',20220,20223).
1812 function('PL_get_atom_nchars',20234,20236).
1813 function('PL_get_list_nchars',20238,20240).
1814 function('PL_get_nchars',20242,20244).
1815 function('PL_put_atom_nchars',20246,20248).
1816 function('PL_put_string_nchars',20250,20252).
1817 function('PL_put_list_ncodes',20254,20256).
1818 function('PL_put_list_nchars',20258,20260).
1819 function('PL_unify_atom_nchars',20262,20264).
1820 function('PL_unify_string_nchars',20266,20268).
1821 function('PL_unify_list_ncodes',20270,20272).
1822 function('PL_unify_list_nchars',20274,20279).
1823 function('PL_new_atom_nchars',20281,20285).
1824 function('PL_atom_nchars',20287,20289).
1825 function('PL_new_atom_wchars',20304,20309).
1826 function('PL_atom_wchars',20311,20317).
1827 function('PL_get_wchars',20319,20322).
1828 function('PL_unify_wchars',20324,20328).
1829 function('PL_unify_wchars_diff',20330,20338).
1830 function('PL_get_list',20370,20373).
1831 function('PL_get_head',20375,20378).
1832 function('PL_get_tail',20380,20383).
1833 function('PL_get_nil',20385,20387).
1834 function('PL_skip_list',20389,20416).
1835 function('PL_put_variable',20484,20487).
1836 function('PL_put_atom',20489,20492).
1837 function('PL_put_bool',20494,20497).
1838 function('PL_put_chars',20499,20508).
1839 function('PL_put_atom_chars',20510,20514).
1840 function('PL_put_string_chars',20516,20519).
1841 function('PL_put_string_nchars',20521,20525).
1842 function('PL_put_list_chars',20527,20529).
1843 function('PL_put_integer',20531,20533).
1844 function('PL_put_int64',20535,20537).
1845 function('PL_put_pointer',20539,20542).
1846 function('PL_put_float',20544,20546).
1847 function('PL_put_functor',20548,20553).
1848 function('PL_put_list',20555,20560).
1849 function('PL_put_nil',20562,20567).
1850 function('PL_put_term',20569,20571).
1851 function('PL_cons_functor',20573,20598).
1852 function('PL_cons_functor_v',20600,20605).
1853 function('PL_cons_list',20607,20629).
1854 function('PL_unify',20679,20711).
1855 function('PL_unify_atom',20713,20715).
1856 function('PL_unify_bool',20717,20719).
1857 function('PL_unify_chars',20721,20734).
1858 function('PL_unify_atom_chars',20736,20739).
1859 function('PL_unify_list_chars',20741,20743).
1860 function('PL_unify_string_chars',20745,20749).
1861 function('PL_unify_integer',20751,20753).
1862 function('PL_unify_int64',20755,20757).
1863 function('PL_unify_uint64',20759,20764).
1864 function('PL_unify_float',20766,20768).
1865 function('PL_unify_pointer',20770,20773).
1866 function('PL_unify_functor',20775,20781).
1867 function('PL_unify_compound',20783,20789).
1868 function('PL_unify_list',20791,20822).
1869 function('PL_unify_nil',20824,20826).
1870 function('PL_unify_arg',20828,20830).
1871 function('PL_unify_term',20832,20983).
1872 function('PL_chars_to_term',20985,21016).
1873 function('PL_wchars_to_term',21018,21020).
1874 function('PL_quote',21022,21031).
1875 function('PL_get_atom_ex',21063,21066).
1876 function('PL_get_integer_ex',21068,21072).
1877 function('PL_get_long_ex',21074,21078).
1878 function('PL_get_int64_ex',21080,21084).
1879 function('PL_get_intptr_ex',21086,21090).
1880 function('PL_get_size_ex',21092,21096).
1881 function('PL_get_bool_ex',21098,21101).
1882 function('PL_get_float_ex',21103,21106).
1883 function('PL_get_char_ex',21108,21112).
1884 function('PL_get_pointer_ex',21114,21117).
1885 function('PL_get_list_ex',21119,21122).
1886 function('PL_get_nil_ex',21124,21127).
1887 function('PL_unify_list_ex',21129,21132).
1888 function('PL_unify_nil_ex',21134,21137).
1889 function('PL_unify_bool_ex',21139,21149).
1890 function('PL_instantiation_error',21151,21155).
1891 function('PL_uninstantiation_error',21157,21162).
1892 function('PL_representation_error',21164,21166).
1893 function('PL_type_error',21168,21170).
1894 function('PL_domain_error',21172,21174).
1895 function('PL_existence_error',21176,21178).
1896 function('PL_permission_error',21180,21183).
1897 function('PL_resource_error',21185,21187).
1898 function('PL_syntax_error',21189,21192).
1899 function('PL_unregister_blob_type',21295,21303).
1900 function('PL_is_blob',21313,21316).
1901 function('PL_unify_blob',21318,21321).
1902 function('PL_put_blob',21323,21331).
1903 function('PL_get_blob',21333,21337).
1904 function('PL_blob_data',21339,21342).
1905 function('PL_get_mpz',21402,21408).
1906 function('PL_get_mpq',21410,21417).
1907 function('PL_unify_mpz',21419,21422).
1908 function('PL_unify_mpq',21424,21428).
1909 function('PL_pred',21451,21456).
1910 function('PL_predicate',21458,21461).
1911 function('PL_predicate_info',21463,21470).
1912 function('PL_open_query',21484,21562).
1913 function('PL_next_solution',21564,21569).
1914 function('PL_cut_query',21571,21575).
1915 function('PL_close_query',21577,21580).
1916 function('PL_current_query',21582,21585).
1917 function('PL_call_predicate',21587,21591).
1918 function('PL_call',21593,21599).
1919 function('PL_open_foreign_frame',21610,21616).
1920 function('PL_close_foreign_frame',21618,21622).
1921 function('PL_discard_foreign_frame',21624,21627).
1922 function('PL_rewind_foreign_frame',21629,21661).
1923 function('PL_context',21669,21672).
1924 function('PL_strip_module',21674,21694).
1925 function('PL_module_name',21696,21698).
1926 function('PL_new_module',21700,21702).
1927 function('PL_raise_exception',21779,21806).
1928 function('PL_throw',21808,21811).
1929 function('PL_exception',21813,21825).
1930 function('PL_clear_exception',21827,21831).
1931 function('PL_sigaction',21849,21874).
1932 function('PL_signal',21876,21902).
1933 function('PL_raise',21904,21908).
1934 function('PL_handle_signals',21910,21921).
1935 function('PL_get_signum_ex',21923,21929).
1936 function('PL_compare',21937,21940).
1937 function('PL_same_compound',21942,21945).
1938 function('PL_record',21965,21970).
1939 function('PL_duplicate_record',21972,21975).
1940 function('PL_recorded',21977,21983).
1941 function('PL_erase',21985,22020).
1942 function('PL_record_external',22022,22034).
1943 function('PL_recorded_external',22036,22040).
1944 function('PL_erase_external',22042,22045).
1945 function('PL_get_file_name',22055,22088).
1946 function('PL_get_file_nameW',22090,22096).
1947 function('PL_set_prolog_flag',22104,22123).
1948 function('PL_warning',22133,22138).
1949 function('PL_action',22143,22201).
1950 function('PL_query',22206,22240).
1951 function('PL_register_foreign_in_module',22245,22318).
1952 function('PL_register_foreign',22320,22323).
1953 function('PL_register_extensions_in_module',22325,22361).
1954 function('PL_register_extensions',22363,22366).
1955 function('PL_dispatch_hook',22373,22383).
1956 function('PL_abort_hook',22385,22394).
1957 function('PL_abort_unhook',22396,22399).
1958 function('PL_on_halt',22401,22409).
1959 function('PL_exit_hook',22411,22414).
1960 function('PL_agc_hook',22416,22453).
1961 function('PL_initialise',22677,22733).
1962 function('PL_is_initialised',22735,22741).
1963 function('PL_set_resource_db_mem',22743,22826).
1964 function('PL_toplevel',22828,22831).
1965 function('PL_cleanup',22833,22857).
1966 function('PL_cleanup_fork',22859,22872).
1967 function('PL_halt',22874,22878).
1968 function('PL_backtrace',23276,23289).
1969 function('PL_backtrace_string',23291,23305).
1970 function('PL_check_data',23307,23313).
1971 function('PL_check_stacks',23315,23335).
1972 function('PL_malloc',23368,23373).
1973 function('PL_realloc',23375,23379).
1974 function('PL_free',23381,23384).
1975 function('PL_malloc_atomic',23401,23402).
1976 function('PL_malloc_uncollectable',23404,23405).
1977 function('PL_malloc_atomic_uncollectable',23407,23413).
1978 function('PL_malloc_stubborn',23415,23416).
1979 function('PL_end_stubborn_change',23418,23421).
1980 function('PL_license',32730,32733).
1751 function('PL_thread_self',18565,18570).
1752 function('PL_unify_thread_id',18572,18576).
1753 function('PL_thread_attach_engine',18578,18612).
1754 function('PL_thread_destroy_engine',18614,18624).
1755 function('PL_thread_at_exit',18626,18634).
1756 function('PL_create_engine',18663,18672).
1757 function('PL_destroy_engine',18674,18679).
1758 function('PL_set_engine',18681,18701).
1759 function('PL_new_term_ref',19544,19550).
1760 function('PL_new_term_refs',19552,19567).
1761 function('PL_copy_term_ref',19569,19573).
1762 function('PL_reset_term_refs',19575,19585).
1763 function('PL_succeed',19687,19689).
1764 function('PL_fail',19691,19694).
1765 function('PL_retry',19745,19754).
1766 function('PL_retry_address',19756,19760).
1767 function('PL_foreign_control',19762,19767).
1768 function('PL_foreign_context',19769,19774).
1769 function('PL_foreign_context_address',19776,19778).
1770 function('PL_foreign_context_predicate',19780,19825).
1771 function('PL_new_atom',19833,19841).
1772 function('PL_new_atom_mbchars',19856,19861).
1773 function('PL_atom_chars',19863,19871).
1774 function('PL_new_functor',19873,19876).
1775 function('PL_functor_name',19878,19880).
1776 function('PL_functor_arity',19882,19884).
1777 function('PL_register_atom',19899,19903).
1778 function('PL_unregister_atom',19905,19920).
1779 function('PL_term_type',19938,19986).
1780 function('PL_is_variable',19988,19990).
1781 function('PL_is_ground',19992,19995).
1782 function('PL_is_atom',19997,19999).
1783 function('PL_is_string',20001,20003).
1784 function('PL_is_integer',20005,20007).
1785 function('PL_is_float',20009,20011).
1786 function('PL_is_callable',20013,20016).
1787 function('PL_is_compound',20018,20020).
1788 function('PL_is_functor',20022,20026).
1789 function('PL_is_list',20028,20032).
1790 function('PL_is_pair',20034,20037).
1791 function('PL_is_atomic',20039,20041).
1792 function('PL_is_number',20043,20045).
1793 function('PL_is_acyclic',20047,20049).
1794 function('PL_get_atom',20058,20065).
1795 function('PL_get_atom_chars',20067,20072).
1796 function('PL_get_string_chars',20074,20080).
1797 function('PL_get_chars',20082,20164).
1798 function('PL_get_list_chars',20166,20169).
1799 function('PL_get_integer',20171,20175).
1800 function('PL_get_long',20177,20183).
1801 function('PL_get_int64',20185,20188).
1802 function('PL_get_intptr',20190,20195).
1803 function('PL_get_bool',20197,20200).
1804 function('PL_get_pointer',20202,20208).
1805 function('PL_get_float',20210,20212).
1806 function('PL_get_functor',20214,20218).
1807 function('PL_get_name_arity',20220,20224).
1808 function('PL_get_compound_name_arity',20226,20230).
1809 function('PL_get_module',20232,20236).
1810 function('PL_get_arg',20238,20241).
1811 function('_PL_get_arg',20243,20246).
1812 function('PL_get_atom_nchars',20257,20259).
1813 function('PL_get_list_nchars',20261,20263).
1814 function('PL_get_nchars',20265,20267).
1815 function('PL_put_atom_nchars',20269,20271).
1816 function('PL_put_string_nchars',20273,20275).
1817 function('PL_put_list_ncodes',20277,20279).
1818 function('PL_put_list_nchars',20281,20283).
1819 function('PL_unify_atom_nchars',20285,20287).
1820 function('PL_unify_string_nchars',20289,20291).
1821 function('PL_unify_list_ncodes',20293,20295).
1822 function('PL_unify_list_nchars',20297,20302).
1823 function('PL_new_atom_nchars',20304,20308).
1824 function('PL_atom_nchars',20310,20312).
1825 function('PL_new_atom_wchars',20327,20332).
1826 function('PL_atom_wchars',20334,20340).
1827 function('PL_get_wchars',20342,20345).
1828 function('PL_unify_wchars',20347,20351).
1829 function('PL_unify_wchars_diff',20353,20361).
1830 function('PL_get_list',20393,20396).
1831 function('PL_get_head',20398,20401).
1832 function('PL_get_tail',20403,20406).
1833 function('PL_get_nil',20408,20410).
1834 function('PL_skip_list',20412,20439).
1835 function('PL_put_variable',20507,20510).
1836 function('PL_put_atom',20512,20515).
1837 function('PL_put_bool',20517,20520).
1838 function('PL_put_chars',20522,20531).
1839 function('PL_put_atom_chars',20533,20537).
1840 function('PL_put_string_chars',20539,20542).
1841 function('PL_put_string_nchars',20544,20548).
1842 function('PL_put_list_chars',20550,20552).
1843 function('PL_put_integer',20554,20556).
1844 function('PL_put_int64',20558,20560).
1845 function('PL_put_pointer',20562,20565).
1846 function('PL_put_float',20567,20569).
1847 function('PL_put_functor',20571,20576).
1848 function('PL_put_list',20578,20583).
1849 function('PL_put_nil',20585,20590).
1850 function('PL_put_term',20592,20594).
1851 function('PL_cons_functor',20596,20621).
1852 function('PL_cons_functor_v',20623,20628).
1853 function('PL_cons_list',20630,20652).
1854 function('PL_unify',20702,20734).
1855 function('PL_unify_atom',20736,20738).
1856 function('PL_unify_bool',20740,20742).
1857 function('PL_unify_chars',20744,20757).
1858 function('PL_unify_atom_chars',20759,20762).
1859 function('PL_unify_list_chars',20764,20766).
1860 function('PL_unify_string_chars',20768,20772).
1861 function('PL_unify_integer',20774,20776).
1862 function('PL_unify_int64',20778,20780).
1863 function('PL_unify_uint64',20782,20787).
1864 function('PL_unify_float',20789,20791).
1865 function('PL_unify_pointer',20793,20796).
1866 function('PL_unify_functor',20798,20804).
1867 function('PL_unify_compound',20806,20812).
1868 function('PL_unify_list',20814,20845).
1869 function('PL_unify_nil',20847,20849).
1870 function('PL_unify_arg',20851,20853).
1871 function('PL_unify_term',20855,21006).
1872 function('PL_chars_to_term',21008,21039).
1873 function('PL_wchars_to_term',21041,21043).
1874 function('PL_quote',21045,21054).
1875 function('PL_get_atom_ex',21086,21089).
1876 function('PL_get_integer_ex',21091,21095).
1877 function('PL_get_long_ex',21097,21101).
1878 function('PL_get_int64_ex',21103,21107).
1879 function('PL_get_intptr_ex',21109,21113).
1880 function('PL_get_size_ex',21115,21119).
1881 function('PL_get_bool_ex',21121,21124).
1882 function('PL_get_float_ex',21126,21129).
1883 function('PL_get_char_ex',21131,21135).
1884 function('PL_get_pointer_ex',21137,21140).
1885 function('PL_get_list_ex',21142,21145).
1886 function('PL_get_nil_ex',21147,21150).
1887 function('PL_unify_list_ex',21152,21155).
1888 function('PL_unify_nil_ex',21157,21160).
1889 function('PL_unify_bool_ex',21162,21172).
1890 function('PL_instantiation_error',21174,21178).
1891 function('PL_uninstantiation_error',21180,21185).
1892 function('PL_representation_error',21187,21189).
1893 function('PL_type_error',21191,21193).
1894 function('PL_domain_error',21195,21197).
1895 function('PL_existence_error',21199,21201).
1896 function('PL_permission_error',21203,21206).
1897 function('PL_resource_error',21208,21210).
1898 function('PL_syntax_error',21212,21215).
1899 function('PL_unregister_blob_type',21318,21326).
1900 function('PL_is_blob',21336,21339).
1901 function('PL_unify_blob',21341,21344).
1902 function('PL_put_blob',21346,21354).
1903 function('PL_get_blob',21356,21360).
1904 function('PL_blob_data',21362,21365).
1905 function('PL_get_mpz',21425,21431).
1906 function('PL_get_mpq',21433,21440).
1907 function('PL_unify_mpz',21442,21445).
1908 function('PL_unify_mpq',21447,21451).
1909 function('PL_pred',21474,21479).
1910 function('PL_predicate',21481,21484).
1911 function('PL_predicate_info',21486,21493).
1912 function('PL_open_query',21507,21585).
1913 function('PL_next_solution',21587,21592).
1914 function('PL_cut_query',21594,21598).
1915 function('PL_close_query',21600,21603).
1916 function('PL_current_query',21605,21608).
1917 function('PL_call_predicate',21610,21614).
1918 function('PL_call',21616,21622).
1919 function('PL_open_foreign_frame',21633,21639).
1920 function('PL_close_foreign_frame',21641,21645).
1921 function('PL_discard_foreign_frame',21647,21650).
1922 function('PL_rewind_foreign_frame',21652,21684).
1923 function('PL_context',21692,21695).
1924 function('PL_strip_module',21697,21717).
1925 function('PL_module_name',21719,21721).
1926 function('PL_new_module',21723,21725).
1927 function('PL_raise_exception',21802,21829).
1928 function('PL_throw',21831,21834).
1929 function('PL_exception',21836,21848).
1930 function('PL_clear_exception',21850,21854).
1931 function('PL_sigaction',21872,21897).
1932 function('PL_signal',21899,21925).
1933 function('PL_raise',21927,21931).
1934 function('PL_handle_signals',21933,21944).
1935 function('PL_get_signum_ex',21946,21952).
1936 function('PL_compare',21960,21963).
1937 function('PL_same_compound',21965,21968).
1938 function('PL_record',21988,21993).
1939 function('PL_duplicate_record',21995,21998).
1940 function('PL_recorded',22000,22006).
1941 function('PL_erase',22008,22043).
1942 function('PL_record_external',22045,22057).
1943 function('PL_recorded_external',22059,22063).
1944 function('PL_erase_external',22065,22068).
1945 function('PL_get_file_name',22078,22111).
1946 function('PL_get_file_nameW',22113,22119).
1947 function('PL_set_prolog_flag',22127,22146).
1948 function('PL_warning',22156,22161).
1949 function('PL_action',22166,22224).
1950 function('PL_query',22229,22263).
1951 function('PL_register_foreign_in_module',22268,22341).
1952 function('PL_register_foreign',22343,22346).
1953 function('PL_register_extensions_in_module',22348,22384).
1954 function('PL_register_extensions',22386,22389).
1955 function('PL_dispatch_hook',22396,22406).
1956 function('PL_abort_hook',22408,22417).
1957 function('PL_abort_unhook',22419,22422).
1958 function('PL_on_halt',22424,22432).
1959 function('PL_exit_hook',22434,22437).
1960 function('PL_agc_hook',22439,22476).
1961 function('PL_initialise',22700,22756).
1962 function('PL_is_initialised',22758,22764).
1963 function('PL_set_resource_db_mem',22766,22849).
1964 function('PL_toplevel',22851,22854).
1965 function('PL_cleanup',22856,22880).
1966 function('PL_cleanup_fork',22882,22895).
1967 function('PL_halt',22897,22901).
1968 function('PL_backtrace',23299,23312).
1969 function('PL_backtrace_string',23314,23328).
1970 function('PL_check_data',23330,23336).
1971 function('PL_check_stacks',23338,23358).
1972 function('PL_malloc',23391,23396).
1973 function('PL_realloc',23398,23402).
1974 function('PL_free',23404,23407).
1975 function('PL_malloc_atomic',23424,23425).
1976 function('PL_malloc_uncollectable',23427,23428).
1977 function('PL_malloc_atomic_uncollectable',23430,23436).
1978 function('PL_malloc_stubborn',23438,23439).
1979 function('PL_end_stubborn_change',23441,23444).
1980 function('PL_license',32755,32758).
19811981
19821982
110110 % the cycles. This means that this library is rather slow when
111111 % cyclic terms are involved.
112112
113 :- if(catch((A = f(A), variant_hash(A,_)), error(type_error(_,_),_), fail)).
113 :- if(catch((A = f(A), variant_hash(A,_)), _, fail)).
114114 hash_key(Term, BCount, Key) :-
115115 variant_hash(Term, IntHash),
116116 Key is (IntHash mod BCount)+1.
9797 | string | atom,string | char * |
9898 | atom | atom | atom identifier (type atomic) |
9999
100 *NOTE* This modules requires a correctly functioning plld and
100 *NOTE* This modules requires a correctly functioning swipl-ld and
101101 load_foreign_library/1 on your system. If this isn't the
102102 case use make_foreign_wrapper_file/[1,2] to generate a
103103 wrapper and use static embedding.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.21</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="limits.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="IDE.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:64bits"><a id="sec:2.21"><span class="sec-nr">2.21</span> <span class="sec-title">SWI-Prolog
194 <h2 id="sec:64bits"><a name="sec:2.21"><span class="sec-nr">2.21</span> <span class="sec-title">SWI-Prolog
236195 and 64-bit machines</span></a></h2>
237196
238 <a id="sec:64bits"></a>
239
240 <p><a id="idx:bits64:285"></a>Most of today's 64-bit platforms are
197 <a name="sec:64bits"></a>
198
199 <p><a name="idx:bits64:287"></a>Most of today's 64-bit platforms are
241200 capable of running both 32-bit and 64-bit applications. This asks for
242201 some clarifications on the advantages and drawbacks of 64-bit addressing
243202 for (SWI-)Prolog.
244203
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
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
246205 platforms</span></a></h3>
247206
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.
207 <a name="sec:64bitsplatforms"></a>
208
209 <p><a name="idx:64bitsplatforms:288"></a>SWI-Prolog can be compiled for
210 a 32- or 64-bit address space on any system with a suitable C compiler.
252211 Pointer arithmetic is based on the type (u)intptr_t from <code>stdint.h</code>,
253212 with suitable emulation on MS-Windows.
254213
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
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
256215 32- and 64-bits Prolog</span></a></h3>
257216
258 <a id="sec:32vs64bits"></a>
217 <a name="sec:32vs64bits"></a>
259218
260219 <p>Most of Prolog's memory usage consists of pointers. This indicates
261220 the primary drawback: Prolog memory usage almost doubles when using the
274233
275234 <p>Multi-threaded applications profit much more because every thread has
276235 its own set of stacks. The Prolog stacks start small and are dynamically
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
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
281240 over Prolog data structures is removed from most of SWI-Prolog. When
282241 removed from all predicates it will often be possible to use lower
283242 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>
284243
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
244 <p><a name="idx:IA32:289"></a><a name="idx:AMD64:290"></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
289248 architectures. Here, it appears that the loss is compensated for by an
290249 instruction set that has been optimized for modern programming. In
291250 particular, the AMD64 has more registers and the relative addressing
293252 degradation when placing the SWI-Prolog kernel in a Unix shared object,
294253 we cannot find a measurable difference on AMD64.
295254
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
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
297256 between 32- and 64-bit Prolog</span></a></h3>
298257
299 <a id="sec:32vs64bitschoice"></a>
258 <a name="sec:32vs64bitschoice"></a>
300259
301260 <p>For those cases where we can choose between 32 and 64 bits, either
302261 because the hardware and OS support both or because we can still choose
321280 of 32-bit hardware is 4GB, but in many cases the operating system
322281 provides less to user applications.
323282
324 <p><a id="idx:RDFmemoryusage:289"></a>The only standard SWI-Prolog
283 <p><a name="idx:RDFmemoryusage:291"></a>The only standard SWI-Prolog
325284 library adding significantly to this calculation is the RDF database
326285 provided by the <em>semweb</em> package. It uses approximately 80 bytes
327286 per triple on 32-bit hardware and 150 bytes on 64-bit hardware. Details
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
233192 <a class="nav" href="DocIndex.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235194
236 <h1><a id="sec:G"><span class="sec-nr">G</span> <span class="sec-title">Bibliography</span></a></h1>
195 <h1><a name="sec:G"><span class="sec-nr">G</span> <span class="sec-title">Bibliography</span></a></h1>
237196
238197 <dl class="bib">
239 <dt class="bib"><a id="Bowen:83"><strong>Bowen <em>et al.</em>, 1983</strong></a></dt>
198 <dt class="bib"><a name="Bowen:83"><strong>Bowen <em>et al.</em>, 1983</strong></a></dt>
240199 <dd class="bib">
241200 D.&nbsp;L. Bowen, L.&nbsp;M. Byrd, and WF. Clocksin. A portable Prolog
242201 compiler. In L.&nbsp;M. Pereira, editor, <em>Proceedings of the Logic
243202 Programming Workshop 1983</em>, Lisabon, Portugal, 1983. Universidade
244203 nova de Lisboa.</dd>
245 <dt class="bib"><a id="Bratko:86"><strong>Bratko, 1986</strong></a></dt>
204 <dt class="bib"><a name="Bratko:86"><strong>Bratko, 1986</strong></a></dt>
246205 <dd class="bib">
247206 I.&nbsp;Bratko.
248207 <em>Prolog Programming for Artificial Intelligence</em>. Addison-Wesley,
249208 Reading, Massachusetts, 1986.</dd>
250 <dt class="bib"><a id="Butenhof:1997:PPT"><strong>Butenhof, 1997</strong></a></dt>
209 <dt class="bib"><a name="Butenhof:1997:PPT"><strong>Butenhof, 1997</strong></a></dt>
251210 <dd class="bib">
252211 David&nbsp;R. Butenhof.
253212 <em>Programming with POSIX threads</em>. Ad d i s on-Wes l ey, Reading,
254213 MA, USA, 1997.</dd>
255 <dt class="bib"><a id="Byrd:80"><strong>Byrd, 1980</strong></a></dt>
214 <dt class="bib"><a name="Byrd:80"><strong>Byrd, 1980</strong></a></dt>
256215 <dd class="bib">
257216 L.&nbsp;Byrd. Understanding the control flow of Prolog programs.
258217 <em>Logic Programming Workshop</em>, 1980.</dd>
259 <dt class="bib"><a id="Clocksin:87"><strong>Clocksin &amp; Melish, 1987</strong></a></dt>
218 <dt class="bib"><a name="Clocksin:87"><strong>Clocksin &amp; Melish,
219 1987</strong></a></dt>
260220 <dd class="bib">
261221 W.&nbsp;F. Clocksin and C.&nbsp;S. Melish.
262222 <em>Programming in Prolog</em>. Springer-Verlag, New York, Third, Revised
263223 and Extended edition, 1987.</dd>
264 <dt class="bib"><a id="Demoen:CW350"><strong>Demoen, 2002</strong></a></dt>
224 <dt class="bib"><a name="Demoen:CW350"><strong>Demoen, 2002</strong></a></dt>
265225 <dd class="bib">
266226 Bart Demoen.
267227 Dynamic attributes, their hProlog implementation, and a first
268228 evaluation. Report CW 350, Department of Computer Science, K.U.Leuven,
269229 Leuven, Belgium, oct 2002. URL =
270230 http://www.cs.kuleuven.ac.be/publicaties/rapporten/cw/CW350.abs.html.</dd>
271 <dt class="bib"><a id="DBLP:journals/tplp/DesouterDS15"><strong>Desouter <em>et
231 <dt class="bib"><a name="DBLP:journals/tplp/DesouterDS15"><strong>Desouter <em>et
272232 al.</em>, 2015</strong></a></dt>
273233 <dd class="bib">
274234 Benoit Desouter, Marko van Dooren, and Tom Schrijvers. Tabling as a
275235 library with delimited control.
276236 <em>TPLP</em>, 15(4-5):419--433, 2015.</dd>
277 <dt class="bib"><a id="oai:CiteSeerPSU:36493"><strong>Freire <em>et al.</em>,
278 1997</strong></a></dt>
237 <dt class="bib"><a name="oai:CiteSeerPSU:36493"><strong>Freire <em>et
238 al.</em>, 1997</strong></a></dt>
279239 <dd class="bib">
280240 Juliana Freire, David&nbsp;S. Warren, Konstantinos Sagonas, Prasad Rao,
281241 and Terrance Swift.
282242 XSB: A system for efficiently computing well-founded semantics. In <em>Proceedings
283243 of LPNMR 97</em>, pages 430--440, Berlin, Germany, jan 1997. Springer
284244 Verlag. LNCS 1265.</dd>
285 <dt class="bib"><a id="chrSite"><strong>Fr&uuml;hwirth,</strong></a></dt>
245 <dt class="bib"><a name="chrSite"><strong>Fr&uuml;hwirth,</strong></a></dt>
286246 <dd class="bib">
287247 T.&nbsp;Fr&uuml;hwirth. Thom Fruehwirth's constraint handling rules
288248 website. http://www.constraint-handling-rules.org.</dd>
289 <dt class="bib"><a id="Freuhwirth:2009"><strong>Fr&uuml;hwirth, 2009</strong></a></dt>
249 <dt class="bib"><a name="Freuhwirth:2009"><strong>Fr&uuml;hwirth, 2009</strong></a></dt>
290250 <dd class="bib">
291251 T.&nbsp;Fr&uuml;hwirth.
292252 <em>Constraint Handling Rules</em>. Cambridge University Press, 2009.</dd>
293 <dt class="bib"><a id="graham82gprof"><strong>Graham <em>et al.</em>,
253 <dt class="bib"><a name="graham82gprof"><strong>Graham <em>et al.</em>,
294254 1982</strong></a></dt>
295255 <dd class="bib">
296256 Susan&nbsp;L. Graham, Peter&nbsp;B. Kessler, and Marshall&nbsp;K.
297257 McKusick. gprof: a call graph execution profiler. In <em>SIGPLAN
298258 Symposium on Compiler Construction</em>, pages 120--126, 1982.</dd>
299 <dt class="bib"><a id="stdprolog:98"><strong>Hodgson, 1998</strong></a></dt>
259 <dt class="bib"><a name="stdprolog:98"><strong>Hodgson, 1998</strong></a></dt>
300260 <dd class="bib">
301261 Jonathan Hodgson. validation suite for conformance with part 1 of the
302262 standard, 1998,
303263 <a class="url" href="http://www.sju.edu/~jhodgson/pub/suite.tar.gz">http://www.sju.edu/~jhodgson/pub/suite.tar.gz</a>.</dd>
304 <dt class="bib"><a id="holzbaur:1992"><strong>Holzbaur, 1992</strong></a></dt>
264 <dt class="bib"><a name="holzbaur:1992"><strong>Holzbaur, 1992</strong></a></dt>
305265 <dd class="bib">
306266 Christian Holzbaur. Metastructures versus attributed variables in the
307267 context of extensible unification. In <em>PLILP</em>, volume 631, pages
308268 260--268. Springer-Verlag, 1992. LNCS 631.</dd>
309 <dt class="bib"><a id="Kernighan:78"><strong>Kernighan &amp; Ritchie,
269 <dt class="bib"><a name="Kernighan:78"><strong>Kernighan &amp; Ritchie,
310270 1978</strong></a></dt>
311271 <dd class="bib">
312272 B.&nbsp;W. Kernighan and D.&nbsp;M. Ritchie.
313273 <em>The C Programming Language</em>. Prentice-Hall, Englewood Cliffs,
314274 New Jersey, 1978.</dd>
315 <dt class="bib"><a id="Neumerkel:93"><strong>Neumerkel, 1993</strong></a></dt>
275 <dt class="bib"><a name="Neumerkel:93"><strong>Neumerkel, 1993</strong></a></dt>
316276 <dd class="bib">
317277 Ulrich Neumerkel. The binary WAM, a simplified Prolog engine. Technical
318278 report, Technische Universit&auml;t Wien , 1993.
319279 http://www.complang.tuwien.ac.at/ulrich/papers/PDF/binwam-nov93.pdf.</dd>
320 <dt class="bib"><a id="Keefe:90"><strong>O'Keefe, 1990</strong></a></dt>
280 <dt class="bib"><a name="Keefe:90"><strong>O'Keefe, 1990</strong></a></dt>
321281 <dd class="bib">
322282 R.&nbsp;A. O'Keefe.
323283 <em>The Craft of Prolog</em>. MIT Press, Massachussetts, 1990.</dd>
324 <dt class="bib"><a id="CPROLOG:manual"><strong>Pereira, 1986</strong></a></dt>
284 <dt class="bib"><a name="CPROLOG:manual"><strong>Pereira, 1986</strong></a></dt>
325285 <dd class="bib">
326286 F.&nbsp;Pereira.
327287 <em>C-Prolog User's Manual</em>. EdCaad, University of Edinburgh, 1986.</dd>
328 <dt class="bib"><a id="QUINTUS:manual"><strong>Qui, 1997</strong></a></dt>
288 <dt class="bib"><a name="QUINTUS:manual"><strong>Qui, 1997</strong></a></dt>
329289 <dd class="bib">
330290 AI International ltd., Berkhamsted, UK.
331291 <em>Quintus Prolog, User Guide and Reference Manual</em>, 1997.</dd>
332 <dt class="bib"><a id="logicalloops:2002"><strong>Schimpf, 2002</strong></a></dt>
292 <dt class="bib"><a name="logicalloops:2002"><strong>Schimpf, 2002</strong></a></dt>
333293 <dd class="bib">
334294 Joachim Schimpf. Logical loops. In PeterJ. Stuckey, editor, <em>Logic
335295 Programming</em>, volume 2401 of
336296 <em>Lecture Notes in Computer Science</em>, pages 224--238. Springer
337297 Berlin Heidelberg, 2002.</dd>
338 <dt class="bib"><a id="DBLP:journals/tplp/SchrijversDDW13"><strong>Schrijvers <em>et
298 <dt class="bib"><a name="DBLP:journals/tplp/SchrijversDDW13"><strong>Schrijvers <em>et
339299 al.</em>, 2013</strong></a></dt>
340300 <dd class="bib">
341301 Tom Schrijvers, Bart Demoen, Benoit Desouter, and Jan Wielemaker.
342302 Delimited continuations for prolog.
343303 <em>TPLP</em>, 13(4-5):533--546, 2013.</dd>
344 <dt class="bib"><a id="Sterling:86"><strong>Sterling &amp; Shapiro, 1986</strong></a></dt>
304 <dt class="bib"><a name="Sterling:86"><strong>Sterling &amp; Shapiro,
305 1986</strong></a></dt>
345306 <dd class="bib">
346307 L.&nbsp;Sterling and E.&nbsp;Shapiro.
347308 <em>The Art of Prolog</em>. MIT Press, Cambridge, Massachusetts, 1986.</dd>
348 <dt class="bib"><a id="DBLP:conf/coordination/Tarau11"><strong>Tarau,
309 <dt class="bib"><a name="DBLP:conf/coordination/Tarau11"><strong>Tarau,
349310 2011</strong></a></dt>
350311 <dd class="bib">
351312 Paul Tarau. Coordination and concurrency in multi-engine prolog. In
354315 COORDINATION 2011, Reykjavik, Iceland, June 6-9, 2011. Proceedings</em>,
355316 volume 6721 of <em>Lecture Notes in Computer Science</em>, pages
356317 157--171. Springer, 2011.</dd>
357 <dt class="bib"><a id="clpb:Triska2016"><strong>Triska, 2016</strong></a></dt>
318 <dt class="bib"><a name="clpb:Triska2016"><strong>Triska, 2016</strong></a></dt>
358319 <dd class="bib">
359320 Markus Triska. The Boolean constraint solver of SWI-Prolog: System
360321 description. In <em>FLOPS</em>, volume 9613 of <em>LNCS</em>, pages
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
233192 <a class="nav" href="intro.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235194
236 <h1><a id="document-contents">Table of Contents</a></h1>
195 <h1><a name="document-contents">Table of Contents</a></h1>
237196
238197 <div class="toc">
239198 <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.7.4 Reference Manual: Section 4.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="signal.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="db.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:DCG"><a id="sec:4.13"><span class="sec-nr">4.13</span> <span class="sec-title">DCG
194 <h2 id="sec:DCG"><a name="sec:4.13"><span class="sec-nr">4.13</span> <span class="sec-title">DCG
236195 Grammar rules</span></a></h2>
237196
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
197 <a name="sec:DCG"></a>
198
199 <p><a name="idx:DCG:779"></a><a name="idx:serialize:780"></a><a name="idx:deserialize:781"></a>Grammar
241200 rules form a comfortable interface to <em>difference lists</em>. They
242201 are designed both to support writing parsers that build a parse tree
243202 from a list of characters or tokens and for generating a flat list from
245204
246205 <p>Grammar rules look like ordinary clauses using <code><code>--&gt;</code>/2</code>
247206 for separating the head and body rather than <code><code>:-</code>/2</code>.
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>,
207 Expanding grammar rules is done by <a name="idx:expandterm2:782"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>,
249208 which adds two additional arguments to each term for representing the
250209 difference list.
251210
280239 }.
281240 </pre>
282241
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>:
242 <p>Grammar rule sets are called using the built-in predicates <a name="idx:phrase2:783"></a><a class="pred" href="DCG.html#phrase/2">phrase/2</a>
243 and <a name="idx:phrase3:784"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>:
285244
286245 <dl class="latex">
287 <dt class="pubdef"><a id="phrase/2"><strong>phrase</strong>(<var>:DCGBody,
246 <dt class="pubdef"><a name="phrase/2"><strong>phrase</strong>(<var>:DCGBody,
288247 ?List</var>)</a></dt>
289248 <dd class="defbody">
290249 Equivalent to <code>phrase(<var>DCGBody</var>, <var>InputList</var>, [])</code>.
291250 </dd>
292 <dt class="pubdef"><a id="phrase/3"><strong>phrase</strong>(<var>:DCGBody,
251 <dt class="pubdef"><a name="phrase/3"><strong>phrase</strong>(<var>:DCGBody,
293252 ?List, ?Rest</var>)</a></dt>
294253 <dd class="defbody">
295254 True when <var>DCGBody</var> applies to the difference
298257 <em>callable</em> term that denotes a grammar rule, it can be any term
299258 that is valid as the body of a DCG rule.
300259
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>
260 <p>The example below calls the rule set <a name="idx:integer1:785"></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>
304263 to the remainder of the input after matching the integer.
305264
306265 <pre class="code">
312271 </pre>
313272
314273 <p>The next example exploits a complete body. Given the following
315 definition of digit_weight//1 , we can pose the query below.
274 definition of digit_weight1, we can pose the query below.
316275
317276 <pre class="code">
318277 digit_weight(W) --&gt;
329288 Minor = 4.
330289 </pre>
331290
332 <p>The SWI-Prolog implementation of <a id="idx:phrase3:784"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
291 <p>The SWI-Prolog implementation of <a name="idx:phrase3:786"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
333292 verifies that the <var>List</var> and <var>Rest</var> arguments are
334293 unbound, bound to the empty list or a list
335 <em>cons cell</em>. Other values raise a type error.<sup class="fn">71<span class="fn-text">The
294 <em>cons cell</em>. Other values raise a type error.<sup class="fn">70<span class="fn-text">The
336295 ISO standard allows for both raising a type error and accepting any term
337296 as input and output. Note the tail of the list is not checked for
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>
297 performance reasons.</span></sup> The predicate <a name="idx:calldcg3:787"></a><a class="pred" href="DCG.html#call_dcg/3">call_dcg/3</a>
339298 is provided to use grammar rules with terms that are not lists.
340299
341300 <p>Note that the syntax for lists of codes changed in SWI-Prolog version&nbsp;7
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>.
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:788"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.
347305 This is typically not a problem for applications as the input of a DCG
348306 rarely appears in the source code. For testing in the toplevel, one must
349307 use double quoted text in versions prior to&nbsp;7 and back quoted text
350308 in version&nbsp;7 or later.
351309
352 <p>See also <a id="idx:portraytext1:787"></a><span class="pred-ext">portray_text/1</span>,
310 <p>See also <a name="idx:portraytext1:789"></a><span class="pred-ext">portray_text/1</span>,
353311 which can be used to print lists of character codes as a string to the
354312 top level and debugger to facilitate debugging DCGs that process
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>
313 character codes. The library <code>library(apply_macros)</code> compiles <a name="idx:phrase3:790"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
356314 if the argument is sufficiently instantiated, eliminating the runtime
357315 overhead of translating <var>DCGBody</var> and meta-calling.</dd>
358 <dt class="pubdef"><a id="call_dcg/3"><strong>call_dcg</strong>(<var>:DCGBody,
316 <dt class="pubdef"><a name="call_dcg/3"><strong>call_dcg</strong>(<var>:DCGBody,
359317 ?State0, ?State</var>)</a></dt>
360318 <dd class="defbody">
361 As <a id="idx:phrase3:789"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>,
319 As <a name="idx:phrase3:791"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>,
362320 but without type checking <var>State0</var> and <var>State</var>. This
363321 allows for using DCG rules for threading an arbitrary state variable.
364322 This predicate was introduced after type checking was added to
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
323 <a name="idx:phrase3:792"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.<sup class="fn">71<span class="fn-text">After
366324 discussion with Samer Abdallah.</span></sup>
367325
368326 <p>A portable solution for threading state through a DCG can be
369327 implemented by wrapping the state in a list and use the DCG semicontext
370328 facility. Subsequently, the following predicates may be used to access
371 and modify the state:<sup class="fn">73<span class="fn-text">This
329 and modify the state:<sup class="fn">72<span class="fn-text">This
372330 solution was proposed by Markus Triska.</span></sup>
373331
374332 <pre class="code">
381339
382340 <p>As stated above, grammar rules are a general interface to difference
383341 lists. To illustrate, we show a DCG-based implementation of
384 <a id="idx:reverse2:791"></a><a class="pred" href="lists.html#reverse/2">reverse/2</a>:
342 <a name="idx:reverse2:793"></a><a class="pred" href="lists.html#reverse/2">reverse/2</a>:
385343
386344 <pre class="code">
387345 reverse(List, Reversed) :-
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.43</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="memory.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="miscpreds.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:DDE"><a id="sec:4.43"><span class="sec-nr">4.43</span> <span class="sec-title">Windows
194 <h2 id="sec:DDE"><a name="sec:4.43"><span class="sec-nr">4.43</span> <span class="sec-title">Windows
236195 DDE interface</span></a></h2>
237196
238 <a id="sec:DDE"></a>
197 <a name="sec:DDE"></a>
239198
240199 <p>The predicates in this section deal with MS-Windows `Dynamic Data
241200 Exchange' or DDE protocol.<sup class="fn">141<span class="fn-text">This
253212 error(dde_error(Operation, Message), Context)
254213 </pre>
255214
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
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
257216 client interface</span></a></h3>
258217
259 <a id="sec:dde-client"></a>
218 <a name="sec:dde-client"></a>
260219
261220 <p>The DDE client interface allows Prolog to talk to DDE server
262221 programs. We will demonstrate the use of the DDE interface using the
283242 setup scripts in Prolog.
284243
285244 <dl class="latex">
286 <dt class="pubdef"><a id="open_dde_conversation/3"><strong>open_dde_conversation</strong>(<var>+Service,
245 <dt class="pubdef"><a name="open_dde_conversation/3"><strong>open_dde_conversation</strong>(<var>+Service,
287246 +Topic, -Handle</var>)</a></dt>
288247 <dd class="defbody">
289248 Open a conversation with a server supporting the given service name and
290249 topic (atoms). If successful, <var>Handle</var> may be used to send
291250 transactions to the server. If no willing server is found this predicate
292251 fails silently.</dd>
293 <dt class="pubdef"><a id="close_dde_conversation/1"><strong>close_dde_conversation</strong>(<var>+Handle</var>)</a></dt>
252 <dt class="pubdef"><a name="close_dde_conversation/1"><strong>close_dde_conversation</strong>(<var>+Handle</var>)</a></dt>
294253 <dd class="defbody">
295254 Close the conversation associated with <var>Handle</var>. All opened
296255 conversations should be closed when they're no longer needed, although
297256 the system will close any that remain open on process termination.</dd>
298 <dt class="pubdef"><a id="dde_request/3"><strong>dde_request</strong>(<var>+Handle,
257 <dt class="pubdef"><a name="dde_request/3"><strong>dde_request</strong>(<var>+Handle,
299258 +Item, -Value</var>)</a></dt>
300259 <dd class="defbody">
301260 Request a value from the server. <var>Item</var> is an atom that
302261 identifies the requested data, and <var>Value</var> will be a string (<code>CF_TEXT</code>
303262 data in DDE parlance) representing that data, if the request is
304263 successful.</dd>
305 <dt class="pubdef"><a id="dde_execute/2"><strong>dde_execute</strong>(<var>+Handle,
264 <dt class="pubdef"><a name="dde_execute/2"><strong>dde_execute</strong>(<var>+Handle,
306265 +Command</var>)</a></dt>
307266 <dd class="defbody">
308267 Request the DDE server to execute the given command string. Succeeds if
309268 the command could be executed and fails with an error message otherwise.</dd>
310 <dt class="pubdef"><a id="dde_poke/4"><strong>dde_poke</strong>(<var>+Handle,
269 <dt class="pubdef"><a name="dde_poke/4"><strong>dde_poke</strong>(<var>+Handle,
311270 +Item, +Command</var>)</a></dt>
312271 <dd class="defbody">
313272 Issue a <code>POKE</code> command to the server on the specified <var>Item</var>.
315274 </dd>
316275 </dl>
317276
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
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
319278 server mode</span></a></h3>
320279
321 <a id="sec:dde-server"></a>
280 <a name="sec:dde-server"></a>
322281
323282 <p>The <code>library(dde)</code> defines primitives to realise simple
324283 DDE server applications in SWI-Prolog. These features are provided as of
327286 provided by this interface, please study <code>library(dde)</code>.
328287
329288 <dl class="latex">
330 <dt class="pubdef"><a id="dde_register_service/2"><strong>dde_register_service</strong>(<var>+Template,
289 <dt class="pubdef"><a name="dde_register_service/2"><strong>dde_register_service</strong>(<var>+Template,
331290 +Goal</var>)</a></dt>
332291 <dd class="defbody">
333292 Register a server to handle DDE request or DDE <code>execute</code>
344303 to version 3.4.5 this was a list of character codes. As recent versions
345304 have atom garbage collection there is no need for this anymore.</span></sup>
346305
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>
306 <p>The example below registers the Prolog <a name="idx:currentprologflag2:1588"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
348307 predicate to be accessible from other applications. The request may be
349308 given from the same Prolog as well as from another application.
350309
368327 requests either succeed or fail. If <var>Goal</var> fails, a `not
369328 processed' is passed back to the caller of the DDE request.
370329 </dd>
371 <dt class="pubdef"><a id="dde_unregister_service/1"><strong>dde_unregister_service</strong>(<var>+Service</var>)</a></dt>
330 <dt class="pubdef"><a name="dde_unregister_service/1"><strong>dde_unregister_service</strong>(<var>+Service</var>)</a></dt>
372331 <dd class="defbody">
373332 Stop responding to <var>Service</var>. If Prolog is halted, it will
374333 automatically call this on all open services.
375334 </dd>
376 <dt class="pubdef"><a id="dde_current_service/2"><strong>dde_current_service</strong>(<var>-Service,
335 <dt class="pubdef"><a name="dde_current_service/2"><strong>dde_current_service</strong>(<var>-Service,
377336 -Topic</var>)</a></dt>
378337 <dd class="defbody">
379338 Find currently registered services and the topics served on them.
380339 </dd>
381 <dt class="pubdef"><a id="dde_current_connection/2"><strong>dde_current_connection</strong>(<var>-Service,
340 <dt class="pubdef"><a name="dde_current_connection/2"><strong>dde_current_connection</strong>(<var>-Service,
382341 -Topic</var>)</a></dt>
383342 <dd class="defbody">
384343 Find currently open conversations.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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;
19 dt.pubdef
20 { background-color: #c5e1ff;
2621 }
2722
28 dt.pubdef { background-color: #0c3d6e; }
29 dt.multidef { background-color: #ef9439; }
23 dt.multidef
24 { background-color: #c8ffc7;
25 }
3026
3127 .bib dd
3228 { margin-bottom: 1em;
120116 padding-top: 0.2em;
121117 font-size: 80%;
122118 font-style: italic;
123 color: #fff;
119 color: #202020;
124120 }
125121
126122 div.caption
130126 }
131127
132128 /* Footnotes */
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;
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;
154140 }
155141
156142 /* Lists */
194180 font-size: +1;
195181 margin-top: 1ex;
196182 }
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
224183 </style>
225184 </head>
226185 <body style="background:white">
231190 <a class="nav" href="Bibliography.html"><img src="prev.gif" alt="Previous"></a>
232191 </div>
233192
234 <h1><a id="document-index">Index</a></h1>
193 <h1><a name="document-index">Index</a></h1>
235194
236195 <dl>
237196 <dt class="index-sep">?</dt>
238197 <dt>.pl</dt>
239198 <dd>
240 <a class="idx" href="projectfiles.html#idx:pl:292">3.1.1.1</a></dd>
199 <a class="idx" href="projectfiles.html#idx:pl:294">3.1.1.1</a></dd>
241200 <dt>.pro</dt>
242201 <dd>
243 <a class="idx" href="projectfiles.html#idx:pro:293">3.1.1.1</a></dd>
202 <a class="idx" href="projectfiles.html#idx:pro:295">3.1.1.1</a></dd>
244203 <dt>64-bits,platforms</dt>
245204 <dd>
246 <a class="idx" href="64bits.html#idx:64bitsplatforms:286">2.21.1</a></dd>
205 <a class="idx" href="64bits.html#idx:64bitsplatforms:288">2.21.1</a></dd>
247206 <dt><a class="idx" href="db.html#abolish/1">abolish/1</a></dt>
248207 <dd>
249 <a class="idx" href="db.html#idx:abolish1:814">4.14.1</a> <a class="idx" href="db.html#idx:abolish1:817">4.14.1</a> <a class="idx" href="db.html#idx:abolish1:818">4.14.1</a> <a class="idx" href="db.html#idx:abolish1:821">4.14.1</a></dd>
208 <a class="idx" href="db.html#idx:abolish1:816">4.14.1</a> <a class="idx" href="db.html#idx:abolish1:819">4.14.1</a> <a class="idx" href="db.html#idx:abolish1:820">4.14.1</a> <a class="idx" href="db.html#idx:abolish1:823">4.14.1</a></dd>
250209 <dt><a class="idx" href="db.html#abolish/2">abolish/2</a></dt>
251210 <dd>
252 <a class="idx" href="db.html#idx:abolish2:820">4.14.1</a></dd>
211 <a class="idx" href="db.html#idx:abolish2:822">4.14.1</a></dd>
253212 <dt>abolish/[1,2]</dt>
254213 <dd>
255 <a class="idx" href="flags.html#idx:abolish12:118">2.11</a></dd>
214 <a class="idx" href="flags.html#idx:abolish12:120">2.11</a></dd>
256215 <dt><a class="idx" href="tabling.html#abolish_all_tables/0">abolish_all_tables/0</a></dt>
257216 <dt><a class="idx" href="tabling.html#abolish_table_subgoals/1">abolish_table_subgoals/1</a></dt>
258217 <dt><a class="idx" href="toplevel.html#abort/0">abort/0</a></dt>
259218 <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>
219 <a class="idx" href="cmdline.html#idx:abort0:46">2.4.4</a> <a class="idx" href="debugoverview.html#idx:abort0:67">2.9</a> <a class="idx" href="exception.html#idx:abort0:712">4.11</a> <a class="idx" href="exception.html#idx:abort0:714">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:719">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:722">4.11.1</a> <a class="idx" href="exception.html#idx:abort0:723">4.11.1</a> <a class="idx" href="IO.html#idx:abort0:978">4.17.2</a> <a class="idx" href="IO.html#idx:abort0:986">4.17.2</a> <a class="idx" href="IO.html#idx:abort0:1020">4.17.2</a> <a class="idx" href="debugging.html#idx:abort0:1820">8.4.2</a> <a class="idx" href="foreigninclude.html#idx:abort0:2067">11.4.16</a> <a class="idx" href="foreigninclude.html#idx:abort0:2071">11.4.19</a> <a class="idx" href="foreigninclude.html#idx:abort0:2072">11.4.19</a> <a class="idx" href="tracehook.html#idx:abort0:2197">B.3</a></dd>
261220 <dt><a class="idx" href="files.html#absolute_file_name/2">absolute_file_name/2</a></dt>
262221 <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>
222 <a class="idx" href="acknowledge.html#idx:absolutefilename2:5">1.6</a> <a class="idx" href="consulting.html#idx:absolutefilename2:399">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename2:475">4.3</a> <a class="idx" href="files.html#idx:absolutefilename2:1515">4.36</a> <a class="idx" href="files.html#idx:absolutefilename2:1521">4.36</a> <a class="idx" href="useresource.html#idx:absolutefilename2:2127">12.3.1</a></dd>
264223 <dt><a class="idx" href="files.html#absolute_file_name/3">absolute_file_name/3</a></dt>
265224 <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>
225 <a class="idx" href="flags.html#idx:absolutefilename3:114">2.11</a> <a class="idx" href="flags.html#idx:absolutefilename3:136">2.11</a> <a class="idx" href="hooks.html#idx:absolutefilename3:173">2.12</a> <a class="idx" href="hooks.html#idx:absolutefilename3:174">2.12</a> <a class="idx" href="packs.html#idx:absolutefilename3:210">2.14</a> <a class="idx" href="xref.html#idx:absolutefilename3:326">3.7</a> <a class="idx" href="consulting.html#idx:absolutefilename3:365">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:367">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:466">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:471">4.3</a> <a class="idx" href="consulting.html#idx:absolutefilename3:497">4.3</a> <a class="idx" href="system.html#idx:absolutefilename3:1476">4.35.1</a> <a class="idx" href="files.html#idx:absolutefilename3:1506">4.36</a> <a class="idx" href="files.html#idx:absolutefilename3:1508">4.36</a> <a class="idx" href="foreigninclude.html#idx:absolutefilename3:2058">11.4.14.3</a> <a class="idx" href="foreigninclude.html#idx:absolutefilename3:2059">11.4.14.3</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2161">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2162">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2165">A.30</a> <a class="idx" href="readutil.html#idx:absolutefilename3:2166">A.30</a></dd>
267226 <dt>absolute_file_name/[2,3]</dt>
268227 <dd>
269 <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>
228 <a class="idx" href="flags.html#idx:absolutefilename23:157">2.11</a> <a class="idx" href="consulting.html#idx:absolutefilename23:470">4.3</a> <a class="idx" href="files.html#idx:absolutefilename23:1510">4.36</a></dd>
270229 <dt><a class="idx" href="files.html#access_file/2">access_file/2</a></dt>
271230 <dd>
272 <a class="idx" href="flags.html#idx:accessfile2:111">2.11</a> <a class="idx" href="flags.html#idx:accessfile2:158">2.11</a> <a class="idx" href="files.html#idx:accessfile2:1509">4.36</a></dd>
231 <a class="idx" href="flags.html#idx:accessfile2:112">2.11</a> <a class="idx" href="flags.html#idx:accessfile2:160">2.11</a> <a class="idx" href="files.html#idx:accessfile2:1511">4.36</a></dd>
273232 <dt><a class="idx" href="foreigninclude.html#acquire()">acquire()</a></dt>
274233 <dt><a class="idx" href="typetest.html#acyclic_term/1">acyclic_term/1</a></dt>
275234 <dd>
276 <a class="idx" href="cyclic.html#idx:acyclicterm1:232">2.17</a> <a class="idx" href="typetest.html#idx:acyclicterm1:620">4.6</a> <a class="idx" href="typetest.html#idx:acyclicterm1:622">4.6</a> <a class="idx" href="compare.html#idx:acyclicterm1:632">4.7.2</a></dd>
235 <a class="idx" href="cyclic.html#idx:acyclicterm1:234">2.17</a> <a class="idx" href="typetest.html#idx:acyclicterm1:622">4.6</a> <a class="idx" href="typetest.html#idx:acyclicterm1:624">4.6</a> <a class="idx" href="compare.html#idx:acyclicterm1:634">4.7.2</a></dd>
277236 <dt><a class="idx" href="ugraphs.html#add_edges/3">add_edges/3</a></dt>
278237 <dt><a class="idx" href="importmodule.html#add_import_module/3">add_import_module/3</a></dt>
279238 <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>
239 <a class="idx" href="importmodule.html#idx:addimportmodule3:1722">6.9</a> <a class="idx" href="modulecompat.html#idx:addimportmodule3:1760">6.15</a></dd>
281240 <dt><a class="idx" href="nb_set.html#add_nb_set/2">add_nb_set/2</a></dt>
282241 <dt><a class="idx" href="nb_set.html#add_nb_set/3">add_nb_set/3</a></dt>
283242 <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>
243 <a class="idx" href="nb_set.html#idx:addnbset3:2149">A.17</a> <a class="idx" href="nb_set.html#idx:addnbset3:2150">A.17</a></dd>
285244 <dt><a class="idx" href="ugraphs.html#add_vertices/3">add_vertices/3</a></dt>
286245 <dt>agent</dt>
287246 <dd>
288 <a class="idx" href="broadcast.html#idx:agent:2139">A.4</a></dd>
247 <a class="idx" href="broadcast.html#idx:agent:2138">A.4</a></dd>
289248 <dt><a class="idx" href="aggregate.html#aggregate/3">aggregate/3</a></dt>
290249 <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>
250 <a class="idx" href="db.html#idx:aggregate3:795">4.14</a> <a class="idx" href="metapred.html#idx:aggregate3:1698">6.4</a></dd>
292251 <dt><a class="idx" href="aggregate.html#aggregate/4">aggregate/4</a></dt>
293252 <dd>
294 <a class="idx" href="metapred.html#idx:aggregate4:1700">6.4</a></dd>
253 <a class="idx" href="metapred.html#idx:aggregate4:1699">6.4</a></dd>
295254 <dt><a class="idx" href="aggregate.html#aggregate_all/3">aggregate_all/3</a></dt>
296255 <dd>
297 <a class="idx" href="db.html#idx:aggregateall3:813">4.14</a></dd>
256 <a class="idx" href="db.html#idx:aggregateall3:815">4.14</a></dd>
298257 <dt><a class="idx" href="aggregate.html#aggregate_all/4">aggregate_all/4</a></dt>
299258 <dt><a class="idx" href="clpfd.html#all_different/1">all_different/1</a></dt>
300259 <dt><a class="idx" href="clpfd.html#all_distinct/1">all_distinct/1</a></dt>
301260 <dt>anonymous variable</dt>
302261 <dd>
303 <a class="idx" href="glossary.html#idx:anonymousvariable:2270">D</a></dd>
262 <a class="idx" href="glossary.html#idx:anonymousvariable:2269">D</a></dd>
304263 <dt>anonymous,variable</dt>
305264 <dd>
306 <a class="idx" href="syntax.html#idx:anonymousvariable:223">2.16.1.9</a></dd>
265 <a class="idx" href="syntax.html#idx:anonymousvariable:225">2.16.1.9</a></dd>
307266 <dt>ansi_format/3</dt>
308267 <dd>
309 <a class="idx" href="exception.html#idx:ansiformat3:760">4.11.4</a></dd>
268 <a class="idx" href="exception.html#idx:ansiformat3:762">4.11.4</a></dd>
310269 <dt>answer subsumption,tabling</dt>
311270 <dd>
312 <a class="idx" href="tabling.html#idx:answersubsumptiontabling:2178">A.35.3</a></dd>
271 <a class="idx" href="tabling.html#idx:answersubsumptiontabling:2177">A.35.3</a></dd>
313272 <dt><a class="idx" href="IO.html#append/1">append/1</a></dt>
314273 <dd>
315 <a class="idx" href="IO.html#idx:append1:1033">4.17.3</a></dd>
274 <a class="idx" href="IO.html#idx:append1:1035">4.17.3</a></dd>
316275 <dt><a class="idx" href="lists.html#append/2">append/2</a></dt>
317276 <dd>
318 <a class="idx" href="import.html#idx:append2:1682">6.3</a></dd>
277 <a class="idx" href="import.html#idx:append2:1681">6.3</a></dd>
319278 <dt><a class="idx" href="lists.html#append/3">append/3</a></dt>
320279 <dd>
321 <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>
280 <a class="idx" href="examineprog.html#idx:append3:941">4.16</a> <a class="idx" href="manipatom.html#idx:append3:1275">4.22</a></dd>
322281 <dt><a class="idx" href="metacall.html#apply/2">apply/2</a></dt>
323282 <dt><a class="idx" href="help.html#apropos/1">apropos/1</a></dt>
324283 <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>
284 <a class="idx" href="help.html#idx:apropos1:50">2.6</a> <a class="idx" href="help.html#idx:apropos1:51">2.6</a> <a class="idx" href="hooks.html#idx:apropos1:190">2.12</a> <a class="idx" href="intlibs.html#idx:apropos1:2238">B.7</a> <a class="idx" href="predsummary.html#idx:apropos1:2348">F.1</a></dd>
326285 <dt><a class="idx" href="manipterm.html#arg/3">arg/3</a></dt>
327286 <dd>
328 <a class="idx" href="manipterm.html#idx:arg3:1192">4.21</a></dd>
287 <a class="idx" href="manipterm.html#idx:arg3:1194">4.21</a></dd>
329288 <dt><a class="idx" href="main.html#argv_options/3">argv_options/3</a></dt>
330289 <dt>arithmetic_function/1</dt>
331290 <dd>
332 <a class="idx" href="foreigninclude.html#idx:arithmeticfunction1:2051">11.4.12</a></dd>
291 <a class="idx" href="foreigninclude.html#idx:arithmeticfunction1:2050">11.4.12</a></dd>
333292 <dt>arity</dt>
334293 <dd>
335 <a class="idx" href="glossary.html#idx:arity:2272">D</a></dd>
294 <a class="idx" href="glossary.html#idx:arity:2271">D</a></dd>
336295 <dt>assert</dt>
337296 <dd>
338 <a class="idx" href="glossary.html#idx:assert:2273">D</a></dd>
297 <a class="idx" href="glossary.html#idx:assert:2272">D</a></dd>
339298 <dt><a class="idx" href="db.html#assert/1">assert/1</a></dt>
340299 <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>
300 <a class="idx" href="consulting.html#idx:assert1:373">4.3</a> <a class="idx" href="db.html#idx:assert1:833">4.14.1</a> <a class="idx" href="db.html#idx:assert1:839">4.14.1</a> <a class="idx" href="db.html#idx:assert1:864">4.14.5</a> <a class="idx" href="dynamic.html#idx:assert1:882">4.15</a> <a class="idx" href="dynamic.html#idx:assert1:887">4.15</a> <a class="idx" href="dynamic.html#idx:assert1:888">4.15</a> <a class="idx" href="examineprog.html#idx:assert1:915">4.16</a> <a class="idx" href="gvar.html#idx:assert1:1413">4.33</a> <a class="idx" href="modules.html#idx:assert1:1662">6</a> <a class="idx" href="metapred.html#idx:assert1:1689">6.4</a> <a class="idx" href="threadcom.html#idx:assert1:1920">9.3.3</a></dd>
342301 <dt><a class="idx" href="db.html#assert/2">assert/2</a></dt>
343302 <dd>
344 <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>
303 <a class="idx" href="flags.html#idx:assert2:100">2.11</a> <a class="idx" href="db.html#idx:assert2:851">4.14.2</a> <a class="idx" href="examineprog.html#idx:assert2:939">4.16</a></dd>
345304 <dt><a class="idx" href="predicate_options.html#assert_predicate_options/4">assert_predicate_options/4</a></dt>
346305 <dt><a class="idx" href="db.html#asserta/1">asserta/1</a></dt>
347306 <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>
307 <a class="idx" href="cmdline.html#idx:asserta1:38">2.4.2</a> <a class="idx" href="cyclic.html#idx:asserta1:256">2.17</a> <a class="idx" href="jitindex.html#idx:asserta1:258">2.18</a> <a class="idx" href="consulting.html#idx:asserta1:463">4.3</a> <a class="idx" href="compare.html#idx:asserta1:638">4.7.2</a> <a class="idx" href="db.html#idx:asserta1:796">4.14</a> <a class="idx" href="db.html#idx:asserta1:831">4.14.1</a> <a class="idx" href="db.html#idx:asserta1:836">4.14.1</a> <a class="idx" href="db.html#idx:asserta1:837">4.14.1</a> <a class="idx" href="overrule.html#idx:asserta1:1705">6.5</a> <a class="idx" href="overrule.html#idx:asserta1:1707">6.5.1</a> <a class="idx" href="glossary.html#idx:asserta1:2273">D</a></dd>
349308 <dt><a class="idx" href="db.html#asserta/2">asserta/2</a></dt>
350309 <dd>
351 <a class="idx" href="db.html#idx:asserta2:850">4.14.2</a></dd>
310 <a class="idx" href="db.html#idx:asserta2:852">4.14.2</a></dd>
352311 <dt><a class="idx" href="debug.html#assertion/1">assertion/1</a></dt>
353312 <dd>
354 <a class="idx" href="breakpoint.html#idx:assertion1:2207">B.4</a></dd>
313 <a class="idx" href="breakpoint.html#idx:assertion1:2206">B.4</a></dd>
355314 <dt><a class="idx" href="db.html#assertz/1">assertz/1</a></dt>
356315 <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>
316 <a class="idx" href="quickstart.html#idx:assertz1:8">2.1.2</a> <a class="idx" href="consulting.html#idx:assertz1:462">4.3</a> <a class="idx" href="db.html#idx:assertz1:797">4.14</a> <a class="idx" href="db.html#idx:assertz1:824">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:834">4.14.1</a> <a class="idx" href="db.html#idx:assertz1:838">4.14.1</a> <a class="idx" href="examineprog.html#idx:assertz1:929">4.16</a> <a class="idx" href="examineprog.html#idx:assertz1:946">4.16</a> <a class="idx" href="manipmodule.html#idx:assertz1:1753">6.14</a> <a class="idx" href="clp.html#idx:assertz1:1769">7</a> <a class="idx" href="engine-examples.html#idx:assertz1:1974">10.1.2</a> <a class="idx" href="glossary.html#idx:assertz1:2274">D</a></dd>
358317 <dt><a class="idx" href="db.html#assertz/2">assertz/2</a></dt>
359318 <dd>
360 <a class="idx" href="db.html#idx:assertz2:851">4.14.2</a></dd>
319 <a class="idx" href="db.html#idx:assertz2:853">4.14.2</a></dd>
361320 <dt><a class="idx" href="simplex.html#assignment/2">assignment/2</a></dt>
362321 <dt><a class="idx" href="assoc.html#assoc_to_keys/2">assoc_to_keys/2</a></dt>
363322 <dt><a class="idx" href="assoc.html#assoc_to_list/2">assoc_to_list/2</a></dt>
365324 <dt><a class="idx" href="chario.html#at_end_of_stream/0">at_end_of_stream/0</a></dt>
366325 <dt><a class="idx" href="chario.html#at_end_of_stream/1">at_end_of_stream/1</a></dt>
367326 <dd>
368 <a class="idx" href="chario.html#idx:atendofstream1:1107">4.19</a></dd>
327 <a class="idx" href="chario.html#idx:atendofstream1:1109">4.19</a></dd>
369328 <dt>at_end_of_stream/[0,1]</dt>
370329 <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>
330 <a class="idx" href="IO.html#idx:atendofstream01:987">4.17.2</a> <a class="idx" href="readutil.html#idx:atendofstream01:2158">A.30</a></dd>
372331 <dt><a class="idx" href="consulting.html#at_halt/1">at_halt/1</a></dt>
373332 <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>
333 <a class="idx" href="flags.html#idx:athalt1:109">2.11</a> <a class="idx" href="consulting.html#idx:athalt1:503">4.3</a> <a class="idx" href="toplevel.html#idx:athalt1:1532">4.37</a> <a class="idx" href="threadcreate.html#idx:athalt1:1868">9.1</a> <a class="idx" href="foreigninclude.html#idx:athalt1:2073">11.4.19</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:2086">11.4.21</a> <a class="idx" href="predsummary.html#idx:athalt1:2355">F.1</a></dd>
375334 <dt>atom</dt>
376335 <dd>
377 <a class="idx" href="glossary.html#idx:atom:2276">D</a></dd>
336 <a class="idx" href="glossary.html#idx:atom:2275">D</a></dd>
378337 <dt><a class="idx" href="typetest.html#atom/1">atom/1</a></dt>
379338 <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>
339 <a class="idx" href="typetest.html#idx:atom1:606">4.6</a> <a class="idx" href="coroutining.html#idx:atom1:1798">7.2</a> <a class="idx" href="foreigninclude.html#idx:atom1:2019">11.4.3</a></dd>
381340 <dt><a class="idx" href="manipatom.html#atom_chars/2">atom_chars/2</a></dt>
382341 <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>
342 <a class="idx" href="chars.html#idx:atomchars2:347">4.2</a> <a class="idx" href="IO.html#idx:atomchars2:1061">4.17.5</a> <a class="idx" href="chario.html#idx:atomchars2:1086">4.19</a> <a class="idx" href="manipatom.html#idx:atomchars2:1248">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="manipatom.html#idx:atomchars2:1255">4.22</a> <a class="idx" href="chartype.html#idx:atomchars2:1300">4.24</a> <a class="idx" href="ext-issues.html#idx:atomchars2:1659">5.6</a></dd>
384343 <dt><a class="idx" href="manipatom.html#atom_codes/2">atom_codes/2</a></dt>
385344 <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>
345 <a class="idx" href="chars.html#idx:atomcodes2:345">4.2</a> <a class="idx" href="chars.html#idx:atomcodes2:348">4.2</a> <a class="idx" href="IO.html#idx:atomcodes2:1060">4.17.5</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1242">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1245">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:1254">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1259">4.22</a> <a class="idx" href="manipatom.html#idx:atomcodes2:1265">4.22</a> <a class="idx" href="chartype.html#idx:atomcodes2:1301">4.24</a> <a class="idx" href="ext-issues.html#idx:atomcodes2:1658">5.6</a></dd>
387346 <dt><a class="idx" href="manipatom.html#atom_concat/3">atom_concat/3</a></dt>
388347 <dd>
389 <a class="idx" href="strings.html#idx:atomconcat3:1602">5.2.1</a></dd>
348 <a class="idx" href="strings.html#idx:atomconcat3:1605">5.2.1</a></dd>
390349 <dt><a class="idx" href="manipatom.html#atom_length/2">atom_length/2</a></dt>
391350 <dd>
392 <a class="idx" href="flags.html#idx:atomlength2:116">2.11</a> <a class="idx" href="strings.html#idx:atomlength2:1599">5.2.1</a></dd>
351 <a class="idx" href="flags.html#idx:atomlength2:118">2.11</a> <a class="idx" href="strings.html#idx:atomlength2:1602">5.2.1</a></dd>
393352 <dt><a class="idx" href="manipatom.html#atom_number/2">atom_number/2</a></dt>
394353 <dd>
395 <a class="idx" href="IO.html#idx:atomnumber2:1053">4.17.5</a> <a class="idx" href="manipatom.html#idx:atomnumber2:1260">4.22</a> <a class="idx" href="manipatom.html#idx:atomnumber2:1265">4.22</a></dd>
354 <a class="idx" href="IO.html#idx:atomnumber2:1055">4.17.5</a> <a class="idx" href="manipatom.html#idx:atomnumber2:1262">4.22</a> <a class="idx" href="manipatom.html#idx:atomnumber2:1267">4.22</a></dd>
396355 <dt><a class="idx" href="manipatom.html#atom_prefix/2">atom_prefix/2</a></dt>
397356 <dt>atom_result/2</dt>
398357 <dd>
399 <a class="idx" href="ctxmodule.html#idx:atomresult2:1745">6.13</a></dd>
358 <a class="idx" href="ctxmodule.html#idx:atomresult2:1744">6.13</a></dd>
400359 <dt><a class="idx" href="strings.html#atom_string/2">atom_string/2</a></dt>
401360 <dt><a class="idx" href="charsio.html#atom_to_chars/2">atom_to_chars/2</a></dt>
402361 <dt><a class="idx" href="charsio.html#atom_to_chars/3">atom_to_chars/3</a></dt>
403362 <dt><a class="idx" href="manipatom.html#atom_to_term/3">atom_to_term/3</a></dt>
404363 <dd>
405 <a class="idx" href="termrw.html#idx:atomtoterm3:1183">4.20</a></dd>
364 <a class="idx" href="termrw.html#idx:atomtoterm3:1185">4.20</a></dd>
406365 <dt><a class="idx" href="typetest.html#atomic/1">atomic/1</a></dt>
407366 <dd>
408 <a class="idx" href="typetest.html#idx:atomic1:602">4.6</a></dd>
367 <a class="idx" href="typetest.html#idx:atomic1:604">4.6</a></dd>
409368 <dt><a class="idx" href="manipatom.html#atomic_concat/3">atomic_concat/3</a></dt>
410369 <dd>
411 <a class="idx" href="manipatom.html#idx:atomicconcat3:1274">4.22</a></dd>
370 <a class="idx" href="manipatom.html#idx:atomicconcat3:1276">4.22</a></dd>
412371 <dt><a class="idx" href="manipatom.html#atomic_list_concat/2">atomic_list_concat/2</a></dt>
413372 <dd>
414 <a class="idx" href="manipatom.html#idx:atomiclistconcat2:1262">4.22</a> <a class="idx" href="manipatom.html#idx:atomiclistconcat2:1275">4.22</a></dd>
373 <a class="idx" href="manipatom.html#idx:atomiclistconcat2:1264">4.22</a> <a class="idx" href="manipatom.html#idx:atomiclistconcat2:1277">4.22</a></dd>
415374 <dt><a class="idx" href="manipatom.html#atomic_list_concat/3">atomic_list_concat/3</a></dt>
416375 <dt><a class="idx" href="strings.html#atomics_to_string/2">atomics_to_string/2</a></dt>
417376 <dd>
418 <a class="idx" href="strings.html#idx:atomicstostring2:1605">5.2.1</a></dd>
377 <a class="idx" href="strings.html#idx:atomicstostring2:1608">5.2.1</a></dd>
419378 <dt><a class="idx" href="strings.html#atomics_to_string/3">atomics_to_string/3</a></dt>
420379 <dt><a class="idx" href="thutil.html#attach_console/0">attach_console/0</a></dt>
421380 <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>
381 <a class="idx" href="thutil.html#idx:attachconsole0:1941">9.5</a> <a class="idx" href="thutil.html#idx:attachconsole0:1943">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:attachconsole0:2069">11.4.16</a></dd>
423382 <dt><a class="idx" href="packs.html#attach_packs/0">attach_packs/0</a></dt>
424383 <dd>
425 <a class="idx" href="packs.html#idx:attachpacks0:209">2.14</a></dd>
384 <a class="idx" href="packs.html#idx:attachpacks0:211">2.14</a></dd>
426385 <dt><a class="idx" href="packs.html#attach_packs/1">attach_packs/1</a></dt>
427386 <dt><a class="idx" href="packs.html#attach_packs/2">attach_packs/2</a></dt>
428387 <dd>
429 <a class="idx" href="packs.html#idx:attachpacks2:210">2.14</a></dd>
388 <a class="idx" href="packs.html#idx:attachpacks2:212">2.14</a></dd>
430389 <dt><a class="idx" href="attvar.html#attr_portray_hook/2">attr_portray_hook/2</a></dt>
431390 <dd>
432 <a class="idx" href="termrw.html#idx:attrportrayhook2:1120">4.20</a></dd>
391 <a class="idx" href="termrw.html#idx:attrportrayhook2:1122">4.20</a></dd>
433392 <dt><a class="idx" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a></dt>
434393 <dd>
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>
394 <a class="idx" href="attvar.html#idx:attrunifyhook2:1774">7.1</a> <a class="idx" href="attvar.html#idx:attrunifyhook2:1776">7.1</a></dd>
395 <dt>attribute_goals//1</dt>
396 <dd>
397 <a class="idx" href="attvar.html#idx:attributegoals1:1777">7.1</a> <a class="idx" href="attvar.html#idx:attributegoals1:1783">7.1.2</a> <a class="idx" href="attvar.html#idx:attributegoals1:1788">7.1.2</a> <a class="idx" href="attvar.html#idx:attributegoals1:1789">7.1.3</a></dd>
398 <dt><a class="idx" href="attvar.html#attribute_goals/1">attribute_goals/1</a></dt>
439399 <dt><a class="idx" href="attvar.html#attvar/1">attvar/1</a></dt>
440400 <dt><a class="idx" href="runtime.html#autoload/0">autoload/0</a></dt>
441401 <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>
402 <a class="idx" href="autoload.html#idx:autoload0:209">2.13</a> <a class="idx" href="consulting.html#idx:autoload0:455">4.3</a> <a class="idx" href="runtime.html#idx:autoload0:2103">12</a> <a class="idx" href="runtime.html#idx:autoload0:2107">12</a></dd>
443403 <dt><a class="idx" href="autoload.html#autoload_path/1">autoload_path/1</a></dt>
444404 <dt><a class="idx" href="clpfd.html#automaton/3">automaton/3</a></dt>
445405 <dt><a class="idx" href="clpfd.html#automaton/8">automaton/8</a></dt>
446406 <dt><a class="idx" href="gvar.html#b_getval/2">b_getval/2</a></dt>
447407 <dd>
448 <a class="idx" href="gvar.html#idx:bgetval2:1421">4.33</a> <a class="idx" href="gvar.html#idx:bgetval2:1424">4.33</a></dd>
408 <a class="idx" href="gvar.html#idx:bgetval2:1423">4.33</a> <a class="idx" href="gvar.html#idx:bgetval2:1426">4.33</a></dd>
449409 <dt><a class="idx" href="dicts.html#b_set_dict/3">b_set_dict/3</a></dt>
450410 <dt><a class="idx" href="gvar.html#b_setval/2">b_setval/2</a></dt>
451411 <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>
412 <a class="idx" href="flags.html#idx:bsetval2:142">2.11</a> <a class="idx" href="db.html#idx:bsetval2:811">4.14</a> <a class="idx" href="gvar.html#idx:bsetval2:1416">4.33</a> <a class="idx" href="gvar.html#idx:bsetval2:1417">4.33</a> <a class="idx" href="dicts.html#idx:bsetval2:1644">5.4.2.1</a> <a class="idx" href="engine-examples.html#idx:bsetval2:1976">10.1.2</a> <a class="idx" href="exception3.html#idx:bsetval2:2221">B.6</a></dd>
453413 <dt>backtracking</dt>
454414 <dd>
455 <a class="idx" href="glossary.html#idx:backtracking:2277">D</a></dd>
415 <a class="idx" href="glossary.html#idx:backtracking:2276">D</a></dd>
456416 <dt><a class="idx" href="allsolutions.html#bagof/3">bagof/3</a></dt>
457417 <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>
418 <a class="idx" href="cyclic.html#idx:bagof3:235">2.17</a> <a class="idx" href="allsolutions.html#idx:bagof3:1364">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1365">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="allsolutions.html#idx:bagof3:1374">4.30</a> <a class="idx" href="allsolutions.html#idx:bagof3:1375">4.30</a> <a class="idx" href="metapred.html#idx:bagof3:1697">6.4</a> <a class="idx" href="engine-examples.html#idx:bagof3:1970">10.1.1</a> <a class="idx" href="predsummary.html#idx:bagof3:2350">F.1</a></dd>
459419 <dt><a class="idx" href="clpqr.html#bb_inf/3">bb_inf/3</a></dt>
460420 <dt><a class="idx" href="clpqr.html#bb_inf/4">bb_inf/4</a></dt>
461421 <dt><a class="idx" href="clpqr.html#bb_inf/5">bb_inf/5</a></dt>
462422 <dt><a class="idx" href="arith.html#between/3">between/3</a></dt>
463423 <dd>
464 <a class="idx" href="arith.html#idx:between3:1321">4.27.1</a></dd>
424 <a class="idx" href="arith.html#idx:between3:1323">4.27.1</a></dd>
465425 <dt>binding</dt>
466426 <dd>
467 <a class="idx" href="glossary.html#idx:binding:2278">D</a></dd>
427 <a class="idx" href="glossary.html#idx:binding:2277">D</a></dd>
468428 <dt>bits, 64</dt>
469429 <dd>
470 <a class="idx" href="64bits.html#idx:bits64:285">2.21</a></dd>
430 <a class="idx" href="64bits.html#idx:bits64:287">2.21</a></dd>
471431 <dt>blackboard</dt>
472432 <dd>
473 <a class="idx" href="broadcast.html#idx:blackboard:2138">A.4</a></dd>
433 <a class="idx" href="broadcast.html#idx:blackboard:2137">A.4</a></dd>
474434 <dt><a class="idx" href="typetest.html#blob/2">blob/2</a></dt>
475435 <dd>
476 <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>
436 <a class="idx" href="typetest.html#idx:blob2:610">4.6</a> <a class="idx" href="IO.html#idx:blob2:972">4.17.2</a></dd>
477437 <dt>body</dt>
478438 <dd>
479 <a class="idx" href="glossary.html#idx:body:2281">D</a></dd>
439 <a class="idx" href="glossary.html#idx:body:2280">D</a></dd>
480440 <dt><a class="idx" href="toplevel.html#break/0">break/0</a></dt>
481441 <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>
442 <a class="idx" href="cmdline.html#idx:break0:45">2.4.4</a> <a class="idx" href="debugoverview.html#idx:break0:68">2.9</a> <a class="idx" href="flags.html#idx:break0:92">2.11</a> <a class="idx" href="flags.html#idx:break0:145">2.11</a> <a class="idx" href="debugging.html#idx:break0:1819">8.4.2</a> <a class="idx" href="foreigninclude.html#idx:break0:2068">11.4.16</a></dd>
483443 <dt>broadcast</dt>
484444 <dd>
485 <a class="idx" href="broadcast.html#idx:broadcast:2136">A.4</a></dd>
445 <a class="idx" href="broadcast.html#idx:broadcast:2135">A.4</a></dd>
486446 <dt><a class="idx" href="broadcast.html#broadcast/1">broadcast/1</a></dt>
487447 <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>
448 <a class="idx" href="broadcast.html#idx:broadcast1:2140">A.4</a> <a class="idx" href="broadcast.html#idx:broadcast1:2141">A.4</a></dd>
489449 <dt><a class="idx" href="broadcast.html#broadcast_request/1">broadcast_request/1</a></dt>
490450 <dt>built-in predicate</dt>
491451 <dd>
492 <a class="idx" href="glossary.html#idx:builtinpredicate:2279">D</a></dd>
452 <a class="idx" href="glossary.html#idx:builtinpredicate:2278">D</a></dd>
493453 <dt><a class="idx" href="streamstat.html#byte_count/2">byte_count/2</a></dt>
494454 <dd>
495 <a class="idx" href="IO.html#idx:bytecount2:1002">4.17.2</a></dd>
455 <a class="idx" href="IO.html#idx:bytecount2:1004">4.17.2</a></dd>
496456 <dt><a class="idx" href="metacall.html#call/1">call/1</a></dt>
497457 <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>
458 <a class="idx" href="xref.html#idx:call1:324">3.7</a> <a class="idx" href="typetest.html#idx:call1:614">4.6</a> <a class="idx" href="typetest.html#idx:call1:616">4.6</a> <a class="idx" href="typetest.html#idx:call1:619">4.6</a> <a class="idx" href="control.html#idx:call1:648">4.8</a> <a class="idx" href="metacall.html#idx:call1:651">4.9</a> <a class="idx" href="exception.html#idx:call1:695">4.11</a> <a class="idx" href="exception.html#idx:call1:699">4.11</a> <a class="idx" href="exception.html#idx:call1:701">4.11</a> <a class="idx" href="debugger.html#idx:call1:1555">4.39</a> <a class="idx" href="statistics.html#idx:call1:1567">4.40</a> <a class="idx" href="profile.html#idx:call1:1572">4.41.1</a> <a class="idx" href="profile.html#idx:call1:1575">4.41.3</a> <a class="idx" href="profile.html#idx:call1:1576">4.41.3</a> <a class="idx" href="modules.html#idx:call1:1661">6</a> <a class="idx" href="coroutining.html#idx:call1:1807">7.2</a> <a class="idx" href="foreigninclude.html#idx:call1:2043">11.4.9</a> <a class="idx" href="breakpoint.html#idx:call1:2205">B.4</a></dd>
499459 <dt><a class="idx" href="metacall.html#call/2">call/2</a></dt>
500460 <dd>
501 <a class="idx" href="typetest.html#idx:call2:613">4.6</a></dd>
461 <a class="idx" href="typetest.html#idx:call2:615">4.6</a></dd>
502462 <dt>call/3</dt>
503463 <dd>
504 <a class="idx" href="termrw.html#idx:call3:1129">4.20</a></dd>
464 <a class="idx" href="termrw.html#idx:call3:1131">4.20</a></dd>
505465 <dt>call/[2-8]</dt>
506466 <dd>
507 <a class="idx" href="metacall.html#idx:call28:650">4.9</a></dd>
467 <a class="idx" href="metacall.html#idx:call28:652">4.9</a></dd>
508468 <dt><a class="idx" href="metacall.html#call_cleanup/2">call_cleanup/2</a></dt>
509469 <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>
470 <a class="idx" href="metacall.html#idx:callcleanup2:676">4.9</a> <a class="idx" href="metacall.html#idx:callcleanup2:677">4.9</a> <a class="idx" href="metacall.html#idx:callcleanup2:679">4.9</a> <a class="idx" href="IO.html#idx:callcleanup2:1059">4.17.5</a> <a class="idx" href="manipstack.html#idx:callcleanup2:2189">B.1</a> <a class="idx" href="portabilitystrategies.html#idx:callcleanup2:2259">C.1</a></dd>
511471 <dt><a class="idx" href="metacall.html#call_cleanup/3">call_cleanup/3</a></dt>
512472 <dt><a class="idx" href="DCG.html#call_dcg/3">call_dcg/3</a></dt>
513473 <dd>
514 <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>
474 <a class="idx" href="DCG.html#idx:calldcg3:787">4.13</a></dd>
516475 <dt><a class="idx" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a></dt>
517476 <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>
477 <a class="idx" href="coroutining.html#idx:callresiduevars2:1801">7.2</a> <a class="idx" href="coroutining.html#idx:callresiduevars2:1812">7.2</a> <a class="idx" href="coroutining.html#idx:callresiduevars2:1813">7.2</a></dd>
519478 <dt><a class="idx" href="foreignlink.html#call_shared_object_function/2">call_shared_object_function/2</a></dt>
520479 <dt><a class="idx" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a></dt>
521480 <dd>
522 <a class="idx" href="metacall.html#idx:callwithdepthlimit3:656">4.9</a> <a class="idx" href="metacall.html#idx:callwithdepthlimit3:659">4.9</a> <a class="idx" href="metacall.html#idx:callwithdepthlimit3:664">4.9</a></dd>
481 <a class="idx" href="metacall.html#idx:callwithdepthlimit3:658">4.9</a> <a class="idx" href="metacall.html#idx:callwithdepthlimit3:661">4.9</a> <a class="idx" href="metacall.html#idx:callwithdepthlimit3:666">4.9</a></dd>
523482 <dt><a class="idx" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a></dt>
524483 <dd>
525 <a class="idx" href="metacall.html#idx:callwithinferencelimit3:660">4.9</a> <a class="idx" href="metacall.html#idx:callwithinferencelimit3:661">4.9</a> <a class="idx" href="metacall.html#idx:callwithinferencelimit3:662">4.9</a></dd>
484 <a class="idx" href="metacall.html#idx:callwithinferencelimit3:662">4.9</a> <a class="idx" href="metacall.html#idx:callwithinferencelimit3:663">4.9</a> <a class="idx" href="metacall.html#idx:callwithinferencelimit3:664">4.9</a></dd>
526485 <dt>call_with_time_limit/2</dt>
527486 <dd>
528 <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>
487 <a class="idx" href="metacall.html#idx:callwithtimelimit2:667">4.9</a> <a class="idx" href="metacall.html#idx:callwithtimelimit2:668">4.9</a> <a class="idx" href="exception.html#idx:callwithtimelimit2:720">4.11.1</a></dd>
529488 <dt><a class="idx" href="typetest.html#callable/1">callable/1</a></dt>
530489 <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>
490 <a class="idx" href="typetest.html#idx:callable1:618">4.6</a> <a class="idx" href="foreigninclude.html#idx:callable1:2021">11.4.3.1</a> <a class="idx" href="prolog_xref.html#idx:callable1:2156">A.27</a></dd>
532491 <dt><a class="idx" href="consulting.html#cancel_halt/1">cancel_halt/1</a></dt>
533492 <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>
493 <a class="idx" href="consulting.html#idx:cancelhalt1:501">4.3</a> <a class="idx" href="toplevel.html#idx:cancelhalt1:1533">4.37</a> <a class="idx" href="foreigninclude.html#idx:cancelhalt1:2087">11.4.21</a></dd>
535494 <dt><a class="idx" href="exception.html#catch/3">catch/3</a></dt>
536495 <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>
496 <a class="idx" href="delcont.html#idx:catch3:684">4.10</a> <a class="idx" href="exception.html#idx:catch3:693">4.11</a> <a class="idx" href="exception.html#idx:catch3:698">4.11</a> <a class="idx" href="exception.html#idx:catch3:700">4.11</a> <a class="idx" href="exception.html#idx:catch3:703">4.11</a> <a class="idx" href="exception.html#idx:catch3:704">4.11</a> <a class="idx" href="exception.html#idx:catch3:705">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:709">4.11</a> <a class="idx" href="exception.html#idx:catch3:710">4.11</a> <a class="idx" href="exception.html#idx:catch3:724">4.11.1</a> <a class="idx" href="exception.html#idx:catch3:727">4.11.2</a> <a class="idx" href="exception.html#idx:catch3:728">4.11.2</a> <a class="idx" href="exception.html#idx:catch3:729">4.11.2</a> <a class="idx" href="termrw.html#idx:catch3:1169">4.20</a> <a class="idx" href="files.html#idx:catch3:1496">4.36</a> <a class="idx" href="toplevel.html#idx:catch3:1529">4.37</a> <a class="idx" href="profile.html#idx:catch3:1574">4.41.1</a> <a class="idx" href="threadcreate.html#idx:catch3:1847">9.1</a> <a class="idx" href="thmonitor.html#idx:catch3:1875">9.2</a> <a class="idx" href="thmonitor.html#idx:catch3:1880">9.2</a> <a class="idx" href="engine-examples.html#idx:catch3:1981">10.1.2</a> <a class="idx" href="manipstack.html#idx:catch3:2187">B.1</a> <a class="idx" href="excepthook.html#idx:catch3:2210">B.5</a> <a class="idx" href="exception3.html#idx:catch3:2215">B.6</a> <a class="idx" href="exception3.html#idx:catch3:2218">B.6</a> <a class="idx" href="predsummary.html#idx:catch3:2373">F.1</a></dd>
538497 <dt><a class="idx" href="clpfd.html#chain/2">chain/2</a></dt>
539498 <dt><a class="idx" href="manipatom.html#char_code/2">char_code/2</a></dt>
540499 <dd>
541 <a class="idx" href="chars.html#idx:charcode2:344">4.2</a></dd>
500 <a class="idx" href="chars.html#idx:charcode2:346">4.2</a></dd>
542501 <dt><a class="idx" href="charconv.html#char_conversion/2">char_conversion/2</a></dt>
543502 <dd>
544 <a class="idx" href="flags.html#idx:charconversion2:92">2.11</a> <a class="idx" href="charconv.html#idx:charconversion2:1320">4.26</a></dd>
503 <a class="idx" href="flags.html#idx:charconversion2:93">2.11</a> <a class="idx" href="charconv.html#idx:charconversion2:1322">4.26</a></dd>
545504 <dt><a class="idx" href="chartype.html#char_type/2">char_type/2</a></dt>
546505 <dd>
547 <a class="idx" href="syntax.html#idx:chartype2:221">2.16.1.8</a> <a class="idx" href="locale.html#idx:chartype2:1280">4.23</a> <a class="idx" href="chartype.html#idx:chartype2:1297">4.24</a> <a class="idx" href="chartype.html#idx:chartype2:1301">4.24.1</a> <a class="idx" href="chartype.html#idx:chartype2:1302">4.24.1</a></dd>
506 <a class="idx" href="syntax.html#idx:chartype2:223">2.16.1.8</a> <a class="idx" href="locale.html#idx:chartype2:1282">4.23</a> <a class="idx" href="chartype.html#idx:chartype2:1299">4.24</a> <a class="idx" href="chartype.html#idx:chartype2:1303">4.24.1</a> <a class="idx" href="chartype.html#idx:chartype2:1304">4.24.1</a></dd>
548507 <dt>character set</dt>
549508 <dd>
550 <a class="idx" href="syntax.html#idx:characterset:213">2.16.1.1</a></dd>
509 <a class="idx" href="syntax.html#idx:characterset:215">2.16.1.1</a></dd>
551510 <dt><a class="idx" href="streamstat.html#character_count/2">character_count/2</a></dt>
552511 <dd>
553 <a class="idx" href="IO.html#idx:charactercount2:1001">4.17.2</a> <a class="idx" href="streamstat.html#idx:charactercount2:1073">4.18</a></dd>
512 <a class="idx" href="IO.html#idx:charactercount2:1003">4.17.2</a> <a class="idx" href="streamstat.html#idx:charactercount2:1075">4.18</a></dd>
554513 <dt><a class="idx" href="files.html#chdir/1">chdir/1</a></dt>
555514 <dd>
556 <a class="idx" href="files.html#idx:chdir1:1520">4.36</a></dd>
515 <a class="idx" href="files.html#idx:chdir1:1522">4.36</a></dd>
557516 <dt><a class="idx" href="check.html#check/0">check/0</a></dt>
558517 <dd>
559 <a class="idx" href="consulting.html#idx:check0:452">4.3</a></dd>
518 <a class="idx" href="consulting.html#idx:check0:454">4.3</a></dd>
560519 <dt><a class="idx" href="strings.html#check:string_predicate/1">check:string_predicate/1</a></dt>
561520 <dt><a class="idx" href="strings.html#check:valid_string_goal/1">check:valid_string_goal/1</a></dt>
562521 <dt><a class="idx" href="predicate_options.html#check_predicate_option/3">check_predicate_option/3</a></dt>
564523 <dt><a class="idx" href="check.html#checker/2">checker/2</a></dt>
565524 <dt>choice point</dt>
566525 <dd>
567 <a class="idx" href="glossary.html#idx:choicepoint:2282">D</a></dd>
526 <a class="idx" href="glossary.html#idx:choicepoint:2281">D</a></dd>
568527 <dt><a class="idx" href="practical.html#chr_constraint/1">chr_constraint/1</a></dt>
569528 <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>
529 <a class="idx" href="practical.html#idx:chrconstraint1:1814">8.3.2</a> <a class="idx" href="sicstus-chr.html#idx:chrconstraint1:1826">8.6.1</a></dd>
571530 <dt><a class="idx" href="debugging.html#chr_leash/1">chr_leash/1</a></dt>
572531 <dt><a class="idx" href="debugging.html#chr_notrace/0">chr_notrace/0</a></dt>
573532 <dd>
574 <a class="idx" href="debugging.html#idx:chrnotrace0:1819">8.4.2</a></dd>
533 <a class="idx" href="debugging.html#idx:chrnotrace0:1818">8.4.2</a></dd>
575534 <dt><a class="idx" href="SyntaxAndSemantics.html#chr_option/2">chr_option/2</a></dt>
576535 <dd>
577 <a class="idx" href="sicstus-chr.html#idx:chroption2:1828">8.6.1</a></dd>
536 <a class="idx" href="sicstus-chr.html#idx:chroption2:1827">8.6.1</a></dd>
578537 <dt><a class="idx" href="debugging.html#chr_show_store/1">chr_show_store/1</a></dt>
579538 <dt><a class="idx" href="debugging.html#chr_trace/0">chr_trace/0</a></dt>
580539 <dd>
581 <a class="idx" href="debugging.html#idx:chrtrace0:1818">8.4.2</a></dd>
540 <a class="idx" href="debugging.html#idx:chrtrace0:1817">8.4.2</a></dd>
582541 <dt><a class="idx" href="practical.html#chr_type/1">chr_type/1</a></dt>
583542 <dd>
584 <a class="idx" href="practical.html#idx:chrtype1:1816">8.3.2</a></dd>
543 <a class="idx" href="practical.html#idx:chrtype1:1815">8.3.2</a></dd>
585544 <dt><a class="idx" href="clpfd.html#circuit/1">circuit/1</a></dt>
586545 <dt>clause</dt>
587546 <dd>
588 <a class="idx" href="glossary.html#idx:clause:2283">D</a></dd>
547 <a class="idx" href="glossary.html#idx:clause:2282">D</a></dd>
589548 <dt><a class="idx" href="examineprog.html#clause/2">clause/2</a></dt>
590549 <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>
550 <a class="idx" href="flags.html#idx:clause2:130">2.11</a> <a class="idx" href="flags.html#idx:clause2:131">2.11</a> <a class="idx" href="listing.html#idx:clause2:597">4.5</a> <a class="idx" href="control.html#idx:clause2:650">4.8</a> <a class="idx" href="examineprog.html#idx:clause2:938">4.16</a> <a class="idx" href="runtime.html#idx:clause2:2108">12</a></dd>
592551 <dt><a class="idx" href="examineprog.html#clause/3">clause/3</a></dt>
593552 <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>
553 <a class="idx" href="db.html#idx:clause3:840">4.14.1</a> <a class="idx" href="db.html#idx:clause3:850">4.14.2</a> <a class="idx" href="examineprog.html#idx:clause3:942">4.16</a> <a class="idx" href="examineprog.html#idx:clause3:948">4.16</a> <a class="idx" href="qsavelimits.html#idx:clause3:2117">12.1</a></dd>
595554 <dt>clause/[2,3]</dt>
596555 <dd>
597 <a class="idx" href="flags.html#idx:clause23:117">2.11</a></dd>
556 <a class="idx" href="flags.html#idx:clause23:119">2.11</a></dd>
598557 <dt><a class="idx" href="examineprog.html#clause_property/2">clause_property/2</a></dt>
599558 <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>
559 <a class="idx" href="consulting.html#idx:clauseproperty2:452">4.3</a> <a class="idx" href="consulting.html#idx:clauseproperty2:476">4.3</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:920">4.16</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:923">4.16</a> <a class="idx" href="examineprog.html#idx:clauseproperty2:945">4.16</a> <a class="idx" href="manipstack.html#idx:clauseproperty2:2184">B.1</a></dd>
601560 <dt><a class="idx" href="IO.html#close/1">close/1</a></dt>
602561 <dd>
603 <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>
562 <a class="idx" href="IO.html#idx:close1:950">4.17</a> <a class="idx" href="IO.html#idx:close1:984">4.17.2</a> <a class="idx" href="IO.html#idx:close1:997">4.17.2</a></dd>
604563 <dt><a class="idx" href="IO.html#close/2">close/2</a></dt>
605564 <dt><a class="idx" href="iostream.html#close_any/1">close_any/1</a></dt>
606565 <dt><a class="idx" href="DDE.html#close_dde_conversation/1">close_dde_conversation/1</a></dt>
607566 <dt><a class="idx" href="foreignlink.html#close_shared_object/1">close_shared_object/1</a></dt>
608567 <dt><a class="idx" href="chartype.html#code_type/2">code_type/2</a></dt>
609568 <dd>
610 <a class="idx" href="locale.html#idx:codetype2:1281">4.23</a> <a class="idx" href="chartype.html#idx:codetype2:1292">4.24</a> <a class="idx" href="chartype.html#idx:codetype2:1300">4.24.1</a></dd>
569 <a class="idx" href="locale.html#idx:codetype2:1283">4.23</a> <a class="idx" href="chartype.html#idx:codetype2:1294">4.24</a> <a class="idx" href="chartype.html#idx:codetype2:1302">4.24.1</a></dd>
611570 <dt>collate</dt>
612571 <dd>
613 <a class="idx" href="chartype.html#idx:collate:1307">4.24.3</a></dd>
572 <a class="idx" href="chartype.html#idx:collate:1309">4.24.3</a></dd>
614573 <dt><a class="idx" href="chartype.html#collation_key/2">collation_key/2</a></dt>
615574 <dd>
616 <a class="idx" href="locale.html#idx:collationkey2:1282">4.23</a> <a class="idx" href="chartype.html#idx:collationkey2:1309">4.24.3</a> <a class="idx" href="chartype.html#idx:collationkey2:1312">4.24.3</a> <a class="idx" href="system.html#idx:collationkey2:1457">4.35</a></dd>
575 <a class="idx" href="locale.html#idx:collationkey2:1284">4.23</a> <a class="idx" href="chartype.html#idx:collationkey2:1311">4.24.3</a> <a class="idx" href="chartype.html#idx:collationkey2:1314">4.24.3</a> <a class="idx" href="system.html#idx:collationkey2:1459">4.35</a></dd>
617576 <dt>command line, arguments</dt>
618577 <dd>
619 <a class="idx" href="cmdline.html#idx:commandlinearguments:39">2.4.2</a></dd>
578 <a class="idx" href="cmdline.html#idx:commandlinearguments:40">2.4.2</a></dd>
620579 <dt><a class="idx" href="foreigninclude.html#compare()">compare()</a></dt>
621580 <dt>compare,language-specific</dt>
622581 <dd>
623 <a class="idx" href="chartype.html#idx:comparelanguagespecific:1308">4.24.3</a></dd>
582 <a class="idx" href="chartype.html#idx:comparelanguagespecific:1310">4.24.3</a></dd>
624583 <dt><a class="idx" href="compare.html#compare/3">compare/3</a></dt>
625584 <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>
585 <a class="idx" href="cyclic.html#idx:compare3:236">2.17</a> <a class="idx" href="builtinlist.html#idx:compare3:1360">4.29</a> <a class="idx" href="foreigninclude.html#idx:compare3:2054">11.4.14.1</a> <a class="idx" href="portabilitystrategies.html#idx:compare3:2262">C.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:2267">C.1</a></dd>
627586 <dt><a class="idx" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a></dt>
628587 <dd>
629 <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>
588 <a class="idx" href="consulting.html#idx:compileauxclauses1:377">4.3</a> <a class="idx" href="examineprog.html#idx:compileauxclauses1:914">4.16</a></dd>
630589 <dt><a class="idx" href="dynamic.html#compile_predicates/1">compile_predicates/1</a></dt>
631590 <dd>
632 <a class="idx" href="dynamic.html#idx:compilepredicates1:883">4.15</a></dd>
591 <a class="idx" href="dynamic.html#idx:compilepredicates1:885">4.15</a></dd>
633592 <dt><a class="idx" href="consulting.html#compiling/0">compiling/0</a></dt>
634593 <dd>
635 <a class="idx" href="consulting.html#idx:compiling0:581">4.3.3</a></dd>
594 <a class="idx" href="consulting.html#idx:compiling0:583">4.3.3</a></dd>
636595 <dt><a class="idx" href="ugraphs.html#complement/2">complement/2</a></dt>
637596 <dt><a class="idx" href="ugraphs.html#compose/3">compose/3</a></dt>
638597 <dt>compound</dt>
639598 <dd>
640 <a class="idx" href="glossary.html#idx:compound:2284">D</a></dd>
599 <a class="idx" href="glossary.html#idx:compound:2283">D</a></dd>
641600 <dt><a class="idx" href="typetest.html#compound/1">compound/1</a></dt>
642601 <dt><a class="idx" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a></dt>
643602 <dd>
644 <a class="idx" href="typetest.html#idx:compoundnamearguments3:611">4.6</a> <a class="idx" href="manipterm.html#idx:compoundnamearguments3:1193">4.21</a> <a class="idx" href="manipterm.html#idx:compoundnamearguments3:1196">4.21</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearguments3:1627">5.3.2</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearguments3:1629">5.3.2</a> <a class="idx" href="dicts.html#idx:compoundnamearguments3:1633">5.4.1</a></dd>
603 <a class="idx" href="typetest.html#idx:compoundnamearguments3:613">4.6</a> <a class="idx" href="manipterm.html#idx:compoundnamearguments3:1195">4.21</a> <a class="idx" href="manipterm.html#idx:compoundnamearguments3:1198">4.21</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearguments3:1630">5.3.2</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearguments3:1632">5.3.2</a> <a class="idx" href="dicts.html#idx:compoundnamearguments3:1636">5.4.1</a></dd>
645604 <dt><a class="idx" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a></dt>
646605 <dd>
647 <a class="idx" href="typetest.html#idx:compoundnamearity3:610">4.6</a> <a class="idx" href="manipterm.html#idx:compoundnamearity3:1190">4.21</a> <a class="idx" href="manipterm.html#idx:compoundnamearity3:1197">4.21</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearity3:1626">5.3.2</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearity3:1628">5.3.2</a> <a class="idx" href="dicts.html#idx:compoundnamearity3:1632">5.4.1</a></dd>
606 <a class="idx" href="typetest.html#idx:compoundnamearity3:612">4.6</a> <a class="idx" href="manipterm.html#idx:compoundnamearity3:1192">4.21</a> <a class="idx" href="manipterm.html#idx:compoundnamearity3:1199">4.21</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearity3:1629">5.3.2</a> <a class="idx" href="ext-syntax.html#idx:compoundnamearity3:1631">5.3.2</a> <a class="idx" href="dicts.html#idx:compoundnamearity3:1635">5.4.1</a></dd>
648607 <dt>concat_atom/3</dt>
649608 <dd>
650 <a class="idx" href="manipatom.html#idx:concatatom3:1276">4.22</a></dd>
609 <a class="idx" href="manipatom.html#idx:concatatom3:1278">4.22</a></dd>
651610 <dt>constraint programming</dt>
652611 <dd>
653 <a class="idx" href="clp.html#idx:constraintprogramming:1764">7</a></dd>
612 <a class="idx" href="clp.html#idx:constraintprogramming:1763">7</a></dd>
654613 <dt><a class="idx" href="simplex.html#constraint/3">constraint/3</a></dt>
655614 <dt><a class="idx" href="simplex.html#constraint/4">constraint/4</a></dt>
656615 <dt><a class="idx" href="simplex.html#constraint_add/4">constraint_add/4</a></dt>
657616 <dt><a class="idx" href="consulting.html#consult/1">consult/1</a></dt>
658617 <dd>
659 <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>
618 <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:179">2.12</a> <a class="idx" href="pceemacs.html#idx:consult1:315">3.4.3.1</a> <a class="idx" href="consulting.html#idx:consult1:361">4.3</a> <a class="idx" href="consulting.html#idx:consult1:382">4.3</a> <a class="idx" href="consulting.html#idx:consult1:388">4.3</a> <a class="idx" href="consulting.html#idx:consult1:394">4.3</a> <a class="idx" href="consulting.html#idx:consult1:405">4.3</a> <a class="idx" href="consulting.html#idx:consult1:424">4.3</a> <a class="idx" href="consulting.html#idx:consult1:428">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:433">4.3</a> <a class="idx" href="consulting.html#idx:consult1:443">4.3</a> <a class="idx" href="consulting.html#idx:consult1:456">4.3</a> <a class="idx" href="consulting.html#idx:consult1:567">4.3.2.1</a> <a class="idx" href="consulting.html#idx:consult1:568">4.3.2.1</a> <a class="idx" href="consulting.html#idx:consult1:574">4.3.2.1</a> <a class="idx" href="consulting.html#idx:consult1:579">4.3.3</a> <a class="idx" href="consulting.html#idx:consult1:580">4.3.3</a> <a class="idx" href="consulting.html#idx:consult1:581">4.3.3</a> <a class="idx" href="dynamic.html#idx:consult1:890">4.15</a></dd>
660619 <dt>context module</dt>
661620 <dd>
662 <a class="idx" href="glossary.html#idx:contextmodule:2285">D</a></dd>
621 <a class="idx" href="glossary.html#idx:contextmodule:2284">D</a></dd>
663622 <dt><a class="idx" href="ctxmodule.html#context_module/1">context_module/1</a></dt>
664623 <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>
624 <a class="idx" href="metapred.html#idx:contextmodule1:1703">6.4</a> <a class="idx" href="ctxmodule.html#idx:contextmodule1:1748">6.13</a> <a class="idx" href="foreigninclude.html#idx:contextmodule1:2045">11.4.9.2</a></dd>
666625 <dt>convert_time/[2,8]</dt>
667626 <dd>
668 <a class="idx" href="files.html#idx:converttime28:1502">4.36</a></dd>
627 <a class="idx" href="files.html#idx:converttime28:1504">4.36</a></dd>
669628 <dt><a class="idx" href="apply.html#convlist/3">convlist/3</a></dt>
670629 <dt>copy_file/2</dt>
671630 <dd>
672 <a class="idx" href="system.html#idx:copyfile2:1447">4.35</a></dd>
631 <a class="idx" href="system.html#idx:copyfile2:1449">4.35</a></dd>
673632 <dt><a class="idx" href="db.html#copy_predicate_clauses/2">copy_predicate_clauses/2</a></dt>
674633 <dt><a class="idx" href="chario.html#copy_stream_data/2">copy_stream_data/2</a></dt>
675634 <dd>
676 <a class="idx" href="chario.html#idx:copystreamdata2:1112">4.19</a></dd>
635 <a class="idx" href="chario.html#idx:copystreamdata2:1114">4.19</a></dd>
677636 <dt><a class="idx" href="chario.html#copy_stream_data/3">copy_stream_data/3</a></dt>
678637 <dd>
679 <a class="idx" href="IO.html#idx:copystreamdata3:1008">4.17.2</a></dd>
638 <a class="idx" href="IO.html#idx:copystreamdata3:1010">4.17.2</a></dd>
680639 <dt><a class="idx" href="manipterm.html#copy_term/2">copy_term/2</a></dt>
681640 <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>
641 <a class="idx" href="cyclic.html#idx:copyterm2:237">2.17</a> <a class="idx" href="compare.html#idx:copyterm2:636">4.7.2</a> <a class="idx" href="manipterm.html#idx:copyterm2:1217">4.21</a> <a class="idx" href="manipterm.html#idx:copyterm2:1224">4.21.1</a> <a class="idx" href="manipterm.html#idx:copyterm2:1235">4.21.1</a> <a class="idx" href="gvar.html#idx:copyterm2:1422">4.33</a> <a class="idx" href="dicts.html#idx:copyterm2:1642">5.4.2.1</a> <a class="idx" href="clp.html#idx:copyterm2:1772">7</a> <a class="idx" href="attvar.html#idx:copyterm2:1790">7.1.3</a></dd>
683642 <dt><a class="idx" href="attvar.html#copy_term/3">copy_term/3</a></dt>
684643 <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>
644 <a class="idx" href="IO.html#idx:copyterm3:1066">4.17.6</a> <a class="idx" href="termrw.html#idx:copyterm3:1139">4.20</a> <a class="idx" href="clp.html#idx:copyterm3:1773">7</a> <a class="idx" href="attvar.html#idx:copyterm3:1784">7.1.2</a> <a class="idx" href="attvar.html#idx:copyterm3:1787">7.1.2</a></dd>
686645 <dt><a class="idx" href="attvar.html#copy_term_nat/2">copy_term_nat/2</a></dt>
687646 <dt>count_atom_results/3</dt>
688647 <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>
648 <a class="idx" href="ctxmodule.html#idx:countatomresults3:1743">6.13</a> <a class="idx" href="ctxmodule.html#idx:countatomresults3:1745">6.13</a></dd>
690649 <dt><a class="idx" href="threadpool.html#create_pool/1">create_pool/1</a></dt>
691650 <dt><a class="idx" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a></dt>
692651 <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>
652 <a class="idx" href="flags.html#idx:createprologflag3:85">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:153">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:154">2.11</a> <a class="idx" href="flags.html#idx:createprologflag3:167">2.11</a> <a class="idx" href="foreigninclude.html#idx:createprologflag3:2062">11.4.14.4</a></dd>
694653 <dt>crypto_n_random_bytes/2</dt>
695654 <dd>
696 <a class="idx" href="arith.html#idx:cryptonrandombytes2:1335">4.27.2.3</a></dd>
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>
655 <a class="idx" href="arith.html#idx:cryptonrandombytes2:1337">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>
699658 <dt><a class="idx" href="csv.html#csv_options/2">csv_options/2</a></dt>
700659 <dt><a class="idx" href="csv.html#csv_read_file/2">csv_read_file/2</a></dt>
701660 <dd>
702 <a class="idx" href="builtinlist.html#idx:csvreadfile2:1349">4.29</a></dd>
661 <a class="idx" href="builtinlist.html#idx:csvreadfile2:1351">4.29</a></dd>
703662 <dt><a class="idx" href="csv.html#csv_read_file/3">csv_read_file/3</a></dt>
704663 <dt><a class="idx" href="csv.html#csv_read_file_row/3">csv_read_file_row/3</a></dt>
705664 <dt><a class="idx" href="csv.html#csv_read_row/3">csv_read_row/3</a></dt>
711670 <dt><a class="idx" href="miscarith.html#current_arithmetic_function/1">current_arithmetic_function/1</a></dt>
712671 <dt><a class="idx" href="examineprog.html#current_atom/1">current_atom/1</a></dt>
713672 <dd>
714 <a class="idx" href="examineprog.html#idx:currentatom1:895">4.16</a></dd>
673 <a class="idx" href="examineprog.html#idx:currentatom1:897">4.16</a></dd>
715674 <dt><a class="idx" href="examineprog.html#current_blob/2">current_blob/2</a></dt>
716675 <dd>
717 <a class="idx" href="foreigninclude.html#idx:currentblob2:2042">11.4.7.1</a></dd>
676 <a class="idx" href="foreigninclude.html#idx:currentblob2:2041">11.4.7.1</a></dd>
718677 <dt><a class="idx" href="charconv.html#current_char_conversion/2">current_char_conversion/2</a></dt>
719678 <dd>
720 <a class="idx" href="charconv.html#idx:currentcharconversion2:1319">4.26</a></dd>
679 <a class="idx" href="charconv.html#idx:currentcharconversion2:1321">4.26</a></dd>
721680 <dt><a class="idx" href="engine-predicates.html#current_engine/1">current_engine/1</a></dt>
722681 <dt><a class="idx" href="examineprog.html#current_flag/1">current_flag/1</a></dt>
723682 <dt><a class="idx" href="foreignlink.html#current_foreign_library/2">current_foreign_library/2</a></dt>
724683 <dd>
725 <a class="idx" href="runtime.html#idx:currentforeignlibrary2:2105">12</a></dd>
684 <a class="idx" href="runtime.html#idx:currentforeignlibrary2:2104">12</a></dd>
726685 <dt><a class="idx" href="format.html#current_format_predicate/2">current_format_predicate/2</a></dt>
727686 <dt><a class="idx" href="examineprog.html#current_functor/2">current_functor/2</a></dt>
728687 <dd>
729 <a class="idx" href="examineprog.html#idx:currentfunctor2:896">4.16</a></dd>
688 <a class="idx" href="examineprog.html#idx:currentfunctor2:898">4.16</a></dd>
730689 <dt><a class="idx" href="IO.html#current_input/1">current_input/1</a></dt>
731690 <dd>
732 <a class="idx" href="consulting.html#idx:currentinput1:489">4.3</a> <a class="idx" href="IO.html#idx:currentinput1:963">4.17.1</a> <a class="idx" href="IO.html#idx:currentinput1:1047">4.17.3</a></dd>
691 <a class="idx" href="consulting.html#idx:currentinput1:491">4.3</a> <a class="idx" href="IO.html#idx:currentinput1:965">4.17.1</a> <a class="idx" href="IO.html#idx:currentinput1:1049">4.17.3</a></dd>
733692 <dt><a class="idx" href="examineprog.html#current_key/1">current_key/1</a></dt>
734693 <dd>
735 <a class="idx" href="db.html#idx:currentkey1:844">4.14.2</a></dd>
694 <a class="idx" href="db.html#idx:currentkey1:846">4.14.2</a></dd>
736695 <dt><a class="idx" href="locale.html#current_locale/1">current_locale/1</a></dt>
737696 <dt><a class="idx" href="manipmodule.html#current_module/1">current_module/1</a></dt>
738697 <dd>
739 <a class="idx" href="examineprog.html#idx:currentmodule1:902">4.16</a></dd>
698 <a class="idx" href="examineprog.html#idx:currentmodule1:904">4.16</a></dd>
740699 <dt><a class="idx" href="operators.html#current_op/3">current_op/3</a></dt>
741700 <dt><a class="idx" href="predicate_options.html#current_option_arg/2">current_option_arg/2</a></dt>
742701 <dt><a class="idx" href="IO.html#current_output/1">current_output/1</a></dt>
743702 <dd>
744 <a class="idx" href="IO.html#idx:currentoutput1:964">4.17.1</a> <a class="idx" href="IO.html#idx:currentoutput1:1048">4.17.3</a></dd>
703 <a class="idx" href="IO.html#idx:currentoutput1:966">4.17.1</a> <a class="idx" href="IO.html#idx:currentoutput1:1050">4.17.3</a></dd>
745704 <dt><a class="idx" href="persistency.html#current_persistent_predicate/1">current_persistent_predicate/1</a></dt>
746705 <dt><a class="idx" href="examineprog.html#current_predicate/1">current_predicate/1</a></dt>
747706 <dd>
748 <a class="idx" href="metacall.html#idx:currentpredicate1:651">4.9</a> <a class="idx" href="examineprog.html#idx:currentpredicate1:899">4.16</a> <a class="idx" href="examineprog.html#idx:currentpredicate1:905">4.16</a> <a class="idx" href="examineprog.html#idx:currentpredicate1:911">4.16</a></dd>
707 <a class="idx" href="metacall.html#idx:currentpredicate1:653">4.9</a> <a class="idx" href="examineprog.html#idx:currentpredicate1:901">4.16</a> <a class="idx" href="examineprog.html#idx:currentpredicate1:907">4.16</a> <a class="idx" href="examineprog.html#idx:currentpredicate1:913">4.16</a></dd>
749708 <dt><a class="idx" href="examineprog.html#current_predicate/2">current_predicate/2</a></dt>
750709 <dd>
751 <a class="idx" href="examineprog.html#idx:currentpredicate2:900">4.16</a> <a class="idx" href="examineprog.html#idx:currentpredicate2:907">4.16</a></dd>
710 <a class="idx" href="examineprog.html#idx:currentpredicate2:902">4.16</a> <a class="idx" href="examineprog.html#idx:currentpredicate2:909">4.16</a></dd>
752711 <dt><a class="idx" href="predicate_options.html#current_predicate_option/3">current_predicate_option/3</a></dt>
753712 <dt><a class="idx" href="predicate_options.html#current_predicate_options/3">current_predicate_options/3</a></dt>
754713 <dt><a class="idx" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a></dt>
755714 <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>
715 <a class="idx" href="cmdline.html#idx:currentprologflag2:27">2.4.2</a> <a class="idx" href="cmdline.html#idx:currentprologflag2:33">2.4.2</a> <a class="idx" href="cmdline.html#idx:currentprologflag2:41">2.4.2</a> <a class="idx" href="flags.html#idx:currentprologflag2:81">2.11</a> <a class="idx" href="flags.html#idx:currentprologflag2:83">2.11</a> <a class="idx" href="autoload.html#idx:currentprologflag2:194">2.13</a> <a class="idx" href="gc.html#idx:currentprologflag2:213">2.15</a> <a class="idx" href="syntax.html#idx:currentprologflag2:216">2.16.1.3</a> <a class="idx" href="consulting.html#idx:currentprologflag2:401">4.3</a> <a class="idx" href="termrw.html#idx:currentprologflag2:1170">4.20</a> <a class="idx" href="DDE.html#idx:currentprologflag2:1588">4.43.2</a> <a class="idx" href="foreignlink.html#idx:currentprologflag2:2011">11.2.1</a> <a class="idx" href="foreigninclude.html#idx:currentprologflag2:2063">11.4.14.4</a> <a class="idx" href="libpl.html#idx:currentprologflag2:2134">A</a> <a class="idx" href="glossary.html#idx:currentprologflag2:2306">D</a></dd>
757716 <dt><a class="idx" href="signal.html#current_signal/3">current_signal/3</a></dt>
758717 <dd>
759 <a class="idx" href="signal.html#idx:currentsignal3:774">4.12</a></dd>
718 <a class="idx" href="signal.html#idx:currentsignal3:776">4.12</a></dd>
760719 <dt><a class="idx" href="IO.html#current_stream/3">current_stream/3</a></dt>
761720 <dd>
762 <a class="idx" href="IO.html#idx:currentstream3:994">4.17.2</a> <a class="idx" href="files.html#idx:currentstream3:1523">4.36</a></dd>
721 <a class="idx" href="IO.html#idx:currentstream3:996">4.17.2</a> <a class="idx" href="files.html#idx:currentstream3:1525">4.36</a></dd>
763722 <dt><a class="idx" href="threadpool.html#current_thread_pool/1">current_thread_pool/1</a></dt>
764723 <dt><a class="idx" href="db.html#current_trie/1">current_trie/1</a></dt>
765724 <dd>
766 <a class="idx" href="db.html#idx:currenttrie1:854">4.14.4</a></dd>
725 <a class="idx" href="db.html#idx:currenttrie1:856">4.14.4</a></dd>
767726 <dt><a class="idx" href="error.html#current_type/3">current_type/3</a></dt>
768727 <dt>cyclic terms</dt>
769728 <dd>
770 <a class="idx" href="cyclic.html#idx:cyclicterms:230">2.17</a></dd>
729 <a class="idx" href="cyclic.html#idx:cyclicterms:232">2.17</a></dd>
771730 <dt><a class="idx" href="typetest.html#cyclic_term/1">cyclic_term/1</a></dt>
772731 <dd>
773 <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>
732 <a class="idx" href="cyclic.html#idx:cyclicterm1:238">2.17</a> <a class="idx" href="typetest.html#idx:cyclicterm1:623">4.6</a> <a class="idx" href="typetest.html#idx:cyclicterm1:625">4.6</a></dd>
774733 <dt>daemon</dt>
775734 <dd>
776 <a class="idx" href="broadcast.html#idx:daemon:2140">A.4</a></dd>
735 <a class="idx" href="broadcast.html#idx:daemon:2139">A.4</a></dd>
777736 <dt><a class="idx" href="system.html#date_time_stamp/2">date_time_stamp/2</a></dt>
778737 <dt><a class="idx" href="system.html#date_time_value/3">date_time_value/3</a></dt>
779738 <dd>
780 <a class="idx" href="system.html#idx:datetimevalue3:1480">4.35.2.1</a> <a class="idx" href="system.html#idx:datetimevalue3:1481">4.35.2.1</a></dd>
739 <a class="idx" href="system.html#idx:datetimevalue3:1482">4.35.2.1</a> <a class="idx" href="system.html#idx:datetimevalue3:1483">4.35.2.1</a></dd>
781740 <dt><a class="idx" href="system.html#day_of_the_week/2">day_of_the_week/2</a></dt>
782741 <dt><a class="idx" href="persistency.html#db_attach/2">db_attach/2</a></dt>
783742 <dt><a class="idx" href="persistency.html#db_attached/1">db_attached/1</a></dt>
786745 <dt><a class="idx" href="persistency.html#db_sync_all/1">db_sync_all/1</a></dt>
787746 <dt>dcg</dt>
788747 <dd>
789 <a class="idx" href="glossary.html#idx:dcg:2288">D</a></dd>
748 <a class="idx" href="glossary.html#idx:dcg:2287">D</a></dd>
790749 <dt><a class="idx" href="consulting.html#dcg_translate_rule/2">dcg_translate_rule/2</a></dt>
791750 <dd>
792 <a class="idx" href="consulting.html#idx:dcgtranslaterule2:530">4.3.1</a></dd>
751 <a class="idx" href="consulting.html#idx:dcgtranslaterule2:532">4.3.1</a></dd>
793752 <dt><a class="idx" href="consulting.html#dcg_translate_rule/4">dcg_translate_rule/4</a></dt>
794753 <dt><a class="idx" href="DDE.html#dde_current_connection/2">dde_current_connection/2</a></dt>
795754 <dt><a class="idx" href="DDE.html#dde_current_service/2">dde_current_service/2</a></dt>
800759 <dt><a class="idx" href="DDE.html#dde_unregister_service/1">dde_unregister_service/1</a></dt>
801760 <dt><a class="idx" href="debugger.html#debug/0">debug/0</a></dt>
802761 <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>
762 <a class="idx" href="debugoverview.html#idx:debug0:58">2.9</a> <a class="idx" href="debugoverview.html#idx:debug0:71">2.9</a> <a class="idx" href="flags.html#idx:debug0:146">2.11</a> <a class="idx" href="exception.html#idx:debug0:730">4.11.2</a> <a class="idx" href="debugger.html#idx:debug0:1550">4.39</a> <a class="idx" href="debugger.html#idx:debug0:1558">4.39</a> <a class="idx" href="memory.html#idx:debug0:1582">4.42</a> <a class="idx" href="thutil.html#idx:debug0:1945">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:debug0:2065">11.4.16</a> <a class="idx" href="breakpoint.html#idx:debug0:2203">B.4</a> <a class="idx" href="excepthook.html#idx:debug0:2213">B.5</a></dd>
804763 <dt><a class="idx" href="debug.html#debug/1">debug/1</a></dt>
805764 <dt><a class="idx" href="debug.html#debug/3">debug/3</a></dt>
806765 <dd>
807 <a class="idx" href="exception.html#idx:debug3:736">4.11.4</a></dd>
766 <a class="idx" href="exception.html#idx:debug3:738">4.11.4</a></dd>
808767 <dt><a class="idx" href="debug.html#debug_message_context/1">debug_message_context/1</a></dt>
809768 <dt>debugging,exceptions</dt>
810769 <dd>
811 <a class="idx" href="exception.html#idx:debuggingexceptions:724">4.11.2</a></dd>
770 <a class="idx" href="exception.html#idx:debuggingexceptions:726">4.11.2</a></dd>
812771 <dt><a class="idx" href="debugger.html#debugging/0">debugging/0</a></dt>
813772 <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>
773 <a class="idx" href="hooks.html#idx:debugging0:187">2.12</a> <a class="idx" href="debugger.html#idx:debugging0:1553">4.39</a> <a class="idx" href="intlibs.html#idx:debugging0:2231">B.7</a> <a class="idx" href="intlibs.html#idx:debugging0:2232">B.7</a></dd>
815774 <dt><a class="idx" href="debug.html#debugging/1">debugging/1</a></dt>
816775 <dt><a class="idx" href="debug.html#debugging/2">debugging/2</a></dt>
817776 <dt>declarative</dt>
818777 <dd>
819 <a class="idx" href="clp.html#idx:declarative:1768">7</a></dd>
778 <a class="idx" href="clp.html#idx:declarative:1767">7</a></dd>
820779 <dt><a class="idx" href="importmodule.html#default_module/2">default_module/2</a></dt>
821780 <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>
781 <a class="idx" href="consulting.html#idx:defaultmodule2:540">4.3.1</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:911">4.16</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:921">4.16</a> <a class="idx" href="examineprog.html#idx:defaultmodule2:934">4.16</a> <a class="idx" href="importmodule.html#idx:defaultmodule2:1724">6.9</a></dd>
823782 <dt><a class="idx" href="assoc.html#del_assoc/4">del_assoc/4</a></dt>
824783 <dt><a class="idx" href="attvar.html#del_attr/2">del_attr/2</a></dt>
825784 <dd>
826 <a class="idx" href="attvar.html#idx:delattr2:1795">7.1.4</a></dd>
785 <a class="idx" href="attvar.html#idx:delattr2:1794">7.1.4</a></dd>
827786 <dt><a class="idx" href="attvar.html#del_attrs/1">del_attrs/1</a></dt>
828787 <dt><a class="idx" href="dicts.html#del_dict/4">del_dict/4</a></dt>
829788 <dt><a class="idx" href="ugraphs.html#del_edges/3">del_edges/3</a></dt>
834793 <dt><a class="idx" href="files.html#delete_directory/1">delete_directory/1</a></dt>
835794 <dt><a class="idx" href="files.html#delete_file/1">delete_file/1</a></dt>
836795 <dd>
837 <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>
796 <a class="idx" href="system.html#idx:deletefile1:1447">4.35</a> <a class="idx" href="files.html#idx:deletefile1:1520">4.36</a></dd>
838797 <dt><a class="idx" href="importmodule.html#delete_import_module/2">delete_import_module/2</a></dt>
839798 <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>
799 <a class="idx" href="importmodule.html#idx:deleteimportmodule2:1723">6.9</a> <a class="idx" href="importmodule.html#idx:deleteimportmodule2:1727">6.9</a> <a class="idx" href="modulecompat.html#idx:deleteimportmodule2:1761">6.15</a></dd>
841800 <dt><a class="idx" href="predicate_options.html#derive_predicate_options/0">derive_predicate_options/0</a></dt>
842801 <dt><a class="idx" href="predicate_options.html#derived_predicate_options/1">derived_predicate_options/1</a></dt>
843802 <dt><a class="idx" href="predicate_options.html#derived_predicate_options/3">derived_predicate_options/3</a></dt>
844803 <dt>deserialize</dt>
845804 <dd>
846 <a class="idx" href="DCG.html#idx:deserialize:779">4.13</a></dd>
805 <a class="idx" href="DCG.html#idx:deserialize:781">4.13</a></dd>
847806 <dt>det</dt>
848807 <dd>
849 <a class="idx" href="glossary.html#idx:det:2289">D</a></dd>
808 <a class="idx" href="glossary.html#idx:det:2288">D</a></dd>
850809 <dt>determinism</dt>
851810 <dd>
852 <a class="idx" href="glossary.html#idx:determinism:2290">D</a></dd>
811 <a class="idx" href="glossary.html#idx:determinism:2289">D</a></dd>
853812 <dt>deterministic</dt>
854813 <dd>
855 <a class="idx" href="glossary.html#idx:deterministic:2291">D</a></dd>
814 <a class="idx" href="glossary.html#idx:deterministic:2290">D</a></dd>
856815 <dt><a class="idx" href="manipstack.html#deterministic/1">deterministic/1</a></dt>
857816 <dd>
858 <a class="idx" href="metacall.html#idx:deterministic1:673">4.9</a></dd>
817 <a class="idx" href="metacall.html#idx:deterministic1:675">4.9</a></dd>
859818 <dt><a class="idx" href="dicts.html#dict_create/3">dict_create/3</a></dt>
860819 <dd>
861 <a class="idx" href="dicts.html#idx:dictcreate3:1640">5.4.2</a></dd>
820 <a class="idx" href="dicts.html#idx:dictcreate3:1639">5.4.2</a></dd>
862821 <dt><a class="idx" href="option.html#dict_options/2">dict_options/2</a></dt>
863822 <dt><a class="idx" href="dicts.html#dict_pairs/3">dict_pairs/3</a></dt>
864823 <dd>
865 <a class="idx" href="dicts.html#idx:dictpairs3:1657">5.4.3</a></dd>
824 <a class="idx" href="dicts.html#idx:dictpairs3:1656">5.4.3</a></dd>
866825 <dt><a class="idx" href="coroutining.html#dif/2">dif/2</a></dt>
867826 <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>
827 <a class="idx" href="cyclic.html#idx:dif2:239">2.17</a> <a class="idx" href="compare.html#idx:dif2:626">4.7</a> <a class="idx" href="compare.html#idx:dif2:642">4.7.2</a> <a class="idx" href="clp.html#idx:dif2:1765">7</a> <a class="idx" href="coroutining.html#idx:dif2:1796">7.2</a> <a class="idx" href="coroutining.html#idx:dif2:1802">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:1810">7.2</a></dd>
869828 <dt>directory_file_path/3</dt>
870829 <dd>
871 <a class="idx" href="files.html#idx:directoryfilepath3:1495">4.36</a></dd>
830 <a class="idx" href="files.html#idx:directoryfilepath3:1497">4.36</a></dd>
872831 <dt><a class="idx" href="files.html#directory_files/2">directory_files/2</a></dt>
873832 <dt><a class="idx" href="dynamic.html#discontiguous/1">discontiguous/1</a></dt>
874833 <dd>
875 <a class="idx" href="consulting.html#idx:discontiguous1:445">4.3</a> <a class="idx" href="exception.html#idx:discontiguous1:739">4.11.4</a> <a class="idx" href="dynamic.html#idx:discontiguous1:877">4.15</a> <a class="idx" href="debugger.html#idx:discontiguous1:1561">4.39</a></dd>
834 <a class="idx" href="consulting.html#idx:discontiguous1:447">4.3</a> <a class="idx" href="exception.html#idx:discontiguous1:741">4.11.4</a> <a class="idx" href="dynamic.html#idx:discontiguous1:879">4.15</a> <a class="idx" href="debugger.html#idx:discontiguous1:1563">4.39</a></dd>
876835 <dt><a class="idx" href="clpfd.html#disjoint2/1">disjoint2/1</a></dt>
877836 <dt>display/1</dt>
878837 <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>
838 <a class="idx" href="format.html#idx:display1:1397">4.32.1</a> <a class="idx" href="foreigninclude.html#idx:display1:2028">11.4.3.6</a> <a class="idx" href="foreigninclude.html#idx:display1:2029">11.4.3.6</a></dd>
880839 <dt><a class="idx" href="solutionsequences.html#distinct/1">distinct/1</a></dt>
881840 <dt><a class="idx" href="solutionsequences.html#distinct/2">distinct/2</a></dt>
882841 <dt><a class="idx" href="arith.html#divmod/4">divmod/4</a></dt>
883842 <dd>
884 <a class="idx" href="arith.html#idx:divmod4:1323">4.27.1</a></dd>
843 <a class="idx" href="arith.html#idx:divmod4:1325">4.27.1</a></dd>
885844 <dt>dld</dt>
886845 <dd>
887 <a class="idx" href="foreignlink.html#idx:dld:2011">11.2</a></dd>
846 <a class="idx" href="foreignlink.html#idx:dld:2010">11.2</a></dd>
888847 <dt>do_not_use/1</dt>
889848 <dd>
890 <a class="idx" href="reexport.html#idx:donotuse1:1715">6.7</a></dd>
849 <a class="idx" href="reexport.html#idx:donotuse1:1714">6.7</a></dd>
891850 <dt>domain/2</dt>
892851 <dd>
893 <a class="idx" href="attvar.html#idx:domain2:1776">7.1</a></dd>
852 <a class="idx" href="attvar.html#idx:domain2:1775">7.1</a></dd>
894853 <dt><a class="idx" href="error.html#domain_error/2">domain_error/2</a></dt>
895854 <dd>
896 <a class="idx" href="foreigninclude.html#idx:domainerror2:2036">11.4.6</a></dd>
855 <a class="idx" href="foreigninclude.html#idx:domainerror2:2035">11.4.6</a></dd>
897856 <dt><a class="idx" href="chartype.html#downcase_atom/2">downcase_atom/2</a></dt>
898857 <dd>
899 <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>
858 <a class="idx" href="chartype.html#idx:downcaseatom2:1296">4.24</a> <a class="idx" href="chartype.html#idx:downcaseatom2:1298">4.24</a> <a class="idx" href="chartype.html#idx:downcaseatom2:1305">4.24.1</a></dd>
900859 <dt><a class="idx" href="clpqr.html#dump/3">dump/3</a></dt>
901860 <dd>
902 <a class="idx" href="clpqr.html#idx:dump3:2148">A.9.5</a></dd>
861 <a class="idx" href="clpqr.html#idx:dump3:2147">A.9.5</a></dd>
903862 <dt><a class="idx" href="manipterm.html#duplicate_term/2">duplicate_term/2</a></dt>
904863 <dd>
905 <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>
864 <a class="idx" href="cyclic.html#idx:duplicateterm2:240">2.17</a> <a class="idx" href="manipterm.html#idx:duplicateterm2:1219">4.21</a> <a class="idx" href="manipterm.html#idx:duplicateterm2:1227">4.21.1</a> <a class="idx" href="gvar.html#idx:duplicateterm2:1424">4.33</a></dd>
906865 <dt><a class="idx" href="miscpreds.html#dwim_match/2">dwim_match/2</a></dt>
907866 <dd>
908 <a class="idx" href="examineprog.html#idx:dwimmatch2:935">4.16</a> <a class="idx" href="miscpreds.html#idx:dwimmatch2:1586">4.44</a></dd>
867 <a class="idx" href="examineprog.html#idx:dwimmatch2:937">4.16</a> <a class="idx" href="miscpreds.html#idx:dwimmatch2:1589">4.44</a></dd>
909868 <dt><a class="idx" href="miscpreds.html#dwim_match/3">dwim_match/3</a></dt>
910869 <dt><a class="idx" href="examineprog.html#dwim_predicate/2">dwim_predicate/2</a></dt>
911870 <dt>dynamic predicate</dt>
912871 <dd>
913 <a class="idx" href="glossary.html#idx:dynamicpredicate:2292">D</a></dd>
872 <a class="idx" href="glossary.html#idx:dynamicpredicate:2291">D</a></dd>
914873 <dt><a class="idx" href="dynamic.html#dynamic/1">dynamic/1</a></dt>
915874 <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>
875 <a class="idx" href="flags.html#idx:dynamic1:125">2.11</a> <a class="idx" href="flags.html#idx:dynamic1:150">2.11</a> <a class="idx" href="preddesc.html#idx:dynamic1:341">4.1</a> <a class="idx" href="consulting.html#idx:dynamic1:436">4.3</a> <a class="idx" href="db.html#idx:dynamic1:800">4.14</a> <a class="idx" href="db.html#idx:dynamic1:829">4.14.1</a> <a class="idx" href="db.html#idx:dynamic1:830">4.14.1</a> <a class="idx" href="dynamic.html#idx:dynamic1:877">4.15</a> <a class="idx" href="dynamic.html#idx:dynamic1:886">4.15</a> <a class="idx" href="examineprog.html#idx:dynamic1:917">4.16</a> <a class="idx" href="ctxmodule.html#idx:dynamic1:1747">6.13</a> <a class="idx" href="threadcom.html#idx:dynamic1:1917">9.3.3</a> <a class="idx" href="threadcom.html#idx:dynamic1:1919">9.3.3</a> <a class="idx" href="runtime.html#idx:dynamic1:2113">12</a></dd>
917876 <dt><a class="idx" href="ugraphs.html#edges/2">edges/2</a></dt>
918877 <dt><a class="idx" href="edit.html#edit/0">edit/0</a></dt>
919878 <dd>
920 <a class="idx" href="flags.html#idx:edit0:90">2.11</a></dd>
879 <a class="idx" href="flags.html#idx:edit0:91">2.11</a></dd>
921880 <dt><a class="idx" href="edit.html#edit/1">edit/1</a></dt>
922881 <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>
882 <a class="idx" href="quickstart.html#idx:edit1:10">2.1.4</a> <a class="idx" href="flags.html#idx:edit1:106">2.11</a> <a class="idx" href="hooks.html#idx:edit1:181">2.12</a> <a class="idx" href="hooks.html#idx:edit1:182">2.12</a> <a class="idx" href="hooks.html#idx:edit1:183">2.12</a> <a class="idx" href="editreload.html#idx:edit1:308">3.3.1</a> <a class="idx" href="pceemacs.html#idx:edit1:311">3.4.1</a> <a class="idx" href="pceemacs.html#idx:edit1:312">3.4.3.1</a> <a class="idx" href="idesummary.html#idx:edit1:329">3.9</a> <a class="idx" href="idesummary.html#idx:edit1:330">3.9</a> <a class="idx" href="consulting.html#idx:edit1:449">4.3</a> <a class="idx" href="consulting.html#idx:edit1:458">4.3</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</a> <a class="idx" href="edit.html#idx:edit1:590">4.4</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="edit.html#idx:edit1:593">4.4.1</a> <a class="idx" href="edit.html#idx:edit1:594">4.4.1</a> <a class="idx" href="mtoplevel.html#idx:edit1:1709">6.6</a> <a class="idx" href="predsummary.html#idx:edit1:2365">F.1</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></dd>
924883 <dt><a class="idx" href="clpfd.html#element/3">element/3</a></dt>
925884 <dt><a class="idx" href="consulting.html#elif/1">elif/1</a></dt>
926885 <dt><a class="idx" href="consulting.html#else/0">else/0</a></dt>
928887 <dt><a class="idx" href="nb_set.html#empty_nb_set/1">empty_nb_set/1</a></dt>
929888 <dt><a class="idx" href="consulting.html#encoding/1">encoding/1</a></dt>
930889 <dd>
931 <a class="idx" href="widechars.html#idx:encoding1:271">2.19.1</a></dd>
890 <a class="idx" href="widechars.html#idx:encoding1:273">2.19.1</a></dd>
932891 <dt><a class="idx" href="consulting.html#endif/0">endif/0</a></dt>
933892 <dt><a class="idx" href="engine-predicates.html#engine_create/3">engine_create/3</a></dt>
934893 <dd>
935 <a class="idx" href="engine-predicates.html#idx:enginecreate3:1997">10.3</a></dd>
894 <a class="idx" href="engine-predicates.html#idx:enginecreate3:1996">10.3</a></dd>
936895 <dt><a class="idx" href="engine-predicates.html#engine_create/4">engine_create/4</a></dt>
937896 <dt><a class="idx" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a></dt>
938897 <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>
898 <a class="idx" href="engine-resources.html#idx:enginedestroy1:1987">10.2</a> <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></dd>
940899 <dt><a class="idx" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a></dt>
941900 <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>
901 <a class="idx" href="engine-examples.html#idx:enginefetch1:1979">10.1.2</a> <a class="idx" href="engine-predicates.html#idx:enginefetch1:2000">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginefetch1:2002">10.3</a></dd>
943902 <dt>engine_next/1</dt>
944903 <dd>
945 <a class="idx" href="engine-examples.html#idx:enginenext1:1969">10.1.1</a></dd>
904 <a class="idx" href="engine-examples.html#idx:enginenext1:1968">10.1.1</a></dd>
946905 <dt><a class="idx" href="engine-predicates.html#engine_next/2">engine_next/2</a></dt>
947906 <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>
907 <a class="idx" href="engines.html#idx:enginenext2:1966">10</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:1994">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginenext2:1999">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:2004">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></dd>
949908 <dt><a class="idx" href="engine-predicates.html#engine_next_reified/2">engine_next_reified/2</a></dt>
950909 <dt><a class="idx" href="engine-predicates.html#engine_post/2">engine_post/2</a></dt>
951910 <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>
911 <a class="idx" href="engine-predicates.html#idx:enginepost2:2003">10.3</a> <a class="idx" href="engine-predicates.html#idx:enginepost2:2008">10.3</a></dd>
953912 <dt><a class="idx" href="engine-predicates.html#engine_post/3">engine_post/3</a></dt>
954913 <dd>
955 <a class="idx" href="engine-predicates.html#idx:enginepost3:2010">10.3</a></dd>
914 <a class="idx" href="engine-predicates.html#idx:enginepost3:2009">10.3</a></dd>
956915 <dt><a class="idx" href="engine-predicates.html#engine_self/1">engine_self/1</a></dt>
957916 <dt><a class="idx" href="engine-predicates.html#engine_yield/1">engine_yield/1</a></dt>
958917 <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>
918 <a class="idx" href="engines.html#idx:engineyield1:1967">10</a> <a class="idx" href="engine-examples.html#idx:engineyield1:1980">10.1.2</a> <a class="idx" href="engine-resources.html#idx:engineyield1:1992">10.2</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:1997">10.3</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:1998">10.3</a> <a class="idx" href="engine-predicates.html#idx:engineyield1:2007">10.3</a></dd>
960919 <dt><a class="idx" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a></dt>
961920 <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>
921 <a class="idx" href="compilation.html#idx:ensureloaded1:73">2.10.1</a> <a class="idx" href="consulting.html#idx:ensureloaded1:362">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:383">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:389">4.3</a> <a class="idx" href="consulting.html#idx:ensureloaded1:432">4.3</a> <a class="idx" href="import.html#idx:ensureloaded1:1671">6.3</a> <a class="idx" href="import.html#idx:ensureloaded1:1672">6.3</a></dd>
963922 <dt><a class="idx" href="clpqr.html#entailed/1">entailed/1</a></dt>
964923 <dt><a class="idx" href="prologpack.html#environment/2">environment/2</a></dt>
965924 <dt><a class="idx" href="db.html#erase/1">erase/1</a></dt>
966925 <dd>
967 <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>
926 <a class="idx" href="db.html#idx:erase1:807">4.14</a> <a class="idx" href="db.html#idx:erase1:841">4.14.1</a> <a class="idx" href="db.html#idx:erase1:842">4.14.2</a> <a class="idx" href="examineprog.html#idx:erase1:940">4.16</a></dd>
968927 <dt><a class="idx" href="exception3.html#exception/3">exception/3</a></dt>
969928 <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>
929 <a class="idx" href="gvar.html#idx:exception3:1421">4.33</a> <a class="idx" href="exception3.html#idx:exception3:2214">B.6</a> <a class="idx" href="exception3.html#idx:exception3:2217">B.6</a></dd>
971930 <dt>exceptions,debugging</dt>
972931 <dd>
973 <a class="idx" href="exception.html#idx:exceptionsdebugging:723">4.11.2</a></dd>
932 <a class="idx" href="exception.html#idx:exceptionsdebugging:725">4.11.2</a></dd>
974933 <dt><a class="idx" href="apply.html#exclude/3">exclude/3</a></dt>
975934 <dt><a class="idx" href="error.html#existence_error/2">existence_error/2</a></dt>
935 <dt><a class="idx" href="error.html#existence_error/3">existence_error/3</a></dt>
976936 <dt><a class="idx" href="files.html#exists_directory/1">exists_directory/1</a></dt>
977937 <dt><a class="idx" href="files.html#exists_file/1">exists_file/1</a></dt>
978938 <dd>
979 <a class="idx" href="flags.html#idx:existsfile1:110">2.11</a></dd>
939 <a class="idx" href="flags.html#idx:existsfile1:111">2.11</a></dd>
980940 <dt><a class="idx" href="dialect.html#exists_source/1">exists_source/1</a></dt>
981941 <dd>
982 <a class="idx" href="dialect.html#idx:existssource1:2250">C</a></dd>
942 <a class="idx" href="dialect.html#idx:existssource1:2249">C</a></dd>
983943 <dt><a class="idx" href="toplevel.html#expand_answer/2">expand_answer/2</a></dt>
984944 <dd>
985 <a class="idx" href="toplevel.html#idx:expandanswer2:1536">4.37</a></dd>
945 <a class="idx" href="toplevel.html#idx:expandanswer2:1538">4.37</a></dd>
986946 <dt><a class="idx" href="files.html#expand_file_name/2">expand_file_name/2</a></dt>
987947 <dd>
988 <a class="idx" href="flags.html#idx:expandfilename2:112">2.11</a> <a class="idx" href="consulting.html#idx:expandfilename2:402">4.3</a> <a class="idx" href="system.html#idx:expandfilename2:1451">4.35</a> <a class="idx" href="system.html#idx:expandfilename2:1463">4.35</a> <a class="idx" href="files.html#idx:expandfilename2:1505">4.36</a> <a class="idx" href="files.html#idx:expandfilename2:1511">4.36</a> <a class="idx" href="files.html#idx:expandfilename2:1515">4.36</a></dd>
948 <a class="idx" href="flags.html#idx:expandfilename2:113">2.11</a> <a class="idx" href="consulting.html#idx:expandfilename2:404">4.3</a> <a class="idx" href="system.html#idx:expandfilename2:1453">4.35</a> <a class="idx" href="system.html#idx:expandfilename2:1465">4.35</a> <a class="idx" href="files.html#idx:expandfilename2:1507">4.36</a> <a class="idx" href="files.html#idx:expandfilename2:1513">4.36</a> <a class="idx" href="files.html#idx:expandfilename2:1517">4.36</a></dd>
989949 <dt><a class="idx" href="consulting.html#expand_file_search_path/2">expand_file_search_path/2</a></dt>
990950 <dt><a class="idx" href="consulting.html#expand_goal/2">expand_goal/2</a></dt>
991951 <dd>
992 <a class="idx" href="flags.html#idx:expandgoal2:122">2.11</a> <a class="idx" href="consulting.html#idx:expandgoal2:520">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:528">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:531">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:535">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:543">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:555">4.3.1.2</a></dd>
952 <a class="idx" href="flags.html#idx:expandgoal2:124">2.11</a> <a class="idx" href="consulting.html#idx:expandgoal2:522">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:530">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:533">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:537">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:545">4.3.1</a> <a class="idx" href="consulting.html#idx:expandgoal2:557">4.3.1.2</a></dd>
993953 <dt><a class="idx" href="consulting.html#expand_goal/4">expand_goal/4</a></dt>
994954 <dt><a class="idx" href="toplevel.html#expand_query/4">expand_query/4</a></dt>
995955 <dt><a class="idx" href="consulting.html#expand_term/2">expand_term/2</a></dt>
996956 <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>
957 <a class="idx" href="consulting.html#idx:expandterm2:494">4.3</a> <a class="idx" href="consulting.html#idx:expandterm2:519">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:528">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:536">4.3.1</a> <a class="idx" href="consulting.html#idx:expandterm2:551">4.3.1</a> <a class="idx" href="DCG.html#idx:expandterm2:782">4.13</a> <a class="idx" href="record.html#idx:expandterm2:2172">A.31</a></dd>
998958 <dt><a class="idx" href="consulting.html#expand_term/4">expand_term/4</a></dt>
999959 <dt><a class="idx" href="dialect.html#expects_dialect/1">expects_dialect/1</a></dt>
1000960 <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>
961 <a class="idx" href="consulting.html#idx:expectsdialect1:403">4.3</a> <a class="idx" href="consulting.html#idx:expectsdialect1:423">4.3</a> <a class="idx" href="consulting.html#idx:expectsdialect1:490">4.3</a> <a class="idx" href="dialect.html#idx:expectsdialect1:2248">C</a></dd>
1002962 <dt><a class="idx" href="help.html#explain/1">explain/1</a></dt>
1003963 <dd>
1004 <a class="idx" href="help.html#idx:explain1:51">2.6</a></dd>
964 <a class="idx" href="help.html#idx:explain1:52">2.6</a></dd>
1005965 <dt><a class="idx" href="help.html#explain/2">explain/2</a></dt>
1006966 <dt><a class="idx" href="altmoduleapi.html#export/1">export/1</a></dt>
1007967 <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>
968 <a class="idx" href="consulting.html#idx:export1:560">4.3.2</a> <a class="idx" href="dynamic.html#idx:export1:896">4.15</a> <a class="idx" href="altmoduleapi.html#idx:export1:1732">6.11</a> <a class="idx" href="altmoduleapi.html#idx:export1:1735">6.11</a> <a class="idx" href="dynamic-modules.html#idx:export1:1738">6.12</a></dd>
1009969 <dt>export_list/2</dt>
1010970 <dd>
1011 <a class="idx" href="altmoduleapi.html#idx:exportlist2:1737">6.11</a></dd>
971 <a class="idx" href="altmoduleapi.html#idx:exportlist2:1736">6.11</a></dd>
1012972 <dt>exported predicate</dt>
1013973 <dd>
1014 <a class="idx" href="glossary.html#idx:exportedpredicate:2294">D</a></dd>
974 <a class="idx" href="glossary.html#idx:exportedpredicate:2293">D</a></dd>
1015975 <dt><a class="idx" href="arith.html#f-**/2">f-**/2</a></dt>
1016976 <dt><a class="idx" href="arith.html#f-*/2">f-*/2</a></dt>
1017977 <dt><a class="idx" href="arith.html#f-+/1">f-+/1</a></dt>
10861046 <dt><a class="idx" href="arith.html#f-xor/2">f-xor/2</a></dt>
10871047 <dt>fact</dt>
10881048 <dd>
1089 <a class="idx" href="glossary.html#idx:fact:2297">D</a></dd>
1049 <a class="idx" href="glossary.html#idx:fact:2296">D</a></dd>
10901050 <dt><a class="idx" href="control.html#fail/0">fail/0</a></dt>
10911051 <dd>
1092 <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>
1052 <a class="idx" href="consulting.html#idx:fail0:547">4.3.1</a> <a class="idx" href="control.html#idx:fail0:646">4.8</a></dd>
10931053 <dt><a class="idx" href="control.html#false/0">false/0</a></dt>
10941054 <dt><a class="idx" href="IO.html#fast_read/2">fast_read/2</a></dt>
10951055 <dd>
1096 <a class="idx" href="IO.html#idx:fastread2:1065">4.17.6</a></dd>
1056 <a class="idx" href="IO.html#idx:fastread2:1067">4.17.6</a></dd>
10971057 <dt><a class="idx" href="IO.html#fast_term_serialized/2">fast_term_serialized/2</a></dt>
10981058 <dt><a class="idx" href="IO.html#fast_write/2">fast_write/2</a></dt>
10991059 <dt><a class="idx" href="clpfd.html#fd_dom/2">fd_dom/2</a></dt>
11041064 <dt><a class="idx" href="files.html#file_base_name/2">file_base_name/2</a></dt>
11051065 <dt><a class="idx" href="files.html#file_directory_name/2">file_directory_name/2</a></dt>
11061066 <dd>
1107 <a class="idx" href="files.html#idx:filedirectoryname2:1499">4.36</a></dd>
1067 <a class="idx" href="files.html#idx:filedirectoryname2:1501">4.36</a></dd>
11081068 <dt><a class="idx" href="files.html#file_name_extension/3">file_name_extension/3</a></dt>
11091069 <dt><a class="idx" href="url.html#file_name_to_url/2">file_name_to_url/2</a></dt>
11101070 <dt>file_of_label/2</dt>
11111071 <dd>
1112 <a class="idx" href="mtoplevel.html#idx:fileoflabel2:1713">6.6</a></dd>
1072 <a class="idx" href="mtoplevel.html#idx:fileoflabel2:1712">6.6</a></dd>
11131073 <dt><a class="idx" href="consulting.html#file_search_path/2">file_search_path/2</a></dt>
11141074 <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>
1075 <a class="idx" href="initfile.html#idx:filesearchpath2:22">2.2</a> <a class="idx" href="cmdline.html#idx:filesearchpath2:37">2.4.2</a> <a class="idx" href="cmdline.html#idx:filesearchpath2:39">2.4.2</a> <a class="idx" href="flags.html#idx:filesearchpath2:90">2.11</a> <a class="idx" href="flags.html#idx:filesearchpath2:158">2.11</a> <a class="idx" href="autoload.html#idx:filesearchpath2:192">2.13</a> <a class="idx" href="autoload.html#idx:filesearchpath2:198">2.13</a> <a class="idx" href="autoload.html#idx:filesearchpath2:204">2.13</a> <a class="idx" href="projectfiles.html#idx:filesearchpath2:301">3.1.1.3</a> <a class="idx" href="projectfiles.html#idx:filesearchpath2:302">3.1.1.3</a> <a class="idx" href="xref.html#idx:filesearchpath2:325">3.7</a> <a class="idx" href="consulting.html#idx:filesearchpath2:406">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:469">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:472">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:473">4.3</a> <a class="idx" href="consulting.html#idx:filesearchpath2:496">4.3</a> <a class="idx" href="foreigninclude.html#idx:filesearchpath2:2060">11.4.14.3</a> <a class="idx" href="findhome.html#idx:filesearchpath2:2092">11.6</a> <a class="idx" href="qsaveforeign.html#idx:filesearchpath2:2120">12.2</a> <a class="idx" href="qsaveforeign.html#idx:filesearchpath2:2121">12.2</a> <a class="idx" href="useresource.html#idx:filesearchpath2:2126">12.3.1</a> <a class="idx" href="useresource.html#idx:filesearchpath2:2128">12.3.1</a> <a class="idx" href="findappfile.html#idx:filesearchpath2:2132">12.4</a></dd>
11161076 <dt><a class="idx" href="chario.html#fill_buffer/1">fill_buffer/1</a></dt>
11171077 <dt><a class="idx" href="debugging.html#find_chr_constraint/1">find_chr_constraint/1</a></dt>
11181078 <dt><a class="idx" href="allsolutions.html#findall/3">findall/3</a></dt>
11191079 <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>
1080 <a class="idx" href="cyclic.html#idx:findall3:241">2.17</a> <a class="idx" href="compare.html#idx:findall3:637">4.7.2</a> <a class="idx" href="control.html#idx:findall3:645">4.8</a> <a class="idx" href="db.html#idx:findall3:794">4.14</a> <a class="idx" href="allsolutions.html#idx:findall3:1363">4.30</a> <a class="idx" href="allsolutions.html#idx:findall3:1366">4.30</a> <a class="idx" href="allsolutions.html#idx:findall3:1367">4.30</a> <a class="idx" href="forall2.html#idx:findall3:1383">4.31</a> <a class="idx" href="dicts.html#idx:findall3:1652">5.4.3</a> <a class="idx" href="clp.html#idx:findall3:1771">7</a> <a class="idx" href="engine-examples.html#idx:findall3:1969">10.1.1</a> <a class="idx" href="engine-examples.html#idx:findall3:1971">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-predicates.html#idx:findall3:1993">10.3</a> <a class="idx" href="predsummary.html#idx:findall3:2358">F.1</a></dd>
11211081 <dt><a class="idx" href="allsolutions.html#findall/4">findall/4</a></dt>
11221082 <dd>
1123 <a class="idx" href="allsolutions.html#idx:findall4:1366">4.30</a></dd>
1083 <a class="idx" href="allsolutions.html#idx:findall4:1368">4.30</a></dd>
11241084 <dt><a class="idx" href="allsolutions.html#findnsols/4">findnsols/4</a></dt>
11251085 <dd>
1126 <a class="idx" href="predsummary.html#idx:findnsols4:2360">F.1</a></dd>
1086 <a class="idx" href="predsummary.html#idx:findnsols4:2359">F.1</a></dd>
11271087 <dt><a class="idx" href="allsolutions.html#findnsols/5">findnsols/5</a></dt>
11281088 <dt><a class="idx" href="db.html#flag/3">flag/3</a></dt>
11291089 <dd>
1130 <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>
1090 <a class="idx" href="db.html#idx:flag3:809">4.14</a> <a class="idx" href="db.html#idx:flag3:810">4.14</a> <a class="idx" href="db.html#idx:flag3:854">4.14.3</a> <a class="idx" href="examineprog.html#idx:flag3:899">4.16</a> <a class="idx" href="manipterm.html#idx:flag3:1231">4.21.1</a></dd>
11311091 <dt><a class="idx" href="lists.html#flatten/2">flatten/2</a></dt>
11321092 <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>
1093 <a class="idx" href="import.html#idx:flatten2:1673">6.3</a> <a class="idx" href="import.html#idx:flatten2:1676">6.3</a></dd>
11341094 <dt><a class="idx" href="typetest.html#float/1">float/1</a></dt>
11351095 <dd>
1136 <a class="idx" href="typetest.html#idx:float1:607">4.6</a></dd>
1096 <a class="idx" href="typetest.html#idx:float1:609">4.6</a></dd>
11371097 <dt>flounder</dt>
11381098 <dd>
1139 <a class="idx" href="coroutining.html#idx:flounder:1801">7.2</a></dd>
1099 <a class="idx" href="coroutining.html#idx:flounder:1800">7.2</a></dd>
11401100 <dt><a class="idx" href="chario.html#flush_output/0">flush_output/0</a></dt>
11411101 <dd>
1142 <a class="idx" href="chario.html#idx:flushoutput0:1080">4.19</a></dd>
1102 <a class="idx" href="chario.html#idx:flushoutput0:1082">4.19</a></dd>
11431103 <dt><a class="idx" href="chario.html#flush_output/1">flush_output/1</a></dt>
11441104 <dd>
1145 <a class="idx" href="exception.html#idx:flushoutput1:748">4.11.4</a> <a class="idx" href="chario.html#idx:flushoutput1:1110">4.19</a></dd>
1105 <a class="idx" href="exception.html#idx:flushoutput1:750">4.11.4</a> <a class="idx" href="chario.html#idx:flushoutput1:1112">4.19</a></dd>
11461106 <dt>flush_output/[0,1]</dt>
11471107 <dd>
1148 <a class="idx" href="IO.html#idx:flushoutput01:975">4.17.2</a> <a class="idx" href="chario.html#idx:flushoutput01:1082">4.19</a></dd>
1108 <a class="idx" href="IO.html#idx:flushoutput01:977">4.17.2</a> <a class="idx" href="chario.html#idx:flushoutput01:1084">4.19</a></dd>
11491109 <dt><a class="idx" href="apply.html#foldl/4">foldl/4</a></dt>
11501110 <dt><a class="idx" href="apply.html#foldl/5">foldl/5</a></dt>
11511111 <dt><a class="idx" href="apply.html#foldl/6">foldl/6</a></dt>
11521112 <dt><a class="idx" href="apply.html#foldl/7">foldl/7</a></dt>
11531113 <dt><a class="idx" href="forall2.html#forall/2">forall/2</a></dt>
11541114 <dd>
1155 <a class="idx" href="forall2.html#idx:forall2:1375">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1376">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1377">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1378">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1379">4.31</a></dd>
1115 <a class="idx" href="forall2.html#idx:forall2:1377">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1378">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1379">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1380">4.31</a> <a class="idx" href="forall2.html#idx:forall2:1381">4.31</a></dd>
11561116 <dt><a class="idx" href="aggregate.html#foreach/2">foreach/2</a></dt>
11571117 <dd>
1158 <a class="idx" href="forall2.html#idx:foreach2:1382">4.31</a></dd>
1118 <a class="idx" href="forall2.html#idx:foreach2:1384">4.31</a></dd>
1119 <dt>fork/1</dt>
1120 <dd>
1121 <a class="idx" href="memory.html#idx:fork1:1579">4.42</a></dd>
11591122 <dt><a class="idx" href="format.html#format/1">format/1</a></dt>
11601123 <dd>
1161 <a class="idx" href="exception.html#idx:format1:749">4.11.4</a> <a class="idx" href="format.html#idx:format1:1386">4.32</a></dd>
1124 <a class="idx" href="exception.html#idx:format1:751">4.11.4</a> <a class="idx" href="format.html#idx:format1:1388">4.32</a></dd>
11621125 <dt><a class="idx" href="format.html#format/2">format/2</a></dt>
11631126 <dd>
1164 <a class="idx" href="syntax.html#idx:format2:220">2.16.1.5</a> <a class="idx" href="IO.html#idx:format2:979">4.17.2</a> <a class="idx" href="termrw.html#idx:format2:1147">4.20</a> <a class="idx" href="locale.html#idx:format2:1285">4.23</a> <a class="idx" href="locale.html#idx:format2:1286">4.23</a> <a class="idx" href="format.html#idx:format2:1387">4.32</a> <a class="idx" href="format.html#idx:format2:1399">4.32.2</a> <a class="idx" href="format.html#idx:format2:1407">4.32.2</a></dd>
1127 <a class="idx" href="syntax.html#idx:format2:222">2.16.1.5</a> <a class="idx" href="IO.html#idx:format2:981">4.17.2</a> <a class="idx" href="termrw.html#idx:format2:1149">4.20</a> <a class="idx" href="locale.html#idx:format2:1287">4.23</a> <a class="idx" href="locale.html#idx:format2:1288">4.23</a> <a class="idx" href="format.html#idx:format2:1389">4.32</a> <a class="idx" href="format.html#idx:format2:1401">4.32.2</a> <a class="idx" href="format.html#idx:format2:1409">4.32.2</a></dd>
11651128 <dt><a class="idx" href="format.html#format/3">format/3</a></dt>
11661129 <dd>
1167 <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>
1130 <a class="idx" href="exception.html#idx:format3:736">4.11.4</a> <a class="idx" href="exception.html#idx:format3:749">4.11.4</a> <a class="idx" href="exception.html#idx:format3:752">4.11.4</a> <a class="idx" href="exception.html#idx:format3:763">4.11.4</a> <a class="idx" href="exception.html#idx:format3:767">4.11.4.1</a> <a class="idx" href="IO.html#idx:format3:963">4.17.1</a> <a class="idx" href="IO.html#idx:format3:1056">4.17.5</a> <a class="idx" href="termrw.html#idx:format3:1119">4.20</a> <a class="idx" href="manipatom.html#idx:format3:1256">4.22</a> <a class="idx" href="manipatom.html#idx:format3:1269">4.22</a> <a class="idx" href="locale.html#idx:format3:1289">4.23</a> <a class="idx" href="chartype.html#idx:format3:1307">4.24.2</a> <a class="idx" href="arith.html#idx:format3:1333">4.27.2.1</a> <a class="idx" href="arith.html#idx:format3:1335">4.27.2.2</a> <a class="idx" href="format.html#idx:format3:1390">4.32</a> <a class="idx" href="format.html#idx:format3:1406">4.32.2</a> <a class="idx" href="format.html#idx:format3:1411">4.32.3</a> <a class="idx" href="strings.html#idx:format3:1614">5.2.2</a> <a class="idx" href="strings.html#idx:format3:1623">5.2.3</a></dd>
11681131 <dt>format/[1,2]</dt>
11691132 <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>
1133 <a class="idx" href="termrw.html#idx:format12:1116">4.20</a> <a class="idx" href="predsummary.html#idx:format12:2360">F.1</a></dd>
11711134 <dt>format/[2,3]</dt>
11721135 <dd>
1173 <a class="idx" href="syntax.html#idx:format23:218">2.16.1.3</a></dd>
1136 <a class="idx" href="syntax.html#idx:format23:220">2.16.1.3</a></dd>
11741137 <dt><a class="idx" href="format.html#format_predicate/2">format_predicate/2</a></dt>
11751138 <dt><a class="idx" href="system.html#format_time/3">format_time/3</a></dt>
11761139 <dd>
1177 <a class="idx" href="flags.html#idx:formattime3:137">2.11</a> <a class="idx" href="locale.html#idx:formattime3:1284">4.23</a> <a class="idx" href="format.html#idx:formattime3:1410">4.32.3</a> <a class="idx" href="system.html#idx:formattime3:1456">4.35</a></dd>
1140 <a class="idx" href="flags.html#idx:formattime3:139">2.11</a> <a class="idx" href="locale.html#idx:formattime3:1286">4.23</a> <a class="idx" href="format.html#idx:formattime3:1412">4.32.3</a> <a class="idx" href="system.html#idx:formattime3:1458">4.35</a></dd>
11781141 <dt><a class="idx" href="system.html#format_time/4">format_time/4</a></dt>
11791142 <dd>
1180 <a class="idx" href="system.html#idx:formattime4:1484">4.35.2.2</a> <a class="idx" href="system.html#idx:formattime4:1485">4.35.2.2</a> <a class="idx" href="system.html#idx:formattime4:1486">4.35.2.2</a> <a class="idx" href="system.html#idx:formattime4:1487">4.35.2.2</a></dd>
1143 <a class="idx" href="system.html#idx:formattime4:1486">4.35.2.2</a> <a class="idx" href="system.html#idx:formattime4:1487">4.35.2.2</a> <a class="idx" href="system.html#idx:formattime4:1488">4.35.2.2</a> <a class="idx" href="system.html#idx:formattime4:1489">4.35.2.2</a></dd>
11811144 <dt><a class="idx" href="charsio.html#format_to_chars/3">format_to_chars/3</a></dt>
11821145 <dt><a class="idx" href="charsio.html#format_to_chars/4">format_to_chars/4</a></dt>
11831146 <dt><a class="idx" href="aggregate.html#free_variables/4">free_variables/4</a></dt>
11841147 <dt><a class="idx" href="coroutining.html#freeze/2">freeze/2</a></dt>
11851148 <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>
1149 <a class="idx" href="coroutining.html#idx:freeze2:1797">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1806">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1808">7.2</a> <a class="idx" href="coroutining.html#idx:freeze2:1809">7.2</a></dd>
11871150 <dt><a class="idx" href="coroutining.html#frozen/2">frozen/2</a></dt>
11881151 <dt>functor</dt>
11891152 <dd>
1190 <a class="idx" href="glossary.html#idx:functor:2298">D</a></dd>
1153 <a class="idx" href="glossary.html#idx:functor:2297">D</a></dd>
11911154 <dt><a class="idx" href="manipterm.html#functor/3">functor/3</a></dt>
11921155 <dd>
1193 <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>
1156 <a class="idx" href="typetest.html#idx:functor3:611">4.6</a> <a class="idx" href="examineprog.html#idx:functor3:908">4.16</a> <a class="idx" href="manipterm.html#idx:functor3:1193">4.21</a> <a class="idx" href="manipterm.html#idx:functor3:1196">4.21</a> <a class="idx" href="manipterm.html#idx:functor3:1197">4.21</a> <a class="idx" href="gvar.html#idx:functor3:1435">4.33.1</a> <a class="idx" href="ext-syntax.html#idx:functor3:1628">5.3.2</a> <a class="idx" href="dicts.html#idx:functor3:1634">5.4.1</a></dd>
11941157 <dt><a class="idx" href="memory.html#garbage_collect/0">garbage_collect/0</a></dt>
11951158 <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>
1159 <a class="idx" href="engine-examples.html#idx:garbagecollect0:1984">10.1.3</a> <a class="idx" href="engine-resources.html#idx:garbagecollect0:1990">10.2</a></dd>
11971160 <dt><a class="idx" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a></dt>
11981161 <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>
1200 <dt><a class="idx" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a></dt>
1201 <dd>
1202 <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>
1162 <a class="idx" href="flags.html#idx:garbagecollectatoms0:86">2.11</a> <a class="idx" href="memory.html#idx:garbagecollectatoms0:1578">4.42</a> <a class="idx" href="engine-resources.html#idx:garbagecollectatoms0:1986">10.2</a> <a class="idx" href="foreigninclude.html#idx:garbagecollectatoms0:2076">11.4.19</a></dd>
1163 <dt><a class="idx" href="memory.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a></dt>
1164 <dd>
1165 <a class="idx" href="jitindex.html#idx:garbagecollectclauses0:259">2.18</a> <a class="idx" href="jitindex.html#idx:garbagecollectclauses0:260">2.18</a> <a class="idx" href="consulting.html#idx:garbagecollectclauses0:559">4.3.2</a> <a class="idx" href="consulting.html#idx:garbagecollectclauses0:561">4.3.2</a> <a class="idx" href="db.html#idx:garbagecollectclauses0:803">4.14</a></dd>
12031166 <dt><a class="idx" href="guitracer.html#gdebug/0">gdebug/0</a></dt>
12041167 <dt><a class="idx" href="assoc.html#gen_assoc/3">gen_assoc/3</a></dt>
12051168 <dt><a class="idx" href="nb_set.html#gen_nb_set/2">gen_nb_set/2</a></dt>
12071170 <dt><a class="idx" href="gensym.html#gensym/2">gensym/2</a></dt>
12081171 <dt><a class="idx" href="chario.html#get/1">get/1</a></dt>
12091172 <dd>
1210 <a class="idx" href="chario.html#idx:get1:1094">4.19</a> <a class="idx" href="chario.html#idx:get1:1096">4.19</a></dd>
1173 <a class="idx" href="chario.html#idx:get1:1096">4.19</a> <a class="idx" href="chario.html#idx:get1:1098">4.19</a></dd>
12111174 <dt><a class="idx" href="chario.html#get/2">get/2</a></dt>
12121175 <dt><a class="idx" href="chario.html#get0/1">get0/1</a></dt>
12131176 <dd>
1214 <a class="idx" href="IO.html#idx:get01:977">4.17.2</a> <a class="idx" href="chario.html#idx:get01:1089">4.19</a> <a class="idx" href="chario.html#idx:get01:1091">4.19</a> <a class="idx" href="chario.html#idx:get01:1093">4.19</a> <a class="idx" href="chario.html#idx:get01:1095">4.19</a> <a class="idx" href="chario.html#idx:get01:1097">4.19</a></dd>
1177 <a class="idx" href="IO.html#idx:get01:979">4.17.2</a> <a class="idx" href="chario.html#idx:get01:1091">4.19</a> <a class="idx" href="chario.html#idx:get01:1093">4.19</a> <a class="idx" href="chario.html#idx:get01:1095">4.19</a> <a class="idx" href="chario.html#idx:get01:1097">4.19</a> <a class="idx" href="chario.html#idx:get01:1099">4.19</a></dd>
12151178 <dt><a class="idx" href="chario.html#get0/2">get0/2</a></dt>
12161179 <dd>
1217 <a class="idx" href="chario.html#idx:get02:1098">4.19</a></dd>
1180 <a class="idx" href="chario.html#idx:get02:1100">4.19</a></dd>
12181181 <dt><a class="idx" href="assoc.html#get_assoc/3">get_assoc/3</a></dt>
12191182 <dd>
1220 <a class="idx" href="dicts.html#idx:getassoc3:1656">5.4.3</a></dd>
1183 <a class="idx" href="dicts.html#idx:getassoc3:1655">5.4.3</a></dd>
12211184 <dt><a class="idx" href="assoc.html#get_assoc/5">get_assoc/5</a></dt>
12221185 <dt><a class="idx" href="attvar.html#get_attr/3">get_attr/3</a></dt>
12231186 <dd>
1224 <a class="idx" href="attvar.html#idx:getattr3:1794">7.1.4</a></dd>
1187 <a class="idx" href="attvar.html#idx:getattr3:1793">7.1.4</a></dd>
12251188 <dt><a class="idx" href="attvar.html#get_attrs/2">get_attrs/2</a></dt>
12261189 <dd>
1227 <a class="idx" href="attvar.html#idx:getattrs2:1796">7.1.4</a></dd>
1190 <a class="idx" href="attvar.html#idx:getattrs2:1795">7.1.4</a></dd>
12281191 <dt><a class="idx" href="chario.html#get_byte/1">get_byte/1</a></dt>
12291192 <dd>
1230 <a class="idx" href="chario.html#idx:getbyte1:1090">4.19</a></dd>
1193 <a class="idx" href="chario.html#idx:getbyte1:1092">4.19</a></dd>
12311194 <dt><a class="idx" href="chario.html#get_byte/2">get_byte/2</a></dt>
12321195 <dd>
1233 <a class="idx" href="chario.html#idx:getbyte2:1086">4.19</a></dd>
1196 <a class="idx" href="chario.html#idx:getbyte2:1088">4.19</a></dd>
12341197 <dt>get_byte/[1,2]</dt>
12351198 <dd>
1236 <a class="idx" href="chars.html#idx:getbyte12:351">4.2</a></dd>
1199 <a class="idx" href="chars.html#idx:getbyte12:353">4.2</a></dd>
12371200 <dt><a class="idx" href="chario.html#get_char/1">get_char/1</a></dt>
12381201 <dd>
1239 <a class="idx" href="chario.html#idx:getchar1:1083">4.19</a></dd>
1202 <a class="idx" href="chario.html#idx:getchar1:1085">4.19</a></dd>
12401203 <dt><a class="idx" href="chario.html#get_char/2">get_char/2</a></dt>
12411204 <dd>
1242 <a class="idx" href="chario.html#idx:getchar2:1085">4.19</a></dd>
1205 <a class="idx" href="chario.html#idx:getchar2:1087">4.19</a></dd>
12431206 <dt>get_char/[1,2]</dt>
12441207 <dd>
1245 <a class="idx" href="chars.html#idx:getchar12:349">4.2</a></dd>
1208 <a class="idx" href="chars.html#idx:getchar12:351">4.2</a></dd>
12461209 <dt><a class="idx" href="chario.html#get_code/1">get_code/1</a></dt>
12471210 <dd>
1248 <a class="idx" href="chars.html#idx:getcode1:342">4.2</a> <a class="idx" href="IO.html#idx:getcode1:955">4.17.1</a> <a class="idx" href="chario.html#idx:getcode1:1088">4.19</a> <a class="idx" href="chario.html#idx:getcode1:1100">4.19</a> <a class="idx" href="chario.html#idx:getcode1:1102">4.19</a></dd>
1211 <a class="idx" href="chars.html#idx:getcode1:344">4.2</a> <a class="idx" href="IO.html#idx:getcode1:957">4.17.1</a> <a class="idx" href="chario.html#idx:getcode1:1090">4.19</a> <a class="idx" href="chario.html#idx:getcode1:1102">4.19</a> <a class="idx" href="chario.html#idx:getcode1:1104">4.19</a></dd>
12491212 <dt><a class="idx" href="chario.html#get_code/2">get_code/2</a></dt>
12501213 <dd>
1251 <a class="idx" href="widechars.html#idx:getcode2:266">2.19.1</a> <a class="idx" href="IO.html#idx:getcode2:1007">4.17.2</a> <a class="idx" href="chario.html#idx:getcode2:1087">4.19</a> <a class="idx" href="chario.html#idx:getcode2:1092">4.19</a> <a class="idx" href="chario.html#idx:getcode2:1104">4.19</a> <a class="idx" href="chario.html#idx:getcode2:1108">4.19</a></dd>
1214 <a class="idx" href="widechars.html#idx:getcode2:268">2.19.1</a> <a class="idx" href="IO.html#idx:getcode2:1009">4.17.2</a> <a class="idx" href="chario.html#idx:getcode2:1089">4.19</a> <a class="idx" href="chario.html#idx:getcode2:1094">4.19</a> <a class="idx" href="chario.html#idx:getcode2:1106">4.19</a> <a class="idx" href="chario.html#idx:getcode2:1110">4.19</a></dd>
12521215 <dt>get_code/[1,2]</dt>
12531216 <dd>
1254 <a class="idx" href="chars.html#idx:getcode12:350">4.2</a></dd>
1217 <a class="idx" href="chars.html#idx:getcode12:352">4.2</a></dd>
12551218 <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>
12581219 <dt><a class="idx" href="dicts.html#get_dict/5">get_dict/5</a></dt>
12591220 <dt>get_dict_ex/3</dt>
12601221 <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>
1222 <a class="idx" href="dicts.html#idx:getdictex3:1637">5.4.1</a></dd>
12621223 <dt><a class="idx" href="db.html#get_flag/2">get_flag/2</a></dt>
12631224 <dt><a class="idx" href="chario.html#get_single_char/1">get_single_char/1</a></dt>
12641225 <dd>
1265 <a class="idx" href="cmdline.html#idx:getsinglechar1:30">2.4.2</a> <a class="idx" href="flags.html#idx:getsinglechar1:146">2.11</a></dd>
1226 <a class="idx" href="cmdline.html#idx:getsinglechar1:31">2.4.2</a> <a class="idx" href="flags.html#idx:getsinglechar1:148">2.11</a></dd>
12661227 <dt><a class="idx" href="strings.html#get_string_code/3">get_string_code/3</a></dt>
12671228 <dt><a class="idx" href="system.html#get_time/1">get_time/1</a></dt>
12681229 <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>
1230 <a class="idx" href="files.html#idx:gettime1:1505">4.36</a> <a class="idx" href="statistics.html#idx:gettime1:1565">4.40</a> <a class="idx" href="threadcom.html#idx:gettime1:1891">9.3.1</a> <a class="idx" href="threadcom.html#idx:gettime1:1905">9.3.1</a></dd>
12701231 <dt><a class="idx" href="system.html#getenv/2">getenv/2</a></dt>
12711232 <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>
1233 <a class="idx" href="system.html#idx:getenv2:1452">4.35</a> <a class="idx" href="www_browser.html#idx:getenv2:2152">A.18</a></dd>
12731234 <dt><a class="idx" href="random.html#getrand/1">getrand/1</a></dt>
12741235 <dt><a class="idx" href="clpfd.html#global_cardinality/2">global_cardinality/2</a></dt>
12751236 <dt><a class="idx" href="clpfd.html#global_cardinality/3">global_cardinality/3</a></dt>
12761237 <dt><a class="idx" href="url.html#global_url/3">global_url/3</a></dt>
12771238 <dt>go/0</dt>
12781239 <dd>
1279 <a class="idx" href="ext-syntax.html#idx:go0:1630">5.3.2</a></dd>
1240 <a class="idx" href="ext-syntax.html#idx:go0:1633">5.3.2</a></dd>
12801241 <dt>goal</dt>
12811242 <dd>
1282 <a class="idx" href="glossary.html#idx:goal:2299">D</a></dd>
1243 <a class="idx" href="glossary.html#idx:goal:2298">D</a></dd>
12831244 <dt><a class="idx" href="consulting.html#goal_expansion/2">goal_expansion/2</a></dt>
12841245 <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>
1246 <a class="idx" href="flags.html#idx:goalexpansion2:166">2.11</a> <a class="idx" href="consulting.html#idx:goalexpansion2:371">4.3</a> <a class="idx" href="consulting.html#idx:goalexpansion2:487">4.3</a> <a class="idx" href="consulting.html#idx:goalexpansion2:521">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:529">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:535">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:538">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:541">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:544">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:548">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:549">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:552">4.3.1</a> <a class="idx" href="consulting.html#idx:goalexpansion2:556">4.3.1.2</a> <a class="idx" href="consulting.html#idx:goalexpansion2:563">4.3.2</a> <a class="idx" href="dialect.html#idx:goalexpansion2:2257">C</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2261">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2266">C.1</a> <a class="idx" href="portabilitystrategies.html#idx:goalexpansion2:2268">C.1</a> <a class="idx" href="predsummary.html#idx:goalexpansion2:2356">F.1</a></dd>
12861247 <dt><a class="idx" href="consulting.html#goal_expansion/4">goal_expansion/4</a></dt>
12871248 <dd>
1288 <a class="idx" href="consulting.html#idx:goalexpansion4:370">4.3</a></dd>
1249 <a class="idx" href="consulting.html#idx:goalexpansion4:372">4.3</a></dd>
12891250 <dt><a class="idx" href="typetest.html#ground/1">ground/1</a></dt>
12901251 <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>
1252 <a class="idx" href="cyclic.html#idx:ground1:242">2.17</a> <a class="idx" href="db.html#idx:ground1:869">4.14.6</a> <a class="idx" href="manipterm.html#idx:ground1:1212">4.21</a> <a class="idx" href="foreigninclude.html#idx:ground1:2020">11.4.3.1</a></dd>
12921253 <dt><a class="idx" href="solutionsequences.html#group_by/4">group_by/4</a></dt>
12931254 <dt><a class="idx" href="pairs.html#group_pairs_by_key/2">group_pairs_by_key/2</a></dt>
12941255 <dt><a class="idx" href="guitracer.html#gspy/1">gspy/1</a></dt>
12951256 <dt><a class="idx" href="guitracer.html#gtrace/0">gtrace/0</a></dt>
12961257 <dd>
1297 <a class="idx" href="thutil.html#idx:gtrace0:1945">9.5.1</a></dd>
1258 <a class="idx" href="thutil.html#idx:gtrace0:1944">9.5.1</a></dd>
12981259 <dt><a class="idx" href="guitracer.html#guitracer/0">guitracer/0</a></dt>
12991260 <dd>
1300 <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>
1261 <a class="idx" href="guitracer.html#idx:guitracer0:317">3.5.1</a> <a class="idx" href="guitracer.html#idx:guitracer0:323">3.5.1</a> <a class="idx" href="idesummary.html#idx:guitracer0:332">3.9</a> <a class="idx" href="debugger.html#idx:guitracer0:1543">4.39</a></dd>
13011262 <dt><a class="idx" href="xref.html#gxref/0">gxref/0</a></dt>
13021263 <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>
1264 <a class="idx" href="help.html#idx:gxref0:53">2.6</a> <a class="idx" href="import.html#idx:gxref0:1687">6.3</a> <a class="idx" href="runtime.html#idx:gxref0:2111">12</a> <a class="idx" href="prolog_xref.html#idx:gxref0:2154">A.27</a></dd>
13041265 <dt><a class="idx" href="toplevel.html#halt/0">halt/0</a></dt>
13051266 <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>
1267 <a class="idx" href="quickstart.html#idx:halt0:17">2.1.5</a> <a class="idx" href="debugoverview.html#idx:halt0:69">2.9</a> <a class="idx" href="flags.html#idx:halt0:141">2.11</a> <a class="idx" href="consulting.html#idx:halt0:502">4.3</a> <a class="idx" href="consulting.html#idx:halt0:514">4.3</a> <a class="idx" href="predsummary.html#idx:halt0:2354">F.1</a></dd>
13071268 <dt><a class="idx" href="toplevel.html#halt/1">halt/1</a></dt>
13081269 <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>
1270 <a class="idx" href="flags.html#idx:halt1:108">2.11</a> <a class="idx" href="toplevel.html#idx:halt1:1531">4.37</a> <a class="idx" href="foreigninclude.html#idx:halt1:2066">11.4.16</a> <a class="idx" href="predsummary.html#idx:halt1:2352">F.1</a></dd>
13101271 <dt>halt/[0,1]</dt>
13111272 <dd>
1312 <a class="idx" href="consulting.html#idx:halt01:498">4.3</a></dd>
1273 <a class="idx" href="consulting.html#idx:halt01:500">4.3</a></dd>
13131274 <dt><a class="idx" href="error.html#has_type/2">has_type/2</a></dt>
13141275 <dt>hashing</dt>
13151276 <dd>
1316 <a class="idx" href="glossary.html#idx:hashing:2301">D</a></dd>
1277 <a class="idx" href="glossary.html#idx:hashing:2300">D</a></dd>
13171278 <dt>head</dt>
13181279 <dd>
1319 <a class="idx" href="glossary.html#idx:head:2302">D</a></dd>
1280 <a class="idx" href="glossary.html#idx:head:2301">D</a></dd>
13201281 <dt><a class="idx" href="help.html#help/0">help/0</a></dt>
13211282 <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>
1283 <a class="idx" href="hooks.html#idx:help0:188">2.12</a> <a class="idx" href="useresource.html#idx:help0:2125">12.3</a> <a class="idx" href="intlibs.html#idx:help0:2233">B.7</a> <a class="idx" href="intlibs.html#idx:help0:2235">B.7</a></dd>
13231284 <dt><a class="idx" href="help.html#help/1">help/1</a></dt>
13241285 <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>
1286 <a class="idx" href="help.html#idx:help1:49">2.6</a> <a class="idx" href="flags.html#idx:help1:164">2.11</a> <a class="idx" href="hooks.html#idx:help1:189">2.12</a> <a class="idx" href="intlibs.html#idx:help1:2234">B.7</a> <a class="idx" href="intlibs.html#idx:help1:2236">B.7</a> <a class="idx" href="intlibs.html#idx:help1:2237">B.7</a></dd>
13261287 <dt>hooks</dt>
13271288 <dd>
1328 <a class="idx" href="hooks.html#idx:hooks:167">2.12</a></dd>
1289 <a class="idx" href="hooks.html#idx:hooks:169">2.12</a></dd>
13291290 <dt><a class="idx" href="url.html#http_location/2">http_location/2</a></dt>
13301291 <dt>http_open/3</dt>
13311292 <dd>
1332 <a class="idx" href="exception.html#idx:httpopen3:770">4.11.4.1</a></dd>
1293 <a class="idx" href="exception.html#idx:httpopen3:772">4.11.4.1</a></dd>
13331294 <dt>http_timestamp/2</dt>
13341295 <dd>
1335 <a class="idx" href="system.html#idx:httptimestamp2:1488">4.35.2.2</a></dd>
1296 <a class="idx" href="system.html#idx:httptimestamp2:1490">4.35.2.2</a></dd>
13361297 <dt>if, directive</dt>
13371298 <dd>
1338 <a class="idx" href="consulting.html#idx:ifdirective:552">4.3.1.2</a></dd>
1299 <a class="idx" href="consulting.html#idx:ifdirective:554">4.3.1.2</a></dd>
13391300 <dt><a class="idx" href="consulting.html#if/1">if/1</a></dt>
13401301 <dd>
1341 <a class="idx" href="consulting.html#idx:if1:487">4.3</a></dd>
1302 <a class="idx" href="consulting.html#idx:if1:489">4.3</a></dd>
13421303 <dt><a class="idx" href="metacall.html#ignore/1">ignore/1</a></dt>
13431304 <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>
1305 <a class="idx" href="profile.html#idx:ignore1:1573">4.41.1</a> <a class="idx" href="threadcreate.html#idx:ignore1:1846">9.1</a></dd>
13451306 <dt>immediate, update view</dt>
13461307 <dd>
1347 <a class="idx" href="db.html#idx:immediateupdateview:860">4.14.5</a></dd>
1308 <a class="idx" href="db.html#idx:immediateupdateview:862">4.14.5</a></dd>
13481309 <dt><a class="idx" href="altmoduleapi.html#import/1">import/1</a></dt>
13491310 <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>
1311 <a class="idx" href="altmoduleapi.html#idx:import1:1734">6.11</a> <a class="idx" href="dynamic-modules.html#idx:import1:1737">6.12</a></dd>
13511312 <dt><a class="idx" href="importmodule.html#import_module/2">import_module/2</a></dt>
13521313 <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>
1314 <a class="idx" href="examineprog.html#idx:importmodule2:905">4.16</a> <a class="idx" href="importmodule.html#idx:importmodule2:1725">6.9</a> <a class="idx" href="importmodule.html#idx:importmodule2:1726">6.9</a></dd>
13541315 <dt>imported predicate</dt>
13551316 <dd>
1356 <a class="idx" href="glossary.html#idx:importedpredicate:2303">D</a></dd>
1317 <a class="idx" href="glossary.html#idx:importedpredicate:2302">D</a></dd>
13571318 <dt><a class="idx" href="clpfd.html#in/2">in/2</a></dt>
13581319 <dt><a class="idx" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a></dt>
13591320 <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>
1321 <a class="idx" href="mt-xpce.html#idx:inpcethread1:1959">9.7</a> <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></dd>
13611322 <dt><a class="idx" href="mt-xpce.html#in_pce_thread_sync/1">in_pce_thread_sync/1</a></dt>
13621323 <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>
1324 <a class="idx" href="mt-xpce.html#idx:inpcethreadsync1:1962">9.7</a> <a class="idx" href="mt-xpce.html#idx:inpcethreadsync1:1964">9.7</a></dd>
13641325 <dt><a class="idx" href="consulting.html#include/1">include/1</a></dt>
13651326 <dd>
1366 <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>
1327 <a class="idx" href="consulting.html#idx:include1:364">4.3</a> <a class="idx" href="consulting.html#idx:include1:397">4.3</a> <a class="idx" href="consulting.html#idx:include1:439">4.3</a> <a class="idx" href="consulting.html#idx:include1:441">4.3</a> <a class="idx" href="consulting.html#idx:include1:442">4.3</a> <a class="idx" href="consulting.html#idx:include1:444">4.3</a> <a class="idx" href="consulting.html#idx:include1:445">4.3</a> <a class="idx" href="consulting.html#idx:include1:446">4.3</a> <a class="idx" href="consulting.html#idx:include1:477">4.3</a> <a class="idx" href="consulting.html#idx:include1:478">4.3</a> <a class="idx" href="consulting.html#idx:include1:481">4.3</a> <a class="idx" href="examineprog.html#idx:include1:947">4.16</a></dd>
13671328 <dt><a class="idx" href="apply.html#include/3">include/3</a></dt>
13681329 <dt>indexing</dt>
13691330 <dd>
1370 <a class="idx" href="glossary.html#idx:indexing:2305">D</a></dd>
1331 <a class="idx" href="glossary.html#idx:indexing:2304">D</a></dd>
13711332 <dt>indexing,term-hashes</dt>
13721333 <dd>
1373 <a class="idx" href="db.html#idx:indexingtermhashes:864">4.14.6</a></dd>
1334 <a class="idx" href="db.html#idx:indexingtermhashes:866">4.14.6</a></dd>
13741335 <dt><a class="idx" href="clpfd.html#indomain/1">indomain/1</a></dt>
13751336 <dt><a class="idx" href="clpqr.html#inf/2">inf/2</a></dt>
13761337 <dt>infinite trees</dt>
13771338 <dd>
1378 <a class="idx" href="cyclic.html#idx:infinitetrees:229">2.17</a></dd>
1339 <a class="idx" href="cyclic.html#idx:infinitetrees:231">2.17</a></dd>
13791340 <dt><a class="idx" href="consulting.html#initialization/0">initialization/0</a></dt>
13801341 <dt><a class="idx" href="consulting.html#initialization/1">initialization/1</a></dt>
13811342 <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>
1343 <a class="idx" href="consulting.html#idx:initialization1:379">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:505">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:506">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:508">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:511">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:512">4.3</a> <a class="idx" href="consulting.html#idx:initialization1:565">4.3.2</a> <a class="idx" href="consulting.html#idx:initialization1:576">4.3.2.2</a> <a class="idx" href="gvar.html#idx:initialization1:1419">4.33</a> <a class="idx" href="threadcreate.html#idx:initialization1:1866">9.1</a> <a class="idx" href="threadcreate.html#idx:initialization1:1867">9.1</a> <a class="idx" href="foreignlink.html#idx:initialization1:2014">11.2.2</a> <a class="idx" href="foreigninclude.html#idx:initialization1:2078">11.4.21</a> <a class="idx" href="qsavelimits.html#idx:initialization1:2116">12.1</a></dd>
13831344 <dt><a class="idx" href="consulting.html#initialization/2">initialization/2</a></dt>
13841345 <dd>
1385 <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>
1346 <a class="idx" href="cmdline.html#idx:initialization2:34">2.4.2</a> <a class="idx" href="compilation.html#idx:initialization2:74">2.10.2.1</a> <a class="idx" href="flags.html#idx:initialization2:140">2.11</a> <a class="idx" href="consulting.html#idx:initialization2:566">4.3.2</a></dd>
13861347 <dt>initialize/0</dt>
13871348 <dd>
1388 <a class="idx" href="cmdline.html#idx:initialize0:34">2.4.2</a> <a class="idx" href="consulting.html#idx:initialize0:511">4.3</a></dd>
1349 <a class="idx" href="cmdline.html#idx:initialize0:35">2.4.2</a> <a class="idx" href="consulting.html#idx:initialize0:513">4.3</a></dd>
13891350 <dt><a class="idx" href="clpfd.html#ins/2">ins/2</a></dt>
13901351 <dt><a class="idx" href="db.html#instance/2">instance/2</a></dt>
13911352 <dt>instantiation</dt>
13921353 <dd>
1393 <a class="idx" href="glossary.html#idx:instantiation:2309">D</a></dd>
1354 <a class="idx" href="glossary.html#idx:instantiation:2308">D</a></dd>
13941355 <dt><a class="idx" href="error.html#instantiation_error/1">instantiation_error/1</a></dt>
13951356 <dd>
1396 <a class="idx" href="foreigninclude.html#idx:instantiationerror1:2032">11.4.6</a></dd>
1357 <a class="idx" href="foreigninclude.html#idx:instantiationerror1:2031">11.4.6</a></dd>
13971358 <dt>integer</dt>
13981359 <dd>
1399 <a class="idx" href="glossary.html#idx:integer:2306">D</a></dd>
1360 <a class="idx" href="glossary.html#idx:integer:2305">D</a></dd>
14001361 <dt>integer,unbounded</dt>
14011362 <dd>
1402 <a class="idx" href="arith.html#idx:integerunbounded:1326">4.27.2.1</a></dd>
1363 <a class="idx" href="arith.html#idx:integerunbounded:1328">4.27.2.1</a></dd>
14031364 <dt>integer//1</dt>
14041365 <dd>
1405 <a class="idx" href="DCG.html#idx:integer1:783">4.13</a></dd>
1366 <a class="idx" href="DCG.html#idx:integer1:785">4.13</a></dd>
14061367 <dt><a class="idx" href="typetest.html#integer/1">integer/1</a></dt>
14071368 <dd>
1408 <a class="idx" href="typetest.html#idx:integer1:606">4.6</a></dd>
1369 <a class="idx" href="typetest.html#idx:integer1:608">4.6</a></dd>
14091370 <dt><a class="idx" href="thutil.html#interactor/0">interactor/0</a></dt>
14101371 <dd>
1411 <a class="idx" href="IO.html#idx:interactor0:1017">4.17.2</a></dd>
1372 <a class="idx" href="IO.html#idx:interactor0:1019">4.17.2</a></dd>
14121373 <dt>internationalization</dt>
14131374 <dd>
1414 <a class="idx" href="widechars.html#idx:internationalization:265">2.19</a></dd>
1375 <a class="idx" href="widechars.html#idx:internationalization:267">2.19</a></dd>
14151376 <dt>interpreted</dt>
14161377 <dd>
1417 <a class="idx" href="glossary.html#idx:interpreted:2308">D</a></dd>
1378 <a class="idx" href="glossary.html#idx:interpreted:2307">D</a></dd>
14181379 <dt><a class="idx" href="lists.html#intersection/3">intersection/3</a></dt>
14191380 <dt><a class="idx" href="arith.html#is/2">is/2</a></dt>
14201381 <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>
1382 <a class="idx" href="arith.html#idx:is2:1327">4.27.2</a> <a class="idx" href="arith.html#idx:is2:1332">4.27.2.1</a> <a class="idx" href="arith.html#idx:is2:1338">4.27.2.3</a> <a class="idx" href="sicstus-chr.html#idx:is2:1828">8.6.1</a></dd>
14221383 <dt><a class="idx" href="files.html#is_absolute_file_name/1">is_absolute_file_name/1</a></dt>
14231384 <dt><a class="idx" href="url.html#is_absolute_url/1">is_absolute_url/1</a></dt>
14241385 <dt><a class="idx" href="assoc.html#is_assoc/1">is_assoc/1</a></dt>
14281389 <dt><a class="idx" href="yall.html#is_lambda/1">is_lambda/1</a></dt>
14291390 <dt><a class="idx" href="builtinlist.html#is_list/1">is_list/1</a></dt>
14301391 <dd>
1431 <a class="idx" href="builtinlist.html#idx:islist1:1342">4.29</a> <a class="idx" href="builtinlist.html#idx:islist1:1343">4.29</a> <a class="idx" href="builtinlist.html#idx:islist1:1344">4.29</a></dd>
1392 <a class="idx" href="builtinlist.html#idx:islist1:1344">4.29</a> <a class="idx" href="builtinlist.html#idx:islist1:1345">4.29</a> <a class="idx" href="builtinlist.html#idx:islist1:1346">4.29</a></dd>
14321393 <dt><a class="idx" href="error.html#is_of_type/2">is_of_type/2</a></dt>
14331394 <dt><a class="idx" href="ordsets.html#is_ordset/1">is_ordset/1</a></dt>
14341395 <dt><a class="idx" href="lists.html#is_set/1">is_set/1</a></dt>
14361397 <dt><a class="idx" href="thmonitor.html#is_thread/1">is_thread/1</a></dt>
14371398 <dt><a class="idx" href="db.html#is_trie/1">is_trie/1</a></dt>
14381399 <dd>
1439 <a class="idx" href="db.html#idx:istrie1:855">4.14.4</a></dd>
1400 <a class="idx" href="db.html#idx:istrie1:857">4.14.4</a></dd>
14401401 <dt>jiti_list/0</dt>
14411402 <dd>
1442 <a class="idx" href="jitindex.html#idx:jitilist0:259">2.18</a></dd>
1403 <a class="idx" href="jitindex.html#idx:jitilist0:261">2.18</a></dd>
14431404 <dt>jitindex</dt>
14441405 <dd>
1445 <a class="idx" href="jitindex.html#idx:jitindex:255">2.18</a></dd>
1406 <a class="idx" href="jitindex.html#idx:jitindex:257">2.18</a></dd>
14461407 <dt><a class="idx" href="thutil.html#join_threads/0">join_threads/0</a></dt>
14471408 <dd>
1448 <a class="idx" href="thutil.html#idx:jointhreads0:1941">9.5</a></dd>
1409 <a class="idx" href="thutil.html#idx:jointhreads0:1940">9.5</a></dd>
14491410 <dt><a class="idx" href="builtinlist.html#keysort/2">keysort/2</a></dt>
14501411 <dd>
1451 <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>
1412 <a class="idx" href="builtinlist.html#idx:keysort2:1354">4.29</a> <a class="idx" href="builtinlist.html#idx:keysort2:1358">4.29</a> <a class="idx" href="builtinlist.html#idx:keysort2:1362">4.29</a></dd>
14521413 <dt><a class="idx" href="softlicense.html#known_licenses/0">known_licenses/0</a></dt>
14531414 <dd>
1454 <a class="idx" href="softlicense.html#idx:knownlicenses0:2345">E.2</a></dd>
1415 <a class="idx" href="softlicense.html#idx:knownlicenses0:2344">E.2</a></dd>
14551416 <dt><a class="idx" href="clpfd.html#label/1">label/1</a></dt>
14561417 <dt><a class="idx" href="clpb.html#labeling/1">labeling/1</a></dt>
14571418 <dt><a class="idx" href="clpfd.html#labeling/2">labeling/2</a></dt>
14581419 <dt><a class="idx" href="yall.html#lambda_calls/2">lambda_calls/2</a></dt>
14591420 <dt><a class="idx" href="yall.html#lambda_calls/3">lambda_calls/3</a></dt>
14601421 <dt><a class="idx" href="lists.html#last/2">last/2</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>
1422 <dt><a class="idx" href="pio.html#lazy_list_character_count/1">lazy_list_character_count/1</a></dt>
1423 <dt><a class="idx" href="pio.html#lazy_list_location/1">lazy_list_location/1</a></dt>
14631424 <dt><a class="idx" href="debugger.html#leash/1">leash/1</a></dt>
14641425 <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>
1426 <a class="idx" href="debugoverview.html#idx:leash1:61">2.9</a> <a class="idx" href="debugger.html#idx:leash1:1559">4.39</a> <a class="idx" href="debugging.html#idx:leash1:1825">8.4.3</a> <a class="idx" href="tracehook.html#idx:leash1:2192">B.3</a></dd>
14661427 <dt><a class="idx" href="builtinlist.html#length/2">length/2</a></dt>
14671428 <dd>
1468 <a class="idx" href="dicts.html#idx:length2:1635">5.4.1.1</a></dd>
1429 <a class="idx" href="dicts.html#idx:length2:1638">5.4.1.1</a></dd>
14691430 <dt><a class="idx" href="clpfd.html#lex_chain/1">lex_chain/1</a></dt>
14701431 <dt><a class="idx" href="consulting.html#library_directory/1">library_directory/1</a></dt>
14711432 <dd>
1472 <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>
1433 <a class="idx" href="autoload.html#idx:librarydirectory1:191">2.13</a> <a class="idx" href="autoload.html#idx:librarydirectory1:197">2.13</a> <a class="idx" href="autoload.html#idx:librarydirectory1:201">2.13</a> <a class="idx" href="autoload.html#idx:librarydirectory1:203">2.13</a></dd>
14731434 <dt><a class="idx" href="softlicense.html#license/0">license/0</a></dt>
14741435 <dd>
1475 <a class="idx" href="softlicense.html#idx:license0:2344">E.2</a></dd>
1436 <a class="idx" href="softlicense.html#idx:license0:2343">E.2</a></dd>
14761437 <dt><a class="idx" href="softlicense.html#license/1">license/1</a></dt>
14771438 <dd>
1478 <a class="idx" href="contrib.html#idx:license1:2343">E.1</a></dd>
1439 <a class="idx" href="contrib.html#idx:license1:2342">E.1</a></dd>
14791440 <dt><a class="idx" href="softlicense.html#license/2">license/2</a></dt>
14801441 <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>
1442 <a class="idx" href="softlicense.html#idx:license2:2345">E.2</a> <a class="idx" href="softlicense.html#idx:license2:2346">E.2</a></dd>
14821443 <dt><a class="idx" href="solutionsequences.html#limit/2">limit/2</a></dt>
14831444 <dt><a class="idx" href="streamstat.html#line_count/2">line_count/2</a></dt>
14841445 <dd>
1485 <a class="idx" href="IO.html#idx:linecount2:999">4.17.2</a> <a class="idx" href="IO.html#idx:linecount2:1026">4.17.2</a> <a class="idx" href="tty.html#idx:linecount2:1435">4.34</a></dd>
1446 <a class="idx" href="IO.html#idx:linecount2:1001">4.17.2</a> <a class="idx" href="IO.html#idx:linecount2:1028">4.17.2</a> <a class="idx" href="tty.html#idx:linecount2:1437">4.34</a></dd>
14861447 <dt><a class="idx" href="streamstat.html#line_position/2">line_position/2</a></dt>
14871448 <dd>
1488 <a class="idx" href="IO.html#idx:lineposition2:1000">4.17.2</a> <a class="idx" href="IO.html#idx:lineposition2:1020">4.17.2</a> <a class="idx" href="IO.html#idx:lineposition2:1027">4.17.2</a> <a class="idx" href="tty.html#idx:lineposition2:1436">4.34</a></dd>
1449 <a class="idx" href="IO.html#idx:lineposition2:1002">4.17.2</a> <a class="idx" href="IO.html#idx:lineposition2:1022">4.17.2</a> <a class="idx" href="IO.html#idx:lineposition2:1029">4.17.2</a> <a class="idx" href="tty.html#idx:lineposition2:1438">4.34</a></dd>
14891450 <dt><a class="idx" href="check.html#list_autoload/0">list_autoload/0</a></dt>
14901451 <dt><a class="idx" href="debug.html#list_debug_topics/0">list_debug_topics/0</a></dt>
14911452 <dt><a class="idx" href="check.html#list_redefined/0">list_redefined/0</a></dt>
14921453 <dt><a class="idx" href="strings.html#list_strings/0">list_strings/0</a></dt>
14931454 <dd>
1494 <a class="idx" href="extensions.html#idx:liststrings0:1588">5</a> <a class="idx" href="strings.html#idx:liststrings0:1616">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1617">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1618">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1619">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1624">5.2.4</a></dd>
1455 <a class="idx" href="extensions.html#idx:liststrings0:1591">5</a> <a class="idx" href="strings.html#idx:liststrings0:1619">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1620">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1621">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1622">5.2.3</a> <a class="idx" href="strings.html#idx:liststrings0:1627">5.2.4</a></dd>
14951456 <dt><a class="idx" href="check.html#list_strings/1">list_strings/1</a></dt>
14961457 <dt><a class="idx" href="assoc.html#list_to_assoc/2">list_to_assoc/2</a></dt>
14971458 <dd>
1498 <a class="idx" href="dicts.html#idx:listtoassoc2:1655">5.4.3</a></dd>
1459 <a class="idx" href="dicts.html#idx:listtoassoc2:1654">5.4.3</a></dd>
14991460 <dt><a class="idx" href="ordsets.html#list_to_ord_set/2">list_to_ord_set/2</a></dt>
15001461 <dt><a class="idx" href="lists.html#list_to_set/2">list_to_set/2</a></dt>
15011462 <dt><a class="idx" href="check.html#list_trivial_fails/0">list_trivial_fails/0</a></dt>
15021463 <dt><a class="idx" href="check.html#list_trivial_fails/1">list_trivial_fails/1</a></dt>
15031464 <dt><a class="idx" href="check.html#list_undefined/0">list_undefined/0</a></dt>
15041465 <dd>
1505 <a class="idx" href="flags.html#idx:listundefined0:98">2.11</a> <a class="idx" href="consulting.html#idx:listundefined0:459">4.3</a> <a class="idx" href="examineprog.html#idx:listundefined0:931">4.16</a></dd>
1466 <a class="idx" href="flags.html#idx:listundefined0:99">2.11</a> <a class="idx" href="consulting.html#idx:listundefined0:461">4.3</a> <a class="idx" href="examineprog.html#idx:listundefined0:933">4.16</a></dd>
15061467 <dt><a class="idx" href="check.html#list_undefined/1">list_undefined/1</a></dt>
15071468 <dt><a class="idx" href="check.html#list_void_declarations/0">list_void_declarations/0</a></dt>
15081469 <dt><a class="idx" href="broadcast.html#listen/2">listen/2</a></dt>
15091470 <dd>
1510 <a class="idx" href="broadcast.html#idx:listen2:2143">A.4</a></dd>
1471 <a class="idx" href="broadcast.html#idx:listen2:2142">A.4</a></dd>
15111472 <dt><a class="idx" href="broadcast.html#listen/3">listen/3</a></dt>
15121473 <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>
1474 <a class="idx" href="broadcast.html#idx:listen3:2144">A.4</a> <a class="idx" href="broadcast.html#idx:listen3:2145">A.4</a> <a class="idx" href="broadcast.html#idx:listen3:2146">A.4</a></dd>
15141475 <dt><a class="idx" href="broadcast.html#listening/3">listening/3</a></dt>
15151476 <dt><a class="idx" href="listing.html#listing/0">listing/0</a></dt>
15161477 <dd>
15171478 <a class="idx" href="quickstart.html#idx:listing0:16">2.1.4</a></dd>
15181479 <dt><a class="idx" href="listing.html#listing/1">listing/1</a></dt>
15191480 <dd>
1520 <a class="idx" href="quickstart.html#idx:listing1:13">2.1.4</a> <a class="idx" href="quickstart.html#idx:listing1:14">2.1.4</a> <a class="idx" href="debugoverview.html#idx:listing1:65">2.9</a> <a class="idx" href="listing.html#idx:listing1:598">4.5</a></dd>
1481 <a class="idx" href="quickstart.html#idx:listing1:13">2.1.4</a> <a class="idx" href="quickstart.html#idx:listing1:14">2.1.4</a> <a class="idx" href="debugoverview.html#idx:listing1:66">2.9</a> <a class="idx" href="listing.html#idx:listing1:600">4.5</a></dd>
15211482 <dt><a class="idx" href="consulting.html#load_files/1">load_files/1</a></dt>
15221483 <dt><a class="idx" href="consulting.html#load_files/2">load_files/2</a></dt>
15231484 <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>
1485 <a class="idx" href="flags.html#idx:loadfiles2:132">2.11</a> <a class="idx" href="flags.html#idx:loadfiles2:134">2.11</a> <a class="idx" href="flags.html#idx:loadfiles2:156">2.11</a> <a class="idx" href="hooks.html#idx:loadfiles2:175">2.12</a> <a class="idx" href="hooks.html#idx:loadfiles2:177">2.12</a> <a class="idx" href="hooks.html#idx:loadfiles2:178">2.12</a> <a class="idx" href="widechars.html#idx:loadfiles2:270">2.19.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:381">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:387">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:395">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:396">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:398">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:415">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:425">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:427">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:430">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:479">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:480">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:482">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:483">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:485">4.3</a> <a class="idx" href="consulting.html#idx:loadfiles2:569">4.3.2.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:572">4.3.2.1</a> <a class="idx" href="consulting.html#idx:loadfiles2:575">4.3.2.2</a> <a class="idx" href="consulting.html#idx:loadfiles2:577">4.3.2.2</a> <a class="idx" href="consulting.html#idx:loadfiles2:586">4.3.3</a> <a class="idx" href="debugger.html#idx:loadfiles2:1561">4.39</a> <a class="idx" href="import.html#idx:loadfiles2:1679">6.3</a> <a class="idx" href="prolog_xref.html#idx:loadfiles2:2155">A.27</a> <a class="idx" href="loadfilehook.html#idx:loadfiles2:2239">B.8</a> <a class="idx" href="loadfilehook.html#idx:loadfiles2:2241">B.8</a> <a class="idx" href="dialect.html#idx:loadfiles2:2258">C</a> <a class="idx" href="predsummary.html#idx:loadfiles2:2369">F.1</a></dd>
15251486 <dt><a class="idx" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a></dt>
15261487 <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>
1488 <a class="idx" href="consulting.html#idx:loadforeignlibrary1:509">4.3</a> <a class="idx" href="foreignlink.html#idx:loadforeignlibrary1:2016">11.2.4</a> <a class="idx" href="plld.html#idx:loadforeignlibrary1:2090">11.5</a> <a class="idx" href="qsaveforeign.html#idx:loadforeignlibrary1:2119">12.2</a></dd>
15281489 <dt><a class="idx" href="foreignlink.html#load_foreign_library/2">load_foreign_library/2</a></dt>
15291490 <dt>locale</dt>
15301491 <dd>
1531 <a class="idx" href="chartype.html#idx:locale:1306">4.24.3</a></dd>
1492 <a class="idx" href="chartype.html#idx:locale:1308">4.24.3</a></dd>
15321493 <dt><a class="idx" href="locale.html#locale_create/3">locale_create/3</a></dt>
15331494 <dd>
1534 <a class="idx" href="locale.html#idx:localecreate3:1289">4.23</a></dd>
1495 <a class="idx" href="locale.html#idx:localecreate3:1291">4.23</a></dd>
15351496 <dt><a class="idx" href="locale.html#locale_destroy/1">locale_destroy/1</a></dt>
15361497 <dd>
1537 <a class="idx" href="locale.html#idx:localedestroy1:1288">4.23</a></dd>
1498 <a class="idx" href="locale.html#idx:localedestroy1:1290">4.23</a></dd>
15381499 <dt><a class="idx" href="locale.html#locale_property/2">locale_property/2</a></dt>
15391500 <dt><a class="idx" href="chartype.html#locale_sort/2">locale_sort/2</a></dt>
15401501 <dd>
1541 <a class="idx" href="locale.html#idx:localesort2:1283">4.23</a> <a class="idx" href="chartype.html#idx:localesort2:1310">4.24.3</a> <a class="idx" href="chartype.html#idx:localesort2:1311">4.24.3</a> <a class="idx" href="system.html#idx:localesort2:1458">4.35</a></dd>
1502 <a class="idx" href="locale.html#idx:localesort2:1285">4.23</a> <a class="idx" href="chartype.html#idx:localesort2:1312">4.24.3</a> <a class="idx" href="chartype.html#idx:localesort2:1313">4.24.3</a> <a class="idx" href="system.html#idx:localesort2:1460">4.35</a></dd>
15421503 <dt>logical,update view</dt>
15431504 <dd>
1544 <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>
1505 <a class="idx" href="db.html#idx:logicalupdateview:861">4.14.5</a></dd>
15481506 <dt><a class="idx" href="main.html#main/0">main/0</a></dt>
15491507 <dd>
1550 <a class="idx" href="compilation.html#idx:main0:74">2.10.2.1</a></dd>
1508 <a class="idx" href="compilation.html#idx:main0:75">2.10.2.1</a></dd>
15511509 <dt>main/1</dt>
15521510 <dd>
1553 <a class="idx" href="compilation.html#idx:main1:75">2.10.2.1</a></dd>
1511 <a class="idx" href="compilation.html#idx:main1:76">2.10.2.1</a></dd>
15541512 <dt><a class="idx" href="consulting.html#make/0">make/0</a></dt>
15551513 <dd>
1556 <a class="idx" href="swiorother.html#idx:make0:1">1.3</a> <a class="idx" href="quickstart.html#idx:make0:7">2.1.2</a> <a class="idx" href="quickstart.html#idx:make0:11">2.1.4</a> <a class="idx" href="quickstart.html#idx:make0:12">2.1.4</a> <a class="idx" href="flags.html#idx:make0:97">2.11</a> <a class="idx" href="autoload.html#idx:make0:194">2.13</a> <a class="idx" href="autoload.html#idx:make0:204">2.13</a> <a class="idx" href="editreload.html#idx:make0:307">3.3.2</a> <a class="idx" href="editreload.html#idx:make0:308">3.3.2</a> <a class="idx" href="pceemacs.html#idx:make0:311">3.4.3.1</a> <a class="idx" href="idesummary.html#idx:make0:329">3.9</a> <a class="idx" href="consulting.html#idx:make0:400">4.3</a> <a class="idx" href="consulting.html#idx:make0:418">4.3</a> <a class="idx" href="consulting.html#idx:make0:433">4.3</a> <a class="idx" href="consulting.html#idx:make0:436">4.3</a> <a class="idx" href="consulting.html#idx:make0:455">4.3</a> <a class="idx" href="consulting.html#idx:make0:457">4.3</a> <a class="idx" href="consulting.html#idx:make0:458">4.3</a> <a class="idx" href="consulting.html#idx:make0:482">4.3</a> <a class="idx" href="consulting.html#idx:make0:556">4.3.2</a> <a class="idx" href="consulting.html#idx:make0:560">4.3.2</a></dd>
1514 <a class="idx" href="swiorother.html#idx:make0:1">1.3</a> <a class="idx" href="quickstart.html#idx:make0:7">2.1.2</a> <a class="idx" href="quickstart.html#idx:make0:11">2.1.4</a> <a class="idx" href="quickstart.html#idx:make0:12">2.1.4</a> <a class="idx" href="flags.html#idx:make0:98">2.11</a> <a class="idx" href="autoload.html#idx:make0:196">2.13</a> <a class="idx" href="autoload.html#idx:make0:206">2.13</a> <a class="idx" href="editreload.html#idx:make0:309">3.3.2</a> <a class="idx" href="editreload.html#idx:make0:310">3.3.2</a> <a class="idx" href="pceemacs.html#idx:make0:313">3.4.3.1</a> <a class="idx" href="idesummary.html#idx:make0:331">3.9</a> <a class="idx" href="consulting.html#idx:make0:402">4.3</a> <a class="idx" href="consulting.html#idx:make0:420">4.3</a> <a class="idx" href="consulting.html#idx:make0:435">4.3</a> <a class="idx" href="consulting.html#idx:make0:438">4.3</a> <a class="idx" href="consulting.html#idx:make0:457">4.3</a> <a class="idx" href="consulting.html#idx:make0:459">4.3</a> <a class="idx" href="consulting.html#idx:make0:460">4.3</a> <a class="idx" href="consulting.html#idx:make0:484">4.3</a> <a class="idx" href="consulting.html#idx:make0:558">4.3.2</a> <a class="idx" href="consulting.html#idx:make0:562">4.3.2</a></dd>
15571515 <dt><a class="idx" href="files.html#make_directory/1">make_directory/1</a></dt>
15581516 <dd>
1559 <a class="idx" href="system.html#idx:makedirectory1:1444">4.35</a></dd>
1517 <a class="idx" href="system.html#idx:makedirectory1:1446">4.35</a></dd>
15601518 <dt><a class="idx" href="autoload.html#make_library_index/1">make_library_index/1</a></dt>
15611519 <dd>
1562 <a class="idx" href="autoload.html#idx:makelibraryindex1:198">2.13</a></dd>
1520 <a class="idx" href="autoload.html#idx:makelibraryindex1:200">2.13</a></dd>
15631521 <dt><a class="idx" href="autoload.html#make_library_index/2">make_library_index/2</a></dt>
15641522 <dd>
1565 <a class="idx" href="autoload.html#idx:makelibraryindex2:197">2.13</a></dd>
1523 <a class="idx" href="autoload.html#idx:makelibraryindex2:199">2.13</a></dd>
15661524 <dt>make_library_index/[1,2]</dt>
15671525 <dd>
1568 <a class="idx" href="autoload.html#idx:makelibraryindex12:203">2.13</a></dd>
1526 <a class="idx" href="autoload.html#idx:makelibraryindex12:205">2.13</a></dd>
15691527 <dt><a class="idx" href="assoc.html#map_assoc/2">map_assoc/2</a></dt>
15701528 <dt><a class="idx" href="assoc.html#map_assoc/3">map_assoc/3</a></dt>
15711529 <dt><a class="idx" href="pairs.html#map_list_to_pairs/3">map_list_to_pairs/3</a></dt>
15721530 <dt><a class="idx" href="apply.html#maplist/2">maplist/2</a></dt>
15731531 <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>
1532 <a class="idx" href="forall2.html#idx:maplist2:1382">4.31</a> <a class="idx" href="ext-issues.html#idx:maplist2:1660">5.6</a></dd>
15751533 <dt><a class="idx" href="apply.html#maplist/3">maplist/3</a></dt>
15761534 <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>
1535 <a class="idx" href="dicts.html#idx:maplist3:1653">5.4.3</a> <a class="idx" href="metapred.html#idx:maplist3:1691">6.4</a> <a class="idx" href="metapred.html#idx:maplist3:1693">6.4</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1740">6.13</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1741">6.13</a></dd>
15781536 <dt><a class="idx" href="apply.html#maplist/4">maplist/4</a></dt>
15791537 <dt><a class="idx" href="apply.html#maplist/5">maplist/5</a></dt>
15801538 <dt>maplist_/3</dt>
15811539 <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>
1540 <a class="idx" href="metapred.html#idx:maplist3:1692">6.4</a> <a class="idx" href="ctxmodule.html#idx:maplist3:1742">6.13</a></dd>
15831541 <dt><a class="idx" href="assoc.html#max_assoc/3">max_assoc/3</a></dt>
15841542 <dt><a class="idx" href="lists.html#max_list/2">max_list/2</a></dt>
15851543 <dt><a class="idx" href="lists.html#max_member/2">max_member/2</a></dt>
15911549 <dt><a class="idx" href="random.html#maybe/2">maybe/2</a></dt>
15921550 <dt><a class="idx" href="lists.html#member/2">member/2</a></dt>
15931551 <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>
1552 <a class="idx" href="debugoverview.html#idx:member2:64">2.9</a> <a class="idx" href="debugoverview.html#idx:member2:65">2.9</a> <a class="idx" href="metacall.html#idx:member2:671">4.9</a> <a class="idx" href="builtinlist.html#idx:member2:1347">4.29</a> <a class="idx" href="files.html#idx:member2:1514">4.36</a> <a class="idx" href="import.html#idx:member2:1680">6.3</a> <a class="idx" href="predsummary.html#idx:member2:2361">F.1</a></dd>
15951553 <dt><a class="idx" href="builtinlist.html#memberchk/2">memberchk/2</a></dt>
15961554 <dd>
1597 <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>
1555 <a class="idx" href="compare.html#idx:memberchk2:641">4.7.2</a> <a class="idx" href="builtinlist.html#idx:memberchk2:1348">4.29</a> <a class="idx" href="builtinlist.html#idx:memberchk2:1349">4.29</a> <a class="idx" href="strings.html#idx:memberchk2:1626">5.2.4</a></dd>
15981556 <dt>memory,layout</dt>
15991557 <dd>
1600 <a class="idx" href="limits.html#idx:memorylayout:282">2.20.1.1</a></dd>
1558 <a class="idx" href="limits.html#idx:memorylayout:284">2.20.1.1</a></dd>
16011559 <dt><a class="idx" href="option.html#merge_options/3">merge_options/3</a></dt>
16021560 <dt>message,service</dt>
16031561 <dd>
1604 <a class="idx" href="broadcast.html#idx:messageservice:2137">A.4</a></dd>
1562 <a class="idx" href="broadcast.html#idx:messageservice:2136">A.4</a></dd>
16051563 <dt><a class="idx" href="exception.html#message_hook/3">message_hook/3</a></dt>
16061564 <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>
1565 <a class="idx" href="exception.html#idx:messagehook3:734">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:737">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:740">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:744">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:745">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:754">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:761">4.11.4</a> <a class="idx" href="exception.html#idx:messagehook3:774">4.11.4.1</a> <a class="idx" href="memory.html#idx:messagehook3:1584">4.42</a> <a class="idx" href="predsummary.html#idx:messagehook3:2372">F.1</a></dd>
16081566 <dt><a class="idx" href="exception.html#message_property/2">message_property/2</a></dt>
16091567 <dd>
1610 <a class="idx" href="flags.html#idx:messageproperty2:94">2.11</a></dd>
1568 <a class="idx" href="flags.html#idx:messageproperty2:95">2.11</a></dd>
16111569 <dt><a class="idx" href="threadcom.html#message_queue_create/1">message_queue_create/1</a></dt>
16121570 <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>
1571 <a class="idx" href="threadcom.html#idx:messagequeuecreate1:1885">9.3.1</a> <a class="idx" href="threadcom.html#idx:messagequeuecreate1:1900">9.3.1</a></dd>
16141572 <dt><a class="idx" href="threadcom.html#message_queue_create/2">message_queue_create/2</a></dt>
16151573 <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>
1574 <a class="idx" href="threadcom.html#idx:messagequeuecreate2:1898">9.3.1</a> <a class="idx" href="threadcom.html#idx:messagequeuecreate2:1911">9.3.1</a></dd>
16171575 <dt>message_queue_create/3</dt>
16181576 <dd>
1619 <a class="idx" href="threadsync.html#idx:messagequeuecreate3:1928">9.4</a></dd>
1577 <a class="idx" href="threadsync.html#idx:messagequeuecreate3:1927">9.4</a></dd>
16201578 <dt><a class="idx" href="threadcom.html#message_queue_destroy/1">message_queue_destroy/1</a></dt>
16211579 <dd>
1622 <a class="idx" href="threadcom.html#idx:messagequeuedestroy1:1904">9.3.1</a></dd>
1580 <a class="idx" href="threadcom.html#idx:messagequeuedestroy1:1903">9.3.1</a></dd>
16231581 <dt><a class="idx" href="threadcom.html#message_queue_property/2">message_queue_property/2</a></dt>
16241582 <dd>
1625 <a class="idx" href="thmonitor.html#idx:messagequeueproperty2:1883">9.2</a></dd>
1583 <a class="idx" href="thmonitor.html#idx:messagequeueproperty2:1882">9.2</a></dd>
16261584 <dt><a class="idx" href="exception.html#message_to_string/2">message_to_string/2</a></dt>
16271585 <dd>
1628 <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>
1586 <a class="idx" href="exception.html#idx:messagetostring2:747">4.11.4</a> <a class="idx" href="exception.html#idx:messagetostring2:758">4.11.4</a></dd>
16291587 <dt>meta-predicate</dt>
16301588 <dd>
1631 <a class="idx" href="glossary.html#idx:metapredicate:2310">D</a></dd>
1589 <a class="idx" href="glossary.html#idx:metapredicate:2309">D</a></dd>
16321590 <dt><a class="idx" href="option.html#meta_options/3">meta_options/3</a></dt>
16331591 <dd>
1634 <a class="idx" href="import.html#idx:metaoptions3:1683">6.3</a></dd>
1592 <a class="idx" href="import.html#idx:metaoptions3:1682">6.3</a></dd>
16351593 <dt><a class="idx" href="metapred.html#meta_predicate/1">meta_predicate/1</a></dt>
16361594 <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>
1595 <a class="idx" href="flags.html#idx:metapredicate1:97">2.11</a> <a class="idx" href="consulting.html#idx:metapredicate1:542">4.3.1</a> <a class="idx" href="typetest.html#idx:metapredicate1:617">4.6</a> <a class="idx" href="examineprog.html#idx:metapredicate1:925">4.16</a> <a class="idx" href="examineprog.html#idx:metapredicate1:926">4.16</a> <a class="idx" href="examineprog.html#idx:metapredicate1:932">4.16</a> <a class="idx" href="metapred.html#idx:metapredicate1:1690">6.4</a> <a class="idx" href="metapred.html#idx:metapredicate1:1694">6.4</a> <a class="idx" href="metapred.html#idx:metapredicate1:1701">6.4</a> <a class="idx" href="ctxmodule.html#idx:metapredicate1:1739">6.13</a> <a class="idx" href="modulecompat.html#idx:metapredicate1:1757">6.15</a> <a class="idx" href="modulecompat.html#idx:metapredicate1:1758">6.15</a> <a class="idx" href="foreigninclude.html#idx:metapredicate1:2044">11.4.9.2</a> <a class="idx" href="foreigninclude.html#idx:metapredicate1:2070">11.4.18</a> <a class="idx" href="runtime.html#idx:metapredicate1:2109">12</a> <a class="idx" href="runtime.html#idx:metapredicate1:2112">12</a></dd>
16381596 <dt>mild/1</dt>
16391597 <dd>
16401598 <a class="idx" href="quickstart.html#idx:mild1:15">2.1.4</a></dd>
16451603 <dt><a class="idx" href="simplex.html#minimize/3">minimize/3</a></dt>
16461604 <dt>mode</dt>
16471605 <dd>
1648 <a class="idx" href="glossary.html#idx:mode:2311">D</a></dd>
1606 <a class="idx" href="glossary.html#idx:mode:2310">D</a></dd>
16491607 <dt>module</dt>
16501608 <dd>
1651 <a class="idx" href="glossary.html#idx:module:2312">D</a></dd>
1609 <a class="idx" href="glossary.html#idx:module:2311">D</a></dd>
16521610 <dt>module transparent</dt>
16531611 <dd>
1654 <a class="idx" href="glossary.html#idx:moduletransparent:2313">D</a></dd>
1612 <a class="idx" href="glossary.html#idx:moduletransparent:2312">D</a></dd>
16551613 <dt>module,contex</dt>
16561614 <dd>
1657 <a class="idx" href="glossary.html#idx:modulecontex:2286">D</a></dd>
1615 <a class="idx" href="glossary.html#idx:modulecontex:2285">D</a></dd>
16581616 <dt><a class="idx" href="mtoplevel.html#module/1">module/1</a></dt>
16591617 <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>
1618 <a class="idx" href="flags.html#idx:module1:144">2.11</a> <a class="idx" href="consulting.html#idx:module1:360">4.3</a> <a class="idx" href="dynamic.html#idx:module1:895">4.15</a> <a class="idx" href="mtoplevel.html#idx:module1:1710">6.6</a> <a class="idx" href="threadcreate.html#idx:module1:1850">9.1</a></dd>
16611619 <dt><a class="idx" href="defmodule.html#module/2">module/2</a></dt>
16621620 <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>
1621 <a class="idx" href="consulting.html#idx:module2:523">4.3.1</a> <a class="idx" href="operators.html#idx:module2:1317">4.25</a> <a class="idx" href="operators.html#idx:module2:1318">4.25</a> <a class="idx" href="defmodule.html#idx:module2:1663">6.2</a> <a class="idx" href="defmodule.html#idx:module2:1664">6.2</a> <a class="idx" href="defmodule.html#idx:module2:1667">6.2</a> <a class="idx" href="import.html#idx:module2:1684">6.3</a> <a class="idx" href="moduleop.html#idx:module2:1720">6.8</a> <a class="idx" href="altmoduleapi.html#idx:module2:1731">6.11</a> <a class="idx" href="modulecompat.html#idx:module2:1759">6.15</a></dd>
16641622 <dt><a class="idx" href="defmodule.html#module/3">module/3</a></dt>
16651623 <dt><a class="idx" href="manipmodule.html#module_property/2">module_property/2</a></dt>
16661624 <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>
1625 <a class="idx" href="manipmodule.html#idx:moduleproperty2:1752">6.14</a> <a class="idx" href="manipmodule.html#idx:moduleproperty2:1754">6.14</a></dd>
16681626 <dt><a class="idx" href="ctxmodule.html#module_transparent/1">module_transparent/1</a></dt>
16691627 <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>
1628 <a class="idx" href="examineprog.html#idx:moduletransparent1:931">4.16</a> <a class="idx" href="metapred.html#idx:moduletransparent1:1702">6.4</a> <a class="idx" href="overrule.html#idx:moduletransparent1:1706">6.5.1</a> <a class="idx" href="modulecompat.html#idx:moduletransparent1:1755">6.15</a> <a class="idx" href="foreigninclude.html#idx:moduletransparent1:2046">11.4.9.2</a> <a class="idx" href="glossary.html#idx:moduletransparent1:2286">D</a></dd>
16711629 <dt><a class="idx" href="builtinlist.html#msort/2">msort/2</a></dt>
16721630 <dd>
1673 <a class="idx" href="builtinlist.html#idx:msort2:1351">4.29</a></dd>
1631 <a class="idx" href="builtinlist.html#idx:msort2:1353">4.29</a></dd>
16741632 <dt>multi</dt>
16751633 <dd>
1676 <a class="idx" href="glossary.html#idx:multi:2315">D</a></dd>
1634 <a class="idx" href="glossary.html#idx:multi:2314">D</a></dd>
16771635 <dt><a class="idx" href="dynamic.html#multifile/1">multifile/1</a></dt>
16781636 <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>
1637 <a class="idx" href="flags.html#idx:multifile1:151">2.11</a> <a class="idx" href="consulting.html#idx:multifile1:437">4.3</a> <a class="idx" href="consulting.html#idx:multifile1:448">4.3</a> <a class="idx" href="dynamic.html#idx:multifile1:878">4.15</a> <a class="idx" href="examineprog.html#idx:multifile1:924">4.16</a> <a class="idx" href="intlibs.html#idx:multifile1:2223">B.7</a> <a class="idx" href="glossary.html#idx:multifile1:2315">D</a></dd>
16801638 <dt><a class="idx" href="error.html#must_be/2">must_be/2</a></dt>
16811639 <dd>
1682 <a class="idx" href="record.html#idx:mustbe2:2170">A.31</a></dd>
1640 <a class="idx" href="record.html#idx:mustbe2:2169">A.31</a></dd>
16831641 <dt><a class="idx" href="threadsync.html#mutex_create/1">mutex_create/1</a></dt>
16841642 <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>
1643 <a class="idx" href="threadsync.html#idx:mutexcreate1:1929">9.4</a> <a class="idx" href="threadsync.html#idx:mutexcreate1:1932">9.4</a></dd>
16861644 <dt><a class="idx" href="threadsync.html#mutex_create/2">mutex_create/2</a></dt>
16871645 <dd>
1688 <a class="idx" href="threadsync.html#idx:mutexcreate2:1940">9.4</a></dd>
1646 <a class="idx" href="threadsync.html#idx:mutexcreate2:1939">9.4</a></dd>
16891647 <dt><a class="idx" href="threadsync.html#mutex_destroy/1">mutex_destroy/1</a></dt>
16901648 <dt><a class="idx" href="threadsync.html#mutex_lock/1">mutex_lock/1</a></dt>
16911649 <dd>
1692 <a class="idx" href="threadsync.html#idx:mutexlock1:1936">9.4</a></dd>
1650 <a class="idx" href="threadsync.html#idx:mutexlock1:1935">9.4</a></dd>
16931651 <dt><a class="idx" href="threadsync.html#mutex_property/2">mutex_property/2</a></dt>
16941652 <dt><a class="idx" href="thmonitor.html#mutex_statistics/0">mutex_statistics/0</a></dt>
16951653 <dt><a class="idx" href="threadsync.html#mutex_trylock/1">mutex_trylock/1</a></dt>
16971655 <dt><a class="idx" href="threadsync.html#mutex_unlock_all/0">mutex_unlock_all/0</a></dt>
16981656 <dt>my_compare/3</dt>
16991657 <dd>
1700 <a class="idx" href="portabilitystrategies.html#idx:mycompare3:2266">C.1</a></dd>
1658 <a class="idx" href="portabilitystrategies.html#idx:mycompare3:2265">C.1</a></dd>
17011659 <dt>mypred/1</dt>
17021660 <dd>
1703 <a class="idx" href="reexport.html#idx:mypred1:1717">6.7</a></dd>
1661 <a class="idx" href="reexport.html#idx:mypred1:1716">6.7</a></dd>
17041662 <dt>name/1</dt>
17051663 <dd>
1706 <a class="idx" href="metapred.html#idx:name1:1689">6.4</a></dd>
1664 <a class="idx" href="metapred.html#idx:name1:1688">6.4</a></dd>
17071665 <dt><a class="idx" href="manipatom.html#name/2">name/2</a></dt>
17081666 <dd>
1709 <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>
1667 <a class="idx" href="manipatom.html#idx:name2:1244">4.22</a> <a class="idx" href="manipatom.html#idx:name2:1247">4.22</a></dd>
17101668 <dt>name_of/2</dt>
17111669 <dd>
1712 <a class="idx" href="broadcast.html#idx:nameof2:2144">A.4</a></dd>
1670 <a class="idx" href="broadcast.html#idx:nameof2:2143">A.4</a></dd>
17131671 <dt><a class="idx" href="gvar.html#nb_current/2">nb_current/2</a></dt>
17141672 <dd>
1715 <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>
1673 <a class="idx" href="gvar.html#idx:nbcurrent2:1428">4.33</a> <a class="idx" href="gvar.html#idx:nbcurrent2:1430">4.33</a></dd>
17161674 <dt><a class="idx" href="gvar.html#nb_delete/1">nb_delete/1</a></dt>
17171675 <dt><a class="idx" href="gvar.html#nb_getval/2">nb_getval/2</a></dt>
17181676 <dd>
1719 <a class="idx" href="gvar.html#idx:nbgetval2:1423">4.33</a> <a class="idx" href="gvar.html#idx:nbgetval2:1425">4.33</a> <a class="idx" href="gvar.html#idx:nbgetval2:1429">4.33</a></dd>
1677 <a class="idx" href="gvar.html#idx:nbgetval2:1425">4.33</a> <a class="idx" href="gvar.html#idx:nbgetval2:1427">4.33</a> <a class="idx" href="gvar.html#idx:nbgetval2:1431">4.33</a></dd>
17201678 <dt><a class="idx" href="dicts.html#nb_link_dict/3">nb_link_dict/3</a></dt>
17211679 <dt><a class="idx" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a></dt>
17221680 <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>
1681 <a class="idx" href="manipterm.html#idx:nblinkarg3:1230">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkarg3:1240">4.21.1</a> <a class="idx" href="dicts.html#idx:nblinkarg3:1647">5.4.2.1</a></dd>
17241682 <dt><a class="idx" href="gvar.html#nb_linkval/2">nb_linkval/2</a></dt>
17251683 <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>
1684 <a class="idx" href="manipterm.html#idx:nblinkval2:1233">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkval2:1234">4.21.1</a> <a class="idx" href="manipterm.html#idx:nblinkval2:1238">4.21.1</a> <a class="idx" href="gvar.html#idx:nblinkval2:1433">4.33.1</a> <a class="idx" href="dicts.html#idx:nblinkval2:1648">5.4.2.1</a> <a class="idx" href="dicts.html#idx:nblinkval2:1649">5.4.2.1</a></dd>
17271685 <dt><a class="idx" href="dicts.html#nb_set_dict/3">nb_set_dict/3</a></dt>
17281686 <dt><a class="idx" href="nb_set.html#nb_set_to_list/2">nb_set_to_list/2</a></dt>
17291687 <dt><a class="idx" href="manipterm.html#nb_setarg/3">nb_setarg/3</a></dt>
17301688 <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>
1689 <a class="idx" href="preddesc.html#idx:nbsetarg3:338">4.1</a> <a class="idx" href="db.html#idx:nbsetarg3:814">4.14</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1221">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1232">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetarg3:1239">4.21.1</a> <a class="idx" href="allsolutions.html#idx:nbsetarg3:1369">4.30</a> <a class="idx" href="dicts.html#idx:nbsetarg3:1645">5.4.2.1</a> <a class="idx" href="nb_set.html#idx:nbsetarg3:2148">A.17</a> <a class="idx" href="record.html#idx:nbsetarg3:2171">A.31</a></dd>
17321690 <dt><a class="idx" href="gvar.html#nb_setval/2">nb_setval/2</a></dt>
17331691 <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>
1692 <a class="idx" href="db.html#idx:nbsetval2:812">4.14</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1228">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1229">4.21.1</a> <a class="idx" href="manipterm.html#idx:nbsetval2:1237">4.21.1</a> <a class="idx" href="gvar.html#idx:nbsetval2:1415">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1418">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1429">4.33</a> <a class="idx" href="gvar.html#idx:nbsetval2:1432">4.33.1</a> <a class="idx" href="dicts.html#idx:nbsetval2:1646">5.4.2.1</a> <a class="idx" href="engine-examples.html#idx:nbsetval2:1977">10.1.2</a> <a class="idx" href="exception3.html#idx:nbsetval2:2220">B.6</a></dd>
17351693 <dt>neck</dt>
17361694 <dd>
1737 <a class="idx" href="glossary.html#idx:neck:2317">D</a></dd>
1695 <a class="idx" href="glossary.html#idx:neck:2316">D</a></dd>
17381696 <dt><a class="idx" href="ugraphs.html#neighbors/3">neighbors/3</a></dt>
17391697 <dt><a class="idx" href="ugraphs.html#neighbours/3">neighbours/3</a></dt>
17401698 <dd>
1741 <a class="idx" href="ugraphs.html#idx:neighbours3:2180">A.37</a></dd>
1699 <a class="idx" href="ugraphs.html#idx:neighbours3:2179">A.37</a></dd>
17421700 <dt><a class="idx" href="lists.html#nextto/3">nextto/3</a></dt>
17431701 <dt><a class="idx" href="chario.html#nl/0">nl/0</a></dt>
17441702 <dd>
1745 <a class="idx" href="chario.html#idx:nl0:1074">4.19</a></dd>
1703 <a class="idx" href="chario.html#idx:nl0:1076">4.19</a></dd>
17461704 <dt><a class="idx" href="chario.html#nl/1">nl/1</a></dt>
17471705 <dt>nl/[0,1]</dt>
17481706 <dd>
1749 <a class="idx" href="format.html#idx:nl01:1390">4.32.1</a></dd>
1707 <a class="idx" href="format.html#idx:nl01:1392">4.32.1</a></dd>
17501708 <dt><a class="idx" href="debugger.html#nodebug/0">nodebug/0</a></dt>
17511709 <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>
1710 <a class="idx" href="debugger.html#idx:nodebug0:1556">4.39</a> <a class="idx" href="tracehook.html#idx:nodebug0:2198">B.3</a></dd>
17531711 <dt><a class="idx" href="debug.html#nodebug/1">nodebug/1</a></dt>
17541712 <dt><a class="idx" href="guitracer.html#noguitracer/0">noguitracer/0</a></dt>
17551713 <dd>
1756 <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>
1714 <a class="idx" href="guitracer.html#idx:noguitracer0:318">3.5.1</a> <a class="idx" href="idesummary.html#idx:noguitracer0:333">3.9</a></dd>
17571715 <dt>non deterministic</dt>
17581716 <dd>
1759 <a class="idx" href="glossary.html#idx:nondeterministic:2319">D</a></dd>
1717 <a class="idx" href="glossary.html#idx:nondeterministic:2318">D</a></dd>
17601718 <dt>nondet</dt>
17611719 <dd>
1762 <a class="idx" href="glossary.html#idx:nondet:2318">D</a></dd>
1720 <a class="idx" href="glossary.html#idx:nondet:2317">D</a></dd>
17631721 <dt><a class="idx" href="manipterm.html#nonground/2">nonground/2</a></dt>
17641722 <dd>
1765 <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>
1723 <a class="idx" href="typetest.html#idx:nonground2:620">4.6</a> <a class="idx" href="manipterm.html#idx:nonground2:1211">4.21</a></dd>
17661724 <dt><a class="idx" href="typetest.html#nonvar/1">nonvar/1</a></dt>
17671725 <dt><a class="idx" href="profile.html#noprofile/1">noprofile/1</a></dt>
17681726 <dt><a class="idx" href="protocol.html#noprotocol/0">noprotocol/0</a></dt>
17691727 <dt><a class="idx" href="chartype.html#normalize_space/2">normalize_space/2</a></dt>
17701728 <dt><a class="idx" href="debugger.html#nospy/1">nospy/1</a></dt>
17711729 <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>
1730 <a class="idx" href="debugoverview.html#idx:nospy1:63">2.9</a> <a class="idx" href="hooks.html#idx:nospy1:185">2.12</a> <a class="idx" href="thutil.html#idx:nospy1:1952">9.5.1</a> <a class="idx" href="intlibs.html#idx:nospy1:2226">B.7</a> <a class="idx" href="intlibs.html#idx:nospy1:2227">B.7</a> <a class="idx" href="intlibs.html#idx:nospy1:2229">B.7</a></dd>
17731731 <dt><a class="idx" href="debugger.html#nospyall/0">nospyall/0</a></dt>
17741732 <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>
1733 <a class="idx" href="hooks.html#idx:nospyall0:186">2.12</a> <a class="idx" href="intlibs.html#idx:nospyall0:2230">B.7</a></dd>
17761734 <dt><a class="idx" href="metacall.html#not/1">not/1</a></dt>
17771735 <dd>
1778 <a class="idx" href="predsummary.html#idx:not1:2350">F.1</a></dd>
1736 <a class="idx" href="predsummary.html#idx:not1:2349">F.1</a></dd>
17791737 <dt><a class="idx" href="debugger.html#notrace/0">notrace/0</a></dt>
17801738 <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>
1739 <a class="idx" href="debugger.html#idx:notrace0:1547">4.39</a> <a class="idx" href="debugging.html#idx:notrace0:1822">8.4.3</a> <a class="idx" href="debugging.html#idx:notrace0:1824">8.4.3</a></dd>
17821740 <dt><a class="idx" href="debugger.html#notrace/1">notrace/1</a></dt>
17831741 <dt><a class="idx" href="lists.html#nth0/3">nth0/3</a></dt>
17841742 <dt><a class="idx" href="lists.html#nth0/4">nth0/4</a></dt>
17861744 <dt><a class="idx" href="lists.html#nth1/4">nth1/4</a></dt>
17871745 <dt><a class="idx" href="examineprog.html#nth_clause/3">nth_clause/3</a></dt>
17881746 <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>
1747 <a class="idx" href="examineprog.html#idx:nthclause3:919">4.16</a> <a class="idx" href="examineprog.html#idx:nthclause3:943">4.16</a> <a class="idx" href="manipstack.html#idx:nthclause3:2183">B.1</a></dd>
17901748 <dt><a class="idx" href="arith.html#nth_integer_root_and_remainder/4">nth_integer_root_and_remainder/4</a></dt>
17911749 <dt>number,rational</dt>
17921750 <dd>
1793 <a class="idx" href="arith.html#idx:numberrational:1328">4.27.2.1</a></dd>
1751 <a class="idx" href="arith.html#idx:numberrational:1330">4.27.2.1</a></dd>
17941752 <dt><a class="idx" href="typetest.html#number/1">number/1</a></dt>
17951753 <dd>
1796 <a class="idx" href="typetest.html#idx:number1:601">4.6</a> <a class="idx" href="typetest.html#idx:number1:603">4.6</a></dd>
1754 <a class="idx" href="typetest.html#idx:number1:603">4.6</a> <a class="idx" href="typetest.html#idx:number1:605">4.6</a></dd>
17971755 <dt><a class="idx" href="manipatom.html#number_chars/2">number_chars/2</a></dt>
17981756 <dd>
1799 <a class="idx" href="chars.html#idx:numberchars2:347">4.2</a> <a class="idx" href="manipatom.html#idx:numberchars2:1256">4.22</a></dd>
1757 <a class="idx" href="chars.html#idx:numberchars2:349">4.2</a> <a class="idx" href="manipatom.html#idx:numberchars2:1258">4.22</a></dd>
18001758 <dt><a class="idx" href="manipatom.html#number_codes/2">number_codes/2</a></dt>
18011759 <dd>
1802 <a class="idx" href="chars.html#idx:numbercodes2:348">4.2</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1241">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1244">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1258">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1259">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1261">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1264">4.22</a></dd>
1760 <a class="idx" href="chars.html#idx:numbercodes2:350">4.2</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1243">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1246">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1260">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1261">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1263">4.22</a> <a class="idx" href="manipatom.html#idx:numbercodes2:1266">4.22</a></dd>
18031761 <dt><a class="idx" href="strings.html#number_string/2">number_string/2</a></dt>
18041762 <dt><a class="idx" href="charsio.html#number_to_chars/2">number_to_chars/2</a></dt>
18051763 <dt><a class="idx" href="charsio.html#number_to_chars/3">number_to_chars/3</a></dt>
18061764 <dt><a class="idx" href="varnumbers.html#numbervars/1">numbervars/1</a></dt>
18071765 <dt><a class="idx" href="manipterm.html#numbervars/3">numbervars/3</a></dt>
18081766 <dd>
1809 <a class="idx" href="cyclic.html#idx:numbervars3:242">2.17</a> <a class="idx" href="termrw.html#idx:numbervars3:1126">4.20</a> <a class="idx" href="manipterm.html#idx:numbervars3:1200">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars3:1201">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars3:1206">4.21</a></dd>
1767 <a class="idx" href="cyclic.html#idx:numbervars3:244">2.17</a> <a class="idx" href="termrw.html#idx:numbervars3:1128">4.20</a> <a class="idx" href="manipterm.html#idx:numbervars3:1202">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars3:1203">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars3:1208">4.21</a></dd>
18101768 <dt><a class="idx" href="manipterm.html#numbervars/4">numbervars/4</a></dt>
18111769 <dd>
1812 <a class="idx" href="cyclic.html#idx:numbervars4:243">2.17</a> <a class="idx" href="termrw.html#idx:numbervars4:1141">4.20</a> <a class="idx" href="termrw.html#idx:numbervars4:1142">4.20</a> <a class="idx" href="manipterm.html#idx:numbervars4:1199">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars4:1202">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars4:1214">4.21</a></dd>
1770 <a class="idx" href="cyclic.html#idx:numbervars4:245">2.17</a> <a class="idx" href="termrw.html#idx:numbervars4:1143">4.20</a> <a class="idx" href="termrw.html#idx:numbervars4:1144">4.20</a> <a class="idx" href="manipterm.html#idx:numbervars4:1201">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars4:1204">4.21</a> <a class="idx" href="manipterm.html#idx:numbervars4:1216">4.21</a></dd>
18131771 <dt><a class="idx" href="lists.html#numlist/3">numlist/3</a></dt>
18141772 <dt><a class="idx" href="simplex.html#objective/2">objective/2</a></dt>
18151773 <dt>occurs_check</dt>
18161774 <dd>
1817 <a class="idx" href="compare.html#idx:occurscheck:629">4.7.2</a></dd>
1775 <a class="idx" href="compare.html#idx:occurscheck:631">4.7.2</a></dd>
18181776 <dt><a class="idx" href="solutionsequences.html#offset/2">offset/2</a></dt>
18191777 <dt><a class="idx" href="signal.html#on_signal/3">on_signal/3</a></dt>
18201778 <dd>
1821 <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>
1779 <a class="idx" href="signal.html#idx:onsignal3:775">4.12</a> <a class="idx" href="signal.html#idx:onsignal3:777">4.12</a></dd>
18221780 <dt><a class="idx" href="metacall.html#once/1">once/1</a></dt>
18231781 <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>
1782 <a class="idx" href="control.html#idx:once1:649">4.8</a> <a class="idx" href="metacall.html#idx:once1:655">4.9</a> <a class="idx" href="metacall.html#idx:once1:656">4.9</a> <a class="idx" href="metacall.html#idx:once1:657">4.9</a> <a class="idx" href="metacall.html#idx:once1:670">4.9</a> <a class="idx" href="IO.html#idx:once1:1052">4.17.5</a> <a class="idx" href="allsolutions.html#idx:once1:1370">4.30</a> <a class="idx" href="toplevel.html#idx:once1:1530">4.37</a> <a class="idx" href="debugger.html#idx:once1:1554">4.39</a> <a class="idx" href="profile.html#idx:once1:1568">4.41.1</a> <a class="idx" href="profile.html#idx:once1:1569">4.41.1</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="threadsync.html#idx:once1:1931">9.4</a> <a class="idx" href="foreigninclude.html#idx:once1:2049">11.4.9.2</a></dd>
18251783 <dt><a class="idx" href="operators.html#op/3">op/3</a></dt>
18261784 <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>
1785 <a class="idx" href="dynamic.html#idx:op3:881">4.15</a> <a class="idx" href="termrw.html#idx:op3:1127">4.20</a> <a class="idx" href="operators.html#idx:op3:1319">4.25</a> <a class="idx" href="moduleop.html#idx:op3:1719">6.8</a></dd>
18281786 <dt><a class="idx" href="IO.html#open/3">open/3</a></dt>
18291787 <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>
1788 <a class="idx" href="flags.html#idx:open3:110">2.11</a> <a class="idx" href="preddesc.html#idx:open3:336">4.1</a> <a class="idx" href="IO.html#idx:open3:949">4.17</a> <a class="idx" href="IO.html#idx:open3:968">4.17.2</a> <a class="idx" href="foreigninclude.html#idx:open3:2032">11.4.6</a></dd>
18311789 <dt><a class="idx" href="IO.html#open/4">open/4</a></dt>
18321790 <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>
1791 <a class="idx" href="widechars.html#idx:open4:271">2.19.1</a> <a class="idx" href="widechars.html#idx:open4:277">2.19.1.1</a> <a class="idx" href="widechars.html#idx:open4:279">2.19.1.1</a> <a class="idx" href="chars.html#idx:open4:342">4.2</a> <a class="idx" href="IO.html#idx:open4:974">4.17.2</a> <a class="idx" href="IO.html#idx:open4:982">4.17.2</a> <a class="idx" href="IO.html#idx:open4:985">4.17.2</a> <a class="idx" href="IO.html#idx:open4:988">4.17.2</a> <a class="idx" href="IO.html#idx:open4:989">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1006">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1017">4.17.2</a> <a class="idx" href="IO.html#idx:open4:1027">4.17.2</a> <a class="idx" href="chario.html#idx:open4:1105">4.19</a> <a class="idx" href="locale.html#idx:open4:1292">4.23</a> <a class="idx" href="files.html#idx:open4:1495">4.36</a> <a class="idx" href="dicts.html#idx:open4:1651">5.4.3</a> <a class="idx" href="dicts.html#idx:open4:1657">5.4.4</a> <a class="idx" href="readutil.html#idx:open4:2163">A.30</a> <a class="idx" href="readutil.html#idx:open4:2167">A.30</a></dd>
18341792 <dt><a class="idx" href="iostream.html#open_any/5">open_any/5</a></dt>
18351793 <dt><a class="idx" href="charsio.html#open_chars_stream/2">open_chars_stream/2</a></dt>
18361794 <dt><a class="idx" href="DDE.html#open_dde_conversation/3">open_dde_conversation/3</a></dt>
18371795 <dt><a class="idx" href="iostream.html#open_hook/6">open_hook/6</a></dt>
18381796 <dt><a class="idx" href="IO.html#open_null_stream/1">open_null_stream/1</a></dt>
18391797 <dd>
1840 <a class="idx" href="IO.html#idx:opennullstream1:1009">4.17.2</a></dd>
1798 <a class="idx" href="IO.html#idx:opennullstream1:1011">4.17.2</a></dd>
18411799 <dt><a class="idx" href="useresource.html#open_resource/3">open_resource/3</a></dt>
18421800 <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>
1801 <a class="idx" href="foreigninclude.html#idx:openresource3:2081">11.4.21</a> <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="runtime.html#idx:openresource3:2100">12</a> <a class="idx" href="useresource.html#idx:openresource3:2124">12.3</a> <a class="idx" href="useresource.html#idx:openresource3:2129">12.3.1</a></dd>
18441802 <dt><a class="idx" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a></dt>
18451803 <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>
1804 <a class="idx" href="flags.html#idx:opensharedobject2:122">2.11</a> <a class="idx" href="system.html#idx:opensharedobject2:1478">4.35.1</a> <a class="idx" href="foreignlink.html#idx:opensharedobject2:2012">11.2.1</a> <a class="idx" href="foreignlink.html#idx:opensharedobject2:2017">11.2.4</a></dd>
18471805 <dt><a class="idx" href="foreignlink.html#open_shared_object/3">open_shared_object/3</a></dt>
18481806 <dd>
1849 <a class="idx" href="foreignlink.html#idx:opensharedobject3:2016">11.2.4</a></dd>
1807 <a class="idx" href="foreignlink.html#idx:opensharedobject3:2015">11.2.4</a></dd>
18501808 <dt><a class="idx" href="strings.html#open_string/2">open_string/2</a></dt>
18511809 <dt>operand</dt>
18521810 <dd>
1853 <a class="idx" href="glossary.html#idx:operand:2321">D</a></dd>
1811 <a class="idx" href="glossary.html#idx:operand:2320">D</a></dd>
18541812 <dt>operator</dt>
18551813 <dd>
1856 <a class="idx" href="glossary.html#idx:operator:2320">D</a></dd>
1814 <a class="idx" href="glossary.html#idx:operator:2319">D</a></dd>
18571815 <dt>operator,and modules</dt>
18581816 <dd>
1859 <a class="idx" href="operators.html#idx:operatorandmodules:1314">4.25</a></dd>
1817 <a class="idx" href="operators.html#idx:operatorandmodules:1316">4.25</a></dd>
18601818 <dt><a class="idx" href="optparse.html#opt_arguments/3">opt_arguments/3</a></dt>
18611819 <dt><a class="idx" href="optparse.html#opt_help/2">opt_help/2</a></dt>
18621820 <dt><a class="idx" href="optparse.html#opt_parse/4">opt_parse/4</a></dt>
18841842 <dt><a class="idx" href="ordsets.html#ord_union/4">ord_union/4</a></dt>
18851843 <dt><a class="idx" href="solutionsequences.html#order_by/2">order_by/2</a></dt>
18861844 <dd>
1887 <a class="idx" href="builtinlist.html#idx:orderby2:1354">4.29</a></dd>
1845 <a class="idx" href="builtinlist.html#idx:orderby2:1356">4.29</a></dd>
18881846 <dt><a class="idx" href="prologpack.html#pack_info/1">pack_info/1</a></dt>
18891847 <dt><a class="idx" href="prologpack.html#pack_install/1">pack_install/1</a></dt>
18901848 <dt><a class="idx" href="prologpack.html#pack_install/2">pack_install/2</a></dt>
19031861 <dt><a class="idx" href="system.html#parse_time/2">parse_time/2</a></dt>
19041862 <dt><a class="idx" href="system.html#parse_time/3">parse_time/3</a></dt>
19051863 <dd>
1906 <a class="idx" href="system.html#idx:parsetime3:1489">4.35.2.2</a></dd>
1864 <a class="idx" href="system.html#idx:parsetime3:1491">4.35.2.2</a></dd>
19071865 <dt><a class="idx" href="optparse.html#parse_type/3">parse_type/3</a></dt>
19081866 <dt><a class="idx" href="url.html#parse_url/2">parse_url/2</a></dt>
19091867 <dt><a class="idx" href="url.html#parse_url/3">parse_url/3</a></dt>
19121870 <dt><a class="idx" href="apply.html#partition/5">partition/5</a></dt>
19131871 <dt><a class="idx" href="mt-xpce.html#pce_dispatch/1">pce_dispatch/1</a></dt>
19141872 <dd>
1915 <a class="idx" href="mt-xpce.html#idx:pcedispatch1:1959">9.7</a></dd>
1873 <a class="idx" href="mt-xpce.html#idx:pcedispatch1:1958">9.7</a></dd>
19161874 <dt>pce_thread/1</dt>
19171875 <dd>
1918 <a class="idx" href="mt-xpce.html#idx:pcethread1:1964">9.7</a></dd>
1876 <a class="idx" href="mt-xpce.html#idx:pcethread1:1963">9.7</a></dd>
19191877 <dt><a class="idx" href="chario.html#peek_byte/1">peek_byte/1</a></dt>
19201878 <dt><a class="idx" href="chario.html#peek_byte/2">peek_byte/2</a></dt>
19211879 <dt>peek_byte/[1,2]</dt>
19221880 <dd>
1923 <a class="idx" href="chars.html#idx:peekbyte12:354">4.2</a></dd>
1881 <a class="idx" href="chars.html#idx:peekbyte12:356">4.2</a></dd>
19241882 <dt><a class="idx" href="chario.html#peek_char/1">peek_char/1</a></dt>
19251883 <dt><a class="idx" href="chario.html#peek_char/2">peek_char/2</a></dt>
19261884 <dt>peek_char/[1,2]</dt>
19271885 <dd>
1928 <a class="idx" href="chars.html#idx:peekchar12:352">4.2</a></dd>
1886 <a class="idx" href="chars.html#idx:peekchar12:354">4.2</a></dd>
19291887 <dt><a class="idx" href="chario.html#peek_code/1">peek_code/1</a></dt>
19301888 <dt><a class="idx" href="chario.html#peek_code/2">peek_code/2</a></dt>
19311889 <dt>peek_code/[1,2]</dt>
19321890 <dd>
1933 <a class="idx" href="chars.html#idx:peekcode12:353">4.2</a></dd>
1891 <a class="idx" href="chars.html#idx:peekcode12:355">4.2</a></dd>
19341892 <dt><a class="idx" href="chario.html#peek_string/3">peek_string/3</a></dt>
19351893 <dt><a class="idx" href="error.html#permission_error/3">permission_error/3</a></dt>
19361894 <dd>
1937 <a class="idx" href="foreigninclude.html#idx:permissionerror3:2038">11.4.6</a></dd>
1895 <a class="idx" href="foreigninclude.html#idx:permissionerror3:2037">11.4.6</a></dd>
19381896 <dt><a class="idx" href="lists.html#permutation/2">permutation/2</a></dt>
19391897 <dt><a class="idx" href="persistency.html#persistent/1">persistent/1</a></dt>
19401898 <dt><a class="idx" href="DCG.html#phrase/2">phrase/2</a></dt>
19411899 <dd>
1942 <a class="idx" href="DCG.html#idx:phrase2:781">4.13</a></dd>
1900 <a class="idx" href="DCG.html#idx:phrase2:783">4.13</a></dd>
19431901 <dt><a class="idx" href="DCG.html#phrase/3">phrase/3</a></dt>
19441902 <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>
1903 <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:790">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:791">4.13</a> <a class="idx" href="DCG.html#idx:phrase3:792">4.13</a> <a class="idx" href="strings.html#idx:phrase3:1612">5.2.2</a> <a class="idx" href="metapred.html#idx:phrase3:1700">6.4</a> <a class="idx" href="predsummary.html#idx:phrase3:2353">F.1</a></dd>
19461904 <dt><a class="idx" href="pio.html#phrase_from_file/2">phrase_from_file/2</a></dt>
19471905 <dt><a class="idx" href="pio.html#phrase_from_file/3">phrase_from_file/3</a></dt>
19481906 <dt><a class="idx" href="quasiquotations.html#phrase_from_quasi_quotation/2">phrase_from_quasi_quotation/2</a></dt>
19501908 <dt><a class="idx" href="arith.html#plus/3">plus/3</a></dt>
19511909 <dt>poll()</dt>
19521910 <dd>
1953 <a class="idx" href="streamstat.html#idx:poll:1069">4.18</a></dd>
1911 <a class="idx" href="streamstat.html#idx:poll:1071">4.18</a></dd>
19541912 <dt>portable,prolog code</dt>
19551913 <dd>
1956 <a class="idx" href="dialect.html#idx:portableprologcode:2248">C</a></dd>
1914 <a class="idx" href="dialect.html#idx:portableprologcode:2247">C</a></dd>
19571915 <dt><a class="idx" href="termrw.html#portray/1">portray/1</a></dt>
19581916 <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>
1917 <a class="idx" href="debugoverview.html#idx:portray1:70">2.9</a> <a class="idx" href="projectfiles.html#idx:portray1:305">3.1.2</a> <a class="idx" href="termrw.html#idx:portray1:1123">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1130">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1132">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1133">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1152">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1153">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1156">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1157">4.20</a> <a class="idx" href="termrw.html#idx:portray1:1158">4.20</a> <a class="idx" href="foreigninclude.html#idx:portray1:2048">11.4.9.2</a> <a class="idx" href="foreigninclude.html#idx:portray1:2077">11.4.20</a> <a class="idx" href="intlibs.html#idx:portray1:2222">B.7</a></dd>
19601918 <dt><a class="idx" href="listing.html#portray_clause/1">portray_clause/1</a></dt>
19611919 <dd>
1962 <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>
1920 <a class="idx" href="listing.html#idx:portrayclause1:598">4.5</a> <a class="idx" href="listing.html#idx:portrayclause1:599">4.5</a> <a class="idx" href="listing.html#idx:portrayclause1:602">4.5</a></dd>
19631921 <dt><a class="idx" href="listing.html#portray_clause/2">portray_clause/2</a></dt>
19641922 <dd>
1965 <a class="idx" href="listing.html#idx:portrayclause2:599">4.5</a> <a class="idx" href="manipterm.html#idx:portrayclause2:1204">4.21</a></dd>
1923 <a class="idx" href="listing.html#idx:portrayclause2:601">4.5</a> <a class="idx" href="manipterm.html#idx:portrayclause2:1206">4.21</a></dd>
19661924 <dt>portray_text/1</dt>
19671925 <dd>
1968 <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>
1926 <a class="idx" href="DCG.html#idx:portraytext1:789">4.13</a> <a class="idx" href="strings.html#idx:portraytext1:1624">5.2.4</a></dd>
19691927 <dt>precedence</dt>
19701928 <dd>
1971 <a class="idx" href="glossary.html#idx:precedence:2322">D</a></dd>
1929 <a class="idx" href="glossary.html#idx:precedence:2321">D</a></dd>
19721930 <dt>pred/1</dt>
19731931 <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>
1932 <a class="idx" href="reexport.html#idx:pred1:1713">6.7</a> <a class="idx" href="reexport.html#idx:pred1:1715">6.7</a></dd>
19751933 <dt>predicate</dt>
19761934 <dd>
1977 <a class="idx" href="glossary.html#idx:predicate:2323">D</a></dd>
1935 <a class="idx" href="glossary.html#idx:predicate:2322">D</a></dd>
19781936 <dt>predicate indicator</dt>
19791937 <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>
1938 <a class="idx" href="preddesc.html#idx:predicateindicator:339">4.1</a> <a class="idx" href="glossary.html#idx:predicateindicator:2323">D</a></dd>
19811939 <dt>predicate,dynamic</dt>
19821940 <dd>
1983 <a class="idx" href="glossary.html#idx:predicatedynamic:2293">D</a></dd>
1941 <a class="idx" href="glossary.html#idx:predicatedynamic:2292">D</a></dd>
19841942 <dt>predicate,exported</dt>
19851943 <dd>
1986 <a class="idx" href="glossary.html#idx:predicateexported:2295">D</a></dd>
1944 <a class="idx" href="glossary.html#idx:predicateexported:2294">D</a></dd>
19871945 <dt>predicate,imported</dt>
19881946 <dd>
1989 <a class="idx" href="glossary.html#idx:predicateimported:2304">D</a></dd>
1947 <a class="idx" href="glossary.html#idx:predicateimported:2303">D</a></dd>
19901948 <dt><a class="idx" href="predicate_options.html#predicate_options/3">predicate_options/3</a></dt>
19911949 <dt><a class="idx" href="examineprog.html#predicate_property/2">predicate_property/2</a></dt>
19921950 <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>
1951 <a class="idx" href="consulting.html#idx:predicateproperty2:412">4.3</a> <a class="idx" href="consulting.html#idx:predicateproperty2:451">4.3</a> <a class="idx" href="consulting.html#idx:predicateproperty2:550">4.3.1</a> <a class="idx" href="metacall.html#idx:predicateproperty2:654">4.9</a> <a class="idx" href="dynamic.html#idx:predicateproperty2:893">4.15</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:903">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:906">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:910">4.16</a> <a class="idx" href="examineprog.html#idx:predicateproperty2:912">4.16</a> <a class="idx" href="metapred.html#idx:predicateproperty2:1695">6.4</a> <a class="idx" href="manipmodule.html#idx:predicateproperty2:1749">6.14</a> <a class="idx" href="manipmodule.html#idx:predicateproperty2:1751">6.14</a></dd>
19941952 <dt><a class="idx" href="builtinlist.html#predsort/3">predsort/3</a></dt>
19951953 <dd>
1996 <a class="idx" href="builtinlist.html#idx:predsort3:1353">4.29</a></dd>
1954 <a class="idx" href="builtinlist.html#idx:predsort3:1355">4.29</a></dd>
19971955 <dt><a class="idx" href="lists.html#prefix/2">prefix/2</a></dt>
19981956 <dt><a class="idx" href="termrw.html#print/1">print/1</a></dt>
19991957 <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>
1958 <a class="idx" href="flags.html#idx:print1:127">2.11</a> <a class="idx" href="termrw.html#idx:print1:1134">4.20</a> <a class="idx" href="termrw.html#idx:print1:1147">4.20</a> <a class="idx" href="termrw.html#idx:print1:1148">4.20</a> <a class="idx" href="termrw.html#idx:print1:1154">4.20</a> <a class="idx" href="termrw.html#idx:print1:1155">4.20</a> <a class="idx" href="termrw.html#idx:print1:1159">4.20</a> <a class="idx" href="format.html#idx:print1:1393">4.32.1</a> <a class="idx" href="format.html#idx:print1:1398">4.32.1</a> <a class="idx" href="format.html#idx:print1:1403">4.32.2</a> <a class="idx" href="foreigninclude.html#idx:print1:2047">11.4.9.2</a> <a class="idx" href="predsummary.html#idx:print1:2364">F.1</a></dd>
20011959 <dt><a class="idx" href="termrw.html#print/2">print/2</a></dt>
20021960 <dd>
2003 <a class="idx" href="flags.html#idx:print2:126">2.11</a></dd>
1961 <a class="idx" href="flags.html#idx:print2:128">2.11</a></dd>
20041962 <dt><a class="idx" href="exception.html#print_message/2">print_message/2</a></dt>
20051963 <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>
1964 <a class="idx" href="flags.html#idx:printmessage2:96">2.11</a> <a class="idx" href="flags.html#idx:printmessage2:155">2.11</a> <a class="idx" href="hooks.html#idx:printmessage2:171">2.12</a> <a class="idx" href="hooks.html#idx:printmessage2:172">2.12</a> <a class="idx" href="consulting.html#idx:printmessage2:400">4.3</a> <a class="idx" href="consulting.html#idx:printmessage2:499">4.3</a> <a class="idx" href="exception.html#idx:printmessage2:717">4.11.1</a> <a class="idx" href="exception.html#idx:printmessage2:732">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:735">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:742">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:748">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:755">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:756">4.11.4</a> <a class="idx" href="exception.html#idx:printmessage2:768">4.11.4.1</a> <a class="idx" href="exception.html#idx:printmessage2:769">4.11.4.1</a> <a class="idx" href="termrw.html#idx:printmessage2:1150">4.20</a> <a class="idx" href="termrw.html#idx:printmessage2:1177">4.20</a> <a class="idx" href="termrw.html#idx:printmessage2:1178">4.20</a> <a class="idx" href="memory.html#idx:printmessage2:1583">4.42</a> <a class="idx" href="threadcreate.html#idx:printmessage2:1845">9.1</a> <a class="idx" href="threadcreate.html#idx:printmessage2:1857">9.1</a> <a class="idx" href="predsummary.html#idx:printmessage2:2362">F.1</a></dd>
20071965 <dt><a class="idx" href="exception.html#print_message_lines/3">print_message_lines/3</a></dt>
20081966 <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>
1967 <a class="idx" href="exception.html#idx:printmessagelines3:743">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:757">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:764">4.11.4</a> <a class="idx" href="exception.html#idx:printmessagelines3:773">4.11.4.1</a> <a class="idx" href="predsummary.html#idx:printmessagelines3:2363">F.1</a></dd>
20101968 <dt>priority</dt>
20111969 <dd>
2012 <a class="idx" href="glossary.html#idx:priority:2325">D</a></dd>
1970 <a class="idx" href="glossary.html#idx:priority:2324">D</a></dd>
20131971 <dt>process_create/3</dt>
20141972 <dd>
2015 <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>
1973 <a class="idx" href="IO.html#idx:processcreate3:973">4.17.2</a> <a class="idx" href="system.html#idx:processcreate3:1450">4.35</a> <a class="idx" href="system.html#idx:processcreate3:1470">4.35.1</a></dd>
20161974 <dt>profile file</dt>
20171975 <dd>
20181976 <a class="idx" href="initfile.html#idx:profilefile:20">2.2</a></dd>
20191977 <dt><a class="idx" href="profile.html#profile/1">profile/1</a></dt>
20201978 <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>
1979 <a class="idx" href="thutil.html#idx:profile1:1954">9.5.2</a> <a class="idx" href="foreigninclude.html#idx:profile1:2088">11.4.21</a></dd>
20221980 <dt><a class="idx" href="profile.html#profile/3">profile/3</a></dt>
20231981 <dt><a class="idx" href="profile.html#profiler/2">profiler/2</a></dt>
20241982 <dt>profiling,foreign code</dt>
20251983 <dd>
2026 <a class="idx" href="foreignnotes.html#idx:profilingforeigncode:2099">11.8.4</a></dd>
1984 <a class="idx" href="foreignnotes.html#idx:profilingforeigncode:2098">11.8.4</a></dd>
20271985 <dt>program</dt>
20281986 <dd>
2029 <a class="idx" href="glossary.html#idx:program:2326">D</a></dd>
1987 <a class="idx" href="glossary.html#idx:program:2325">D</a></dd>
20301988 <dt><a class="idx" href="attvar.html#project_attributes/2">project_attributes/2</a></dt>
20311989 <dd>
2032 <a class="idx" href="attvar.html#idx:projectattributes2:1786">7.1.2</a></dd>
1990 <a class="idx" href="attvar.html#idx:projectattributes2:1785">7.1.2</a></dd>
20331991 <dt><a class="idx" href="toplevel.html#prolog/0">prolog/0</a></dt>
20341992 <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>
1993 <a class="idx" href="cmdline.html#idx:prolog0:44">2.4.4</a> <a class="idx" href="IO.html#idx:prolog0:1032">4.17.2</a> <a class="idx" href="toplevel.html#idx:prolog0:1527">4.37</a> <a class="idx" href="toplevel.html#idx:prolog0:1535">4.37</a> <a class="idx" href="toplevel.html#idx:prolog0:1537">4.37</a> <a class="idx" href="mtoplevel.html#idx:prolog0:1711">6.6</a> <a class="idx" href="foreigninclude.html#idx:prolog0:2085">11.4.21</a> <a class="idx" href="manipstack.html#idx:prolog0:2188">B.1</a></dd>
20361994 <dt><a class="idx" href="debug.html#prolog:assertion_failed/2">prolog:assertion_failed/2</a></dt>
20371995 <dt><a class="idx" href="breakpoint.html#prolog:break_hook/6">prolog:break_hook/6</a></dt>
20381996 <dt><a class="idx" href="prolog_xref.html#prolog:called_by/2">prolog:called_by/2</a></dt>
20411999 <dt><a class="idx" href="debug.html#prolog:debug_print_hook/3">prolog:debug_print_hook/3</a></dt>
20422000 <dt><a class="idx" href="intlibs.html#prolog:help_hook/1">prolog:help_hook/1</a></dt>
20432001 <dt><a class="idx" href="exception.html#prolog:message_line_element/2">prolog:message_line_element/2</a></dt>
2002 <dt><a class="idx" href="signal.html#prolog_alert_signal/2">prolog_alert_signal/2</a></dt>
2003 <dd>
2004 <a class="idx" href="cmdline.html#idx:prologalertsignal2:30">2.4.2</a></dd>
20442005 <dt><a class="idx" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a></dt>
20452006 <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>
2007 <a class="idx" href="manipstack.html#idx:prologchoiceattribute3:2180">B.1</a> <a class="idx" href="tracehook.html#idx:prologchoiceattribute3:2196">B.3</a></dd>
20472008 <dt><a class="idx" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a></dt>
20482009 <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>
2010 <a class="idx" href="manipstack.html#idx:prologcurrentchoice1:2186">B.1</a> <a class="idx" href="ancestral-cut.html#idx:prologcurrentchoice1:2190">B.2</a></dd>
20502011 <dt><a class="idx" href="manipstack.html#prolog_current_frame/1">prolog_current_frame/1</a></dt>
20512012 <dd>
2052 <a class="idx" href="manipstack.html#idx:prologcurrentframe1:2182">B.1</a></dd>
2013 <a class="idx" href="manipstack.html#idx:prologcurrentframe1:2181">B.1</a></dd>
20532014 <dt><a class="idx" href="ancestral-cut.html#prolog_cut_to/1">prolog_cut_to/1</a></dt>
20542015 <dd>
2055 <a class="idx" href="ancestral-cut.html#idx:prologcutto1:2192">B.2</a></dd>
2016 <a class="idx" href="ancestral-cut.html#idx:prologcutto1:2191">B.2</a></dd>
20562017 <dt><a class="idx" href="foreignnotes.html#prolog_debug/1">prolog_debug/1</a></dt>
20572018 <dd>
2058 <a class="idx" href="foreignnotes.html#idx:prologdebug1:2094">11.8.1</a></dd>
2019 <a class="idx" href="foreignnotes.html#idx:prologdebug1:2093">11.8.1</a></dd>
20592020 <dt><a class="idx" href="edit.html#prolog_edit:edit_command/2">prolog_edit:edit_command/2</a></dt>
20602021 <dt><a class="idx" href="edit.html#prolog_edit:edit_source/1">prolog_edit:edit_source/1</a></dt>
20612022 <dt><a class="idx" href="edit.html#prolog_edit:load/0">prolog_edit:load/0</a></dt>
20632024 <dt><a class="idx" href="edit.html#prolog_edit:locate/3">prolog_edit:locate/3</a></dt>
20642025 <dt>prolog_event_hook/1</dt>
20652026 <dd>
2066 <a class="idx" href="exception.html#idx:prologeventhook1:713">4.11.1</a></dd>
2027 <a class="idx" href="exception.html#idx:prologeventhook1:715">4.11.1</a></dd>
20672028 <dt><a class="idx" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a></dt>
20682029 <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>
2030 <a class="idx" href="exception.html#idx:prologexceptionhook4:702">4.11</a> <a class="idx" href="exception.html#idx:prologexceptionhook4:716">4.11.1</a> <a class="idx" href="exception.html#idx:prologexceptionhook4:731">4.11.2</a> <a class="idx" href="memory.html#idx:prologexceptionhook4:1586">4.42</a> <a class="idx" href="excepthook.html#idx:prologexceptionhook4:2207">B.5</a> <a class="idx" href="excepthook.html#idx:prologexceptionhook4:2211">B.5</a></dd>
20702031 <dt><a class="idx" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a></dt>
20712032 <dd>
2072 <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>
2033 <a class="idx" href="consulting.html#idx:prologfiletype2:366">4.3</a> <a class="idx" href="consulting.html#idx:prologfiletype2:474">4.3</a> <a class="idx" href="files.html#idx:prologfiletype2:1512">4.36</a></dd>
20732034 <dt><a class="idx" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a></dt>
20742035 <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>
2036 <a class="idx" href="examineprog.html#idx:prologframeattribute3:944">4.16</a> <a class="idx" href="tracehook.html#idx:prologframeattribute3:2194">B.3</a> <a class="idx" href="tracehook.html#idx:prologframeattribute3:2195">B.3</a> <a class="idx" href="excepthook.html#idx:prologframeattribute3:2209">B.5</a></dd>
20762037 <dt><a class="idx" href="idepreds.html#prolog_ide/1">prolog_ide/1</a></dt>
20772038 <dd>
2078 <a class="idx" href="idepreds.html#idx:prologide1:326">3.8</a></dd>
2039 <a class="idx" href="idepreds.html#idx:prologide1:328">3.8</a></dd>
20792040 <dt><a class="idx" href="intlibs.html#prolog_list_goal/1">prolog_list_goal/1</a></dt>
20802041 <dt><a class="idx" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a></dt>
20812042 <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>
2043 <a class="idx" href="consulting.html#idx:prologloadcontext2:498">4.3</a> <a class="idx" href="consulting.html#idx:prologloadcontext2:543">4.3.1</a> <a class="idx" href="termrw.html#idx:prologloadcontext2:1167">4.20</a> <a class="idx" href="dialect.html#idx:prologloadcontext2:2256">C</a></dd>
20832044 <dt><a class="idx" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a></dt>
20842045 <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>
2046 <a class="idx" href="consulting.html#idx:prologloadfile2:426">4.3</a> <a class="idx" href="loadfilehook.html#idx:prologloadfile2:2240">B.8</a></dd>
20862047 <dt><a class="idx" href="foreignnotes.html#prolog_nodebug/1">prolog_nodebug/1</a></dt>
20872048 <dd>
2088 <a class="idx" href="foreignnotes.html#idx:prolognodebug1:2095">11.8.1</a></dd>
2049 <a class="idx" href="foreignnotes.html#idx:prolognodebug1:2094">11.8.1</a></dd>
20892050 <dt><a class="idx" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a></dt>
20902051 <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>
2052 <a class="idx" href="tracehook.html#idx:prologskipframe1:2200">B.3</a> <a class="idx" href="tracehook.html#idx:prologskipframe1:2201">B.3</a></dd>
20922053 <dt><a class="idx" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a></dt>
20932054 <dd>
2094 <a class="idx" href="tracehook.html#idx:prologskiplevel2:2200">B.3</a></dd>
2055 <a class="idx" href="tracehook.html#idx:prologskiplevel2:2199">B.3</a></dd>
20952056 <dt><a class="idx" href="memory.html#prolog_stack_property/2">prolog_stack_property/2</a></dt>
20962057 <dd>
2097 <a class="idx" href="memory.html#idx:prologstackproperty2:1577">4.42</a></dd>
2058 <a class="idx" href="memory.html#idx:prologstackproperty2:1580">4.42</a></dd>
20982059 <dt><a class="idx" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a></dt>
20992060 <dd>
2100 <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>
2061 <a class="idx" href="projectfiles.html#idx:prologtoosfilename2:298">3.1.1.2</a> <a class="idx" href="projectfiles.html#idx:prologtoosfilename2:299">3.1.1.2</a> <a class="idx" href="system.html#idx:prologtoosfilename2:1474">4.35.1</a> <a class="idx" href="files.html#idx:prologtoosfilename2:1500">4.36</a> <a class="idx" href="files.html#idx:prologtoosfilename2:1516">4.36</a></dd>
21012062 <dt><a class="idx" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a></dt>
21022063 <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>
2064 <a class="idx" href="guitracer.html#idx:prologtraceinterception4:316">3.5</a> <a class="idx" href="debugger.html#idx:prologtraceinterception4:1548">4.39</a> <a class="idx" href="memory.html#idx:prologtraceinterception4:1585">4.42</a> <a class="idx" href="manipstack.html#idx:prologtraceinterception4:2182">B.1</a> <a class="idx" href="manipstack.html#idx:prologtraceinterception4:2185">B.1</a></dd>
21042065 <dt>prompt, alternatives</dt>
21052066 <dd>
2106 <a class="idx" href="flags.html#idx:promptalternatives:127">2.11</a></dd>
2067 <a class="idx" href="flags.html#idx:promptalternatives:129">2.11</a></dd>
21072068 <dt><a class="idx" href="termrw.html#prompt/2">prompt/2</a></dt>
21082069 <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>
2070 <a class="idx" href="termrw.html#idx:prompt2:1188">4.20</a> <a class="idx" href="termrw.html#idx:prompt2:1191">4.20</a> <a class="idx" href="threadcreate.html#idx:prompt2:1849">9.1</a></dd>
21102071 <dt><a class="idx" href="termrw.html#prompt1/1">prompt1/1</a></dt>
21112072 <dt>propagation</dt>
21122073 <dd>
2113 <a class="idx" href="clp.html#idx:propagation:1767">7</a></dd>
2074 <a class="idx" href="clp.html#idx:propagation:1766">7</a></dd>
21142075 <dt><a class="idx" href="lists.html#proper_length/2">proper_length/2</a></dt>
21152076 <dt>property</dt>
21162077 <dd>
2117 <a class="idx" href="glossary.html#idx:property:2327">D</a></dd>
2078 <a class="idx" href="glossary.html#idx:property:2326">D</a></dd>
21182079 <dt><a class="idx" href="protocol.html#protocol/1">protocol/1</a></dt>
21192080 <dd>
2120 <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>
2081 <a class="idx" href="protocol.html#idx:protocol1:1540">4.38</a> <a class="idx" href="protocol.html#idx:protocol1:1541">4.38</a></dd>
21212082 <dt><a class="idx" href="protocol.html#protocola/1">protocola/1</a></dt>
21222083 <dd>
2123 <a class="idx" href="protocol.html#idx:protocola1:1540">4.38</a></dd>
2084 <a class="idx" href="protocol.html#idx:protocola1:1542">4.38</a></dd>
21242085 <dt><a class="idx" href="protocol.html#protocolling/1">protocolling/1</a></dt>
21252086 <dt>prove</dt>
21262087 <dd>
2127 <a class="idx" href="glossary.html#idx:prove:2328">D</a></dd>
2088 <a class="idx" href="glossary.html#idx:prove:2327">D</a></dd>
21282089 <dt>public list</dt>
21292090 <dd>
2130 <a class="idx" href="glossary.html#idx:publiclist:2329">D</a></dd>
2091 <a class="idx" href="glossary.html#idx:publiclist:2328">D</a></dd>
21312092 <dt><a class="idx" href="dynamic.html#public/1">public/1</a></dt>
21322093 <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>
2094 <a class="idx" href="dynamic.html#idx:public1:880">4.15</a> <a class="idx" href="dynamic.html#idx:public1:892">4.15</a> <a class="idx" href="dynamic.html#idx:public1:894">4.15</a> <a class="idx" href="examineprog.html#idx:public1:927">4.16</a> <a class="idx" href="runtime.html#idx:public1:2114">12</a></dd>
21342095 <dt><a class="idx" href="chario.html#put/1">put/1</a></dt>
21352096 <dd>
2136 <a class="idx" href="chario.html#idx:put1:1077">4.19</a></dd>
2097 <a class="idx" href="chario.html#idx:put1:1079">4.19</a></dd>
21372098 <dt><a class="idx" href="chario.html#put/2">put/2</a></dt>
21382099 <dt><a class="idx" href="assoc.html#put_assoc/4">put_assoc/4</a></dt>
21392100 <dt><a class="idx" href="attvar.html#put_attr/3">put_attr/3</a></dt>
21402101 <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>
2102 <a class="idx" href="manipterm.html#idx:putattr3:1225">4.21.1</a> <a class="idx" href="attvar.html#idx:putattr3:1780">7.1.1</a> <a class="idx" href="attvar.html#idx:putattr3:1782">7.1.2</a> <a class="idx" href="attvar.html#idx:putattr3:1792">7.1.4</a></dd>
21422103 <dt><a class="idx" href="attvar.html#put_attrs/2">put_attrs/2</a></dt>
21432104 <dt><a class="idx" href="chario.html#put_byte/1">put_byte/1</a></dt>
21442105 <dt><a class="idx" href="chario.html#put_byte/2">put_byte/2</a></dt>
21452106 <dt>put_byte/[1,2]</dt>
21462107 <dd>
2147 <a class="idx" href="chars.html#idx:putbyte12:357">4.2</a></dd>
2108 <a class="idx" href="chars.html#idx:putbyte12:359">4.2</a></dd>
21482109 <dt><a class="idx" href="chario.html#put_char/1">put_char/1</a></dt>
21492110 <dd>
2150 <a class="idx" href="chario.html#idx:putchar1:1075">4.19</a> <a class="idx" href="chario.html#idx:putchar1:1078">4.19</a></dd>
2111 <a class="idx" href="chario.html#idx:putchar1:1077">4.19</a> <a class="idx" href="chario.html#idx:putchar1:1080">4.19</a></dd>
21512112 <dt><a class="idx" href="chario.html#put_char/2">put_char/2</a></dt>
21522113 <dt>put_char/[1,2]</dt>
21532114 <dd>
2154 <a class="idx" href="chars.html#idx:putchar12:356">4.2</a></dd>
2115 <a class="idx" href="chars.html#idx:putchar12:358">4.2</a></dd>
21552116 <dt><a class="idx" href="chario.html#put_code/1">put_code/1</a></dt>
21562117 <dd>
2157 <a class="idx" href="chario.html#idx:putcode1:1076">4.19</a> <a class="idx" href="chario.html#idx:putcode1:1079">4.19</a></dd>
2118 <a class="idx" href="chario.html#idx:putcode1:1078">4.19</a> <a class="idx" href="chario.html#idx:putcode1:1081">4.19</a></dd>
21582119 <dt><a class="idx" href="chario.html#put_code/2">put_code/2</a></dt>
21592120 <dd>
2160 <a class="idx" href="widechars.html#idx:putcode2:267">2.19.1</a> <a class="idx" href="chario.html#idx:putcode2:1105">4.19</a> <a class="idx" href="chario.html#idx:putcode2:1109">4.19</a> <a class="idx" href="chario.html#idx:putcode2:1111">4.19</a></dd>
2121 <a class="idx" href="widechars.html#idx:putcode2:269">2.19.1</a> <a class="idx" href="chario.html#idx:putcode2:1107">4.19</a> <a class="idx" href="chario.html#idx:putcode2:1111">4.19</a> <a class="idx" href="chario.html#idx:putcode2:1113">4.19</a></dd>
21612122 <dt>put_code/[1,2]</dt>
21622123 <dd>
2163 <a class="idx" href="chars.html#idx:putcode12:355">4.2</a></dd>
2124 <a class="idx" href="chars.html#idx:putcode12:357">4.2</a></dd>
21642125 <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>
21672126 <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>
21702127 <dt><a class="idx" href="consulting.html#qcompile/1">qcompile/1</a></dt>
21712128 <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>
2129 <a class="idx" href="swiorother.html#idx:qcompile1:2">1.3</a> <a class="idx" href="consulting.html#idx:qcompile1:376">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:407">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:414">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:416">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:515">4.3</a> <a class="idx" href="consulting.html#idx:qcompile1:578">4.3.3</a> <a class="idx" href="consulting.html#idx:qcompile1:585">4.3.3</a> <a class="idx" href="guidelines.html#idx:qcompile1:1829">8.7</a></dd>
21732130 <dt><a class="idx" href="consulting.html#qcompile/2">qcompile/2</a></dt>
21742131 <dt><a class="idx" href="runtime.html#qsave_program/1">qsave_program/1</a></dt>
21752132 <dd>
2176 <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>
2133 <a class="idx" href="flags.html#idx:qsaveprogram1:102">2.11</a> <a class="idx" href="consulting.html#idx:qsaveprogram1:504">4.3</a> <a class="idx" href="consulting.html#idx:qsaveprogram1:507">4.3</a></dd>
21772134 <dt><a class="idx" href="runtime.html#qsave_program/2">qsave_program/2</a></dt>
21782135 <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>
2136 <a class="idx" href="swiorother.html#idx:qsaveprogram2:3">1.3</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="compilation.html#idx:qsaveprogram2:80">2.10.2.4</a> <a class="idx" href="flags.html#idx:qsaveprogram2:107">2.11</a> <a class="idx" href="autoload.html#idx:qsaveprogram2:208">2.13</a> <a class="idx" href="projectfiles.html#idx:qsaveprogram2:304">3.1.2</a> <a class="idx" href="idepreds.html#idx:qsaveprogram2:327">3.8</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram2:2080">11.4.21</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram2:2084">11.4.21</a> <a class="idx" href="runtime.html#idx:qsaveprogram2:2101">12</a> <a class="idx" href="useresource.html#idx:qsaveprogram2:2122">12.3</a></dd>
21802137 <dt>qsave_program/[1,2]</dt>
21812138 <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>
2139 <a class="idx" href="cmdline.html#idx:qsaveprogram12:36">2.4.2</a> <a class="idx" href="compilation.html#idx:qsaveprogram12:77">2.10.2.3</a> <a class="idx" href="flags.html#idx:qsaveprogram12:135">2.11</a> <a class="idx" href="examineprog.html#idx:qsaveprogram12:935">4.16</a> <a class="idx" href="foreignlink.html#idx:qsaveprogram12:2013">11.2.2</a> <a class="idx" href="foreigninclude.html#idx:qsaveprogram12:2079">11.4.21</a> <a class="idx" href="findhome.html#idx:qsaveprogram12:2091">11.6</a> <a class="idx" href="runtime.html#idx:qsaveprogram12:2106">12</a> <a class="idx" href="qsavelimits.html#idx:qsaveprogram12:2115">12.1</a></dd>
21832140 <dt><a class="idx" href="quasiquotations.html#quasi_quotation_syntax/1">quasi_quotation_syntax/1</a></dt>
21842141 <dd>
2185 <a class="idx" href="examineprog.html#idx:quasiquotationsyntax1:926">4.16</a></dd>
2142 <a class="idx" href="examineprog.html#idx:quasiquotationsyntax1:928">4.16</a></dd>
21862143 <dt><a class="idx" href="quasiquotations.html#quasi_quotation_syntax_error/1">quasi_quotation_syntax_error/1</a></dt>
21872144 <dt>query</dt>
21882145 <dd>
2189 <a class="idx" href="glossary.html#idx:query:2300">D</a></dd>
2146 <a class="idx" href="glossary.html#idx:query:2299">D</a></dd>
21902147 <dt>quiet</dt>
21912148 <dd>
21922149 <a class="idx" href="cmdline.html#idx:quiet:26">2.4.2</a></dd>
21992156 <dt><a class="idx" href="random.html#random_permutation/2">random_permutation/2</a></dt>
22002157 <dt><a class="idx" href="miscarith.html#random_property/1">random_property/1</a></dt>
22012158 <dd>
2202 <a class="idx" href="miscarith.html#idx:randomproperty1:1340">4.28</a></dd>
2159 <a class="idx" href="miscarith.html#idx:randomproperty1:1342">4.28</a></dd>
22032160 <dt><a class="idx" href="random.html#random_select/3">random_select/3</a></dt>
22042161 <dt><a class="idx" href="random.html#randseq/3">randseq/3</a></dt>
22052162 <dt><a class="idx" href="random.html#randset/3">randset/3</a></dt>
22062163 <dt>rational trees</dt>
22072164 <dd>
2208 <a class="idx" href="cyclic.html#idx:rationaltrees:228">2.17</a></dd>
2165 <a class="idx" href="cyclic.html#idx:rationaltrees:230">2.17</a></dd>
22092166 <dt>rational,number</dt>
22102167 <dd>
2211 <a class="idx" href="arith.html#idx:rationalnumber:1327">4.27.2.1</a></dd>
2168 <a class="idx" href="arith.html#idx:rationalnumber:1329">4.27.2.1</a></dd>
22122169 <dt><a class="idx" href="typetest.html#rational/1">rational/1</a></dt>
22132170 <dt><a class="idx" href="typetest.html#rational/3">rational/3</a></dt>
22142171 <dd>
2215 <a class="idx" href="arith.html#idx:rational3:1332">4.27.2.1</a></dd>
2172 <a class="idx" href="arith.html#idx:rational3:1334">4.27.2.1</a></dd>
22162173 <dt><a class="idx" href="ugraphs.html#reachable/3">reachable/3</a></dt>
22172174 <dt><a class="idx" href="termrw.html#read/1">read/1</a></dt>
22182175 <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>
2176 <a class="idx" href="flags.html#idx:read1:88">2.11</a> <a class="idx" href="flags.html#idx:read1:94">2.11</a> <a class="idx" href="limits.html#idx:read1:285">2.20.2</a> <a class="idx" href="IO.html#idx:read1:955">4.17.1</a> <a class="idx" href="IO.html#idx:read1:971">4.17.2</a> <a class="idx" href="IO.html#idx:read1:980">4.17.2</a> <a class="idx" href="chario.html#idx:read1:1083">4.19</a> <a class="idx" href="termrw.html#idx:read1:1146">4.20</a> <a class="idx" href="termrw.html#idx:read1:1160">4.20</a> <a class="idx" href="termrw.html#idx:read1:1168">4.20</a> <a class="idx" href="termrw.html#idx:read1:1190">4.20</a> <a class="idx" href="gvar.html#idx:read1:1434">4.33.1</a> <a class="idx" href="readutil.html#idx:read1:2164">A.30</a> <a class="idx" href="predsummary.html#idx:read1:2370">F.1</a></dd>
22202177 <dt><a class="idx" href="termrw.html#read/2">read/2</a></dt>
22212178 <dd>
2222 <a class="idx" href="streamstat.html#idx:read2:1071">4.18</a></dd>
2179 <a class="idx" href="streamstat.html#idx:read2:1073">4.18</a></dd>
22232180 <dt><a class="idx" href="termrw.html#read_clause/3">read_clause/3</a></dt>
22242181 <dd>
2225 <a class="idx" href="syntax.html#idx:readclause3:226">2.16.1.9</a> <a class="idx" href="debugger.html#idx:readclause3:1560">4.39</a></dd>
2182 <a class="idx" href="syntax.html#idx:readclause3:228">2.16.1.9</a> <a class="idx" href="debugger.html#idx:readclause3:1562">4.39</a></dd>
22262183 <dt><a class="idx" href="readutil.html#read_file_to_codes/3">read_file_to_codes/3</a></dt>
22272184 <dt><a class="idx" href="readutil.html#read_file_to_terms/3">read_file_to_terms/3</a></dt>
22282185 <dt><a class="idx" href="charsio.html#read_from_chars/2">read_from_chars/2</a></dt>
22292186 <dd>
2230 <a class="idx" href="manipatom.html#idx:readfromchars2:1255">4.22</a></dd>
2187 <a class="idx" href="manipatom.html#idx:readfromchars2:1257">4.22</a></dd>
22312188 <dt><a class="idx" href="termrw.html#read_history/6">read_history/6</a></dt>
22322189 <dd>
2233 <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>
2190 <a class="idx" href="termrw.html#idx:readhistory6:1187">4.20</a> <a class="idx" href="termrw.html#idx:readhistory6:1189">4.20</a></dd>
22342191 <dt><a class="idx" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a></dt>
22352192 <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>
2193 <a class="idx" href="strings.html#idx:readlinetocodes2:1613">5.2.2</a> <a class="idx" href="readutil.html#idx:readlinetocodes2:2159">A.30</a></dd>
22372194 <dt><a class="idx" href="readutil.html#read_line_to_codes/3">read_line_to_codes/3</a></dt>
22382195 <dd>
2239 <a class="idx" href="readutil.html#idx:readlinetocodes3:2158">A.30</a></dd>
2196 <a class="idx" href="readutil.html#idx:readlinetocodes3:2157">A.30</a></dd>
22402197 <dt><a class="idx" href="files.html#read_link/3">read_link/3</a></dt>
22412198 <dt><a class="idx" href="chario.html#read_pending_chars/3">read_pending_chars/3</a></dt>
22422199 <dt><a class="idx" href="chario.html#read_pending_codes/3">read_pending_codes/3</a></dt>
22432200 <dd>
2244 <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>
2201 <a class="idx" href="chario.html#idx:readpendingcodes3:1108">4.19</a> <a class="idx" href="chario.html#idx:readpendingcodes3:1115">4.19</a></dd>
22452202 <dt><a class="idx" href="readutil.html#read_stream_to_codes/2">read_stream_to_codes/2</a></dt>
22462203 <dd>
2247 <a class="idx" href="readutil.html#idx:readstreamtocodes2:2161">A.30</a></dd>
2204 <a class="idx" href="readutil.html#idx:readstreamtocodes2:2160">A.30</a></dd>
22482205 <dt><a class="idx" href="readutil.html#read_stream_to_codes/3">read_stream_to_codes/3</a></dt>
22492206 <dt><a class="idx" href="strings.html#read_string/3">read_string/3</a></dt>
22502207 <dt><a class="idx" href="strings.html#read_string/5">read_string/5</a></dt>
22512208 <dd>
2252 <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>
2209 <a class="idx" href="strings.html#idx:readstring5:1606">5.2.1</a> <a class="idx" href="strings.html#idx:readstring5:1610">5.2.1</a></dd>
22532210 <dt><a class="idx" href="termrw.html#read_term/2">read_term/2</a></dt>
22542211 <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>
2212 <a class="idx" href="flags.html#idx:readterm2:89">2.11</a> <a class="idx" href="consulting.html#idx:readterm2:495">4.3</a> <a class="idx" href="consulting.html#idx:readterm2:553">4.3.1.1</a> <a class="idx" href="termrw.html#idx:readterm2:1125">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1138">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1172">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1183">4.20</a> <a class="idx" href="termrw.html#idx:readterm2:1186">4.20</a> <a class="idx" href="manipatom.html#idx:readterm2:1272">4.22</a> <a class="idx" href="manipatom.html#idx:readterm2:1273">4.22</a> <a class="idx" href="ext-lists.html#idx:readterm2:1593">5.1</a> <a class="idx" href="ext-lists.html#idx:readterm2:1595">5.1</a> <a class="idx" href="strings.html#idx:readterm2:1600">5.2.1</a> <a class="idx" href="loadfilehook.html#idx:readterm2:2242">B.8</a> <a class="idx" href="loadfilehook.html#idx:readterm2:2243">B.8</a></dd>
22562213 <dt><a class="idx" href="termrw.html#read_term/3">read_term/3</a></dt>
22572214 <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>
2215 <a class="idx" href="syntax.html#idx:readterm3:229">2.16.1.9</a> <a class="idx" href="termrw.html#idx:readterm3:1135">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:1165">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1166">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1176">4.20</a> <a class="idx" href="termrw.html#idx:readterm3:1184">4.20</a> <a class="idx" href="charconv.html#idx:readterm3:1320">4.26</a> <a class="idx" href="toplevel.html#idx:readterm3:1536">4.37</a> <a class="idx" href="dicts.html#idx:readterm3:1650">5.4.3</a> <a class="idx" href="loadfilehook.html#idx:readterm3:2245">B.8</a></dd>
22592216 <dt>read_term/[2,3]</dt>
22602217 <dd>
2261 <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>
2218 <a class="idx" href="termrw.html#idx:readterm23:1179">4.20</a> <a class="idx" href="termrw.html#idx:readterm23:1180">4.20</a></dd>
22622219 <dt><a class="idx" href="termrw.html#read_term_from_atom/3">read_term_from_atom/3</a></dt>
22632220 <dd>
2264 <a class="idx" href="manipatom.html#idx:readtermfromatom3:1272">4.22</a></dd>
2221 <a class="idx" href="manipatom.html#idx:readtermfromatom3:1274">4.22</a></dd>
22652222 <dt><a class="idx" href="charsio.html#read_term_from_chars/3">read_term_from_chars/3</a></dt>
22662223 <dt>reconsult</dt>
22672224 <dd>
2268 <a class="idx" href="consulting.html#idx:reconsult:378">4.3</a></dd>
2225 <a class="idx" href="consulting.html#idx:reconsult:380">4.3</a></dd>
22692226 <dt><a class="idx" href="record.html#record/1">record/1</a></dt>
22702227 <dd>
2271 <a class="idx" href="record.html#idx:record1:2169">A.31</a></dd>
2228 <a class="idx" href="record.html#idx:record1:2168">A.31</a></dd>
22722229 <dt><a class="idx" href="db.html#recorda/2">recorda/2</a></dt>
22732230 <dd>
2274 <a class="idx" href="db.html#idx:recorda2:842">4.14.2</a></dd>
2231 <a class="idx" href="db.html#idx:recorda2:844">4.14.2</a></dd>
22752232 <dt><a class="idx" href="db.html#recorda/3">recorda/3</a></dt>
22762233 <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>
2234 <a class="idx" href="cyclic.html#idx:recorda3:246">2.17</a> <a class="idx" href="db.html#idx:recorda3:805">4.14</a> <a class="idx" href="db.html#idx:recorda3:843">4.14.2</a> <a class="idx" href="db.html#idx:recorda3:847">4.14.2</a> <a class="idx" href="examineprog.html#idx:recorda3:900">4.16</a> <a class="idx" href="gvar.html#idx:recorda3:1414">4.33</a> <a class="idx" href="foreigninclude.html#idx:recorda3:2055">11.4.14.2</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></dd>
22782235 <dt><a class="idx" href="db.html#recorded/2">recorded/2</a></dt>
22792236 <dt><a class="idx" href="db.html#recorded/3">recorded/3</a></dt>
22802237 <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>
2238 <a class="idx" href="db.html#idx:recorded3:808">4.14</a> <a class="idx" href="db.html#idx:recorded3:849">4.14.2</a> <a class="idx" href="qsavelimits.html#idx:recorded3:2118">12.1</a></dd>
22822239 <dt><a class="idx" href="db.html#recordz/2">recordz/2</a></dt>
22832240 <dd>
2284 <a class="idx" href="db.html#idx:recordz2:843">4.14.2</a></dd>
2241 <a class="idx" href="db.html#idx:recordz2:845">4.14.2</a></dd>
22852242 <dt><a class="idx" href="db.html#recordz/3">recordz/3</a></dt>
22862243 <dd>
2287 <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>
2244 <a class="idx" href="cyclic.html#idx:recordz3:247">2.17</a> <a class="idx" href="db.html#idx:recordz3:806">4.14</a> <a class="idx" href="db.html#idx:recordz3:848">4.14.2</a></dd>
22882245 <dt><a class="idx" href="db.html#redefine_system_predicate/1">redefine_system_predicate/1</a></dt>
22892246 <dd>
2290 <a class="idx" href="glossary.html#idx:redefinesystempredicate1:2280">D</a></dd>
2247 <a class="idx" href="glossary.html#idx:redefinesystempredicate1:2279">D</a></dd>
22912248 <dt><a class="idx" href="solutionsequences.html#reduced/1">reduced/1</a></dt>
22922249 <dt><a class="idx" href="solutionsequences.html#reduced/3">reduced/3</a></dt>
22932250 <dt><a class="idx" href="reexport.html#reexport/1">reexport/1</a></dt>
22942251 <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>
2252 <a class="idx" href="consulting.html#idx:reexport1:386">4.3</a> <a class="idx" href="consulting.html#idx:reexport1:392">4.3</a> <a class="idx" href="consulting.html#idx:reexport1:418">4.3</a> <a class="idx" href="dialect.html#idx:reexport1:2254">C</a></dd>
22962253 <dt><a class="idx" href="reexport.html#reexport/2">reexport/2</a></dt>
22972254 <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>
2255 <a class="idx" href="consulting.html#idx:reexport2:393">4.3</a> <a class="idx" href="consulting.html#idx:reexport2:410">4.3</a> <a class="idx" href="consulting.html#idx:reexport2:419">4.3</a> <a class="idx" href="dialect.html#idx:reexport2:2255">C</a></dd>
22992256 <dt>registry</dt>
23002257 <dd>
2301 <a class="idx" href="limits.html#idx:registry:279">2.20.1</a></dd>
2258 <a class="idx" href="limits.html#idx:registry:281">2.20.1</a></dd>
23022259 <dt><a class="idx" href="registry.html#registry_delete_key/1">registry_delete_key/1</a></dt>
23032260 <dt><a class="idx" href="registry.html#registry_get_key/2">registry_get_key/2</a></dt>
23042261 <dt><a class="idx" href="registry.html#registry_get_key/3">registry_get_key/3</a></dt>
23082265 <dt><a class="idx" href="foreignlink.html#reload_foreign_libraries/0">reload_foreign_libraries/0</a></dt>
23092266 <dt><a class="idx" href="autoload.html#reload_library_index/0">reload_library_index/0</a></dt>
23102267 <dd>
2311 <a class="idx" href="autoload.html#idx:reloadlibraryindex0:191">2.13</a> <a class="idx" href="autoload.html#idx:reloadlibraryindex0:200">2.13</a> <a class="idx" href="autoload.html#idx:reloadlibraryindex0:205">2.13</a></dd>
2268 <a class="idx" href="autoload.html#idx:reloadlibraryindex0:193">2.13</a> <a class="idx" href="autoload.html#idx:reloadlibraryindex0:202">2.13</a> <a class="idx" href="autoload.html#idx:reloadlibraryindex0:207">2.13</a></dd>
23122269 <dt><a class="idx" href="files.html#rename_file/2">rename_file/2</a></dt>
23132270 <dd>
2314 <a class="idx" href="system.html#idx:renamefile2:1446">4.35</a></dd>
2271 <a class="idx" href="system.html#idx:renamefile2:1448">4.35</a></dd>
23152272 <dt><a class="idx" href="control.html#repeat/0">repeat/0</a></dt>
23162273 <dd>
2317 <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>
2274 <a class="idx" href="control.html#idx:repeat0:644">4.8</a> <a class="idx" href="metacall.html#idx:repeat0:660">4.9</a> <a class="idx" href="metacall.html#idx:repeat0:673">4.9</a></dd>
23182275 <dt><a class="idx" href="error.html#representation_error/1">representation_error/1</a></dt>
23192276 <dd>
2320 <a class="idx" href="foreigninclude.html#idx:representationerror1:2034">11.4.6</a></dd>
2277 <a class="idx" href="foreigninclude.html#idx:representationerror1:2033">11.4.6</a></dd>
23212278 <dt><a class="idx" href="consulting.html#require/1">require/1</a></dt>
23222279 <dd>
2323 <a class="idx" href="dialect.html#idx:require1:2252">C</a></dd>
2280 <a class="idx" href="dialect.html#idx:require1:2251">C</a></dd>
23242281 <dt><a class="idx" href="delcont.html#reset/3">reset/3</a></dt>
23252282 <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>
2283 <a class="idx" href="delcont.html#idx:reset3:680">4.10</a> <a class="idx" href="delcont.html#idx:reset3:686">4.10</a> <a class="idx" href="delcont.html#idx:reset3:689">4.10</a> <a class="idx" href="delcont.html#idx:reset3:691">4.10</a> <a class="idx" href="delcont.html#idx:reset3:692">4.10</a> <a class="idx" href="predsummary.html#idx:reset3:2371">F.1</a></dd>
23272284 <dt><a class="idx" href="gensym.html#reset_gensym/0">reset_gensym/0</a></dt>
23282285 <dt><a class="idx" href="gensym.html#reset_gensym/1">reset_gensym/1</a></dt>
23292286 <dt><a class="idx" href="profile.html#reset_profiler/0">reset_profiler/0</a></dt>
23302287 <dt>residual</dt>
23312288 <dd>
2332 <a class="idx" href="coroutining.html#idx:residual:1800">7.2</a></dd>
2289 <a class="idx" href="coroutining.html#idx:residual:1799">7.2</a></dd>
23332290 <dt><a class="idx" href="useresource.html#resource/3">resource/3</a></dt>
23342291 <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>
2292 <a class="idx" href="flags.html#idx:resource3:133">2.11</a> <a class="idx" href="runtime.html#idx:resource3:2099">12</a> <a class="idx" href="runtime.html#idx:resource3:2102">12</a> <a class="idx" href="useresource.html#idx:resource3:2123">12.3</a> <a class="idx" href="useresource.html#idx:resource3:2130">12.3.1</a> <a class="idx" href="useresource.html#idx:resource3:2131">12.3.1</a></dd>
23362293 <dt><a class="idx" href="error.html#resource_error/1">resource_error/1</a></dt>
23372294 <dd>
2338 <a class="idx" href="foreigninclude.html#idx:resourceerror1:2039">11.4.6</a></dd>
2295 <a class="idx" href="foreigninclude.html#idx:resourceerror1:2038">11.4.6</a></dd>
23392296 <dt>retract</dt>
23402297 <dd>
2341 <a class="idx" href="glossary.html#idx:retract:2330">D</a></dd>
2298 <a class="idx" href="glossary.html#idx:retract:2329">D</a></dd>
23422299 <dt><a class="idx" href="db.html#retract/1">retract/1</a></dt>
23432300 <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>
2301 <a class="idx" href="quickstart.html#idx:retract1:9">2.1.2</a> <a class="idx" href="consulting.html#idx:retract1:374">4.3</a> <a class="idx" href="consulting.html#idx:retract1:464">4.3</a> <a class="idx" href="db.html#idx:retract1:798">4.14</a> <a class="idx" href="db.html#idx:retract1:801">4.14</a> <a class="idx" href="db.html#idx:retract1:817">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:827">4.14.1</a> <a class="idx" href="db.html#idx:retract1:828">4.14.1</a> <a class="idx" href="db.html#idx:retract1:865">4.14.5</a> <a class="idx" href="dynamic.html#idx:retract1:883">4.15</a> <a class="idx" href="dynamic.html#idx:retract1:889">4.15</a> <a class="idx" href="examineprog.html#idx:retract1:916">4.16</a> <a class="idx" href="clp.html#idx:retract1:1770">7</a> <a class="idx" href="threadcom.html#idx:retract1:1921">9.3.3</a> <a class="idx" href="engine-examples.html#idx:retract1:1975">10.1.2</a></dd>
23452302 <dt><a class="idx" href="db.html#retractall/1">retractall/1</a></dt>
23462303 <dd>
2347 <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>
2304 <a class="idx" href="db.html#idx:retractall1:799">4.14</a> <a class="idx" href="db.html#idx:retractall1:802">4.14</a> <a class="idx" href="db.html#idx:retractall1:818">4.14.1</a> <a class="idx" href="db.html#idx:retractall1:821">4.14.1</a></dd>
23482305 <dt><a class="idx" href="predicate_options.html#retractall_predicate_options/0">retractall_predicate_options/0</a></dt>
23492306 <dt>rev/3</dt>
23502307 <dd>
2351 <a class="idx" href="defmodule.html#idx:rev3:1667">6.2</a></dd>
2308 <a class="idx" href="defmodule.html#idx:rev3:1666">6.2</a></dd>
23522309 <dt><a class="idx" href="lists.html#reverse/2">reverse/2</a></dt>
23532310 <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>
2311 <a class="idx" href="DCG.html#idx:reverse2:793">4.13</a> <a class="idx" href="defmodule.html#idx:reverse2:1665">6.2</a></dd>
23552312 <dt><a class="idx" href="files.html#same_file/2">same_file/2</a></dt>
23562313 <dd>
2357 <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>
2314 <a class="idx" href="files.html#idx:samefile2:1498">4.36</a> <a class="idx" href="files.html#idx:samefile2:1499">4.36</a> <a class="idx" href="files.html#idx:samefile2:1502">4.36</a> <a class="idx" href="files.html#idx:samefile2:1503">4.36</a></dd>
23582315 <dt><a class="idx" href="lists.html#same_length/2">same_length/2</a></dt>
23592316 <dt><a class="idx" href="manipterm.html#same_term/2">same_term/2</a></dt>
23602317 <dt><a class="idx" href="aggregate.html#sandbox:safe_meta/2">sandbox:safe_meta/2</a></dt>
23672324 <dt><a class="idx" href="apply.html#scanl/7">scanl/7</a></dt>
23682325 <dt><a class="idx" href="IO.html#see/1">see/1</a></dt>
23692326 <dd>
2370 <a class="idx" href="IO.html#idx:see1:950">4.17</a> <a class="idx" href="IO.html#idx:see1:956">4.17.1</a> <a class="idx" href="IO.html#idx:see1:1034">4.17.3</a> <a class="idx" href="IO.html#idx:see1:1041">4.17.3</a> <a class="idx" href="IO.html#idx:see1:1043">4.17.3</a></dd>
2327 <a class="idx" href="IO.html#idx:see1:952">4.17</a> <a class="idx" href="IO.html#idx:see1:958">4.17.1</a> <a class="idx" href="IO.html#idx:see1:1036">4.17.3</a> <a class="idx" href="IO.html#idx:see1:1043">4.17.3</a> <a class="idx" href="IO.html#idx:see1:1045">4.17.3</a></dd>
23712328 <dt><a class="idx" href="IO.html#seeing/1">seeing/1</a></dt>
23722329 <dd>
2373 <a class="idx" href="IO.html#idx:seeing1:1036">4.17.3</a> <a class="idx" href="IO.html#idx:seeing1:1039">4.17.3</a> <a class="idx" href="files.html#idx:seeing1:1522">4.36</a></dd>
2330 <a class="idx" href="IO.html#idx:seeing1:1038">4.17.3</a> <a class="idx" href="IO.html#idx:seeing1:1041">4.17.3</a> <a class="idx" href="files.html#idx:seeing1:1524">4.36</a></dd>
23742331 <dt><a class="idx" href="IO.html#seek/4">seek/4</a></dt>
23752332 <dd>
2376 <a class="idx" href="IO.html#idx:seek4:990">4.17.2</a> <a class="idx" href="IO.html#idx:seek4:997">4.17.2</a> <a class="idx" href="IO.html#idx:seek4:1003">4.17.2</a> <a class="idx" href="IO.html#idx:seek4:1010">4.17.2</a></dd>
2333 <a class="idx" href="IO.html#idx:seek4:992">4.17.2</a> <a class="idx" href="IO.html#idx:seek4:999">4.17.2</a> <a class="idx" href="IO.html#idx:seek4:1005">4.17.2</a> <a class="idx" href="IO.html#idx:seek4:1012">4.17.2</a></dd>
23772334 <dt><a class="idx" href="IO.html#seen/0">seen/0</a></dt>
23782335 <dt>select()</dt>
23792336 <dd>
2380 <a class="idx" href="streamstat.html#idx:select:1068">4.18</a></dd>
2337 <a class="idx" href="streamstat.html#idx:select:1070">4.18</a></dd>
23812338 <dt><a class="idx" href="lists.html#select/3">select/3</a></dt>
23822339 <dt><a class="idx" href="lists.html#select/4">select/4</a></dt>
23832340 <dt>select_dict/2</dt>
23842341 <dd>
2385 <a class="idx" href="dicts.html#idx:selectdict2:1641">5.4.2</a></dd>
2342 <a class="idx" href="dicts.html#idx:selectdict2:1640">5.4.2</a></dd>
23862343 <dt><a class="idx" href="dicts.html#select_dict/3">select_dict/3</a></dt>
23872344 <dd>
2388 <a class="idx" href="dicts.html#idx:selectdict3:1642">5.4.2</a></dd>
2345 <a class="idx" href="dicts.html#idx:selectdict3:1641">5.4.2</a></dd>
23892346 <dt><a class="idx" href="option.html#select_option/3">select_option/3</a></dt>
23902347 <dt><a class="idx" href="option.html#select_option/4">select_option/4</a></dt>
23912348 <dt><a class="idx" href="lists.html#selectchk/3">selectchk/3</a></dt>
23922349 <dt><a class="idx" href="lists.html#selectchk/4">selectchk/4</a></dt>
23932350 <dt>semi deterministic</dt>
23942351 <dd>
2395 <a class="idx" href="glossary.html#idx:semideterministic:2332">D</a></dd>
2352 <a class="idx" href="glossary.html#idx:semideterministic:2331">D</a></dd>
23962353 <dt>semidet</dt>
23972354 <dd>
2398 <a class="idx" href="glossary.html#idx:semidet:2331">D</a></dd>
2355 <a class="idx" href="glossary.html#idx:semidet:2330">D</a></dd>
2356 <dt><a class="idx" href="control.html#send_arrow/2">send_arrow/2</a></dt>
23992357 <dt>serialize</dt>
24002358 <dd>
2401 <a class="idx" href="DCG.html#idx:serialize:778">4.13</a></dd>
2359 <a class="idx" href="DCG.html#idx:serialize:780">4.13</a></dd>
24022360 <dt><a class="idx" href="clpfd.html#serialized/2">serialized/2</a></dt>
24032361 <dt>set_breakpoint/4</dt>
24042362 <dd>
2405 <a class="idx" href="breakpoint.html#idx:setbreakpoint4:2203">B.4</a></dd>
2363 <a class="idx" href="breakpoint.html#idx:setbreakpoint4:2202">B.4</a></dd>
24062364 <dt><a class="idx" href="chario.html#set_end_of_stream/1">set_end_of_stream/1</a></dt>
24072365 <dt><a class="idx" href="db.html#set_flag/2">set_flag/2</a></dt>
24082366 <dt><a class="idx" href="IO.html#set_input/1">set_input/1</a></dt>
24092367 <dd>
2410 <a class="idx" href="IO.html#idx:setinput1:958">4.17.1</a> <a class="idx" href="IO.html#idx:setinput1:1016">4.17.2</a> <a class="idx" href="IO.html#idx:setinput1:1044">4.17.3</a></dd>
2368 <a class="idx" href="IO.html#idx:setinput1:960">4.17.1</a> <a class="idx" href="IO.html#idx:setinput1:1018">4.17.2</a> <a class="idx" href="IO.html#idx:setinput1:1046">4.17.3</a></dd>
24112369 <dt><a class="idx" href="locale.html#set_locale/1">set_locale/1</a></dt>
24122370 <dt><a class="idx" href="manipmodule.html#set_module/1">set_module/1</a></dt>
24132371 <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>
2372 <a class="idx" href="db.html#idx:setmodule1:835">4.14.1</a> <a class="idx" href="importmodule.html#idx:setmodule1:1721">6.9</a> <a class="idx" href="manipmodule.html#idx:setmodule1:1750">6.14</a></dd>
24152373 <dt><a class="idx" href="IO.html#set_output/1">set_output/1</a></dt>
24162374 <dd>
2417 <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>
2375 <a class="idx" href="IO.html#idx:setoutput1:961">4.17.1</a> <a class="idx" href="IO.html#idx:setoutput1:1047">4.17.3</a></dd>
24182376 <dt><a class="idx" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a></dt>
24192377 <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>
2378 <a class="idx" href="history.html#idx:setprologflag2:54">2.7</a> <a class="idx" href="flags.html#idx:setprologflag2:82">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:84">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:152">2.11</a> <a class="idx" href="flags.html#idx:setprologflag2:168">2.11</a> <a class="idx" href="consulting.html#idx:setprologflag2:378">4.3</a> <a class="idx" href="arith.html#idx:setprologflag2:1326">4.27.2</a> <a class="idx" href="foreigninclude.html#idx:setprologflag2:2061">11.4.14.4</a></dd>
2379 <dt>set_prolog_gc_thread/1</dt>
2380 <dd>
2381 <a class="idx" href="flags.html#idx:setprologgcthread1:115">2.11</a></dd>
24212382 <dt><a class="idx" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a></dt>
24222383 <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>
2384 <a class="idx" href="cmdline.html#idx:setprologstack2:42">2.4.3</a> <a class="idx" href="limits.html#idx:setprologstack2:280">2.20.1</a> <a class="idx" href="limits.html#idx:setprologstack2:282">2.20.1</a> <a class="idx" href="debugger.html#idx:setprologstack2:1557">4.39</a> <a class="idx" href="memory.html#idx:setprologstack2:1587">4.42</a> <a class="idx" href="strings.html#idx:setprologstack2:1597">5.2</a> <a class="idx" href="threadcreate.html#idx:setprologstack2:1852">9.1</a></dd>
24242385 <dt><a class="idx" href="miscarith.html#set_random/1">set_random/1</a></dt>
24252386 <dd>
2426 <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>
2387 <a class="idx" href="arith.html#idx:setrandom1:1336">4.27.2.3</a> <a class="idx" href="miscarith.html#idx:setrandom1:1343">4.28</a></dd>
24272388 <dt><a class="idx" href="IO.html#set_stream/2">set_stream/2</a></dt>
24282389 <dd>
2429 <a class="idx" href="widechars.html#idx:setstream2:270">2.19.1</a> <a class="idx" href="widechars.html#idx:setstream2:272">2.19.1</a> <a class="idx" href="IO.html#idx:setstream2:952">4.17.1</a> <a class="idx" href="IO.html#idx:setstream2:973">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:991">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:992">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:993">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:1031">4.17.2</a> <a class="idx" href="streamstat.html#idx:setstream2:1072">4.18</a> <a class="idx" href="chario.html#idx:setstream2:1099">4.19</a> <a class="idx" href="locale.html#idx:setstream2:1291">4.23</a></dd>
2390 <a class="idx" href="widechars.html#idx:setstream2:272">2.19.1</a> <a class="idx" href="widechars.html#idx:setstream2:274">2.19.1</a> <a class="idx" href="IO.html#idx:setstream2:954">4.17.1</a> <a class="idx" href="IO.html#idx:setstream2:975">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:993">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:994">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:995">4.17.2</a> <a class="idx" href="IO.html#idx:setstream2:1033">4.17.2</a> <a class="idx" href="streamstat.html#idx:setstream2:1074">4.18</a> <a class="idx" href="chario.html#idx:setstream2:1101">4.19</a> <a class="idx" href="locale.html#idx:setstream2:1293">4.23</a></dd>
24302391 <dt><a class="idx" href="IO.html#set_stream_position/2">set_stream_position/2</a></dt>
24312392 <dd>
2432 <a class="idx" href="IO.html#idx:setstreamposition2:989">4.17.2</a> <a class="idx" href="IO.html#idx:setstreamposition2:1006">4.17.2</a> <a class="idx" href="IO.html#idx:setstreamposition2:1012">4.17.2</a></dd>
2393 <a class="idx" href="IO.html#idx:setstreamposition2:991">4.17.2</a> <a class="idx" href="IO.html#idx:setstreamposition2:1008">4.17.2</a> <a class="idx" href="IO.html#idx:setstreamposition2:1014">4.17.2</a></dd>
24332394 <dt><a class="idx" href="url.html#set_url_encoding/2">set_url_encoding/2</a></dt>
24342395 <dt><a class="idx" href="manipterm.html#setarg/3">setarg/3</a></dt>
24352396 <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>
2397 <a class="idx" href="preddesc.html#idx:setarg3:337">4.1</a> <a class="idx" href="db.html#idx:setarg3:813">4.14</a> <a class="idx" href="manipterm.html#idx:setarg3:1218">4.21</a> <a class="idx" href="manipterm.html#idx:setarg3:1220">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1222">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1223">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1226">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1236">4.21.1</a> <a class="idx" href="manipterm.html#idx:setarg3:1241">4.21.1</a> <a class="idx" href="gvar.html#idx:setarg3:1436">4.33.1</a> <a class="idx" href="dicts.html#idx:setarg3:1643">5.4.2.1</a> <a class="idx" href="attvar.html#idx:setarg3:1778">7.1</a> <a class="idx" href="attvar.html#idx:setarg3:1781">7.1.1</a> <a class="idx" href="record.html#idx:setarg3:2170">A.31</a></dd>
24372398 <dt><a class="idx" href="system.html#setenv/2">setenv/2</a></dt>
24382399 <dd>
2439 <a class="idx" href="system.html#idx:setenv2:1452">4.35</a></dd>
2400 <a class="idx" href="system.html#idx:setenv2:1454">4.35</a></dd>
24402401 <dt>setlocale/1</dt>
24412402 <dd>
2442 <a class="idx" href="threadcreate.html#idx:setlocale1:1852">9.1</a></dd>
2403 <a class="idx" href="threadcreate.html#idx:setlocale1:1851">9.1</a></dd>
24432404 <dt><a class="idx" href="system.html#setlocale/3">setlocale/3</a></dt>
24442405 <dd>
2445 <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>
2406 <a class="idx" href="chartype.html#idx:setlocale3:1315">4.24.3</a> <a class="idx" href="system.html#idx:setlocale3:1457">4.35</a></dd>
24462407 <dt><a class="idx" href="allsolutions.html#setof/3">setof/3</a></dt>
24472408 <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>
2409 <a class="idx" href="cyclic.html#idx:setof3:248">2.17</a> <a class="idx" href="metapred.html#idx:setof3:1696">6.4</a> <a class="idx" href="predsummary.html#idx:setof3:2351">F.1</a></dd>
24492410 <dt><a class="idx" href="random.html#setrand/1">setrand/1</a></dt>
24502411 <dt><a class="idx" href="metacall.html#setup_call_catcher_cleanup/4">setup_call_catcher_cleanup/4</a></dt>
24512412 <dt>setup_call_cleanup/2</dt>
24522413 <dd>
2453 <a class="idx" href="threadsync.html#idx:setupcallcleanup2:1927">9.4</a></dd>
2414 <a class="idx" href="threadsync.html#idx:setupcallcleanup2:1926">9.4</a></dd>
24542415 <dt><a class="idx" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a></dt>
24552416 <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>
2417 <a class="idx" href="metacall.html#idx:setupcallcleanup3:672">4.9</a> <a class="idx" href="metacall.html#idx:setupcallcleanup3:674">4.9</a> <a class="idx" href="metacall.html#idx:setupcallcleanup3:678">4.9</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:713">4.11.1</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:718">4.11.1</a> <a class="idx" href="exception.html#idx:setupcallcleanup3:721">4.11.1</a> <a class="idx" href="threadcreate.html#idx:setupcallcleanup3:1864">9.1</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1930">9.4</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1934">9.4</a> <a class="idx" href="threadsync.html#idx:setupcallcleanup3:1937">9.4</a></dd>
24572418 <dt><a class="idx" href="simplex.html#shadow_price/3">shadow_price/3</a></dt>
24582419 <dt>shared</dt>
24592420 <dd>
2460 <a class="idx" href="glossary.html#idx:shared:2333">D</a></dd>
2421 <a class="idx" href="glossary.html#idx:shared:2332">D</a></dd>
24612422 <dt>shell/0</dt>
24622423 <dd>
2463 <a class="idx" href="system.html#idx:shell0:1461">4.35</a></dd>
2424 <a class="idx" href="system.html#idx:shell0:1463">4.35</a></dd>
24642425 <dt><a class="idx" href="system.html#shell/1">shell/1</a></dt>
24652426 <dd>
2466 <a class="idx" href="projectfiles.html#idx:shell1:298">3.1.1.2</a> <a class="idx" href="edit.html#idx:shell1:593">4.4.1</a> <a class="idx" href="edit.html#idx:shell1:594">4.4.1</a> <a class="idx" href="system.html#idx:shell1:1459">4.35</a> <a class="idx" href="system.html#idx:shell1:1460">4.35</a></dd>
2427 <a class="idx" href="projectfiles.html#idx:shell1:300">3.1.1.2</a> <a class="idx" href="edit.html#idx:shell1:595">4.4.1</a> <a class="idx" href="edit.html#idx:shell1:596">4.4.1</a> <a class="idx" href="system.html#idx:shell1:1461">4.35</a> <a class="idx" href="system.html#idx:shell1:1462">4.35</a></dd>
24672428 <dt><a class="idx" href="system.html#shell/2">shell/2</a></dt>
24682429 <dd>
2469 <a class="idx" href="system.html#idx:shell2:1440">4.35</a> <a class="idx" href="system.html#idx:shell2:1467">4.35.1</a></dd>
2430 <a class="idx" href="system.html#idx:shell2:1442">4.35</a> <a class="idx" href="system.html#idx:shell2:1469">4.35.1</a></dd>
24702431 <dt>shell/[0-2]</dt>
24712432 <dd>
2472 <a class="idx" href="system.html#idx:shell02:1449">4.35</a></dd>
2433 <a class="idx" href="system.html#idx:shell02:1451">4.35</a></dd>
24732434 <dt>shell/[1,2]</dt>
24742435 <dd>
2475 <a class="idx" href="system.html#idx:shell12:1441">4.35</a></dd>
2436 <a class="idx" href="system.html#idx:shell12:1443">4.35</a></dd>
24762437 <dt><a class="idx" href="registry.html#shell_register_dde/6">shell_register_dde/6</a></dt>
24772438 <dt><a class="idx" href="registry.html#shell_register_file_type/4">shell_register_file_type/4</a></dt>
24782439 <dd>
2479 <a class="idx" href="registry.html#idx:shellregisterfiletype4:2174">A.32</a></dd>
2440 <a class="idx" href="registry.html#idx:shellregisterfiletype4:2173">A.32</a></dd>
24802441 <dt><a class="idx" href="registry.html#shell_register_prolog/1">shell_register_prolog/1</a></dt>
24812442 <dt><a class="idx" href="delcont.html#shift/1">shift/1</a></dt>
24822443 <dd>
2483 <a class="idx" href="delcont.html#idx:shift1:679">4.10</a> <a class="idx" href="delcont.html#idx:shift1:680">4.10</a> <a class="idx" href="delcont.html#idx:shift1:681">4.10</a> <a class="idx" href="delcont.html#idx:shift1:683">4.10</a> <a class="idx" href="delcont.html#idx:shift1:685">4.10</a> <a class="idx" href="delcont.html#idx:shift1:686">4.10</a></dd>
2444 <a class="idx" href="delcont.html#idx:shift1:681">4.10</a> <a class="idx" href="delcont.html#idx:shift1:682">4.10</a> <a class="idx" href="delcont.html#idx:shift1:683">4.10</a> <a class="idx" href="delcont.html#idx:shift1:685">4.10</a> <a class="idx" href="delcont.html#idx:shift1:687">4.10</a> <a class="idx" href="delcont.html#idx:shift1:688">4.10</a></dd>
24842445 <dt><a class="idx" href="profile.html#show_profile/1">show_profile/1</a></dt>
24852446 <dd>
2486 <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>
2447 <a class="idx" href="profile.html#idx:showprofile1:1570">4.41.1</a> <a class="idx" href="profile.html#idx:showprofile1:1571">4.41.1</a></dd>
24872448 <dt>singleton</dt>
24882449 <dd>
2489 <a class="idx" href="glossary.html#idx:singleton:2334">D</a></dd>
2450 <a class="idx" href="glossary.html#idx:singleton:2333">D</a></dd>
24902451 <dt>singleton,variable</dt>
24912452 <dd>
2492 <a class="idx" href="syntax.html#idx:singletonvariable:222">2.16.1.9</a></dd>
2453 <a class="idx" href="syntax.html#idx:singletonvariable:224">2.16.1.9</a></dd>
24932454 <dt><a class="idx" href="files.html#size_file/2">size_file/2</a></dt>
24942455 <dt><a class="idx" href="nb_set.html#size_nb_set/2">size_nb_set/2</a></dt>
24952456 <dt><a class="idx" href="chario.html#skip/1">skip/1</a></dt>
24962457 <dd>
2497 <a class="idx" href="chario.html#idx:skip1:1101">4.19</a></dd>
2458 <a class="idx" href="chario.html#idx:skip1:1103">4.19</a></dd>
24982459 <dt><a class="idx" href="chario.html#skip/2">skip/2</a></dt>
24992460 <dt><a class="idx" href="miscpreds.html#sleep/1">sleep/1</a></dt>
25002461 <dd>
2501 <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>
2462 <a class="idx" href="cmdline.html#idx:sleep1:29">2.4.2</a> <a class="idx" href="miscpreds.html#idx:sleep1:1590">4.44</a></dd>
25022463 <dt>solution</dt>
25032464 <dd>
2504 <a class="idx" href="glossary.html#idx:solution:2335">D</a></dd>
2465 <a class="idx" href="glossary.html#idx:solution:2334">D</a></dd>
25052466 <dt><a class="idx" href="builtinlist.html#sort/2">sort/2</a></dt>
25062467 <dd>
2507 <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>
2468 <a class="idx" href="compare.html#idx:sort2:627">4.7.1</a> <a class="idx" href="metacall.html#idx:sort2:665">4.9</a> <a class="idx" href="builtinlist.html#idx:sort2:1350">4.29</a> <a class="idx" href="builtinlist.html#idx:sort2:1352">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="builtinlist.html#idx:sort2:1361">4.29</a> <a class="idx" href="allsolutions.html#idx:sort2:1376">4.30</a></dd>
25082469 <dt><a class="idx" href="builtinlist.html#sort/4">sort/4</a></dt>
25092470 <dt><a class="idx" href="dialect.html#source_exports/2">source_exports/2</a></dt>
25102471 <dd>
2511 <a class="idx" href="dialect.html#idx:sourceexports2:2251">C</a></dd>
2472 <a class="idx" href="dialect.html#idx:sourceexports2:2250">C</a></dd>
25122473 <dt><a class="idx" href="consulting.html#source_file/1">source_file/1</a></dt>
25132474 <dt><a class="idx" href="consulting.html#source_file/2">source_file/2</a></dt>
25142475 <dd>
2515 <a class="idx" href="consulting.html#idx:sourcefile2:448">4.3</a> <a class="idx" href="consulting.html#idx:sourcefile2:582">4.3.3</a> <a class="idx" href="examineprog.html#idx:sourcefile2:916">4.16</a> <a class="idx" href="examineprog.html#idx:sourcefile2:920">4.16</a></dd>
2476 <a class="idx" href="consulting.html#idx:sourcefile2:450">4.3</a> <a class="idx" href="consulting.html#idx:sourcefile2:584">4.3.3</a> <a class="idx" href="examineprog.html#idx:sourcefile2:918">4.16</a> <a class="idx" href="examineprog.html#idx:sourcefile2:922">4.16</a></dd>
25162477 <dt><a class="idx" href="consulting.html#source_file_property/2">source_file_property/2</a></dt>
25172478 <dd>
2518 <a class="idx" href="consulting.html#idx:sourcefileproperty2:419">4.3</a> <a class="idx" href="consulting.html#idx:sourcefileproperty2:451">4.3</a></dd>
2479 <a class="idx" href="consulting.html#idx:sourcefileproperty2:421">4.3</a> <a class="idx" href="consulting.html#idx:sourcefileproperty2:453">4.3</a></dd>
25192480 <dt><a class="idx" href="consulting.html#source_location/2">source_location/2</a></dt>
25202481 <dd>
2521 <a class="idx" href="consulting.html#idx:sourcelocation2:486">4.3</a></dd>
2482 <a class="idx" href="consulting.html#idx:sourcelocation2:488">4.3</a></dd>
25222483 <dt><a class="idx" href="strings.html#split_string/4">split_string/4</a></dt>
25232484 <dd>
2524 <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>
2485 <a class="idx" href="manipatom.html#idx:splitstring4:1279">4.22</a> <a class="idx" href="strings.html#idx:splitstring4:1609">5.2.1</a> <a class="idx" href="strings.html#idx:splitstring4:1611">5.2.1</a></dd>
25252486 <dt><a class="idx" href="debugger.html#spy/1">spy/1</a></dt>
25262487 <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>
2488 <a class="idx" href="debugoverview.html#idx:spy1:57">2.9</a> <a class="idx" href="debugoverview.html#idx:spy1:62">2.9</a> <a class="idx" href="flags.html#idx:spy1:103">2.11</a> <a class="idx" href="flags.html#idx:spy1:117">2.11</a> <a class="idx" href="hooks.html#idx:spy1:184">2.12</a> <a class="idx" href="guitracer.html#idx:spy1:320">3.5.1</a> <a class="idx" href="guitracer.html#idx:spy1:322">3.5.1</a> <a class="idx" href="idesummary.html#idx:spy1:335">3.9</a> <a class="idx" href="preddesc.html#idx:spy1:340">4.1</a> <a class="idx" href="mtoplevel.html#idx:spy1:1708">6.6</a> <a class="idx" href="thutil.html#idx:spy1:1948">9.5.1</a> <a class="idx" href="thutil.html#idx:spy1:1950">9.5.1</a> <a class="idx" href="intlibs.html#idx:spy1:2224">B.7</a> <a class="idx" href="intlibs.html#idx:spy1:2225">B.7</a> <a class="idx" href="intlibs.html#idx:spy1:2228">B.7</a> <a class="idx" href="predsummary.html#idx:spy1:2357">F.1</a></dd>
25282489 <dt>stack,memory management</dt>
25292490 <dd>
2530 <a class="idx" href="limits.html#idx:stackmemorymanagement:281">2.20.1.1</a></dd>
2491 <a class="idx" href="limits.html#idx:stackmemorymanagement:283">2.20.1.1</a></dd>
25312492 <dt><a class="idx" href="system.html#stamp_date_time/3">stamp_date_time/3</a></dt>
25322493 <dd>
2533 <a class="idx" href="system.html#idx:stampdatetime3:1479">4.35.2.1</a> <a class="idx" href="system.html#idx:stampdatetime3:1482">4.35.2.2</a></dd>
2494 <a class="idx" href="system.html#idx:stampdatetime3:1481">4.35.2.1</a> <a class="idx" href="system.html#idx:stampdatetime3:1484">4.35.2.2</a></dd>
25342495 <dt>startup file</dt>
25352496 <dd>
25362497 <a class="idx" href="initfile.html#idx:startupfile:18">2.2</a></dd>
25372498 <dt><a class="idx" href="statistics.html#statistics/0">statistics/0</a></dt>
25382499 <dd>
2539 <a class="idx" href="exception.html#idx:statistics0:737">4.11.4</a></dd>
2500 <a class="idx" href="exception.html#idx:statistics0:739">4.11.4</a></dd>
25402501 <dt><a class="idx" href="statistics.html#statistics/2">statistics/2</a></dt>
25412502 <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>
2503 <a class="idx" href="arith.html#idx:statistics2:1340">4.27.2.3</a> <a class="idx" href="statistics.html#idx:statistics2:1564">4.40</a> <a class="idx" href="statistics.html#idx:statistics2:1566">4.40</a> <a class="idx" href="thmonitor.html#idx:statistics2:1883">9.2</a> <a class="idx" href="thmonitor.html#idx:statistics2:1884">9.2</a></dd>
25432504 <dt><a class="idx" href="IO.html#stream_pair/3">stream_pair/3</a></dt>
25442505 <dd>
2545 <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>
2506 <a class="idx" href="IO.html#idx:streampair3:970">4.17.2</a> <a class="idx" href="IO.html#idx:streampair3:983">4.17.2</a> <a class="idx" href="IO.html#idx:streampair3:1015">4.17.2</a></dd>
25462507 <dt><a class="idx" href="IO.html#stream_position_data/3">stream_position_data/3</a></dt>
25472508 <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>
2509 <a class="idx" href="consulting.html#idx:streampositiondata3:493">4.3</a> <a class="idx" href="IO.html#idx:streampositiondata3:990">4.17.2</a> <a class="idx" href="termrw.html#idx:streampositiondata3:1171">4.20</a> <a class="idx" href="loadfilehook.html#idx:streampositiondata3:2244">B.8</a></dd>
25492510 <dt><a class="idx" href="IO.html#stream_property/2">stream_property/2</a></dt>
25502511 <dd>
2551 <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>
2512 <a class="idx" href="widechars.html#idx:streamproperty2:278">2.19.1.1</a> <a class="idx" href="consulting.html#idx:streamproperty2:492">4.3</a> <a class="idx" href="IO.html#idx:streamproperty2:976">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:1000">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1007">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1013">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1016">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:1023">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1024">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1030">4.17.2</a> <a class="idx" href="IO.html#idx:streamproperty2:1031">4.17.2</a> <a class="idx" href="termrw.html#idx:streamproperty2:1181">4.20</a></dd>
25522513 <dt><a class="idx" href="pio.html#stream_to_lazy_list/2">stream_to_lazy_list/2</a></dt>
25532514 <dt><a class="idx" href="typetest.html#string/1">string/1</a></dt>
25542515 <dd>
2555 <a class="idx" href="typetest.html#idx:string1:605">4.6</a> <a class="idx" href="format.html#idx:string1:1403">4.32.2</a> <a class="idx" href="strings.html#idx:string1:1595">5.2.1</a></dd>
2516 <a class="idx" href="typetest.html#idx:string1:607">4.6</a> <a class="idx" href="format.html#idx:string1:1405">4.32.2</a> <a class="idx" href="strings.html#idx:string1:1598">5.2.1</a></dd>
25562517 <dt><a class="idx" href="strings.html#string_chars/2">string_chars/2</a></dt>
25572518 <dt><a class="idx" href="strings.html#string_code/3">string_code/3</a></dt>
25582519 <dd>
2559 <a class="idx" href="strings.html#idx:stringcode3:1601">5.2.1</a> <a class="idx" href="strings.html#idx:stringcode3:1622">5.2.4</a></dd>
2520 <a class="idx" href="strings.html#idx:stringcode3:1604">5.2.1</a> <a class="idx" href="strings.html#idx:stringcode3:1625">5.2.4</a></dd>
25602521 <dt><a class="idx" href="strings.html#string_codes/2">string_codes/2</a></dt>
25612522 <dd>
2562 <a class="idx" href="strings.html#idx:stringcodes2:1614">5.2.2</a> <a class="idx" href="strings.html#idx:stringcodes2:1615">5.2.2</a></dd>
2523 <a class="idx" href="strings.html#idx:stringcodes2:1617">5.2.2</a> <a class="idx" href="strings.html#idx:stringcodes2:1618">5.2.2</a></dd>
25632524 <dt><a class="idx" href="strings.html#string_concat/3">string_concat/3</a></dt>
25642525 <dd>
2565 <a class="idx" href="strings.html#idx:stringconcat3:1612">5.2.2</a></dd>
2526 <a class="idx" href="strings.html#idx:stringconcat3:1615">5.2.2</a></dd>
25662527 <dt><a class="idx" href="strings.html#string_length/2">string_length/2</a></dt>
25672528 <dt><a class="idx" href="strings.html#string_lower/2">string_lower/2</a></dt>
25682529 <dt><a class="idx" href="check.html#string_predicate/1">string_predicate/1</a></dt>
25692530 <dt><a class="idx" href="strings.html#string_upper/2">string_upper/2</a></dt>
25702531 <dt><a class="idx" href="ctxmodule.html#strip_module/3">strip_module/3</a></dt>
25712532 <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>
2533 <a class="idx" href="metapred.html#idx:stripmodule3:1704">6.4</a> <a class="idx" href="ctxmodule.html#idx:stripmodule3:1746">6.13</a> <a class="idx" href="modulecompat.html#idx:stripmodule3:1756">6.15</a></dd>
25732534 <dt>structure</dt>
25742535 <dd>
2575 <a class="idx" href="glossary.html#idx:structure:2336">D</a></dd>
2536 <a class="idx" href="glossary.html#idx:structure:2335">D</a></dd>
25762537 <dt><a class="idx" href="debugger.html#style_check/1">style_check/1</a></dt>
25772538 <dd>
2578 <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>
2539 <a class="idx" href="syntax.html#idx:stylecheck1:226">2.16.1.9</a> <a class="idx" href="syntax.html#idx:stylecheck1:227">2.16.1.9</a> <a class="idx" href="consulting.html#idx:stylecheck1:422">4.3</a> <a class="idx" href="dynamic.html#idx:stylecheck1:891">4.15</a></dd>
25792540 <dt><a class="idx" href="manipatom.html#sub_atom/5">sub_atom/5</a></dt>
25802541 <dd>
2581 <a class="idx" href="strings.html#idx:subatom5:1604">5.2.1</a></dd>
2542 <a class="idx" href="strings.html#idx:subatom5:1607">5.2.1</a></dd>
25822543 <dt><a class="idx" href="manipatom.html#sub_atom_icasechk/3">sub_atom_icasechk/3</a></dt>
25832544 <dt><a class="idx" href="strings.html#sub_string/5">sub_string/5</a></dt>
25842545 <dd>
2585 <a class="idx" href="strings.html#idx:substring5:1600">5.2.1</a> <a class="idx" href="strings.html#idx:substring5:1613">5.2.2</a></dd>
2546 <a class="idx" href="strings.html#idx:substring5:1603">5.2.1</a> <a class="idx" href="strings.html#idx:substring5:1616">5.2.2</a></dd>
25862547 <dt><a class="idx" href="lists.html#subset/2">subset/2</a></dt>
25872548 <dt>subsumes_chk/2</dt>
25882549 <dd>
2589 <a class="idx" href="compare.html#idx:subsumeschk2:638">4.7.2</a> <a class="idx" href="db.html#idx:subsumeschk2:871">4.14.6</a></dd>
2550 <a class="idx" href="compare.html#idx:subsumeschk2:640">4.7.2</a> <a class="idx" href="db.html#idx:subsumeschk2:873">4.14.6</a></dd>
25902551 <dt><a class="idx" href="compare.html#subsumes_term/2">subsumes_term/2</a></dt>
25912552 <dd>
2592 <a class="idx" href="cyclic.html#idx:subsumesterm2:247">2.17</a> <a class="idx" href="compare.html#idx:subsumesterm2:627">4.7.2</a> <a class="idx" href="compare.html#idx:subsumesterm2:637">4.7.2</a></dd>
2553 <a class="idx" href="cyclic.html#idx:subsumesterm2:249">2.17</a> <a class="idx" href="compare.html#idx:subsumesterm2:629">4.7.2</a> <a class="idx" href="compare.html#idx:subsumesterm2:639">4.7.2</a></dd>
25932554 <dt><a class="idx" href="lists.html#subtract/3">subtract/3</a></dt>
25942555 <dt><a class="idx" href="arith.html#succ/2">succ/2</a></dt>
25952556 <dd>
2596 <a class="idx" href="arith.html#idx:succ2:1322">4.27.1</a></dd>
2557 <a class="idx" href="arith.html#idx:succ2:1324">4.27.1</a></dd>
25972558 <dt>succeed</dt>
25982559 <dd>
2599 <a class="idx" href="glossary.html#idx:succeed:2337">D</a></dd>
2560 <a class="idx" href="glossary.html#idx:succeed:2336">D</a></dd>
26002561 <dt><a class="idx" href="clpfd.html#sum/3">sum/3</a></dt>
26012562 <dt><a class="idx" href="lists.html#sum_list/2">sum_list/2</a></dt>
26022563 <dt><a class="idx" href="clpqr.html#sup/2">sup/2</a></dt>
26032564 <dt><a class="idx" href="format.html#swritef/2">swritef/2</a></dt>
26042565 <dt><a class="idx" href="format.html#swritef/3">swritef/3</a></dt>
26052566 <dd>
2606 <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>
2567 <a class="idx" href="IO.html#idx:swritef3:1053">4.17.5</a> <a class="idx" href="format.html#idx:swritef3:1387">4.32</a></dd>
26082568 <dt><a class="idx" href="error.html#syntax_error/1">syntax_error/1</a></dt>
26092569 <dt><a class="idx" href="chario.html#tab/1">tab/1</a></dt>
26102570 <dt><a class="idx" href="chario.html#tab/2">tab/2</a></dt>
26112571 <dt><a class="idx" href="tabling.html#table/1">table/1</a></dt>
26122572 <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>
2573 <a class="idx" href="flags.html#idx:table1:138">2.11</a> <a class="idx" href="tabling.html#idx:table1:2175">A.35</a> <a class="idx" href="tabling.html#idx:table1:2176">A.35.2</a> <a class="idx" href="tabling.html#idx:table1:2178">A.35.1.1</a></dd>
26142574 <dt><a class="idx" href="clpb.html#taut/2">taut/2</a></dt>
26152575 <dt><a class="idx" href="thutil.html#tdebug/0">tdebug/0</a></dt>
26162576 <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>
2577 <a class="idx" href="threadcreate.html#idx:tdebug0:1840">9.1</a> <a class="idx" href="thutil.html#idx:tdebug0:1951">9.5.1</a></dd>
26182578 <dt><a class="idx" href="thutil.html#tdebug/1">tdebug/1</a></dt>
26192579 <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>
2580 <a class="idx" href="thutil.html#idx:tdebug1:1947">9.5.1</a> <a class="idx" href="thutil.html#idx:tdebug1:1949">9.5.1</a></dd>
26212581 <dt><a class="idx" href="IO.html#tell/1">tell/1</a></dt>
26222582 <dd>
2623 <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>
2583 <a class="idx" href="IO.html#idx:tell1:951">4.17</a> <a class="idx" href="IO.html#idx:tell1:959">4.17.1</a> <a class="idx" href="IO.html#idx:tell1:1034">4.17.3</a> <a class="idx" href="IO.html#idx:tell1:1039">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:1044">4.17.3</a> <a class="idx" href="IO.html#idx:tell1:1048">4.17.3</a></dd>
26242584 <dt><a class="idx" href="IO.html#telling/1">telling/1</a></dt>
26252585 <dd>
2626 <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>
2586 <a class="idx" href="IO.html#idx:telling1:1037">4.17.3</a> <a class="idx" href="IO.html#idx:telling1:1040">4.17.3</a> <a class="idx" href="files.html#idx:telling1:1523">4.36</a></dd>
26272587 <dt>term</dt>
26282588 <dd>
2629 <a class="idx" href="glossary.html#idx:term:2338">D</a></dd>
2589 <a class="idx" href="glossary.html#idx:term:2337">D</a></dd>
26302590 <dt>term//1</dt>
26312591 <dd>
2632 <a class="idx" href="IO.html#idx:term1:1055">4.17.5</a></dd>
2592 <a class="idx" href="IO.html#idx:term1:1057">4.17.5</a></dd>
26332593 <dt><a class="idx" href="attvar.html#term_attvars/2">term_attvars/2</a></dt>
26342594 <dd>
2635 <a class="idx" href="attvar.html#idx:termattvars2:1792">7.1.3</a></dd>
2595 <a class="idx" href="attvar.html#idx:termattvars2:1791">7.1.3</a></dd>
26362596 <dt><a class="idx" href="consulting.html#term_expansion/2">term_expansion/2</a></dt>
26372597 <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>
2598 <a class="idx" href="flags.html#idx:termexpansion2:165">2.11</a> <a class="idx" href="hooks.html#idx:termexpansion2:176">2.12</a> <a class="idx" href="consulting.html#idx:termexpansion2:369">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:375">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:486">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:516">4.3</a> <a class="idx" href="consulting.html#idx:termexpansion2:518">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:520">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:527">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:531">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:534">4.3.1</a> <a class="idx" href="consulting.html#idx:termexpansion2:555">4.3.1.2</a> <a class="idx" href="consulting.html#idx:termexpansion2:564">4.3.2</a> <a class="idx" href="consulting.html#idx:termexpansion2:582">4.3.3</a> <a class="idx" href="toplevel.html#idx:termexpansion2:1539">4.37</a> <a class="idx" href="practical.html#idx:termexpansion2:1816">8.3.3</a> <a class="idx" href="portabilitystrategies.html#idx:termexpansion2:2260">C.1</a></dd>
26392599 <dt><a class="idx" href="consulting.html#term_expansion/4">term_expansion/4</a></dt>
26402600 <dd>
2641 <a class="idx" href="consulting.html#idx:termexpansion4:368">4.3</a></dd>
2601 <a class="idx" href="consulting.html#idx:termexpansion4:370">4.3</a></dd>
26422602 <dt>term_factorized/3</dt>
26432603 <dd>
2644 <a class="idx" href="IO.html#idx:termfactorized3:1063">4.17.6</a></dd>
2604 <a class="idx" href="IO.html#idx:termfactorized3:1065">4.17.6</a></dd>
26452605 <dt><a class="idx" href="db.html#term_hash/2">term_hash/2</a></dt>
26462606 <dd>
2647 <a class="idx" href="cyclic.html#idx:termhash2:241">2.17</a> <a class="idx" href="jitindex.html#idx:termhash2:260">2.18.2</a> <a class="idx" href="db.html#idx:termhash2:865">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:868">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:869">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:870">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:873">4.14.6</a></dd>
2607 <a class="idx" href="cyclic.html#idx:termhash2:243">2.17</a> <a class="idx" href="jitindex.html#idx:termhash2:262">2.18.2</a> <a class="idx" href="db.html#idx:termhash2:867">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:870">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:871">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:872">4.14.6</a> <a class="idx" href="db.html#idx:termhash2:875">4.14.6</a></dd>
26482608 <dt><a class="idx" href="db.html#term_hash/4">term_hash/4</a></dt>
26492609 <dd>
2650 <a class="idx" href="jitindex.html#idx:termhash4:261">2.18.2</a> <a class="idx" href="db.html#idx:termhash4:866">4.14.6</a></dd>
2610 <a class="idx" href="jitindex.html#idx:termhash4:263">2.18.2</a> <a class="idx" href="db.html#idx:termhash4:868">4.14.6</a></dd>
26512611 <dt><a class="idx" href="manipterm.html#term_singletons/2">term_singletons/2</a></dt>
26522612 <dt><a class="idx" href="strings.html#term_string/2">term_string/2</a></dt>
26532613 <dd>
2654 <a class="idx" href="manipatom.html#idx:termstring2:1269">4.22</a> <a class="idx" href="strings.html#idx:termstring2:1596">5.2.1</a></dd>
2614 <a class="idx" href="manipatom.html#idx:termstring2:1271">4.22</a> <a class="idx" href="strings.html#idx:termstring2:1599">5.2.1</a></dd>
26552615 <dt><a class="idx" href="strings.html#term_string/3">term_string/3</a></dt>
26562616 <dt><a class="idx" href="compare.html#term_subsumer/3">term_subsumer/3</a></dt>
26572617 <dt><a class="idx" href="manipatom.html#term_to_atom/2">term_to_atom/2</a></dt>
26582618 <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>
2619 <a class="idx" href="IO.html#idx:termtoatom2:1054">4.17.5</a> <a class="idx" href="foreigninclude.html#idx:termtoatom2:2030">11.4.5</a></dd>
26602620 <dt><a class="idx" href="manipterm.html#term_variables/2">term_variables/2</a></dt>
26612621 <dd>
2662 <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>
2622 <a class="idx" href="cyclic.html#idx:termvariables2:250">2.17</a> <a class="idx" href="typetest.html#idx:termvariables2:621">4.6</a> <a class="idx" href="termrw.html#idx:termvariables2:1182">4.20</a> <a class="idx" href="manipterm.html#idx:termvariables2:1209">4.21</a> <a class="idx" href="manipterm.html#idx:termvariables2:1214">4.21</a> <a class="idx" href="manipterm.html#idx:termvariables2:1215">4.21</a></dd>
26632623 <dt><a class="idx" href="manipterm.html#term_variables/3">term_variables/3</a></dt>
26642624 <dd>
2665 <a class="idx" href="manipterm.html#idx:termvariables3:1208">4.21</a></dd>
2625 <a class="idx" href="manipterm.html#idx:termvariables3:1210">4.21</a></dd>
26662626 <dt>terms,cyclic</dt>
26672627 <dd>
2668 <a class="idx" href="cyclic.html#idx:termscyclic:231">2.17</a></dd>
2628 <a class="idx" href="cyclic.html#idx:termscyclic:233">2.17</a></dd>
26692629 <dt><a class="idx" href="strings.html#text_to_string/2">text_to_string/2</a></dt>
26702630 <dt><a class="idx" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a></dt>
26712631 <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>
2632 <a class="idx" href="toplevel.html#idx:threadatexit1:1534">4.37</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1835">9.1</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:1871">9.1</a> <a class="idx" href="threadcreate.html#idx:threadatexit1:1872">9.1</a> <a class="idx" href="foreignthread.html#idx:threadatexit1:1957">9.6.1</a></dd>
26732633 <dt><a class="idx" href="threadcreate.html#thread_create/2">thread_create/2</a></dt>
26742634 <dt><a class="idx" href="threadcreate.html#thread_create/3">thread_create/3</a></dt>
26752635 <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>
2636 <a class="idx" href="threadcreate.html#idx:threadcreate3:1830">9.1</a> <a class="idx" href="threadcreate.html#idx:threadcreate3:1859">9.1</a> <a class="idx" href="threadcreate.html#idx:threadcreate3:1873">9.1</a> <a class="idx" href="mt-xpce.html#idx:threadcreate3:1965">9.7</a> <a class="idx" href="engine-predicates.html#idx:threadcreate3:1995">10.3</a></dd>
26772637 <dt><a class="idx" href="threadpool.html#thread_create_in_pool/4">thread_create_in_pool/4</a></dt>
26782638 <dd>
2679 <a class="idx" href="threadcreate.html#idx:threadcreateinpool4:1849">9.1</a></dd>
2639 <a class="idx" href="threadcreate.html#idx:threadcreateinpool4:1848">9.1</a></dd>
26802640 <dt><a class="idx" href="threadcreate.html#thread_detach/1">thread_detach/1</a></dt>
26812641 <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>
2642 <a class="idx" href="threadcreate.html#idx:threaddetach1:1832">9.1</a> <a class="idx" href="threadcreate.html#idx:threaddetach1:1844">9.1</a></dd>
26832643 <dt><a class="idx" href="threadcreate.html#thread_exit/1">thread_exit/1</a></dt>
26842644 <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>
2645 <a class="idx" href="threadcreate.html#idx:threadexit1:1858">9.1</a> <a class="idx" href="thmonitor.html#idx:threadexit1:1878">9.2</a> <a class="idx" href="threadsync.html#idx:threadexit1:1938">9.4</a></dd>
26862646 <dt><a class="idx" href="threadcom.html#thread_get_message/1">thread_get_message/1</a></dt>
26872647 <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>
2648 <a class="idx" href="threadcom.html#idx:threadgetmessage1:1902">9.3.1</a> <a class="idx" href="engine-examples.html#idx:threadgetmessage1:1983">10.1.3</a></dd>
26892649 <dt><a class="idx" href="threadcom.html#thread_get_message/2">thread_get_message/2</a></dt>
26902650 <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>
2651 <a class="idx" href="threadcom.html#idx:threadgetmessage2:1901">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage2:1904">9.3.1</a></dd>
26922652 <dt><a class="idx" href="threadcom.html#thread_get_message/3">thread_get_message/3</a></dt>
26932653 <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>
2654 <a class="idx" href="threadcom.html#idx:threadgetmessage3:1890">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1897">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadgetmessage3:1906">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:1909">9.3.1</a></dd>
26952655 <dt><a class="idx" href="threadcreate.html#thread_initialization/1">thread_initialization/1</a></dt>
26962656 <dd>
2697 <a class="idx" href="gvar.html#idx:threadinitialization1:1418">4.33</a></dd>
2657 <a class="idx" href="gvar.html#idx:threadinitialization1:1420">4.33</a></dd>
2658 <dt><a class="idx" href="threadcreate.html#thread_join/1">thread_join/1</a></dt>
26982659 <dt><a class="idx" href="threadcreate.html#thread_join/2">thread_join/2</a></dt>
26992660 <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>
2661 <a class="idx" href="threadcreate.html#idx:threadjoin2:1831">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1834">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1841">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:1853">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1855">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1856">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1862">9.1</a> <a class="idx" href="threadcreate.html#idx:threadjoin2:1863">9.1</a> <a class="idx" href="thmonitor.html#idx:threadjoin2:1877">9.2</a></dd>
27012662 <dt><a class="idx" href="threadcom.html#thread_local/1">thread_local/1</a></dt>
27022663 <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>
2664 <a class="idx" href="exception.html#idx:threadlocal1:760">4.11.4</a> <a class="idx" href="db.html#idx:threadlocal1:804">4.14</a> <a class="idx" href="dynamic.html#idx:threadlocal1:884">4.15</a> <a class="idx" href="examineprog.html#idx:threadlocal1:930">4.16</a> <a class="idx" href="toplevel.html#idx:threadlocal1:1528">4.37</a> <a class="idx" href="threadcom.html#idx:threadlocal1:1918">9.3.3</a> <a class="idx" href="engine-examples.html#idx:threadlocal1:1978">10.1.2</a></dd>
27042665 <dt><a class="idx" href="exception.html#thread_message_hook/3">thread_message_hook/3</a></dt>
27052666 <dt><a class="idx" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a></dt>
27062667 <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>
2668 <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1895">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1896">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadpeekmessage1:1910">9.3.1</a></dd>
27082669 <dt><a class="idx" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a></dt>
27092670 <dd>
2710 <a class="idx" href="threadcom.html#idx:threadpeekmessage2:1909">9.3.1</a></dd>
2671 <a class="idx" href="threadcom.html#idx:threadpeekmessage2:1908">9.3.1</a></dd>
27112672 <dt><a class="idx" href="threadpool.html#thread_pool_create/3">thread_pool_create/3</a></dt>
27122673 <dt><a class="idx" href="threadpool.html#thread_pool_destroy/1">thread_pool_destroy/1</a></dt>
27132674 <dt><a class="idx" href="threadpool.html#thread_pool_property/2">thread_pool_property/2</a></dt>
27142675 <dt><a class="idx" href="thmonitor.html#thread_property/2">thread_property/2</a></dt>
27152676 <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>
2677 <a class="idx" href="threadcreate.html#idx:threadproperty2:1833">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1854">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1861">9.1</a> <a class="idx" href="threadcreate.html#idx:threadproperty2:1869">9.1</a> <a class="idx" href="thmonitor.html#idx:threadproperty2:1876">9.2</a></dd>
27172678 <dt><a class="idx" href="threadcreate.html#thread_self/1">thread_self/1</a></dt>
27182679 <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>
2680 <a class="idx" href="flags.html#idx:threadself1:137">2.11</a> <a class="idx" href="threadcreate.html#idx:threadself1:1860">9.1</a> <a class="idx" href="threadcreate.html#idx:threadself1:1870">9.1</a> <a class="idx" href="threadcom.html#idx:threadself1:1886">9.3.1</a></dd>
27202681 <dt><a class="idx" href="threadcom.html#thread_send_message/2">thread_send_message/2</a></dt>
27212682 <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>
2683 <a class="idx" href="threadcom.html#idx:threadsendmessage2:1887">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage2:1888">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage2:1899">9.3.1</a> <a class="idx" href="engine-examples.html#idx:threadsendmessage2:1982">10.1.3</a></dd>
27232684 <dt><a class="idx" href="threadcom.html#thread_send_message/3">thread_send_message/3</a></dt>
27242685 <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>
2686 <a class="idx" href="threadcom.html#idx:threadsendmessage3:1889">9.3.1</a> <a class="idx" href="threadcom.html#idx:threadsendmessage3:1892">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></dd>
27262687 <dt><a class="idx" href="threadcreate.html#thread_setconcurrency/2">thread_setconcurrency/2</a></dt>
27272688 <dd>
2728 <a class="idx" href="flags.html#idx:threadsetconcurrency2:100">2.11</a></dd>
2689 <a class="idx" href="flags.html#idx:threadsetconcurrency2:101">2.11</a></dd>
27292690 <dt><a class="idx" href="threadcom.html#thread_signal/2">thread_signal/2</a></dt>
27302691 <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>
2692 <a class="idx" href="cmdline.html#idx:threadsignal2:28">2.4.2</a> <a class="idx" href="metacall.html#idx:threadsignal2:669">4.9</a> <a class="idx" href="threadcom.html#idx:threadsignal2:1914">9.3.2</a> <a class="idx" href="thutil.html#idx:threadsignal2:1946">9.5.1</a> <a class="idx" href="foreigninclude.html#idx:threadsignal2:2053">11.4.13</a> <a class="idx" href="foreigninclude.html#idx:threadsignal2:2089">11.4.21.1</a></dd>
27322693 <dt><a class="idx" href="thmonitor.html#thread_statistics/3">thread_statistics/3</a></dt>
27332694 <dd>
2734 <a class="idx" href="thmonitor.html#idx:threadstatistics3:1882">9.2</a></dd>
2695 <a class="idx" href="thmonitor.html#idx:threadstatistics3:1881">9.2</a></dd>
27352696 <dt><a class="idx" href="thutil.html#threads/0">threads/0</a></dt>
27362697 <dt><a class="idx" href="exception.html#throw/1">throw/1</a></dt>
27372698 <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>
2699 <a class="idx" href="debugoverview.html#idx:throw1:55">2.9</a> <a class="idx" href="cyclic.html#idx:throw1:251">2.17</a> <a class="idx" href="delcont.html#idx:throw1:690">4.10</a> <a class="idx" href="exception.html#idx:throw1:694">4.11</a> <a class="idx" href="exception.html#idx:throw1:696">4.11</a> <a class="idx" href="exception.html#idx:throw1:697">4.11</a> <a class="idx" href="exception.html#idx:throw1:706">4.11</a> <a class="idx" href="exception.html#idx:throw1:711">4.11</a> <a class="idx" href="exception.html#idx:throw1:770">4.11.4.1</a> <a class="idx" href="signal.html#idx:throw1:778">4.12.1</a> <a class="idx" href="threadcreate.html#idx:throw1:1865">9.1</a> <a class="idx" href="thmonitor.html#idx:throw1:1879">9.2</a> <a class="idx" href="threadcom.html#idx:throw1:1913">9.3.2</a> <a class="idx" href="threadcom.html#idx:throw1:1915">9.3.2</a> <a class="idx" href="foreigninclude.html#idx:throw1:2051">11.4.12</a> <a class="idx" href="foreigninclude.html#idx:throw1:2052">11.4.12</a> <a class="idx" href="excepthook.html#idx:throw1:2208">B.5</a> <a class="idx" href="exception3.html#idx:throw1:2216">B.6</a> <a class="idx" href="exception3.html#idx:throw1:2219">B.6</a></dd>
27392700 <dt><a class="idx" href="statistics.html#time/1">time/1</a></dt>
27402701 <dd>
2741 <a class="idx" href="arith.html#idx:time1:1339">4.27.2.3</a></dd>
2702 <a class="idx" href="arith.html#idx:time1:1341">4.27.2.3</a></dd>
27422703 <dt><a class="idx" href="files.html#time_file/2">time_file/2</a></dt>
27432704 <dt><a class="idx" href="files.html#tmp_file/2">tmp_file/2</a></dt>
27442705 <dd>
2745 <a class="idx" href="files.html#idx:tmpfile2:1517">4.36</a></dd>
2706 <a class="idx" href="files.html#idx:tmpfile2:1519">4.36</a></dd>
27462707 <dt><a class="idx" href="files.html#tmp_file_stream/3">tmp_file_stream/3</a></dt>
27472708 <dd>
2748 <a class="idx" href="files.html#idx:tmpfilestream3:1516">4.36</a></dd>
2709 <a class="idx" href="files.html#idx:tmpfilestream3:1518">4.36</a></dd>
27492710 <dt><a class="idx" href="thutil.html#tnodebug/0">tnodebug/0</a></dt>
27502711 <dt><a class="idx" href="thutil.html#tnodebug/1">tnodebug/1</a></dt>
27512712 <dd>
2752 <a class="idx" href="thutil.html#idx:tnodebug1:1954">9.5.1</a></dd>
2713 <a class="idx" href="thutil.html#idx:tnodebug1:1953">9.5.1</a></dd>
27532714 <dt><a class="idx" href="IO.html#told/0">told/0</a></dt>
27542715 <dt><a class="idx" href="ugraphs.html#top_sort/2">top_sort/2</a></dt>
27552716 <dt><a class="idx" href="ugraphs.html#top_sort/3">top_sort/3</a></dt>
27562717 <dt><a class="idx" href="thutil.html#tprofile/1">tprofile/1</a></dt>
27572718 <dd>
2758 <a class="idx" href="thutil.html#idx:tprofile1:1956">9.5.2</a></dd>
2719 <a class="idx" href="thutil.html#idx:tprofile1:1955">9.5.2</a></dd>
27592720 <dt><a class="idx" href="debugger.html#trace/0">trace/0</a></dt>
27602721 <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>
2722 <a class="idx" href="debugoverview.html#idx:trace0:56">2.9</a> <a class="idx" href="debugoverview.html#idx:trace0:59">2.9</a> <a class="idx" href="flags.html#idx:trace0:116">2.11</a> <a class="idx" href="flags.html#idx:trace0:147">2.11</a> <a class="idx" href="guitracer.html#idx:trace0:319">3.5.1</a> <a class="idx" href="guitracer.html#idx:trace0:321">3.5.1</a> <a class="idx" href="idesummary.html#idx:trace0:334">3.9</a> <a class="idx" href="debugger.html#idx:trace0:1544">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1545">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1551">4.39</a> <a class="idx" href="debugger.html#idx:trace0:1552">4.39</a> <a class="idx" href="debugging.html#idx:trace0:1821">8.4.3</a> <a class="idx" href="debugging.html#idx:trace0:1823">8.4.3</a> <a class="idx" href="threadcom.html#idx:trace0:1916">9.3.2</a> <a class="idx" href="foreigninclude.html#idx:trace0:2064">11.4.16</a> <a class="idx" href="breakpoint.html#idx:trace0:2204">B.4</a> <a class="idx" href="excepthook.html#idx:trace0:2212">B.5</a></dd>
27622723 <dt><a class="idx" href="debugger.html#trace/1">trace/1</a></dt>
27632724 <dd>
2764 <a class="idx" href="flags.html#idx:trace1:103">2.11</a></dd>
2725 <a class="idx" href="flags.html#idx:trace1:104">2.11</a></dd>
27652726 <dt><a class="idx" href="debugger.html#trace/2">trace/2</a></dt>
27662727 <dd>
2767 <a class="idx" href="debugger.html#idx:trace2:1547">4.39</a></dd>
2728 <a class="idx" href="debugger.html#idx:trace2:1549">4.39</a></dd>
27682729 <dt><a class="idx" href="debugger.html#tracing/0">tracing/0</a></dt>
27692730 <dd>
2770 <a class="idx" href="debugger.html#idx:tracing0:1544">4.39</a></dd>
2731 <a class="idx" href="debugger.html#idx:tracing0:1546">4.39</a></dd>
27712732 <dt>transformation,of program</dt>
27722733 <dd>
2773 <a class="idx" href="consulting.html#idx:transformationofprogram:515">4.3.1</a></dd>
2734 <a class="idx" href="consulting.html#idx:transformationofprogram:517">4.3.1</a></dd>
27742735 <dt><a class="idx" href="ugraphs.html#transitive_closure/2">transitive_closure/2</a></dt>
27752736 <dt>transparent</dt>
27762737 <dd>
2777 <a class="idx" href="glossary.html#idx:transparent:2314">D</a></dd>
2738 <a class="idx" href="glossary.html#idx:transparent:2313">D</a></dd>
27782739 <dt><a class="idx" href="simplex.html#transportation/4">transportation/4</a></dt>
27792740 <dt><a class="idx" href="pairs.html#transpose_pairs/2">transpose_pairs/2</a></dt>
27802741 <dt><a class="idx" href="ugraphs.html#transpose_ugraph/2">transpose_ugraph/2</a></dt>
27822743 <dt><a class="idx" href="db.html#trie_destroy/1">trie_destroy/1</a></dt>
27832744 <dt><a class="idx" href="db.html#trie_gen/3">trie_gen/3</a></dt>
27842745 <dd>
2785 <a class="idx" href="db.html#idx:triegen3:853">4.14.4</a></dd>
2746 <a class="idx" href="db.html#idx:triegen3:855">4.14.4</a></dd>
27862747 <dt><a class="idx" href="db.html#trie_insert/3">trie_insert/3</a></dt>
27872748 <dd>
2788 <a class="idx" href="db.html#idx:trieinsert3:856">4.14.4</a> <a class="idx" href="db.html#idx:trieinsert3:857">4.14.4</a></dd>
2749 <a class="idx" href="db.html#idx:trieinsert3:858">4.14.4</a> <a class="idx" href="db.html#idx:trieinsert3:859">4.14.4</a></dd>
27892750 <dt><a class="idx" href="db.html#trie_insert/4">trie_insert/4</a></dt>
27902751 <dt>trie_insert_new/3</dt>
27912752 <dd>
2792 <a class="idx" href="db.html#idx:trieinsertnew3:858">4.14.4</a></dd>
2753 <a class="idx" href="db.html#idx:trieinsertnew3:860">4.14.4</a></dd>
27932754 <dt><a class="idx" href="db.html#trie_lookup/3">trie_lookup/3</a></dt>
27942755 <dt><a class="idx" href="db.html#trie_new/1">trie_new/1</a></dt>
27952756 <dt><a class="idx" href="db.html#trie_property/2">trie_property/2</a></dt>
27972758 <dt><a class="idx" href="db.html#trie_update/3">trie_update/3</a></dt>
27982759 <dt><a class="idx" href="memory.html#trim_stacks/0">trim_stacks/0</a></dt>
27992760 <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>
2761 <a class="idx" href="memory.html#idx:trimstacks0:1577">4.42</a> <a class="idx" href="memory.html#idx:trimstacks0:1581">4.42</a> <a class="idx" href="engine-examples.html#idx:trimstacks0:1985">10.1.3</a></dd>
28012762 <dt>trimm_stacks/0</dt>
28022763 <dd>
2803 <a class="idx" href="engine-resources.html#idx:trimmstacks0:1992">10.2</a></dd>
2764 <a class="idx" href="engine-resources.html#idx:trimmstacks0:1991">10.2</a></dd>
28042765 <dt><a class="idx" href="check.html#trivial_fail_goal/1">trivial_fail_goal/1</a></dt>
28052766 <dt><a class="idx" href="control.html#true/0">true/0</a></dt>
28062767 <dd>
2807 <a class="idx" href="flags.html#idx:true0:121">2.11</a> <a class="idx" href="consulting.html#idx:true0:544">4.3.1</a> <a class="idx" href="control.html#idx:true0:645">4.8</a> <a class="idx" href="metacall.html#idx:true0:657">4.9</a></dd>
2768 <a class="idx" href="flags.html#idx:true0:123">2.11</a> <a class="idx" href="consulting.html#idx:true0:546">4.3.1</a> <a class="idx" href="control.html#idx:true0:647">4.8</a> <a class="idx" href="metacall.html#idx:true0:659">4.9</a></dd>
28082769 <dt>truncate/1</dt>
28092770 <dd>
2810 <a class="idx" href="arith.html#idx:truncate1:1337">4.27.2.3</a></dd>
2771 <a class="idx" href="arith.html#idx:truncate1:1339">4.27.2.3</a></dd>
28112772 <dt><a class="idx" href="thutil.html#tspy/1">tspy/1</a></dt>
28122773 <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>
2774 <a class="idx" href="threadcreate.html#idx:tspy1:1839">9.1</a> <a class="idx" href="thutil.html#idx:tspy1:1942">9.5.1</a></dd>
28142775 <dt><a class="idx" href="thutil.html#tspy/2">tspy/2</a></dt>
28152776 <dt><a class="idx" href="tty.html#tty_get_capability/3">tty_get_capability/3</a></dt>
28162777 <dd>
2817 <a class="idx" href="tty.html#idx:ttygetcapability3:1437">4.34</a> <a class="idx" href="tty.html#idx:ttygetcapability3:1439">4.34</a></dd>
2778 <a class="idx" href="tty.html#idx:ttygetcapability3:1439">4.34</a> <a class="idx" href="tty.html#idx:ttygetcapability3:1441">4.34</a></dd>
28182779 <dt><a class="idx" href="tty.html#tty_goto/2">tty_goto/2</a></dt>
28192780 <dt><a class="idx" href="tty.html#tty_put/2">tty_put/2</a></dt>
28202781 <dt><a class="idx" href="tty.html#tty_size/2">tty_size/2</a></dt>
28212782 <dd>
2822 <a class="idx" href="tty.html#idx:ttysize2:1438">4.34</a></dd>
2783 <a class="idx" href="tty.html#idx:ttysize2:1440">4.34</a></dd>
28232784 <dt><a class="idx" href="chario.html#ttyflush/0">ttyflush/0</a></dt>
28242785 <dd>
2825 <a class="idx" href="format.html#idx:ttyflush0:1397">4.32.1</a></dd>
2786 <a class="idx" href="format.html#idx:ttyflush0:1399">4.32.1</a></dd>
28262787 <dt><a class="idx" href="clpfd.html#tuples_in/2">tuples_in/2</a></dt>
28272788 <dt><a class="idx" href="error.html#type_error/2">type_error/2</a></dt>
28282789 <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>
2790 <a class="idx" href="exception.html#idx:typeerror2:771">4.11.4.1</a> <a class="idx" href="foreigninclude.html#idx:typeerror2:2034">11.4.6</a> <a class="idx" href="foreigninclude.html#idx:typeerror2:2036">11.4.6</a></dd>
28302791 <dt><a class="idx" href="ugraphs.html#ugraph_union/3">ugraph_union/3</a></dt>
28312792 <dt><a class="idx" href="compare.html#unifiable/3">unifiable/3</a></dt>
28322793 <dd>
2833 <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>
2794 <a class="idx" href="cyclic.html#idx:unifiable3:253">2.17</a> <a class="idx" href="compare.html#idx:unifiable3:630">4.7.2</a></dd>
28342795 <dt>unify</dt>
28352796 <dd>
2836 <a class="idx" href="glossary.html#idx:unify:2339">D</a></dd>
2797 <a class="idx" href="glossary.html#idx:unify:2338">D</a></dd>
28372798 <dt><a class="idx" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a></dt>
28382799 <dd>
2839 <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>
2800 <a class="idx" href="flags.html#idx:unifywithoccurscheck2:121">2.11</a> <a class="idx" href="cyclic.html#idx:unifywithoccurscheck2:252">2.17</a> <a class="idx" href="compare.html#idx:unifywithoccurscheck2:628">4.7.2</a> <a class="idx" href="compare.html#idx:unifywithoccurscheck2:632">4.7.2</a> <a class="idx" href="compare.html#idx:unifywithoccurscheck2:633">4.7.2</a></dd>
28402801 <dt><a class="idx" href="error.html#uninstantiation_error/1">uninstantiation_error/1</a></dt>
28412802 <dt><a class="idx" href="lists.html#union/3">union/3</a></dt>
28422803 <dt>unix</dt>
28432804 <dd>
2844 <a class="idx" href="flags.html#idx:unix:147">2.11</a></dd>
2805 <a class="idx" href="flags.html#idx:unix:149">2.11</a></dd>
28452806 <dt><a class="idx" href="system.html#unix/1">unix/1</a></dt>
28462807 <dt><a class="idx" href="debugger.html#unknown/2">unknown/2</a></dt>
28472808 <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>
2809 <a class="idx" href="debugger.html#idx:unknown2:1560">4.39</a> <a class="idx" href="libpl.html#idx:unknown2:2133">A</a></dd>
28492810 <dt><a class="idx" href="broadcast.html#unlisten/1">unlisten/1</a></dt>
28502811 <dt><a class="idx" href="broadcast.html#unlisten/2">unlisten/2</a></dt>
28512812 <dt><a class="idx" href="broadcast.html#unlisten/3">unlisten/3</a></dt>
28522813 <dt><a class="idx" href="consulting.html#unload_file/1">unload_file/1</a></dt>
28532814 <dd>
2854 <a class="idx" href="consulting.html#idx:unloadfile1:415">4.3</a></dd>
2815 <a class="idx" href="consulting.html#idx:unloadfile1:417">4.3</a></dd>
28552816 <dt><a class="idx" href="foreignlink.html#unload_foreign_library/1">unload_foreign_library/1</a></dt>
28562817 <dt><a class="idx" href="foreignlink.html#unload_foreign_library/2">unload_foreign_library/2</a></dt>
28572818 <dt><a class="idx" href="system.html#unsetenv/1">unsetenv/1</a></dt>
28582819 <dd>
2859 <a class="idx" href="system.html#idx:unsetenv1:1453">4.35</a> <a class="idx" href="system.html#idx:unsetenv1:1454">4.35</a></dd>
2820 <a class="idx" href="system.html#idx:unsetenv1:1455">4.35</a> <a class="idx" href="system.html#idx:unsetenv1:1456">4.35</a></dd>
28602821 <dt><a class="idx" href="chartype.html#upcase_atom/2">upcase_atom/2</a></dt>
28612822 <dd>
2862 <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>
2823 <a class="idx" href="chartype.html#idx:upcaseatom2:1295">4.24</a> <a class="idx" href="chartype.html#idx:upcaseatom2:1297">4.24</a></dd>
28632824 <dt>update view</dt>
28642825 <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>
2826 <a class="idx" href="db.html#idx:updateview:863">4.14.5</a> <a class="idx" href="glossary.html#idx:updateview:2339">D</a></dd>
28662827 <dt><a class="idx" href="url.html#url_iri/2">url_iri/2</a></dt>
28672828 <dt><a class="idx" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a></dt>
28682829 <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>
2830 <a class="idx" href="consulting.html#idx:useforeignlibrary1:468">4.3</a> <a class="idx" href="consulting.html#idx:useforeignlibrary1:510">4.3</a> <a class="idx" href="system.html#idx:useforeignlibrary1:1475">4.35.1</a> <a class="idx" href="runtime.html#idx:useforeignlibrary1:2105">12</a></dd>
28702831 <dt><a class="idx" href="foreignlink.html#use_foreign_library/2">use_foreign_library/2</a></dt>
28712832 <dt><a class="idx" href="import.html#use_module/1">use_module/1</a></dt>
28722833 <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>
2834 <a class="idx" href="flags.html#idx:usemodule1:159">2.11</a> <a class="idx" href="hooks.html#idx:usemodule1:180">2.12</a> <a class="idx" href="projectfiles.html#idx:usemodule1:303">3.1.1.3</a> <a class="idx" href="consulting.html#idx:usemodule1:384">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:390">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:408">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:440">4.3</a> <a class="idx" href="consulting.html#idx:usemodule1:570">4.3.2.1</a> <a class="idx" href="consulting.html#idx:usemodule1:571">4.3.2.1</a> <a class="idx" href="consulting.html#idx:usemodule1:573">4.3.2.1</a> <a class="idx" href="defmodule.html#idx:usemodule1:1668">6.2</a> <a class="idx" href="import.html#idx:usemodule1:1669">6.3</a> <a class="idx" href="import.html#idx:usemodule1:1677">6.3</a> <a class="idx" href="import.html#idx:usemodule1:1685">6.3</a> <a class="idx" href="reexport.html#idx:usemodule1:1717">6.7</a> <a class="idx" href="resmodules.html#idx:usemodule1:1728">6.10</a> <a class="idx" href="altmoduleapi.html#idx:usemodule1:1729">6.11</a> <a class="idx" href="runtime.html#idx:usemodule1:2110">12</a> <a class="idx" href="dialect.html#idx:usemodule1:2252">C</a></dd>
28742835 <dt><a class="idx" href="import.html#use_module/2">use_module/2</a></dt>
28752836 <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>
2837 <a class="idx" href="autoload.html#idx:usemodule2:195">2.13</a> <a class="idx" href="consulting.html#idx:usemodule2:385">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:391">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:409">4.3</a> <a class="idx" href="consulting.html#idx:usemodule2:411">4.3</a> <a class="idx" href="import.html#idx:usemodule2:1670">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1674">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1675">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1678">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1683">6.3</a> <a class="idx" href="import.html#idx:usemodule2:1686">6.3</a> <a class="idx" href="reexport.html#idx:usemodule2:1718">6.7</a> <a class="idx" href="dialect.html#idx:usemodule2:2253">C</a></dd>
28772838 <dt>use_module/[1,2]</dt>
28782839 <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>
2840 <a class="idx" href="compilation.html#idx:usemodule12:72">2.10.1</a> <a class="idx" href="pceemacs.html#idx:usemodule12:314">3.4.3.1</a> <a class="idx" href="consulting.html#idx:usemodule12:363">4.3</a> <a class="idx" href="consulting.html#idx:usemodule12:413">4.3</a> <a class="idx" href="consulting.html#idx:usemodule12:434">4.3</a> <a class="idx" href="altmoduleapi.html#idx:usemodule12:1730">6.11</a> <a class="idx" href="altmoduleapi.html#idx:usemodule12:1733">6.11</a> <a class="idx" href="glossary.html#idx:usemodule12:2295">D</a></dd>
28802841 <dt>user profile file</dt>
28812842 <dd>
28822843 <a class="idx" href="initfile.html#idx:userprofilefile:19">2.2</a></dd>
28832844 <dt>utf-8</dt>
28842845 <dd>
2885 <a class="idx" href="chars.html#idx:utf8:341">4.2</a></dd>
2846 <a class="idx" href="chars.html#idx:utf8:343">4.2</a></dd>
28862847 <dt>valgrind</dt>
28872848 <dd>
2888 <a class="idx" href="foreignnotes.html#idx:valgrind:2098">11.8.4</a></dd>
2849 <a class="idx" href="foreignnotes.html#idx:valgrind:2097">11.8.4</a></dd>
28892850 <dt><a class="idx" href="check.html#valid_string_goal/1">valid_string_goal/1</a></dt>
28902851 <dt><a class="idx" href="typetest.html#var/1">var/1</a></dt>
28912852 <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>
2853 <a class="idx" href="attvar.html#idx:var1:1779">7.1.1</a> <a class="idx" href="foreigninclude.html#idx:var1:2018">11.4.3</a></dd>
28932854 <dt><a class="idx" href="manipterm.html#var_number/2">var_number/2</a></dt>
28942855 <dt><a class="idx" href="consulting.html#var_property/2">var_property/2</a></dt>
28952856 <dt>variable</dt>
28962857 <dd>
2897 <a class="idx" href="glossary.html#idx:variable:2342">D</a></dd>
2858 <a class="idx" href="glossary.html#idx:variable:2341">D</a></dd>
28982859 <dt>variable,anonymous</dt>
28992860 <dd>
2900 <a class="idx" href="glossary.html#idx:variableanonymous:2271">D</a></dd>
2861 <a class="idx" href="glossary.html#idx:variableanonymous:2270">D</a></dd>
29012862 <dt><a class="idx" href="simplex.html#variable_value/3">variable_value/3</a></dt>
29022863 <dt>variant</dt>
29032864 <dd>
2904 <a class="idx" href="compare.html#idx:variant:633">4.7.2</a></dd>
2865 <a class="idx" href="compare.html#idx:variant:635">4.7.2</a></dd>
29052866 <dt><a class="idx" href="db.html#variant_hash/2">variant_hash/2</a></dt>
29062867 <dt><a class="idx" href="db.html#variant_sha1/2">variant_sha1/2</a></dt>
29072868 <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>
2869 <a class="idx" href="db.html#idx:variantsha12:874">4.14.6</a> <a class="idx" href="db.html#idx:variantsha12:876">4.14.6</a> <a class="idx" href="otherlicenses.html#idx:variantsha12:2347">E.3.1</a></dd>
29092870 <dt><a class="idx" href="varnumbers.html#varnumbers/2">varnumbers/2</a></dt>
29102871 <dt><a class="idx" href="varnumbers.html#varnumbers/3">varnumbers/3</a></dt>
29112872 <dt><a class="idx" href="varnumbers.html#varnumbers_names/3">varnumbers_names/3</a></dt>
29142875 <a class="idx" href="cmdline.html#idx:verbose:25">2.4.2</a></dd>
29152876 <dt><a class="idx" href="exception.html#version/0">version/0</a></dt>
29162877 <dd>
2917 <a class="idx" href="cmdline.html#idx:version0:42">2.4.4</a> <a class="idx" href="exception.html#idx:version0:764">4.11.4</a></dd>
2878 <a class="idx" href="cmdline.html#idx:version0:43">2.4.4</a> <a class="idx" href="exception.html#idx:version0:766">4.11.4</a></dd>
29182879 <dt><a class="idx" href="exception.html#version/1">version/1</a></dt>
29192880 <dd>
2920 <a class="idx" href="exception.html#idx:version1:763">4.11.4</a></dd>
2881 <a class="idx" href="exception.html#idx:version1:765">4.11.4</a></dd>
29212882 <dt><a class="idx" href="ugraphs.html#vertices/2">vertices/2</a></dt>
29222883 <dt><a class="idx" href="ugraphs.html#vertices_edges_to_ugraph/3">vertices_edges_to_ugraph/3</a></dt>
29232884 <dt>view,update</dt>
29242885 <dd>
2925 <a class="idx" href="glossary.html#idx:viewupdate:2341">D</a></dd>
2886 <a class="idx" href="glossary.html#idx:viewupdate:2340">D</a></dd>
29262887 <dt><a class="idx" href="debugger.html#visible/1">visible/1</a></dt>
29272888 <dd>
2928 <a class="idx" href="tracehook.html#idx:visible1:2194">B.3</a></dd>
2889 <a class="idx" href="tracehook.html#idx:visible1:2193">B.3</a></dd>
29292890 <dt><a class="idx" href="runtime.html#volatile/1">volatile/1</a></dt>
29302891 <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>
2892 <a class="idx" href="examineprog.html#idx:volatile1:936">4.16</a> <a class="idx" href="threadcom.html#idx:volatile1:1922">9.3.3</a></dd>
29322893 <dt><a class="idx" href="streamstat.html#wait_for_input/3">wait_for_input/3</a></dt>
29332894 <dd>
2934 <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>
2895 <a class="idx" href="IO.html#idx:waitforinput3:1025">4.17.2</a> <a class="idx" href="IO.html#idx:waitforinput3:1026">4.17.2</a> <a class="idx" href="streamstat.html#idx:waitforinput3:1068">4.18</a> <a class="idx" href="streamstat.html#idx:waitforinput3:1069">4.18</a> <a class="idx" href="streamstat.html#idx:waitforinput3:1072">4.18</a></dd>
29352896 <dt><a class="idx" href="clpb.html#weighted_maximum/3">weighted_maximum/3</a></dt>
29362897 <dt><a class="idx" href="coroutining.html#when/2">when/2</a></dt>
29372898 <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>
2899 <a class="idx" href="cyclic.html#idx:when2:254">2.17</a> <a class="idx" href="compare.html#idx:when2:643">4.7.2</a> <a class="idx" href="manipterm.html#idx:when2:1213">4.21</a> <a class="idx" href="coroutining.html#idx:when2:1811">7.2</a></dd>
29392900 <dt><a class="idx" href="miscpreds.html#wildcard_match/2">wildcard_match/2</a></dt>
29402901 <dt><a class="idx" href="system.html#win_add_dll_directory/1">win_add_dll_directory/1</a></dt>
29412902 <dt><a class="idx" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a></dt>
29422903 <dd>
2943 <a class="idx" href="system.html#idx:winadddlldirectory2:1471">4.35.1</a> <a class="idx" href="system.html#idx:winadddlldirectory2:1477">4.35.1</a> <a class="idx" href="system.html#idx:winadddlldirectory2:1478">4.35.1</a></dd>
2904 <a class="idx" href="system.html#idx:winadddlldirectory2:1473">4.35.1</a> <a class="idx" href="system.html#idx:winadddlldirectory2:1479">4.35.1</a> <a class="idx" href="system.html#idx:winadddlldirectory2:1480">4.35.1</a></dd>
29442905 <dt><a class="idx" href="system.html#win_exec/2">win_exec/2</a></dt>
29452906 <dd>
2946 <a class="idx" href="system.html#idx:winexec2:1442">4.35</a> <a class="idx" href="system.html#idx:winexec2:1465">4.35.1</a> <a class="idx" href="system.html#idx:winexec2:1470">4.35.1</a></dd>
2907 <a class="idx" href="system.html#idx:winexec2:1444">4.35</a> <a class="idx" href="system.html#idx:winexec2:1467">4.35.1</a> <a class="idx" href="system.html#idx:winexec2:1472">4.35.1</a></dd>
29472908 <dt><a class="idx" href="system.html#win_folder/2">win_folder/2</a></dt>
29482909 <dd>
2949 <a class="idx" href="initfile.html#idx:winfolder2:23">2.2</a> <a class="idx" href="cmdline.html#idx:winfolder2:31">2.4.2</a></dd>
2910 <a class="idx" href="initfile.html#idx:winfolder2:23">2.2</a> <a class="idx" href="cmdline.html#idx:winfolder2:32">2.4.2</a></dd>
29502911 <dt><a class="idx" href="system.html#win_has_menu/0">win_has_menu/0</a></dt>
29512912 <dt><a class="idx" href="system.html#win_insert_menu/2">win_insert_menu/2</a></dt>
29522913 <dd>
2953 <a class="idx" href="system.html#idx:wininsertmenu2:1490">4.35.3</a> <a class="idx" href="system.html#idx:wininsertmenu2:1492">4.35.3</a></dd>
2914 <a class="idx" href="system.html#idx:wininsertmenu2:1492">4.35.3</a> <a class="idx" href="system.html#idx:wininsertmenu2:1494">4.35.3</a></dd>
29542915 <dt><a class="idx" href="system.html#win_insert_menu_item/4">win_insert_menu_item/4</a></dt>
29552916 <dd>
2956 <a class="idx" href="system.html#idx:wininsertmenuitem4:1491">4.35.3</a></dd>
2917 <a class="idx" href="system.html#idx:wininsertmenuitem4:1493">4.35.3</a></dd>
29572918 <dt><a class="idx" href="system.html#win_registry_get_value/3">win_registry_get_value/3</a></dt>
29582919 <dt><a class="idx" href="system.html#win_remove_dll_directory/1">win_remove_dll_directory/1</a></dt>
29592920 <dd>
2960 <a class="idx" href="system.html#idx:winremovedlldirectory1:1475">4.35.1</a></dd>
2921 <a class="idx" href="system.html#idx:winremovedlldirectory1:1477">4.35.1</a></dd>
29612922 <dt><a class="idx" href="system.html#win_shell/2">win_shell/2</a></dt>
29622923 <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>
2924 <a class="idx" href="system.html#idx:winshell2:1445">4.35</a> <a class="idx" href="system.html#idx:winshell2:1468">4.35.1</a> <a class="idx" href="www_browser.html#idx:winshell2:2151">A.18</a></dd>
29642925 <dt><a class="idx" href="system.html#win_shell/3">win_shell/3</a></dt>
29652926 <dt><a class="idx" href="system.html#win_window_pos/1">win_window_pos/1</a></dt>
29662927 <dt><a class="idx" href="system.html#window_title/2">window_title/2</a></dt>
29672928 <dt>windows</dt>
29682929 <dd>
2969 <a class="idx" href="flags.html#idx:windows:159">2.11</a></dd>
2930 <a class="idx" href="flags.html#idx:windows:161">2.11</a></dd>
29702931 <dt><a class="idx" href="threadsync.html#with_mutex/2">with_mutex/2</a></dt>
29712932 <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>
2933 <a class="idx" href="threadcom.html#idx:withmutex2:1912">9.3.2</a> <a class="idx" href="threadsync.html#idx:withmutex2:1923">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1924">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1933">9.4</a> <a class="idx" href="threadsync.html#idx:withmutex2:1936">9.4</a> <a class="idx" href="foreignthread.html#idx:withmutex2:1956">9.6</a></dd>
29732934 <dt><a class="idx" href="IO.html#with_output_to/2">with_output_to/2</a></dt>
29742935 <dd>
2975 <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>
2936 <a class="idx" href="IO.html#idx:withoutputto2:962">4.17.1</a> <a class="idx" href="IO.html#idx:withoutputto2:964">4.17.1</a> <a class="idx" href="IO.html#idx:withoutputto2:969">4.17.2</a> <a class="idx" href="IO.html#idx:withoutputto2:1051">4.17.4</a> <a class="idx" href="IO.html#idx:withoutputto2:1058">4.17.5</a> <a class="idx" href="termrw.html#idx:withoutputto2:1118">4.20</a> <a class="idx" href="manipatom.html#idx:withoutputto2:1270">4.22</a> <a class="idx" href="chartype.html#idx:withoutputto2:1306">4.24.2</a> <a class="idx" href="format.html#idx:withoutputto2:1410">4.32.2</a> <a class="idx" href="system.html#idx:withoutputto2:1485">4.35.2.2</a></dd>
29762937 <dt><a class="idx" href="charsio.html#with_output_to_chars/2">with_output_to_chars/2</a></dt>
29772938 <dt><a class="idx" href="charsio.html#with_output_to_chars/3">with_output_to_chars/3</a></dt>
29782939 <dt><a class="idx" href="charsio.html#with_output_to_chars/4">with_output_to_chars/4</a></dt>
29792940 <dt><a class="idx" href="quasiquotations.html#with_quasi_quotation_input/3">with_quasi_quotation_input/3</a></dt>
29802941 <dt><a class="idx" href="files.html#working_directory/2">working_directory/2</a></dt>
29812942 <dd>
2982 <a class="idx" href="cmdline.html#idx:workingdirectory2:24">2.4</a> <a class="idx" href="system.html#idx:workingdirectory2:1462">4.35</a> <a class="idx" href="system.html#idx:workingdirectory2:1464">4.35</a> <a class="idx" href="files.html#idx:workingdirectory2:1507">4.36</a> <a class="idx" href="files.html#idx:workingdirectory2:1524">4.36</a></dd>
2943 <a class="idx" href="cmdline.html#idx:workingdirectory2:24">2.4</a> <a class="idx" href="system.html#idx:workingdirectory2:1464">4.35</a> <a class="idx" href="system.html#idx:workingdirectory2:1466">4.35</a> <a class="idx" href="files.html#idx:workingdirectory2:1509">4.36</a> <a class="idx" href="files.html#idx:workingdirectory2:1526">4.36</a></dd>
29832944 <dt><a class="idx" href="foreigninclude.html#write()">write()</a></dt>
29842945 <dt><a class="idx" href="termrw.html#write/1">write/1</a></dt>
29852946 <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>
2947 <a class="idx" href="flags.html#idx:write1:162">2.11</a> <a class="idx" href="cyclic.html#idx:write1:255">2.17</a> <a class="idx" href="limits.html#idx:write1:286">2.20.2</a> <a class="idx" href="IO.html#idx:write1:956">4.17.1</a> <a class="idx" href="IO.html#idx:write1:967">4.17.1</a> <a class="idx" href="format.html#idx:write1:1394">4.32.1</a> <a class="idx" href="format.html#idx:write1:1407">4.32.2</a> <a class="idx" href="foreigninclude.html#idx:write1:2022">11.4.3.2</a> <a class="idx" href="foreigninclude.html#idx:write1:2023">11.4.3.2</a> <b>11.4.3.5</b> <a class="idx" href="foreigninclude.html#idx:write1:2027">11.4.3.6</a> <a class="idx" href="foreigninclude.html#idx:write1:2042">11.4.7.1</a></dd>
29872948 <dt><a class="idx" href="termrw.html#write/2">write/2</a></dt>
29882949 <dt><a class="idx" href="termrw.html#write_canonical/1">write_canonical/1</a></dt>
29892950 <dd>
2990 <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>
2951 <a class="idx" href="termrw.html#idx:writecanonical1:1136">4.20</a> <a class="idx" href="termrw.html#idx:writecanonical1:1145">4.20</a> <a class="idx" href="termrw.html#idx:writecanonical1:1175">4.20</a> <a class="idx" href="format.html#idx:writecanonical1:1402">4.32.2</a> <a class="idx" href="ext-lists.html#idx:writecanonical1:1592">5.1</a></dd>
29912952 <dt><a class="idx" href="termrw.html#write_canonical/2">write_canonical/2</a></dt>
29922953 <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>
2954 <a class="idx" href="IO.html#idx:writecanonical2:1062">4.17.6</a> <a class="idx" href="IO.html#idx:writecanonical2:1063">4.17.6</a> <a class="idx" href="IO.html#idx:writecanonical2:1064">4.17.6</a> <a class="idx" href="manipterm.html#idx:writecanonical2:1207">4.21</a> <a class="idx" href="foreigninclude.html#idx:writecanonical2:2024">11.4.3.2</a></dd>
29942955 <dt><a class="idx" href="termrw.html#write_length/3">write_length/3</a></dt>
29952956 <dd>
2996 <a class="idx" href="manipatom.html#idx:writelength3:1278">4.22</a></dd>
2957 <a class="idx" href="manipatom.html#idx:writelength3:1280">4.22</a></dd>
29972958 <dt><a class="idx" href="termrw.html#write_term/2">write_term/2</a></dt>
29982959 <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>
2960 <a class="idx" href="debugoverview.html#idx:writeterm2:60">2.9</a> <a class="idx" href="flags.html#idx:writeterm2:105">2.11</a> <a class="idx" href="flags.html#idx:writeterm2:126">2.11</a> <a class="idx" href="flags.html#idx:writeterm2:143">2.11</a> <a class="idx" href="termrw.html#idx:writeterm2:1120">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1121">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1124">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1126">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1137">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1140">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1141">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1142">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1151">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1173">4.20</a> <a class="idx" href="termrw.html#idx:writeterm2:1174">4.20</a> <a class="idx" href="manipterm.html#idx:writeterm2:1205">4.21</a> <a class="idx" href="manipatom.html#idx:writeterm2:1268">4.22</a> <a class="idx" href="format.html#idx:writeterm2:1396">4.32.1</a> <a class="idx" href="format.html#idx:writeterm2:1408">4.32.2</a> <a class="idx" href="ext-lists.html#idx:writeterm2:1594">5.1</a> <a class="idx" href="ext-lists.html#idx:writeterm2:1596">5.1</a> <a class="idx" href="strings.html#idx:writeterm2:1601">5.2.1</a> <a class="idx" href="attvar.html#idx:writeterm2:1786">7.1.2</a></dd>
30002961 <dt><a class="idx" href="termrw.html#write_term/3">write_term/3</a></dt>
30012962 <dd>
3002 <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>
2963 <a class="idx" href="flags.html#idx:writeterm3:163">2.11</a> <a class="idx" href="hooks.html#idx:writeterm3:170">2.12</a> <a class="idx" href="termrw.html#idx:writeterm3:1129">4.20</a> <a class="idx" href="manipterm.html#idx:writeterm3:1200">4.21</a> <a class="idx" href="manipatom.html#idx:writeterm3:1281">4.22</a></dd>
30032964 <dt><a class="idx" href="charsio.html#write_to_chars/2">write_to_chars/2</a></dt>
30042965 <dt><a class="idx" href="charsio.html#write_to_chars/3">write_to_chars/3</a></dt>
30052966 <dt><a class="idx" href="format.html#writef/1">writef/1</a></dt>
30062967 <dd>
3007 <a class="idx" href="format.html#idx:writef1:1383">4.32</a></dd>
2968 <a class="idx" href="format.html#idx:writef1:1385">4.32</a></dd>
30082969 <dt><a class="idx" href="format.html#writef/2">writef/2</a></dt>
30092970 <dd>
3010 <a class="idx" href="acknowledge.html#idx:writef2:4">1.6</a> <a class="idx" href="syntax.html#idx:writef2:215">2.16.1.3</a> <a class="idx" href="syntax.html#idx:writef2:216">2.16.1.3</a> <a class="idx" href="syntax.html#idx:writef2:217">2.16.1.3</a> <a class="idx" href="syntax.html#idx:writef2:219">2.16.1.3</a> <a class="idx" href="termrw.html#idx:writef2:1115">4.20</a> <a class="idx" href="format.html#idx:writef2:1384">4.32</a> <a class="idx" href="format.html#idx:writef2:1389">4.32.1</a> <a class="idx" href="format.html#idx:writef2:1398">4.32.1</a></dd>
2971 <a class="idx" href="acknowledge.html#idx:writef2:4">1.6</a> <a class="idx" href="syntax.html#idx:writef2:217">2.16.1.3</a> <a class="idx" href="syntax.html#idx:writef2:218">2.16.1.3</a> <a class="idx" href="syntax.html#idx:writef2:219">2.16.1.3</a> <a class="idx" href="syntax.html#idx:writef2:221">2.16.1.3</a> <a class="idx" href="termrw.html#idx:writef2:1117">4.20</a> <a class="idx" href="format.html#idx:writef2:1386">4.32</a> <a class="idx" href="format.html#idx:writef2:1391">4.32.1</a> <a class="idx" href="format.html#idx:writef2:1400">4.32.1</a></dd>
30112972 <dt><a class="idx" href="termrw.html#writeln/1">writeln/1</a></dt>
30122973 <dt><a class="idx" href="termrw.html#writeln/2">writeln/2</a></dt>
30132974 <dt><a class="idx" href="termrw.html#writeq/1">writeq/1</a></dt>
30142975 <dd>
3015 <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>
2976 <a class="idx" href="format.html#idx:writeq1:1395">4.32.1</a> <a class="idx" href="format.html#idx:writeq1:1404">4.32.2</a></dd>
30162977 <dt><a class="idx" href="termrw.html#writeq/2">writeq/2</a></dt>
30172978 <dd>
3018 <a class="idx" href="foreigninclude.html#idx:writeq2:2026">11.4.3.2</a></dd>
2979 <a class="idx" href="foreigninclude.html#idx:writeq2:2025">11.4.3.2</a></dd>
30192980 <dt><a class="idx" href="url.html#www_form_encode/2">www_form_encode/2</a></dt>
30202981 <dt><a class="idx" href="www_browser.html#www_open_url/1">www_open_url/1</a></dt>
30212982 <dd>
3022 <a class="idx" href="www_browser.html#idx:wwwopenurl1:2154">A.18</a></dd>
2983 <a class="idx" href="www_browser.html#idx:wwwopenurl1:2153">A.18</a></dd>
30232984 <dt><a class="idx" href="prolog_xref.html#xref_built_in/1">xref_built_in/1</a></dt>
30242985 <dt><a class="idx" href="prolog_xref.html#xref_called/3">xref_called/3</a></dt>
30252986 <dt><a class="idx" href="prolog_xref.html#xref_clean/1">xref_clean/1</a></dt>
30302991 <dt><a class="idx" href="prolog_xref.html#xref_source/1">xref_source/1</a></dt>
30312992 <dt><a class="idx" href="clpfd.html#zcompare/3">zcompare/3</a></dt>
30322993 <dd>
3033 <a class="idx" href="clp.html#idx:zcompare3:1769">7</a></dd>
2994 <a class="idx" href="clp.html#idx:zcompare3:1768">7</a></dd>
30342995 <dt><a class="idx" href="control.html#!/0">!/0</a></dt>
30352996 <dt class="index-sep">#</dt>
30362997 <dt><a class="idx" href="clpfd.html##/\/2">#/ 2</a></dt>
30503011 <dt><a class="idx" href="control.html#*->/2">*-&gt;/2</a></dt>
30513012 <dt class="index-sep">,</dt>
30523013 <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>
30553014 <dt class="index-sep">.</dt>
30563015 <dt><a class="idx" href="dicts.html#./3">./3</a></dt>
30573016 <dt class="index-sep">/</dt>
31053064 <dt class="index-sep">A</dt>
31063065 <dt>AMD64</dt>
31073066 <dd>
3108 <a class="idx" href="64bits.html#idx:AMD64:288">2.21.2</a></dd>
3067 <a class="idx" href="64bits.html#idx:AMD64:290">2.21.2</a></dd>
31093068 <dt><a class="idx" href="foreigninclude.html#ATOM_dot()">ATOM_dot()</a></dt>
31103069 <dt><a class="idx" href="foreigninclude.html#ATOM_nil()">ATOM_nil()</a></dt>
31113070 <dt class="index-sep">B</dt>
31123071 <dt>Boehm GC</dt>
31133072 <dd>
3114 <a class="idx" href="foreignnotes.html#idx:BoehmGC:2096">11.8.2.1</a></dd>
3073 <a class="idx" href="foreignnotes.html#idx:BoehmGC:2095">11.8.2.1</a></dd>
31153074 <dt>BOM</dt>
31163075 <dd>
3117 <a class="idx" href="widechars.html#idx:BOM:273">2.19.1.1</a></dd>
3076 <a class="idx" href="widechars.html#idx:BOM:275">2.19.1.1</a></dd>
31183077 <dt>Byte Order Mark</dt>
31193078 <dd>
3120 <a class="idx" href="widechars.html#idx:ByteOrderMark:274">2.19.1.1</a></dd>
3079 <a class="idx" href="widechars.html#idx:ByteOrderMark:276">2.19.1.1</a></dd>
31213080 <dt class="index-sep">C</dt>
31223081 <dt>CLP</dt>
31233082 <dd>
3124 <a class="idx" href="clp.html#idx:CLP:1763">7</a></dd>
3083 <a class="idx" href="clp.html#idx:CLP:1762">7</a></dd>
31253084 <dt>COM</dt>
31263085 <dd>
3127 <a class="idx" href="foreigninclude.html#idx:COM:2041">11.4.7</a></dd>
3086 <a class="idx" href="foreigninclude.html#idx:COM:2040">11.4.7</a></dd>
31283087 <dt class="index-sep">D</dt>
31293088 <dt>Development environment</dt>
31303089 <dd>
3131 <a class="idx" href="IDE.html#idx:Developmentenvironment:291">3</a></dd>
3090 <a class="idx" href="IDE.html#idx:Developmentenvironment:293">3</a></dd>
31323091 <dt>DCG</dt>
31333092 <dd>
3134 <a class="idx" href="consulting.html#idx:DCG:366">4.3</a> <a class="idx" href="DCG.html#idx:DCG:777">4.13</a></dd>
3093 <a class="idx" href="consulting.html#idx:DCG:368">4.3</a> <a class="idx" href="DCG.html#idx:DCG:779">4.13</a></dd>
31353094 <dt class="index-sep">E</dt>
31363095 <dt>Emacs</dt>
31373096 <dd>
3138 <a class="idx" href="gemacs.html#idx:Emacs:47">2.5</a></dd>
3097 <a class="idx" href="gemacs.html#idx:Emacs:48">2.5</a></dd>
31393098 <dt class="index-sep">G</dt>
31403099 <dt>GMP</dt>
31413100 <dd>
3142 <a class="idx" href="arith.html#idx:GMP:1329">4.27.2.1</a></dd>
3101 <a class="idx" href="arith.html#idx:GMP:1331">4.27.2.1</a></dd>
31433102 <dt>GNU-Emacs</dt>
31443103 <dd>
3145 <a class="idx" href="gemacs.html#idx:GNUEmacs:46">2.5</a></dd>
3104 <a class="idx" href="gemacs.html#idx:GNUEmacs:47">2.5</a></dd>
31463105 <dt class="index-sep">H</dt>
31473106 <dt>Herbrand term</dt>
31483107 <dd>
3149 <a class="idx" href="clp.html#idx:Herbrandterm:1765">7</a></dd>
3108 <a class="idx" href="clp.html#idx:Herbrandterm:1764">7</a></dd>
31503109 <dt class="index-sep">I</dt>
31513110 <dt>IA32</dt>
31523111 <dd>
3153 <a class="idx" href="64bits.html#idx:IA32:287">2.21.2</a></dd>
3112 <a class="idx" href="64bits.html#idx:IA32:289">2.21.2</a></dd>
31543113 <dt>IDE</dt>
31553114 <dd>
3156 <a class="idx" href="IDE.html#idx:IDE:290">3</a></dd>
3115 <a class="idx" href="IDE.html#idx:IDE:292">3</a></dd>
31573116 <dt><a class="idx" href="IO.html#set_prolog_IO/3">set_prolog_IO/3</a></dt>
31583117 <dd>
3159 <a class="idx" href="IO.html#idx:setprologIO3:951">4.17.1</a></dd>
3118 <a class="idx" href="IO.html#idx:setprologIO3:953">4.17.1</a></dd>
31603119 <dt>ISO Latin 1</dt>
31613120 <dd>
3162 <a class="idx" href="syntax.html#idx:ISOLatin1:212">2.16.1.1</a></dd>
3121 <a class="idx" href="syntax.html#idx:ISOLatin1:214">2.16.1.1</a></dd>
31633122 <dt class="index-sep">J</dt>
31643123 <dt>Java</dt>
31653124 <dd>
3166 <a class="idx" href="foreigninclude.html#idx:Java:2040">11.4.7</a></dd>
3125 <a class="idx" href="foreigninclude.html#idx:Java:2039">11.4.7</a></dd>
31673126 <dt class="index-sep">M</dt>
31683127 <dt>MacOS</dt>
31693128 <dd>
3170 <a class="idx" href="flags.html#idx:MacOS:86">2.11</a></dd>
3129 <a class="idx" href="flags.html#idx:MacOS:87">2.11</a></dd>
31713130 <dt class="index-sep">P</dt>
31723131 <dt><a class="idx" href="foreigninclude.html#PL_abort_hook()">PL_abort_hook()</a></dt>
31733132 <dt><a class="idx" href="foreigninclude.html#PL_abort_unhook()">PL_abort_unhook()</a></dt>
34063365 <dt><a class="idx" href="foreigninclude.html#PL_PARTIAL_LIST">PL_PARTIAL_LIST</a></dt>
34073366 <dt>PLVERSION</dt>
34083367 <dd>
3409 <a class="idx" href="foreignnotes.html#idx:PLVERSION:2097">11.8.3</a></dd>
3368 <a class="idx" href="foreignnotes.html#idx:PLVERSION:2096">11.8.3</a></dd>
34103369 <dt><a class="idx" href="foreigninclude.html#PL_get_file_nameW()">PL_get_file_nameW()</a></dt>
34113370 <dt class="index-sep">R</dt>
34123371 <dt>RDF,memory usage</dt>
34133372 <dd>
3414 <a class="idx" href="64bits.html#idx:RDFmemoryusage:289">2.21.3</a></dd>
3373 <a class="idx" href="64bits.html#idx:RDFmemoryusage:291">2.21.3</a></dd>
34153374 <dt class="index-sep">S</dt>
34163375 <dt>Solaris</dt>
34173376 <dd>
3418 <a class="idx" href="threadcreate.html#idx:Solaris:1875">9.1</a></dd>
3377 <a class="idx" href="threadcreate.html#idx:Solaris:1874">9.1</a></dd>
34193378 <dt><code>/</code></dt>
34203379 <dd>
3421 <a class="idx" href="projectfiles.html#idx:Sdiv:294">3.1.1.2</a></dd>
3380 <a class="idx" href="projectfiles.html#idx:Sdiv:296">3.1.1.2</a></dd>
34223381 <dt><code><code>\</code></code></dt>
34233382 <dd>
3424 <a class="idx" href="projectfiles.html#idx:chrSneg:295">3.1.1.2</a></dd>
3383 <a class="idx" href="projectfiles.html#idx:chrSneg:297">3.1.1.2</a></dd>
3384 <dt><a class="idx" href="memory.html#set_prolog_gc_thread/+Status">set_prolog_gc_thread/+Status</a></dt>
34253385 <dt>SLG,resolution</dt>
34263386 <dd>
3427 <a class="idx" href="tabling.html#idx:SLGresolution:2175">A.35</a></dd>
3387 <a class="idx" href="tabling.html#idx:SLGresolution:2174">A.35</a></dd>
34283388 <dt class="index-sep">T</dt>
34293389 <dt>TAB,completion</dt>
34303390 <dd>
3431 <a class="idx" href="editreload.html#idx:TABcompletion:304">3.3.1</a></dd>
3391 <a class="idx" href="editreload.html#idx:TABcompletion:306">3.3.1</a></dd>
34323392 <dt>completion,TAB</dt>
34333393 <dd>
3434 <a class="idx" href="editreload.html#idx:completionTAB:305">3.3.1</a></dd>
3394 <a class="idx" href="editreload.html#idx:completionTAB:307">3.3.1</a></dd>
34353395 <dt class="index-sep">U</dt>
34363396 <dt>Unicode</dt>
34373397 <dd>
3438 <a class="idx" href="widechars.html#idx:Unicode:263">2.19</a></dd>
3398 <a class="idx" href="widechars.html#idx:Unicode:265">2.19</a></dd>
34393399 <dt>UCS</dt>
34403400 <dd>
3441 <a class="idx" href="widechars.html#idx:UCS:264">2.19</a></dd>
3401 <a class="idx" href="widechars.html#idx:UCS:266">2.19</a></dd>
34423402 <dt>URL</dt>
34433403 <dd>
3444 <a class="idx" href="system.html#idx:URL:1469">4.35.1</a></dd>
3404 <a class="idx" href="system.html#idx:URL:1471">4.35.1</a></dd>
34453405 <dt>UTF-8</dt>
34463406 <dd>
3447 <a class="idx" href="widechars.html#idx:UTF8:262">2.19</a></dd>
3407 <a class="idx" href="widechars.html#idx:UTF8:264">2.19</a></dd>
34483408 <dt class="index-sep">Y</dt>
34493409 <dt>YAP,prolog</dt>
34503410 <dd>
3451 <a class="idx" href="dialect.html#idx:YAPprolog:2247">C</a></dd>
3411 <a class="idx" href="dialect.html#idx:YAPprolog:2246">C</a></dd>
34523412 <dt class="index-sep">{</dt>
34533413 <dt><a class="idx" href="clpqr.html#{}/1">/1</a></dt>
34543414 <dt class="index-sep">|</dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="64bits.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="projectfiles.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:IDE"><a id="sec:3"><span class="sec-nr">3</span> <span class="sec-title">Initialising
194 <h1 id="sec:IDE"><a name="sec:3"><span class="sec-nr">3</span> <span class="sec-title">Initialising
236195 and Managing a Prolog Project</span></a></h1>
237196
238 <a id="sec:IDE"></a>
239
240 <p><a id="idx:IDE:290"></a><a id="idx:Developmentenvironment:291"></a>Prolog
197 <a name="sec:IDE"></a>
198
199 <p><a name="idx:IDE:292"></a><a name="idx:Developmentenvironment:293"></a>Prolog
241200 text-books give you an overview of the Prolog language. The manual tells
242201 you what predicates are provided in the system and what they do. This
243202 chapter explains how to run a project. There is no ultimate `right' way
245204 SWI-Prolog's commands are there to support this practice. This chapter
246205 describes the conventions and supporting commands.
247206
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>)
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>)
250209 only require plain Prolog. The remainder discusses the use of the
251210 built-in graphical tools that require the XPCE graphical library
252211 installed on your system.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.17</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="examineprog.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="streamstat.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:IO"><a id="sec:4.17"><span class="sec-nr">4.17</span> <span class="sec-title">Input
194 <h2 id="sec:IO"><a name="sec:4.17"><span class="sec-nr">4.17</span> <span class="sec-title">Input
236195 and output</span></a></h2>
237196
238 <a id="sec:IO"></a>
197 <a name="sec:IO"></a>
239198
240199 <p>SWI-Prolog provides two different packages for input and output. The
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>
243 and friends.<sup class="fn">82<span class="fn-text">Actually based on
200 native I/O system is based on the ISO standard predicates <a name="idx:open3:949"></a><a class="pred" href="IO.html#open/3">open/3</a>,
201 <a name="idx:close1:950"></a><a class="pred" href="IO.html#close/1">close/1</a>
202 and friends.<sup class="fn">81<span class="fn-text">Actually based on
244203 Quintus Prolog, providing this interface before the ISO standard
245204 existed.</span></sup> Being more widely portable and equipped with a
246205 clearer and more robust specification, new code is encouraged to use
247206 these predicates for manipulation of I/O streams.
248207
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>
208 <p><a class="sec" href="IO.html">Section 4.17.3</a> describes <a name="idx:tell1:951"></a><a class="pred" href="IO.html#tell/1">tell/1</a>, <a name="idx:see1:952"></a><a class="pred" href="IO.html#see/1">see/1</a>
250209 and friends, providing I/O in the spirit of the traditional Edinburgh
251210 standard. These predicates are layered on top of the ISO predicates.
252211 Both packages are fully integrated; the user may switch freely between
253212 them.
254213
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
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
256215 stream aliases</span></a></h3>
257216
258 <a id="sec:streamalias"></a>
217 <a name="sec:streamalias"></a>
259218
260219 <p>Each thread has five stream aliases: <code>user_input</code>,
261220 <code>user_output</code>, <code>user_error</code>, <code>current_input</code>,
268227 handles 0,&nbsp;1 and&nbsp;2). These aliases may be re-bound, for
269228 example if standard I/O refers to a window such as in the <b>swipl-win.exe</b>
270229 GUI executable for Windows. They can be re-bound by the user using
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>
230 <a name="idx:setprologIO3:953"></a><a class="pred" href="IO.html#set_prolog_IO/3">set_prolog_IO/3</a>
231 and <a name="idx:setstream2:954"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
273232 by setting the alias of a stream (e.g,
274233 <code>set_stream(S, alias(user_output))</code>). An example of rebinding
275234 can be found in library <code>library(prolog_server)</code>, providing a <b>telnet</b>
276235 service. The aliases <code>current_input</code> and <code>current_output</code>
277236 define the source and destination for predicates that do not take 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>,
237 stream argument (e.g., <a name="idx:read1:955"></a><a class="pred" href="termrw.html#read/1">read/1</a>, <a name="idx:write1:956"></a><a class="pred" href="termrw.html#write/1">write/1</a>, <a name="idx:getcode1:957"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>,
279238 ... ). Initially, these are bound to the same stream as <code>user_input</code>
280239 and
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>
240 <code>user_error</code>. They are re-bound by <a name="idx:see1:958"></a><a class="pred" href="IO.html#see/1">see/1</a>, <a name="idx:tell1:959"></a><a class="pred" href="IO.html#tell/1">tell/1</a>, <a name="idx:setinput1:960"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>
282241 and
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>
242 <a name="idx:setoutput1:961"></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:962"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
244 or <a name="idx:format3:963"></a><a class="pred" href="format.html#format/3">format/3</a>
286245 using e.g.,
287246 <code>format(atom(A), ...</code>. Note that code which explicitly writes
288247 to the streams <code>user_output</code> and <code>user_error</code> will
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>.
248 not be redirected by <a name="idx:withoutputto2:964"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
290249
291250 <p><b>Compatibility</b>
292251
293252 <p>Note that the ISO standard only defines the <code>user_*</code>
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>
253 streams. The `current' streams can be accessed using <a name="idx:currentinput1:965"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>
295254 and
296 <a id="idx:currentoutput1:964"></a><a class="pred" href="IO.html#current_output/1">current_output/1</a>.
255 <a name="idx:currentoutput1:966"></a><a class="pred" href="IO.html#current_output/1">current_output/1</a>.
297256 For example, an ISO compatible implementation of
298 <a id="idx:write1:965"></a><a class="pred" href="termrw.html#write/1">write/1</a>
257 <a name="idx:write1:967"></a><a class="pred" href="termrw.html#write/1">write/1</a>
299258 is
300259
301260 <pre class="code">
308267 write(Term) :- write(current_output, Term).
309268 </pre>
310269
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
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
312271 Input and Output Streams</span></a></h3>
313272
314 <a id="sec:isoIO"></a>
273 <a name="sec:isoIO"></a>
315274
316275 <p>The predicates described in this section provide ISO compliant I/O,
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>.
276 where streams are explicitly created using the predicate <a name="idx:open3:968"></a><a class="pred" href="IO.html#open/3">open/3</a>.
318277 The resulting stream identifier is then passed as a parameter to the
319278 reading and writing predicates to specify the source or destination of
320279 the data.
322281 <p>This schema is not vulnerable to filename and stream ambiguities as
323282 well as changes to the working directory. On the other hand, using the
324283 notion of current-I/O simplifies reusability of code without the need to
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>.
284 pass arguments around. E.g., see <a name="idx:withoutputto2:969"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.
326285
327286 <p>SWI-Prolog streams are, compatible with the ISO standard, either
328287 input or output streams. To accommodate portability to other systems, a
329288 pair of streams can be packed into a <em>stream-pair</em>. See
330 <a id="idx:streampair3:968"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>
289 <a name="idx:streampair3:970"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>
331290 for details.
332291
333292 <p>SWI-Prolog stream handles are unique symbols that have no syntactical
334293 representation. They are written as <code>&lt;stream&gt;(hex-number)</code>,
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>).
294 which is not valid input for <a name="idx:read1:971"></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:972"></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>).
338297
339298 <dl class="latex">
340 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="open/4"><strong>open</strong>(<var>+SrcDest,
299 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="open/4"><strong>open</strong>(<var>+SrcDest,
341300 +Mode, --Stream, +Options</var>)</a></dt>
342301 <dd class="defbody">
343302 True when <var>SrcDest</var> can be opened in <var>Mode</var> and <var>Stream</var>
351310 positioning the file pointer at the beginning of the file without
352311 truncating the file. <var>Stream</var> is either a variable, in which
353312 case it is bound to an integer identifying the stream, or an atom, in
354 which case this atom will be the stream identifier.<sup class="fn">83<span class="fn-text">New
313 which case this atom will be the stream identifier.<sup class="fn">82<span class="fn-text">New
355314 code should use the <code>alias(Alias)</code> option for compatibility
356315 with the ISO standard.</span></sup>
357316
363322 <code>read</code>, data written by <var>Command</var> to the standard
364323 output may be read from <var>Stream</var>. On Unix systems, <var>Command</var>
365324 is handed to popen() which hands it to the Unix shell. On Windows, <var>Command</var>
366 is executed directly. See also <a id="idx:processcreate3:971"></a><span class="pred-ext">process_create/3</span>
325 is executed directly. See also <a name="idx:processcreate3:973"></a><span class="pred-ext">process_create/3</span>
367326 from <code>library(process)</code>.
368327
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>:
328 <p>The following <var>Options</var> are recognised by <a name="idx:open4:974"></a><a class="pred" href="IO.html#open/4">open/4</a>:
370329
371330 <dl class="latex">
372331 <dt><strong>alias</strong>(<var>Atom</var>)</dt>
373332 <dd class="defbody">
374333 Gives the stream a name. Below is an example. Be careful with this
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>.
334 option as stream names are global. See also <a name="idx:setstream2:975"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
376335
377336 <pre class="code">
378337 ?- open(data, read, Fd, [alias(input)]).
387346 <dd class="defbody">
388347 Check for a BOM (<em>Byte Order Marker</em>) or write one. If omitted,
389348 the default is <code>true</code> for mode <code>read</code> and
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>
349 <code>false</code> for mode <code>write</code>. See also <a name="idx:streamproperty2:976"></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>
393352 <dt><strong>buffer</strong>(<var>Buffering</var>)</dt>
394353 <dd class="defbody">
395354 Defines output buffering. The atom <code>full</code> (default) defines
396355 full buffering, <code>line</code> buffering by line, and <code>false</code>
397356 implies the stream is fully unbuffered. Smaller buffering is useful if
398357 another process or the user is waiting for the output as it is being
399 produced. See also <a id="idx:flushoutput01:975"></a><a class="pred" href="chario.html#flush_output/0">flush_output/[0,1]</a>.
358 produced. See also <a name="idx:flushoutput01:977"></a><a class="pred" href="chario.html#flush_output/0">flush_output/[0,1]</a>.
400359 This option is not an ISO option.</dd>
401360 <dt><strong>close_on_abort</strong>(<var>Bool</var>)</dt>
402361 <dd class="defbody">
403362 If <code>true</code> (default), the stream is closed on an abort (see
404 <a id="idx:abort0:976"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
363 <a name="idx:abort0:978"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
405364 If <code>false</code>, the stream is not closed. If it is an output
406365 stream, however, it will be flushed. Useful for logfiles and if the
407366 stream is associated to a process (using the <code>pipe/1</code>
410369 <dd class="defbody">
411370 Specifies how a new file is created when opening in <code>write</code>,
412371 <code>append</code> or <code>update</code> mode. Currently, <var>List</var>
413 is a list of atoms that describe the permissions of the created file.<sup class="fn">84<span class="fn-text">Added
372 is a list of atoms that describe the permissions of the created file.<sup class="fn">83<span class="fn-text">Added
414373 after feedback from Joachim Shimpf and Per Mildner.</span></sup> Defined
415374 values are below. Not recognised values are silently ignored, allowing
416375 for adding platform specific extensions to this set.
449408 The default encoding for type <code>text</code> is derived from the
450409 Prolog flag <a class="flag" href="flags.html#flag:encoding">encoding</a>.
451410 For <code>binary</code> streams the default encoding is <code>octet</code>.
452 For details on encoding issues, see <a class="sec" href="widechars.html#sec:2.19.1">section
411 For details on encoding issues, see <a class="sec" href="widechars.html">section
453412 2.19.1</a>.</dd>
454413 <dt><strong>eof_action</strong>(<var>Action</var>)</dt>
455414 <dd class="defbody">
456415 Defines what happens if the end of the input stream is reached. The
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>
416 default value for Action is <code>eof_code</code>, which makes <a name="idx:get01:979"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
417 and friends return -1, and <a name="idx:read1:980"></a><a class="pred" href="termrw.html#read/1">read/1</a>
459418 and friends return the atom
460419 <code>end_of_file</code>. Repetitive reading keeps yielding the same
461420 result. Action <code>error</code> is like <code>eof_code</code>, but
464423 grown.</dd>
465424 <dt><strong>locale</strong>(<var>+Locale</var>)</dt>
466425 <dd class="defbody">
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
426 Set the locale that is used by notably <a name="idx:format2:981"></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
469428 4.23</a>.</dd>
470429 <dt><strong>lock</strong>(<var>LockingMode</var>)</dt>
471430 <dd class="defbody">
503462
504463 <p>The option <code>reposition</code> is not supported in SWI-Prolog.
505464 All streams connected to a file may be repositioned.</dd>
506 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="open/3"><strong>open</strong>(<var>+SrcDest,
465 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="open/3"><strong>open</strong>(<var>+SrcDest,
507466 +Mode, --Stream</var>)</a></dt>
508467 <dd class="defbody">
509 Equivalent to <a id="idx:open4:980"></a><a class="pred" href="IO.html#open/4">open/4</a>
468 Equivalent to <a name="idx:open4:982"></a><a class="pred" href="IO.html#open/4">open/4</a>
510469 with an empty option list.</dd>
511 <dt class="pubdef"><a id="open_null_stream/1"><strong>open_null_stream</strong>(<var>--Stream</var>)</a></dt>
470 <dt class="pubdef"><a name="open_null_stream/1"><strong>open_null_stream</strong>(<var>--Stream</var>)</a></dt>
512471 <dd class="defbody">
513472 Open an output stream that produces no output. All counting functions
514473 are enabled on such a stream. It can be used to discard output (like
529488 </pre>
530489
531490 </dd>
532 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="close/1"><strong>close</strong>(<var>+Stream</var>)</a></dt>
491 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="close/1"><strong>close</strong>(<var>+Stream</var>)</a></dt>
533492 <dd class="defbody">
534493 Close the specified stream. If <var>Stream</var> is not open, an
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>
494 existence error is raised. See <a name="idx:streampair3:983"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>
536495 for the implications of closing a
537496 <em>stream pair</em>.
538497
539498 <p>If the closed stream is the current input, output or error stream,
540499 the stream alias is bound to the initial standard I/O streams of the
541 process. Calling <a id="idx:close1:982"></a><a class="pred" href="IO.html#close/1">close/1</a>
500 process. Calling <a name="idx:close1:984"></a><a class="pred" href="IO.html#close/1">close/1</a>
542501 on the initial standard I/O streams of the process is a no-op for an
543 input stream and flushes an output stream without closing it.<sup class="fn">85<span class="fn-text">This
502 input stream and flushes an output stream without closing it.<sup class="fn">84<span class="fn-text">This
544503 behaviour was defined with purely interactive usage of Prolog in mind.
545504 Applications should not count on this behaviour. Future versions may
546505 allow for closing the initial standard I/O streams.</span></sup></dd>
547 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="close/2"><strong>close</strong>(<var>+Stream,
506 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="close/2"><strong>close</strong>(<var>+Stream,
548507 +Options</var>)</a></dt>
549508 <dd class="defbody">
550509 Provides <code>close(Stream, [force(true)])</code> as the only option.
551510 Called this way, any resource errors (such as write errors while
552511 flushing the output buffer) are ignored.</dd>
553 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="stream_property/2"><strong>stream_property</strong>(<var>?Stream,
512 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="stream_property/2"><strong>stream_property</strong>(<var>?Stream,
554513 ?StreamProperty</var>)</a></dt>
555514 <dd class="defbody">
556515 True when <var>StreamProperty</var> is a property of <var>Stream</var>.
571530 <dd class="defbody">
572531 SWI-Prolog extension to query the buffering mode of this stream.
573532 <var>Buffering</var> is one of <code>full</code>, <code>line</code> or <code>false</code>.
574 See also <a id="idx:open4:983"></a><a class="pred" href="IO.html#open/4">open/4</a>.</dd>
533 See also <a name="idx:open4:985"></a><a class="pred" href="IO.html#open/4">open/4</a>.</dd>
575534 <dt><strong>buffer_size</strong>(<var>Integer</var>)</dt>
576535 <dd class="defbody">
577536 SWI-Prolog extension to query the size of the I/O buffer associated to a
580539 <dd class="defbody">
581540 If present and <code>true</code>, a BOM (<em>Byte Order Mark</em>) was
582541 detected while opening the file for reading, or a BOM was written while
583 opening the stream. See <a class="sec" href="widechars.html#sec:2.19.1.1">section
542 opening the stream. See <a class="sec" href="widechars.html">section
584543 2.19.1.1</a> for details.</dd>
585544 <dt><strong>close_on_abort</strong>(<var>Bool</var>)</dt>
586545 <dd class="defbody">
587 Determine whether or not <a id="idx:abort0:984"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
546 Determine whether or not <a name="idx:abort0:986"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
588547 closes the stream. By default streams are closed.</dd>
589548 <dt><strong>close_on_exec</strong>(<var>Bool</var>)</dt>
590549 <dd class="defbody">
595554 on Windows.</dd>
596555 <dt><strong>encoding</strong>(<var>Encoding</var>)</dt>
597556 <dd class="defbody">
598 Query the encoding used for text. See <a class="sec" href="widechars.html#sec:2.19.1">section
557 Query the encoding used for text. See <a class="sec" href="widechars.html">section
599558 2.19.1</a> for an overview of wide character and encoding issues in
600559 SWI-Prolog.</dd>
601560 <dt><strong>end_of_stream</strong>(<var>E</var>)</dt>
603562 If <var>Stream</var> is an input stream, unify <var>E</var> with one of
604563 the atoms <code>not</code>, <code>at</code> or <code>past</code>. See
605564 also
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>
565 <a name="idx:atendofstream01:987"></a><a class="pred" href="chario.html#at_end_of_stream/0">at_end_of_stream/[0,1]</a>.</dd>
607566 <dt><strong>eof_action</strong>(<var>A</var>)</dt>
608567 <dd class="defbody">
609568 Unify <var>A</var> with one of <code>eof_code</code>, <code>reset</code>
610569 or
611 <code>error</code>. See <a id="idx:open4:986"></a><a class="pred" href="IO.html#open/4">open/4</a>
570 <code>error</code>. See <a name="idx:open4:988"></a><a class="pred" href="IO.html#open/4">open/4</a>
612571 for details.</dd>
613572 <dt><strong>file_name</strong>(<var>Atom</var>)</dt>
614573 <dd class="defbody">
626585 <dt><strong>locale</strong>(<var>Locale</var>)</dt>
627586 <dd class="defbody">
628587 True when <var>Locale</var> is the current locale associated with the
629 stream. See <a class="sec" href="locale.html#sec:4.23">section 4.23</a>.</dd>
588 stream. See <a class="sec" href="locale.html">section 4.23</a>.</dd>
630589 <dt><strong>mode</strong>(<var>IOMode</var>)</dt>
631590 <dd class="defbody">
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>
591 Unify <var>IOMode</var> to the mode given to <a name="idx:open4:989"></a><a class="pred" href="IO.html#open/4">open/4</a>
633592 for opening the stream. Values are: <code>read</code>, <code>write</code>, <code>append</code>
634593 and the SWI-Prolog extension <code>update</code>.</dd>
635594 <dt><strong>newline</strong>(<var>NewlineMode</var>)</dt>
652611 <dd class="defbody">
653612 Unify <var>Pos</var> with the current stream position. A stream position
654613 is an opaque term whose fields can be extracted using
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>
614 <a name="idx:streampositiondata3:990"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.
615 See also <a name="idx:setstreamposition2:991"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.</dd>
657616 <dt><strong>reposition</strong>(<var>Bool</var>)</dt>
658617 <dd class="defbody">
659618 Unify <var>Bool</var> with <var>true</var> if the position of the stream
660 can be set (see <a id="idx:seek4:990"></a><a class="pred" href="IO.html#seek/4">seek/4</a>).
619 can be set (see <a name="idx:seek4:992"></a><a class="pred" href="IO.html#seek/4">seek/4</a>).
661620 It is assumed the position can be set if the stream has a <em>seek-function</em>
662621 and is not based on a POSIX file descriptor that is not associated to a
663622 regular file.</dd>
670629 escape code) or <code>xml</code> (write <code>&amp;#...;</code> XML
671630 character entity). The initial mode is <code>prolog</code> for the user
672631 streams and
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>
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:993"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
675634 <dt><strong>timeout</strong>(<var>-Time</var>)</dt>
676635 <dd class="defbody">
677636 <var>Time</var> is the timeout currently associated with the stream. See
678 <a id="idx:setstream2:992"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
637 <a name="idx:setstream2:994"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
679638 with the same option. If no timeout is specified,
680639 <var>Time</var> is unified to the atom <code>infinite</code>.</dd>
681640 <dt><strong>type</strong>(<var>Type</var>)</dt>
684643 <dt><strong>tty</strong>(<var>Bool</var>)</dt>
685644 <dd class="defbody">
686645 This property is reported with <var>Bool</var> equal to <code>true</code>
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>
646 if the stream is associated with a terminal. See also <a name="idx:setstream2:995"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.</dd>
688647 <dt><strong>write_errors</strong>(<var>Atom</var>)</dt>
689648 <dd class="defbody">
690649 <var>Atom</var> is one of <code>error</code> (default) or <code>ignore</code>.
695654 </dl>
696655
697656 </dd>
698 <dt class="pubdef"><a id="current_stream/3"><strong>current_stream</strong>(<var>?Object,
657 <dt class="pubdef"><a name="current_stream/3"><strong>current_stream</strong>(<var>?Object,
699658 ?Mode, ?Stream</var>)</a></dt>
700659 <dd class="defbody">
701 The predicate <a id="idx:currentstream3:994"></a><a class="pred" href="IO.html#current_stream/3">current_stream/3</a>
660 The predicate <a name="idx:currentstream3:996"></a><a class="pred" href="IO.html#current_stream/3">current_stream/3</a>
702661 is used to access the status of a stream as well as to generate all open
703662 streams. <var>Object</var> is the name of the file opened if the stream
704663 refers to an open file, an integer file descriptor if the stream
705664 encapsulates an operating system stream, or the atom <code>[]</code> if
706665 the stream refers to some other object.
707666 <var>Mode</var> is one of <code>read</code> or <code>write</code>.</dd>
708 <dt class="pubdef"><a id="is_stream/1"><strong>is_stream</strong>(<var>+Term</var>)</a></dt>
667 <dt class="pubdef"><a name="is_stream/1"><strong>is_stream</strong>(<var>+Term</var>)</a></dt>
709668 <dd class="defbody">
710669 True if <var>Term</var> is a stream name or valid stream handle. This
711670 predicate realises a safe test for the existence of a stream alias or
712671 handle.</dd>
713 <dt class="pubdef"><a id="stream_pair/3"><strong>stream_pair</strong>(<var>?StreamPair,
672 <dt class="pubdef"><a name="stream_pair/3"><strong>stream_pair</strong>(<var>?StreamPair,
714673 ?Read, ?Write</var>)</a></dt>
715674 <dd class="defbody">
716675 This predicate can be used in mode (-,+,+) to create a
724683
725684 <p>Stream-pairs can be used by all I/O operations on streams, where the
726685 operation selects the appropriate member of the pair. The predicate
727 <a id="idx:close1:995"></a><a class="pred" href="IO.html#close/1">close/1</a>
728 closes the still open streams of the pair.<sup class="fn">86<span class="fn-text">As
686 <a name="idx:close1:997"></a><a class="pred" href="IO.html#close/1">close/1</a>
687 closes the still open streams of the pair.<sup class="fn">85<span class="fn-text">As
729688 of version 7.1.19, it is allowed to close one of the members of the
730689 stream directly and close the pair later.</span></sup> The output stream
731690 is closed before the input stream. If closing the output stream results
732691 in an error, the input stream is still closed. Success is only returned
733692 if both streams were closed successfully.</dd>
734 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_stream_position/2"><strong>set_stream_position</strong>(<var>+Stream,
693 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_stream_position/2"><strong>set_stream_position</strong>(<var>+Stream,
735694 +Pos</var>)</a></dt>
736695 <dd class="defbody">
737696 Set the current position of <var>Stream</var> to <var>Pos</var>. <var>Pos</var>
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,
697 is a term as returned by <a name="idx:streamproperty2:998"></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:999"></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,
741700 +Pos, -Data</var>)</a></dt>
742701 <dd class="defbody">
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>
702 Extracts information from the opaque stream position term as returned by <a name="idx:streamproperty2:1000"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
744703 requesting the <code>position(Pos)</code> property.
745704 <var>Field</var> is one of <code>line_count</code>, <code>line_position</code>,
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
705 <code>char_count</code> or <code>byte_count</code>. See also <a name="idx:linecount2:1001"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>,
706 <a name="idx:lineposition2:1002"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>, <a name="idx:charactercount2:1003"></a><a class="pred" href="streamstat.html#character_count/2">character_count/2</a>
707 and <a name="idx:bytecount2:1004"></a><a class="pred" href="streamstat.html#byte_count/2">byte_count/2</a>.<sup class="fn">86<span class="fn-text">Introduced
749708 in version 5.6.4 after extending the position term with a byte count.
750709 Compatible with SICStus Prolog.</span></sup></dd>
751 <dt class="pubdef"><a id="seek/4"><strong>seek</strong>(<var>+Stream,
710 <dt class="pubdef"><a name="seek/4"><strong>seek</strong>(<var>+Stream,
752711 +Offset, +Method, -NewLocation</var>)</a></dt>
753712 <dd class="defbody">
754713 Reposition the current point of the given <var>Stream</var>. <var>Method</var>
761720 files using 2-byte Unicode encoding (2 bytes) or <em>wchar</em> encoding
762721 (sizeof(wchar_t)). The latter guarantees comfortable interaction with
763722 wide-character text objects. Otherwise, the use of
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>)
723 <a name="idx:seek4:1005"></a><a class="pred" href="IO.html#seek/4">seek/4</a>
724 on non-binary files (see <a name="idx:open4:1006"></a><a class="pred" href="IO.html#open/4">open/4</a>)
766725 is of limited use, especially when using multi-byte text encodings (e.g. UTF-8)
767726 or multi-byte newline files (e.g. DOS/Windows). On text files,
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>
727 SWI-Prolog offers reliable backup to an old position using <a name="idx:streamproperty2:1007"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
769728 and
770 <a id="idx:setstreamposition2:1006"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.
729 <a name="idx:setstreamposition2:1008"></a><a class="pred" href="IO.html#set_stream_position/2">set_stream_position/2</a>.
771730 Skipping <var>N</var> character codes is achieved calling
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>).
731 <a name="idx:getcode2:1009"></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:1010"></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:1011"></a><a class="pred" href="IO.html#open_null_stream/1">open_null_stream/1</a>).
775734 If the seek modifies the current location, the line number and character
776735 position in the line are set to 0.
777736
779738 is raised. If applying the offset would result in a file position less
780739 than zero, a <code>domain_error</code> is raised. Behaviour when seeking
781740 to positions beyond the size of the underlying object depend on the
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>
741 object and possibly the operating system. The predicate <a name="idx:seek4:1012"></a><a class="pred" href="IO.html#seek/4">seek/4</a>
783742 is compatible with Quintus Prolog, though the error conditions and
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,
743 signalling is ISO compliant. See also <a name="idx:streamproperty2:1013"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
744 and <a name="idx:setstreamposition2:1014"></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,
787746 +Attribute</var>)</a></dt>
788747 <dd class="defbody">
789748 Modify an attribute of an existing stream. <var>Attribute</var>
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>)
749 specifies the stream property to set. If stream is a <em>pair</em> (see <a name="idx:streampair3:1015"></a><a class="pred" href="IO.html#stream_pair/3">stream_pair/3</a>)
791750 both streams are modified, unless the property is only meaningful on one
792751 of the streams or setting both is not meaningful. In particular,
793752 <code>eof_action</code> only applies to the <em>read</em> stream,
794753 <code>representation_errors</code> only applies to the <em>write</em>
795754 stream and trying to set <code>alias</code> or <code>line_position</code>
796755 on a pair results in a <code>permission_error</code> exception. See also
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>.
756 <a name="idx:streamproperty2:1016"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
757 and <a name="idx:open4:1017"></a><a class="pred" href="IO.html#open/4">open/4</a>.
799758
800759 <dl class="latex">
801760 <dt><strong>alias</strong>(<var>AliasName</var>)</dt>
802761 <dd class="defbody">
803762 Set the alias of an already created stream. If <var>AliasName</var> is
804763 the name of one of the standard streams, this stream is rebound. Thus, <code>set_stream(S,
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>,
764 current_input)</code> is the same as <a name="idx:setinput1:1018"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>,
806765 and by setting the alias of a stream to <code>user_input</code>, etc.,
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>
766 all user terminal input is read from this stream. See also <a name="idx:interactor0:1019"></a><a class="pred" href="thutil.html#interactor/0">interactor/0</a>.</dd>
808767 <dt><strong>buffer</strong>(<var>Buffering</var>)</dt>
809768 <dd class="defbody">
810769 Set the buffering mode of an already created stream. Buffering is one of <code>full</code>, <code>line</code>
815774 bytes.</dd>
816775 <dt><strong>close_on_abort</strong>(<var>Bool</var>)</dt>
817776 <dd class="defbody">
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>.
777 Determine whether or not the stream is closed by <a name="idx:abort0:1020"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
819778 By default, streams are closed.</dd>
820779 <dt><strong>close_on_exec</strong>(<var>Bool</var>)</dt>
821780 <dd class="defbody">
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>
781 Set the <code>close_on_exec</code> property. See <a name="idx:streamproperty2:1021"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.</dd>
823782 <dt><strong>encoding</strong>(<var>Atom</var>)</dt>
824783 <dd class="defbody">
825784 Defines the mapping between bytes and character codes used for the
826 stream. See <a class="sec" href="widechars.html#sec:2.19.1">section
827 2.19.1</a> for supported encodings. The value
785 stream. See <a class="sec" href="widechars.html">section 2.19.1</a> for
786 supported encodings. The value
828787 <code>bom</code> causes the stream to check whether the current
829788 character is a Unicode BOM marker. If a BOM marker is found, the
830789 encoding is set accordingly and the call succeeds. Otherwise the call
846805 to correct position management of the stream after sending a terminal
847806 escape sequence (e.g., setting ANSI character attributes). Setting this
848807 attribute raises a permission error if the stream does not record
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>
808 positions. See <a name="idx:lineposition2:1022"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>
809 and <a name="idx:streamproperty2:1023"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
851810 (property <code>position</code>).</dd>
852811 <dt><strong>locale</strong>(<var>+Locale</var>)</dt>
853812 <dd class="defbody">
854 Change the locale of the stream. See <a class="sec" href="locale.html#sec:4.23">section
813 Change the locale of the stream. See <a class="sec" href="locale.html">section
855814 4.23</a>.</dd>
856815 <dt><strong>newline</strong>(<var>NewlineMode</var>)</dt>
857816 <dd class="defbody">
858817 Set input or output translation for newlines. See corresponding
859 <a id="idx:streamproperty2:1022"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
818 <a name="idx:streamproperty2:1024"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
860819 for details. In addition to the detected modes, an input stream can be
861820 set in mode <code>detect</code>. It will be set to <code>dos</code> if a <code>\r</code>
862821 character was removed.</dd>
865824 This option can be used to make streams generate an exception if it
866825 takes longer than <var>Seconds</var> before any new data arrives at the
867826 stream. The value <var>infinite</var> (default) makes the stream block
868 indefinitely. Like <a id="idx:waitforinput3:1023"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>,
827 indefinitely. Like <a name="idx:waitforinput3:1025"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>,
869828 this call only applies to streams that support the select() system call.
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>.
829 For further information about timeout handling, see <a name="idx:waitforinput3:1026"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>.
871830 The exception is of the form
872831 <blockquote>
873832 <code>error(<code>timeout_error(read, Stream)</code>, _)</code>
876835 <dt><strong>type</strong>(<var>Type</var>)</dt>
877836 <dd class="defbody">
878837 Set the type of the stream to one of <code>text</code> or <code>binary</code>.
879 See also <a id="idx:open4:1025"></a><a class="pred" href="IO.html#open/4">open/4</a>
838 See also <a name="idx:open4:1027"></a><a class="pred" href="IO.html#open/4">open/4</a>
880839 and the <code>encoding</code> property of streams. Switching to <code>binary</code>
881840 sets the encoding to <code>octet</code>. Switching to
882841 <code>text</code> sets the encoding to the default text encoding.</dd>
883842 <dt><strong>record_position</strong>(<var>Bool</var>)</dt>
884843 <dd class="defbody">
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>).
844 Do/do not record the line count and line position (see <a name="idx:linecount2:1028"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>
845 and <a name="idx:lineposition2:1029"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>).
887846 Calling <code>set_stream(S, record_position(true))</code> resets the
888847 position the start of line&nbsp;1.</dd>
889848 <dt><strong>representation_errors</strong>(<var>Mode</var>)</dt>
890849 <dd class="defbody">
891850 Change the behaviour when writing characters to the stream that cannot
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>
851 be represented by the encoding. See also <a name="idx:streamproperty2:1030"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
893852 and
894 <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a>.</dd>
853 <a class="sec" href="widechars.html">section 2.19.1</a>.</dd>
895854 <dt><strong>tty</strong>(<var>Bool</var>)</dt>
896855 <dd class="defbody">
897856 Modify whether Prolog thinks there is a terminal (i.e. human
898857 interaction) connected to this stream. On Unix systems the initial value
899858 comes from isatty(). On Windows, the initial user streams are supposed
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>.
859 to be associated to a terminal. See also <a name="idx:streamproperty2:1031"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.
901860 </dd>
902861 </dl>
903862
904863 </dd>
905 <dt class="pubdef"><a id="set_prolog_IO/3"><strong>set_prolog_IO</strong>(<var>+In,
864 <dt class="pubdef"><a name="set_prolog_IO/3"><strong>set_prolog_IO</strong>(<var>+In,
906865 +Out, +Error</var>)</a></dt>
907866 <dd class="defbody">
908867 Prepare the given streams for interactive behaviour normally associated
915874 is used for
916875 <code>user_error</code>. Output buffering for <var>Out</var> is set to
917876 <code>line</code> and buffering on <var>Error</var> is disabled. See
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>.
877 also <a name="idx:prolog0:1032"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
878 and <a name="idx:setstream2:1033"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
920879 The <em>clib</em> package provides the library <code>library(prolog_server)</code>,
921880 creating a TCP/IP server for creating an interactive session to Prolog.
922881 </dd>
923882 </dl>
924883
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
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
926885 I/O</span></a></h3>
927886
928 <a id="sec:edinburghIO"></a>
887 <a name="sec:edinburghIO"></a>
929888
930889 <p>The package for implicit input and output destinations is (almost)
931890 compatible with Edinburgh DEC-10 and C-Prolog. The reading and writing
932891 predicates refer to, resp., the <em>current</em> input and output
933892 streams. Initially these streams are connected to the terminal. The
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>
893 current output stream is changed using <a name="idx:tell1:1034"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
894 or <a name="idx:append1:1035"></a><a class="pred" href="IO.html#append/1">append/1</a>.
895 The current input stream is changed using <a name="idx:see1:1036"></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:1037"></a><a class="pred" href="IO.html#telling/1">telling/1</a>
897 for output and <a name="idx:seeing1:1038"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
939898 for input.
940899
941900 <p>Source and destination are either a file, <code>user</code>, or a
942901 term `pipe(<var>Command</var>)'. The reserved stream name <code>user</code>
943 refers to the terminal.<sup class="fn">88<span class="fn-text">The ISO
902 refers to the terminal.<sup class="fn">87<span class="fn-text">The ISO
944903 I/O layer uses <code>user_input</code>, <code>user_output</code> and <code>user_error</code>.</span></sup>
945904 In the predicate descriptions below we will call the source/destination
946905 argument `<var>SrcDest</var>'. Below are some examples of
947906 source/destination specifications.
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>
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>
956914 </table>
915 </div>
957916
958917 <p>Another example of using the <code>pipe/1</code> construct is shown
959 below.<sup class="fn">89<span class="fn-text">As of version 5.3.15, the
918 below.<sup class="fn">88<span class="fn-text">As of version 5.3.15, the
960919 pipe construct is supported in the MS-Windows version, both for <b>swipl.exe</b>
961920 and <b>swipl-win.exe</b>. The implementation uses code from the LUA
962921 programming language (<a class="url" href="http://www.lua.org">http://www.lua.org</a>).</span></sup>
976935 collect_wd([]).
977936 </pre>
978937
979 <p>The effect of <a id="idx:tell1:1037"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
938 <p>The effect of <a name="idx:tell1:1039"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
980939 is not undone on backtracking, and since the stream handle is not
981940 specified explicitly in further I/O operations when using
982941 Edinburgh-style I/O, you may write to unintended streams more easily
989948
990949 <h4>Compatibility notes</h4>
991950
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>
951 <p>Unlike Edinburgh Prolog systems, <a name="idx:telling1:1040"></a><a class="pred" href="IO.html#telling/1">telling/1</a>
952 and <a name="idx:seeing1:1041"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
994953 do not return the filename of the current input/output but rather the
995954 stream identifier, to ensure the design pattern below works under all
996 circumstances:<sup class="fn">90<span class="fn-text">Filenames can be
955 circumstances:<sup class="fn">89<span class="fn-text">Filenames can be
997956 ambiguous and SWI-Prolog streams can refer to much more than just files.</span></sup>
998957
999958 <pre class="code">
1004963 ...,
1005964 </pre>
1006965
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>
966 <p>The predicates <a name="idx:tell1:1042"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
967 and <a name="idx:see1:1043"></a><a class="pred" href="IO.html#see/1">see/1</a>
1009968 first check for <code>user</code>, the
1010969 <code>pipe(command)</code> and a stream handle. Otherwise, if the
1011970 argument is an atom it is first compared to open streams associated to a
1012971 file with <em>exactly</em> the same name. If such a stream exists,
1013972 created using
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>,
973 <a name="idx:tell1:1044"></a><a class="pred" href="IO.html#tell/1">tell/1</a>
974 or <a name="idx:see1:1045"></a><a class="pred" href="IO.html#see/1">see/1</a>,
1016975 output (input) is switched to the open stream. Otherwise a file with the
1017976 specified name is opened.
1018977
1020979 without problems. Changing directory, non-file streams, and multiple
1021980 names referring to the same file easily lead to unexpected behaviour.
1022981 New code, especially when managing multiple I/O channels, should
1023 consider using the ISO I/O predicates defined in <a class="sec" href="IO.html#sec:4.17.2">section
982 consider using the ISO I/O predicates defined in <a class="sec" href="IO.html">section
1024983 4.17.2</a>.
1025984
1026985 <dl class="latex">
1027 <dt class="pubdef"><a id="see/1"><strong>see</strong>(<var>+SrcDest</var>)</a></dt>
986 <dt class="pubdef"><a name="see/1"><strong>see</strong>(<var>+SrcDest</var>)</a></dt>
1028987 <dd class="defbody">
1029988 Open <var>SrcDest</var> for reading and make it the current input (see
1030 <a id="idx:setinput1:1044"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>).
989 <a name="idx:setinput1:1046"></a><a class="pred" href="IO.html#set_input/1">set_input/1</a>).
1031990 If <var>SrcDest</var> is a stream handle, just make this stream the
1032 current input. See the introduction of <a class="sec" href="IO.html#sec:4.17.3">section
991 current input. See the introduction of <a class="sec" href="IO.html">section
1033992 4.17.3</a> for details.</dd>
1034 <dt class="pubdef"><a id="tell/1"><strong>tell</strong>(<var>+SrcDest</var>)</a></dt>
993 <dt class="pubdef"><a name="tell/1"><strong>tell</strong>(<var>+SrcDest</var>)</a></dt>
1035994 <dd class="defbody">
1036995 Open <var>SrcDest</var> for writing and make it the current output (see
1037 <a id="idx:setoutput1:1045"></a><a class="pred" href="IO.html#set_output/1">set_output/1</a>).
996 <a name="idx:setoutput1:1047"></a><a class="pred" href="IO.html#set_output/1">set_output/1</a>).
1038997 If <var>SrcDest</var> is a stream handle, just make this stream the
1039 current output. See the introduction of <a class="sec" href="IO.html#sec:4.17.3">section
998 current output. See the introduction of <a class="sec" href="IO.html">section
1040999 4.17.3</a> for details.</dd>
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>,
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:1048"></a><a class="pred" href="IO.html#tell/1">tell/1</a>,
10441003 but positions the file pointer at the end of <var>File</var> rather than
10451004 truncating an existing file. The pipe construct is not accepted by this
10461005 predicate.</dd>
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>,
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:1049"></a><a class="pred" href="IO.html#current_input/1">current_input/1</a>,
10501009 except that <code>user</code> is returned if the current input is the
10511010 stream <code>user_input</code> to improve compatibility with traditional
10521011 Edinburgh I/O. See the introduction of
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>,
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:1050"></a><a class="pred" href="IO.html#current_output/1">current_output/1</a>,
10571016 except that <code>user</code> is returned if the current output is the
10581017 stream <code>user_output</code> to improve compatibility with
10591018 traditional Edinburgh I/O. See the introduction of
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>
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>
10621021 <dd class="defbody">
10631022 Close the current input stream. The new input stream becomes
10641023 <code>user_input</code>.</dd>
1065 <dt class="pubdef"><a id="told/0"><strong>told</strong></a></dt>
1024 <dt class="pubdef"><a name="told/0"><strong>told</strong></a></dt>
10661025 <dd class="defbody">
10671026 Close the current output stream. The new output stream becomes
10681027 <code>user_output</code>.
10691028 </dd>
10701029 </dl>
10711030
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
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
10731032 between Edinburgh and ISO I/O</span></a></h3>
10741033
1075 <a id="sec:edinburgh-iso-io"></a>
1034 <a name="sec:edinburgh-iso-io"></a>
10761035
10771036 <p>The predicates below can be used for switching between the implicit
10781037 and the explicit stream-based I/O predicates.
10791038
10801039 <dl class="latex">
1081 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_input/1"><strong>set_input</strong>(<var>+Stream</var>)</a></dt>
1040 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_input/1"><strong>set_input</strong>(<var>+Stream</var>)</a></dt>
10821041 <dd class="defbody">
10831042 Set the current input stream to become <var>Stream</var>. Thus, <code>open(file,
10841043 read, Stream), set_input(Stream)</code> is equivalent to <code>see(file)</code>.
10851044 </dd>
1086 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_output/1"><strong>set_output</strong>(<var>+Stream</var>)</a></dt>
1045 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_output/1"><strong>set_output</strong>(<var>+Stream</var>)</a></dt>
10871046 <dd class="defbody">
10881047 Set the current output stream to become <var>Stream</var>. See also
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>
1048 <a name="idx:withoutputto2:1051"></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>
10921051 <dd class="defbody">
10931052 Get the current input stream. Useful for getting access to the status
10941053 predicates associated with streams.
10951054 </dd>
1096 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_output/1"><strong>current_output</strong>(<var>-Stream</var>)</a></dt>
1055 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_output/1"><strong>current_output</strong>(<var>-Stream</var>)</a></dt>
10971056 <dd class="defbody">
10981057 Get the current output stream.
10991058 </dd>
11001059 </dl>
11011060
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
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
11031062 onto atoms, code-lists, etc.</span></a></h3>
11041063
1105 <a id="sec:write-on-atom"></a>
1064 <a name="sec:write-on-atom"></a>
11061065
11071066 <dl class="latex">
1108 <dt class="pubdef"><a id="with_output_to/2"><strong>with_output_to</strong>(<var>+Output,
1067 <dt class="pubdef"><a name="with_output_to/2"><strong>with_output_to</strong>(<var>+Output,
11091068 :Goal</var>)</a></dt>
11101069 <dd class="defbody">
1111 Run <var>Goal</var> as <a id="idx:once1:1050"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
1070 Run <var>Goal</var> as <a name="idx:once1:1052"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
11121071 while characters written to the current output are sent to <var>Output</var>.
11131072 The predicate is SWI-Prolog-specific, inspired by various posts to the
11141073 mailinglist. It provides a flexible replacement for predicates such as
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>
1074 sformat/3 , <a name="idx:swritef3:1053"></a><a class="pred" href="format.html#swritef/3">swritef/3</a>,
1075 <a name="idx:termtoatom2:1054"></a><a class="pred" href="manipatom.html#term_to_atom/2">term_to_atom/2</a>, <a name="idx:atomnumber2:1055"></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:1056"></a><a class="pred" href="format.html#format/3">format/3</a>
11181077 accepts the same terms as output argument.
11191078
11201079 <p>Applications should generally avoid creating atoms by breaking and
11221081 intermediate atoms generally leads to poor performance, even more so in
11231082 multithreaded applications. This predicate supports creating difference
11241083 lists from character data efficiently. The example below defines the DCG
1125 rule <a id="idx:term1:1055"></a><span class="pred-ext">term//1</span> to
1126 insert a term in the output:
1084 rule <a name="idx:term1:1057"></a><span class="pred-ext">term/3</span>
1085 to insert a term in the output:
11271086
11281087 <pre class="code">
11291088 term(Term, In, Tail) :-
11381097 <dt><b>A Stream handle or alias</b></dt>
11391098 <dd class="defbody">
11401099 Temporarily switch current output to the given stream. Redirection using
1141 <a id="idx:withoutputto2:1056"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
1100 <a name="idx:withoutputto2:1058"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
11421101 guarantees the original output is restored, also if
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>
1102 <var>Goal</var> fails or raises an exception. See also <a name="idx:callcleanup2:1059"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.</dd>
11441103 <dt><strong>atom</strong>(<var>-Atom</var>)</dt>
11451104 <dd class="defbody">
11461105 Create an atom from the emitted characters. Please note the remark
11471106 above.</dd>
11481107 <dt><strong>string</strong>(<var>-String</var>)</dt>
11491108 <dd class="defbody">
1150 Create a string object as defined in <a class="sec" href="strings.html#sec:5.2">section
1109 Create a string object as defined in <a class="sec" href="strings.html">section
11511110 5.2</a>.</dd>
11521111 <dt><strong>codes</strong>(<var>-Codes</var>)</dt>
11531112 <dd class="defbody">
11541113 Create a list of character codes from the emitted characters, similar to
1155 <a id="idx:atomcodes2:1058"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.</dd>
1114 <a name="idx:atomcodes2:1060"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.</dd>
11561115 <dt><strong>codes</strong>(<var>-Codes, -Tail</var>)</dt>
11571116 <dd class="defbody">
11581117 Create a list of character codes as a difference list.</dd>
11591118 <dt><strong>chars</strong>(<var>-Chars</var>)</dt>
11601119 <dd class="defbody">
11611120 Create a list of one-character atoms from the emitted characters,
1162 similar to <a id="idx:atomchars2:1059"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>.</dd>
1121 similar to <a name="idx:atomchars2:1061"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>.</dd>
11631122 <dt><strong>chars</strong>(<var>-Chars, -Tail</var>)</dt>
11641123 <dd class="defbody">
11651124 Create a list of one-character atoms as a difference list.
11691128 </dd>
11701129 </dl>
11711130
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
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
11731132 binary term I/O</span></a></h3>
11741133
1175 <a id="sec:fast-term-io"></a>
1134 <a name="sec:fast-term-io"></a>
11761135
11771136 <p>The predicates in this section provide fast binary I/O of arbitrary
11781137 Prolog terms, including cyclic terms and terms holding attributed
11801139 compatible library that extends the core primitives described below.
11811140
11821141 <p>The binary representation the same as used by <a class="func" href="foreigninclude.html#PL_record_external()">PL_record_external()</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>
1142 The use of these primitives instead of using <a name="idx:writecanonical2:1062"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>
11841143 has advantages and disadvantages. Below are the main considerations:
11851144
11861145 <p>
11871146 <ul class="latex">
1188 <li>Using <a id="idx:writecanonical2:1061"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>
1147 <li>Using <a name="idx:writecanonical2:1063"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>
11891148 allows or exchange of terms with other Prolog systems. The format is
11901149 stable and, as it is text based, it can be inspected and corrected.
11911150 <li>Using the binary format improves the performance roughly 3 times.
11921151 <li>The size of both representations is comparable.
11931152 <li>The binary format can deal with cycles, sharing and attributes.
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>.
1153 Special precautions are needed to transfer such terms using <a name="idx:writecanonical2:1064"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.
1154 See <a name="idx:termfactorized3:1065"></a><span class="pred-ext">term_factorized/3</span>
1155 and <a name="idx:copyterm3:1066"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>.
11971156 <li>In the current version, reading the binary format has only
11981157 incomplete consistency checks. This implies a user must be able to <b>trust
11991158 the source</b> as crafted messages may compromise the reading Prolog
12011160 </ul>
12021161
12031162 <dl class="latex">
1204 <dt class="pubdef"><a id="fast_term_serialized/2"><strong>fast_term_serialized</strong>(<var>?Term,
1163 <dt class="pubdef"><a name="fast_term_serialized/2"><strong>fast_term_serialized</strong>(<var>?Term,
12051164 ?String</var>)</a></dt>
12061165 <dd class="defbody">
12071166 (De-)serialize <var>Term</var> to/from <var>String</var>.</dd>
1208 <dt class="pubdef"><a id="fast_write/2"><strong>fast_write</strong>(<var>+Output,
1167 <dt class="pubdef"><a name="fast_write/2"><strong>fast_write</strong>(<var>+Output,
12091168 +Term</var>)</a></dt>
12101169 <dd class="defbody">
12111170 Write <var>Term</var> using the fast serialization format to the
12121171 <var>Output</var> stream. <var>Output</var> <em>must</em> be a binary
12131172 stream.</dd>
1214 <dt class="pubdef"><a id="fast_read/2"><strong>fast_read</strong>(<var>+Input,
1173 <dt class="pubdef"><a name="fast_read/2"><strong>fast_read</strong>(<var>+Input,
12151174 -Term</var>)</a></dt>
12161175 <dd class="defbody">
12171176 Read <var>Term</var> using the fast serialization format from the
12181177 <var>Input</var> stream. <var>Input</var> <em>must</em> be a binary
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>
1178 stream.<sup class="fn">bug<span class="fn-text">The predicate <a name="idx:fastread2:1067"></a><a class="pred" href="IO.html#fast_read/2">fast_read/2</a>
12201179 may crash on arbitrary input.</span></sup>
12211180 </dd>
12221181 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="chrintro.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="practical.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:SyntaxAndSemantics"><a id="sec:8.2"><span class="sec-nr">8.2</span> <span class="sec-title">Syntax
194 <h2 id="sec:SyntaxAndSemantics"><a name="sec:8.2"><span class="sec-nr">8.2</span> <span class="sec-title">Syntax
236195 and Semantics</span></a></h2>
237196
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
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
240199 of CHR rules</span></a></h3>
241200
242 <a id="sec:chr-syntax"></a>
201 <a name="sec:chr-syntax"></a>
243202
244203 <pre class="code">
245204 rules --&gt; rule, rules ; [].
288247 do not appear in the head of the rule, e.g. an auxiliary variable
289248 introduced in the guard.
290249
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
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
294253 semantics of CHR in Prolog are presented informally. They do not differ
295254 essentially from other CHR systems.
296255
375334 <p>Additional pragmas may be released in the future.
376335
377336 <dl class="latex">
378 <dt class="pubdef"><a id="chr_option/2">:- <strong>chr_option</strong>(<var>+Option,
337 <dt class="pubdef"><a name="chr_option/2">:- <strong>chr_option</strong>(<var>+Option,
379338 +Value</var>)</a></dt>
380339 <dd class="defbody">
381340 It is possible to specify options that apply to all the CHR rules in the
413372 <dd class="defbody">
414373 This option enables or disables the possibility to debug the CHR code.
415374 Possible values are <code>on</code> (default) and <code>off</code>. See
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>,
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>,
418377 which is <code>true</code> by default. See <strong>-nodebug</strong>. If
419378 debugging is enabled, optimization must be disabled.
420379 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="implhistory.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="overview.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>Some small parts of the Prolog code of SWI-Prolog are modified
240199 versions of the corresponding Edinburgh C-Prolog code: grammar rule
241 compilation and <a id="idx:writef2:4"></a><a class="pred" href="format.html#writef/2">writef/2</a>.
200 compilation and <a name="idx:writef2:4"></a><a class="pred" href="format.html#writef/2">writef/2</a>.
242201 Also some of the C-code originates from C-Prolog: finding the path of
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>.
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>.
244203 Ideas on programming style and techniques originate from C-Prolog and
245204 Richard O'Keefe's <em>thief</em> editor. An important source of
246205 inspiration are the programming techniques introduced by Anjo
265224 implementation.
266225
267226 <p>Tom Schrijvers and Bart Demoen initiated the implementation of
268 <em>delimited continuations</em> (<a class="sec" href="delcont.html#sec:4.10">section
227 <em>delimited continuations</em> (<a class="sec" href="delcont.html">section
269228 4.10</a>), which was used by Benoit Desouter and Tom Schrijvers to
270 implement <em>tabling</em> (<a class="sec" href="tabling.html#sec:A.35">section
229 implement <em>tabling</em> (<a class="sec" href="tabling.html">section
271230 A.35</a>) as a library. Fabrizio Riguzzi added a first implementation
272 for <em>mode directed tabling</em> (<a class="sec" href="tabling.html#sec:A.35.3">section
231 for <em>mode directed tabling</em> (<a class="sec" href="tabling.html">section
273232 A.35.3</a>).
274233
275 <p>The SWI-Prolog&nbsp;7 extensions (<a class="sec" href="extensions.html#sec:5">section
234 <p>The SWI-Prolog&nbsp;7 extensions (<a class="sec" href="extensions.html">section
276235 5</a>) are the result of a long heated discussion on the mailinglist.
277236 Nicos Angelopoulos' wish for a smooth integration with the R language
278237 triggered the overall intend of these extensions to enable a smoother
304263
305264 <p>Kyndi (<a class="url" href="https://kyndi.com/">https://kyndi.com/</a>)
306265 sponsored the development of the
307 <em>engines</em> interface (<a class="sec" href="engines.html#sec:10">chapter
266 <em>engines</em> interface (<a class="sec" href="engines.html">chapter
308267 10</a>). The final API was established after discussion with the
309268 founding father of engines, Paul Tarau and Paulo Moura. Kyndi also
310269 sponsored JIT indexing on multiple arguments.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="libpl.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="apply.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:aggregate"><a id="sec:A.1"><span class="sec-nr">A.1</span> <span class="sec-title">library(aggregate):
194 <h2 id="sec:aggregate"><a name="sec:A.1"><span class="sec-nr">A.1</span> <span class="sec-title">library(aggregate):
236195 Aggregation operators on backtrackable predicates</span></a></h2>
237196
238 <p><a id="sec:aggregate"></a>
197 <p><a name="sec:aggregate"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">Compatibility</dt>
353312 <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>
354313
355314 <dl class="latex">
356 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="aggregate/3"><strong>aggregate</strong>(<var>+Template,
315 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="aggregate/3"><strong>aggregate</strong>(<var>+Template,
357316 :Goal, -Result</var>)</a></dt>
358317 <dd class="defbody">
359318 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
360319 The <a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
361320 version performs <a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
362321 on <var>Goal</var>.</dd>
363 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="aggregate/4"><strong>aggregate</strong>(<var>+Template,
322 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="aggregate/4"><strong>aggregate</strong>(<var>+Template,
364323 +Discriminator, :Goal, -Result</var>)</a></dt>
365324 <dd class="defbody">
366325 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
367326 The <a class="pred" href="aggregate.html#aggregate/4">aggregate/4</a>
368327 version performs <a class="pred" href="allsolutions.html#setof/3">setof/3</a>
369328 on <var>Goal</var>.</dd>
370 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="aggregate_all/3"><strong>aggregate_all</strong>(<var>+Template,
329 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="aggregate_all/3"><strong>aggregate_all</strong>(<var>+Template,
371330 :Goal, -Result</var>)</a></dt>
372331 <dd class="defbody">
373332 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
379338 <code>max(X)</code>, <code>min(X,Witness)</code> or <code>max(X,Witness)</code>
380339 and <var>Goal</var> has no solutions, i.e., the minumum and maximum of
381340 an empty set is undefined.</dd>
382 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="aggregate_all/4"><strong>aggregate_all</strong>(<var>+Template,
341 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="aggregate_all/4"><strong>aggregate_all</strong>(<var>+Template,
383342 +Discriminator, :Goal, -Result</var>)</a></dt>
384343 <dd class="defbody">
385344 Aggregate bindings in <var>Goal</var> according to <var>Template</var>.
389348 followed by <a class="pred" href="builtinlist.html#sort/2">sort/2</a> on
390349 <var>Goal</var>. See <a class="pred" href="aggregate.html#aggregate_all/3">aggregate_all/3</a>
391350 to understand why this predicate can fail.</dd>
392 <dt class="pubdef"><a id="foreach/2"><strong>foreach</strong>(<var>:Generator,
351 <dt class="pubdef"><a name="foreach/2"><strong>foreach</strong>(<var>:Generator,
393352 :Goal</var>)</a></dt>
394353 <dd class="defbody">
395354 True if conjunction of results is true. Unlike <a class="pred" href="forall2.html#forall/2">forall/2</a>,
422381 </dl>
423382
424383 </dd>
425 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="free_variables/4"><strong>free_variables</strong>(<var>:Generator,
384 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="free_variables/4"><strong>free_variables</strong>(<var>:Generator,
426385 +Template, +VarList0, -VarList</var>)</a></dt>
427386 <dd class="defbody">
428387 Find free variables in bagof/setof template. In order to handle
458417 </dl>
459418
460419 </dd>
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,
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,
462421 -Called</var>)</a></dt>
463422 <dd class="defbody">
464423 Declare the aggregate meta-calls safe. This cannot be proven due to the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.30</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="builtinlist.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="forall2.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:allsolutions"><a id="sec:4.30"><span class="sec-nr">4.30</span> <span class="sec-title">Finding
194 <h2 id="sec:allsolutions"><a name="sec:4.30"><span class="sec-nr">4.30</span> <span class="sec-title">Finding
236195 all Solutions to a Goal</span></a></h2>
237196
238 <a id="sec:allsolutions"></a>
197 <a name="sec:allsolutions"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="findall/3"><strong>findall</strong>(<var>+Template,
200 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="findall/3"><strong>findall</strong>(<var>+Template,
242201 :Goal, -Bag</var>)</a></dt>
243202 <dd class="defbody">
244203 Create a list of the instantiations <var>Template</var> gets
245204 successively on backtracking over <var>Goal</var> and unify the result
246205 with <var>Bag</var>. Succeeds with an empty list if <var>Goal</var> has
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>
206 no solutions. <a name="idx:findall3:1363"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
207 is equivalent to <a name="idx:bagof3:1364"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
249208 with all free variables bound with the existential operator (<strong><code>^</code></strong>),
250 except that <a id="idx:bagof3:1363"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
209 except that <a name="idx:bagof3:1365"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
251210 fails when <var>Goal</var> has no solutions.</dd>
252 <dt class="pubdef"><a id="findall/4"><strong>findall</strong>(<var>+Template,
211 <dt class="pubdef"><a name="findall/4"><strong>findall</strong>(<var>+Template,
253212 :Goal, -Bag, +Tail</var>)</a></dt>
254213 <dd class="defbody">
255 As <a id="idx:findall3:1364"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
214 As <a name="idx:findall3:1366"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
256215 but returns the result as the difference list
257216 <var>Bag</var>-<var>Tail</var>. The 3-argument version is defined as
258217
262221 </pre>
263222
264223 </dd>
265 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="findnsols/4"><strong>findnsols</strong>(<var>+N,
224 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="findnsols/4"><strong>findnsols</strong>(<var>+N,
266225 @Template, :Goal, -List</var>)</a></dt>
267 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="findnsols/5"><strong>findnsols</strong>(<var>+N,
226 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="findnsols/5"><strong>findnsols</strong>(<var>+N,
268227 @Template, :Goal, -List, ?Tail</var>)</a></dt>
269228 <dd class="defbody">
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>,
229 As <a name="idx:findall3:1367"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
230 and <a name="idx:findall4:1368"></a><a class="pred" href="allsolutions.html#findall/4">findall/4</a>,
272231 but generates at most <var>N</var> solutions. If
273232 <var>N</var> solutions are returned, this predicate succeeds with a
274233 choice point if <var>Goal</var> has a choice point. Backtracking returns
275234 the next chunk of (at most) <var>N</var> solutions. In addition to
276235 passing a plain integer for <var>N</var>, a term of the form <code>count(N)</code>
277236 is accepted. Using <code>count(N)</code>, the size of the next chunk can
278 be controlled using <a id="idx:nbsetarg3:1367"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
237 be controlled using <a name="idx:nbsetarg3:1369"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
279238 The non-deterministic behaviour used to implement the
280239 <em>chunk</em> option in <code>library(pengines)</code>. Based on Ciao,
281240 but the Ciao version is deterministic. Portability can be achieved by
282 wrapping the goal in <a id="idx:once1:1368"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
241 wrapping the goal in <a name="idx:once1:1370"></a><a class="pred" href="metacall.html#once/1">once/1</a>.
283242 Below are three examples. The first illustrates standard chunking of
284243 answers. The second illustrates that the chunk size can be adjusted
285244 dynamically and the last illustrates that no choice point is left if <var>Goal</var>
303262 </pre>
304263
305264 </dd>
306 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="bagof/3"><strong>bagof</strong>(<var>+Template,
265 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="bagof/3"><strong>bagof</strong>(<var>+Template,
307266 :Goal, -Bag</var>)</a></dt>
308267 <dd class="defbody">
309268 Unify <var>Bag</var> with the alternatives of <var>Template</var>. If <var>Goal</var>
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>
269 has free variables besides the one sharing with <var>Template</var>, <a name="idx:bagof3:1371"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
311270 will backtrack over the alternatives of these free variables, unifying
312271 <var>Bag</var> with the corresponding alternatives of <var>Template</var>.
313272 The construct <code>+<var>Var</var><code>^</code><var>Goal</var></code>
314 tells <a id="idx:bagof3:1370"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
273 tells <a name="idx:bagof3:1372"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
315274 not to bind
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>
275 <var>Var</var> in <var>Goal</var>. <a name="idx:bagof3:1373"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
317276 fails if <var>Goal</var> has no solutions.
318277
319 <p>The example below illustrates <a id="idx:bagof3:1372"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
278 <p>The example below illustrates <a name="idx:bagof3:1374"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>
320279 and the <strong><code>^</code></strong> operator. The variable bindings
321280 are printed together on one line to save paper.
322281
342301 </pre>
343302
344303 </dd>
345 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="setof/3"><strong>setof</strong>(<var>+Template,
304 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="setof/3"><strong>setof</strong>(<var>+Template,
346305 +Goal, -Set</var>)</a></dt>
347306 <dd class="defbody">
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>
307 Equivalent to <a name="idx:bagof3:1375"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
308 but sorts the result using <a name="idx:sort2:1376"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
350309 to get a sorted list of alternatives without duplicates.
351310 </dd>
352311 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="resmodules.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="dynamic-modules.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:altmoduleapi"><a id="sec:6.11"><span class="sec-nr">6.11</span> <span class="sec-title">An
194 <h2 id="sec:altmoduleapi"><a name="sec:6.11"><span class="sec-nr">6.11</span> <span class="sec-title">An
236195 alternative import/export interface</span></a></h2>
237196
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
197 <a name="sec:altmoduleapi"></a>
198
199 <p>The <a name="idx:usemodule1:1729"></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
245204 6.12</a>, this interface cannot be used. The interface below provides
246205 for import/export from modules that are not created using a module file.
247206
248207 <dl class="latex">
249 <dt class="pubdef"><a id="export/1"><strong>export</strong>(<var>+PredicateIndicator,
208 <dt class="pubdef"><a name="export/1"><strong>export</strong>(<var>+PredicateIndicator,
250209 ...</var>)</a></dt>
251210 <dd class="defbody">
252211 Add predicates to the public list of the context module. This implies
253212 the predicate will be imported into another module if this module is
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>
213 imported with <a name="idx:usemodule12:1730"></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:1731"></a><a class="pred" href="defmodule.html#module/2">module/2</a>. <a name="idx:export1:1732"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
256215 is meant to handle export from dynamically created modules.</dd>
257 <dt class="pubdef"><a id="import/1"><strong>import</strong>(<var>+PredicateIndicator,
216 <dt class="pubdef"><a name="import/1"><strong>import</strong>(<var>+PredicateIndicator,
258217 ...</var>)</a></dt>
259218 <dd class="defbody">
260219 Import predicates <var>PredicateIndicator</var> into the current context
261220 module. <var>PredicateIndicator</var> must specify the source module
262221 using the &lt;<var>module</var>&gt;:&lt;<var>pi</var>&gt; construct.
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>
222 Note that predicates are normally imported using one of the directives <a name="idx:usemodule12:1733"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
223 The <a name="idx:import1:1734"></a><a class="pred" href="altmoduleapi.html#import/1">import/1</a>
265224 alternative is meant for handling imports into dynamically created
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>.
225 modules. See also <a name="idx:export1:1735"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
226 and <a name="idx:exportlist2:1736"></a><span class="pred-ext">export_list/2</span>.
268227 </dd>
269228 </dl>
270229
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="manipstack.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="tracehook.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ancestral-cut"><a id="sec:B.2"><span class="sec-nr">B.2</span> <span class="sec-title">Ancestral
194 <h2 id="sec:ancestral-cut"><a name="sec:B.2"><span class="sec-nr">B.2</span> <span class="sec-title">Ancestral
236195 cuts</span></a></h2>
237196
238 <a id="sec:ancestral-cut"></a>
197 <a name="sec:ancestral-cut"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="prolog_cut_to/1"><strong>prolog_cut_to</strong>(<var>+Choice</var>)</a></dt>
200 <dt class="pubdef"><a name="prolog_cut_to/1"><strong>prolog_cut_to</strong>(<var>+Choice</var>)</a></dt>
242201 <dd class="defbody">
243202 Prunes all choice points created since <var>Choice</var>. Can be used
244 together with <a id="idx:prologcurrentchoice1:2191"></a><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a>
203 together with <a name="idx:prologcurrentchoice1:2190"></a><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a>
245204 to implement <em>ancestral</em> cuts. This predicate is in the hackers
246205 corner because it should not be used in normal Prolog code. It may be
247206 used to create new high level control structures, particularly for
251210 environment frames are <em>not</em> reclaimed. As a consequence, where
252211 predicates that are deterministic due to clause indexing, normal cuts or
253212 <code>(if\send{then};else)</code> and and tail recursive run in bounded
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>
213 local stack space, predicates using <a name="idx:prologcutto1:2191"></a><a class="pred" href="ancestral-cut.html#prolog_cut_to/1">prolog_cut_to/1</a>
255214 will run out of stack.
256215 </dd>
257216 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="aggregate.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="assoc.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:apply"><a id="sec:A.2"><span class="sec-nr">A.2</span> <span class="sec-title">library(apply):
194 <h2 id="sec:apply"><a name="sec:A.2"><span class="sec-nr">A.2</span> <span class="sec-title">library(apply):
236195 Apply predicates on a list</span></a></h2>
237196
238 <p><a id="sec:apply"></a>
197 <p><a name="sec:apply"></a>
239198
240199 <dl class="tags">
241200 <dt class="mtag">See also</dt>
254213 members of a list.
255214
256215 <dl class="latex">
257 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="include/3"><strong>include</strong>(<var>:Goal,
216 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="include/3"><strong>include</strong>(<var>:Goal,
258217 +List1, ?List2</var>)</a></dt>
259218 <dd class="defbody">
260219 Filter elements for which <var>Goal</var> succeeds. True if <var>List2</var>
270229 </dl>
271230
272231 </dd>
273 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="exclude/3"><strong>exclude</strong>(<var>:Goal,
232 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="exclude/3"><strong>exclude</strong>(<var>:Goal,
274233 +List1, ?List2</var>)</a></dt>
275234 <dd class="defbody">
276235 Filter elements for which <var>Goal</var> fails. True if <var>List2</var>
277236 contains those elements Xi of <var>List1</var> for which <code>call(Goal, Xi)</code>
278237 fails.</dd>
279 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="partition/4"><strong>partition</strong>(<var>:Pred,
238 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="partition/4"><strong>partition</strong>(<var>:Pred,
280239 +List, ?Included, ?Excluded</var>)</a></dt>
281240 <dd class="defbody">
282241 Filter elements of <var>List</var> according to <var>Pred</var>. True if <var>Included</var>
283242 contains all elements for which <code>call(Pred, X)</code> succeeds and
284243 <var>Excluded</var> contains the remaining elements.</dd>
285 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="partition/5"><strong>partition</strong>(<var>:Pred,
244 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="partition/5"><strong>partition</strong>(<var>:Pred,
286245 +List, ?Less, ?Equal, ?Greater</var>)</a></dt>
287246 <dd class="defbody">
288247 Filter <var>List</var> according to <var>Pred</var> in three sets. For
290249 where Place must be unified to one of <code>&lt;</code>, <code>=</code>
291250 or <code>&gt;</code>.
292251 <var>Pred</var> must be deterministic.</dd>
293 <dt class="pubdef"><a id="maplist/2"><strong>maplist</strong>(<var>:Goal,
252 <dt class="pubdef"><a name="maplist/2"><strong>maplist</strong>(<var>:Goal,
294253 ?List</var>)</a></dt>
295254 <dd class="defbody">
296255 True if <var>Goal</var> can successfully be applied on all elements of
297256 <var>List</var>. Arguments are reordered to gain performance as well as
298257 to make the predicate deterministic under normal circumstances.</dd>
299 <dt class="pubdef"><a id="maplist/3"><strong>maplist</strong>(<var>:Goal,
258 <dt class="pubdef"><a name="maplist/3"><strong>maplist</strong>(<var>:Goal,
300259 ?List1, ?List2</var>)</a></dt>
301260 <dd class="defbody">
302261 As <a class="pred" href="apply.html#maplist/2">maplist/2</a>, operating
303262 on pairs of elements from two lists.</dd>
304 <dt class="pubdef"><a id="maplist/4"><strong>maplist</strong>(<var>:Goal,
263 <dt class="pubdef"><a name="maplist/4"><strong>maplist</strong>(<var>:Goal,
305264 ?List1, ?List2, ?List3</var>)</a></dt>
306265 <dd class="defbody">
307266 As <a class="pred" href="apply.html#maplist/2">maplist/2</a>, operating
308267 on triples of elements from three lists.</dd>
309 <dt class="pubdef"><a id="maplist/5"><strong>maplist</strong>(<var>:Goal,
268 <dt class="pubdef"><a name="maplist/5"><strong>maplist</strong>(<var>:Goal,
310269 ?List1, ?List2, ?List3, ?List4</var>)</a></dt>
311270 <dd class="defbody">
312271 As <a class="pred" href="apply.html#maplist/2">maplist/2</a>, operating
313272 on quadruples of elements from four lists.</dd>
314 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="convlist/3"><strong>convlist</strong>(<var>:Goal,
273 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="convlist/3"><strong>convlist</strong>(<var>:Goal,
315274 +ListIn, -ListOut</var>)</a></dt>
316275 <dd class="defbody">
317276 Similar to <a class="pred" href="apply.html#maplist/3">maplist/3</a>,
333292 </dl>
334293
335294 </dd>
336 <dt class="pubdef"><a id="foldl/4"><strong>foldl</strong>(<var>:Goal,
295 <dt class="pubdef"><a name="foldl/4"><strong>foldl</strong>(<var>:Goal,
337296 +List, +V0, -V</var>)</a></dt>
338 <dt class="pubdef"><a id="foldl/5"><strong>foldl</strong>(<var>:Goal,
297 <dt class="pubdef"><a name="foldl/5"><strong>foldl</strong>(<var>:Goal,
339298 +List1, +List2, +V0, -V</var>)</a></dt>
340 <dt class="pubdef"><a id="foldl/6"><strong>foldl</strong>(<var>:Goal,
299 <dt class="pubdef"><a name="foldl/6"><strong>foldl</strong>(<var>:Goal,
341300 +List1, +List2, +List3, +V0, -V</var>)</a></dt>
342 <dt class="pubdef"><a id="foldl/7"><strong>foldl</strong>(<var>:Goal,
301 <dt class="pubdef"><a name="foldl/7"><strong>foldl</strong>(<var>:Goal,
343302 +List1, +List2, +List3, +List4, +V0, -V</var>)</a></dt>
344303 <dd class="defbody">
345304 Fold a list, using arguments of the list as left argument. The foldl
353312 </pre>
354313
355314 </dd>
356 <dt class="pubdef"><a id="scanl/4"><strong>scanl</strong>(<var>:Goal,
315 <dt class="pubdef"><a name="scanl/4"><strong>scanl</strong>(<var>:Goal,
357316 +List, +V0, -Values</var>)</a></dt>
358 <dt class="pubdef"><a id="scanl/5"><strong>scanl</strong>(<var>:Goal,
317 <dt class="pubdef"><a name="scanl/5"><strong>scanl</strong>(<var>:Goal,
359318 +List1, +List2, +V0, -Values</var>)</a></dt>
360 <dt class="pubdef"><a id="scanl/6"><strong>scanl</strong>(<var>:Goal,
319 <dt class="pubdef"><a name="scanl/6"><strong>scanl</strong>(<var>:Goal,
361320 +List1, +List2, +List3, +V0, -Values</var>)</a></dt>
362 <dt class="pubdef"><a id="scanl/7"><strong>scanl</strong>(<var>:Goal,
321 <dt class="pubdef"><a name="scanl/7"><strong>scanl</strong>(<var>:Goal,
363322 +List1, +List2, +List3, +List4, +V0, -Values</var>)</a></dt>
364323 <dd class="defbody">
365324 Left scan of list. The scanl family of higher order list operations is
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.27</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="charconv.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="miscarith.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>Arithmetic can be divided into some special purpose integer
240199 predicates and a series of general predicates for integer, floating
241200 point and rational arithmetic as appropriate. The general arithmetic
242201 predicates all handle <var>expressions</var>. An expression is either a
243202 simple number or a <var>function</var>. The arguments of a function are
244 expressions. The functions are described in <a class="sec" href="arith.html#sec:4.27.2.3">section
203 expressions. The functions are described in <a class="sec" href="arith.html">section
245204 4.27.2.3</a>.
246205
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
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
248207 purpose integer arithmetic</span></a></h3>
249208
250 <a id="sec:logic-int-arith"></a>
209 <a name="sec:logic-int-arith"></a>
251210
252211 <p>The predicates in this section provide more logical operations
253212 between integers. They are not covered by the ISO standard, although
255214 in many other Prolog systems.
256215
257216 <dl class="latex">
258 <dt class="pubdef"><a id="between/3"><strong>between</strong>(<var>+Low,
217 <dt class="pubdef"><a name="between/3"><strong>between</strong>(<var>+Low,
259218 +High, ?Value</var>)</a></dt>
260219 <dd class="defbody">
261220 <var>Low</var> and <var>High</var> are integers, <var><var>High</var> &gt;=<var>Low</var></var>.
264223 =&lt;<var>High</var></var>. When <var>Value</var> is a variable it is
265224 successively bound to all integers between <var>Low</var> and <var>High</var>.
266225 If <var>High</var> is <code>inf</code> or
267 <code>infinite</code><sup class="fn">106<span class="fn-text">We prefer <code>infinite</code>,
226 <code>infinite</code><sup class="fn">105<span class="fn-text">We prefer <code>infinite</code>,
268227 but some other Prolog systems already use <code>inf</code> for infinity;
269228 we accept both for the time being.</span></sup>
270 <a id="idx:between3:1321"></a><a class="pred" href="arith.html#between/3">between/3</a>
229 <a name="idx:between3:1323"></a><a class="pred" href="arith.html#between/3">between/3</a>
271230 is true iff <var><var>Value</var> &gt;=<var>Low</var></var>, a feature
272231 that is particularly interesting for generating integers from a certain
273232 value.</dd>
274 <dt class="pubdef"><a id="succ/2"><strong>succ</strong>(<var>?Int1,
233 <dt class="pubdef"><a name="succ/2"><strong>succ</strong>(<var>?Int1,
275234 ?Int2</var>)</a></dt>
276235 <dd class="defbody">
277236 True if <var><var>Int2</var> = <var>Int1</var> + 1</var> and <var><var>Int1</var>
278237 &gt;= 0</var>. At least one of the arguments must be instantiated to a
279238 natural number. This predicate raises the domain error <code>not_less_than_zero</code>
280239 if called with a negative integer. E.g. <code>succ(X, 0)</code> fails
281 silently and <code>succ(X, -1)</code> raises a domain error.<sup class="fn">107<span class="fn-text">The
240 silently and <code>succ(X, -1)</code> raises a domain error.<sup class="fn">106<span class="fn-text">The
282241 behaviour to deal with natural numbers only was defined by Richard
283242 O'Keefe to support the common count-down-to-zero in a natural way. Up to
284 5.1.8, <a id="idx:succ2:1322"></a><a class="pred" href="arith.html#succ/2">succ/2</a>
243 5.1.8, <a name="idx:succ2:1324"></a><a class="pred" href="arith.html#succ/2">succ/2</a>
285244 also accepted negative integers.</span></sup></dd>
286 <dt class="pubdef"><a id="plus/3"><strong>plus</strong>(<var>?Int1,
245 <dt class="pubdef"><a name="plus/3"><strong>plus</strong>(<var>?Int1,
287246 ?Int2, ?Int3</var>)</a></dt>
288247 <dd class="defbody">
289248 True if <var><var>Int3</var> = <var>Int1</var> + <var>Int2</var></var>.
290249 At least two of the three arguments must be instantiated to integers.</dd>
291 <dt class="pubdef"><a id="divmod/4"><strong>divmod</strong>(<var>+Dividend,
250 <dt class="pubdef"><a name="divmod/4"><strong>divmod</strong>(<var>+Dividend,
292251 +Divisor, -Quotient, -Remainder</var>)</a></dt>
293252 <dd class="defbody">
294253 This predicate is a shorthand for computing both the <var>Quotient</var>
297256 for exploiting the fact that the low level implementation for computing
298257 the quotient also produces the remainder. Timing confirms that this
299258 predicate is almost twice as fast as performing the steps independently.
300 Semantically, <a id="idx:divmod4:1323"></a><a class="pred" href="arith.html#divmod/4">divmod/4</a>
259 Semantically, <a name="idx:divmod4:1325"></a><a class="pred" href="arith.html#divmod/4">divmod/4</a>
301260 is defined as below.
302261
303262 <pre class="code">
309268 <p>Note that this predicate is only available if SWI-Prolog is compiled
310269 with unbounded integer support. This is the case for all packaged
311270 versions.</dd>
312 <dt class="pubdef"><a id="nth_integer_root_and_remainder/4"><strong>nth_integer_root_and_remainder</strong>(<var>+N,
271 <dt class="pubdef"><a name="nth_integer_root_and_remainder/4"><strong>nth_integer_root_and_remainder</strong>(<var>+N,
313272 +I, -Root, -Remainder</var>)</a></dt>
314273 <dd class="defbody">
315274 True when <var>Root ** N + Remainder = I</var>. <var>N</var> and <var>I</var>
316 must be integers.<sup class="fn">108<span class="fn-text">This predicate
275 must be integers.<sup class="fn">107<span class="fn-text">This predicate
317276 was suggested by Markus Triska. The final name and argument order is by
318277 Richard O'Keefe. The decision to include the remainder is by Jan
319278 Wielemaker. Including the remainder makes this predicate about twice as
337296 <p></dd>
338297 </dl>
339298
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
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
341300 purpose arithmetic</span></a></h3>
342301
343 <a id="sec:arithpreds"></a>
302 <a name="sec:arithpreds"></a>
344303
345304 <p>The general arithmetic predicates are optionally compiled (see
346 <a id="idx:setprologflag2:1324"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
305 <a name="idx:setprologflag2:1326"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
347306 and the <strong>-O</strong> command line option). Compiled arithmetic
348307 reduces global stack requirements and improves performance.
349308 Unfortunately compiled arithmetic cannot be traced, which is why it is
350309 optional.
351310
352311 <dl class="latex">
353 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id=">/2"><var>+Expr1</var> <strong>&gt;</strong> <var>+Expr2</var></a></dt>
312 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name=">/2"><var>+Expr1</var> <strong>&gt;</strong> <var>+Expr2</var></a></dt>
354313 <dd class="defbody">
355314 True if expression <var>Expr1</var> evaluates to a larger number than <var>Expr2</var>.</dd>
356 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="</2"><var>+Expr1</var> <strong>&lt;</strong> <var>+Expr2</var></a></dt>
315 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="</2"><var>+Expr1</var> <strong>&lt;</strong> <var>+Expr2</var></a></dt>
357316 <dd class="defbody">
358317 True if expression <var>Expr1</var> evaluates to a smaller number than <var>Expr2</var>.</dd>
359 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=</2"><var>+Expr1</var> <strong>=&lt;</strong> <var>+Expr2</var></a></dt>
318 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=</2"><var>+Expr1</var> <strong>=&lt;</strong> <var>+Expr2</var></a></dt>
360319 <dd class="defbody">
361320 True if expression <var>Expr1</var> evaluates to a smaller or equal
362321 number to <var>Expr2</var>.</dd>
363 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id=">=/2"><var>+Expr1</var> <strong>&gt;=</strong> <var>+Expr2</var></a></dt>
322 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name=">=/2"><var>+Expr1</var> <strong>&gt;=</strong> <var>+Expr2</var></a></dt>
364323 <dd class="defbody">
365324 True if expression <var>Expr1</var> evaluates to a larger or equal
366325 number to <var>Expr2</var>.</dd>
367 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=\=/2"><var>+Expr1</var> <strong>=\=</strong> <var>+Expr2</var></a></dt>
326 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=\=/2"><var>+Expr1</var> <strong>=\=</strong> <var>+Expr2</var></a></dt>
368327 <dd class="defbody">
369328 True if expression <var>Expr1</var> evaluates to a number non-equal to
370329 <var>Expr2</var>.</dd>
371 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=:=/2"><var>+Expr1</var> <strong>=:=</strong> <var>+Expr2</var></a></dt>
330 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=:=/2"><var>+Expr1</var> <strong>=:=</strong> <var>+Expr2</var></a></dt>
372331 <dd class="defbody">
373332 True if expression <var>Expr1</var> evaluates to a number equal to <var>
374333 Expr2</var>.</dd>
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>
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>
376335 <dd class="defbody">
377336 True when <var>Number</var> is the value to which <var>Expr</var>
378 evaluates. Typically, <a id="idx:is2:1325"></a><a class="pred" href="arith.html#is/2">is/2</a>
337 evaluates. Typically, <a name="idx:is2:1327"></a><a class="pred" href="arith.html#is/2">is/2</a>
379338 should be used with unbound left operand. If equality is to be tested, <a class="pred" href="arith.html#=:=/2">=:=/2</a>
380339 should be used. For example:
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>
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>
386346 </table>
347 </div>
387348 </dd>
388349 </dl>
389350
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
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
391352 types</span></a></h4>
392353
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
354 <a name="sec:artypes"></a>
355
356 <p><a name="idx:integerunbounded:1328"></a><a name="idx:rationalnumber:1329"></a><a name="idx:numberrational:1330"></a>SWI-Prolog
396357 defines the following numeric types:
397358
398359 <p>
399360 <ul class="latex">
400361 <li><i>integer</i><br>
401362 If SWI-Prolog is built using the <em>GNU multiple precision arithmetic
402 library</em> <a id="idx:GMP:1329"></a>(GMP), integer arithmetic is <em>unbounded</em>,
363 library</em> <a name="idx:GMP:1331"></a>(GMP), integer arithmetic is <em>unbounded</em>,
403364 which means that the size of integers is limited by available memory
404365 only. Without GMP, SWI-Prolog integers are 64-bits, regardless of the
405366 native integer size of the platform. The type of integer support can be
421382 arithmetic is only provided if GMP is used (see above). Rational numbers
422383 are currently not supported by a Prolog type. They are represented by
423384 the compound term <code>rdiv(N,M)</code>. Rational numbers that are
424 returned from <a id="idx:is2:1330"></a><a class="pred" href="arith.html#is/2">is/2</a>
385 returned from <a name="idx:is2:1332"></a><a class="pred" href="arith.html#is/2">is/2</a>
425386 are <em>canonical</em>, which means <var>M</var> is positive and <var>N</var>
426387 and
427388 <var>M</var> have no common divisors. Rational numbers are introduced in
429390 or the <a class="function" href="arith.html#f-rdiv/2">rdiv/2</a>
430391 (rational division) function. Using the same functor for rational
431392 division and for representing rational numbers allows for passing
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>
393 rational numbers between computations as well as for using <a name="idx:format3:1333"></a><a class="pred" href="format.html#format/3">format/3</a>
433394 for printing.
434395
435396 <p>In the long term, it is likely that rational numbers will become
436397 <em>atomic</em> as well as a subtype of <em>number</em>. User code that
437398 creates or inspects the <code>rdiv(M,N)</code> terms will not be
438399 portable to future versions. Rationals are created using one of the
439 functions mentioned above and inspected using <a id="idx:rational3:1332"></a><a class="pred" href="typetest.html#rational/3">rational/3</a>.
400 functions mentioned above and inspected using <a name="idx:rational3:1334"></a><a class="pred" href="typetest.html#rational/3">rational/3</a>.
440401
441402 <p>
442403 <li><i>float</i><br>
455416 floating point number
456417 </blockquote>
457418
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
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
459420 number examples</span></a></h4>
460421
461 <a id="sec:rational"></a>
422 <a name="sec:rational"></a>
462423
463424 <p>The use of rational numbers with unbounded integers allows for exact
464425 integer or <em>fixed point</em> arithmetic under addition, subtraction,
469430 on floats will convert a rational operand to float and continue the
470431 arithmetic using floating point numbers. Here are some examples.
471432
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>
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>
477438 </table>
478439
479440 <p>Note that floats cannot represent all decimal numbers exactly. The
484445 for details and examples.
485446
486447 <p>Rational numbers can be printed as decimal numbers with arbitrary
487 precision using the <a id="idx:format3:1333"></a><a class="pred" href="format.html#format/3">format/3</a>
448 precision using the <a name="idx:format3:1335"></a><a class="pred" href="format.html#format/3">format/3</a>
488449 floating point conversion:
489450
490451 <pre class="code">
495456 A = 17 rdiv 6
496457 </pre>
497458
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
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
499460 Functions</span></a></h4>
500461
501 <a id="sec:functions"></a>
462 <a name="sec:functions"></a>
502463
503464 <p>Arithmetic functions are terms which are evaluated by the arithmetic
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>
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>
516476 </table>
477 </div>
517478
518479 <p>For systems using bounded integer arithmetic (default is unbounded,
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.
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.
522483
523484 <p>SWI-Prolog provides many extensions to the set of floating point
524485 functions defined by the ISO standard. The current policy is to provide
525486 such functions on `as-needed' basis if the function is widely supported
526487 elsewhere and notably if it is part of the
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>.
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.
529491
530492 <dl class="latex">
531 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f--/1"><strong>-</strong> <var>+Expr</var></a></dt>
493 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f--/1"><strong>-</strong> <var>+Expr</var></a></dt>
532494 <dd class="defbody">
533495 <var><var>Result</var> = -<var>Expr</var></var></dd>
534 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-+/1"><strong>+</strong> <var>+Expr</var></a></dt>
496 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-+/1"><strong>+</strong> <var>+Expr</var></a></dt>
535497 <dd class="defbody">
536498 <var><var>Result</var> = <var>Expr</var></var>. Note that if <code><code>+</code></code>
537499 is followed by a number, the parser discards the <code><code>+</code></code>.
538500 I.e. <code>?- integer(+1)</code> succeeds.</dd>
539 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-+/2"><var>+Expr1</var> <strong>+</strong> <var>+Expr2</var></a></dt>
501 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-+/2"><var>+Expr1</var> <strong>+</strong> <var>+Expr2</var></a></dt>
540502 <dd class="defbody">
541503 <var><var>Result</var> = <var>Expr1</var> + <var>Expr2</var></var></dd>
542 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f--/2"><var>+Expr1</var> <strong>-</strong> <var>+Expr2</var></a></dt>
504 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f--/2"><var>+Expr1</var> <strong>-</strong> <var>+Expr2</var></a></dt>
543505 <dd class="defbody">
544506 <var><var>Result</var> = <var>Expr1</var> - <var>Expr2</var></var></dd>
545 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-*/2"><var>+Expr1</var> <strong>*</strong> <var>+Expr2</var></a></dt>
507 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-*/2"><var>+Expr1</var> <strong>*</strong> <var>+Expr2</var></a></dt>
546508 <dd class="defbody">
547509 <var><var>Result</var> = <var>Expr1</var> &times; <var>Expr2</var></var></dd>
548 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-//2"><var>+Expr1</var> <strong>/</strong> <var>+Expr2</var></a></dt>
510 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-//2"><var>+Expr1</var> <strong>/</strong> <var>+Expr2</var></a></dt>
549511 <dd class="defbody">
550512 <var><var>Result</var> = <var>Expr1</var>/<var>Expr2</var></var>. If the
551513 flag <a class="flag" href="flags.html#flag:iso">iso</a> is <code>true</code>,
556518 returns a rational number. In all other cases the return value is a
557519 float. See also <a class="function" href="arith.html#f-///2">///2</a>
558520 and <a class="function" href="arith.html#f-rdiv/2">rdiv/2</a>.</dd>
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>
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>
560522 <dd class="defbody">
561523 Modulo, defined as <var>Result</var> = <var>IntExpr1</var> - (<var>IntExpr1</var>
562524 div <var>IntExpr2</var>) <var> &times; </var> <var>IntExpr2</var>, where <code>div</code>
563525 is
564526 <em>floored</em> division.</dd>
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>
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>
566528 <dd class="defbody">
567529 Remainder of integer division. Behaves as if defined by
568530 <var>Result</var> is <var>IntExpr1</var> - (<var>IntExpr1</var> // <var>IntExpr2</var>) <var> &times; </var> <var>IntExpr2</var></dd>
569 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-///2"><var>+IntExpr1</var> <strong>//</strong> <var>+IntExpr2</var></a></dt>
531 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-///2"><var>+IntExpr1</var> <strong>//</strong> <var>+IntExpr2</var></a></dt>
570532 <dd class="defbody">
571533 Integer division, defined as <var>Result</var> is <var>rnd_I</var>(<var>Expr1</var>/<var>Expr2</var>)
572534 . The function <var>rnd_I</var> is the default rounding used by the C
573535 compiler and available through the Prolog flag
574536 <a class="flag" href="flags.html#flag:integer_rounding_function">integer_rounding_function</a>.
575 In the C99 standard, C-rounding is defined as <code>towards_zero</code>.<sup class="fn">109<span class="fn-text">Future
537 In the C99 standard, C-rounding is defined as <code>towards_zero</code>.<sup class="fn">108<span class="fn-text">Future
576538 versions might guarantee rounding towards zero.</span></sup></dd>
577 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-div/2"><strong>div</strong>(<var>+IntExpr1,
539 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-div/2"><strong>div</strong>(<var>+IntExpr1,
578540 +IntExpr2</var>)</a></dt>
579541 <dd class="defbody">
580542 Integer division, defined as <var>Result</var> is (<var>IntExpr1</var> - <var>IntExpr1</var> <var>mod</var> <var>IntExpr2</var>)
592554 </pre>
593555
594556 </dd>
595 <dt class="pubdef"><a id="f-rdiv/2"><var>+RatExpr</var> <strong>rdiv</strong> <var>+RatExpr</var></a></dt>
557 <dt class="pubdef"><a name="f-rdiv/2"><var>+RatExpr</var> <strong>rdiv</strong> <var>+RatExpr</var></a></dt>
596558 <dd class="defbody">
597559 Rational number division. This function is only available if SWI-Prolog
598560 has been compiled with rational number support. See
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>
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>
602563 <dd class="defbody">
603564 Result is the greatest common divisor of <var>IntExpr1</var>, <var>IntExpr2</var>.</dd>
604 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-abs/1"><strong>abs</strong>(<var>+Expr</var>)</a></dt>
565 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-abs/1"><strong>abs</strong>(<var>+Expr</var>)</a></dt>
605566 <dd class="defbody">
606567 Evaluate <var>Expr</var> and return the absolute value of it.</dd>
607 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-sign/1"><strong>sign</strong>(<var>+Expr</var>)</a></dt>
568 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-sign/1"><strong>sign</strong>(<var>+Expr</var>)</a></dt>
608569 <dd class="defbody">
609570 Evaluate to -1 if <var><var>Expr</var> &lt; 0</var>, 1 if <var><var>Expr</var>
610571 &gt; 0</var> and 0 if
611572 <var><var>Expr</var> = 0</var>. If <var>Expr</var> evaluates to a float,
612573 the return value is a float (e.g., -1.0, 0.0 or 1.0). In particular,
613574 note that sign(-0.0) evaluates to 0.0. See also <a class="function" href="arith.html#f-copysign/2">copysign/2</a></dd>
614 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-copysign/2"><strong>copysign</strong>(<var>+Expr1,
575 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-copysign/2"><strong>copysign</strong>(<var>+Expr1,
615576 +Expr2</var>)</a></dt>
616577 <dd class="defbody">
617578 Evaluate to <var>X</var>, where the absolute value of <var>X</var>
624585 -<var>Expr1</var> if the signs do not match. Here, we use the extended
625586 notion of signs for floating point numbers, where the sign of -0.0 and
626587 other special floats is negative.</dd>
627 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-max/2"><strong>max</strong>(<var>+Expr1,
588 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-max/2"><strong>max</strong>(<var>+Expr1,
628589 +Expr2</var>)</a></dt>
629590 <dd class="defbody">
630591 Evaluate to the larger of <var>Expr1</var> and <var>Expr2</var>. Both
631592 arguments are compared after converting to the same type, but the return
632593 value is in the original type. For example, max(2.5, 3) compares the two
633594 values after converting to float, but returns the integer 3.</dd>
634 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-min/2"><strong>min</strong>(<var>+Expr1,
595 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-min/2"><strong>min</strong>(<var>+Expr1,
635596 +Expr2</var>)</a></dt>
636597 <dd class="defbody">
637598 Evaluate to the smaller of <var>Expr1</var> and <var>Expr2</var>. See
638599 <a class="function" href="arith.html#f-max/2">max/2</a> for a
639600 description of type handling.</dd>
640 <dt class="pubdef"><a id="f-./2"><strong>.</strong>(<var>+Int,[]</var>)</a></dt>
601 <dt class="pubdef"><a name="f-./2"><strong>.</strong>(<var>+Int,[]</var>)</a></dt>
641602 <dd class="defbody">
642603 A list of one element evaluates to the element. This implies <code>"a"</code>
643604 evaluates to the character code of the letter `a' (97) using the
644605 traditional mapping of double quoted string to a list of character
645606 codes. Arithmetic evaluation also translates a string object (see
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>
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>
649610 is set to <code>string</code>. The recommended way to specify the
650611 character code of the letter `a' is
651612 <code>0'a</code>.</dd>
652 <dt class="pubdef"><a id="f-random/1"><strong>random</strong>(<var>+IntExpr</var>)</a></dt>
613 <dt class="pubdef"><a name="f-random/1"><strong>random</strong>(<var>+IntExpr</var>)</a></dt>
653614 <dd class="defbody">
654615 Evaluate to a random integer <var>i</var> for which <var>0 =&lt; i &lt; <var>IntExpr</var></var>.
655616 The system has two implementations. If it is compiled with support for
657618 In this case, each thread keeps its own random state. The default
658619 algorithm is the <em>Mersenne Twister</em> algorithm. The seed is set
659620 when the first random number in a thread is generated. If available, it
660 is set from <code>/dev/random</code>.<sup class="fn">110<span class="fn-text">On
621 is set from <code>/dev/random</code>.<sup class="fn">109<span class="fn-text">On
661622 Windows the state is initialised from CryptGenRandom().</span></sup>
662623 Otherwise it is set from the system clock. If unbounded arithmetic is
663624 not supported, random numbers are shared between threads and the seed is
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>
625 initialised from the clock when SWI-Prolog was started. The predicate <a name="idx:setrandom1:1336"></a><a class="pred" href="miscarith.html#set_random/1">set_random/1</a>
665626 can be used to control the random number generator.
666627
667628 <p><b>Warning!</b> Although properly seeded (if supported on the OS),
668629 the Mersenne Twister algorithm does <em>not</em> produce
669630 cryptographically secure random numbers. To generate cryptographically
670 secure random numbers, use <a id="idx:cryptonrandombytes2:1335"></a><span class="pred-ext">crypto_n_random_bytes/2</span>
631 secure random numbers, use <a name="idx:cryptonrandombytes2:1337"></a><span class="pred-ext">crypto_n_random_bytes/2</span>
671632 from library <code>library(crypto)</code> provided by the <code>ssl</code>
672633 package.</dd>
673 <dt class="pubdef"><a id="f-random_float/0"><strong>random_float</strong></a></dt>
634 <dt class="pubdef"><a name="f-random_float/0"><strong>random_float</strong></a></dt>
674635 <dd class="defbody">
675636 Evaluate to a random float <var>I</var> for which <var>0.0 &lt; i &lt;
676637 1.0</var>. This function shares the random state with <a class="function" href="arith.html#f-random/1">random/1</a>.
679640 Note that both sides of the domain are <em>open</em>. This avoids
680641 evaluation errors on, e.g., <a class="function" href="arith.html#f-log/1">log/1</a>
681642 or <a class="function" href="arith.html#f-//2">//2</a> while no
682 practical application can expect 0.0.<sup class="fn">111<span class="fn-text">Richard
643 practical application can expect 0.0.<sup class="fn">110<span class="fn-text">Richard
683644 O'Keefe said: ``If you <em>are</em> generating IEEE doubles with the
684645 claimed uniformity, then 0 has a 1 in <var>2^53 = 1 in
685646 9,007,199,254,740,992</var> chance of turning up. No program that
686647 expects [0.0,1.0) is going to be surprised when 0.0 fails to turn up in
687648 a few millions of millions of trials, now is it? But a program that
688649 expects (0.0,1.0) could be devastated if 0.0 did turn up.''</span></sup></dd>
689 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-round/1"><strong>round</strong>(<var>+Expr</var>)</a></dt>
650 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-round/1"><strong>round</strong>(<var>+Expr</var>)</a></dt>
690651 <dd class="defbody">
691652 Evaluate <var>Expr</var> and round the result to the nearest integer.
692653 According to ISO, <a class="function" href="arith.html#f-round/1">round/1</a>
696657 <code>round(Expr) == -round(-Expr)</code> does not hold. SWI-Prolog
697658 rounds <em>outward</em>, e.g., <code>round(1.5) =:= 2</code> and round
698659 <code>round(-1.5) =:= -2</code>.</dd>
699 <dt class="pubdef"><a id="f-integer/1"><strong>integer</strong>(<var>+Expr</var>)</a></dt>
660 <dt class="pubdef"><a name="f-integer/1"><strong>integer</strong>(<var>+Expr</var>)</a></dt>
700661 <dd class="defbody">
701662 Same as <a class="function" href="arith.html#f-round/1">round/1</a>
702663 (backward compatibility).</dd>
703 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-float/1"><strong>float</strong>(<var>+Expr</var>)</a></dt>
664 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-float/1"><strong>float</strong>(<var>+Expr</var>)</a></dt>
704665 <dd class="defbody">
705666 Translate the result to a floating point number. Normally, Prolog will
706667 use integers whenever possible. When used around the 2nd argument of
707 <a id="idx:is2:1336"></a><a class="pred" href="arith.html#is/2">is/2</a>,
668 <a name="idx:is2:1338"></a><a class="pred" href="arith.html#is/2">is/2</a>,
708669 the result will be returned as a floating point number. In other
709670 contexts, the operation has no effect.</dd>
710 <dt class="pubdef"><a id="f-rational/1"><strong>rational</strong>(<var>+Expr</var>)</a></dt>
671 <dt class="pubdef"><a name="f-rational/1"><strong>rational</strong>(<var>+Expr</var>)</a></dt>
711672 <dd class="defbody">
712673 Convert the <var>Expr</var> to a rational number or integer. The
713674 function returns the input on integers and rational numbers. For
716677 numbers the results may be surprising. In the examples below, doubles
717678 can represent 0.25 and the result is as expected, in contrast to the
718679 result of <code>rational(0.1)</code>. The function <a class="function" href="arith.html#f-rationalize/1">rationalize/1</a>
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.
680 remedies this. See <a class="sec" href="arith.html">section 4.27.2.2</a>
681 for more information on rational number support.
721682
722683 <pre class="code">
723684 ?- A is rational(0.25).
728689 </pre>
729690
730691 </dd>
731 <dt class="pubdef"><a id="f-rationalize/1"><strong>rationalize</strong>(<var>+Expr</var>)</a></dt>
692 <dt class="pubdef"><a name="f-rationalize/1"><strong>rationalize</strong>(<var>+Expr</var>)</a></dt>
732693 <dd class="defbody">
733694 Convert the <var>Expr</var> to a rational number or integer. The
734695 function is similar to <a class="function" href="arith.html#f-rational/1">rational/1</a>,
735696 but the result is only accurate within the rounding error of floating
736 point numbers, generally producing a much smaller denominator.<sup class="fn">112<span class="fn-text">The
697 point numbers, generally producing a much smaller denominator.<sup class="fn">111<span class="fn-text">The
737698 names <a class="function" href="arith.html#f-rational/1">rational/1</a>
738699 and <a class="function" href="arith.html#f-rationalize/1">rationalize/1</a>
739700 as well as their semantics are inspired by Common Lisp.</span></sup>
748709 </pre>
749710
750711 </dd>
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>
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>
752713 <dd class="defbody">
753714 Fractional part of a floating point number. Negative if <var>Expr</var>
754715 is negative, rational if <var>Expr</var> is rational and 0 if <var>Expr</var>
755716 is integer. The following relation is always true:
756717 <var>X is float_fractional_part(X) + float_integer_part(X)</var>.</dd>
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>
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>
758719 <dd class="defbody">
759720 Integer part of floating point number. Negative if <var>Expr</var> is
760721 negative, <var>Expr</var> if <var>Expr</var> is integer.</dd>
761 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-truncate/1"><strong>truncate</strong>(<var>+Expr</var>)</a></dt>
722 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-truncate/1"><strong>truncate</strong>(<var>+Expr</var>)</a></dt>
762723 <dd class="defbody">
763724 Truncate <var>Expr</var> to an integer. If <var><var>Expr</var> &gt;= 0</var>
764725 this is the same as <code>floor(Expr)</code>. For <var><var>Expr</var> &lt;
765726 0</var> this is the same as
766 <code>ceil(Expr)</code>. That is, <a id="idx:truncate1:1337"></a><span class="pred-ext">truncate/1</span>
727 <code>ceil(Expr)</code>. That is, <a name="idx:truncate1:1339"></a><span class="pred-ext">truncate/1</span>
767728 rounds towards zero.</dd>
768 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-floor/1"><strong>floor</strong>(<var>+Expr</var>)</a></dt>
729 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-floor/1"><strong>floor</strong>(<var>+Expr</var>)</a></dt>
769730 <dd class="defbody">
770731 Evaluate <var>Expr</var> and return the largest integer smaller or equal
771732 to the result of the evaluation.</dd>
772 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-ceiling/1"><strong>ceiling</strong>(<var>+Expr</var>)</a></dt>
733 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-ceiling/1"><strong>ceiling</strong>(<var>+Expr</var>)</a></dt>
773734 <dd class="defbody">
774735 Evaluate <var>Expr</var> and return the smallest integer larger or equal
775736 to the result of the evaluation.</dd>
776 <dt class="pubdef"><a id="f-ceil/1"><strong>ceil</strong>(<var>+Expr</var>)</a></dt>
737 <dt class="pubdef"><a name="f-ceil/1"><strong>ceil</strong>(<var>+Expr</var>)</a></dt>
777738 <dd class="defbody">
778739 Same as <a class="function" href="arith.html#f-ceiling/1">ceiling/1</a>
779740 (backward compatibility).</dd>
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>
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>
781742 <dd class="defbody">
782743 Bitwise shift <var>IntExpr1</var> by <var>IntExpr2</var> bits to the
783744 right. The operation performs <em>arithmetic shift</em>, which implies
784745 that the inserted most significant bits are copies of the original most
785746 significant bits.</dd>
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>
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>
787748 <dd class="defbody">
788749 Bitwise shift <var>IntExpr1</var> by <var>IntExpr2</var> bits to the
789750 left.</dd>
790 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-\//2"><var>+IntExpr1</var> <strong>\/</strong> <var>+IntExpr2</var></a></dt>
751 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-\//2"><var>+IntExpr1</var> <strong>\/</strong> <var>+IntExpr2</var></a></dt>
791752 <dd class="defbody">
792753 Bitwise `or' <var>IntExpr1</var> and <var>IntExpr2</var>.</dd>
793 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-/\/2"><var>+IntExpr1</var> <strong>/\</strong> <var>+IntExpr2</var></a></dt>
754 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-/\/2"><var>+IntExpr1</var> <strong>/\</strong> <var>+IntExpr2</var></a></dt>
794755 <dd class="defbody">
795756 Bitwise `and' <var>IntExpr1</var> and <var>IntExpr2</var>.</dd>
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>
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>
797758 <dd class="defbody">
798759 Bitwise `exclusive or' <var>IntExpr1</var> and <var>IntExpr2</var>.</dd>
799 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-\/1"><strong>\</strong> <var>+IntExpr</var></a></dt>
760 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-\/1"><strong>\</strong> <var>+IntExpr</var></a></dt>
800761 <dd class="defbody">
801762 Bitwise negation. The returned value is the one's complement of
802763 <var>IntExpr</var>.</dd>
803 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-sqrt/1"><strong>sqrt</strong>(<var>+Expr</var>)</a></dt>
764 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-sqrt/1"><strong>sqrt</strong>(<var>+Expr</var>)</a></dt>
804765 <dd class="defbody">
805766 <var><var>Result</var> = sqrt(<var>Expr</var>)</var>
806767 </dd>
807 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-sin/1"><strong>sin</strong>(<var>+Expr</var>)</a></dt>
768 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-sin/1"><strong>sin</strong>(<var>+Expr</var>)</a></dt>
808769 <dd class="defbody">
809770 <var><var>Result</var> = sin(<var>Expr</var>)</var>. <var>Expr</var> is
810771 the angle in radians.
811772 </dd>
812 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-cos/1"><strong>cos</strong>(<var>+Expr</var>)</a></dt>
773 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-cos/1"><strong>cos</strong>(<var>+Expr</var>)</a></dt>
813774 <dd class="defbody">
814775 <var><var>Result</var> = cos(<var>Expr</var>)</var>. <var>Expr</var> is
815776 the angle in radians.
816777 </dd>
817 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-tan/1"><strong>tan</strong>(<var>+Expr</var>)</a></dt>
778 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-tan/1"><strong>tan</strong>(<var>+Expr</var>)</a></dt>
818779 <dd class="defbody">
819780 <var><var>Result</var> = tan(<var>Expr</var>)</var>. <var>Expr</var> is
820781 the angle in radians.
821782 </dd>
822 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-asin/1"><strong>asin</strong>(<var>+Expr</var>)</a></dt>
783 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-asin/1"><strong>asin</strong>(<var>+Expr</var>)</a></dt>
823784 <dd class="defbody">
824785 <var><var>Result</var> = arcsin(<var>Expr</var>)</var>. <var>Result</var>
825786 is the angle in radians.
826787 </dd>
827 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-acos/1"><strong>acos</strong>(<var>+Expr</var>)</a></dt>
788 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-acos/1"><strong>acos</strong>(<var>+Expr</var>)</a></dt>
828789 <dd class="defbody">
829790 <var><var>Result</var> = arccos(<var>Expr</var>)</var>. <var>Result</var>
830791 is the angle in radians.
831792 </dd>
832 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-atan/1"><strong>atan</strong>(<var>+Expr</var>)</a></dt>
793 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-atan/1"><strong>atan</strong>(<var>+Expr</var>)</a></dt>
833794 <dd class="defbody">
834795 <var><var>Result</var> = arctan(<var>Expr</var>)</var>. <var>Result</var>
835796 is the angle in radians.
836797 </dd>
837 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-atan2/2"><strong>atan2</strong>(<var>+YExpr,
798 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-atan2/2"><strong>atan2</strong>(<var>+YExpr,
838799 +XExpr</var>)</a></dt>
839800 <dd class="defbody">
840801 <var><var>Result</var> = arctan(<var>YExpr</var>/<var>XExpr</var>)</var>. <var>Result</var>
846807 to raise an evaluation error, whereas the C99 and POSIX standards demand
847808 this to evaluate to 0.0. SWI-Prolog follows C99 and POSIX.
848809 </dd>
849 <dt class="pubdef"><a id="f-atan/2"><strong>atan</strong>(<var>+YExpr,
810 <dt class="pubdef"><a name="f-atan/2"><strong>atan</strong>(<var>+YExpr,
850811 +XExpr</var>)</a></dt>
851812 <dd class="defbody">
852813 Same as <a class="function" href="arith.html#f-atan2/2">atan2/2</a>
853814 (backward compatibility).</dd>
854 <dt class="pubdef"><a id="f-sinh/1"><strong>sinh</strong>(<var>+Expr</var>)</a></dt>
815 <dt class="pubdef"><a name="f-sinh/1"><strong>sinh</strong>(<var>+Expr</var>)</a></dt>
855816 <dd class="defbody">
856817 <var><var>Result</var> = sinh(<var>Expr</var>)</var>. The hyperbolic
857818 sine of <var>X</var> is defined as <var>e ** X - e ** -X / 2</var>.
858819 </dd>
859 <dt class="pubdef"><a id="f-cosh/1"><strong>cosh</strong>(<var>+Expr</var>)</a></dt>
820 <dt class="pubdef"><a name="f-cosh/1"><strong>cosh</strong>(<var>+Expr</var>)</a></dt>
860821 <dd class="defbody">
861822 <var><var>Result</var> = cosh(<var>Expr</var>)</var>. The hyperbolic
862823 cosine of <var>X</var> is defined as <var>e ** X + e ** -X / 2</var>.
863824 </dd>
864 <dt class="pubdef"><a id="f-tanh/1"><strong>tanh</strong>(<var>+Expr</var>)</a></dt>
825 <dt class="pubdef"><a name="f-tanh/1"><strong>tanh</strong>(<var>+Expr</var>)</a></dt>
865826 <dd class="defbody">
866827 <var><var>Result</var> = tanh(<var>Expr</var>)</var>. The hyperbolic
867828 tangent of <var>X</var> is defined as <var>sinh( X ) / cosh( X )</var>.</dd>
868 <dt class="pubdef"><a id="f-asinh/1"><strong>asinh</strong>(<var>+Expr</var>)</a></dt>
829 <dt class="pubdef"><a name="f-asinh/1"><strong>asinh</strong>(<var>+Expr</var>)</a></dt>
869830 <dd class="defbody">
870831 <var><var>Result</var> = arcsinh(<var>Expr</var>)</var> (inverse
871832 hyperbolic sine).
872833 </dd>
873 <dt class="pubdef"><a id="f-acosh/1"><strong>acosh</strong>(<var>+Expr</var>)</a></dt>
834 <dt class="pubdef"><a name="f-acosh/1"><strong>acosh</strong>(<var>+Expr</var>)</a></dt>
874835 <dd class="defbody">
875836 <var><var>Result</var> = arccosh(<var>Expr</var>)</var> (inverse
876837 hyperbolic cosine).
877838 </dd>
878 <dt class="pubdef"><a id="f-atanh/1"><strong>atanh</strong>(<var>+Expr</var>)</a></dt>
839 <dt class="pubdef"><a name="f-atanh/1"><strong>atanh</strong>(<var>+Expr</var>)</a></dt>
879840 <dd class="defbody">
880841 <var><var>Result</var> = arctanh(<var>Expr</var>)</var>. (inverse
881842 hyperbolic tangent).</dd>
882 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-log/1"><strong>log</strong>(<var>+Expr</var>)</a></dt>
843 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-log/1"><strong>log</strong>(<var>+Expr</var>)</a></dt>
883844 <dd class="defbody">
884845 Natural logarithm. <var><var>Result</var> = ln(<var>Expr</var>)</var>
885846 </dd>
886 <dt class="pubdef"><a id="f-log10/1"><strong>log10</strong>(<var>+Expr</var>)</a></dt>
847 <dt class="pubdef"><a name="f-log10/1"><strong>log10</strong>(<var>+Expr</var>)</a></dt>
887848 <dd class="defbody">
888849 Base-10 logarithm. <var><var>Result</var> = log10(<var>Expr</var>)</var>
889850 </dd>
890 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-exp/1"><strong>exp</strong>(<var>+Expr</var>)</a></dt>
851 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-exp/1"><strong>exp</strong>(<var>+Expr</var>)</a></dt>
891852 <dd class="defbody">
892853 <var><var>Result</var> = e **<var>Expr</var></var></dd>
893 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-**/2"><var>+Expr1</var> <strong>**</strong> <var>+Expr2</var></a></dt>
854 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-**/2"><var>+Expr1</var> <strong>**</strong> <var>+Expr2</var></a></dt>
894855 <dd class="defbody">
895856 <var><var>Result</var> = <var>Expr1</var>**<var>Expr2</var></var>. The
896857 result is a float, unless SWI-Prolog is compiled with unbounded integer
908869 casting the <em>input</em> result in a floating point computation, while
909870 casting the <em>output</em> performs integer exponentiation followed by
910871 a conversion to float.</dd>
911 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="f-^/2"><var>+Expr1</var> <strong>^</strong> <var>+Expr2</var></a></dt>
872 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="f-^/2"><var>+Expr1</var> <strong>^</strong> <var>+Expr2</var></a></dt>
912873 <dd class="defbody">
913874 In SWI-Prolog, <a class="function" href="arith.html#f-^/2">^/2</a> is
914875 equivalent to <a class="function" href="arith.html#f-**/2">**/2</a>. The
918879 an integer. The table below illustrates the behaviour of the
919880 exponentiation functions in ISO and SWI.
920881
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
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
924886 or Float</td><td>Float </td></tr>
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
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
930893 or Float</td><td>Int or error </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>
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>
935898 </table>
936899 </dd>
937 <dt class="pubdef"><a id="f-powm/3"><strong>powm</strong>(<var>+IntExprBase,
900 <dt class="pubdef"><a name="f-powm/3"><strong>powm</strong>(<var>+IntExprBase,
938901 +IntExprExp, +IntExprMod</var>)</a></dt>
939902 <dd class="defbody">
940903 <var><var>Result</var> = (<var>IntExprBase</var>**<var>IntExprExp</var>)
943906 key-exchange, a technique where two parties can establish a secret key
944907 over a public network.
945908 <var>IntExprBase</var> and <var>IntExprExp</var> must be non-negative (<var>&gt;=0</var>),
946 <var>IntExprMod</var> must be positive (<var>&gt;0</var>).<sup class="fn">113<span class="fn-text">The
909 <var>IntExprMod</var> must be positive (<var>&gt;0</var>).<sup class="fn">112<span class="fn-text">The
947910 underlying GMP mpz_powm() function allows negative values under some
948911 conditions. As the conditions are expensive to pre-compute, error
949912 handling from GMP is non-trivial and negative values are not needed for
950913 Diffie-Hellman key-exchange we do not support these.</span></sup></dd>
951 <dt class="pubdef"><a id="f-lgamma/1"><strong>lgamma</strong>(<var>+Expr</var>)</a></dt>
914 <dt class="pubdef"><a name="f-lgamma/1"><strong>lgamma</strong>(<var>+Expr</var>)</a></dt>
952915 <dd class="defbody">
953916 Return the natural logarithm of the absolute value of the Gamma
954 function.<sup class="fn">114<span class="fn-text">Some interfaces also
917 function.<sup class="fn">113<span class="fn-text">Some interfaces also
955918 provide the sign of the Gamma function. We canot do that in an
956919 arithmetic function. Future versions may provide a <em>predicate</em>
957920 lgamma/3 that returns both the value and the sign.</span></sup></dd>
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>
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>
969932 <dd class="defbody">
970933 Evaluate to the mathematical constant <var>pi</var> (3.14159 ... ).
971934 </dd>
972 <dt class="pubdef"><a id="f-e/0"><strong>e</strong></a></dt>
935 <dt class="pubdef"><a name="f-e/0"><strong>e</strong></a></dt>
973936 <dd class="defbody">
974937 Evaluate to the mathematical constant <var>e</var> (2.71828 ... ).
975938 </dd>
976 <dt class="pubdef"><a id="f-epsilon/0"><strong>epsilon</strong></a></dt>
939 <dt class="pubdef"><a name="f-epsilon/0"><strong>epsilon</strong></a></dt>
977940 <dd class="defbody">
978941 Evaluate to the difference between the float 1.0 and the first larger
979942 floating point number.
980943 </dd>
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
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
984947 2.16.1.6</a>. This value can be negated using <a class="function" href="arith.html#f--/1">-/1</a>.
985948 </dd>
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
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
989952 2.16.1.6</a>.
990953 </dd>
991 <dt class="pubdef"><a id="f-cputime/0"><strong>cputime</strong></a></dt>
954 <dt class="pubdef"><a name="f-cputime/0"><strong>cputime</strong></a></dt>
992955 <dd class="defbody">
993956 Evaluate to a floating point number expressing the <span style="font-variant:small-caps">CPU</span>
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>
957 time (in seconds) used by Prolog up till now. See also <a name="idx:statistics2:1340"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>
958 and <a name="idx:time1:1341"></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>
997960 <dd class="defbody">
998961 Evaluate <var>Expr</var>. Although ISO standard dictates that `<var>A</var>=1+2, <var>B</var>
999962 is
1000963 <var>A</var>' works and unifies <var>B</var> to 3, it is widely felt
1001964 that source level variables in arithmetic expressions should have been
1002965 limited to numbers. In this view the eval function can be used to
1003 evaluate arbitrary expressions.<sup class="fn">115<span class="fn-text">The <a class="function" href="arith.html#f-eval/1">eval/1</a>
966 evaluate arbitrary expressions.<sup class="fn">114<span class="fn-text">The <a class="function" href="arith.html#f-eval/1">eval/1</a>
1004967 function was first introduced by ECLiPSe and is under consideration for
1005968 YAP.</span></sup>
1006969 </dd>
1017980 bit-vectors.
1018981
1019982 <dl class="latex">
1020 <dt class="pubdef"><a id="f-msb/1"><strong>msb</strong>(<var>+IntExpr</var>)</a></dt>
983 <dt class="pubdef"><a name="f-msb/1"><strong>msb</strong>(<var>+IntExpr</var>)</a></dt>
1021984 <dd class="defbody">
1022985 Return the largest integer <var>N</var> such that <code>(IntExpr &gt;&gt; N) /\ 1 =:= 1</code>.
1023986 This is the (zero-origin) index of the most significant 1 bit in the
1024987 value of <var>IntExpr</var>, which must evaluate to a positive integer.
1025988 Errors for 0, negative integers, and non-integers.</dd>
1026 <dt class="pubdef"><a id="f-lsb/1"><strong>lsb</strong>(<var>+IntExpr</var>)</a></dt>
989 <dt class="pubdef"><a name="f-lsb/1"><strong>lsb</strong>(<var>+IntExpr</var>)</a></dt>
1027990 <dd class="defbody">
1028991 Return the smallest integer <var>N</var> such that <code>(IntExpr &gt;&gt; N) /\ 1 =:= 1</code>.
1029992 This is the (zero-origin) index of the least significant 1 bit in the
1030993 value of <var>IntExpr</var>, which must evaluate to a positive integer.
1031994 Errors for 0, negative integers, and non-integers.</dd>
1032 <dt class="pubdef"><a id="f-popcount/1"><strong>popcount</strong>(<var>+IntExpr</var>)</a></dt>
995 <dt class="pubdef"><a name="f-popcount/1"><strong>popcount</strong>(<var>+IntExpr</var>)</a></dt>
1033996 <dd class="defbody">
1034997 Return the number of 1s in the binary representation of the non-negative
1035998 integer <var>IntExpr</var>.</dd>
1036 <dt class="pubdef"><a id="f-getbit/2"><strong>getbit</strong>(<var>+IntExprV,
999 <dt class="pubdef"><a name="f-getbit/2"><strong>getbit</strong>(<var>+IntExprV,
10371000 +IntExprI</var>)</a></dt>
10381001 <dd class="defbody">
10391002 Evaluates to the bit value (0 or 1) of the <var>IntExprI</var>-th bit of
10421005 but more efficient because materialization of the shifted value is
10431006 avoided. Future versions will optimise <code>(IntExprV &gt;&gt; IntExprI)/\1</code>
10441007 to a call to <a class="function" href="arith.html#f-getbit/2">getbit/2</a>,
1045 providing both portability and performance.<sup class="fn">116<span class="fn-text">This
1008 providing both portability and performance.<sup class="fn">115<span class="fn-text">This
10461009 issue was fiercely debated at the ISO standard mailinglist. The name <i>getbit</i>
10471010 was selected for compatibility with ECLiPSe, the only system providing
10481011 this support. Richard O'Keefe disliked the name and argued that
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="apply.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="broadcast.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:assoc"><a id="sec:A.3"><span class="sec-nr">A.3</span> <span class="sec-title">library(assoc):
194 <h2 id="sec:assoc"><a name="sec:A.3"><span class="sec-nr">A.3</span> <span class="sec-title">library(assoc):
236195 Association lists</span></a></h2>
237196
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>
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>
247206
248207 <p>An <i>association list</i> as implemented by this library is a
249208 collection of unique <i>keys</i> that are associated to <i>values</i>.
280239 arrays efficiently.
281240 </ul>
282241
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
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
284243 association lists</span></a></h3>
285244
286 <p><a id="sec:assoc-creation"></a>
245 <p><a name="sec:assoc-creation"></a>
287246
288247 <p>An assocation list is <i>created</i> with one of the following
289248 predicates:
290249
291250 <dl class="latex">
292 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="empty_assoc/1"><strong>empty_assoc</strong>(<var>?Assoc</var>)</a></dt>
251 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="empty_assoc/1"><strong>empty_assoc</strong>(<var>?Assoc</var>)</a></dt>
293252 <dd class="defbody">
294253 Is true if <var>Assoc</var> is the empty association list.</dd>
295 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_to_assoc/2"><strong>list_to_assoc</strong>(<var>+Pairs,
254 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_to_assoc/2"><strong>list_to_assoc</strong>(<var>+Pairs,
296255 -Assoc</var>)</a></dt>
297256 <dd class="defbody">
298257 Create an association from a list <var>Pairs</var> of Key-Value pairs.
307266 </dl>
308267
309268 </dd>
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,
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,
311270 -Assoc</var>)</a></dt>
312271 <dd class="defbody">
313272 <var>Assoc</var> is created from an ordered list <var>Pairs</var> of
325284 </dd>
326285 </dl>
327286
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
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
329288 association lists</span></a></h3>
330289
331 <p><a id="sec:assoc-querying"></a>
290 <p><a name="sec:assoc-querying"></a>
332291
333292 <p>An association list can be <i>queried</i> with:
334293
335294 <dl class="latex">
336 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="get_assoc/3"><strong>get_assoc</strong>(<var>+Key,
295 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="get_assoc/3"><strong>get_assoc</strong>(<var>+Key,
337296 +Assoc, -Value</var>)</a></dt>
338297 <dd class="defbody">
339298 True if <var>Key</var>-<var>Value</var> is an association in <var>Assoc</var>.
347306 </dl>
348307
349308 </dd>
350 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="get_assoc/5"><strong>get_assoc</strong>(<var>+Key,
309 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="get_assoc/5"><strong>get_assoc</strong>(<var>+Key,
351310 +Assoc0, ?Val0, ?Assoc, ?Val</var>)</a></dt>
352311 <dd class="defbody">
353312 True if <var>Key</var>-<var>Val0</var> is in <var>Assoc0</var> and <var>Key</var>-<var>Val</var>
354313 is in <var>Assoc</var>.</dd>
355 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="max_assoc/3"><strong>max_assoc</strong>(<var>+Assoc,
314 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="max_assoc/3"><strong>max_assoc</strong>(<var>+Assoc,
356315 -Key, -Value</var>)</a></dt>
357316 <dd class="defbody">
358317 True if <var>Key</var>-<var>Value</var> is in <var>Assoc</var> and <var>Key</var>
359318 is the largest key.</dd>
360 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="min_assoc/3"><strong>min_assoc</strong>(<var>+Assoc,
319 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="min_assoc/3"><strong>min_assoc</strong>(<var>+Assoc,
361320 -Key, -Value</var>)</a></dt>
362321 <dd class="defbody">
363322 True if <var>Key</var>-<var>Value</var> is in assoc and <var>Key</var>
364323 is the smallest key.</dd>
365 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="gen_assoc/3"><strong>gen_assoc</strong>(<var>?Key,
324 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="gen_assoc/3"><strong>gen_assoc</strong>(<var>?Key,
366325 +Assoc, ?Value</var>)</a></dt>
367326 <dd class="defbody">
368327 True if <var>Key</var>-<var>Value</var> is an association in <var>Assoc</var>.
378337 </dd>
379338 </dl>
380339
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
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
382341 association lists</span></a></h3>
383342
384 <p><a id="sec:assoc-modifications"></a>
343 <p><a name="sec:assoc-modifications"></a>
385344
386345 <p>Elements of an association list can be changed and inserted with:
387346
388347 <dl class="latex">
389 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="put_assoc/4"><strong>put_assoc</strong>(<var>+Key,
348 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="put_assoc/4"><strong>put_assoc</strong>(<var>+Key,
390349 +Assoc0, +Value, -Assoc</var>)</a></dt>
391350 <dd class="defbody">
392351 <var>Assoc</var> is <var>Assoc0</var>, except that <var>Key</var> is
393352 associated with
394353 <var>Value</var>. This can be used to insert and change associations.</dd>
395 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="del_assoc/4"><strong>del_assoc</strong>(<var>+Key,
354 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="del_assoc/4"><strong>del_assoc</strong>(<var>+Key,
396355 +Assoc0, ?Value, -Assoc</var>)</a></dt>
397356 <dd class="defbody">
398357 True if <var>Key</var>-<var>Value</var> is in <var>Assoc0</var>. <var>Assoc</var>
399358 is <var>Assoc0</var> with
400359 <var>Key</var>-<var>Value</var> removed.</dd>
401 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="del_min_assoc/4"><strong>del_min_assoc</strong>(<var>+Assoc0,
360 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="del_min_assoc/4"><strong>del_min_assoc</strong>(<var>+Assoc0,
402361 ?Key, ?Val, -Assoc</var>)</a></dt>
403362 <dd class="defbody">
404363 True if <var>Key</var>-Value is in <var>Assoc0</var> and <var>Key</var>
406365 <var>Assoc</var> is <var>Assoc0</var> with <var>Key</var>-Value removed.
407366 Warning: This will succeed with <i>no</i> bindings for <var>Key</var> or <var>Val</var>
408367 if <var>Assoc0</var> is empty.</dd>
409 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="del_max_assoc/4"><strong>del_max_assoc</strong>(<var>+Assoc0,
368 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="del_max_assoc/4"><strong>del_max_assoc</strong>(<var>+Assoc0,
410369 ?Key, ?Val, -Assoc</var>)</a></dt>
411370 <dd class="defbody">
412371 True if <var>Key</var>-Value is in <var>Assoc0</var> and <var>Key</var>
417376 </dd>
418377 </dl>
419378
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
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
421380 predicates</span></a></h3>
422381
423 <p><a id="sec:assoc-conversion"></a>
382 <p><a name="sec:assoc-conversion"></a>
424383
425384 <p>Conversion of (parts of) an association list to <i>lists</i> is
426385 possible with:
427386
428387 <dl class="latex">
429 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assoc_to_list/2"><strong>assoc_to_list</strong>(<var>+Assoc,
388 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assoc_to_list/2"><strong>assoc_to_list</strong>(<var>+Assoc,
430389 -Pairs</var>)</a></dt>
431390 <dd class="defbody">
432391 Translate <var>Assoc</var> to a list <var>Pairs</var> of Key-Value
433392 pairs. The keys in <var>Pairs</var> are sorted in ascending order.</dd>
434 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assoc_to_keys/2"><strong>assoc_to_keys</strong>(<var>+Assoc,
393 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assoc_to_keys/2"><strong>assoc_to_keys</strong>(<var>+Assoc,
435394 -Keys</var>)</a></dt>
436395 <dd class="defbody">
437396 True if <var>Keys</var> is the list of keys in <var>Assoc</var>. The
438397 keys are sorted in ascending order.</dd>
439 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assoc_to_values/2"><strong>assoc_to_values</strong>(<var>+Assoc,
398 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assoc_to_values/2"><strong>assoc_to_values</strong>(<var>+Assoc,
440399 -Values</var>)</a></dt>
441400 <dd class="defbody">
442401 True if <var>Values</var> is the list of values in <var>Assoc</var>. <var>Values</var>
445404 </dd>
446405 </dl>
447406
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
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
449408 about association lists and their elements</span></a></h3>
450409
451 <p><a id="sec:assoc-reasoning"></a>
410 <p><a name="sec:assoc-reasoning"></a>
452411
453412 <p>Further inspection predicates of an association list and its elements
454413 are:
455414
456415 <dl class="latex">
457 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_assoc/1"><strong>is_assoc</strong>(<var>+Assoc</var>)</a></dt>
416 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_assoc/1"><strong>is_assoc</strong>(<var>+Assoc</var>)</a></dt>
458417 <dd class="defbody">
459418 True if <var>Assoc</var> is an association list. This predicate checks
460419 that the structure is valid, elements are in order, and tree is balanced
461420 to the extent guaranteed by AVL trees. I.e., branches of each subtree
462421 differ in depth by at most 1.</dd>
463 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="map_assoc/2"><strong>map_assoc</strong>(<var>:Pred,
422 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="map_assoc/2"><strong>map_assoc</strong>(<var>:Pred,
464423 +Assoc</var>)</a></dt>
465424 <dd class="defbody">
466425 True if <var>Pred</var>(Value) is true for all values in <var>Assoc</var>.</dd>
467 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="map_assoc/3"><strong>map_assoc</strong>(<var>:Pred,
426 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="map_assoc/3"><strong>map_assoc</strong>(<var>:Pred,
468427 +Assoc0, ?Assoc</var>)</a></dt>
469428 <dd class="defbody">
470429 Map corresponding values. True if <var>Assoc</var> is <var>Assoc0</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 7.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="clp.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="coroutining.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:attvar"><a id="sec:7.1"><span class="sec-nr">7.1</span> <span class="sec-title">Attributed
194 <h2 id="sec:attvar"><a name="sec:7.1"><span class="sec-nr">7.1</span> <span class="sec-title">Attributed
236195 variables</span></a></h2>
237196
238 <a id="sec:attvar"></a>
197 <a name="sec:attvar"></a>
239198
240199 <p><em>Attributed variables</em> provide a technique for extending the
241200 Prolog unification algorithm <cite><a class="cite" href="Bibliography.html#holzbaur:1992">Holzbaur,
244203 interface to attributed variables. The SWI-Prolog interface is identical
245204 to the one realised by Bart Demoen for hProlog <cite><a class="cite" href="Bibliography.html#Demoen:CW350">Demoen,
246205 2002</a></cite>. This interface is simple and available on all Prolog
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>).
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 ).
250208
251209 <p>Binding an attributed variable schedules a goal to be executed at the
252210 first possible opportunity. In the current implementation the hooks are
253211 executed immediately after a successful unification of the clause-head
254212 or successful completion of a foreign language (built-in) predicate.
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>)
213 Each attribute is associated to a module, and the hook (<a name="idx:attrunifyhook2:1774"></a><a class="pred" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a>)
256214 is executed in this module. The example below realises a very simple and
257215 incomplete finite domain reasoner:
258216
296254
297255 <p>Before explaining the code we give some example queries:
298256 <blockquote>
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,
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,
304262 [a, c]) </td></tr>
305263 </table>
306264 </blockquote>
307265
308266 <p>The predicate domain/2 fetches (first clause) or assigns (second
309267 clause) the variable a <em>domain</em>, a set of values the variable can
310 be unified with. In the second clause, <a id="idx:domain2:1776"></a><span class="pred-ext">domain/2</span>
268 be unified with. In the second clause, <a name="idx:domain2:1775"></a><span class="pred-ext">domain/2</span>
311269 first associates the domain with a fresh variable (Y) and then unifies X
312270 to this variable to deal with the possibility that X already has 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>
271 domain. The predicate <a name="idx:attrunifyhook2:1776"></a><a class="pred" href="attvar.html#attr_unify_hook/2">attr_unify_hook/2</a>
314272 (see below) is a hook called after a variable with a domain is assigned
315273 a value. In the simple case where the variable is bound to a concrete
316274 value, we simply check whether this value is in the domain. Otherwise we
318276 is empty (first example), assign the value if there is only one value in
319277 the intersection (second example), or assign the intersection as the new
320278 domain of the variable (third example). The nonterminal
321 <a id="idx:attributegoals1:1778"></a><a class="pred" href="attvar.html#attribute_goals//1">attribute_goals//1</a>
279 <a name="idx:attributegoals1:1777"></a><span class="pred-ext">attribute_goals/3</span>
322280 is used to translate remaining attributes to user-readable goals that,
323281 when called, reinstate these attributes or attributes that correspond to
324282 equivalent constraints.
325283
326 <p>Implementing constraint solvers (<a class="sec" href="clp.html#sec:7">chapter
284 <p>Implementing constraint solvers (<a class="sec" href="clp.html">chapter
327285 7</a>) is the most common, but not the only use case for attributed
328286 variables: If you implement algorithms that require efficient
329287 destructive modifications, then using attributed variables is often 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>
288 more convenient and somewhat more declarative alternative for <a name="idx:setarg3:1778"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
331289 and related predicates whose sharing semantics are harder to understand.
332290 In particular, attributed variables make it easy to express graph
333291 networks and graph-oriented algorithms, since each variable can store
335293 of attributed variables should be confined within a module that exposes
336294 its functionality via more declarative interface predicates.
337295
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
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
339297 manipulation predicates</span></a></h3>
340298
341 <a id="sec:attvar-predicates"></a>
299 <a name="sec:attvar-predicates"></a>
342300
343301 <dl class="latex">
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>
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:1779"></a><a class="pred" href="typetest.html#var/1">var/1</a>
347305 also succeeds on attributed variables. Attributed variables are created
348306 with
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,
307 <a name="idx:putattr3:1780"></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,
351309 +Module, +Value</var>)</a></dt>
352310 <dd class="defbody">
353311 If <var>Var</var> is a variable or attributed variable, set the value
354312 for the attribute named <var>Module</var> to <var>Value</var>. If an
355313 attribute with this name is already associated with <var>Var</var>, the
356314 old value is replaced. Backtracking will restore the old value (i.e., an
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>).
315 attribute is a mutable term; see also <a name="idx:setarg3:1781"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>).
358316 This predicate raises an uninstantiation error if
359317 <var>Var</var> is not a variable, and a type error if <var>Module</var>
360318 is not an atom.</dd>
361 <dt class="pubdef"><a id="get_attr/3"><strong>get_attr</strong>(<var>+Var,
319 <dt class="pubdef"><a name="get_attr/3"><strong>get_attr</strong>(<var>+Var,
362320 +Module, -Value</var>)</a></dt>
363321 <dd class="defbody">
364322 Request the current <var>value</var> for the attribute named <var>Module</var>.
366324 <var>Var</var> is not an attributed variable or the named attribute is
367325 not associated to <var>Var</var> this predicate fails silently. If <var>Module</var>
368326 is not an atom, a type error is raised.</dd>
369 <dt class="pubdef"><a id="del_attr/2"><strong>del_attr</strong>(<var>+Var,
327 <dt class="pubdef"><a name="del_attr/2"><strong>del_attr</strong>(<var>+Var,
370328 +Module</var>)</a></dt>
371329 <dd class="defbody">
372330 Delete the named attribute. If <var>Var</var> loses its last attribute
377335 </dd>
378336 </dl>
379337
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
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
381339 variable hooks</span></a></h3>
382340
383 <a id="sec:attvar-hooks"></a>
341 <a name="sec:attvar-hooks"></a>
384342
385343 <p>Attribute names are linked to modules. This means that certain
386344 operations on attributed variables cause <em>hooks</em> to be called in
387345 the module whose name matches the attribute name.
388346
389347 <dl class="latex">
390 <dt class="pubdef"><a id="attr_unify_hook/2"><strong>attr_unify_hook</strong>(<var>+AttValue,
348 <dt class="pubdef"><a name="attr_unify_hook/2"><strong>attr_unify_hook</strong>(<var>+AttValue,
391349 +VarValue</var>)</a></dt>
392350 <dd class="defbody">
393351 A hook that must be defined in the module to which an attributed
399357 is another attributed variable the hook often combines the two
400358 attributes and associates the combined attribute with <var>VarValue</var>
401359 using
402 <a id="idx:putattr3:1783"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>.
360 <a name="idx:putattr3:1782"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>.
403361
404362 <dl class="tags">
405363 <dt class="tag">To be done</dt>
415373 </dl>
416374
417375 </dd>
418 <dt class="pubdef"><a id="attribute_goals//1"><strong>attribute_goals</strong>(<var>+Var</var>)</a><code>//</code></dt>
376 <dt class="pubdef"><a name="attribute_goals/1"><strong>attribute_goals</strong>(<var>+Var</var>)</a><code>//</code></dt>
419377 <dd class="defbody">
420378 This nonterminal is the main mechanism in which residual constraints are
421379 obtained. It is called in every module where it is defined, and
422380 <var>Var</var> has an attribute. Its argument is that variable. In each
423 module, <a id="idx:attributegoals1:1784"></a><a class="pred" href="attvar.html#attribute_goals//1">attribute_goals//1</a>
381 module, <a name="idx:attributegoals1:1783"></a><span class="pred-ext">attribute_goals/3</span>
424382 must describe a list of Prolog goals that are declaratively equivalent
425383 to the goals that caused the attributes of that module to be present and
426384 in their current state. It is always possible to do this (since these
446404 constraint solvers by contrasting obtained residual goals with expected
447405 answers.
448406
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>,
407 <p>This nonterminal is used by <a name="idx:copyterm3:1784"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>,
450408 on which the Prolog top level relies to ensure the basic invariant of
451409 pure Prolog programs: The answer is <i>declaratively equivalent</i> to
452410 the query.
455413 <i>list</i> is used to represent residual goals. This simplifies
456414 processing and reasoning about residual goals throughout all programs
457415 that need this functionality.</dd>
458 <dt class="pubdef"><a id="project_attributes/2"><strong>project_attributes</strong>(<var>+QueryVars,
416 <dt class="pubdef"><a name="project_attributes/2"><strong>project_attributes</strong>(<var>+QueryVars,
459417 +ResidualVars</var>)</a></dt>
460418 <dd class="defbody">
461419 A hook that can be defined in each module to project constraints on
462420 newly introduced variables back to the query variables.
463421 <var>QueryVars</var> is the list of variables occurring in the query and
464422 <var>ResidualVars</var> is a list of variables that have attributes
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>
423 attached. There may be variables that occur in both lists. If possible, <a name="idx:projectattributes2:1785"></a><a class="pred" href="attvar.html#project_attributes/2">project_attributes/2</a>
466424 should change the attributes so that all constraints are expressed as
467425 residual goals that refer only to
468426 <var>QueryVars</var>, while other variables are existentially
469427 quantified.</dd>
470 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="attr_portray_hook/2"><strong>attr_portray_hook</strong>(<var>+AttValue,
428 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="attr_portray_hook/2"><strong>attr_portray_hook</strong>(<var>+AttValue,
471429 +Var</var>)</a></dt>
472430 <dd class="defbody">
473 Called by <a id="idx:writeterm2:1787"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
431 Called by <a name="idx:writeterm2:1786"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
474432 and friends for each attribute if the option
475433 <code>attributes(portray)</code> is in effect. If the hook succeeds the
476434 attribute is considered printed. Otherwise <code>Module = ...</code> is
477435 printed to indicate the existence of a variable. This predicate is
478436 deprecated because it cannot work with pure interface predicates like
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>
437 <a name="idx:copyterm3:1787"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>.
438 Use <a name="idx:attributegoals1:1788"></a><span class="pred-ext">attribute_goals/3</span>
481439 instead to map attributes to residual goals.
482440 </dd>
483441 </dl>
484442
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
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
486444 on terms with attributed variables</span></a></h3>
487445
488 <a id="sec:terms-with-attvars"></a>
446 <a name="sec:terms-with-attvars"></a>
489447
490448 <dl class="latex">
491 <dt class="pubdef"><a id="copy_term/3"><strong>copy_term</strong>(<var>+Term,
449 <dt class="pubdef"><a name="copy_term/3"><strong>copy_term</strong>(<var>+Term,
492450 -Copy, -Gs</var>)</a></dt>
493451 <dd class="defbody">
494452 Create a regular term <var>Copy</var> as a copy of <var>Term</var>
495453 (without any attributes), and a list <var>Gs</var> of goals that
496454 represents the attributes. The goal <code>maplist(call, Gs)</code>
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>,
455 recreates the attributes for <var>Copy</var>. The nonterminal <a name="idx:attributegoals1:1789"></a><span class="pred-ext">attribute_goals/3</span>,
498456 as defined in the modules the attributes stem from, is used to convert
499457 attributes to lists of goals.
500458
505463
506464 <p>The form <code>copy_term(Term, Term, Gs)</code> can be used to reason
507465 about the constraints in which <code>Term</code> is involved.</dd>
508 <dt class="pubdef"><a id="copy_term_nat/2"><strong>copy_term_nat</strong>(<var>+Term,
466 <dt class="pubdef"><a name="copy_term_nat/2"><strong>copy_term_nat</strong>(<var>+Term,
509467 -Copy</var>)</a></dt>
510468 <dd class="defbody">
511 As <a id="idx:copyterm2:1791"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>.
469 As <a name="idx:copyterm2:1790"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>.
512470 Attributes, however, are <em>not</em> copied but replaced by fresh
513471 variables.</dd>
514 <dt class="pubdef"><a id="term_attvars/2"><strong>term_attvars</strong>(<var>+Term,
472 <dt class="pubdef"><a name="term_attvars/2"><strong>term_attvars</strong>(<var>+Term,
515473 -AttVars</var>)</a></dt>
516474 <dd class="defbody">
517475 <var>AttVars</var> is a list of all attributed variables in <var>Term</var>
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>
476 and its attributes. That is, <a name="idx:termattvars2:1791"></a><a class="pred" href="attvar.html#term_attvars/2">term_attvars/2</a>
519477 works recursively through attributes. This predicate is cycle-safe. The
520478 goal
521479 <code>term_attvars(Term,[])</code> in an efficient test that <var>Term</var>
525483 </dd>
526484 </dl>
527485
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
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
529487 purpose predicates for attributes</span></a></h3>
530488
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>.
489 <a name="sec:attvar-low-level-preds"></a>
490
491 <p>Normal user code should deal with <a name="idx:putattr3:1792"></a><a class="pred" href="attvar.html#put_attr/3">put_attr/3</a>, <a name="idx:getattr3:1793"></a><a class="pred" href="attvar.html#get_attr/3">get_attr/3</a>
492 and <a name="idx:delattr2:1794"></a><a class="pred" href="attvar.html#del_attr/2">del_attr/2</a>.
535493 The routines in this section fetch or set the entire attribute list of a
536494 variable. Use of these predicates is anticipated to be restricted to
537495 printing and other special purpose operations.
538496
539497 <dl class="latex">
540 <dt class="pubdef"><a id="get_attrs/2"><strong>get_attrs</strong>(<var>+Var,
498 <dt class="pubdef"><a name="get_attrs/2"><strong>get_attrs</strong>(<var>+Var,
541499 -Attributes</var>)</a></dt>
542500 <dd class="defbody">
543501 Get all attributes of <var>Var</var>. <var>Attributes</var> is a term of
545503 <code>att(Module, Value, MoreAttributes)</code>, where <var>MoreAttributes</var>
546504 is
547505 <code>[]</code> for the last attribute.</dd>
548 <dt class="pubdef"><a id="put_attrs/2"><strong>put_attrs</strong>(<var>+Var,
506 <dt class="pubdef"><a name="put_attrs/2"><strong>put_attrs</strong>(<var>+Var,
549507 -Attributes</var>)</a></dt>
550508 <dd class="defbody">
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>
509 Set all attributes of <var>Var</var>. See <a name="idx:getattrs2:1795"></a><a class="pred" href="attvar.html#get_attrs/2">get_attrs/2</a>
552510 for a description of
553511 <var>Attributes</var>.</dd>
554 <dt class="pubdef"><a id="del_attrs/1"><strong>del_attrs</strong>(<var>+Var</var>)</a></dt>
512 <dt class="pubdef"><a name="del_attrs/1"><strong>del_attrs</strong>(<var>+Var</var>)</a></dt>
555513 <dd class="defbody">
556514 If <var>Var</var> is an attributed variable, delete <em>all</em> its
557515 attributes. In all other cases, this predicate succeeds without
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="hooks.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="packs.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:autoload"><a id="sec:2.13"><span class="sec-nr">2.13</span> <span class="sec-title">Automatic
194 <h2 id="sec:autoload"><a name="sec:2.13"><span class="sec-nr">2.13</span> <span class="sec-title">Automatic
236195 loading of libraries</span></a></h2>
237196
238 <a id="sec:autoload"></a>
197 <a name="sec:autoload"></a>
239198
240199 <p>If ---at runtime--- an undefined predicate is trapped, the system
241200 will first try to import the predicate from the module's default module
242201 (see
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,
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,
245204 the hook user:exception/3 is called; only if this hook fails does it
246205 call the autoloader.</span></sup> On first activation an index to all
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>
206 library files in all library directories is loaded in core (see <a name="idx:librarydirectory1:191"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>, <a name="idx:filesearchpath2:192"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
248207 and
249 <a id="idx:reloadlibraryindex0:191"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>).
208 <a name="idx:reloadlibraryindex0:193"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>).
250209 If the undefined predicate can be located in one of the libraries, that
251210 library file is automatically loaded and the call to the (previously
252211 undefined) predicate is restarted. By default this mechanism loads the
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>
212 file silently. The <a name="idx:currentprologflag2:194"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
254213 key <a class="flag" href="flags.html#flag:verbose_autoload">verbose_autoload</a>
255214 is provided to get verbose loading. The Prolog flag <a class="flag" href="flags.html#flag:autoload">autoload</a>
256215 can be used to enable/disable the autoload system.
257216
258217 <p>Autoloading only handles (library) source files that use the module
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>
218 mechanism described in <a class="sec" href="modules.html">chapter 6</a>.
219 The files are loaded with <a name="idx:usemodule2:195"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
261220 and only the trapped undefined predicate is imported into the module
262221 where the undefined predicate was called. Each library directory must
263222 hold a file <code>INDEX.pl</code> that contains an index to all library
268227 index(Name, Arity, Module, File).
269228 </pre>
270229
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>)
230 <p>The predicate <a name="idx:make0:196"></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:197"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>
232 and <a name="idx:filesearchpath2:198"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>)
274233 holding the file <code>MKINDEX.pl</code> or <code>INDEX.pl</code>. If
275234 the current user can write or create the file <code>INDEX.pl</code> and
276235 it does not exist or is older than the directory or one of its files,
277236 the index for this directory is updated. If the file <code>MKINDEX.pl</code>
278237 exists, updating is achieved by loading this file, normally containing a
279238 directive calling
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>
239 <a name="idx:makelibraryindex2:199"></a><a class="pred" href="autoload.html#make_library_index/2">make_library_index/2</a>.
240 Otherwise <a name="idx:makelibraryindex1:200"></a><a class="pred" href="autoload.html#make_library_index/1">make_library_index/1</a>
282241 is called, creating an index for all <code>*.pl</code> files containing
283242 a module.
284243
298257 <li>If there is a library file that defines the module in which the
299258 undefined predicate is trapped, this file is used.
300259 <li>Otherwise library files are considered in the order they appear in
301 the <a id="idx:librarydirectory1:199"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>
260 the <a name="idx:librarydirectory1:201"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>
302261 predicate and within the directory alphabetically.
303262 </ol>
304263
305264 <dl class="latex">
306 <dt class="pubdef"><a id="autoload_path/1"><strong>autoload_path</strong>(<var>+DirAlias</var>)</a></dt>
265 <dt class="pubdef"><a name="autoload_path/1"><strong>autoload_path</strong>(<var>+DirAlias</var>)</a></dt>
307266 <dd class="defbody">
308267 Add <var>DirAlias</var> to the libraries that are used by the
309268 autoloader. This extends the search path <code>autoload</code> and
315274
316275 <p>If this call appears as a directive, it is term-expanded into a
317276 clause for user:file_search_path/2 and a directive calling
318 <a id="idx:reloadlibraryindex0:200"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>.
277 <a name="idx:reloadlibraryindex0:202"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>.
319278 This keeps source information and allows for removing this directive.</dd>
320 <dt class="pubdef"><a id="make_library_index/1"><strong>make_library_index</strong>(<var>+Directory</var>)</a></dt>
279 <dt class="pubdef"><a name="make_library_index/1"><strong>make_library_index</strong>(<var>+Directory</var>)</a></dt>
321280 <dd class="defbody">
322281 Create an index for this directory. The index is written to the file
323282 'INDEX.pl' in the specified directory. Fails with a warning if the
324283 directory does not exist or is write protected.</dd>
325 <dt class="pubdef"><a id="make_library_index/2"><strong>make_library_index</strong>(<var>+Directory,
284 <dt class="pubdef"><a name="make_library_index/2"><strong>make_library_index</strong>(<var>+Directory,
326285 +ListOfPatterns</var>)</a></dt>
327286 <dd class="defbody">
328287 Normally used in <code>MKINDEX.pl</code>, this predicate creates <code>INDEX.pl</code>
346305 </pre>
347306
348307 </dd>
349 <dt class="pubdef"><a id="reload_library_index/0"><strong>reload_library_index</strong></a></dt>
308 <dt class="pubdef"><a name="reload_library_index/0"><strong>reload_library_index</strong></a></dt>
350309 <dd class="defbody">
351310 Force reloading the index after modifying the set of library directories
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>,
311 by changing the rules for <a name="idx:librarydirectory1:203"></a><a class="pred" href="consulting.html#library_directory/1">library_directory/1</a>, <a name="idx:filesearchpath2:204"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>,
353312 adding or deleting <code>INDEX.pl</code> files. This predicate does <em>not</em>
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>
313 update the <code>INDEX.pl</code> files. Check <a name="idx:makelibraryindex12:205"></a><a class="pred" href="autoload.html#make_library_index/1">make_library_index/[1,2]</a>
355314 and
356 <a id="idx:make0:204"></a><a class="pred" href="consulting.html#make/0">make/0</a>
315 <a name="idx:make0:206"></a><a class="pred" href="consulting.html#make/0">make/0</a>
357316 for updating the index files.
358317
359318 <p>Normally, the index is reloaded automatically if a predicate cannot
360319 be found in the index and the set of library directories has changed.
361320 Using
362 <a id="idx:reloadlibraryindex0:205"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>
321 <a name="idx:reloadlibraryindex0:207"></a><a class="pred" href="autoload.html#reload_library_index/0">reload_library_index/0</a>
363322 is necessary if directories are removed or the order of the library
364323 directories is changed.
365324 </dd>
366325 </dl>
367326
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>
327 <p>When creating an executable using either <a name="idx:qsaveprogram2:208"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
369328 or the
370329 <strong>-c</strong> command line options, it is necessarry to load all
371330 predicates that would normally be autoloaded explicitly. This is
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>.
331 discussed in <a class="sec" href="runtime.html">section 12</a>. See <a name="idx:autoload0:209"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>.
374332
375333 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="tracehook.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="excepthook.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:breakpoint"><a id="sec:B.4"><span class="sec-nr">B.4</span> <span class="sec-title">Breakpoint
194 <h2 id="sec:breakpoint"><a name="sec:B.4"><span class="sec-nr">B.4</span> <span class="sec-title">Breakpoint
236195 and watchpoint handling</span></a></h2>
237196
238 <a id="sec:breakpoint"></a>
197 <a name="sec:breakpoint"></a>
239198
240199 <p>SWI-Prolog support <em>breakpoints</em>. Breakpoints can be
241200 manipulated with the library <code>library(prolog_breakpoints)</code>.
245204 describes this callback, called prolog:break_hook/6.
246205
247206 <dl class="latex">
248 <dt class="pubdef"><span class="pred-tag">[hook,semidet]</span><a id="prolog:break_hook/6"><strong>prolog:break_hook</strong>(<var>+Clause,
207 <dt class="pubdef"><span class="pred-tag">[hook,semidet]</span><a name="prolog:break_hook/6"><strong>prolog:break_hook</strong>(<var>+Clause,
249208 +PC, +FR, +BFR, +Expression, -Action</var>)</a></dt>
250209 <dd class="defbody">
251210 <em>Experimental</em> This hook is called if the virtual machine
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>
211 executes a <code>D_BREAK</code>, set using <a name="idx:setbreakpoint4:2202"></a><span class="pred-ext">set_breakpoint/4</span>. <var>Clause</var>
253212 and <var>PC</var> identify the breakpoint. <var>FR</var> and <var>BFR</var>
254213 provide the environment frame and current choicepoint. <var>Expression</var>
255214 identifies the action that is interrupted, and is one of the following:
284243 <dd class="defbody">
285244 The breakpoint is on the completion of an in-lined unification while the
286245 system is not in debug mode. If the system is in debug mode, inlined
287 unification is returned as call(Var=Term).<sup class="fn">187<span class="fn-text">This
246 unification is returned as call(Var=Term).<sup class="fn">186<span class="fn-text">This
288247 hack will disappear if we find a good solution for applying D_BREAK to
289248 inlined unification. Only option might be to place the break on both the
290249 unification start and end instructions.</span></sup>
301260 Just continue as if no breakpoint was present.</dd>
302261 <dt><strong>debug</strong></dt>
303262 <dd class="defbody">
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>
263 Continue in <em>debug mode</em>. See <a name="idx:debug0:2203"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
305264 <dt><strong>trace</strong></dt>
306265 <dd class="defbody">
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>
266 Continue in <em>trace mode</em>. See <a name="idx:trace0:2204"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>.</dd>
308267 <dt><strong>call</strong>(<var>Goal</var>)</dt>
309268 <dd class="defbody">
310269 Execute <var>Goal</var> instead of the goal that would be executed.
311 <var>Goal</var> is executed as <a id="idx:call1:2206"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
270 <var>Goal</var> is executed as <a name="idx:call1:2205"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
312271 preserving (non-)determinism and exceptions.
313272 </dd>
314273 </dl>
330289 before deciding the return <code>trace</code>.
331290 <li>Watch variables at a specific point in the execution. Note that
332291 binding of these variables can be monitored using <em>attributed
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>.
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:2206"></a><a class="pred" href="debug.html#assertion/1">assertion/1</a>.
336294 <li>Wrap the <var>Goal</var> into a meta-call that traces progress of
337295 the <var>Goal</var>.
338296 </ul>
Binary diff not shown
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="assoc.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="charsio.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:broadcast"><a id="sec:A.4"><span class="sec-nr">A.4</span> <span class="sec-title">library(broadcast):
194 <h2 id="sec:broadcast"><a name="sec:A.4"><span class="sec-nr">A.4</span> <span class="sec-title">library(broadcast):
236195 Broadcast and receive event notifications</span></a></h2>
237196
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>
197 <a name="sec:broadcast"></a>
198
199 <p><a name="idx:broadcast:2135"></a><a name="idx:messageservice:2136"></a><a name="idx:blackboard:2137"></a><a name="idx:agent:2138"></a><a name="idx:daemon:2139"></a>The <code>library(broadcast)</code>
241200 library was invented to realise GUI applications consisting of
242201 stand-alone components that use the Prolog database for storing the
243202 application data. <a class="fig" href="broadcast.html#fig:broadcast">Figure
244203 12</a> illustrates the flow of information using this design
245204
246 <p><a id="fig:broadcast"></a><div style="text-align:center"><img src="broadcast.gif"></div>
205 <p><a name="fig:broadcast"></a><div style="text-align:center"><img src="broadcast.gif"></div>
247206 <div class="caption"><b>Figure 12 : </b>Information-flow using
248207 broadcasting service</div>
249208
262221 showing <var>X</var>?''.
263222
264223 <dl class="latex">
265 <dt class="pubdef"><a id="broadcast/1"><strong>broadcast</strong>(<var>+Term</var>)</a></dt>
224 <dt class="pubdef"><a name="broadcast/1"><strong>broadcast</strong>(<var>+Term</var>)</a></dt>
266225 <dd class="defbody">
267226 Broadcast <var>Term</var>. There are no limitations to <var>Term</var>,
268227 though being a global service, it is good practice to use a descriptive
269228 and unique principal functor. All associated goals are started and
270 regardless of their success or failure, <a id="idx:broadcast1:2141"></a><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a>
229 regardless of their success or failure, <a name="idx:broadcast1:2140"></a><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a>
271230 always succeeds. Exceptions are passed.</dd>
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>,
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:2141"></a><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a>,
275234 this predicate stops if an associated goal succeeds. Backtracking causes
276235 it to try other listeners. A broadcast request is used to fetch
277236 information without knowing the identity of the agent providing it. C.f. ``Is
285244 <p>If there is an agent (<em>listener</em>) that registered an `age-of'
286245 service and knows about the age of `John' this question will be
287246 answered.</dd>
288 <dt class="pubdef"><a id="listen/2"><strong>listen</strong>(<var>+Template,
247 <dt class="pubdef"><a name="listen/2"><strong>listen</strong>(<var>+Template,
289248 :Goal</var>)</a></dt>
290249 <dd class="defbody">
291250 Register a <em>listen</em> channel. Whenever a term unifying
301260 </pre>
302261
303262 </dd>
304 <dt class="pubdef"><a id="listen/3"><strong>listen</strong>(<var>+Listener,
263 <dt class="pubdef"><a name="listen/3"><strong>listen</strong>(<var>+Listener,
305264 +Template, :Goal</var>)</a></dt>
306265 <dd class="defbody">
307266 Declare <var>Listener</var> as the owner of the channel. Unlike a
308 channel opened using <a id="idx:listen2:2143"></a><a class="pred" href="broadcast.html#listen/2">listen/2</a>,
267 channel opened using <a name="idx:listen2:2142"></a><a class="pred" href="broadcast.html#listen/2">listen/2</a>,
309268 channels that have an owner can terminate the channel. This is commonly
310269 used if an object is listening to broadcast messages. In the example
311270 below we define a `name-item' displaying the name of an identifier
312 represented by the predicate <a id="idx:nameof2:2144"></a><span class="pred-ext">name_of/2</span>.
271 represented by the predicate <a name="idx:nameof2:2143"></a><span class="pred-ext">name_of/2</span>.
313272
314273 <pre class="code">
315274 :- pce_begin_class(name_item, text_item).
338297 </pre>
339298
340299 </dd>
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>
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:2144"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
344303 whose <var>Listener</var> unify.</dd>
345 <dt class="pubdef"><a id="unlisten/2"><strong>unlisten</strong>(<var>+Listener,
304 <dt class="pubdef"><a name="unlisten/2"><strong>unlisten</strong>(<var>+Listener,
346305 +Template</var>)</a></dt>
347306 <dd class="defbody">
348 Deregister all entries created with <a id="idx:listen3:2146"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
307 Deregister all entries created with <a name="idx:listen3:2145"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
349308 whose <var>Listener</var> and <var>Template</var> unify.</dd>
350 <dt class="pubdef"><a id="unlisten/3"><strong>unlisten</strong>(<var>+Listener,
309 <dt class="pubdef"><a name="unlisten/3"><strong>unlisten</strong>(<var>+Listener,
351310 +Template, :Goal</var>)</a></dt>
352311 <dd class="defbody">
353 Deregister all entries created with <a id="idx:listen3:2147"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
312 Deregister all entries created with <a name="idx:listen3:2146"></a><a class="pred" href="broadcast.html#listen/3">listen/3</a>
354313 whose <var>Listener</var>,
355314 <var>Template</var> and <var>Goal</var> unify.</dd>
356 <dt class="pubdef"><a id="listening/3"><strong>listening</strong>(<var>?Listener,
315 <dt class="pubdef"><a name="listening/3"><strong>listening</strong>(<var>?Listener,
357316 ?Template, ?Goal</var>)</a></dt>
358317 <dd class="defbody">
359318 Examine the current listeners. This predicate is useful for debugging
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="idesummary.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="preddesc.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:builtin"><a id="sec:4"><span class="sec-nr">4</span> <span class="sec-title">Built-in
194 <h1 id="sec:builtin"><a name="sec:4"><span class="sec-nr">4</span> <span class="sec-title">Built-in
236195 Predicates</span></a></h1>
237196
238 <a id="sec:builtin"></a>
197 <a name="sec:builtin"></a>
239198
240199 <p>
241200 <hr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.29</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="miscarith.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="allsolutions.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:builtinlist"><a id="sec:4.29"><span class="sec-nr">4.29</span> <span class="sec-title">Built-in
194 <h2 id="sec:builtinlist"><a name="sec:4.29"><span class="sec-nr">4.29</span> <span class="sec-title">Built-in
236195 list operations</span></a></h2>
237196
238 <a id="sec:builtinlist"></a>
197 <a name="sec:builtinlist"></a>
239198
240199 <p>Most list operations are defined in the library <code>library(lists)</code>
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.
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.
244203
245204 <dl class="latex">
246 <dt class="pubdef"><a id="is_list/1"><strong>is_list</strong>(<var>+Term</var>)</a></dt>
205 <dt class="pubdef"><a name="is_list/1"><strong>is_list</strong>(<var>+Term</var>)</a></dt>
247206 <dd class="defbody">
248207 True if <var>Term</var> is bound to the empty list (<code>[]</code>) or
249 a term with functor `<code>'[|]'</code>'<sup class="fn">118<span class="fn-text">The
208 a term with functor `<code>'[|]'</code>'<sup class="fn">117<span class="fn-text">The
250209 traditional list functor is the dot (<code>'.'</code>). This is still
251210 the case of the command line option <strong>--traditional</strong> is
252 given. See also <a class="sec" href="ext-lists.html#sec:5.1">section 5.1</a>.</span></sup>
253 and arity&nbsp;2 and the second argument is a list.<sup class="fn">119<span class="fn-text">In
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>
211 given. See also <a class="sec" href="ext-lists.html">section 5.1</a>.</span></sup>
212 and arity&nbsp;2 and the second argument is a list.<sup class="fn">118<span class="fn-text">In
213 versions before 5.0.1, <a name="idx:islist1:1344"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>
255214 just checked for <code>[]</code> or <code>[_|_]</code> and proper_list/1
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>.
215 had the role of the current <a name="idx:islist1:1345"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>.
257216 The current definition conforms to the de facto standard. Assuming
258217 proper coding standards, there should only be very few cases where a
259 quick-and-dirty <a id="idx:islist1:1344"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>
218 quick-and-dirty <a name="idx:islist1:1346"></a><a class="pred" href="builtinlist.html#is_list/1">is_list/1</a>
260219 is a good choice. Richard O'Keefe pointed at this issue.</span></sup>
261220 This predicate acts as if defined by the definition below on
262221 <em>acyclic</em> terms. The implementation <em>fails</em> safely if
272231 </pre>
273232
274233 </dd>
275 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="memberchk/2"><strong>memberchk</strong>(<var>?Elem,
234 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="memberchk/2"><strong>memberchk</strong>(<var>?Elem,
276235 +List</var>)</a></dt>
277236 <dd class="defbody">
278237 True when <var>Elem</var> is an element of <var>List</var>. This `chk'
279238 variant of
280 <a id="idx:member2:1345"></a><a class="pred" href="lists.html#member/2">member/2</a>
239 <a name="idx:member2:1347"></a><a class="pred" href="lists.html#member/2">member/2</a>
281240 is semi deterministic and typically used to test membership of a list.
282241 Raises a <code>type</code> error if scanning <var>List</var> encounters
283 a non-list. Note that <a id="idx:memberchk2:1346"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
242 a non-list. Note that <a name="idx:memberchk2:1348"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
284243 does <em>not</em> perform a full list typecheck. For example, <code>memberchk(a,
285244 [a|b])</code> succeeds without error. If <var>List</var> is cyclic and <var>Elem</var>
286245 is not a member of
287 <var>List</var>, <a id="idx:memberchk2:1347"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
288 eventually raises a <code>type</code> error.<sup class="fn">120<span class="fn-text"><i>Eventually</i>
246 <var>List</var>, <a name="idx:memberchk2:1349"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
247 eventually raises a <code>type</code> error.<sup class="fn">119<span class="fn-text"><i>Eventually</i>
289248 here means it will scan as many elements as the longest list that may
290249 exist given the current stack usage before raising the exception.</span></sup></dd>
291 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="length/2"><strong>length</strong>(<var>?List,
250 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="length/2"><strong>length</strong>(<var>?List,
292251 ?Int</var>)</a></dt>
293252 <dd class="defbody">
294253 True if <var>Int</var> represents the number of elements in <var>List</var>.
304263 <li><var>Int</var> is bound to a non-integer.
305264 <li><var>Int</var> is a negative integer.
306265 <li><var>List</var> is neither a list nor a partial list. This error
307 condition includes cyclic lists.<sup class="fn">121<span class="fn-text">ISO
266 condition includes cyclic lists.<sup class="fn">120<span class="fn-text">ISO
308267 demands failure here. We think an error is more appropriate.</span></sup>
309268 </ul>
310269
311270 <p>This predicate fails if the tail of <var>List</var> is equivalent to
312 <var>Int</var> (e.g., <code>length(L,L)</code>).<sup class="fn">122<span class="fn-text">This
271 <var>Int</var> (e.g., <code>length(L,L)</code>).<sup class="fn">121<span class="fn-text">This
313272 is logically correct. An exception would be more appropriate, but to our
314273 best knowledge, current practice in Prolog does not describe a suitable
315274 candidate exception term.</span></sup></dd>
316 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="sort/2"><strong>sort</strong>(<var>+List,
275 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="sort/2"><strong>sort</strong>(<var>+List,
317276 -Sorted</var>)</a></dt>
318277 <dd class="defbody">
319278 True if <var>Sorted</var> can be unified with a list holding the
320279 elements of <var>List</var>, sorted to the standard order of terms (see
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>
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">122<span class="fn-text">Contributed
282 by Richard O'Keefe.</span></sup> The <a name="idx:sort2:1350"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
324283 predicate can sort a cyclic list, returning a non-cyclic version with
325284 the same elements.
326285
330289 However, unifying a variable in <var>Sorted</var> may cause this
331290 relation to become invalid,
332291 <em>even</em> unifying a variable in <var>Sorted</var> with another
333 (older) variable. See also <a class="sec" href="compare.html#sec:4.7.1">section
292 (older) variable. See also <a class="sec" href="compare.html">section
334293 4.7.1</a>.</dd>
335 <dt class="pubdef"><a id="sort/4"><strong>sort</strong>(<var>+Key,
294 <dt class="pubdef"><a name="sort/4"><strong>sort</strong>(<var>+Key,
336295 +Order, +List, -Sorted</var>)</a></dt>
337296 <dd class="defbody">
338297 True when <var>Sorted</var> can be unified with a list holding the
340299 <var>List</var>. <var>Key</var> determines which part of each element in
341300 <var>List</var> is used for comparing two term and <var>Order</var>
342301 describes the relation between each set of consecutive elements in
343 <var>Sorted</var>.<sup class="fn">124<span class="fn-text">The
302 <var>Sorted</var>.<sup class="fn">123<span class="fn-text">The
344303 definition of this predicate was established after discussion with
345304 Joachim Schimpf from the ECLiPSe team. ECLiPSe currently only accepts <code><code>&lt;</code></code>, <code><code>=&lt;</code></code>, <code><code>&gt;</code></code>
346305 and <code><code>&gt;=</code></code> for the <var>Order</var> argument
350309 <p>If <var>Key</var> is the integer zero (0), the entire term is used to
351310 compare two elements. Using <var>Key</var>=0 can be used to sort
352311 arbitrary Prolog terms. Other values for <var>Key</var> can only be used
353 with compound terms or dicts (see <a class="sec" href="dicts.html#sec:5.4">section
312 with compound terms or dicts (see <a class="sec" href="dicts.html">section
354313 5.4</a>). An integer key extracts the <var>Key</var>-th argument from a
355314 compound term. An integer or atom key extracts the value from a dict
356315 that is associated with the given key. A type_error is raised if the
361320 <p>Deeper nested elements of structures can be selected by using a list
362321 of keys for the <var>Key</var> argument.
363322
364 <p>The <var>Order</var> argument is described in the table below<sup class="fn">125<span class="fn-text">For
323 <p>The <var>Order</var> argument is described in the table below<sup class="fn">124<span class="fn-text">For
365324 compatibility with ECLiPSe, the values <code><code>&lt;</code></code>, <code><code>=&lt;</code></code>, <code><code>&gt;</code></code>
366325 and <code><code>&gt;=</code></code> are allowed as synonyms.</span></sup>
367326
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>
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>
374334 </table>
375335
376336 <p>The sort is <em>stable</em>, which implies that, if duplicates are
388348
389349 <p>The following example sorts a list of rows, for example resulting
390350 from
391 <a id="idx:csvreadfile2:1349"></a><a class="pred" href="csv.html#csv_read_file/2">csv_read_file/2</a>)
351 <a name="idx:csvreadfile2:1351"></a><a class="pred" href="csv.html#csv_read_file/2">csv_read_file/2</a>)
392352 ascending on the 3th column and descending on the 4th column:
393353
394354 <pre class="code">
396356 sort(3, @=&lt;, Rows1, Sorted).
397357 </pre>
398358
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,
359 <p>See also <a name="idx:sort2:1352"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
360 (ISO), <a name="idx:msort2:1353"></a><a class="pred" href="builtinlist.html#msort/2">msort/2</a>, <a name="idx:keysort2:1354"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>, <a name="idx:predsort3:1355"></a><a class="pred" href="builtinlist.html#predsort/3">predsort/3</a>
361 and <a name="idx:orderby2:1356"></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,
403363 -Sorted</var>)</a></dt>
404364 <dd class="defbody">
405 Equivalent to <a id="idx:sort2:1355"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
365 Equivalent to <a name="idx:sort2:1357"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
406366 but does not remove duplicates. Raises a
407367 <code>type_error</code> if <var>List</var> is a cyclic list or not a
408368 list.</dd>
409 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="keysort/2"><strong>keysort</strong>(<var>+List,
369 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="keysort/2"><strong>keysort</strong>(<var>+List,
410370 -Sorted</var>)</a></dt>
411371 <dd class="defbody">
412372 Sort a list of <em>pairs</em>. <var>List</var> must be a list of
413373 <code><var>Key</var>-<var>Value</var></code> pairs, terms whose
414374 principal functor is (-)/2. <var>List</var> is sorted on <var>Key</var>
415 according to the standard order of terms (see <a class="sec" href="compare.html#sec:4.7.1">section
375 according to the standard order of terms (see <a class="sec" href="compare.html">section
416376 4.7.1</a>). Duplicates are <em>not</em> removed. Sorting is <em>stable</em>
417377 with regard to the order of the
418378 <var>Values</var>, i.e., the order of multiple elements that have the
419379 same
420380 <var>Key</var> is not changed.
421381
422 <p>The <a id="idx:keysort2:1356"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>
382 <p>The <a name="idx:keysort2:1358"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>
423383 predicate is often used together with library
424384 <code>library(pairs)</code>. It can be used to sort lists on different
425385 or multiple criteria. For example, the following predicates sorts a list
436396 </pre>
437397
438398 </dd>
439 <dt class="pubdef"><a id="predsort/3"><strong>predsort</strong>(<var>+Pred,
399 <dt class="pubdef"><a name="predsort/3"><strong>predsort</strong>(<var>+Pred,
440400 +List, -Sorted</var>)</a></dt>
441401 <dd class="defbody">
442 Sorts similar to <a id="idx:sort2:1357"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
402 Sorts similar to <a name="idx:sort2:1359"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>,
443403 but determines the order of two terms by calling <var>Pred</var>(-<var>Delta</var>,
444404 +<var>E1</var>, +<var>E2</var>) . This call must unify <var>Delta</var>
445405 with one of <code><code>&lt;</code></code>, <code><code>&gt;</code></code>
446406 or
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>.
407 <code><code>=</code></code>. If the built-in predicate <a name="idx:compare3:1360"></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:1361"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>.
409 See also <a name="idx:keysort2:1362"></a><a class="pred" href="builtinlist.html#keysort/2">keysort/2</a>.
450410 </dd>
451411 </dl>
452412
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.26</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="operators.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="arith.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:charconv"><a id="sec:4.26"><span class="sec-nr">4.26</span> <span class="sec-title">Character
194 <h2 id="sec:charconv"><a name="sec:4.26"><span class="sec-nr">4.26</span> <span class="sec-title">Character
236195 Conversion</span></a></h2>
237196
238 <a id="sec:charconv"></a>
197 <a name="sec:charconv"></a>
239198
240199 <p>Although I wouldn't really know why you would like to use these
241200 features, they are provided for ISO compliance.
242201
243202 <dl class="latex">
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="char_conversion/2"><strong>char_conversion</strong>(<var>+CharIn,
203 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="char_conversion/2"><strong>char_conversion</strong>(<var>+CharIn,
245204 +CharOut</var>)</a></dt>
246205 <dd class="defbody">
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>)
206 Define that term input (see <a name="idx:readterm3:1320"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>)
248207 maps each character read as
249208 <var>CharIn</var> to the character <var>CharOut</var>. Character
250209 conversion is only executed if the Prolog flag <a class="flag" href="flags.html#flag:char_conversion">char_conversion</a>
251210 is set to
252211 <code>true</code> and not inside quoted atoms or strings. The initial
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>.
212 table maps each character onto itself. See also <a name="idx:currentcharconversion2:1321"></a><a class="pred" href="charconv.html#current_char_conversion/2">current_char_conversion/2</a>.
254213 </dd>
255 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_char_conversion/2"><strong>current_char_conversion</strong>(<var>?CharIn,
214 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_char_conversion/2"><strong>current_char_conversion</strong>(<var>?CharIn,
256215 ?CharOut</var>)</a></dt>
257216 <dd class="defbody">
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>
217 Queries the current character conversion table. See <a name="idx:charconversion2:1322"></a><a class="pred" href="charconv.html#char_conversion/2">char_conversion/2</a>
259218 for details.
260219 </dd>
261220 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.19</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="streamstat.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="termrw.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:chario"><a id="sec:4.19"><span class="sec-nr">4.19</span> <span class="sec-title">Primitive
194 <h2 id="sec:chario"><a name="sec:4.19"><span class="sec-nr">4.19</span> <span class="sec-title">Primitive
236195 character I/O</span></a></h2>
237196
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.
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.
242201
243202 <dl class="latex">
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="nl/0"><strong>nl</strong></a></dt>
203 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="nl/0"><strong>nl</strong></a></dt>
245204 <dd class="defbody">
246205 Write a newline character to the current output stream. On Unix systems
247 <a id="idx:nl0:1074"></a><a class="pred" href="chario.html#nl/0">nl/0</a>
206 <a name="idx:nl0:1076"></a><a class="pred" href="chario.html#nl/0">nl/0</a>
248207 is equivalent to <code>put(10)</code>.</dd>
249 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="nl/1"><strong>nl</strong>(<var>+Stream</var>)</a></dt>
208 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="nl/1"><strong>nl</strong>(<var>+Stream</var>)</a></dt>
250209 <dd class="defbody">
251210 Write a newline to <var>Stream</var>.</dd>
252 <dt class="pubdef"><a id="put/1"><strong>put</strong>(<var>+Char</var>)</a></dt>
211 <dt class="pubdef"><a name="put/1"><strong>put</strong>(<var>+Char</var>)</a></dt>
253212 <dd class="defbody">
254213 Write <var>Char</var> to the current output stream. <var>Char</var> is
255214 either an integer expression evaluating to a character code or an atom
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,
215 of one character. Deprecated. New code should use <a name="idx:putchar1:1077"></a><a class="pred" href="chario.html#put_char/1">put_char/1</a>
216 or <a name="idx:putcode1:1078"></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,
259218 +Char</var>)</a></dt>
260219 <dd class="defbody">
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>
220 Write <var>Char</var> to <var>Stream</var>. See <a name="idx:put1:1079"></a><a class="pred" href="chario.html#put/1">put/1</a>
262221 for details.</dd>
263 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_byte/1"><strong>put_byte</strong>(<var>+Byte</var>)</a></dt>
222 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_byte/1"><strong>put_byte</strong>(<var>+Byte</var>)</a></dt>
264223 <dd class="defbody">
265224 Write a single byte to the output. <var>Byte</var> must be an integer
266225 between 0 and 255.</dd>
267 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_byte/2"><strong>put_byte</strong>(<var>+Stream,
226 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_byte/2"><strong>put_byte</strong>(<var>+Stream,
268227 +Byte</var>)</a></dt>
269228 <dd class="defbody">
270229 Write a single byte to <var>Stream</var>. <var>Byte</var> must be an
271230 integer between 0 and 255.</dd>
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_char/1"><strong>put_char</strong>(<var>+Char</var>)</a></dt>
231 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_char/1"><strong>put_char</strong>(<var>+Char</var>)</a></dt>
273232 <dd class="defbody">
274233 Write a character to the current output, obeying the encoding defined
275234 for the current output stream. Note that this may raise an exception if
276235 the encoding of the output stream cannot represent <var>Char</var>.</dd>
277 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_char/2"><strong>put_char</strong>(<var>+Stream,
236 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_char/2"><strong>put_char</strong>(<var>+Stream,
278237 +Char</var>)</a></dt>
279238 <dd class="defbody">
280239 Write a character to <var>Stream</var>, obeying the encoding defined for
281240 <var>Stream</var>. Note that this may raise an exception if the encoding
282241 of <var>Stream</var> cannot represent <var>Char</var>.</dd>
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>,
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:1080"></a><a class="pred" href="chario.html#put_char/1">put_char/1</a>,
286245 but using a <em>character code</em>. <var>Code</var> is a non-negative
287246 integer. Note that this may raise an exception if the encoding of the
288247 output stream cannot represent <var>Code</var>.</dd>
289 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="put_code/2"><strong>put_code</strong>(<var>+Stream,
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="put_code/2"><strong>put_code</strong>(<var>+Stream,
290249 +Code</var>)</a></dt>
291250 <dd class="defbody">
292 Same as <a id="idx:putcode1:1079"></a><a class="pred" href="chario.html#put_code/1">put_code/1</a>
251 Same as <a name="idx:putcode1:1081"></a><a class="pred" href="chario.html#put_code/1">put_code/1</a>
293252 but directing <var>Code</var> to <var>Stream</var>.</dd>
294 <dt class="pubdef"><a id="tab/1"><strong>tab</strong>(<var>+Amount</var>)</a></dt>
253 <dt class="pubdef"><a name="tab/1"><strong>tab</strong>(<var>+Amount</var>)</a></dt>
295254 <dd class="defbody">
296255 Write <var>Amount</var> spaces on the current output stream. <var>Amount</var>
297256 should be an expression that evaluates to a positive integer (see
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,
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,
300259 +Amount</var>)</a></dt>
301260 <dd class="defbody">
302261 Write <var>Amount</var> spaces to <var>Stream</var>.</dd>
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>
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:1082"></a><a class="pred" href="chario.html#flush_output/0">flush_output/0</a>
265 is automatically generated by <a name="idx:read1:1083"></a><a class="pred" href="termrw.html#read/1">read/1</a>
307266 and derivatives if the current input stream is <code>user</code> and the
308267 cursor is not at the left margin.</dd>
309 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="flush_output/1"><strong>flush_output</strong>(<var>+Stream</var>)</a></dt>
268 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="flush_output/1"><strong>flush_output</strong>(<var>+Stream</var>)</a></dt>
310269 <dd class="defbody">
311270 Flush output on the specified stream. The stream must be open for
312271 writing.</dd>
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>.
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:1084"></a><a class="pred" href="chario.html#flush_output/0">flush_output/[0,1]</a>.
316275 </dd>
317 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_byte/1"><strong>get_byte</strong>(<var>-Byte</var>)</a></dt>
276 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_byte/1"><strong>get_byte</strong>(<var>-Byte</var>)</a></dt>
318277 <dd class="defbody">
319278 Read the current input stream and unify the next byte with <var>Byte</var>
320279 (an integer between 0 and 255). <var>Byte</var> is unified with -1 on
321280 end of file.</dd>
322 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_byte/2"><strong>get_byte</strong>(<var>+Stream,
281 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_byte/2"><strong>get_byte</strong>(<var>+Stream,
323282 -Byte</var>)</a></dt>
324283 <dd class="defbody">
325284 Read the next byte from <var>Stream</var> and unify <var>Byte</var> with
326285 an integer between 0 and 255.</dd>
327 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_code/1"><strong>get_code</strong>(<var>-Code</var>)</a></dt>
286 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_code/1"><strong>get_code</strong>(<var>-Code</var>)</a></dt>
328287 <dd class="defbody">
329288 Read the current input stream and unify <var>Code</var> with the
330289 character code of the next character. <var>Code</var> is unified with -1
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,
290 on end of file. See also <a name="idx:getchar1:1085"></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,
333292 -Code</var>)</a></dt>
334293 <dd class="defbody">
335294 Read the next character code from <var>Stream</var>.</dd>
336 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_char/1"><strong>get_char</strong>(<var>-Char</var>)</a></dt>
295 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_char/1"><strong>get_char</strong>(<var>-Char</var>)</a></dt>
337296 <dd class="defbody">
338297 Read the current input stream and unify <var>Char</var> with the next
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>.
298 character as a one-character atom. See also <a name="idx:atomchars2:1086"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>.
340299 On end-of-file, <var>Char</var> is unified to the atom <code>end_of_file</code>.</dd>
341 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="get_char/2"><strong>get_char</strong>(<var>+Stream,
300 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="get_char/2"><strong>get_char</strong>(<var>+Stream,
342301 -Char</var>)</a></dt>
343302 <dd class="defbody">
344303 Unify <var>Char</var> with the next character from <var>Stream</var> as
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>
304 a one-character atom. See also <a name="idx:getchar2:1087"></a><a class="pred" href="chario.html#get_char/2">get_char/2</a>, <a name="idx:getbyte2:1088"></a><a class="pred" href="chario.html#get_byte/2">get_byte/2</a>
305 and <a name="idx:getcode2:1089"></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:1090"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
350309 predicate. Note that Edinburgh Prolog didn't support wide characters and
351310 therefore technically speaking
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>,
311 <a name="idx:get01:1091"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
312 should have been mapped to <a name="idx:getbyte1:1092"></a><a class="pred" href="chario.html#get_byte/1">get_byte/1</a>.
313 The intention of <a name="idx:get01:1093"></a><a class="pred" href="chario.html#get0/1">get0/1</a>,
355314 however, is to read character codes.</dd>
356 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="get0/2"><strong>get0</strong>(<var>+Stream,
315 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="get0/2"><strong>get0</strong>(<var>+Stream,
357316 -Char</var>)</a></dt>
358317 <dd class="defbody">
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>
318 Edinburgh version of the ISO <a name="idx:getcode2:1094"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
319 predicate. See also <a name="idx:get01:1095"></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>
362321 <dd class="defbody">
363322 Read the current input stream and unify the next non-blank character
364323 with <var>Char</var>. <var>Char</var> is unified with -1 on end of file.
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,
324 The predicate <a name="idx:get1:1096"></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:1097"></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,
368327 -Char</var>)</a></dt>
369328 <dd class="defbody">
370329 Read the next non-blank character from <var>Stream</var>. See also
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,
330 <a name="idx:get1:1098"></a><a class="pred" href="chario.html#get/1">get/1</a>, <a name="idx:get01:1099"></a><a class="pred" href="chario.html#get0/1">get0/1</a>
331 and <a name="idx:get02:1100"></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,
375334 -Byte</var>)</a></dt>
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,
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,
378337 -Code</var>)</a></dt>
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,
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,
381340 -Char</var>)</a></dt>
382341 <dd class="defbody">
383342 Read the next byte/code/char from the input without removing it. These
384343 predicates do not modify the stream's position or end-of-file status.
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>)
344 These predicates require a buffered stream (see <a name="idx:setstream2:1101"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>)
386345 and raise a permission error if the stream is unbuffered or the buffer
387346 is too small to hold the longest multi-byte sequence that might need to
388347 be buffered.</dd>
389 <dt class="pubdef"><a id="peek_string/3"><strong>peek_string</strong>(<var>+Stream,
348 <dt class="pubdef"><a name="peek_string/3"><strong>peek_string</strong>(<var>+Stream,
390349 +Len, -String</var>)</a></dt>
391350 <dd class="defbody">
392351 Read the next <var>Len</var> characters (if the stream is a text stream)
396355 shorter than <var>Len</var> if the stream contains less data. This
397356 predicate is intended to guess the content type of data read from
398357 non-repositionable streams.</dd>
399 <dt class="pubdef"><a id="skip/1"><strong>skip</strong>(<var>+Code</var>)</a></dt>
358 <dt class="pubdef"><a name="skip/1"><strong>skip</strong>(<var>+Code</var>)</a></dt>
400359 <dd class="defbody">
401360 Read the input until <var>Code</var> or the end of the file is
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>
361 encountered. A subsequent call to <a name="idx:getcode1:1102"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
403362 will read the first character after
404363 <var>Code</var>.</dd>
405 <dt class="pubdef"><a id="skip/2"><strong>skip</strong>(<var>+Stream,
364 <dt class="pubdef"><a name="skip/2"><strong>skip</strong>(<var>+Stream,
406365 +Code</var>)</a></dt>
407366 <dd class="defbody">
408 Skip input (as <a id="idx:skip1:1101"></a><a class="pred" href="chario.html#skip/1">skip/1</a>)
367 Skip input (as <a name="idx:skip1:1103"></a><a class="pred" href="chario.html#skip/1">skip/1</a>)
409368 on <var>Stream</var>.</dd>
410 <dt class="pubdef"><a id="get_single_char/1"><strong>get_single_char</strong>(<var>-Code</var>)</a></dt>
369 <dt class="pubdef"><a name="get_single_char/1"><strong>get_single_char</strong>(<var>-Code</var>)</a></dt>
411370 <dd class="defbody">
412371 Get a single character from input stream `user' (regardless of the
413 current input stream). Unlike <a id="idx:getcode1:1102"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>,
372 current input stream). Unlike <a name="idx:getcode1:1104"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>,
414373 this predicate does not wait for a return. The character is not echoed
415374 to the user's terminal. This predicate is meant for keyboard menu
416375 selection, etc. If SWI-Prolog was started with the <strong>-tty</strong>
417376 option this predicate reads an entire line of input and returns the
418377 first non-blank character on this line, or the character code of the
419378 newline (10) if the entire line consisted of blank characters.</dd>
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>
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>
421380 <dd class="defbody">
422381 Succeeds after the last character of the current input stream has been
423382 read. Also succeeds if there is no valid current input stream.</dd>
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>
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>
425384 <dd class="defbody">
426385 Succeeds after the last character of the named stream is read, or
427386 <var>Stream</var> is not a valid input stream. The end-of-stream test is
428387 only available on buffered input streams (unbuffered input streams are
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>
388 rarely used; see <a name="idx:open4:1105"></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>
431390 <dd class="defbody">
432391 Set the size of the file opened as <var>Stream</var> to the current file
433392 position. This is typically used in combination with the open-mode <code>update</code>.</dd>
434 <dt class="pubdef"><a id="copy_stream_data/3"><strong>copy_stream_data</strong>(<var>+StreamIn,
393 <dt class="pubdef"><a name="copy_stream_data/3"><strong>copy_stream_data</strong>(<var>+StreamIn,
435394 +StreamOut, +Len</var>)</a></dt>
436395 <dd class="defbody">
437396 Copy <var>Len</var> codes from <var>StreamIn</var> to <var>StreamOut</var>.
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>
397 Note that the copy is done using the semantics of <a name="idx:getcode2:1106"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
439398 and
440 <a id="idx:putcode2:1105"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>,
399 <a name="idx:putcode2:1107"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>,
441400 taking care of possibly recoding that needs to take place between two
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,
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,
445403 +StreamOut</var>)</a></dt>
446404 <dd class="defbody">
447405 Copy all (remaining) data from <var>StreamIn</var> to
448406 <var>StreamOut</var>.</dd>
449 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="fill_buffer/1"><strong>fill_buffer</strong>(<var>+Stream</var>)</a></dt>
407 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="fill_buffer/1"><strong>fill_buffer</strong>(<var>+Stream</var>)</a></dt>
450408 <dd class="defbody">
451409 Fill the <var>Stream</var>'s input buffer. Subsequent calls try to read
452410 more input until the buffer is completely filled. This predicate is used
453 together with <a id="idx:readpendingcodes3:1106"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>
411 together with <a name="idx:readpendingcodes3:1108"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>
454412 to process input with minimal buffering.</dd>
455 <dt class="pubdef"><a id="read_pending_codes/3"><strong>read_pending_codes</strong>(<var>+StreamIn,
413 <dt class="pubdef"><a name="read_pending_codes/3"><strong>read_pending_codes</strong>(<var>+StreamIn,
456414 -Codes, ?Tail</var>)</a></dt>
457415 <dd class="defbody">
458416 Read input pending in the input buffer of <var>StreamIn</var> and return
467425 input from files and streams using a DCG.
468426
469427 <p>The following code fragment realises efficient non-blocking copying
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>
428 of data from an input to an output stream. The <a name="idx:atendofstream1:1109"></a><a class="pred" href="chario.html#at_end_of_stream/1">at_end_of_stream/1</a>
471429 call checks for end-of-stream and fills the input buffer. Note that the
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>
430 use of a <a name="idx:getcode2:1110"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
431 and <a name="idx:putcode2:1111"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>
432 based loop requires a <a name="idx:flushoutput1:1112"></a><a class="pred" href="chario.html#flush_output/1">flush_output/1</a>
433 call after <em>each</em> <a name="idx:putcode2:1113"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>.
434 The <a name="idx:copystreamdata2:1114"></a><a class="pred" href="chario.html#copy_stream_data/2">copy_stream_data/2</a>
477435 does not allow for inspection of the copied data and suffers from the
478436 same buffering issues.
479437
493451 </pre>
494452
495453 </dd>
496 <dt class="pubdef"><a id="read_pending_chars/3"><strong>read_pending_chars</strong>(<var>+StreamIn,
454 <dt class="pubdef"><a name="read_pending_chars/3"><strong>read_pending_chars</strong>(<var>+StreamIn,
497455 -Chars, ?Tail</var>)</a></dt>
498456 <dd class="defbody">
499 As <a id="idx:readpendingcodes3:1113"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>,
457 As <a name="idx:readpendingcodes3:1115"></a><a class="pred" href="chario.html#read_pending_codes/3">read_pending_codes/3</a>,
500458 but returns a difference list of one-character atoms.
501459 </dd>
502460 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="preddesc.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="consulting.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:chars"><a id="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">Character
194 <h2 id="sec:chars"><a name="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">Character
236195 representation</span></a></h2>
237196
238 <a id="sec:chars"></a>
197 <a name="sec:chars"></a>
239198
240199 <p>In traditional (Edinburgh) Prolog, characters are represented using
241200 <em>character codes</em>. Character codes are integer indices into a
245204 8859-1) is applicable to many Western languages.
246205
247206 <p>ISO Prolog introduces three types, two of which are used for
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>).
207 characters and one for accessing binary streams (see <a name="idx:open4:342"></a><a class="pred" href="IO.html#open/4">open/4</a>).
249208 These types are:
250209
251210 <p>
253212 <li><i>code</i><br>
254213 A <em>character code</em> is an integer representing a single character.
255214 As files may use multi-byte encoding for supporting different character
256 sets (<a id="idx:utf8:341">utf-8</a> encoding for example), reading a
215 sets (<a name="idx:utf8:343">utf-8</a> encoding for example), reading a
257216 code from a text file is in general not the same as reading a byte.
258217 <li><i>char</i><br>
259218 Alternatively, characters may be represented as
265224 </ul>
266225
267226 <p>In SWI-Prolog, character codes are <em>always</em> the Unicode
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>
227 equivalent of the encoding. That is, if <a name="idx:getcode1:344"></a><a class="pred" href="chario.html#get_code/1">get_code/1</a>
269228 reads from a stream encoded as
270229 <code>KOI8-R</code> (used for the Cyrillic alphabet), it returns the
271230 corresponding Unicode code points. Similarly, assembling or
272 disassembling atoms using <a id="idx:atomcodes2:343"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
231 disassembling atoms using <a name="idx:atomcodes2:345"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
273232 interprets the codes as Unicode points. See
274 <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a> for
275 details.
233 <a class="sec" href="widechars.html">section 2.19.1</a> for details.
276234
277235 <p>To ease the pain of the two character representations (code and
278236 char), SWI-Prolog's built-in predicates dealing with character data work
289247
290248 <p>The two character representations are handled by a large number of
291249 built-in predicates, all of which are ISO-compatible. For converting
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>.
250 between code and character there is <a name="idx:charcode2:346"></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:347"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>, <a name="idx:atomcodes2:348"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>,
252 <a name="idx:numberchars2:349"></a><a class="pred" href="manipatom.html#number_chars/2">number_chars/2</a>
253 and <a name="idx:numbercodes2:350"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>.
296254 For character I/O on streams there are
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>
255 <a name="idx:getchar12:351"></a><a class="pred" href="chario.html#get_char/1">get_char/[1,2]</a>, <a name="idx:getcode12:352"></a><a class="pred" href="chario.html#get_code/1">get_code/[1,2]</a>, <a name="idx:getbyte12:353"></a><a class="pred" href="chario.html#get_byte/1">get_byte/[1,2]</a>, <a name="idx:peekchar12:354"></a><a class="pred" href="chario.html#peek_char/1">peek_char/[1,2]</a>,
256 <a name="idx:peekcode12:355"></a><a class="pred" href="chario.html#peek_code/1">peek_code/[1,2]</a>, <a name="idx:peekbyte12:356"></a><a class="pred" href="chario.html#peek_byte/1">peek_byte/[1,2]</a>, <a name="idx:putcode12:357"></a><a class="pred" href="chario.html#put_code/1">put_code/[1,2]</a>, <a name="idx:putchar12:358"></a><a class="pred" href="chario.html#put_char/1">put_char/[1,2]</a>
299257 and
300 <a id="idx:putbyte12:357"></a><a class="pred" href="chario.html#put_byte/1">put_byte/[1,2]</a>.
258 <a name="idx:putbyte12:359"></a><a class="pred" href="chario.html#put_byte/1">put_byte/[1,2]</a>.
301259 The Prolog flag <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>
302260 controls how text between double quotes is interpreted.
303261
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="broadcast.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="check.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:charsio"><a id="sec:A.5"><span class="sec-nr">A.5</span> <span class="sec-title">library(charsio):
194 <h2 id="sec:charsio"><a name="sec:A.5"><span class="sec-nr">A.5</span> <span class="sec-title">library(charsio):
236195 I/O on Lists of Character Codes</span></a></h2>
237196
238 <p><a id="sec:charsio"></a>
197 <p><a name="sec:charsio"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">Compatibility</dt>
252211 can even be replaced by ISO standard predicates.
253212
254213 <dl class="latex">
255 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="format_to_chars/3"><strong>format_to_chars</strong>(<var>+Format,
214 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="format_to_chars/3"><strong>format_to_chars</strong>(<var>+Format,
256215 +Args, -Codes</var>)</a></dt>
257216 <dd class="defbody">
258217 Use <a class="pred" href="format.html#format/2">format/2</a> to write to
259218 a list of character codes.</dd>
260 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="format_to_chars/4"><strong>format_to_chars</strong>(<var>+Format,
219 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="format_to_chars/4"><strong>format_to_chars</strong>(<var>+Format,
261220 +Args, -Codes, ?Tail</var>)</a></dt>
262221 <dd class="defbody">
263222 Use <a class="pred" href="format.html#format/2">format/2</a> to write to
264223 a difference list of character codes.</dd>
265 <dt class="pubdef"><a id="write_to_chars/2"><strong>write_to_chars</strong>(<var>+Term,
224 <dt class="pubdef"><a name="write_to_chars/2"><strong>write_to_chars</strong>(<var>+Term,
266225 -Codes</var>)</a></dt>
267226 <dd class="defbody">
268227 Write a term to a code list. True when <var>Codes</var> is a list of
269228 character codes written by <a class="pred" href="termrw.html#write/1">write/1</a>
270229 on <var>Term</var>.</dd>
271 <dt class="pubdef"><a id="write_to_chars/3"><strong>write_to_chars</strong>(<var>+Term,
230 <dt class="pubdef"><a name="write_to_chars/3"><strong>write_to_chars</strong>(<var>+Term,
272231 -Codes, ?Tail</var>)</a></dt>
273232 <dd class="defbody">
274233 Write a term to a code list. <var>Codes</var><code>\</code><var>Tail</var>
275234 is a difference list of character codes produced by <a class="pred" href="termrw.html#write/1">write/1</a>
276235 on <var>Term</var>.</dd>
277 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="atom_to_chars/2"><strong>atom_to_chars</strong>(<var>+Atom,
236 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="atom_to_chars/2"><strong>atom_to_chars</strong>(<var>+Atom,
278237 -Codes</var>)</a></dt>
279238 <dd class="defbody">
280239 Convert <var>Atom</var> into a list of character codes.
287246 </dl>
288247
289248 </dd>
290 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="atom_to_chars/3"><strong>atom_to_chars</strong>(<var>+Atom,
249 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="atom_to_chars/3"><strong>atom_to_chars</strong>(<var>+Atom,
291250 -Codes, ?Tail</var>)</a></dt>
292251 <dd class="defbody">
293252 Convert <var>Atom</var> into a difference list of character codes.</dd>
294 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="number_to_chars/2"><strong>number_to_chars</strong>(<var>+Number,
253 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="number_to_chars/2"><strong>number_to_chars</strong>(<var>+Number,
295254 -Codes</var>)</a></dt>
296255 <dd class="defbody">
297256 Convert Atom into a list of character codes.
304263 </dl>
305264
306265 </dd>
307 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="number_to_chars/3"><strong>number_to_chars</strong>(<var>+Number,
266 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="number_to_chars/3"><strong>number_to_chars</strong>(<var>+Number,
308267 -Codes, ?Tail</var>)</a></dt>
309268 <dd class="defbody">
310269 Convert <var>Number</var> into a difference list of character codes.</dd>
311 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="read_from_chars/2"><strong>read_from_chars</strong>(<var>+Codes,
270 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="read_from_chars/2"><strong>read_from_chars</strong>(<var>+Codes,
312271 -Term</var>)</a></dt>
313272 <dd class="defbody">
314273 Read <var>Codes</var> into <var>Term</var>.
322281 </dl>
323282
324283 </dd>
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,
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,
326285 -Term, +Options</var>)</a></dt>
327286 <dd class="defbody">
328287 Read <var>Codes</var> into <var>Term</var>. <var>Options</var> are
336295 </dl>
337296
338297 </dd>
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="open_chars_stream/2"><strong>open_chars_stream</strong>(<var>+Codes,
298 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="open_chars_stream/2"><strong>open_chars_stream</strong>(<var>+Codes,
340299 -Stream</var>)</a></dt>
341300 <dd class="defbody">
342301 Open <var>Codes</var> as an input stream.
349308 </dl>
350309
351310 </dd>
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,
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,
353312 -Codes</var>)</a></dt>
354313 <dd class="defbody">
355314 Run <var>Goal</var> as with <a class="pred" href="metacall.html#once/1">once/1</a>.
356315 Output written to <code>current_output</code> is collected in <var>Codes</var>.</dd>
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,
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,
358317 -Codes, ?Tail</var>)</a></dt>
359318 <dd class="defbody">
360319 Run <var>Goal</var> as with <a class="pred" href="metacall.html#once/1">once/1</a>.
361320 Output written to <code>current_output</code> is collected in <var>Codes</var><code>\</code><var>Tail</var>.</dd>
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,
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,
363322 -Stream, -Codes, ?Tail</var>)</a></dt>
364323 <dd class="defbody">
365324 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.7.4 Reference Manual: Section 4.24</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="locale.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="operators.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:chartype"><a id="sec:4.24"><span class="sec-nr">4.24</span> <span class="sec-title">Character
194 <h2 id="sec:chartype"><a name="sec:4.24"><span class="sec-nr">4.24</span> <span class="sec-title">Character
236195 properties</span></a></h2>
237196
238 <a id="sec:chartype"></a>
197 <a name="sec:chartype"></a>
239198
240199 <p>SWI-Prolog offers two comprehensive predicates for classifying
241200 characters and character codes. These predicates are defined as built-in
245204
246205 <p>In addition, there is the library <code>library(ctypes)</code>
247206 providing compatibility with some other Prolog systems. The predicates
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>.
207 of this library are defined in terms of <a name="idx:codetype2:1294"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>.
249208
250209 <dl class="latex">
251 <dt class="pubdef"><a id="char_type/2"><strong>char_type</strong>(<var>?Char,
210 <dt class="pubdef"><a name="char_type/2"><strong>char_type</strong>(<var>?Char,
252211 ?Type</var>)</a></dt>
253212 <dd class="defbody">
254213 Tests or generates alternative <var>Type</var>s or <var>Char</var>s. The
326285 <dd class="defbody">
327286 <var>Char</var> is a lowercase version of <var>Upper</var>. For
328287 non-letters, or letter without case, <var>Char</var> and <var>Lower</var>
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>.
288 are the same. See also <a name="idx:upcaseatom2:1295"></a><a class="pred" href="chartype.html#upcase_atom/2">upcase_atom/2</a>
289 and <a name="idx:downcaseatom2:1296"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>.
331290 </dd>
332291 <dt><strong>upper</strong></dt>
333292 <dd class="defbody">
343302 <dd class="defbody">
344303 <var>Char</var> is an uppercase version of <var>Lower</var>. For
345304 non-letters, or letter without case, <var>Char</var> and <var>Lower</var>
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>.
305 are the same. See also <a name="idx:upcaseatom2:1297"></a><a class="pred" href="chartype.html#upcase_atom/2">upcase_atom/2</a>
306 and <a name="idx:downcaseatom2:1298"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>.
348307 </dd>
349308 <dt><strong>punct</strong></dt>
350309 <dd class="defbody">
402361 </dl>
403362
404363 </dd>
405 <dt class="pubdef"><a id="code_type/2"><strong>code_type</strong>(<var>?Code,
364 <dt class="pubdef"><a name="code_type/2"><strong>code_type</strong>(<var>?Code,
406365 ?Type</var>)</a></dt>
407366 <dd class="defbody">
408 As <a id="idx:chartype2:1297"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>,
367 As <a name="idx:chartype2:1299"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>,
409368 but uses character codes rather than one-character atoms. Please note
410369 that both predicates are as flexible as possible. They handle either
411370 representation if the argument is instantiated and will instantiate only
412371 with an integer code or a one-character atom, depending of the version
413372 used. See also the Prolog flag
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>.
373 <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>, <a name="idx:atomchars2:1300"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
374 and <a name="idx:atomcodes2:1301"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.
416375 </dd>
417376 </dl>
418377
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
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
420379 conversion</span></a></h3>
421380
422 <a id="sec:case"></a>
381 <a name="sec:case"></a>
423382
424383 <p>There is nothing in the Prolog standard for converting case in
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>
384 textual data. The SWI-Prolog predicates <a name="idx:codetype2:1302"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>
385 and <a name="idx:chartype2:1303"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
427386 can be used to test and convert individual characters. We have started
428387 some additional support:
429388
430389 <dl class="latex">
431 <dt class="pubdef"><a id="downcase_atom/2"><strong>downcase_atom</strong>(<var>+AnyCase,
390 <dt class="pubdef"><a name="downcase_atom/2"><strong>downcase_atom</strong>(<var>+AnyCase,
432391 -LowerCase</var>)</a></dt>
433392 <dd class="defbody">
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>
393 Converts the characters of <var>AnyCase</var> into lowercase as <a name="idx:chartype2:1304"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
435394 does (i.e. based on the defined <em>locale</em> if Prolog provides
436395 locale support on the hosting platform) and unifies the lowercase atom
437396 with <var>LowerCase</var>.</dd>
438 <dt class="pubdef"><a id="upcase_atom/2"><strong>upcase_atom</strong>(<var>+AnyCase,
397 <dt class="pubdef"><a name="upcase_atom/2"><strong>upcase_atom</strong>(<var>+AnyCase,
439398 -UpperCase</var>)</a></dt>
440399 <dd class="defbody">
441 Converts, similar to <a id="idx:downcaseatom2:1303"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>,
400 Converts, similar to <a name="idx:downcaseatom2:1305"></a><a class="pred" href="chartype.html#downcase_atom/2">downcase_atom/2</a>,
442401 an atom to uppercase.
443402 </dd>
444403 </dl>
445404
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
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
447406 space normalization</span></a></h3>
448407
449 <a id="sec:whitespace"></a>
408 <a name="sec:whitespace"></a>
450409
451410 <dl class="latex">
452 <dt class="pubdef"><a id="normalize_space/2"><strong>normalize_space</strong>(<var>-Out,
411 <dt class="pubdef"><a name="normalize_space/2"><strong>normalize_space</strong>(<var>-Out,
453412 +In</var>)</a></dt>
454413 <dd class="defbody">
455414 Normalize white space in <var>In</var>. All leading and trailing white
456415 space is removed. All non-empty sequences for Unicode white space
457416 characters are replaced by a single space (<code>\u0020</code>)
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>.
417 character. <var>Out</var> uses the same conventions as <a name="idx:withoutputto2:1306"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
418 and <a name="idx:format3:1307"></a><a class="pred" href="format.html#format/3">format/3</a>.
460419 </dd>
461420 </dl>
462421
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
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
464423 comparison</span></a></h3>
465424
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
425 <a name="sec:collate"></a>
426
427 <p><a name="idx:locale:1308"></a><a name="idx:collate:1309"></a><a name="idx:comparelanguagespecific:1310"></a>This
469428 section deals with predicates for language-specific string comparison
470429 operations.
471430
472431 <dl class="latex">
473 <dt class="pubdef"><a id="collation_key/2"><strong>collation_key</strong>(<var>+Atom,
432 <dt class="pubdef"><a name="collation_key/2"><strong>collation_key</strong>(<var>+Atom,
474433 -Key</var>)</a></dt>
475434 <dd class="defbody">
476435 Create a <var>Key</var> from <var>Atom</var> for locale-specific
479438 is alphabetically smaller than <var>B</var> using the sort order of the
480439 current locale.
481440
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>
441 <p>The predicate <a name="idx:collationkey2:1311"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
442 is used by <a name="idx:localesort2:1312"></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:1313"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
485444 as an example of using this call.
486445
487446 <p>The <var>Key</var> is an implementation-defined and generally
488447 unreadable string. On systems that do not support locale handling, <var>Key</var>
489448 is simply unified with <var>Atom</var>.</dd>
490 <dt class="pubdef"><a id="locale_sort/2"><strong>locale_sort</strong>(<var>+List,
449 <dt class="pubdef"><a name="locale_sort/2"><strong>locale_sort</strong>(<var>+List,
491450 -Sorted</var>)</a></dt>
492451 <dd class="defbody">
493452 Sort a list of atoms using the current locale. <var>List</var> is a list
494 of atoms or string objects (see <a class="sec" href="strings.html#sec:5.2">section
453 of atoms or string objects (see <a class="sec" href="strings.html">section
495454 5.2</a>). <var>Sorted</var> is unified with a list containing all atoms
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>
455 of <var>List</var>, sorted to the rules of the current locale. See also <a name="idx:collationkey2:1314"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
497456 and
498 <a id="idx:setlocale3:1313"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>.
457 <a name="idx:setlocale3:1315"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>.
499458 </dd>
500459 </dl>
501460
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="charsio.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="clpb.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:check"><a id="sec:A.6"><span class="sec-nr">A.6</span> <span class="sec-title">library(check):
194 <h2 id="sec:check"><a name="sec:A.6"><span class="sec-nr">A.6</span> <span class="sec-title">library(check):
236195 Consistency checking</span></a></h2>
237196
238 <p><a id="sec:check"></a>
197 <p><a name="sec:check"></a>
239198
240199 <dl class="tags">
241200 <dt class="mtag">See also</dt>
255214 to find undefined predicates in `user' modules.
256215
257216 <dl class="latex">
258 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="check/0"><strong>check</strong></a></dt>
217 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="check/0"><strong>check</strong></a></dt>
259218 <dd class="defbody">
260219 Run all consistency checks defined by <a class="pred" href="check.html#checker/2">checker/2</a>.
261220 Checks enabled by default are:
274233 lists predicates that will be defined at runtime using the autoloader.
275234 </ul>
276235 </dd>
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>
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>
279238 <dd class="defbody">
280239 Report undefined predicates. This predicate finds undefined predciates
281240 by decompiling and analyzing the body of all clauses.
300259 </dl>
301260
302261 </dd>
303 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_autoload/0"><strong>list_autoload</strong></a></dt>
262 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_autoload/0"><strong>list_autoload</strong></a></dt>
304263 <dd class="defbody">
305264 Report predicates that may be auto-loaded. These are predicates that are
306265 not defined, but will be loaded on demand if referenced.
318277 </dl>
319278
320279 </dd>
321 <dt class="pubdef"><a id="list_redefined/0"><strong>list_redefined</strong></a></dt>
280 <dt class="pubdef"><a name="list_redefined/0"><strong>list_redefined</strong></a></dt>
322281 <dd class="defbody">
323282 Lists predicates that are defined in the global module <code>user</code>
324283 as well as in a normal module; that is, predicates for which the local
325284 definition overrules the global default definition.</dd>
326 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_void_declarations/0"><strong>list_void_declarations</strong></a></dt>
285 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_void_declarations/0"><strong>list_void_declarations</strong></a></dt>
327286 <dd class="defbody">
328287 List predicates that have declared attributes, but no clauses.</dd>
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>
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>
331290 <dd class="defbody">
332291 List goals that trivially fail because there is no matching clause. <var>Options</var>:
333292
341300 </dl>
342301
343302 </dd>
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>
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>
345304 <dd class="defbody">
346305 Multifile hook that tells <a class="pred" href="check.html#list_trivial_fails/0">list_trivial_fails/0</a>
347306 to accept <var>Goal</var> as valid.</dd>
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>
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>
350309 <dd class="defbody">
351310 List strings that appear in clauses. This predicate is used to find
352311 portability issues for changing the Prolog flag
370329 </dl>
371330
372331 </dd>
373 <dt class="multidef"><span class="pred-tag">[multifile]</span><a id="string_predicate/1"><strong>string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
332 <dt class="multidef"><span class="pred-tag">[multifile]</span><a name="string_predicate/1"><strong>string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
374333 <dd class="defbody">
375334 Multifile hook to disable <a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
376335 on the given predicate. This is typically used for facts that store
377336 strings.</dd>
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>
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>
379338 <dd class="defbody">
380339 Multifile hook that qualifies <var>Goal</var> as valid for <a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
381340 For example, <code>format("Hello world~n")</code> is considered proper
382341 use of string constants.</dd>
383 <dt class="multidef"><span class="pred-tag">[multifile]</span><a id="checker/2"><strong>checker</strong>(<var>:Goal,
342 <dt class="multidef"><span class="pred-tag">[multifile]</span><a name="checker/2"><strong>checker</strong>(<var>:Goal,
384343 +Message:text</var>)</a></dt>
385344 <dd class="defbody">
386345 Register code validation routines. Each clause defines a <var>Goal</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="coroutining.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="chrintro.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:chr"><a id="sec:8"><span class="sec-nr">8</span> <span class="sec-title">CHR:
194 <h1 id="sec:chr"><a name="sec:8"><span class="sec-nr">8</span> <span class="sec-title">CHR:
236195 Constraint Handling Rules</span></a></h1>
237196
238 <a id="sec:chr"></a>
197 <a name="sec:chr"></a>
239198
240199 <p>This chapter is written by Tom Schrijvers, K.U. Leuven, and
241200 adjustments by Jan Wielemaker.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="chr.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="SyntaxAndSemantics.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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
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
238197 committed-choice rule-based language embedded in Prolog. It is designed
239198 for writing constraint solvers and is particularly useful for providing
240199 application-specific constraints. It has been used in many kinds of
252211 2009</a></cite>. More background on CHR can be found at
253212 <cite><a class="cite" href="Bibliography.html#chrSite">Fr&uuml;hwirth,</a></cite>.
254213
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
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
258217 8.3</a> deals with practical issues of writing and compiling Prolog
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
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
261220 8.4.3</a> provides a few useful predicates to inspect the constraint
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
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
264223 8.6</a> describes some compatibility issues with older versions of this
265 system and SICStus' CHR system. Finally, <a class="sec" href="guidelines.html#sec:8.7">section
224 system and SICStus' CHR system. Finally, <a class="sec" href="guidelines.html">section
266225 8.7</a> concludes with a few practical guidelines for using CHR.
267226
268227 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="modulecompat.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="attvar.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:clp"><a id="sec:7"><span class="sec-nr">7</span> <span class="sec-title">Constraint
194 <h1 id="sec:clp"><a name="sec:7"><span class="sec-nr">7</span> <span class="sec-title">Constraint
236195 Logic Programming</span></a></h1>
237196
238 <a id="sec:clp"></a>
239 <a id="idx:CLP:1763"></a><a id="idx:constraintprogramming:1764"></a>This
197 <a name="sec:clp"></a>
198 <a name="idx:CLP:1762"></a><a name="idx:constraintprogramming:1763"></a>This
240199 chapter describes the extensions primarily designed to support
241200 <b>constraint logic programming</b>&nbsp;(CLP), an important declarative
242201 programming paradigm with countless practical applications.
244203 <p>CLP(<var>X</var>) stands for constraint logic programming over the
245204 domain&nbsp;<var>X</var>. Plain Prolog can be regarded as&nbsp;CLP(<var>H</var>),
246205 where <var>H</var> stands for
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>
206 <i>Herbrand&nbsp;terms</i><a name="idx:Herbrandterm:1764"></a>. Over
207 this domain,
208 <a class="pred" href="compare.html#=/2">=/2</a> and <a name="idx:dif2:1765"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
250209 are the most important constraints that express, respectively, equality
251210 and disequality of&nbsp;terms. Plain Prolog can thus be regarded as a
252211 special&nbsp;case of&nbsp;CLP.
255214
256215 <p>
257216 <ul class="latex">
258 <li>CLP(FD) for <b>integers</b> (<a class="sec" href="clpfd.html#sec:A.8">section
217 <li>CLP(FD) for <b>integers</b> (<a class="sec" href="clpfd.html">section
259218 A.8</a>)
260 <li>CLP(B) for <b>Boolean</b> variables (<a class="sec" href="clpb.html#sec:A.7">section
219 <li>CLP(B) for <b>Boolean</b> variables (<a class="sec" href="clpb.html">section
261220 A.7</a>)
262 <li>CLP(Q) for <b>rational</b> numbers (<a class="sec" href="clpqr.html#sec:A.9">section
221 <li>CLP(Q) for <b>rational</b> numbers (<a class="sec" href="clpqr.html">section
263222 A.9</a>)
264 <li>CLP(R) for <b>floating point</b> numbers (<a class="sec" href="clpqr.html#sec:A.9">section
223 <li>CLP(R) for <b>floating point</b> numbers (<a class="sec" href="clpqr.html">section
265224 A.9</a>).
266225 </ul>
267226
268 <p>In addition, CHR (<a class="sec" href="chr.html#sec:8">chapter 8</a>)
227 <p>In addition, CHR (<a class="sec" href="chr.html">chapter 8</a>)
269228 provides a general purpose constraint handling language to reason over
270229 user-defined constraints.
271230
287246 it, both <i>before</i> and also <i>during</i> any search for concrete
288247 solutions. Using available information to prune parts of the search
289248 space is called constraint
290 <em>propagation</em><a id="idx:propagation:1767"></a>, and it is
249 <em>propagation</em><a name="idx:propagation:1766"></a>, and it is
291250 performed automatically by the available constraint solvers for their
292251 respective domains. This feature can significantly increase the
293252 <i>performance</i> of your programs.
305264 the constraint solver combines the existing knowledge to infer that <var>X</var>
306265 is either 1 or&nbsp;2 (see below). To obtain concrete values for&nbsp;<var>X</var>,
307266 you can ask the solver to <em>label</em>&nbsp;<var>X</var> and produce 1
308 and 2 on backtracking. See&nbsp;<a class="sec" href="clpfd.html#sec:A.8">section
267 and 2 on backtracking. See&nbsp;<a class="sec" href="clpfd.html">section
309268 A.8</a>.
310269
311270 <pre class="code">
329288 two-dimensional space.
330289
331290 <p>Using constraints therefore makes your program more
332 <em>declarative</em><a id="idx:declarative:1768"></a> in that it frees
291 <em>declarative</em><a name="idx:declarative:1767"></a> in that it frees
333292 you from some procedural aspects and limitations of Prolog.
334293
335294 <p>When working with constraints, keep in mind the following:
341300 goal that is delayed may prematurely prune the search space, because the
342301 truth of delayed goals is not yet established. There are several ways to
343302 avoid cuts in constraint logic programs, retaining both generality and
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>,
303 determinism of your programs. See for example <a name="idx:zcompare3:1768"></a><a class="pred" href="clpfd.html#zcompare/3">zcompare/3</a>.
304 <li>Term-copying operations (<a name="idx:assertz1:1769"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:retract1:1770"></a><a class="pred" href="db.html#retract/1">retract/1</a>, <a name="idx:findall3:1771"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
305 <a name="idx:copyterm2:1772"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
347306 etc.) generally also copy constraints. The effect varies from ok, silent
348307 copying of huge constraint networks to violations of the internal
349308 consistency of constraint networks. As a rule of thumb, copying terms
350309 holding attributes must be deprecated. If you need to reason about 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>
310 term that is involved in constraints, use <a name="idx:copyterm3:1773"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>
352311 to obtain the constraints as Prolog goals, and use these goals for
353312 further processing.
354313 </ul>
355314
356315 <p>All of the mentioned constraint solvers are implemented using the
357 attributed variables interface described in&nbsp;<a class="sec" href="attvar.html#sec:7.1">section
316 attributed variables interface described in&nbsp;<a class="sec" href="attvar.html">section
358317 7.1</a>. These are lower-level predicates that are mainly intended for
359318 library authors, not for typical Prolog programmers.
360319
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="check.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="clpfd.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:clpb"><a id="sec:A.7"><span class="sec-nr">A.7</span> <span class="sec-title">library(clpb):
194 <h2 id="sec:clpb"><a name="sec:A.7"><span class="sec-nr">A.7</span> <span class="sec-title">library(clpb):
236195 CLP(B): Constraint Logic Programming over Boolean Variables</span></a></h2>
237196
238 <a id="sec:clpb"></a>
239
240 <p><a id="sec:clpb"></a>
197 <a name="sec:clpb"></a>
198
199 <p><a name="sec:clpb"></a>
241200
242201 <dl class="tags">
243202 <dt class="tag">author</dt>
244203 <dd>
245 <a class="url" href="https://www.metalevel.at">Markus Triska</a>
204 https://www.metalevel.atMarkus Triska
246205 </dd>
247206 </dl>
248207
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>
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>
252211
253212 <p>This library provides CLP(B), Constraint Logic Programming over
254213 Boolean variables. It can be used to model and solve combinatorial
255214 problems such as verification, allocation and covering tasks.
256215
257 <p>CLP(B) is an instance of the general CLP(<i>X</i>) scheme (<a class="sec" href="clp.html#sec:7">section
216 <p>CLP(B) is an instance of the general CLP(<i>X</i>) scheme (<a class="sec" href="clp.html">section
258217 7</a>), extending logic programming with reasoning over specialised
259218 domains.
260219
262221 Diagrams (BDDs).
263222
264223 <p>Benchmarks and usage examples of this library are available from:
265 <a class="url" href="https://www.metalevel.at/clpb/"><b>https:<code>//</code>www.metalevel.at/clpb/</b></a>
224 https://www.metalevel.at/clpb/<b>https:<code>//</code>www.metalevel.at/clpb/</b>
266225
267226 <p>We recommend the following reference for citing this library in
268227 scientific publications:
281240 </pre>
282241
283242 <p>The paper is available from
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
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
287246 expressions</span></a></h3>
288247
289 <p><a id="sec:clpb-exprs"></a>
248 <p><a name="sec:clpb-exprs"></a>
290249
291250 <p>A <i>Boolean expression</i> is one of:
292251 <blockquote>
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
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
303263 quantification </td></tr>
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
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
306266 (same as #) </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>
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>
316278 </table>
317279 </blockquote>
318280
332294 appear on the right-hand side of equations. Therefore, they can be used
333295 to express functional dependencies on input variables.
334296
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
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
336298 predicates</span></a></h3>
337299
338 <p><a id="sec:clpb-interface"></a>
300 <p><a name="sec:clpb-interface"></a>
339301
340302 <p>The most frequently used CLP(B) predicates are:
341303
361323 <p>The unification of a CLP(B) variable <i>X</i> with a term <i>T</i> is
362324 equivalent to posting the constraint <code>sat(X=:=T)</code>.
363325
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>
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>
367329
368330 <p>Here is an example session with a few queries and their answers:
369331
404366 last example illustrates that when applicable, remaining variables are
405367 expressed as functions of universally quantified variables.
406368
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
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
408370 BDDs</span></a></h3>
409371
410 <p><a id="sec:clpb-residual-goals"></a>
372 <p><a name="sec:clpb-residual-goals"></a>
411373
412374 <p>By default, CLP(B) residual goals appear in (approximately) algebraic
413375 normal form (ANF). This projection is often computationally expensive.
441403 node(2)- (v(X, 1)-&gt;false;true).
442404 </pre>
443405
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
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
445407 monotonic CLP(B)</span></a></h3>
446408
447 <p><a id="sec:clpb-monotonic"></a>
409 <p><a name="sec:clpb-monotonic"></a>
448410
449411 <p>In the default execution mode, CLP(B) constraints are <i>not</i>
450412 monotonic. This means that <i>adding</i> constraints can yield new
459421 </pre>
460422
461423 <p>This behaviour is highly problematic from a logical point of view,
462 and it may render <a class="url" href="https://www.metalevel.at/prolog/debugging"><b>declarative
463 debugging</b></a> techniques inapplicable.
424 and it may render https://www.metalevel.at/prolog/debugging<b>declarative
425 debugging</b> techniques inapplicable.
464426
465427 <p>Set the flag <code>clpb_monotonic</code> to <code>true</code> to make
466428 CLP(B) <b>monotonic</b>. If this mode is enabled, then you must wrap
474436 X = 0.
475437 </pre>
476438
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:
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:
478440 Pigeons</span></a></h3>
479441
480 <p><a id="sec:clpb-pigeons"></a>
442 <p><a name="sec:clpb-pigeons"></a>
481443
482444 <p>In this example, we are attempting to place <i>I</i> pigeons into <i>J</i>
483445 holes in such a way that each hole contains at most one pigeon. One
486448 interesting aspect is that this task has no short resolution refutations
487449 in general.
488450
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.
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.
492454
493455 <pre class="code">
494456 :- use_module(library(clpb)).
520482 [0, 1, 0].
521483 </pre>
522484
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:
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:
524486 Boolean circuit</span></a></h3>
525487
526 <p><a id="sec:clpb-circuit"></a>
488 <p><a name="sec:clpb-circuit"></a>
527489
528490 <p>Consider a Boolean circuit that express the Boolean function <code>XOR</code>
529491 with 4 <code>NAND</code> gates. We can model such a circuit with CLP(B)
549511 sat(Z=:=x#y).
550512 </pre>
551513
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>
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>
555517
556518 <p>The interface predicates of this library follow the example of
557 <a class="url" href="https://sicstus.sics.se"><b>SICStus Prolog</b></a>.
519 https://sicstus.sics.se<b>SICStus Prolog</b>.
558520
559521 <p>Use SICStus Prolog for higher performance in many cases.
560522
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)
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)
562524 predicate index</span></a></h3>
563525
564 <p><a id="sec:clpb-predicates"></a>
526 <p><a name="sec:clpb-predicates"></a>
565527
566528 <p>In the following, each CLP(B) predicate is described in more detail.
567529
570532 <p><a class="url" href="http://eu.swi-prolog.org/man/clpb.html">http://eu.swi-prolog.org/man/clpb.html</a>
571533
572534 <dl class="latex">
573 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="sat/1"><strong>sat</strong>(<var>+Expr</var>)</a></dt>
535 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="sat/1"><strong>sat</strong>(<var>+Expr</var>)</a></dt>
574536 <dd class="defbody">
575537 True iff <var>Expr</var> is a satisfiable Boolean expression.</dd>
576 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="taut/2"><strong>taut</strong>(<var>+Expr,
538 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="taut/2"><strong>taut</strong>(<var>+Expr,
577539 -T</var>)</a></dt>
578540 <dd class="defbody">
579541 Tautology check. Succeeds with <var>T</var> = 0 if the Boolean
580542 expression <var>Expr</var> cannot be satisfied, and with <var>T</var> =
581543 1 if <var>Expr</var> is always true with respect to the current
582544 constraints. Fails otherwise.</dd>
583 <dt class="pubdef"><span class="pred-tag">[multi]</span><a id="labeling/1"><strong>labeling</strong>(<var>+Vs</var>)</a></dt>
545 <dt class="pubdef"><span class="pred-tag">[multi]</span><a name="labeling/1"><strong>labeling</strong>(<var>+Vs</var>)</a></dt>
584546 <dd class="defbody">
585547 Enumerate concrete solutions. Assigns truth values to the Boolean
586548 variables <var>Vs</var> such that all stated constraints are satisfied.</dd>
587 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="sat_count/2"><strong>sat_count</strong>(<var>+Expr,
549 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="sat_count/2"><strong>sat_count</strong>(<var>+Expr,
588550 -Count</var>)</a></dt>
589551 <dd class="defbody">
590552 <var>Count</var> the number of admissible assignments. <var>Count</var>
613575 </pre>
614576
615577 </dd>
616 <dt class="pubdef"><span class="pred-tag">[multi]</span><a id="weighted_maximum/3"><strong>weighted_maximum</strong>(<var>+Weights,
578 <dt class="pubdef"><span class="pred-tag">[multi]</span><a name="weighted_maximum/3"><strong>weighted_maximum</strong>(<var>+Weights,
617579 +Vs, -Maximum</var>)</a></dt>
618580 <dd class="defbody">
619581 Enumerate weighted optima over admissible assignments. Maximize a linear
636598 </pre>
637599
638600 </dd>
639 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_labeling/2"><strong>random_labeling</strong>(<var>+Seed,
601 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_labeling/2"><strong>random_labeling</strong>(<var>+Seed,
640602 +Vs</var>)</a></dt>
641603 <dd class="defbody">
642604 Select a single random solution. An admissible assignment of truth
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="clpb.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="clpqr.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:clpfd"><a id="sec:A.8"><span class="sec-nr">A.8</span> <span class="sec-title">library(clpfd):
194 <h2 id="sec:clpfd"><a name="sec:A.8"><span class="sec-nr">A.8</span> <span class="sec-title">library(clpfd):
236195 CLP(FD): Constraint Logic Programming over Finite Domains</span></a></h2>
237196
238 <a id="sec:clpfd"></a>
239
240 <p><a id="sec:clpfd"></a>
197 <a name="sec:clpfd"></a>
198
199 <p><a name="sec:clpfd"></a>
241200
242201 <dl class="tags">
243202 <dt class="tag">author</dt>
244203 <dd>
245 <a class="url" href="https://www.metalevel.at">Markus Triska</a>
204 https://www.metalevel.atMarkus Triska
246205 </dd>
247206 </dl>
248207
249208 <p><b>Development of this library has moved to SICStus Prolog.</b><br>
250209 Please see
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>
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>
257215
258216 <p>This library provides CLP(FD): Constraint Logic Programming over
259217 Finite Domains. This is an instance of the general CLP(<i>X</i>) scheme
260 (<a class="sec" href="clp.html#sec:7">section 7</a>), extending logic
218 (<a class="sec" href="clp.html">section 7</a>), extending logic
261219 programming with reasoning over specialised domains. CLP(FD) lets us
262220 reason about <b>integers</b> in a way that honors the relational nature
263221 of Prolog.
264222
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.
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.
268225
269226 <p>There are two major use cases of CLP(FD) constraints:
270227
271228 <p>
272229 <ol class="latex">
273 <li><b>declarative integer arithmetic</b> (<a class="sec" href="clpfd.html#sec:A.8.3">section
230 <li><b>declarative integer arithmetic</b> (<a class="sec" href="clpfd.html">section
274231 A.8.3</a>)
275232 <li>solving <b>combinatorial problems</b> such as planning, scheduling
276233 and allocation tasks.
281238 <p>
282239 <ul class="latex">
283240 <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>
284 and <a class="pred" href="clpfd.html##\=/2">#\=/2</a> (<a class="sec" href="clpfd.html#sec:A.8.17.1">section
241 and <a class="pred" href="clpfd.html##\=/2">#\=/2</a> (<a class="sec" href="clpfd.html">section
285242 A.8.17.1</a>)
286243 <li>the <i>membership</i> constraints <a class="pred" href="clpfd.html#in/2">in/2</a>
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
244 and <a class="pred" href="clpfd.html#ins/2">ins/2</a> (<a class="sec" href="clpfd.html">section
288245 A.8.17.2</a>)
289246 <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>
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
247 and <a class="pred" href="clpfd.html#labeling/2">labeling/2</a> (<a class="sec" href="clpfd.html">section
291248 A.8.17.3</a>)
292249 <li><i>combinatorial</i> constraints like <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
293250 and <a class="pred" href="clpfd.html#global_cardinality/2">global_cardinality/2</a>
294 (<a class="sec" href="clpfd.html#sec:A.8.17.4">section A.8.17.4</a>)
251 (<a class="sec" href="clpfd.html">section A.8.17.4</a>)
295252 <li><i>reification</i> predicates such as <a class="pred" href="clpfd.html##<==>/2">#&lt;==&gt;/2</a>
296 (<a class="sec" href="clpfd.html#sec:A.8.17.5">section A.8.17.5</a>)
253 (<a class="sec" href="clpfd.html">section A.8.17.5</a>)
297254 <li><i>reflection</i> predicates such as <a class="pred" href="clpfd.html#fd_dom/2">fd_dom/2</a>
298 (<a class="sec" href="clpfd.html#sec:A.8.17.6">section A.8.17.6</a>)
255 (<a class="sec" href="clpfd.html">section A.8.17.6</a>)
299256 </ul>
300257
301 <p>In most cases, <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html#sec:A.8.2">section
258 <p>In most cases, <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html">section
302259 A.8.2</a>) are the only predicates you will ever need from this library.
303260 When reasoning over integers, simply replace low-level arithmetic
304261 predicates like <code>(is)/2</code> and <code>(&gt;)/2</code> by the
323280
324281 <p>Important concepts and principles of this library are illustrated by
325282 means of usage examples that are available in a public git repository:
326 <a class="url" href="https://github.com/triska/clpfd"><b>github.com/triska/clpfd</b></a>
283 https://github.com/triska/clpfd<b>github.com/triska/clpfd</b>
327284
328285 <p>If you are used to the complicated operational considerations that
329286 low-level arithmetic primitives necessitate, then moving to CLP(FD)
343300 advanced lectures.
344301
345302 <p>We recommend the following reference (PDF:
346 <a class="url" href="https://www.metalevel.at/swiclpfd.pdf">metalevel.at/swiclpfd.pdf</a>)
347 for citing this library in scientific publications:
303 https://www.metalevel.at/swiclpfd.pdfmetalevel.at/swiclpfd.pdf) for
304 citing this library in scientific publications:
348305
349306 <pre class="code">
350307 @inproceedings{Triska12,
359316 </pre>
360317
361318 <p>More information about CLP(FD) constraints and their implementation
362 is contained in: <a class="url" href="https://www.metalevel.at/drt.pdf"><b>metalevel.at/drt.pdf</b></a>
319 is contained in: https://www.metalevel.at/drt.pdf<b>metalevel.at/drt.pdf</b>
363320
364321 <p>The best way to discuss applying, improving and extending CLP(FD)
365322 constraints is to use the dedicated <code>clpfd</code> tag on
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
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
371328 constraints</span></a></h3>
372329
373 <p><a id="sec:clpfd-arith-constraints"></a>
330 <p><a name="sec:clpfd-arith-constraints"></a>
374331
375332 <p>In modern Prolog systems, <b>arithmetic constraints</b> subsume and
376333 supersede low-level predicates over integers. The main advantage of
381338 <p>The most important arithmetic constraint is <a class="pred" href="clpfd.html##=/2">#=/2</a>,
382339 which subsumes both
383340 <code>(is)/2</code> and <code>(=:=)/2</code> over integers. Use <a class="pred" href="clpfd.html##=/2">#=/2</a>
384 to make your programs more general. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
341 to make your programs more general. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
385342 A.8.3</a>).
386343
387344 <p>In total, the arithmetic constraints are:
388345 <blockquote>
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
346 <table border="2" frame="box" rules="groups">
347 <tr valign="top"><td>Expr1 <code>#=</code> Expr2</td><td>Expr1 equals
348 Expr2 </td></tr>
349 <tr valign="top"><td>Expr1 <code>#\=</code> Expr2</td><td>Expr1 is not
393350 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
397 Expr2 </td></tr>
398 <tr><td>Expr1 <code>#&lt;</code> Expr2</td><td>Expr1 is less than 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>
399359 </table>
400360 </blockquote>
401361
402362 <p><var>Expr1</var> and <var>Expr2</var> denote <b>arithmetic
403363 expressions</b>, which are:
404364 <blockquote>
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
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
417384 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>
385 <tr valign="top"><td>Expr div Expr</td><td>Floored integer division </td></tr>
423386 </table>
424387 </blockquote>
425388
429392 <code>(&lt;&lt;)/2</code>, <code>lsb/1</code>, <code>msb/1</code>, <code>popcount/1</code>
430393 and <code>(xor)/2</code> are also supported.
431394
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
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
433396 integer arithmetic</span></a></h3>
434397
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
398 <p><a name="sec:clpfd-integer-arith"></a>
399
400 <p>The <i>arithmetic constraints</i> (<a class="sec" href="clpfd.html">section
438401 A.8.2</a>) <a class="pred" href="clpfd.html##=/2">#=/2</a>, <a class="pred" href="clpfd.html##>/2">#&gt;/2</a>
439402 etc. are meant to be used <i>instead</i> of the primitives <code>(is)/2</code>,
440403 <code>(=:=)/2</code>, <code>(&gt;)/2</code> etc. over integers. Almost
486449
487450 <p>For supported expressions, CLP(FD) constraints are drop-in
488451 replacements of these low-level arithmetic predicates, often yielding
489 more general programs. See <code>n_factorial/2</code> (<a class="sec" href="clpfd.html#sec:A.8.4">section
452 more general programs. See <code>n_factorial/2</code> (<a class="sec" href="clpfd.html">section
490453 A.8.4</a>) for an example.
491454
492455 <p>This library uses <a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
522485 primitives by providing declarative alternatives that are meant to be
523486 used instead.
524487
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:
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:
526489 Factorial relation</span></a></h3>
527490
528 <p><a id="sec:clpfd-factorial"></a>
491 <p><a name="sec:clpfd-factorial"></a>
529492
530493 <p>We illustrate the benefit of using <a class="pred" href="clpfd.html##=/2">#=/2</a>
531494 for more generality with a simple example.
587550 freeing us from <i>all</i> procedural phenomena. For example, the two
588551 programs do not even have the same <i>termination properties</i> in all
589552 cases. Instead, the primary benefit of CLP(FD) constraints is that they
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>
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>
598561 and <code>(=:=)/2</code> to beginners, since <i>both</i> predicates are
599562 subsumed by <a class="pred" href="clpfd.html##=/2">#=/2</a> when
600563 reasoning over integers.
608571 the symbolic outcome (<code>&lt;</code>, <code>=</code>, <code>&gt;</code>)
609572 of 0 compared to N.
610573
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
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
612575 constraints</span></a></h3>
613576
614 <p><a id="sec:clpfd-combinatorial"></a>
577 <p><a name="sec:clpfd-combinatorial"></a>
615578
616579 <p>In addition to subsuming and replacing low-level arithmetic
617580 predicates, CLP(FD) constraints are often used to solve combinatorial
623586 and <a class="pred" href="clpfd.html#automaton/8">automaton/8</a>, which
624587 are useful in more specialized applications.
625588
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>
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>
629592
630593 <p>Each CLP(FD) variable has an associated set of admissible integers,
631594 which we call the variable's <b>domain</b>. Initially, the domain of
643606 <p>Domains are taken into account when further constraints are stated,
644607 and by enumeration predicates like <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>.
645608
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:
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:
647610 Sudoku</span></a></h3>
648611
649 <p><a id="sec:clpfd-sudoku"></a>
612 <p><a name="sec:clpfd-sudoku"></a>
650613
651614 <p>As another example, consider <i>Sudoku</i>: It is a popular puzzle
652615 over integers that can be easily solved with CLP(FD) constraints.
696659 </pre>
697660
698661 <p>In this concrete case, the constraint solver is strong enough to find
699 the unique solution without any search.
700
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
662 the unique solution without any search. For the general case, see search
663 (<a class="sec" href="clpfd.html">section A.8.9</a>).
664
665 <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
702666 goals</span></a></h3>
703667
704 <p><a id="sec:clpfd-residual-goals"></a>
668 <p><a name="sec:clpfd-residual-goals"></a>
705669
706670 <p>Here is an example session with a few queries and their answers:
707671
754718 which we can inspect a variable's current domain. These predicates can
755719 be useful if you want to implement your own labeling strategies.
756720
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
721 <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
758722 relations and search</span></a></h3>
759723
760 <p><a id="sec:clpfd-search"></a>
724 <p><a name="sec:clpfd-search"></a>
761725
762726 <p>Using CLP(FD) constraints to solve combinatorial tasks typically
763727 consists of two phases:
764728
765729 <p>
766730 <ol class="latex">
767 <li>First, all relevant constraints are stated.
768 <li>Second, if the domain of each involved variable is <i>finite</i>,
769 then <i>enumeration predicates</i> can be used to search for concrete
770 solutions.
731 <li><b>Modeling</b>. In this phase, all relevant constraints are stated.
732 <li><b>Search</b>. In this phase, <i>enumeration predicates</i> are used
733 to search for concrete solutions.
771734 </ol>
772735
773736 <p>It is good practice to keep the modeling part, via a dedicated
834797 general though, it is necessary to label all variables to obtain ground
835798 solutions.
836799
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:
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:
838801 Eight queens puzzle</span></a></h3>
839802
840 <p><a id="sec:clpfd-n-queens"></a>
803 <p><a name="sec:clpfd-n-queens"></a>
841804
842805 <p>We illustrate the concepts of the preceding sections by means of the
843806 so-called <i>eight queens puzzle</i>. The task is to place 8 queens on
913876 <p>Experimenting with different search strategies is easy because we
914877 have separated the core relation from the actual search.
915878
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>
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>
919882
920883 <p>We can use <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>
921884 to minimize or maximize the value of a CLP(FD) expression, and generate
934897 optimal solution. However, it is often very valuable to see alternative
935898 solutions that are <i>also</i> optimal, so that we can choose among
936899 optimal solutions by other criteria. For the sake of
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.
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.
940903
941904 <p>Related to optimisation with CLP(FD) constraints are
942 <a class="url" href="http://eu.swi-prolog.org/man/simplex.html"><code>library(simplex)</code></a>
905 http://eu.swi-prolog.org/man/simplex.html<code>library(simplex)</code>
943906 and CLP(Q) which reason about <i>linear</i> constraints over rational
944907 numbers.
945908
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>
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>
949912
950913 <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>,
951914 and <a class="pred" href="clpfd.html##>=/2">#&gt;=/2</a> can be
953916 values represented by the integers 0 and 1. Let P and Q denote reifiable
954917 constraints or Boolean variables, then:
955918 <blockquote>
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>
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>
965931 </table>
966932 </blockquote>
967933
969935
970936 <p>When reasoning over Boolean variables, also consider using CLP(B)
971937 constraints as provided by
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
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
975941 monotonic CLP(FD)</span></a></h3>
976942
977 <p><a id="sec:clpfd-monotonicity"></a>
943 <p><a name="sec:clpfd-monotonicity"></a>
978944
979945 <p>In the default execution mode, CLP(FD) constraints still exhibit some
980946 non-relational properties. For example, <i>adding</i> constraints can
1012978 <p>The wrapper can be omitted for variables that are already constrained
1013979 to integers.
1014980
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
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
1016982 constraints</span></a></h3>
1017983
1018 <p><a id="sec:clpfd-custom-constraints"></a>
984 <p><a name="sec:clpfd-custom-constraints"></a>
1019985
1020986 <p>We can define custom constraints. The mechanism to do this is not yet
1021987 finalised, and we welcome suggestions and descriptions of use cases that
10651031 X in inf..sup.
10661032 </pre>
10671033
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>
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>
10711037
10721038 <p>CLP(FD) applications that we find particularly impressive and worth
10731039 studying include:
10761042 <ul class="latex">
10771043 <li>Michael Hendricks uses CLP(FD) constraints for flexible reasoning
10781044 about <i>dates</i> and <i>times</i> in the
1079 <a class="url" href="http://www.swi-prolog.org/pack/list?p=julian"><code>julian</code></a>
1080 package.
1045 http://www.swi-prolog.org/pack/list?p=julian<code>julian</code> package.
10811046 <li>Julien Cumin uses CLP(FD) constraints for integer arithmetic in
1082 <a class="url" href="https://github.com/JCumin/Brachylog"><code>Brachylog</code></a>.
1047 https://github.com/JCumin/Brachylog<code>Brachylog</code>.
10831048 </ul>
10841049
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)
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)
11091074 predicate index</span></a></h3>
11101075
1111 <p><a id="sec:clpfd-predicate-index"></a>
1076 <p><a name="sec:clpfd-predicate-index"></a>
11121077
11131078 <p>In the following, each CLP(FD) predicate is described in more detail.
11141079
11161081
11171082 <p><a class="url" href="http://eu.swi-prolog.org/man/clpfd.html">http://eu.swi-prolog.org/man/clpfd.html</a>
11181083
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
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
11201085 constraints</span></a></h4>
11211086
1122 <p><a id="sec:clpfd-arithmetic"></a>
1087 <p><a name="sec:clpfd-arithmetic"></a>
11231088
11241089 <p><i>Arithmetic</i> constraints are the most basic use of CLP(FD).
11251090 Every time you use <code>(is)/2</code> or one of the low-level
11261091 arithmetic comparisons (<code>(&lt;)/2</code>, <code>(&gt;)/2</code>
11271092 etc.) over integers, consider using CLP(FD) constraints <i>instead</i>.
11281093 This can at most <i>increase</i> the generality of your programs. See
1129 declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
1094 declarative integer arithmetic (<a class="sec" href="clpfd.html">section
11301095 A.8.3</a>).
11311096
11321097 <dl class="latex">
1133 <dt class="pubdef"><a id="#=/2"><var>?X</var> <strong>#=</strong> <var>?Y</var></a></dt>
1098 <dt class="pubdef"><a name="#=/2"><var>?X</var> <strong>#=</strong> <var>?Y</var></a></dt>
11341099 <dd class="defbody">
11351100 The arithmetic expression <var>X</var> equals <var>Y</var>. This is the
1136 most important arithmetic constraint (<a class="sec" href="clpfd.html#sec:A.8.2">section
1101 most important arithmetic constraint (<a class="sec" href="clpfd.html">section
11371102 A.8.2</a>), subsuming and replacing both <code>(is)/2</code> <i>and</i> <code>(=:=)/2</code>
1138 over integers. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
1103 over integers. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
11391104 A.8.3</a>).</dd>
1140 <dt class="pubdef"><a id="#\=/2"><var>?X</var> <strong>#\=</strong> <var>?Y</var></a></dt>
1105 <dt class="pubdef"><a name="#\=/2"><var>?X</var> <strong>#\=</strong> <var>?Y</var></a></dt>
11411106 <dd class="defbody">
11421107 The arithmetic expressions <var>X</var> and <var>Y</var> evaluate to
11431108 distinct integers. When reasoning over integers, replace <code>(=\=)/2</code>
11441109 by <a class="pred" href="clpfd.html##\=/2">#\=/2</a> to obtain more
1145 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
1110 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
11461111 A.8.3</a>).</dd>
1147 <dt class="pubdef"><a id="#>=/2"><var>?X</var> <strong>#&gt;=</strong> <var>?Y</var></a></dt>
1112 <dt class="pubdef"><a name="#>=/2"><var>?X</var> <strong>#&gt;=</strong> <var>?Y</var></a></dt>
11481113 <dd class="defbody">
11491114 Same as <var>Y</var> <code>#=&lt;</code> <var>X</var>. When reasoning
11501115 over integers, replace <code>(&gt;=)/2</code> by
11511116 <a class="pred" href="clpfd.html##>=/2">#&gt;=/2</a> to obtain more
1152 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
1117 general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
11531118 A.8.3</a>).</dd>
1154 <dt class="pubdef"><a id="#=</2"><var>?X</var> <strong>#=&lt;</strong> <var>?Y</var></a></dt>
1119 <dt class="pubdef"><a name="#=</2"><var>?X</var> <strong>#=&lt;</strong> <var>?Y</var></a></dt>
11551120 <dd class="defbody">
11561121 The arithmetic expression <var>X</var> is less than or equal to <var>Y</var>.
11571122 When reasoning over integers, replace <code>(=&lt;)/2</code> by <a class="pred" href="clpfd.html##=</2">#=&lt;/2</a>
1158 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
1123 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
11591124 A.8.3</a>).</dd>
1160 <dt class="pubdef"><a id="#>/2"><var>?X</var> <strong>#&gt;</strong> <var>?Y</var></a></dt>
1125 <dt class="pubdef"><a name="#>/2"><var>?X</var> <strong>#&gt;</strong> <var>?Y</var></a></dt>
11611126 <dd class="defbody">
11621127 Same as <var>Y</var> <code>#&lt;</code> <var>X</var>. When reasoning
11631128 over integers, replace <code>(&gt;)/2</code> by
11641129 <a class="pred" href="clpfd.html##>/2">#&gt;/2</a> to obtain more
1165 general relations See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
1130 general relations See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
11661131 A.8.3</a>).</dd>
1167 <dt class="pubdef"><a id="#</2"><var>?X</var> <strong>#&lt;</strong> <var>?Y</var></a></dt>
1132 <dt class="pubdef"><a name="#</2"><var>?X</var> <strong>#&lt;</strong> <var>?Y</var></a></dt>
11681133 <dd class="defbody">
11691134 The arithmetic expression <var>X</var> is less than <var>Y</var>. When
11701135 reasoning over integers, replace <code>(&lt;)/2</code> by <a class="pred" href="clpfd.html##</2">#&lt;/2</a>
1171 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html#sec:A.8.3">section
1136 to obtain more general relations. See declarative integer arithmetic (<a class="sec" href="clpfd.html">section
11721137 A.8.3</a>).
11731138
11741139 <p>In addition to its regular use in tasks that require it, this
11891154 <p></dd>
11901155 </dl>
11911156
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
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
11931158 constraints</span></a></h4>
11941159
1195 <p><a id="sec:clpfd-membership"></a>
1160 <p><a name="sec:clpfd-membership"></a>
11961161
11971162 <p>If you are using CLP(FD) to model and solve combinatorial tasks, then
11981163 you typically need to specify the admissible domains of variables. The <i>membership
12001165 are useful in such cases.
12011166
12021167 <dl class="latex">
1203 <dt class="pubdef"><a id="in/2"><var>?Var</var> <strong>in</strong> <var>+Domain</var></a></dt>
1168 <dt class="pubdef"><a name="in/2"><var>?Var</var> <strong>in</strong> <var>+Domain</var></a></dt>
12041169 <dd class="defbody">
12051170 <var>Var</var> is an element of <var>Domain</var>. <var>Domain</var> is
12061171 one of:
12241189 </dl>
12251190
12261191 </dd>
1227 <dt class="pubdef"><a id="ins/2"><var>+Vars</var> <strong>ins</strong> <var>+Domain</var></a></dt>
1192 <dt class="pubdef"><a name="ins/2"><var>+Vars</var> <strong>ins</strong> <var>+Domain</var></a></dt>
12281193 <dd class="defbody">
12291194 The variables in the list <var>Vars</var> are elements of <var>Domain</var>.
12301195 See <a class="pred" href="clpfd.html#in/2">in/2</a> for the syntax of <var>Domain</var>.
12311196 </dd>
12321197 </dl>
12331198
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
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
12351200 predicates</span></a></h4>
12361201
1237 <p><a id="sec:clpfd-enumeration"></a>
1202 <p><a name="sec:clpfd-enumeration"></a>
12381203
12391204 <p>When modeling combinatorial tasks, the actual search for solutions is
12401205 typically performed by <i>enumeration predicates</i> like <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>.
12421207 information.
12431208
12441209 <dl class="latex">
1245 <dt class="pubdef"><a id="indomain/1"><strong>indomain</strong>(<var>?Var</var>)</a></dt>
1210 <dt class="pubdef"><a name="indomain/1"><strong>indomain</strong>(<var>?Var</var>)</a></dt>
12461211 <dd class="defbody">
12471212 Bind <var>Var</var> to all feasible values of its domain on
12481213 backtracking. The domain of <var>Var</var> must be finite.</dd>
1249 <dt class="pubdef"><a id="label/1"><strong>label</strong>(<var>+Vars</var>)</a></dt>
1214 <dt class="pubdef"><a name="label/1"><strong>label</strong>(<var>+Vars</var>)</a></dt>
12501215 <dd class="defbody">
12511216 Equivalent to <code>labeling([], Vars)</code>. See <a class="pred" href="clpfd.html#labeling/2">labeling/2</a>.</dd>
1252 <dt class="pubdef"><a id="labeling/2"><strong>labeling</strong>(<var>+Options,
1217 <dt class="pubdef"><a name="labeling/2"><strong>labeling</strong>(<var>+Options,
12531218 +Vars</var>)</a></dt>
12541219 <dd class="defbody">
12551220 Assign a value to each variable in <var>Vars</var>. Labeling means
13561321 </pre>
13571322
13581323 <p>Labeling is always complete, always terminates, and yields no
1359 redundant solutions. See core relations and search (<a class="sec" href="clpfd.html#sec:A.8.9">section
1324 redundant solutions. See core relations and search (<a class="sec" href="clpfd.html">section
13601325 A.8.9</a>) for usage advice.
13611326 </dd>
13621327 </dl>
13631328
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
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
13651330 constraints</span></a></h4>
13661331
1367 <p><a id="sec:clpfd-global"></a>
1332 <p><a name="sec:clpfd-global"></a>
13681333
13691334 <p>A <i>global constraint</i> expresses a relation that involves many
13701335 variables at once. The most frequently used global constraints of this
13731338 and <a class="pred" href="clpfd.html#cumulative/2">cumulative/2</a>.
13741339
13751340 <dl class="latex">
1376 <dt class="pubdef"><a id="all_distinct/1"><strong>all_distinct</strong>(<var>+Vars</var>)</a></dt>
1341 <dt class="pubdef"><a name="all_distinct/1"><strong>all_distinct</strong>(<var>+Vars</var>)</a></dt>
13771342 <dd class="defbody">
13781343 True iff <var>Vars</var> are pairwise distinct. For example, <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
13791344 can detect that not all variables can assume distinct values given the
13871352 </pre>
13881353
13891354 </dd>
1390 <dt class="pubdef"><a id="all_different/1"><strong>all_different</strong>(<var>+Vars</var>)</a></dt>
1355 <dt class="pubdef"><a name="all_different/1"><strong>all_different</strong>(<var>+Vars</var>)</a></dt>
13911356 <dd class="defbody">
13921357 Like <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>,
13931358 but with weaker propagation. Consider using
13941359 <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
13951360 instead, since <a class="pred" href="clpfd.html#all_distinct/1">all_distinct/1</a>
13961361 is typically acceptably efficient and propagates much more strongly.</dd>
1397 <dt class="pubdef"><a id="sum/3"><strong>sum</strong>(<var>+Vars, +Rel,
1398 ?Expr</var>)</a></dt>
1362 <dt class="pubdef"><a name="sum/3"><strong>sum</strong>(<var>+Vars,
1363 +Rel, ?Expr</var>)</a></dt>
13991364 <dd class="defbody">
14001365 The sum of elements of the list <var>Vars</var> is in relation <var>Rel</var>
14011366 to <var>Expr</var>.
14111376 </pre>
14121377
14131378 </dd>
1414 <dt class="pubdef"><a id="scalar_product/4"><strong>scalar_product</strong>(<var>+Cs,
1379 <dt class="pubdef"><a name="scalar_product/4"><strong>scalar_product</strong>(<var>+Cs,
14151380 +Vs, +Rel, ?Expr</var>)</a></dt>
14161381 <dd class="defbody">
14171382 True iff the scalar product of <var>Cs</var> and <var>Vs</var> is in
14201385 variables and integers.
14211386 <var>Rel</var> is #=, #<code>\</code>=, #<var>&lt;</var>, #<var>&gt;</var>, <code>#=&lt;</code>
14221387 or #<var>&gt;</var>=.</dd>
1423 <dt class="pubdef"><a id="lex_chain/1"><strong>lex_chain</strong>(<var>+Lists</var>)</a></dt>
1388 <dt class="pubdef"><a name="lex_chain/1"><strong>lex_chain</strong>(<var>+Lists</var>)</a></dt>
14241389 <dd class="defbody">
14251390 <var>Lists</var> are lexicographically non-decreasing.</dd>
1426 <dt class="pubdef"><a id="tuples_in/2"><strong>tuples_in</strong>(<var>+Tuples,
1391 <dt class="pubdef"><a name="tuples_in/2"><strong>tuples_in</strong>(<var>+Tuples,
14271392 +Relation</var>)</a></dt>
14281393 <dd class="defbody">
14291394 True iff all <var>Tuples</var> are elements of <var>Relation</var>. Each
14691434 </pre>
14701435
14711436 </dd>
1472 <dt class="pubdef"><a id="serialized/2"><strong>serialized</strong>(<var>+Starts,
1437 <dt class="pubdef"><a name="serialized/2"><strong>serialized</strong>(<var>+Starts,
14731438 +Durations</var>)</a></dt>
14741439 <dd class="defbody">
14751440 Describes a set of non-overlapping tasks.
14991464 </dl>
15001465
15011466 </dd>
1502 <dt class="pubdef"><a id="element/3"><strong>element</strong>(<var>?N,
1467 <dt class="pubdef"><a name="element/3"><strong>element</strong>(<var>?N,
15031468 +Vs, ?V</var>)</a></dt>
15041469 <dd class="defbody">
15051470 The <var>N</var>-th element of the list of finite domain variables <var>Vs</var>
15061471 is <var>V</var>. Analogous to <a class="pred" href="lists.html#nth1/3">nth1/3</a>.</dd>
1507 <dt class="pubdef"><a id="global_cardinality/2"><strong>global_cardinality</strong>(<var>+Vs,
1472 <dt class="pubdef"><a name="global_cardinality/2"><strong>global_cardinality</strong>(<var>+Vs,
15081473 +Pairs</var>)</a></dt>
15091474 <dd class="defbody">
15101475 Global Cardinality constraint. Equivalent to
15201485 </pre>
15211486
15221487 </dd>
1523 <dt class="pubdef"><a id="global_cardinality/3"><strong>global_cardinality</strong>(<var>+Vs,
1488 <dt class="pubdef"><a name="global_cardinality/3"><strong>global_cardinality</strong>(<var>+Vs,
15241489 +Pairs, +Options</var>)</a></dt>
15251490 <dd class="defbody">
15261491 Global Cardinality constraint. <var>Vs</var> is a list of finite domain
15461511 </dl>
15471512
15481513 </dd>
1549 <dt class="pubdef"><a id="circuit/1"><strong>circuit</strong>(<var>+Vs</var>)</a></dt>
1514 <dt class="pubdef"><a name="circuit/1"><strong>circuit</strong>(<var>+Vs</var>)</a></dt>
15501515 <dd class="defbody">
15511516 True iff the list <var>Vs</var> of finite domain variables induces a
15521517 Hamiltonian circuit. The k-th element of <var>Vs</var> denotes the
15631528 </pre>
15641529
15651530 </dd>
1566 <dt class="pubdef"><a id="cumulative/1"><strong>cumulative</strong>(<var>+Tasks</var>)</a></dt>
1531 <dt class="pubdef"><a name="cumulative/1"><strong>cumulative</strong>(<var>+Tasks</var>)</a></dt>
15671532 <dd class="defbody">
15681533 Equivalent to <code>cumulative(Tasks, [limit(1)])</code>. See <a class="pred" href="clpfd.html#cumulative/2">cumulative/2</a>.</dd>
1569 <dt class="pubdef"><a id="cumulative/2"><strong>cumulative</strong>(<var>+Tasks,
1534 <dt class="pubdef"><a name="cumulative/2"><strong>cumulative</strong>(<var>+Tasks,
15701535 +Options</var>)</a></dt>
15711536 <dd class="defbody">
15721537 Schedule with a limited resource. <var>Tasks</var> is a list of tasks,
16071572 </pre>
16081573
16091574 </dd>
1610 <dt class="pubdef"><a id="disjoint2/1"><strong>disjoint2</strong>(<var>+Rectangles</var>)</a></dt>
1575 <dt class="pubdef"><a name="disjoint2/1"><strong>disjoint2</strong>(<var>+Rectangles</var>)</a></dt>
16111576 <dd class="defbody">
16121577 True iff <var>Rectangles</var> are not overlapping. <var>Rectangles</var>
16131578 is a list of terms of the form F(X_i, W_i, Y_i, H_i), where F is any
16141579 functor, and the arguments are finite domain variables or integers that
16151580 denote, respectively, the X coordinate, width, Y coordinate and height
16161581 of each rectangle.</dd>
1617 <dt class="pubdef"><a id="automaton/3"><strong>automaton</strong>(<var>+Vs,
1582 <dt class="pubdef"><a name="automaton/3"><strong>automaton</strong>(<var>+Vs,
16181583 +Nodes, +Arcs</var>)</a></dt>
16191584 <dd class="defbody">
16201585 Describes a list of finite domain variables with a finite automaton.
16411606 </pre>
16421607
16431608 </dd>
1644 <dt class="pubdef"><a id="automaton/8"><strong>automaton</strong>(<var>+Sequence,
1609 <dt class="pubdef"><a name="automaton/8"><strong>automaton</strong>(<var>+Sequence,
16451610 ?Template, +Signature, +Nodes, +Arcs, +Counters, +Initials, ?Finals</var>)</a></dt>
16461611 <dd class="defbody">
16471612 Describes a list of finite domain variables with a finite automaton.
17131678 </pre>
17141679
17151680 </dd>
1716 <dt class="pubdef"><a id="chain/2"><strong>chain</strong>(<var>+Zs,
1681 <dt class="pubdef"><a name="chain/2"><strong>chain</strong>(<var>+Zs,
17171682 +Relation</var>)</a></dt>
17181683 <dd class="defbody">
17191684 <var>Zs</var> form a chain with respect to <var>Relation</var>. <var>Zs</var>
17331698 <p></dd>
17341699 </dl>
17351700
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
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
17371702 predicates</span></a></h4>
17381703
1739 <p><a id="sec:clpfd-reification-predicates"></a>
1704 <p><a name="sec:clpfd-reification-predicates"></a>
17401705
17411706 <p>Many CLP(FD) constraints can be <i>reified</i>. This means that their
17421707 truth value is itself turned into a CLP(FD) variable, so that we can
17431708 explicitly reason about whether a constraint holds or not. See
1744 reification (<a class="sec" href="clpfd.html#sec:A.8.12">section A.8.12</a>).
1709 reification (<a class="sec" href="clpfd.html">section A.8.12</a>).
17451710
17461711 <dl class="latex">
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
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
17501715 A.8.12</a>).
17511716
17521717 <p>For example, to obtain the complement of a domain:
17571722 </pre>
17581723
17591724 </dd>
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
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
17631728 A.8.12</a>).
17641729
17651730 <p>For example:
17981763 </pre>
17991764
18001765 </dd>
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
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
18041769 A.8.12</a>).</dd>
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
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
18081773 A.8.12</a>).</dd>
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
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
18121777 A.8.12</a>).</dd>
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
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
18161781 A.8.12</a>).
18171782
18181783 <p>For example, the sum of natural numbers below 1000 that are multiples
18281793 </pre>
18291794
18301795 </dd>
1831 <dt class="pubdef"><a id="#\/2"><var>?P</var> <strong>#\</strong> <var>?Q</var></a></dt>
1796 <dt class="pubdef"><a name="#\/2"><var>?P</var> <strong>#\</strong> <var>?Q</var></a></dt>
18321797 <dd class="defbody">
18331798 Either <var>P</var> holds or <var>Q</var> holds, but not both. See
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,
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,
18361801 ?A, ?B</var>)</a></dt>
18371802 <dd class="defbody">
18381803 Analogous to <a class="pred" href="compare.html#compare/3">compare/3</a>,
18911856 ensures that the respective ordering between N and 0 holds in each case.
18921857
18931858 <p>The truth value of a comparison can also be reified with (<code>#&lt;==&gt;</code>)/2
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
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
18961861 A.8.12</a>). However, <a class="pred" href="clpfd.html#zcompare/3">zcompare/3</a>
18971862 lets you more conveniently distinguish the cases.
18981863 </dd>
18991864 </dl>
19001865
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
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
19021867 predicates</span></a></h4>
19031868
1904 <p><a id="sec:clpfd-reflection-predicates"></a>
1869 <p><a name="sec:clpfd-reflection-predicates"></a>
19051870
19061871 <p>Reflection predicates let us obtain, in a well-defined way,
19071872 information that is normally internal to this library. In addition to
19121877 useful in program analyzers and declarative debuggers.
19131878
19141879 <dl class="latex">
1915 <dt class="pubdef"><a id="fd_var/1"><strong>fd_var</strong>(<var>+Var</var>)</a></dt>
1880 <dt class="pubdef"><a name="fd_var/1"><strong>fd_var</strong>(<var>+Var</var>)</a></dt>
19161881 <dd class="defbody">
19171882 True iff <var>Var</var> is a CLP(FD) variable.</dd>
1918 <dt class="pubdef"><a id="fd_inf/2"><strong>fd_inf</strong>(<var>+Var,
1883 <dt class="pubdef"><a name="fd_inf/2"><strong>fd_inf</strong>(<var>+Var,
19191884 -Inf</var>)</a></dt>
19201885 <dd class="defbody">
19211886 <var>Inf</var> is the infimum of the current domain of <var>Var</var>.</dd>
1922 <dt class="pubdef"><a id="fd_sup/2"><strong>fd_sup</strong>(<var>+Var,
1887 <dt class="pubdef"><a name="fd_sup/2"><strong>fd_sup</strong>(<var>+Var,
19231888 -Sup</var>)</a></dt>
19241889 <dd class="defbody">
19251890 <var>Sup</var> is the supremum of the current domain of <var>Var</var>.</dd>
1926 <dt class="pubdef"><a id="fd_size/2"><strong>fd_size</strong>(<var>+Var,
1891 <dt class="pubdef"><a name="fd_size/2"><strong>fd_size</strong>(<var>+Var,
19271892 -Size</var>)</a></dt>
19281893 <dd class="defbody">
19291894 Reflect the current size of a domain. <var>Size</var> is the number of
19301895 elements of the current domain of <var>Var</var>, or the atom <b>sup</b>
19311896 if the domain is unbounded.</dd>
1932 <dt class="pubdef"><a id="fd_dom/2"><strong>fd_dom</strong>(<var>+Var,
1897 <dt class="pubdef"><a name="fd_dom/2"><strong>fd_dom</strong>(<var>+Var,
19331898 -Dom</var>)</a></dt>
19341899 <dd class="defbody">
19351900 <var>Dom</var> is the current domain (see <a class="pred" href="clpfd.html#in/2">in/2</a>)
19631928 <p></dd>
19641929 </dl>
19651930
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
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
19671932 and opening words about CLP(FD)</span></a></h3>
19681933
1969 <p><a id="sec:clpfd-closing-opening"></a>
1934 <p><a name="sec:clpfd-closing-opening"></a>
19701935
19711936 <p>CLP(FD) constraints are one of the main reasons why logic programming
19721937 approaches are picked over other paradigms for solving many tasks of
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="clpfd.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="csv.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:clpqr"><a id="sec:A.9"><span class="sec-nr">A.9</span> <span class="sec-title">library(clpqr):
194 <h2 id="sec:clpqr"><a name="sec:A.9"><span class="sec-nr">A.9</span> <span class="sec-title">library(clpqr):
236195 Constraint Logic Programming over Rationals and Reals</span></a></h2>
237196
238 <a id="sec:clpqr"></a>
239 <a id="sec:lib:clpqr"></a>
197 <a name="sec:clpqr"></a>
198 <a name="sec:lib:clpqr"></a>
240199 <blockquote> Author: <em>Christian Holzbaur</em>, ported to SWI-Prolog
241200 by <em>Leslie De Koninck</em>, K.U. Leuven
242201 </blockquote>
244203 <p>This CLP(Q,R) system is a port of the CLP(Q,R) system of Sicstus
245204 Prolog by Christian Holzbaur: Holzbaur C.: OFAI clp(q,r) Manual, Edition
246205 1.3.3, Austrian Research Institute for Artificial Intelligence, Vienna,
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>
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>
248207 This manual is roughly based on the manual of the above mentioned
249208 CLP(Q,R) implementation.
250209
273232 :- use_module(library(clpr)).
274233 </pre>
275234
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
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
277236 predicates</span></a></h3>
278237
279 <a id="sec:clpqr-predicates"></a> The following predicates are provided
280 to work with constraints:
238 <a name="sec:clpqr-predicates"></a> The following predicates are
239 provided to work with constraints:
281240
282241 <dl class="latex">
283 <dt class="pubdef"><a id="{}/1"><strong>{}</strong>(<var>+Constraints</var>)</a></dt>
242 <dt class="pubdef"><a name="{}/1"><strong>{}</strong>(<var>+Constraints</var>)</a></dt>
284243 <dd class="defbody">
285244 Adds the constraints given by <var>Constraints</var> to the constraint
286245 store.</dd>
287 <dt class="pubdef"><a id="entailed/1"><strong>entailed</strong>(<var>+Constraint</var>)</a></dt>
246 <dt class="pubdef"><a name="entailed/1"><strong>entailed</strong>(<var>+Constraint</var>)</a></dt>
288247 <dd class="defbody">
289248 Succeeds if <var>Constraint</var> is necessarily true within the current
290249 constraint store. This means that adding the negation of the constraint
291250 to the store results in failure.</dd>
292 <dt class="pubdef"><a id="inf/2"><strong>inf</strong>(<var>+Expression,
251 <dt class="pubdef"><a name="inf/2"><strong>inf</strong>(<var>+Expression,
293252 -Inf</var>)</a></dt>
294253 <dd class="defbody">
295254 Computes the infimum of <var>Expression</var> within the current state
296255 of the constraint store and returns that infimum in <var>Inf</var>. This
297256 predicate does not change the constraint store.</dd>
298 <dt class="pubdef"><a id="sup/2"><strong>sup</strong>(<var>+Expression,
257 <dt class="pubdef"><a name="sup/2"><strong>sup</strong>(<var>+Expression,
299258 -Sup</var>)</a></dt>
300259 <dd class="defbody">
301260 Computes the supremum of <var>Expression</var> within the current state
302261 of the constraint store and returns that supremum in <var>Sup</var>.
303262 This predicate does not change the constraint store.</dd>
304 <dt class="pubdef"><a id="minimize/1"><strong>minimize</strong>(<var>+Expression</var>)</a></dt>
263 <dt class="pubdef"><a name="minimize/1"><strong>minimize</strong>(<var>+Expression</var>)</a></dt>
305264 <dd class="defbody">
306265 Minimizes <var>Expression</var> within the current constraint store.
307266 This is the same as computing the infimum and equating the expression to
308267 that infimum.</dd>
309 <dt class="pubdef"><a id="maximize/1"><strong>maximize</strong>(<var>+Expression</var>)</a></dt>
268 <dt class="pubdef"><a name="maximize/1"><strong>maximize</strong>(<var>+Expression</var>)</a></dt>
310269 <dd class="defbody">
311270 Maximizes <var>Expression</var> within the current constraint store.
312271 This is the same as computing the supremum and equating the expression
313272 to that supremum.</dd>
314 <dt class="pubdef"><a id="bb_inf/5"><strong>bb_inf</strong>(<var>+Ints,
273 <dt class="pubdef"><a name="bb_inf/5"><strong>bb_inf</strong>(<var>+Ints,
315274 +Expression, -Inf, -Vertex, +Eps</var>)</a></dt>
316275 <dd class="defbody">
317276 This predicate is offered in CLP(R) only. It computes the infimum of
322281 an integer to be considered an integer. E.g. when
323282 <var>Eps</var> = 0.001, then X = 4.999 will be considered as an integer
324283 (5 in this case). <var>Eps</var> should be between 0 and 0.5.</dd>
325 <dt class="pubdef"><a id="bb_inf/4"><strong>bb_inf</strong>(<var>+Ints,
284 <dt class="pubdef"><a name="bb_inf/4"><strong>bb_inf</strong>(<var>+Ints,
326285 +Expression, -Inf, -Vertex</var>)</a></dt>
327286 <dd class="defbody">
328287 This predicate is offered in CLP(Q) only. It behaves the same as
329288 <a class="pred" href="clpqr.html#bb_inf/5">bb_inf/5</a> but does not use
330289 an error margin.</dd>
331 <dt class="pubdef"><a id="bb_inf/3"><strong>bb_inf</strong>(<var>+Ints,
290 <dt class="pubdef"><a name="bb_inf/3"><strong>bb_inf</strong>(<var>+Ints,
332291 +Expression, -Inf</var>)</a></dt>
333292 <dd class="defbody">
334293 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>
335294 but without returning the values of the integers. In CLP(R), an error
336295 margin of 0.001 is used.</dd>
337 <dt class="pubdef"><a id="dump/3"><strong>dump</strong>(<var>+Target,
296 <dt class="pubdef"><a name="dump/3"><strong>dump</strong>(<var>+Target,
338297 +Newvars, -CodedAnswer</var>)</a></dt>
339298 <dd class="defbody">
340299 Returns the constraints on <var>Target</var> in the list <var>CodedAnswer</var>
351310 <p></dd>
352311 </dl>
353312
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
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
355314 of the predicate arguments</span></a></h3>
356315
357 <a id="sec:clpqr-arg-syntax"></a> The arguments of the predicates
316 <a name="sec:clpqr-arg-syntax"></a> The arguments of the predicates
358317 defined in the subsection above are defined in <a class="tab" href="clpqr.html#tab:clpqrbnf">table
359318 10</a>. Failing to meet the syntax rules will result in an exception.
360319 <div style="text-align:center">
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
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
363322 constraint </td></tr>
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>
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>
367328
368329 <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
369330 than </td></tr>
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
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
371332 than </td></tr>
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
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
373334 or equal </td></tr>
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
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
375336 or equal </td></tr>
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
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
377338 or equal </td></tr>
378 <tr><td></td><td align=right>|</td><td>&lt;<var>Expression</var>&gt; <code>=\=</code> &lt;<var>Expression</var>&gt; </td><td>not
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
379340 equal </td></tr>
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>
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>
383346
384347 <p>&lt;<var>Expression</var>&gt; </td><td align=right>::=</td><td>&lt;<var>Variable</var>&gt; </td><td>Prolog
385348 variable </td></tr>
386 <tr><td></td><td align=right>|</td><td>&lt;<var>Number</var>&gt; </td><td>Prolog
349 <tr valign="top"><td></td><td align=right>|</td><td>&lt;<var>Number</var>&gt; </td><td>Prolog
387350 number </td></tr>
388 <tr><td></td><td align=right>|</td><td>+&lt;<var>Expression</var>&gt; </td><td>unary
351 <tr valign="top"><td></td><td align=right>|</td><td>+&lt;<var>Expression</var>&gt; </td><td>unary
389352 plus </td></tr>
390 <tr><td></td><td align=right>|</td><td>-&lt;<var>Expression</var>&gt; </td><td>unary
353 <tr valign="top"><td></td><td align=right>|</td><td>-&lt;<var>Expression</var>&gt; </td><td>unary
391354 minus </td></tr>
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
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
397364 value </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>
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>
406373 </table>
407374 <div class="caption"><b>Table 10 : </b>CLP(Q,R) constraint BNF</div>
408 <a id="tab:clpqrbnf"></a>
375 <a name="tab:clpqrbnf"></a>
409376 </div>
410377
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
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
412379 of unification</span></a></h3>
413380
414 <a id="sec:clpqr-unification"></a>
381 <a name="sec:clpqr-unification"></a>
415382
416383 <p>Instead of using the <a class="pred" href="clpqr.html#{}/1">{}/1</a>
417384 predicate, you can also use the standard unification mechanism to store
439406 <p>
440407 </ul>
441408
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
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
443410 constraints</span></a></h3>
444411
445 <a id="sec:clpqr-non-linear"></a> The CLP(Q,R) system deals only
412 <a name="sec:clpqr-non-linear"></a> The CLP(Q,R) system deals only
446413 passively with non-linear constraints. They remain in a passive state
447414 until certain conditions are satisfied. These conditions, which are
448415 called the isolation axioms, are given in
449416 <a class="tab" href="clpqr.html#tab:clpqraxioms">table 11</a>.
450417 <div style="text-align:center">
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
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
457425 = B / 3 </td></tr>
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
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
471443 = sin(Y) </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>
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>
475447 </table>
476448 <div class="caption"><b>Table 11 : </b>CLP(Q,R) isolating axioms</div>
477 <a id="tab:clpqraxioms"></a>
449 <a name="tab:clpqraxioms"></a>
478450 </div>
479451
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
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
481453 and known problems</span></a></h3>
482454
483 <a id="sec:clpqr-status"></a>
455 <a name="sec:clpqr-status"></a>
484456
485457 <p>The clpq and clpr libraries are `orphaned', i.e., they currently have
486458 no maintainer.
503475
504476 <p>
505477 <li><i>Dumping constraints</i><br>
506 The first argument of <a id="idx:dump3:2148"></a><a class="pred" href="clpqr.html#dump/3">dump/3</a>
478 The first argument of <a name="idx:dump3:2147"></a><a class="pred" href="clpqr.html#dump/3">dump/3</a>
507479 has to be a list of free variables at call-time:
508480
509481 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="initgoal.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="gemacs.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:cmdline"><a id="sec:2.4"><span class="sec-nr">2.4</span> <span class="sec-title">Command
194 <h2 id="sec:cmdline"><a name="sec:2.4"><span class="sec-nr">2.4</span> <span class="sec-title">Command
236195 line options</span></a></h2>
237196
238 <a id="sec:cmdline"></a>
197 <a name="sec:cmdline"></a>
239198
240199 <p>SWI-Prolog can be executed in one of the following modes:
241200
246205 <dt><b><code>swipl --dump-runtime-variables</code></b></dt>
247206 <dd class="defbody">
248207 These options must appear as only option. They cause Prolog to print an
249 informational message and exit. See <a class="sec" href="cmdline.html#sec:2.4.1">section
208 informational message and exit. See <a class="sec" href="cmdline.html">section
250209 2.4.1</a>.</dd>
251210 <dt><b><code>swipl</code> [<var>option</var> ...] <var>script-file</var>
252211 [<var>arg</var> ...]</b></dt>
258217 ... [[<code>--</code>] <var>arg</var> ...]</b></dt>
259218 <dd class="defbody">
260219 This is the normal way to start Prolog. The options are described in
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>
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>
264223 provides access to <var>arg</var> ... If the <var>options</var> are
265224 followed by one or more Prolog file names (i.e., names with extension <code>.pl</code>, <code>.prolog</code>
266225 or (on Windows) the user preferred extension registered during
268227 the Prolog flag
269228 <a class="flag" href="flags.html#flag:associated_file">associated_file</a>.
270229 In addition, <b>pl-win[.exe]</b> switches to the directory in which this
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>
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>
272231 <dt><b><code>swipl</code> -o <var>output</var> -c <var>prolog-file</var>
273232 ...</b></dt>
274233 <dd class="defbody">
275234 The <strong>-c</strong> option is used to compile a set of Prolog files
276 into an executable. See <a class="sec" href="cmdline.html#sec:2.4.5">section
277 2.4.5</a>.</dd>
235 into an executable. See <a class="sec" href="cmdline.html">section 2.4.5</a>.</dd>
278236 <dt><b><code>swipl</code> -o <var>output</var> -b <var>bootfile</var> <var>prolog-file</var>
279237 ...</b></dt>
280238 <dd class="defbody">
281 Bootstrap compilation. See <a class="sec" href="cmdline.html#sec:2.4.6">section
239 Bootstrap compilation. See <a class="sec" href="cmdline.html">section
282240 2.4.6</a>.
283241 </dd>
284242 </dl>
285243
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
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
287245 command line options</span></a></h3>
288246
289 <a id="sec:info-options"></a>
247 <a name="sec:info-options"></a>
290248
291249 <dl class="latex">
292250 <dt><strong>--arch</strong> <var></var></dt>
300258 <dd class="defbody">
301259 When given as the only option, it prints a sequence of variable settings
302260 that can be used in shell scripts to deal with Prolog parameters. This
303 feature is also used by <b>swipl-ld</b> (see <a class="sec" href="plld.html#sec:11.5">section
261 feature is also used by <b>swipl-ld</b> (see <a class="sec" href="plld.html">section
304262 11.5</a>). Below is a typical example of using this feature.
305263
306264 <pre class="code">
322280 </dd>
323281 </dl>
324282
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
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
326284 line options for running Prolog</span></a></h3>
327285
328 <a id="sec:running-options"></a>
286 <a name="sec:running-options"></a>
329287
330288 <dl class="latex">
331289 <dt><strong>--home=DIR</strong> <var></var></dt>
332290 <dd class="defbody">
333 Use DIR as home directory. See <a class="sec" href="findhome.html#sec:11.6">section
291 Use DIR as home directory. See <a class="sec" href="findhome.html">section
334292 11.6</a> for details.</dd>
335293 <dt><strong>--quiet</strong> <var></var></dt>
336294 <dd class="defbody">
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>
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>
340298 <dt><strong>--nodebug</strong> <var></var></dt>
341299 <dd class="defbody">
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>
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>
343301 flag
344302 <a class="flag" href="flags.html#flag:generate_debug_info">generate_debug_info</a>
345303 for details.</dd>
348306 Inhibit any signal handling by Prolog, a property that is sometimes
349307 desirable for embedded applications. This option sets the flag
350308 <a class="flag" href="flags.html#flag:signals">signals</a> to <code>false</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>
354 additionally. See <strong>--sigalert</strong>. This flag also sets
355 <b>gc_thread</b> to <code>false</code> as synchronization with the
356 garbage collect thread is based on signals.</dd>
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>
312 additionally. See <strong>--sigalert</strong>.</dd>
357313 <dt><strong>--pldoc</strong> <var>[=port]</var></dt>
358314 <dd class="defbody">
359315 Start the PlDoc documentation system on a free network port and launch
363319 <dt><strong>--sigalert=NUM</strong> <var></var></dt>
364320 <dd class="defbody">
365321 Use signal <var>NUM</var> (1 ... 31) for alerting a thread. This is
366 needed to make <a id="idx:threadsignal2:28"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>,
322 needed to make <a name="idx:threadsignal2:28"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>,
367323 and derived Prolog signal handling act immediately when the target
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>,
324 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>,
369325 read/write to most devices). The default is to use <code>SIGUSR2</code>.
370 If <var>NUM</var> is 0 (zero), this handler is not installed.</dd>
326 If <var>NUM</var> is 0 (zero), this handler is not installed. See <a name="idx:prologalertsignal2:30"></a><a class="pred" href="signal.html#prolog_alert_signal/2">prolog_alert_signal/2</a>
327 to query or modify this value at runtime.</dd>
371328 <dt><strong>-tty</strong> <var></var></dt>
372329 <dd class="defbody">
373330 Unix only. Switches controlling the terminal for allowing
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>.
331 single-character commands to the tracer and <a name="idx:getsinglechar1:31"></a><a class="pred" href="chario.html#get_single_char/1">get_single_char/1</a>.
375332 By default, manipulating the terminal is enabled unless the system
376333 detects it is not connected to a terminal or it is running as a
377334 GNU-Emacs inferior process. See also <a class="flag" href="flags.html#flag:tty_control">tty_control</a>.</dd>
380337 This option is available only in <b>swipl-win.exe</b> and is used for
381338 the start-menu item. If causes <b>plwin</b> to start in the folder
382339 <code>...\My Documents\Prolog</code> or local equivalent thereof (see
383 <a id="idx:winfolder2:31"></a><a class="pred" href="system.html#win_folder/2">win_folder/2</a>).
340 <a name="idx:winfolder2:32"></a><a class="pred" href="system.html#win_folder/2">win_folder/2</a>).
384341 The <code>Prolog</code> subdirectory is created if it does not exist.</dd>
385342 <dt><strong>-O</strong> <var></var></dt>
386343 <dd class="defbody">
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>
344 Optimised compilation. See <a name="idx:currentprologflag2:33"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
388345 flag
389346 <a class="flag" href="flags.html#flag:optimise">optimise</a> for
390347 details.</dd>
393350 Load <var>file</var>. This flag provides compatibility with some other
394351 Prolog systems.<sup class="fn">10<span class="fn-text">YAP, SICStus</span></sup>
395352 It is used in SWI-Prolog to skip the program initialization specified
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>
353 using <a name="idx:initialization2:34"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
354 directives. See also <a class="sec" href="compilation.html">section
355 2.10.2.1</a>, and <a name="idx:initialize0:35"></a><span class="pred-ext">initialize/0</span>.</dd>
399356 <dt><strong>-s</strong> <var>file</var></dt>
400357 <dd class="defbody">
401358 Use <var>file</var> as a script file. The script file is loaded after
408365 <code>.swiplrc</code> (Unix) or <code>swipl.ini</code> (Windows). `<strong>-f</strong> <var>none</var>'
409366 stops SWI-Prolog from searching for a startup file. This option can be
410367 used as an alternative to <strong>-s</strong> <var>file</var> that stops
411 Prolog from loading the personal initialisation file. See also <a class="sec" href="initfile.html#sec:2.2">section
368 Prolog from loading the personal initialisation file. See also <a class="sec" href="initfile.html">section
412369 2.2</a>.</dd>
413370 <dt><strong>-F</strong> <var>script</var></dt>
414371 <dd class="defbody">
428385 A boot file is a file resulting from a Prolog compilation using the
429386 <strong>-b</strong> or <strong>-c</strong> option or a program saved
430387 using
431 <a id="idx:qsaveprogram12:35"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.</dd>
388 <a name="idx:qsaveprogram12:36"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.</dd>
432389 <dt><strong>-p</strong> <var>alias=path1[:path2 ... ]</var></dt>
433390 <dd class="defbody">
434391 Define a path alias for file_search_path. <var>alias</var> is the name
435392 of the alias, and arg path1 ... is a list of values for the alias. On
436393 Windows the list separator is <code><code>;</code></code>. On other
437394 systems it is <code><code>:</code></code>. A value is either a term of
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>
395 the form alias(value) or pathname. The computed aliases are added to <a name="idx:filesearchpath2:37"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
396 using <a name="idx:asserta1:38"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>,
397 so they precede predefined values for the alias. See <a name="idx:filesearchpath2:39"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
441398 for details on using this file location mechanism.</dd>
442399 <dt><strong>--traditional</strong> <var></var></dt>
443400 <dd class="defbody">
444401 This flag disables the most important extensions of SWI-Prolog version&nbsp;7
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>
402 (see <a class="sec" href="extensions.html">section 5</a>) that introduce
403 incompatibilities with earlier versions. In particular, lists are
404 represented in the traditional way, double quoted text is represented by
405 a list of character codes and the functional notation on dicts is not
406 supported. Dicts as a syntactic entity, and the predicates that act on
407 them, are still supported if this flag is present.</dd>
451408 <dt><strong>--</strong> <var></var></dt>
452409 <dd class="defbody">
453 <a id="idx:commandlinearguments:39"></a>Stops scanning for more
410 <a name="idx:commandlinearguments:40"></a>Stops scanning for more
454411 arguments, so you can pass arguments for your application after this
455 one. See <a id="idx:currentprologflag2:40"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
412 one. See <a name="idx:currentprologflag2:41"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
456413 using the flag <a class="flag" href="flags.html#flag:argv">argv</a> for
457414 obtaining the command line arguments.
458415 </dd>
459416 </dl>
460417
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
418 <p><h3 id="sec:stacksizes"><a name="sec:2.4.3"><span class="sec-nr">2.4.3</span> <span class="sec-title">Controlling
462419 the stack sizes</span></a></h3>
463420
464 <a id="sec:stacksizes"></a>
421 <a name="sec:stacksizes"></a>
465422
466423 <p>The default limit for the Prolog stacks is 128&nbsp;MB on 32-bit and
467424 256&nbsp;MB on 64-bit hardware. The 128&nbsp;MB limit on 32-bit systems
468425 is the highest possible value and the command line options can thus only
469426 be used to lower the limit. On 64-bit systems, the limit can both be
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>
427 reduced and enlarged. See <a class="sec" href="limits.html">section 2.20</a>.
428 Below are two examples, the first reducing the local stack limit to
429 catch unbounded recursion quickly and the second using a big (32&nbsp;GB)
430 global limit, which is only possible on 64-bit hardware. Note that
431 setting the limit using the command line only sets a <em>soft</em>
475432 limit. Stack parameters can be changed (both reduced and enlarged) at
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>.
433 any time using the predicate <a name="idx:setprologstack2:42"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
477434
478435 <pre class="code">
479436 $ swipl -L8m
506463 </dd>
507464 </dl>
508465
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
466 <p><h3 id="sec:runoptions"><a name="sec:2.4.4"><span class="sec-nr">2.4.4</span> <span class="sec-title">Running
510467 goals from the command line</span></a></h3>
511468
512 <a id="sec:runoptions"></a>
469 <a name="sec:runoptions"></a>
513470
514471 <dl class="latex">
515472 <dt><strong>-g</strong> <var>goal</var></dt>
516473 <dd class="defbody">
517474 <var>Goal</var> is executed just before entering the top level. This
518 option may appear multiple times. See <a class="sec" href="initgoal.html#sec:2.3">section
475 option may appear multiple times. See <a class="sec" href="initgoal.html">section
519476 2.3</a> for details. If no initialization goal is present the system
520 calls <a id="idx:version0:42"></a><a class="pred" href="exception.html#version/0">version/0</a>
477 calls <a name="idx:version0:43"></a><a class="pred" href="exception.html#version/0">version/0</a>
521478 to print the welcome message. The welcome message can be suppressed with
522479 <strong>--quiet</strong>, but also with <strong>-g</strong> <var>true</var>. <var>goal</var>
523480 can be a complex term. In this case quotes are normally needed to
535492 <dt><strong>-t</strong> <var>goal</var></dt>
536493 <dd class="defbody">
537494 Use <var>goal</var> as interactive top level instead of the default goal
538 <a id="idx:prolog0:43"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>.
495 <a name="idx:prolog0:44"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>.
539496 The <var>goal</var> can be a complex term. If the top-level goal
540497 succeeds SWI-Prolog exits with status 0. If it fails the exit status is
541498 1. If the top level raises an exception, this is printed as an uncaught
542499 error and the top level is <em>restarted</em>. This flag also determines
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>.
500 the goal started by <a name="idx:break0:45"></a><a class="pred" href="toplevel.html#break/0">break/0</a>
501 and <a name="idx:abort0:46"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
545502 If you want to prevent the user from entering interactive mode, start
546503 the application with `<strong>-g</strong> <var>goal</var> <strong>-t</strong> <var>halt</var>'.
547504 </dd>
548505 </dl>
549506
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
507 <p><h3 id="sec:compoptions"><a name="sec:2.4.5"><span class="sec-nr">2.4.5</span> <span class="sec-title">Compilation
551508 options</span></a></h3>
552509
553 <a id="sec:compoptions"></a>
510 <a name="sec:compoptions"></a>
554511
555512 <dl class="latex">
556513 <dt><strong>-c</strong> <var>file ...</var></dt>
557514 <dd class="defbody">
558 Compile files into an `intermediate code file'. See <a class="sec" href="compilation.html#sec:2.10">section
515 Compile files into an `intermediate code file'. See <a class="sec" href="compilation.html">section
559516 2.10</a>.</dd>
560517 <dt><strong>-o</strong> <var>output</var></dt>
561518 <dd class="defbody">
564521 </dd>
565522 </dl>
566523
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
524 <p><h3 id="sec:maintoptions"><a name="sec:2.4.6"><span class="sec-nr">2.4.6</span> <span class="sec-title">Maintenance
568525 options</span></a></h3>
569526
570 <a id="sec:maintoptions"></a>
527 <a name="sec:maintoptions"></a>
571528
572529 <p>The following options are for system maintenance. They are given for
573530 reference only.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="typetest.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="control.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:compare"><a id="sec:4.7"><span class="sec-nr">4.7</span> <span class="sec-title">Comparison
194 <h2 id="sec:compare"><a name="sec:4.7"><span class="sec-nr">4.7</span> <span class="sec-title">Comparison
236195 and Unification of Terms</span></a></h2>
237196
238 <a id="sec:compare"></a>
197 <a name="sec:compare"></a>
239198
240199 <p>Although unification is mostly done implicitly while matching the
241200 head of a predicate, it is also provided by the predicate =/2.
242201
243202 <dl class="latex">
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=/2"><var>?Term1</var> <strong>=</strong> <var>?Term2</var></a></dt>
203 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=/2"><var>?Term1</var> <strong>=</strong> <var>?Term2</var></a></dt>
245204 <dd class="defbody">
246205 Unify <var>Term1</var> with <var>Term2</var>. True if the unification
247206 succeeds. For behaviour on cyclic terms see the Prolog flag
253212 </pre>
254213
255214 </dd>
256 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="\=/2"><var>@Term1</var> <strong>\=</strong> <var>@Term2</var></a></dt>
215 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="\=/2"><var>@Term1</var> <strong>\=</strong> <var>@Term2</var></a></dt>
257216 <dd class="defbody">
258217 Equivalent to <code><code>\+</code>Term1 = Term2</code>.
259218
263222 incomplete nature of&nbsp;<a class="pred" href="control.html#\+/1">\+/1</a>.
264223
265224 <p>To make your programs work correctly also in situations where the
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>
225 arguments are not yet sufficiently instantiated, use <a name="idx:dif2:626"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
267226 instead.
268227 </dd>
269228 </dl>
270229
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
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
272231 Order of Terms</span></a></h3>
273232
274 <a id="sec:standardorder"></a>
233 <a name="sec:standardorder"></a>
275234
276235 <p>Comparison and unification of arbitrary terms. Terms are ordered in
277236 the so-called ``standard order''. This order is defined as follows:
294253
295254 <p>Although variables are ordered, there are some unexpected properties
296255 one should keep in mind when relying on variable ordering. This applies
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>
256 to the predicates below as to predicate such as <a name="idx:sort2:627"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>
298257 as well as libraries that reply on ordering such as library <code>library(assoc)</code>
299258 and library
300259 <code>library(ordsets)</code>. Obviously, an established relation <var>A</var> <code><code>@&lt;</code></code> <var>B</var>
307266 `newer' variables. If two variables are unified their `shared' age is
308267 the age of oldest variable. This implies we can examine a list of sorted
309268 variables with `newer' (fresh) variables without invalidating the order.
310 Attaching an <em>attribute</em>, see <a class="sec" href="attvar.html#sec:7.1">section
269 Attaching an <em>attribute</em>, see <a class="sec" href="attvar.html">section
311270 7.1</a>, turns an `old' variable into a `new' one as illustrated below.
312271 Note that the first always succeeds as the first argument of a term is
313272 always the oldest. This only applies for the <em>first</em> attribute,
329288 attributes to register information about variables.
330289
331290 <dl class="latex">
332 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="==/2"><var>@Term1</var> <strong>==</strong> <var>@Term2</var></a></dt>
291 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="==/2"><var>@Term1</var> <strong>==</strong> <var>@Term2</var></a></dt>
333292 <dd class="defbody">
334293 True if <var>Term1</var> is equivalent to <var>Term2</var>. A variable
335294 is only identical to a sharing variable.</dd>
336 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="\==/2"><var>@Term1</var> <strong>\==</strong> <var>@Term2</var></a></dt>
295 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="\==/2"><var>@Term1</var> <strong>\==</strong> <var>@Term2</var></a></dt>
337296 <dd class="defbody">
338297 Equivalent to <code><code>\+</code>Term1 == Term2</code>.</dd>
339 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@</2"><var>@Term1</var> <strong>@&lt;</strong> <var>@Term2</var></a></dt>
298 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@</2"><var>@Term1</var> <strong>@&lt;</strong> <var>@Term2</var></a></dt>
340299 <dd class="defbody">
341300 True if <var>Term1</var> is before <var>Term2</var> in the standard
342301 order of terms.</dd>
343 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@=</2"><var>@Term1</var> <strong>@=&lt;</strong> <var>@Term2</var></a></dt>
302 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@=</2"><var>@Term1</var> <strong>@=&lt;</strong> <var>@Term2</var></a></dt>
344303 <dd class="defbody">
345304 True if both terms are equal (<a class="pred" href="compare.html#==/2">==/2</a>)
346305 or <var>Term1</var> is before <var>Term2</var> in the standard order of
347306 terms.</dd>
348 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@>/2"><var>@Term1</var> <strong>@&gt;</strong> <var>@Term2</var></a></dt>
307 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@>/2"><var>@Term1</var> <strong>@&gt;</strong> <var>@Term2</var></a></dt>
349308 <dd class="defbody">
350309 True if <var>Term1</var> is after <var>Term2</var> in the standard order
351310 of terms.</dd>
352 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="@>=/2"><var>@Term1</var> <strong>@&gt;=</strong> <var>@Term2</var></a></dt>
311 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="@>=/2"><var>@Term1</var> <strong>@&gt;=</strong> <var>@Term2</var></a></dt>
353312 <dd class="defbody">
354313 True if both terms are equal (<a class="pred" href="compare.html#==/2">==/2</a>)
355314 or <var>Term1</var> is after <var>Term2</var> in the standard order of
356315 terms.</dd>
357 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="compare/3"><strong>compare</strong>(<var>?Order,
316 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="compare/3"><strong>compare</strong>(<var>?Order,
358317 @Term1, @Term2</var>)</a></dt>
359318 <dd class="defbody">
360319 Determine or test the <var>Order</var> between two terms in the standard
363322 </dd>
364323 </dl>
365324
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
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
367326 unification and comparison predicates</span></a></h3>
368327
369 <a id="sec:unifyspecial"></a>
328 <a name="sec:unifyspecial"></a>
370329
371330 <p>This section describes special purpose variations on Prolog
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>
331 unification. The predicate <a name="idx:unifywithoccurscheck2:628"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
373332 provides sound unification and is part of the ISO standard. The
374 predicate <a id="idx:subsumesterm2:627"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>
333 predicate <a name="idx:subsumesterm2:629"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>
375334 defines `one-sided unification' and is part of the ISO proposal
376 established in Edinburgh (2010). Finally, <a id="idx:unifiable3:628"></a><a class="pred" href="compare.html#unifiable/3">unifiable/3</a>
335 established in Edinburgh (2010). Finally, <a name="idx:unifiable3:630"></a><a class="pred" href="compare.html#unifiable/3">unifiable/3</a>
377336 is a `what-if' version of unification that is often used as a building
378337 block in constraint reasoners.
379338
380339 <dl class="latex">
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,
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,
382341 +Term2</var>)</a></dt>
383342 <dd class="defbody">
384343 As <a class="pred" href="compare.html#=/2">=/2</a>, but using <em>sound
393352 false.
394353 </pre>
395354
396 <p><a id="idx:occurscheck:629"></a>The first statement creates a <em>cyclic
355 <p><a name="idx:occurscheck:631"></a>The first statement creates a <em>cyclic
397356 term</em>, also called a
398357 <em>rational tree</em>. The second executes logically sound unification
399358 and thus fails. Note that the behaviour of unification through
400359 <a class="pred" href="compare.html#=/2">=/2</a> as well as implicit
401360 unification in the head can be changed using the Prolog flag <a class="flag" href="flags.html#flag:occurs_check">occurs_check</a>.
402361
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>
362 <p>The SWI-Prolog implementation of <a name="idx:unifywithoccurscheck2:632"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
404363 is cycle-safe and only guards against <em>creating</em> cycles, not
405364 against cycles that may already be present in one of the arguments. This
406365 is illustrated in the following two queries:
412371 X = Y, Y = f(Y).
413372 </pre>
414373
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>
374 <p>Some other Prolog systems interpret <a name="idx:unifywithoccurscheck2:633"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>
416375 as if defined by the clause below, causing failure on the above two
417 queries. Direct use of <a id="idx:acyclicterm1:632"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
376 queries. Direct use of <a name="idx:acyclicterm1:634"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
418377 is portable and more appropriate for such applications.
419378
420379 <pre class="code">
422381 </pre>
423382
424383 </dd>
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>
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:635"></a>True if <var>Term1</var> is a <em>variant</em>
428387 of (or <em>structurally equivalent</em> to) <var>Term2</var>. Testing
429388 for a variant is weaker than equivalence (<a class="pred" href="compare.html#==/2">==/2</a>),
430389 but stronger than unification (<a class="pred" href="compare.html#=/2">=/2</a>).
431390 Two terms <var>A</var> and <var>B</var> are variants iff there exists a
432391 renaming of the variables in <var>A</var> that makes <var>A</var>
433 equivalent (==) to <var>B</var> and vice versa.<sup class="fn">59<span class="fn-text">Row&nbsp;7
392 equivalent (==) to <var>B</var> and vice versa.<sup class="fn">58<span class="fn-text">Row&nbsp;7
434393 and 8 of this table may come as a surprise, but row&nbsp;8 is satisfied
435394 by (left-to-right) <var>A -&gt; C</var>, <var>B -&gt; A</var> and
436395 (right-to-left) <var>C -&gt; A</var>, <var>A -&gt; B</var>. If the same
439398 E.g., after binding the first argument in row&nbsp;8 to a value, both
440399 terms are no longer variant.</span></sup> Examples:
441400 <blockquote>
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>
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>
451416 </table>
452417 </blockquote>
453418
454419 <p>A term is always a variant of a copy of itself. Term copying takes
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>
420 place in, e.g., <a name="idx:copyterm2:636"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>, <a name="idx:findall3:637"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
456421 or proving a clause added with
457 <a id="idx:asserta1:636"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>.
422 <a name="idx:asserta1:638"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>.
458423 In the pure Prolog world (i.e., without attributed variables), <a class="pred" href="compare.html#=@=/2">=@=/2</a>
459424 behaves as if defined below. With attributed variables, variant of the
460425 attributes is tested rather than trying to satisfy the constraints.
472437 variables that are shared between the left and right argument. Its
473438 performance is comparable to <a class="pred" href="compare.html#==/2">==/2</a>,
474439 both on success and (early) failure.
475 <sup class="fn">60<span class="fn-text">The current implementation is
440 <sup class="fn">59<span class="fn-text">The current implementation is
476441 contributed by Kuniaki Mukai.</span></sup>
477442
478443 <p>This predicate is known by the name <span class="pred-ext">variant/2</span>
479444 in some other Prolog systems. Be aware of possible differences in
480445 semantics if the arguments contain attributed variables or share
481 variables.<sup class="fn">61<span class="fn-text">In many systems
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>
446 variables.<sup class="fn">60<span class="fn-text">In many systems
447 variant is implemented using two calls to <a name="idx:subsumesterm2:639"></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>
484449 <dd class="defbody">
485450 Equivalent to <code>`<code>\+</code>Term1 =@= Term2'</code>. See <a class="pred" href="compare.html#=@=/2">=@=/2</a>
486451 for details.</dd>
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>
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>
488453 <dd class="defbody">
489454 True if <var>Generic</var> can be made equivalent to <var>Specific</var>
490455 by only binding variables in <var>Generic</var>. The current
491456 implementation performs the unification and ensures that the variable
492457 set of <var>Specific</var> is not changed by the unification. On
493 success, the bindings are undone.<sup class="fn">62<span class="fn-text">This
494 predicate is often named <a id="idx:subsumeschk2:638"></a><span class="pred-ext">subsumes_chk/2</span>
458 success, the bindings are undone.<sup class="fn">61<span class="fn-text">This
459 predicate is often named <a name="idx:subsumeschk2:640"></a><span class="pred-ext">subsumes_chk/2</span>
495460 in older Prolog dialects. The current name was established in the ISO
496461 WG17 meeting in Edinburgh (2010). The <code>chk</code> postfix was
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>
462 considered to refer to determinism as in e.g., <a name="idx:memberchk2:641"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>.</span></sup>
498463 This predicate respects constraints.</dd>
499 <dt class="pubdef"><a id="term_subsumer/3"><strong>term_subsumer</strong>(<var>+Special1,
464 <dt class="pubdef"><a name="term_subsumer/3"><strong>term_subsumer</strong>(<var>+Special1,
500465 +Special2, -General</var>)</a></dt>
501466 <dd class="defbody">
502467 <var>General</var> is the most specific term that is a generalisation of
503468 <var>Special1</var> and <var>Special2</var>. The implementation can
504469 handle cyclic terms.</dd>
505 <dt class="pubdef"><a id="unifiable/3"><strong>unifiable</strong>(<var>@X, @Y,
470 <dt class="pubdef"><a name="unifiable/3"><strong>unifiable</strong>(<var>@X, @Y,
506471 -Unifier</var>)</a></dt>
507472 <dd class="defbody">
508473 If <var>X</var> and <var>Y</var> can unify, unify <var>Unifier</var>
509474 with a list of
510475 <var>Var</var> = <var>Value</var>, representing the bindings required to
511 make <var>X</var> and <var>Y</var> equivalent.<sup class="fn">63<span class="fn-text">This
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>
476 make <var>X</var> and <var>Y</var> equivalent.<sup class="fn">62<span class="fn-text">This
477 predicate was introduced for the implementation of <a name="idx:dif2:642"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
478 and <a name="idx:when2:643"></a><a class="pred" href="coroutining.html#when/2">when/2</a>
514479 after discussion with Tom Schrijvers and Bart Demoen. None of us is
515480 really happy with the name and therefore suggestions for a new name are
516481 welcome.</span></sup> This predicate can handle cyclic terms. Attributed
517482 variables are handled as normal variables. Associated hooks are <em>not</em>
518483 executed.</dd>
519 <dt class="pubdef"><a id="?=/2"><strong>?=</strong>(<var>@Term1, @Term2</var>)</a></dt>
484 <dt class="pubdef"><a name="?=/2"><strong>?=</strong>(<var>@Term1, @Term2</var>)</a></dt>
520485 <dd class="defbody">
521486 Succeeds if the syntactic equality of <var>Term1</var> and <var>Term2</var>
522487 can be decided safely, i.e. if the result of <code>Term1 == Term2</code>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="debugoverview.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="flags.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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
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
240199 program development</span></a></h3>
241200
242 <a id="sec:develcomp"></a>
201 <a name="sec:develcomp"></a>
243202
244203 <p>During program development, programs are normally loaded using the
245204 list abbreviation (<code>?- [load].</code>). It is common practice to
246205 organise a project as a collection of source files and a <em>load file</em>,
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>
206 a Prolog file containing only <a name="idx:usemodule12:72"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>
207 or <a name="idx:ensureloaded1:73"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>
249208 directives, possibly with a definition of the <em>entry point</em> of
250209 the program, the predicate that is normally used to start the program.
251210 This file is often called <code>load.pl</code>. If the entry point is
270229 before entering the top level. If Prolog is started from an interactive
271230 shell, one may choose the type <code>swipl -s load.pl</code>.
272231
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
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
274233 running the result</span></a></h3>
275234
276 <a id="sec:runcomp"></a>
235 <a name="sec:runcomp"></a>
277236
278237 <p>There are various options if you want to make your program ready for
279238 real usage. The best choice depends on whether the program is to be used
280239 only on machines holding the SWI-Prolog development system, the size of
281240 the program, and the operating system (Unix vs. Windows).
282241
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
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
284243 PrologScript</span></a></h4>
285244
286 <a id="sec:plscript"></a>
245 <a name="sec:plscript"></a>
287246
288247 <p>A Prolog source file can be used directly as a Unix program using the
289248 Unix <code>#!</code> magic start. The Unix <code>#!</code> magic is
308267 spaces. When started this way, the Prolog flag <a class="flag" href="flags.html#flag:argv">argv</a>
309268 contains the command line arguments that follow the script invocation.
310269
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>
270 <p>Starting with version 7.5.8, <a name="idx:initialization2:74"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
312271 support the <var>When</var> options <code>program</code> and <code>main</code>,
313272 allowing for the following definition of a Prolog script that evaluates
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>
273 an arithmetic expression on the command line. Note that <a name="idx:main0:75"></a><a class="pred" href="main.html#main/0">main/0</a>
315274 is defined lib the library
316 <code>library(main)</code>. It calls <a id="idx:main1:75"></a><span class="pred-ext">main/1</span>
275 <code>library(main)</code>. It calls <a name="idx:main1:76"></a><span class="pred-ext">main/1</span>
317276 with the command line arguments after disabling signal handling.
318277
319278 <pre class="code">
369328 Due to the compatibility issues around <em>HashBang</em> line
370329 processing, we decided to remove it completely.</span></sup>
371330
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
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
373332 a shell script</span></a></h4>
374333
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
334 <a name="sec:shellscript"></a>
335
336 <p>With the introduction of <em>PrologScript</em> (see <a class="sec" href="compilation.html">section
378337 2.10.2.1</a>), using shell scripts as explained in this section has
379338 become redundant for most applications.
380339
407366 shortcut to Prolog, passing the proper options or writing a <code>.bat</code>
408367 file.
409368
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
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
411370 a saved state</span></a></h4>
412371
413 <a id="sec:makestate"></a>
372 <a name="sec:makestate"></a>
414373
415374 <p>For larger programs, as well as for programs that are required to run
416375 on systems that do not have the SWI-Prolog development system installed,
417376 creating a saved state is the best solution. A saved state is created
418 using <a id="idx:qsaveprogram12:76"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
377 using <a name="idx:qsaveprogram12:77"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
419378 or the <strong>-c</strong> command line option. A saved state is a file
420379 containing machine-independent<sup class="fn">16<span class="fn-text">The
421380 saved state does not depend on the CPU instruction set or endianness.
424383 created.</span></sup> intermediate code in a format dedicated for fast
425384 loading. Optionally, the emulator may be integrated in the saved state,
426385 creating a single file, but machine-dependent, executable. This process
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
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
430389 using the -c command line option</span></a></h4>
431390
432 <a id="sec:cmdlinecomp"></a>
391 <a name="sec:cmdlinecomp"></a>
433392
434393 <p>This mechanism loads a series of Prolog source files and then creates
435 a saved state as <a id="idx:qsaveprogram2:77"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
394 a saved state as <a name="idx:qsaveprogram2:78"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
436395 does. The command syntax is:
437396
438397 <pre class="code">
439398 % swipl [option ...] [-o output] -c file.pl ...
440399 </pre>
441400
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>
401 <p>The <var>options</var> argument are options to <a name="idx:qsaveprogram2:79"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
443402 written in the format below. The option names and their values are
444403 described with
445 <a id="idx:qsaveprogram2:79"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
404 <a name="idx:qsaveprogram2:80"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
446405 <blockquote>
447406 <code>--</code><em>option-name</em><code>=</code><em>option-value
448407 </em></blockquote>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="chars.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="edit.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:consulting"><a id="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Loading
194 <h2 id="sec:consulting"><a name="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Loading
236195 Prolog source files</span></a></h2>
237196
238 <a id="sec:consulting"></a>
197 <a name="sec:consulting"></a>
239198
240199 <p>This section deals with loading Prolog source files. A Prolog source
241200 file is a plain text file containing a Prolog program or part thereof.
246205 <dd>
247206 Prolog source file contains Prolog clauses and directives, but no <em>module
248207 declaration</em> (see
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>.
208 <a name="idx:module1:360"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>).
209 They are normally loaded using <a name="idx:consult1:361"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
210 or <a name="idx:ensureloaded1:362"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>.
252211 Currently, a non-module file can only be loaded into a single module.<sup class="fn">45<span class="fn-text">This
253212 limitation may be lifted in the future. Existing limitations in
254213 SWI-Prolog's source code administration make this non-trivial.</span></sup></dd>
257216 Prolog source file starts with a module declaration. The subsequent
258217 Prolog code is loaded into the specified module, and only the <em>exported</em>
259218 predicates are made available to the context loading the module. Module
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>
219 files are normally loaded with <a name="idx:usemodule12:363"></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>
262221 <dt><b> An include</b></dt>
263222 <dd>
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>
223 Prolog source file is loaded using the <a name="idx:include1:364"></a><a class="pred" href="consulting.html#include/1">include/1</a>
265224 directive, textually including Prolog text into another Prolog source. A
266225 file may be included into multiple source files and is typically used to
267226 share <em>declarations</em> such as multifile or dynamic between source
269228 </dd>
270229 </dl>
271230
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>
231 <p>Prolog source files are located using <a name="idx:absolutefilename3:365"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
273232 with the following options:
274233
275234 <pre class="code">
282241 </pre>
283242
284243 <p>The <code>file_type(prolog)</code> option is used to determine the
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>.
244 extension of the file using <a name="idx:prologfiletype2:366"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>.
286245 The default extension is
287246 <code>.pl</code>. <var>Spec</var> allows for the <em>path alias</em>
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>.
247 construct defined by <a name="idx:absolutefilename3:367"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
289248 The most commonly used path alias is <code>library(LibraryFile)</code>.
290249 The example below loads the library file <code>ordsets.pl</code>
291250 (containing predicates for manipulating ordered sets).
294253 :- use_module(library(ordsets)).
295254 </pre>
296255
297 <p>SWI-Prolog recognises grammar rules (<a id="idx:DCG:366">DCG</a>) as
298 defined in
256 <p>SWI-Prolog recognises grammar rules (<a name="idx:DCG:368">DCG</a>)
257 as defined in
299258 <cite><a class="cite" href="Bibliography.html#Clocksin:87">Clocksin &amp;
300259 Melish, 1987</a></cite>. The user may define additional compilation of
301260 the source file by defining the dynamic multifile predicates
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>
261 <a name="idx:termexpansion2:369"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a name="idx:termexpansion4:370"></a><a class="pred" href="consulting.html#term_expansion/4">term_expansion/4</a>, <a name="idx:goalexpansion2:371"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
303262 and
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>
263 <a name="idx:goalexpansion4:372"></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:373"></a><a class="pred" href="db.html#assert/1">assert/1</a>, <a name="idx:retract1:374"></a><a class="pred" href="db.html#retract/1">retract/1</a>
265 or any other database predicate in <a name="idx:termexpansion2:375"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
307266 other than for local computational purposes.<sup class="fn">46<span class="fn-text">It
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>.
267 does work for normal loading, but not for <a name="idx:qcompile1:376"></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:377"></a><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a>.
310269 See <code>library(library(apply_macros))</code> for an example.
311270
312271 <p>A <em>directive</em> is an instruction to the compiler. Directives
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>)
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:378"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>)
315274 and load files (this section). Directives are terms of the form <code><code>:-</code></code> &lt;<var>term</var>&gt;.
316275 . Here are some examples:
317276
321280 store/2. % Name, Value
322281 </pre>
323282
324 <p>The directive <a id="idx:initialization1:377"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
283 <p>The directive <a name="idx:initialization1:379"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
325284 can be used to run arbitrary Prolog goals. The specified goal is started <em>after</em>
326285 loading the file in which it appears has completed.
327286
331290 appears. It also accepts <code><code>?-</code></code> &lt;<var>term</var>&gt;.
332291 as a synonym.
333292
334 <p><a id="idx:reconsult:378"></a>SWI-Prolog does not have a separate
293 <p><a name="idx:reconsult:380"></a>SWI-Prolog does not have a separate
335294 reconsult/1 predicate. Reconsulting is implied automatically by the fact
336295 that a file is consulted which is already loaded.
337296
338297 <p>Advanced topics are handled in subsequent sections: mutually
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
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
342301 4.3.2</a>).
343302
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>.
303 <p>The core of the family of loading predicates is <a name="idx:loadfiles2:381"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
345304 The predicates
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>
305 <a name="idx:consult1:382"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>, <a name="idx:ensureloaded1:383"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>, <a name="idx:usemodule1:384"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>, <a name="idx:usemodule2:385"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
306 and <a name="idx:reexport1:386"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
307 pass the file argument directly to <a name="idx:loadfiles2:387"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
349308 and pass additional options as expressed in the <a class="tab" href="consulting.html#tab:loadpreds">table
350309 4</a>:
351310
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>
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:388"></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:389"></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:390"></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:391"></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:392"></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:393"></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>
360320 </table>
361321 <div class="caption"><b>Table 4 : </b>Properties of the file-loading
362322 predicates. The <i>import</i> column specifies what is imported if the
363323 loaded file is a module file.</div>
364 <a id="tab:loadpreds"></a>
324 <a name="tab:loadpreds"></a>
365325
366326 <dl class="latex">
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>
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:394"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
330 See <a name="idx:loadfiles2:395"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
371331 for supported options.
372332 </dd>
373 <dt class="pubdef"><a id="load_files/2"><strong>load_files</strong>(<var>:Files,
333 <dt class="pubdef"><a name="load_files/2"><strong>load_files</strong>(<var>:Files,
374334 +Options</var>)</a></dt>
375335 <dd class="defbody">
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>
336 The predicate <a name="idx:loadfiles2:396"></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:397"></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:398"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>. <var>Files</var>
379339 is either a single source file or a list of source files. The
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>.
340 specification for a source file is handed to <a name="idx:absolutefilename2:399"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>.
381341 See this predicate for the supported expansions. <var>Options</var> is a
382342 list of options using the format <var>OptionName</var>(<var>OptionValue</var>).
383343
391351 <em>demand</em> load. This implies that, depending on the setting of the
392352 Prolog flag <a class="flag" href="flags.html#flag:verbose_autoload">verbose_autoload</a>,
393353 the load action is printed at level <code>informational</code> or <code>silent</code>.
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>
354 See also <a name="idx:printmessage2:400"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
355 and <a name="idx:currentprologflag2:401"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.</dd>
396356 <dt><strong>check_script</strong>(<var>Bool</var>)</dt>
397357 <dd class="defbody">
398358 If <code>false</code> (default <code>true</code>), do not check the
401361 <dt><strong>derived_from</strong>(<var>File</var>)</dt>
402362 <dd class="defbody">
403363 Indicate that the loaded file is derived from <var>File</var>. Used by
404 <a id="idx:make0:400"></a><a class="pred" href="consulting.html#make/0">make/0</a>
364 <a name="idx:make0:402"></a><a class="pred" href="consulting.html#make/0">make/0</a>
405365 to time-check and load the original file rather than the derived file.</dd>
406366 <dt><strong>dialect</strong>(<var>+Dialect</var>)</dt>
407367 <dd class="defbody">
408368 Load <var>Files</var> with enhanced compatibility with the target Prolog
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>
369 system identified by <var>Dialect</var>. See <a name="idx:expectsdialect1:403"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
410370 and
411 <a class="sec" href="dialect.html#sec:C">section C</a> for details.</dd>
371 <a class="sec" href="dialect.html">section C</a> for details.</dd>
412372 <dt><strong>encoding</strong>(<var>Encoding</var>)</dt>
413373 <dd class="defbody">
414374 Specify the way characters are encoded in the file. Default is taken
415375 from the Prolog flag <a class="flag" href="flags.html#flag:encoding">encoding</a>.
416 See <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a>
417 for details.</dd>
376 See <a class="sec" href="widechars.html">section 2.19.1</a> for details.</dd>
418377 <dt><strong>expand</strong>(<var>Bool</var>)</dt>
419378 <dd class="defbody">
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>
379 If <code>true</code>, run the filenames through <a name="idx:expandfilename2:404"></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:405"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
422381 which is intended for interactive use. Flexible location of files is
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>
382 defined by <a name="idx:filesearchpath2:406"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
424383 <dt><strong>format</strong>(<var>+Format</var>)</dt>
425384 <dd class="defbody">
426385 Used to specify the file format if data is loaded from a stream using
427386 the <code>stream(Stream)</code> option. Default is <code>source</code>,
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>
387 loading Prolog source text. If <code>qlf</code>, load QLF data (see <a name="idx:qcompile1:407"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>).</dd>
429388 <dt><strong>if</strong>(<var>Condition</var>)</dt>
430389 <dd class="defbody">
431390 Load the file only if the specified condition is satisfied. The value
436395 <dt><strong>imports</strong>(<var>Import</var>)</dt>
437396 <dd class="defbody">
438397 Specify what to import from the loaded module. The default for
439 <a id="idx:usemodule1:406"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
398 <a name="idx:usemodule1:408"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
440399 is <code>all</code>. <var>Import</var> is passed from the second
441 argument of <a id="idx:usemodule2:407"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.
400 argument of <a name="idx:usemodule2:409"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.
442401 Traditionally it is a list of predicate indicators to import. As part of
443402 the SWI-Prolog/YAP integration, we also support <var>Pred</var> as <var>Name</var>
444403 to import a predicate under another name. Finally, <var>Import</var> can
445404 be the term <code>except(Exceptions)</code>, where <var>Exceptions</var>
446405 is a list of predicate indicators that specify predicates that are <em>not</em>
447406 imported or <var>Pred</var> as <var>Name</var> terms to denote renamed
448 predicates. See also <a id="idx:reexport2:408"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>
407 predicates. See also <a name="idx:reexport2:410"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>
449408 and
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>
409 <a name="idx:usemodule2:411"></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>
451410 as <var>NewName</var> is currently implemented using a <em>link clause</em>.
452411 This harms efficiency and does not allow for querying the relation
453 through <a id="idx:predicateproperty2:410"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.</span></sup>
412 through <a name="idx:predicateproperty2:412"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.</span></sup>
454413
455414 <p>If <var>Import</var> equals <code>all</code>, all operators are
456415 imported as well. Otherwise, operators are <em>not</em> imported.
479438 <dd class="defbody">
480439 If <code>true</code>, raise an error if the file is not a module file.
481440 Used by
482 <a id="idx:usemodule12:411"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.</dd>
441 <a name="idx:usemodule12:413"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.</dd>
483442 <dt><strong>qcompile</strong>(<var>Atom</var>)</dt>
484443 <dd class="defbody">
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>.
444 How to deal with quick-load-file compilation by <a name="idx:qcompile1:414"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.
486445 Values are:
487446
488447 <dl class="latex">
501460 </dd>
502461 <dt><strong>part</strong></dt>
503462 <dd class="defbody">
504 If <a id="idx:loadfiles2:413"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
463 If <a name="idx:loadfiles2:415"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
505464 appears in a directive of a file that is compiled into Quick Load Format
506 using <a id="idx:qcompile1:414"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
465 using <a name="idx:qcompile1:416"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
507466 the contents of the argument files are included in the <code>.qlf</code>
508467 file instead of the loading directive.
509468 </dd>
516475 Defines what to do if a file is loaded that provides a module that is
517476 already loaded from another file. <var>Action</var> is one of <code>false</code>
518477 (default), which prints an error and refuses to load the file, or
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>
478 <code>true</code>, which uses <a name="idx:unloadfile1:417"></a><a class="pred" href="consulting.html#unload_file/1">unload_file/1</a>
520479 on the old file and then proceeds loading the new file. Finally, there
521480 is <code>ask</code>, which starts interaction with the user. <code>ask</code>
522481 is only provided if the stream <code>user_input</code> is associated
523482 with a terminal.</dd>
524483 <dt><strong>reexport</strong>(<var>Bool</var>)</dt>
525484 <dd class="defbody">
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>
485 If <code>true</code> re-export the imported predicate. Used by <a name="idx:reexport1:418"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
486 and <a name="idx:reexport2:419"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>.</dd>
528487 <dt><strong>register</strong>(<var>Bool</var>)</dt>
529488 <dd class="defbody">
530489 If <code>false</code>, do not register the load location and options.
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>
490 This option is used by <a name="idx:make0:420"></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:421"></a><a class="pred" href="consulting.html#source_file_property/2">source_file_property/2</a>.</dd>
533492 <dt><strong>sandboxed</strong>(<var>Bool</var>)</dt>
534493 <dd class="defbody">
535494 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>.
538497 Prolog flag is set to <code>true</code> raises a permission error.</dd>
539498 <dt><strong>scope_settings</strong>(<var>Bool</var>)</dt>
540499 <dd class="defbody">
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>
500 Scope <a name="idx:stylecheck1:422"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>
501 and <a name="idx:expectsdialect1:423"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
543502 to the file and files loaded from the file after the directive. Default
544503 is <code>true</code>. The system and user initialization files (see <strong>-f</strong>
545504 and
559518 clauses as well as to remove all clauses if the data is reconsulted.
560519
561520 <p>This option is added to allow compiling from non-file locations such
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>)
521 as databases, the web, the <em>user</em> (see <a name="idx:consult1:424"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
563522 or other servers. It can be combined with <code>format(qlf)</code> to
564523 load QLF data from a stream.
565524 </dd>
566525 </dl>
567526
568 <p>The <a id="idx:loadfiles2:423"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
527 <p>The <a name="idx:loadfiles2:425"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
569528 predicate can be hooked to load other data or data from objects other
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>
529 than files. See <a name="idx:prologloadfile2:426"></a><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a>
571530 for a description and
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>
531 <code>library(http/http_load)</code> for an example. All hooks for <a name="idx:loadfiles2:427"></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:428"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
578536 may be abbreviated by just typing a number of filenames in a list.
579537 Examples:
580
581 <p><table class="latex frame-void center">
582 <tr><td><code>?- consult(load).</code> </td><td>% consult <code>load</code>
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>
583540 or <code>load.pl</code> </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>
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>
586545 </table>
587
588 <p>The predicate <a id="idx:consult1:427"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
546 </div>
547
548 <p>The predicate <a name="idx:consult1:429"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
589549 is equivalent to <code>load_files(File, [])</code>, except for handling
590550 the special file <code>user</code>, which reads clauses from the
591551 terminal. See also the <code>stream(Input)</code> option of
592 <a id="idx:loadfiles2:428"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
552 <a name="idx:loadfiles2:430"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
593553 Abbreviation using <code>?- [file1,file2].</code> does
594554 <em>not</em> work for the empty list (<code>[]</code>). This facility is
595555 implemented by defining the list as a predicate. Applications may only
596556 rely on using the list abbreviation at the Prolog toplevel and in
597557 directives.</dd>
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>.
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:431"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>.
601561 Otherwise, if the file defines a module, import all public predicates.
602562 Finally, if the file is already loaded, is not a module file, and the
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>.
563 context module is not the global user module, <a name="idx:ensureloaded1:432"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>
564 will call <a name="idx:consult1:433"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>.
605565
606566 <p>With this semantics, we hope to get as close as possible to the clear
607567 semantics without the presence of a module system. Applications using
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>.
568 modules should consider using <a name="idx:usemodule12:434"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>.
609569
610570 <p>Equivalent to <code>load_files(Files, [if(not_loaded)]).</code><sup class="fn">47<span class="fn-text">On
611571 older versions the condition used to be <code>if(changed)</code>. Poor
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>
572 time management on some machines or copying often caused problems. The <a name="idx:make0:435"></a><a class="pred" href="consulting.html#make/0">make/0</a>
613573 predicate deals with updating the running system after changing the
614574 source code.</span></sup></dd>
615 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="include/1"><strong>include</strong>(<var>+File</var>)</a></dt>
575 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="include/1"><strong>include</strong>(<var>+File</var>)</a></dt>
616576 <dd class="defbody">
617577 Textually include the content of <var>File</var> at the position where
618578 the
619579 <em>directive</em> <code>:- include(File).</code> appears. The include
620580 construct is only honoured if it appears as a directive in a source
621581 file. <em>Textual</em> include (similar to C/C++ #include) is obviously
622 useful for sharing declarations such as <a id="idx:dynamic1:434"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
582 useful for sharing declarations such as <a name="idx:dynamic1:436"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
623583 or
624 <a id="idx:multifile1:435"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>
584 <a name="idx:multifile1:437"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>
625585 by including a file with directives from multiple files that use these
626586 predicates.
627587
630590 in which they are defined. This information is used to <em>replace</em>
631591 the old definition after the file has been modified and is reloaded by,
632592 e.g.,
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>
593 <a name="idx:make0:438"></a><a class="pred" href="consulting.html#make/0">make/0</a>.
594 As we understand it, <a name="idx:include1:439"></a><a class="pred" href="consulting.html#include/1">include/1</a>
635595 is intended to include the same file multiple times. Including a file
636596 holding clauses multiple times into the same module is rather
637597 meaningless as it just duplicates the same clauses. Including a file
638598 holding clauses in multiple modules does not suffer from this problem,
639599 but leads to multiple equivalent
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>
600 <em>copies</em> of predicates. Using <a name="idx:usemodule1:440"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
641601 can achieve the same result while <em>sharing</em> the predicates.
642602
643 <p>If <a id="idx:include1:439"></a><a class="pred" href="consulting.html#include/1">include/1</a>
603 <p>If <a name="idx:include1:441"></a><a class="pred" href="consulting.html#include/1">include/1</a>
644604 is used to load files holding clauses, and if these files are loaded
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>
605 only once, then these <a name="idx:include1:442"></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:443"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>).
607 However, there are several cases where either <a name="idx:include1:444"></a><a class="pred" href="consulting.html#include/1">include/1</a>
648608 has no alternative, or using any alternative also requires other
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>
609 changes. An example of the former is using <a name="idx:include1:445"></a><a class="pred" href="consulting.html#include/1">include/1</a>
650610 to share directives. An example of the latter are cases where clauses of
651611 different predicates are distributed over multiple files: If these files
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>
612 are loaded with <a name="idx:include1:446"></a><a class="pred" href="consulting.html#include/1">include/1</a>,
613 the directive <a name="idx:discontiguous1:447"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
654614 is appropriate, whereas if they are consulted, one must use the
655 directive <a id="idx:multifile1:446"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.
615 directive <a name="idx:multifile1:448"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.
656616
657617 <p>To accommodate included files holding clauses, SWI-Prolog
658618 distinguishes between the source location of a clause (in this case the
659619 included file) and the <em>owner</em> of a clause (the file that
660620 includes the file holding the clause). The source location is used by,
661 e.g., <a id="idx:edit1:447"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
621 e.g., <a name="idx:edit1:449"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
662622 the graphical tracer, etc., while the owner is used to determine which
663623 clauses are removed if the file is modified. Relevant information is
664624 found with the following predicates:
665625
666626 <p>
667627 <ul class="latex">
668 <li><a id="idx:sourcefile2:448"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>
628 <li><a name="idx:sourcefile2:450"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>
669629 describes the owner relation.
670 <li><a id="idx:predicateproperty2:449"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
630 <li><a name="idx:predicateproperty2:451"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
671631 describes the source location (of the first clause).
672 <li><a id="idx:clauseproperty2:450"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>
632 <li><a name="idx:clauseproperty2:452"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>
673633 provides access to both source and ownership.
674 <li><a id="idx:sourcefileproperty2:451"></a><a class="pred" href="consulting.html#source_file_property/2">source_file_property/2</a>
634 <li><a name="idx:sourcefileproperty2:453"></a><a class="pred" href="consulting.html#source_file_property/2">source_file_property/2</a>
675635 can be used to query include relationships between files.
676636 </ul>
677637 </dd>
678 <dt class="pubdef"><a id="require/1"><strong>require</strong>(<var>+ListOfNameAndArity</var>)</a></dt>
638 <dt class="pubdef"><a name="require/1"><strong>require</strong>(<var>+ListOfNameAndArity</var>)</a></dt>
679639 <dd class="defbody">
680640 Declare that this file/module requires the specified predicates to be
681641 defined ``with their commonly accepted definition''. This predicate
689649
690650 <p>SWI-Prolog, having autoloading, does <b>not</b> load the library.
691651 Instead it creates a procedure header for the predicate if it does not
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>
652 exist. This will flag the predicate as `undefined'. See also <a name="idx:check0:454"></a><a class="pred" href="check.html#check/0">check/0</a>
693653 and
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>
654 <a name="idx:autoload0:455"></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>
696656 <dd class="defbody">
697657 This directive can appear anywhere in a source file to define how
698658 characters are encoded in the remainder of the file. It can be used in
699659 files that are encoded with a superset of US-ASCII, currently UTF-8 and
700 ISO Latin-1. See also <a class="sec" href="widechars.html#sec:2.19.1">section
660 ISO Latin-1. See also <a class="sec" href="widechars.html">section
701661 2.19.1</a>.</dd>
702 <dt class="pubdef"><a id="make/0"><strong>make</strong></a></dt>
662 <dt class="pubdef"><a name="make/0"><strong>make</strong></a></dt>
703663 <dd class="defbody">
704664 Consult all source files that have been changed since they were
705665 consulted. It checks <var>all</var> loaded source files: files loaded
706666 into a compiled state using <code>pl -c ...</code> and files loaded
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>
667 using <a name="idx:consult1:456"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
668 or one of its derivatives. The predicate <a name="idx:make0:457"></a><a class="pred" href="consulting.html#make/0">make/0</a>
709669 is called after
710 <a id="idx:edit1:456"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
670 <a name="idx:edit1:458"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
711671 automatically reloading all modified files. If the user uses an external
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>
672 editor (in a separate window), <a name="idx:make0:459"></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:460"></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:461"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>
716676 from the <code>library(check)</code> library to report on undefined
717677 predicates.</dd>
718 <dt class="pubdef"><a id="library_directory/1"><strong>library_directory</strong>(<var>?Atom</var>)</a></dt>
678 <dt class="pubdef"><a name="library_directory/1"><strong>library_directory</strong>(<var>?Atom</var>)</a></dt>
719679 <dd class="defbody">
720680 Dynamic predicate used to specify library directories. Default
721681 <code>./lib</code>, <code> /lib/prolog</code> and the system's library
722682 (in this order) are defined. The user may add library directories using
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,
683 <a name="idx:assertz1:462"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:asserta1:463"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
684 or remove system defaults using <a name="idx:retract1:464"></a><a class="pred" href="db.html#retract/1">retract/1</a>.
685 Deprecated. New code should use <a name="idx:filesearchpath2:465"></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,
727687 -Path</var>)</a></dt>
728688 <dd class="defbody">
729689 Dynamic multifile hook predicate used to specify `path aliases'. This
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>
690 hook is called by <a name="idx:absolutefilename3:466"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
731691 to search files specified as
732692 <code>Alias(Name)</code>, e.g., <code>library(lists)</code>. This
733693 feature is best described using an example. Given the definition:
738698
739699 <p>the file specification <code>demo(myfile)</code> will be expanded to
740700 <code>/usr/lib/prolog/demo/myfile</code>. The second argument of
741 <a id="idx:filesearchpath2:465"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
701 <a name="idx:filesearchpath2:467"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
742702 may be another alias.
743703
744704 <p>Below is the initial definition of the file search path. This path
746706 in the SWI-Prolog home directory. The alias <code>foreign(&lt;<var>Path</var>&gt;)</code>
747707 is intended for storing shared libraries (<code>.so</code> or <code>.DLL</code>
748708 files). See also
749 <a id="idx:useforeignlibrary1:466"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>.
709 <a name="idx:useforeignlibrary1:468"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>.
750710
751711 <pre class="code">
752712 user:file_search_path(library, X) :-
766726 member(Dir, Dirs).
767727 </pre>
768728
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>.
729 <p>The <a name="idx:filesearchpath2:469"></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:470"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>.
771731
772732 <p>The Prolog flag <a class="flag" href="flags.html#flag:verbose_file_search">verbose_file_search</a>
773733 can be set to <code>true</code> to help debugging Prolog's search for
774734 files.</dd>
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,
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,
776736 -Path</var>)</a></dt>
777737 <dd class="defbody">
778738 Unifies <var>Path</var> with all possible expansions of the filename
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,
739 specification <var>Spec</var>. See also <a name="idx:absolutefilename3:471"></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,
781741 ?Type</var>)</a></dt>
782742 <dd class="defbody">
783743 This dynamic multifile predicate defined in module <code>user</code>
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>.
744 determines the extensions considered by <a name="idx:filesearchpath2:472"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
785745 <var>Extension</var> is the filename extension without the leading dot,
786746 and
787747 <var>Type</var> denotes the type as used by the <code>file_type(Type)</code>
788 option of <a id="idx:filesearchpath2:471"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
748 option of <a name="idx:filesearchpath2:473"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
789749 Here is the initial definition of
790 <a id="idx:prologfiletype2:472"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>:
750 <a name="idx:prologfiletype2:474"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>:
791751
792752 <pre class="code">
793753 user:prolog_file_type(pl, prolog).
804764 Prolog implementation. We suggest using <code>.pro</code> for avoiding
805765 conflicts with <b>perl</b>. Overriding the system definitions can stop
806766 the system from finding libraries.</dd>
807 <dt class="pubdef"><a id="source_file/1"><strong>source_file</strong>(<var>?File</var>)</a></dt>
767 <dt class="pubdef"><a name="source_file/1"><strong>source_file</strong>(<var>?File</var>)</a></dt>
808768 <dd class="defbody">
809769 True if <var>File</var> is a loaded Prolog source file. <var>File</var>
810770 is the absolute and canonical path to the source file.</dd>
811 <dt class="pubdef"><a id="source_file/2"><strong>source_file</strong>(<var>:Pred,
771 <dt class="pubdef"><a name="source_file/2"><strong>source_file</strong>(<var>:Pred,
812772 ?File</var>)</a></dt>
813773 <dd class="defbody">
814774 True if the predicate specified by <var>Pred</var> is owned by file
815775 <var>File</var>, where <var>File</var> is an absolute path name (see
816 <a id="idx:absolutefilename2:473"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
776 <a name="idx:absolutefilename2:475"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
817777 Can be used with any instantiation pattern, but the database only
818778 maintains the source file for each predicate. If
819779 <var>Pred</var> is a <em>multifile</em> predicate this predicate
820780 succeeds for all files that contribute clauses to <var>Pred</var>.<sup class="fn">48<span class="fn-text">The
821781 current implementation performs a linear scan through all clauses to
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>.
782 establish this set of files.</span></sup> See also <a name="idx:clauseproperty2:476"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.
823783 Note that the relation between files and predicates is more complicated
824 if <a id="idx:include1:475"></a><a class="pred" href="consulting.html#include/1">include/1</a>
784 if <a name="idx:include1:477"></a><a class="pred" href="consulting.html#include/1">include/1</a>
825785 is used. The predicate describes the <em>owner</em> of the predicate.
826786 See
827 <a id="idx:include1:476"></a><a class="pred" href="consulting.html#include/1">include/1</a>
787 <a name="idx:include1:478"></a><a class="pred" href="consulting.html#include/1">include/1</a>
828788 for details.</dd>
829 <dt class="pubdef"><a id="source_file_property/2"><strong>source_file_property</strong>(<var>?File,
789 <dt class="pubdef"><a name="source_file_property/2"><strong>source_file_property</strong>(<var>?File,
830790 ?Property</var>)</a></dt>
831791 <dd class="defbody">
832792 True when <var>Property</var> is a property of the loaded file <var>File</var>.
833793 If <var>File</var> is non-var, it can be a file specification that is
834 valid for <a id="idx:loadfiles2:477"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
794 valid for <a name="idx:loadfiles2:479"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
835795 Defined properties are:
836796
837797 <dl class="latex">
841801 was last modified at time <var>OriginalModified</var> at the time it was
842802 loaded. This property is available if <var>File</var> was loaded using
843803 the
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>
804 <code>derived_from(Original)</code> option to <a name="idx:loadfiles2:480"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
845805 <dt><strong>includes</strong>(<var>IncludedFile, IncludedFileModified</var>)</dt>
846806 <dd class="defbody">
847 <var>File</var> used <a id="idx:include1:479"></a><a class="pred" href="consulting.html#include/1">include/1</a>
807 <var>File</var> used <a name="idx:include1:481"></a><a class="pred" href="consulting.html#include/1">include/1</a>
848808 to include <var>IncludedFile</var>. The last modified time of <var>IncludedFile</var>
849809 was <var>IncludedFileModified</var> at the time it was included.</dd>
850810 <dt><strong>included_in</strong>(<var>MasterFile, Line</var>)</dt>
860820 the file was loaded. It is either a term &lt;<var>file</var>&gt;:&lt;<var>line</var>&gt;
861821 or the atom
862822 <code>user</code> if the file was loaded from the terminal or another
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>,
823 unknown source. <var>Options</var> are the options passed to <a name="idx:loadfiles2:482"></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:483"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>,
865825 using the option argument to specify the exact behaviour.</dd>
866826 <dt><strong>load_count</strong>(<var>-Count</var>)</dt>
867827 <dd class="defbody">
870830 <dt><strong>modified</strong>(<var>Stamp</var>)</dt>
871831 <dd class="defbody">
872832 File modification time when <var>File</var> was loaded. This is used by
873 <a id="idx:make0:482"></a><a class="pred" href="consulting.html#make/0">make/0</a>
833 <a name="idx:make0:484"></a><a class="pred" href="consulting.html#make/0">make/0</a>
874834 to find files whose modification time is different from when it was
875835 loaded.</dd>
876836 <dt><strong>module</strong>(<var>Module</var>)</dt>
888848 </dl>
889849
890850 </dd>
891 <dt class="pubdef"><a id="unload_file/1"><strong>unload_file</strong>(<var>+File</var>)</a></dt>
851 <dt class="pubdef"><a name="unload_file/1"><strong>unload_file</strong>(<var>+File</var>)</a></dt>
892852 <dd class="defbody">
893853 Remove all clauses loaded from <var>File</var>. If <var>File</var>
894854 loaded a module, clear the module's export list and disassociate it from
895855 the file. <var>File</var> is a canonical filename or a file indicator
896 that is valid for <a id="idx:loadfiles2:483"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
856 that is valid for <a name="idx:loadfiles2:485"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
897857
898858 <p>This predicate should be used with care. The multithreaded nature of
899859 SWI-Prolog makes removing static code unsafe. Attempts to do this should
900860 be reserved for development or situations where the application can
901861 guarantee that none of the clauses associated to <var>File</var> are
902862 active.</dd>
903 <dt class="pubdef"><a id="prolog_load_context/2"><strong>prolog_load_context</strong>(<var>?Key,
863 <dt class="pubdef"><a name="prolog_load_context/2"><strong>prolog_load_context</strong>(<var>?Key,
904864 ?Value</var>)</a></dt>
905865 <dd class="defbody">
906866 Obtain context information during compilation. This predicate can be
907867 used from directives appearing in a source file to get information about
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>
868 the file being loaded as well as by the <a name="idx:termexpansion2:486"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
909869 and
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>.
870 <a name="idx:goalexpansion2:487"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
871 hooks. See also <a name="idx:sourcelocation2:488"></a><a class="pred" href="consulting.html#source_location/2">source_location/2</a>
872 and <a name="idx:if1:489"></a><a class="pred" href="consulting.html#if/1">if/1</a>.
913873 The following keys are defined:
914874
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>
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>
918879 lives </td></tr>
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
880 <tr valign="top"><td><code>dialect</code> </td><td>Compatibility mode.
881 See <a name="idx:expectsdialect1:490"></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
922884 being processed </td></tr>
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
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
926889 <b>re</b>loaded. Not present on first load </td></tr>
927 <tr><td><code>script</code> </td><td>Boolean that indicates whether the
928 file is loaded as a script file (see
890 <tr valign="top"><td><code>script</code> </td><td>Boolean that indicates
891 whether the file is loaded as a script file (see
929892 <strong>-s</strong>) </td></tr>
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
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
933896 <code>.qlf</code> file. </td></tr>
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>
897 <tr valign="top"><td><code>stream</code> </td><td>Stream identifier (see <a name="idx:currentinput1:491"></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:492"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>
938901 (<code>position</code> property and
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
902 <a name="idx:streampositiondata3:493"></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
940903 to version 7.1.22, the position term carried fake data except for the <code>line_count</code>
941904 and had <b>five</b> arguments, where the position property of a stream
942905 only has <b>four</b>.</span></sup> </td></tr>
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>
906 <tr valign="top"><td><code>term</code> </td><td>Term being expanded by <a name="idx:expandterm2:494"></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:495"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
946909 for details. </td></tr>
947910 </table>
948911
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>.
912 <p>The <code>directory</code> is commonly used to add rules to <a name="idx:filesearchpath2:496"></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:497"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
951914 For example:
952915
953916 <pre class="code">
964927 </pre>
965928
966929 </dd>
967 <dt class="pubdef"><a id="source_location/2"><strong>source_location</strong>(<var>-File,
930 <dt class="pubdef"><a name="source_location/2"><strong>source_location</strong>(<var>-File,
968931 -Line</var>)</a></dt>
969932 <dd class="defbody">
970933 If the last term has been read from a physical file (i.e., not from the
971934 file <code>user</code> or a string), unify <var>File</var> with an
972935 absolute path to the file and <var>Line</var> with the line number in
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>
936 the file. New code should use <a name="idx:prologloadcontext2:498"></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>
975938 <dd class="defbody">
976939 Register <var>Goal</var> to be run from <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</a>,
977940 which is called when the system halts. The hooks are run in the reverse
978941 order they were registered (FIFO). Success or failure executing a hook
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>
942 is ignored. If the hook raises an exception this is printed using <a name="idx:printmessage2:499"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
943 An attempt to call <a name="idx:halt01:500"></a><a class="pred" href="toplevel.html#halt/0">halt/[0,1]</a>
981944 from a hook is ignored. Hooks may call
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>
945 <a name="idx:cancelhalt1:501"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>,
946 causing <a name="idx:halt0:502"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
984947 and <a class="func" href="foreigninclude.html#PL_halt()">PL_halt(0)</a>
985948 to print a message indicating that halting the system has been
986949 cancelled.</dd>
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>,
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:503"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>,
990953 halting Prolog is cancelled and an informational message is printed that
991954 includes <var>Reason</var>. This is used by the development tools to
992955 cancel halting the system if the editor has unsafed data and the user
993956 decides to cancel.</dd>
994 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="initialization/1">:- <strong>initialization</strong>(<var>:Goal</var>)</a></dt>
957 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="initialization/1">:- <strong>initialization</strong>(<var>:Goal</var>)</a></dt>
995958 <dd class="defbody">
996959 Call <var>Goal</var> <em>after</em> loading the source file in which
997960 this directive appears has been completed. In addition, <var>Goal</var>
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>
961 is executed if a saved state created using <a name="idx:qsaveprogram1:504"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>
999962 is restored.
1000963
1001964 <p>The ISO standard only allows for using <code>:- Term</code> if <var>Term</var>
1002965 is a
1003966 <em>directive</em>. This means that arbitrary goals can only be called
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>
967 from a directive by means of the <a name="idx:initialization1:505"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1005968 directive. SWI-Prolog does not enforce this rule.
1006969
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>).
970 <p>The <a name="idx:initialization1:506"></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:507"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/1</a>).
1009972 A saved state contains the predicates, Prolog flags and operators
1010973 present at the moment the state was created. Other resources (records,
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>
974 foreign resources, etc.) must be recreated using <a name="idx:initialization1:508"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1012975 directives or from the entry goal of the saved state.
1013976
1014977 <p>Up to SWI-Prolog 5.7.11, <var>Goal</var> was executed immediately
1015978 rather than after loading the program text in which the directive
1016979 appears as dictated by the ISO standard. In many cases the exact moment
1017980 of execution is irrelevant, but there are exceptions. For example,
1018 <a id="idx:loadforeignlibrary1:507"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
981 <a name="idx:loadforeignlibrary1:509"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
1019982 must be executed immediately to make the loaded foreign predicates
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>
983 available for exporting. SWI-Prolog now provides the directive <a name="idx:useforeignlibrary1:510"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
1021984 to ensure immediate loading as well as loading after restoring a saved
1022985 state. If the system encounters a directive <code>:-
1023986 initialization(load_foreign_library(...))</code>, it will load the
1025988 This behaviour can be extended by providing clauses for the multifile
1026989 hook predicate <code>prolog:initialize_now(Term, Advice)</code>, where <var>Advice</var>
1027990 is an atom that gives advice on how to resolve the compatibility issue.</dd>
1028 <dt class="pubdef"><a id="initialization/2"><strong>initialization</strong>(<var>:Goal,
991 <dt class="pubdef"><a name="initialization/2"><strong>initialization</strong>(<var>:Goal,
1029992 +When</var>)</a></dt>
1030993 <dd class="defbody">
1031 Similar to <a id="idx:initialization1:509"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
994 Similar to <a name="idx:initialization1:511"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
1032995 but allows for specifying when <var>Goal</var> is executed while loading
1033996 the program text:
1034997
10401003 <dd class="defbody">
10411004 Execute <var>Goal</var> after loading the program text in which the
10421005 directive appears. This is the same as
1043 <a id="idx:initialization1:510"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.</dd>
1006 <a name="idx:initialization1:512"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.</dd>
10441007 <dt><strong>restore</strong></dt>
10451008 <dd class="defbody">
10461009 Do not execute <var>Goal</var> while loading the program, but <em>only</em>
10521015 encountered and a failure or exception causes the Prolog to exit with
10531016 non-zero exit status. These goals are <em>not</em> executed if the
10541017 <strong>-l</strong> is given to merely <em>load</em> files. In that case
1055 they may be executed explicitly using <a id="idx:initialize0:511"></a><span class="pred-ext">initialize/0</span>.
1018 they may be executed explicitly using <a name="idx:initialize0:513"></a><span class="pred-ext">initialize/0</span>.
10561019 See also
1057 <a class="sec" href="compilation.html#sec:2.10.2.1">section 2.10.2.1</a>.</dd>
1020 <a class="sec" href="compilation.html">section 2.10.2.1</a>.</dd>
10581021 <dt><strong>main</strong></dt>
10591022 <dd class="defbody">
10601023 When Prolog starts, the last goal registered using
10611024 <code>initialization(Goal, main)</code> is executed as main goal. If
10621025 <var>Goal</var> fails or raises an exception, the process terminates
10631026 with non-zero exit code. If not explicitly specified using the
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>,
1027 <strong>-t</strong> the <em>toplevel goal</em> is set to <a name="idx:halt0:514"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>,
10651028 causing the process to exit with status 0. An explicitly specified
10661029 toplevel is executed normally. This implies that <code>-t prolog</code>
10671030 causes the application to start the normal interactive toplevel after
10681031 completing
10691032 <var>Goal</var>. See also the Prolog flag <a class="flag" href="flags.html#flag:toplevel_goal">toplevel_goal</a>
10701033 and
1071 <a class="sec" href="compilation.html#sec:2.10.2.1">section 2.10.2.1</a>.
1034 <a class="sec" href="compilation.html">section 2.10.2.1</a>.
10721035 </dd>
10731036 </dl>
10741037
10751038 </dd>
1076 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="initialization/0"><strong>initialization</strong></a></dt>
1039 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="initialization/0"><strong>initialization</strong></a></dt>
10771040 <dd class="defbody">
10781041 Run all initialization goals registered using
10791042 <code>initialization(Goal, program)</code>. Raises an error
10801043 <code>initialization_error(Reason, Goal, File:Line)</code> if <var>Goal</var>
10811044 fails or raises an exception. <var>Reason</var> is <code>failed</code>
10821045 or the exception raised.</dd>
1083 <dt class="pubdef"><a id="compiling/0"><strong>compiling</strong></a></dt>
1046 <dt class="pubdef"><a name="compiling/0"><strong>compiling</strong></a></dt>
10841047 <dd class="defbody">
10851048 True if the system is compiling source files with the <strong>-c</strong>
1086 option or <a id="idx:qcompile1:513"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
1049 option or <a name="idx:qcompile1:515"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
10871050 into an intermediate code file. Can be used to perform conditional code
1088 optimisations in <a id="idx:termexpansion2:514"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1051 optimisations in <a name="idx:termexpansion2:516"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
10891052 (see also the
10901053 <strong>-O</strong> option) or to omit execution of directives during
10911054 compilation.
10921055 </dd>
10931056 </dl>
10941057
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
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
10961059 compilation and program transformation</span></a></h3>
10971060
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>
1061 <a name="sec:progtransform"></a>
1062
1063 <p><a name="idx:transformationofprogram:517"></a>ISO Prolog defines no
1064 way for program transformations such as macro expansion or conditional
1065 compilation. Expansion through <a name="idx:termexpansion2:518"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1066 and <a name="idx:expandterm2:519"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
11041067 can be seen as part of the de-facto standard. This mechanism can do
11051068 arbitrary translation between valid Prolog terms read from the source
11061069 file to Prolog terms handed to the compiler. As
1107 <a id="idx:termexpansion2:518"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
1070 <a name="idx:termexpansion2:520"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
11081071 can return a list, the transformation does not need to be term-to-term.
11091072
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>
1073 <p>Various Prolog dialects provide the analogous <a name="idx:goalexpansion2:521"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11111074 and
1112 <a id="idx:expandgoal2:520"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
1075 <a name="idx:expandgoal2:522"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
11131076 that allow for translation of individual body terms, freeing the user of
11141077 the task to disassemble each clause.
11151078
11161079 <dl class="latex">
1117 <dt class="pubdef"><a id="term_expansion/2"><strong>term_expansion</strong>(<var>+Term1,
1080 <dt class="pubdef"><a name="term_expansion/2"><strong>term_expansion</strong>(<var>+Term1,
11181081 -Term2</var>)</a></dt>
11191082 <dd class="defbody">
11201083 Dynamic and multifile predicate, normally not defined. When defined by
11301093 <code>'$source_location'(&lt;<var>File</var>&gt;, &lt;<var>Line</var>&gt;):&lt;<var>Clause</var>&gt;</code>
11311094 </blockquote>
11321095
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>
1096 <p>When compiling a module (see <a class="sec" href="modules.html">chapter
1097 6</a> and the directive <a name="idx:module2:523"></a><a class="pred" href="defmodule.html#module/2">module/2</a>),
1098 <a name="idx:expandterm2:524"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1099 will first try <a name="idx:termexpansion2:525"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
11371100 in the module being compiled to allow for term expansion rules that are
11381101 local to a module. If there is no local definition, or the local
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>
1102 definition fails to translate the term, <a name="idx:expandterm2:526"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
1103 will try <a name="idx:termexpansion2:527"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
11411104 in module
11421105 <code>user</code>. For compatibility with SICStus and Quintus Prolog,
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>
1106 this feature should not be used. See also <a name="idx:expandterm2:528"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>, <a name="idx:goalexpansion2:529"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11441107 and
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,
1108 <a name="idx:expandgoal2:530"></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,
11471110 -Term2</var>)</a></dt>
11481111 <dd class="defbody">
11491112 This predicate is normally called by the compiler on terms read from the
11531116 <p>
11541117 <ol class="latex">
11551118 <li>Test conditional compilation directives and translate all input to <code>[]</code>
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
1119 if we are in a `false branch' of the conditional compilation. See <a class="sec" href="consulting.html">section
11571120 4.3.1.2</a>.
11581121
11591122 <p>
1160 <li>Call <a id="idx:termexpansion2:529"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>.
1123 <li>Call <a name="idx:termexpansion2:531"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>.
11611124 This predicate is first tried in the module that is being compiled and
11621125 then in the module
11631126 <code>user</code>.
11641127
11651128 <p>
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>).
1129 <li>Call DCG expansion (<a name="idx:dcgtranslaterule2:532"></a><a class="pred" href="consulting.html#dcg_translate_rule/2">dcg_translate_rule/2</a>).
11671130
11681131 <p>
1169 <li>Call <a id="idx:expandgoal2:531"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
1132 <li>Call <a name="idx:expandgoal2:533"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
11701133 on each body term that appears in the output of the previous steps.
11711134 </ol>
11721135 </dd>
1173 <dt class="pubdef"><a id="goal_expansion/2"><strong>goal_expansion</strong>(<var>+Goal1,
1136 <dt class="pubdef"><a name="goal_expansion/2"><strong>goal_expansion</strong>(<var>+Goal1,
11741137 -Goal2</var>)</a></dt>
11751138 <dd class="defbody">
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>
1139 Like <a name="idx:termexpansion2:534"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a name="idx:goalexpansion2:535"></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:536"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>
11781141 and the actual compilation, the body of clauses analysed and the goals
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>
1142 are handed to <a name="idx:expandgoal2:537"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>,
1143 which uses the <a name="idx:goalexpansion2:538"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11811144 hook to do user-defined expansion.
11821145
1183 <p>The predicate <a id="idx:goalexpansion2:537"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1146 <p>The predicate <a name="idx:goalexpansion2:539"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11841147 is first called in the module that is being compiled, and then follows
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>,
1148 the module inheritance path as defined by <a name="idx:defaultmodule2:540"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>,
11861149 i.e., by default <code>user</code> and <code>system</code>. If <var>Goal</var>
11871150 is of the form <var>Module</var>:<var>Goal</var> where <var>Module</var>
1188 is instantiated, <a id="idx:goalexpansion2:539"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1151 is instantiated, <a name="idx:goalexpansion2:541"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
11891152 is called on <var>Goal</var> using rules from module <var>Module</var>
11901153 followed by default modules for <var>Module</var>.
11911154
11921155 <p>Only goals appearing in the body of clauses when reading a source
11931156 file are expanded using this mechanism, and only if they appear
11941157 literally in the clause, or as an argument to a defined meta-predicate
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>).
1158 that is annotated using `0' (see <a name="idx:metapredicate1:542"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>).
11961159 Other cases need a real predicate definition.
11971160
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>
1161 <p>The expansion hook can use <a name="idx:prologloadcontext2:543"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>
11991162 to obtain information about the context in which the goal is exanded
12001163 such as the module, variable names or the encapsulating term.</dd>
1201 <dt class="pubdef"><a id="expand_goal/2"><strong>expand_goal</strong>(<var>+Goal1,
1164 <dt class="pubdef"><a name="expand_goal/2"><strong>expand_goal</strong>(<var>+Goal1,
12021165 -Goal2</var>)</a></dt>
12031166 <dd class="defbody">
12041167 This predicate is normally called by the compiler to perform
1205 preprocessing using <a id="idx:goalexpansion2:542"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
1168 preprocessing using <a name="idx:goalexpansion2:544"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
12061169 The predicate computes a fixed-point by applying transformations until
12071170 there are no more changes. If optimisation is enabled (see <strong>-O</strong>
12081171 and
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>
1172 <a class="flag" href="flags.html#flag:optimise">optimise</a>), <a name="idx:expandgoal2:545"></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:546"></a><a class="pred" href="control.html#true/0">true/0</a>
1174 and <a name="idx:fail0:547"></a><a class="pred" href="control.html#fail/0">fail/0</a>
12121175 as well as unreachable branches.</dd>
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>.
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:548"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
12161179 This predicate compiles the argument clauses into static predicates,
12171180 associating the predicates with the current file but avoids changing the
12181181 notion of current predicate and therefore discontiguous warnings.
12191182
12201183 <p>Note that in some cases multiple expansions of similar goals can
12211184 share the same compiled auxiliary predicate. In such cases, the
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>
1185 implementation of <a name="idx:goalexpansion2:549"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1186 can use <a name="idx:predicateproperty2:550"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
12241187 using the property
12251188 <code>defined</code> to test whether the predicate is already defined in
12261189 the current context.</dd>
1227 <dt class="pubdef"><a id="dcg_translate_rule/2"><strong>dcg_translate_rule</strong>(<var>+In,
1190 <dt class="pubdef"><a name="dcg_translate_rule/2"><strong>dcg_translate_rule</strong>(<var>+In,
12281191 -Out</var>)</a></dt>
12291192 <dd class="defbody">
12301193 This predicate performs the translation of a term <code>Head--&gt;Body</code>
12311194 into a normal Prolog clause. Normally this functionality should be
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,
1195 accessed using <a name="idx:expandterm2:551"></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,
12341197 ?Property</var>)</a></dt>
12351198 <dd class="defbody">
12361199 True when <var>Property</var> is a property of <var>Var</var>. These
12371200 properties are available during goal- and term-expansion. Defined
12381201 properties are below. Future versions are likely to provide more
12391202 properties, such as whether the variable is a singleton or whether the
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>.
1203 variable is referenced in the remainder of the term. See also <a name="idx:goalexpansion2:552"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
12411204
12421205 <dl class="latex">
12431206 <dt><strong>fresh</strong>(<var>Bool</var>)</dt>
12561219 </dd>
12571220 </dl>
12581221
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
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
12601223 transformation with source layout info</span></a></h4>
12611224
1262 <a id="sec:progtransform-layout"></a>
1225 <a name="sec:progtransform-layout"></a>
12631226
12641227 <p>This sections documents extended versions of the program
12651228 transformation predicates that also transform the source layout
12741237 </ul>
12751238
12761239 <dl class="latex">
1277 <dt class="pubdef"><a id="expand_goal/4"><strong>expand_goal</strong>(<var>+Goal1,
1240 <dt class="pubdef"><a name="expand_goal/4"><strong>expand_goal</strong>(<var>+Goal1,
12781241 ?Layout1, -Goal2, -Layout2</var>)</a></dt>
1279 <dt class="pubdef"><a id="goal_expansion/4"><strong>goal_expansion</strong>(<var>+Goal1,
1242 <dt class="pubdef"><a name="goal_expansion/4"><strong>goal_expansion</strong>(<var>+Goal1,
12801243 ?Layout1, -Goal2, -Layout2</var>)</a></dt>
1281 <dt class="pubdef"><a id="expand_term/4"><strong>expand_term</strong>(<var>+Term1,
1244 <dt class="pubdef"><a name="expand_term/4"><strong>expand_term</strong>(<var>+Term1,
12821245 ?Layout1, -Term2, -Layout2</var>)</a></dt>
1283 <dt class="pubdef"><a id="term_expansion/4"><strong>term_expansion</strong>(<var>+Term1,
1246 <dt class="pubdef"><a name="term_expansion/4"><strong>term_expansion</strong>(<var>+Term1,
12841247 ?Layout1, -Term2, -Layout2</var>)</a></dt>
1285 <dt class="pubdef"><a id="dcg_translate_rule/4"><strong>dcg_translate_rule</strong>(<var>+In,
1248 <dt class="pubdef"><a name="dcg_translate_rule/4"><strong>dcg_translate_rule</strong>(<var>+In,
12861249 ?LayoutIn, -Out, -LayoutOut</var>)</a></dt>
12871250 <dd class="defbody">
12881251 These versions are called <em>before</em> their 2-argument counterparts.
12891252 The input layout term is either a variable (if no layout information is
12901253 available) or a term carrying detailed layout information as returned by
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>.
1254 the <code>subterm_positions</code> of <a name="idx:readterm2:553"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
12921255 </dd>
12931256 </dl>
12941257
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
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
12961259 compilation</span></a></h4>
12971260
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>
1261 <a name="sec:conditionalcompilation"></a>
1262
1263 <p><a name="idx:ifdirective:554"></a>Conditional compilation builds on
1264 the same principle as
1265 <a name="idx:termexpansion2:555"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>, <a name="idx:goalexpansion2:556"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
13031266 and the expansion of grammar rules to compile sections of the source
13041267 code conditionally. One of the reasons for introducing conditional
1305 compilation is to simplify writing portable code. See <a class="sec" href="dialect.html#sec:C">section
1268 compilation is to simplify writing portable code. See <a class="sec" href="dialect.html">section
13061269 C</a> for more information. Here is a simple example:
13071270
13081271 <pre class="code">
13271290 </ul>
13281291
13291292 <dl class="latex">
1330 <dt class="pubdef"><a id="if/1">:- <strong>if</strong>(<var>:Goal</var>)</a></dt>
1293 <dt class="pubdef"><a name="if/1">:- <strong>if</strong>(<var>:Goal</var>)</a></dt>
13311294 <dd class="defbody">
13321295 Compile subsequent code only if <var>Goal</var> succeeds. For enhanced
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>
1296 portability, <var>Goal</var> is processed by <a name="idx:expandgoal2:557"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>
13341297 before execution. If an error occurs, the error is printed and
13351298 processing proceeds as if
13361299 <var>Goal</var> has failed.</dd>
1337 <dt class="pubdef"><a id="elif/1">:- <strong>elif</strong>(<var>:Goal</var>)</a></dt>
1300 <dt class="pubdef"><a name="elif/1">:- <strong>elif</strong>(<var>:Goal</var>)</a></dt>
13381301 <dd class="defbody">
13391302 Equivalent to <code>:- else. :-if(Goal).</code> ... <code>:- endif.</code>
13401303 In a sequence as below, the section below the first matching <code>elif</code>
13531316 </pre>
13541317
13551318 </dd>
1356 <dt class="pubdef"><a id="else/0">:- <strong>else</strong></a></dt>
1319 <dt class="pubdef"><a name="else/0">:- <strong>else</strong></a></dt>
13571320 <dd class="defbody">
13581321 Start `else' branch.</dd>
1359 <dt class="pubdef"><a id="endif/0">:- <strong>endif</strong></a></dt>
1322 <dt class="pubdef"><a name="endif/0">:- <strong>endif</strong></a></dt>
13601323 <dd class="defbody">
13611324 End of conditional compilation.
13621325 </dd>
13631326 </dl>
13641327
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
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
13661329 files, active code and threads</span></a></h3>
13671330
1368 <a id="sec:loadrunningcode"></a>
1331 <a name="sec:loadrunningcode"></a>
13691332
13701333 <p>Traditionally, Prolog environments allow for reloading files holding
13711334 currently active code. In particular, the following sequence is a valid
13761339 <li>Trace a goal
13771340 <li>Find unexpected behaviour of a predicate
13781341 <li>Enter a <em>break</em> using the <b>b</b> command
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>
1342 <li>Fix the sources and reload them using <a name="idx:make0:558"></a><a class="pred" href="consulting.html#make/0">make/0</a>
13801343 <li>Exit the break, <em>retry</em> executing the now fixed predicate
13811344 using the <b>r</b> command
13821345 </ul>
13861349 <em>thread</em>. Executing threads switch atomically to the new
13871350 definition of modified predicates, while clauses that belong to the old
13881351 definition are (eventually) reclaimed by
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
1352 <a name="idx:garbagecollectclauses0:559"></a><a class="pred" href="memory.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.<sup class="fn">50<span class="fn-text">As
13901353 of version 7.3.12. Older versions wipe all clauses originating from the
13911354 file before loading the new clauses. This causes threads that executes
13921355 the code to (typically) die with an <em>undefined predicate</em>
14251388 after the file completes loading. Currently, <code>dynamic</code> and
14261389 <code>thread_local</code> are applied immediately.
14271390 <li>New modules are recorded in the reload context. Export declarations
1428 (the module's public list and <a id="idx:export1:558"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
1391 (the module's public list and <a name="idx:export1:560"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
14291392 calls) are both applied and recorded.
14301393 <li>When the end-of-file is reached, the following fixup steps are taken
14311394 <ol class="latex">
14371400 by changing their `erased' or `created'
14381401 <em>generation</em>. Erased clauses are (eventually) reclaimed by the <em>clause
14391402 garbage collector</em>, see
1440 <a id="idx:garbagecollectclauses0:559"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
1403 <a name="idx:garbagecollectclauses0:561"></a><a class="pred" href="memory.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
14411404 <li>Pending predicate property changes are applied.
14421405 </ol>
14431406 <li>For each module
14491412 </ol>
14501413
14511414 <p>The above generally ensures that changes to the <em>content</em> of
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>.
1415 source files can typically be activated safely using <a name="idx:make0:562"></a><a class="pred" href="consulting.html#make/0">make/0</a>.
14531416 Global changes such as operator changes, changes of module names,
14541417 changes to multi-file predicates, etc. sometimes require a restart. In
14551418 almost all cases, the need for restart is indicated by permission or
14571420 program.
14581421
14591422 <p>In some cases the content of a source file refers `to itself'. This
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>
1423 is notably the case if local rules for <a name="idx:goalexpansion2:563"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1424 or <a name="idx:termexpansion2:564"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
14621425 are defined or goals are executed using
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>
1426 <em>directives</em>.<sup class="fn">51<span class="fn-text">Note that <a name="idx:initialization1:565"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
14641427 directives are executed <em>after</em> loading the file. SWI-Prolog
14651428 allows for directives that are executed <em>while</em> loading the file
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>.
1429 using <code>:- Goal.</code> or <a name="idx:initialization2:566"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a></span></sup>.
14671430 Up to version 7.5.12 it was typically needed to reload the file <em>twice</em>,
14681431 once for updating the code that was used for compiling the remainder of
14691432 the file and once to effectuate this. As of version 7.5.13, conventional <em>transaction
14731436 the new.<sup class="fn">52<span class="fn-text">This feature was
14741437 implemented by Keri Harris.</span></sup>
14751438
1476 <dl class="latex">
1477 <dt class="pubdef"><a id="garbage_collect_clauses/0"><strong>garbage_collect_clauses</strong></a></dt>
1478 <dd class="defbody">
1479 Reclaim retracted clauses. During normal operation, retracting a clause
1480 implies setting the <em>erased generation</em> to the current
1481 <em>generation</em> of the database and increment the generation.
1482 Keeping the clause around is both needed to realise the <em>logical
1483 update view</em> and deal with the fact that other threads may be
1484 executing the clause. Both static and dynamic code is processed this
1485 way.<sup class="fn">53<span class="fn-text">Up to version 7.3.11,
1486 dynamic code was handled using <em>reference counts</em>.</span></sup>.
1487
1488 <p>The clause garbage collector (CGC) scans the environment stacks of
1489 all threads for referenced dirty predicates and at which generation this
1490 reference accesses the predicate. It then removes the references for
1491 clauses that have been retracted before the oldest access generation
1492 from the clause list as well as the secondary clauses indexes of the
1493 predicate. If the clause list is not being scanned, the clause
1494 references and ultimately the clause itself is reclaimed.
1495
1496 <p>The clause garbage collector is called under three conditions, (1)
1497 after
1498 <em>reloading</em> a source file, (2) if the memory occupied by
1499 retracted but not yet reclaimed clauses exceeds 12.5% of the program
1500 store, or (3) if skipping dead clauses in the clause lists becomes too
1501 costly. The cost of clause garbage collection is proportional with the
1502 total size of the local stack of all threads (the scanning phase) and
1503 the number of clauses in all `dirty' predicates (the reclaiming phase).
1504 </dd>
1505 </dl>
1506
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
1439 <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
15081440 of mutually dependent code</span></a></h4>
15091441
1510 <a id="sec:depload"></a>
1442 <a name="sec:depload"></a>
15111443
15121444 <p>Large programs are generally split into multiple files. If file <var>A</var>
15131445 accesses predicates from file <var>B</var> which accesses predicates
15141446 from file
15151447 <var>A</var>, we consider this a mutual or circular dependency. If
1516 traditional load predicates (e.g., <a id="idx:consult1:565"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
1448 traditional load predicates (e.g., <a name="idx:consult1:567"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
15171449 are used to include file <var>B</var> from <var>A</var> and <var>A</var>
15181450 from <var>B</var>, loading either file results in a loop. This is
15191451 because
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>
1452 <a name="idx:consult1:568"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
1453 is mapped to <a name="idx:loadfiles2:569"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
15221454 using the option <code>if(true)(if(true))</code> Such programs are
15231455 typically loaded using a <em>load file</em> that consults all required
15241456 (non-module) files. If modules are used, the dependencies are made
1525 explicit using <a id="idx:usemodule1:568"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1457 explicit using <a name="idx:usemodule1:570"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
15261458 statements. The
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>
1459 <a name="idx:usemodule1:571"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1460 predicate, however, maps to <a name="idx:loadfiles2:572"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
15291461 with the option
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>
1462 <code>if(not_loaded)(if(not_loaded))</code> A <a name="idx:usemodule1:573"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
15311463 on an already loaded file merely makes the public predicates of the used
15321464 module available.
15331465
15341466 <p>Summarizing, mutual dependency of source files is fully supported
15351467 with no precautions when using modules. Modules can use each other in an
1536 arbitrary dependency graph. When using <a id="idx:consult1:572"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
1468 arbitrary dependency graph. When using <a name="idx:consult1:574"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
15371469 predicate dependencies between loaded files can still be arbitrary, but
15381470 the consult relations between files must be a proper tree.
15391471
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
1472 <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
15411473 with multiple threads</span></a></h4>
15421474
1543 <a id="sec:mtload"></a>
1475 <a name="sec:mtload"></a>
15441476
15451477 <p>This section discusses compiling files for the first time. For
1546 reloading, see <a class="sec" href="consulting.html#sec:4.3.2">section
1547 4.3.2</a>.
1478 reloading, see <a class="sec" href="consulting.html">section 4.3.2</a>.
15481479
15491480 <p>In older versions, compilation was thread-safe due to a global
1550 <em>lock</em> in <a id="idx:loadfiles2:573"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
1481 <em>lock</em> in <a name="idx:loadfiles2:575"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
15511482 and the code dealing with
1552 <em>autoloading</em> (see <a class="sec" href="autoload.html#sec:2.13">section
1483 <em>autoloading</em> (see <a class="sec" href="autoload.html">section
15531484 2.13</a>). Besides unnecessary stalling when multiple threads trap
15541485 unrelated undefined predicates, this easily leads to deadlocks, notably
15551486 if threads are started from an
1556 <a id="idx:initialization1:574"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1557 directive.<sup class="fn">54<span class="fn-text">Although such goals
1487 <a name="idx:initialization1:576"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
1488 directive.<sup class="fn">53<span class="fn-text">Although such goals
15581489 are started after loading the file in which they appear, the calling
15591490 thread is still likely to hold the `load' lock because it is compiling
15601491 the file from which the file holding the directive is loaded.</span></sup>
15621493 <p>Starting with version 5.11.27, the autoloader is no longer locked and
15631494 multiple threads can compile files concurrently. This requires special
15641495 precautions only if multiple threads wish to load the same file at the
1565 same time. Therefore, <a id="idx:loadfiles2:575"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
1496 same time. Therefore, <a name="idx:loadfiles2:577"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
15661497 checks automatically whether some other thread is already loading the
15671498 file. If not, it starts loading the file. If another thread is already
15681499 loading the file, the thread blocks until the other thread finishes
15701501 will make the public predicates available.
15711502
15721503 <p>Note that this schema does not prevent deadlocks under all
1573 situations. Consider two mutually dependent (see <a class="sec" href="consulting.html#sec:4.3.2.1">section
1504 situations. Consider two mutually dependent (see <a class="sec" href="consulting.html">section
15741505 4.3.2.1</a>) module files <var>A</var> and <var>B</var>, where thread&nbsp;1
15751506 starts loading <var>A</var> and thread&nbsp;2 starts loading
15761507 <var>B</var> at the same time. Both threads will deadlock when trying to
15801511 involved threads will freeze. This problem can be avoided if a mutually
15811512 dependent collection of files is always loaded from the same start file.
15821513
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
1514 <p><h3 id="sec:qlf"><a name="sec:4.3.3"><span class="sec-nr">4.3.3</span> <span class="sec-title">Quick
15841515 load files</span></a></h3>
15851516
1586 <a id="sec:qlf"></a>
1517 <a name="sec:qlf"></a>
15871518
15881519 <p>SWI-Prolog supports compilation of individual or multiple Prolog
15891520 source files into `Quick Load Files'. A `Quick Load File' (<code>.qlf</code>
15951526 are stored as virtual machine instructions. Changes to the compiler will
15961527 generally make old compiled files unusable.
15971528
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>.
1529 <p>Quick Load Files are created using <a name="idx:qcompile1:578"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>.
15991530 They are loaded using
1600 <a id="idx:consult1:577"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
1531 <a name="idx:consult1:579"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
16011532 or one of the other file-loading predicates described in
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>
1533 <a class="sec" href="consulting.html">section 4.3</a>. If <a name="idx:consult1:580"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
16031534 is given an explicit <code>.pl</code> file, it will load the Prolog
16041535 source. When given a <code>.qlf</code> file, it will load the file. When
16051536 no extension is specified, it will load the
16071538 otherwise.
16081539
16091540 <dl class="latex">
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>,
1541 <dt class="pubdef"><a name="qcompile/1"><strong>qcompile</strong>(<var>:File</var>)</a></dt>
1542 <dd class="defbody">
1543 Takes a file specification as <a name="idx:consult1:581"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
16131544 etc., and, in addition to the normal compilation, creates a <em>Quick
16141545 Load File</em> from <var>File</var>. The file extension of this file is <code>.qlf</code>.
16151546 The basename of the Quick Load File is the same as the input file.
16231554 the
16241555 <code>.pl</code> file.
16251556
1626 <p>For <a id="idx:termexpansion2:580"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>,
1557 <p>For <a name="idx:termexpansion2:582"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>,
16271558 the same rules as described in
1628 <a class="sec" href="compilation.html#sec:2.10">section 2.10</a> apply.
1559 <a class="sec" href="compilation.html">section 2.10</a> apply.
16291560
16301561 <p>Conditional execution or optimisation may test the predicate
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>)
1562 <a name="idx:compiling0:583"></a><a class="pred" href="consulting.html#compiling/0">compiling/0</a>.
1563
1564 <p>Source references (<a name="idx:sourcefile2:584"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>)
16341565 in the Quick Load File refer to the Prolog source file from which the
16351566 compiled code originates.</dd>
1636 <dt class="pubdef"><a id="qcompile/2"><strong>qcompile</strong>(<var>:File,
1567 <dt class="pubdef"><a name="qcompile/2"><strong>qcompile</strong>(<var>:File,
16371568 +Options</var>)</a></dt>
16381569 <dd class="defbody">
1639 As <a id="idx:qcompile1:583"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
1570 As <a name="idx:qcompile1:585"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>,
16401571 but processes additional options as defined by
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
1572 <a name="idx:loadfiles2:586"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.<sup class="fn">bug<span class="fn-text">Option
16421573 processing is currently incomplete.</span></sup>
16431574 </dd>
16441575 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section E.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="license.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="softlicense.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:contrib"><a id="sec:E.1"><span class="sec-nr">E.1</span> <span class="sec-title">Contributing
194 <h2 id="sec:contrib"><a name="sec:E.1"><span class="sec-nr">E.1</span> <span class="sec-title">Contributing
236195 to the SWI-Prolog project</span></a></h2>
237196
238 <a id="sec:contrib"></a>
197 <a name="sec:contrib"></a>
239198
240199 <p>To reach maximal coherence we will, as a rule of thumb, only accept
241200 new code that has the Simplified BSD license and existing code with a
242201 <em>permissive</em> license such as MIT, Apache, BSD-3, etc. In
243202 exceptional cases we may accept code with GPL or LGPL conditions. Such
244 code must be tagged using a <a id="idx:license1:2343"></a><a class="pred" href="softlicense.html#license/1">license/1</a>
203 code must be tagged using a <a name="idx:license1:2342"></a><a class="pred" href="softlicense.html#license/1">license/1</a>
245204 directive (Prolog) or a call to
246205 <a class="func" href="softlicense.html#PL_license()">PL_license()</a>
247206 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.7.4 Reference Manual: Section 4.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="compare.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="metacall.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:control"><a id="sec:4.8"><span class="sec-nr">4.8</span> <span class="sec-title">Control
194 <h2 id="sec:control"><a name="sec:4.8"><span class="sec-nr">4.8</span> <span class="sec-title">Control
236195 Predicates</span></a></h2>
237196
238 <a id="sec:control"></a>
197 <a name="sec:control"></a>
239198
240199 <p>The predicates of this section implement control structures. Normally
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>,
200 the constructs in this section, except for <a name="idx:repeat0:644"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>,
242201 are translated by the compiler. Please note that complex goals passed as
243 arguments to meta-predicates such as <a id="idx:findall3:643"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
202 arguments to meta-predicates such as <a name="idx:findall3:645"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
244203 below cause the goal to be compiled to a temporary location before
245204 execution. It is faster to define a sub-predicate (i.e. one_character_atoms/1
246205 in the example below) and make a call to this simple predicate.
251210 </pre>
252211
253212 <dl class="latex">
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>
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:646"></a><a class="pred" href="control.html#fail/0">fail/0</a>
257216 is translated into a single virtual machine instruction.
258217 </dd>
259 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="false/0"><strong>false</strong></a></dt>
218 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="false/0"><strong>false</strong></a></dt>
260219 <dd class="defbody">
261220 Same as fail, but the name has a more declarative connotation.
262221 </dd>
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>
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:647"></a><a class="pred" href="control.html#true/0">true/0</a>
266225 is translated into a single virtual machine instruction.
267226 </dd>
268 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="repeat/0"><strong>repeat</strong></a></dt>
227 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="repeat/0"><strong>repeat</strong></a></dt>
269228 <dd class="defbody">
270229 Always succeed, provide an infinite number of choice points.</dd>
271 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="!/0"><strong>!</strong></a></dt>
230 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="!/0"><strong>!</strong></a></dt>
272231 <dd class="defbody">
273232 Cut. Discard all choice points created since entering the predicate in
274233 which the cut appears. In other words, <em>commit</em> to the clause in
275234 which the cut appears <em>and</em> discard choice points that have been
276235 created by goals to the left of the cut in the current clause. Meta
277236 calling is opaque to the cut. This implies that cuts that appear in 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>)
237 term that is subject to meta-calling (<a name="idx:call1:648"></a><a class="pred" href="metacall.html#call/1">call/1</a>)
279238 only affect choice points created by the meta-called term. The following
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>
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>
281240 and
282241 <a class="pred" href="control.html#*->/2">*-&gt;/2</a>. Cuts appearing
283242 in the <em>condition</em> part of
284 <a class="pred" href="control.html#->/2">-&gt;/2</a> and <a class="pred" href="control.html#*->/2">*-&gt;/2</a>
243 <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a> and <a class="pred" href="control.html#*->/2">*-&gt;/2</a>
285244 are opaque to the cut. The table below explains the scope of the cut
286245 with examples. <i>Prunes</i> here means ``prunes <var>X</var> choice
287246 point created by <var>X</var>''.
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>%
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>%
295257 prunes a/0 </td></tr>
296258 </table>
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>
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>
299262 <dd class="defbody">
300263 Conjunction. True if both `Goal1' and `Goal2' can be proved. It is
301264 defined as follows (this definition does not lead to a loop as the
306269 </pre>
307270
308271 </dd>
309 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id=";/2"><var>:Goal1</var> <strong>;</strong> <var>:Goal2</var></a></dt>
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name=";/2"><var>:Goal1</var> <strong>;</strong> <var>:Goal2</var></a></dt>
310273 <dd class="defbody">
311274 The `or' predicate is defined as:
312275
316279 </pre>
317280
318281 </dd>
319 <dt class="pubdef"><a id="|/2"><var>:Goal1</var> <strong>|</strong> <var>:Goal2</var></a></dt>
282 <dt class="pubdef"><a name="|/2"><var>:Goal1</var> <strong>|</strong> <var>:Goal2</var></a></dt>
320283 <dd class="defbody">
321284 Equivalent to <a class="pred" href="control.html#;/2">;/2</a>. Retained
322285 for compatibility only. New code should use <a class="pred" href="control.html#;/2">;/2</a>.</dd>
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>
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>
326289 construct commits to the choices made at its left-hand side, destroying
327290 choice points created inside the clause (by <a class="pred" href="control.html#;/2">;/2</a>),
328291 or by goals called by this clause. Unlike <a class="pred" href="control.html#!/0">!/0</a>,
329292 the choice point of the predicate as a whole (due to multiple clauses)
330293 is <strong>not</strong> destroyed. The combination <a class="pred" href="control.html#;/2">;/2</a>
331 and <a class="pred" href="control.html#->/2">-&gt;/2</a> acts as if
332 defined as:
294 and <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a> acts as
295 if defined as:
333296
334297 <pre class="code">
335298 If -&gt; Then; _Else :- If, !, Then.
347310 and that the <em>combined</em> semantics of this syntactic construct as
348311 defined above is <em>different</em> from the simple nesting of the two
349312 individual constructs, i.e., the semantics of
350 <a class="pred" href="control.html#->/2">-&gt;/2</a> <em>changes</em>
313 <a class="pred" href="control.html#send_arrow/2">-&gt;/2</a> <em>changes</em>
351314 when embedded in <a class="pred" href="control.html#;/2">;/2</a>. See
352315 also
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
316 <a name="idx:once1:649"></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
355318 ; :Else</var></a></dt>
356319 <dd class="defbody">
357320 This construct implements the so-called `soft-cut'. The control is
368331 without an
369332 <var>Else</var> branch, is translated as the normal conjunction <var>A</var>,
370333 <var>B</var>.<sup class="fn">bug<span class="fn-text">The decompiler
371 implemented by <a id="idx:clause2:648"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
334 implemented by <a name="idx:clause2:650"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
372335 returns this construct as a normal conjunction too.</span></sup>
373336
374337 <p>This construct is rarely used. An example use case is the
389352 solutions
390353 <var>X=a</var> and <var>X=b</var>, while <code>optional(member(X,[]))</code>
391354 succeeds without binding <var>X</var>.</dd>
392 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="\+/1"><strong>\+</strong> <var>:Goal</var></a></dt>
355 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="\+/1"><strong>\+</strong> <var>:Goal</var></a></dt>
393356 <dd class="defbody">
394357 True if `Goal' cannot be proven (mnemonic: <code><code>+</code></code>
395358 refers to <em>provable</em> and the backslash (<code><code>\</code></code>)
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 7.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="attvar.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="chr.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>Coroutining allows us to delay the execution of Prolog goals until
240199 their truth can be safely decided.
241200
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>,
201 <p>Among the most important coroutining predicates is <a name="idx:dif2:1796"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>,
243202 which expresses <i>disequality</i> of terms in a sound way. The actual
244203 test is delayed until the terms are sufficiently different, or have
245204 become identical. For example:
255214
256215 <p>There are also lower-level coroutining predicates that are intended
257216 as building blocks for higher-level constraints. For example, we can use
258 <a id="idx:freeze2:1798"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
217 <a name="idx:freeze2:1797"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
259218 to define a variable that can only be assigned an atom:
260219
261220 <pre class="code">
263222 X = a.
264223 </pre>
265224
266 <p>In this case, calling <a id="idx:atom1:1799"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>
225 <p>In this case, calling <a name="idx:atom1:1798"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>
267226 earlier causes the whole query to fail:
268227
269228 <pre class="code">
290249 </pre>
291250
292251 <p>Remaining constraints, such as <code>X mod 2#=0</code> in the example
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>
252 above, are called <em>residual</em><a name="idx:residual:1799"></a>
253 goals. They are said to
254 <em>flounder</em><a name="idx:flounder:1800"></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:1801"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
298257 to collect all variables that are involved in constraints.
299258
300259 <dl class="latex">
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>
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:1802"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
304263 predicate is a <i>constraint</i> that is true if and only if <var>A</var>
305264 and <var>B</var> are different terms. If <var>A</var> and <var>B</var>
306 can never unify, <a id="idx:dif2:1804"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
265 can never unify, <a name="idx:dif2:1803"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
307266 succeeds deterministically. If <var>A</var> and <var>B</var> are
308267 identical, it fails immediately. Finally, if <var>A</var> and <var>B</var>
309268 can unify, goals are delayed that prevent <var>A</var> and <var>B</var>
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>
269 to become equal. It is this last property that makes <a name="idx:dif2:1804"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
311270 a more general and more declarative alternative for <a class="pred" href="compare.html#\=/2">\=/2</a>
312271 and related predicates.
313272
315274 <code>dif(X, Y) :- when(?=(X,Y), X \== Y)</code>. See also <a class="pred" href="compare.html#?=/2">?=/2</a>.
316275 The implementation can deal with cyclic terms.
317276
318 <p>The <a id="idx:dif2:1806"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
277 <p>The <a name="idx:dif2:1805"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>
319278 predicate is realised using attributed variables associated with the
320279 module <code>dif</code>. It is an autoloaded predicate that is defined
321280 in the library <code>library(dif)</code>.</dd>
322 <dt class="pubdef"><a id="freeze/2"><strong>freeze</strong>(<var>+Var,
281 <dt class="pubdef"><a name="freeze/2"><strong>freeze</strong>(<var>+Var,
323282 :Goal</var>)</a></dt>
324283 <dd class="defbody">
325284 Delay the execution of <var>Goal</var> until <var>Var</var> is bound
326285 (i.e. is not a variable or attributed variable). If <var>Var</var> is
327286 bound on entry
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>
287 <a name="idx:freeze2:1806"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
288 is equivalent to <a name="idx:call1:1807"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
289 The <a name="idx:freeze2:1808"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
331290 predicate is realised using an attributed variable associated with the
332291 module <code>freeze</code>. Use <code>frozen(Var, Goal)</code> to find
333292 out whether and which goals are delayed on <var>Var</var>.</dd>
334 <dt class="pubdef"><a id="frozen/2"><strong>frozen</strong>(<var>@Var,
293 <dt class="pubdef"><a name="frozen/2"><strong>frozen</strong>(<var>@Var,
335294 -Goal</var>)</a></dt>
336295 <dd class="defbody">
337296 Unify <var>Goal</var> with the goal or conjunction of goals delayed on
338297 <var>Var</var>. If no goals are frozen on <var>Var</var>, <var>Goal</var>
339298 is unified to <code>true</code>.</dd>
340 <dt class="pubdef"><a id="when/2"><strong>when</strong>(<var>@Condition,
299 <dt class="pubdef"><a name="when/2"><strong>when</strong>(<var>@Condition,
341300 :Goal</var>)</a></dt>
342301 <dd class="defbody">
343302 Execute <var>Goal</var> when <var>Condition</var> becomes true. <var>Condition</var>
344303 is one of <code>?=(X, Y)</code>, <code>nonvar(X)</code>, <code>ground(X)</code>,
345304 <code><code>,</code>(Cond1, Cond2)</code> or <code><code>;</code>(Cond1,
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>.
305 Cond2)</code>. See also <a name="idx:freeze2:1809"></a><a class="pred" href="coroutining.html#freeze/2">freeze/2</a>
306 and <a name="idx:dif2:1810"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>.
348307 The implementation can deal with cyclic terms in <var>X</var> and <var>Y</var>.
349308
350 <p>The <a id="idx:when2:1812"></a><a class="pred" href="coroutining.html#when/2">when/2</a>
309 <p>The <a name="idx:when2:1811"></a><a class="pred" href="coroutining.html#when/2">when/2</a>
351310 predicate is realised using attributed variables associated with the
352311 module <code>when</code>. It is defined in the autoload library
353312 <code>library(when)</code>.</dd>
354 <dt class="pubdef"><a id="call_residue_vars/2"><strong>call_residue_vars</strong>(<var>:Goal,
313 <dt class="pubdef"><a name="call_residue_vars/2"><strong>call_residue_vars</strong>(<var>:Goal,
355314 -Vars</var>)</a></dt>
356315 <dd class="defbody">
357316 Find residual attributed variables left by <var>Goal</var>. This
364323 because the constraint solver is too weak to detect the contradiction.
365324 Ideally, delayed goals and constraints are all executed at the end of
366325 the computation. The meta predicate
367 <a id="idx:callresiduevars2:1813"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
326 <a name="idx:callresiduevars2:1812"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
368327 finds variables that are given attributes or whose attributes are
369328 modified by <var>Goal</var>, regardless of whether or not these
370329 variables are reachable from the arguments of
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>
330 <var>Goal</var>.<sup class="fn">153<span class="fn-text">The
331 implementation of <a name="idx:callresiduevars2:1813"></a><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a>
373332 is completely redone in version 7.3.2 (7.2.1) after discussion with Bart
374333 Demoen. The current implementation no longer performs full scans of the
375334 stacks. The overhead is proportional to the number of attributed
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="clpqr.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="debug.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:csv"><a id="sec:A.10"><span class="sec-nr">A.10</span> <span class="sec-title">library(csv):
194 <h2 id="sec:csv"><a name="sec:A.10"><span class="sec-nr">A.10</span> <span class="sec-title">library(csv):
236195 Process CSV (Comma-Separated Values) data</span></a></h2>
237196
238 <p><a id="sec:csv"></a>
197 <p><a name="sec:csv"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">See also</dt>
255214 have the same name and arity.
256215
257216 <dl class="latex">
258 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_read_file/2"><strong>csv_read_file</strong>(<var>+File,
217 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_read_file/2"><strong>csv_read_file</strong>(<var>+File,
259218 -Rows</var>)</a></dt>
260 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_read_file/3"><strong>csv_read_file</strong>(<var>+File,
219 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_read_file/3"><strong>csv_read_file</strong>(<var>+File,
261220 -Rows, +Options</var>)</a></dt>
262221 <dd class="defbody">
263222 Read a CSV file into a list of rows. Each row is a Prolog term with the
264 same arity. <var>Options</var> is handed to <a class="pred" href="csv.html#csv//2">csv//2</a>.
223 same arity. <var>Options</var> is handed to <span class="pred-ext">csv/4</span>.
265224 Remaining options are processed by <a class="pred" href="pio.html#phrase_from_file/3">phrase_from_file/3</a>.
266225 The default separator depends on the file name extension and is <code>\t</code>
267226 for
279238 </pre>
280239
281240 </dd>
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,
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,
284243 +Options</var>)</a><code>//</code></dt>
285244 <dd class="defbody">
286245 Prolog DCG to `read/write' CSV data. <var>Options</var>:
330289 </dl>
331290
332291 </dd>
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,
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,
334293 -Row, +Options</var>)</a></dt>
335294 <dd class="defbody">
336295 True when <var>Row</var> is a row in <var>File</var>. First unifies <var>Row</var>
363322 </dl>
364323
365324 </dd>
366 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_read_row/3"><strong>csv_read_row</strong>(<var>+Stream,
325 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_read_row/3"><strong>csv_read_row</strong>(<var>+Stream,
367326 -Row, +CompiledOptions</var>)</a></dt>
368327 <dd class="defbody">
369328 Read the next CSV record from <var>Stream</var> and unify the result
370329 with <var>Row</var>.
371 <var>CompiledOptions</var> is created from options defined for <a class="pred" href="csv.html#csv//2">csv//2</a>
330 <var>CompiledOptions</var> is created from options defined for <span class="pred-ext">csv/4</span>
372331 using
373332 <a class="pred" href="csv.html#csv_options/2">csv_options/2</a>. <var>Row</var>
374333 is unified with <code>end_of_file</code> upon reaching the end of the
375334 input.</dd>
376 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_options/2"><strong>csv_options</strong>(<var>-Compiled,
335 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_options/2"><strong>csv_options</strong>(<var>-Compiled,
377336 +Options</var>)</a></dt>
378337 <dd class="defbody">
379338 <var>Compiled</var> is the compiled representation of the CSV processing
380 options as they may be passed into <a class="pred" href="csv.html#csv//2">csv//2</a>,
339 options as they may be passed into <span class="pred-ext">csv/4</span>,
381340 etc. This predicate is used in combination with <a class="pred" href="csv.html#csv_read_row/3">csv_read_row/3</a>
382341 to avoid repeated processing of the options.</dd>
383 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_write_file/2"><strong>csv_write_file</strong>(<var>+File,
342 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_write_file/2"><strong>csv_write_file</strong>(<var>+File,
384343 +Data</var>)</a></dt>
385 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_write_file/3"><strong>csv_write_file</strong>(<var>+File,
344 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_write_file/3"><strong>csv_write_file</strong>(<var>+File,
386345 +Data, +Options</var>)</a></dt>
387346 <dd class="defbody">
388347 Write a list of Prolog terms to a CSV file. <var>Options</var> are given
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>
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>
392350 for
393351 <code>.tsv</code> files and <code>,</code> otherwise.</dd>
394 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="csv_write_stream/3"><strong>csv_write_stream</strong>(<var>+Stream,
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="csv_write_stream/3"><strong>csv_write_stream</strong>(<var>+Stream,
395353 +Data, +Options</var>)</a></dt>
396354 <dd class="defbody">
397355 Write the rows in <var>Data</var> to <var>Stream</var>. This is similar
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="dynamic-modules.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="manipmodule.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ctxmodule"><a id="sec:6.13"><span class="sec-nr">6.13</span> <span class="sec-title">Transparent
194 <h2 id="sec:ctxmodule"><a name="sec:6.13"><span class="sec-nr">6.13</span> <span class="sec-title">Transparent
236195 predicates: definition and context module</span></a></h2>
237196
238 <a id="sec:ctxmodule"></a>
197 <a name="sec:ctxmodule"></a>
239198
240199 <p><i>The `module-transparent' mechanism is still underlying the actual
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>
200 implementation. Direct usage by programmers is deprecated. Please use <a name="idx:metapredicate1:1739"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
242201 to deal with meta-predicates.</i>
243202
244 <p>The qualification of module-sensitive arguments described in <a class="sec" href="metapred.html#sec:6.4">section
203 <p>The qualification of module-sensitive arguments described in <a class="sec" href="metapred.html">section
245204 6.4</a> is realised using <em>transparent</em> predicates. It is now
246205 deprecated to use this mechanism directly. However, studying the
247206 underlying mechanism helps to understand SWI-Prolog's modules. In some
258217 default, the context module is the definition module of the predicate
259218 running the goal. For transparent predicates, however, this is the
260219 context module of the goal inherited from the parent goal. Below, we
261 implement <a id="idx:maplist3:1741"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
220 implement <a name="idx:maplist3:1740"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
262221 using the transparent mechanism. The code of
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
222 <a name="idx:maplist3:1741"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
223 and <a name="idx:maplist3:1742"></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
268227 helper.
269228
270229 <pre class="code">
288247 module-sensitive arguments. For example, the module below counts the
289248 number of unique atoms returned as bindings for a variable. It works as
290249 expected. If we use the directive
291 <code>:- module_transparent <a id="idx:countatomresults3:1744"></a><span class="pred-ext">count_atom_results/3</span>.</code>
250 <code>:- module_transparent <a name="idx:countatomresults3:1743"></a><span class="pred-ext">count_atom_results/3</span>.</code>
292251 instead,
293 <a id="idx:atomresult2:1745"></a><span class="pred-ext">atom_result/2</span>
252 <a name="idx:atomresult2:1744"></a><span class="pred-ext">atom_result/2</span>
294253 is called wrongly in the module <em>calling</em>
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>
254 <a name="idx:countatomresults3:1745"></a><span class="pred-ext">count_atom_results/3</span>.
255 This can be solved using <a name="idx:stripmodule3:1746"></a><a class="pred" href="ctxmodule.html#strip_module/3">strip_module/3</a>
297256 to create a qualified goal and a non-transparent helper predicate that
298257 is defined in the same module.
299258
316275 <p>The following predicates support the module-transparent interface:
317276
318277 <dl class="latex">
319 <dt class="pubdef"><a id="module_transparent/1">:- <strong>module_transparent</strong>(<var>+Preds</var>)</a></dt>
278 <dt class="pubdef"><a name="module_transparent/1">:- <strong>module_transparent</strong>(<var>+Preds</var>)</a></dt>
320279 <dd class="defbody">
321280 <var>Preds</var> is a comma-separated list of name/arity pairs (like
322 <a id="idx:dynamic1:1748"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>).
281 <a name="idx:dynamic1:1747"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>).
323282 Each goal associated with a transparent-declared predicate will inherit
324283 the <em>context module</em> from its parent goal.</dd>
325 <dt class="pubdef"><a id="context_module/1"><strong>context_module</strong>(<var>-Module</var>)</a></dt>
284 <dt class="pubdef"><a name="context_module/1"><strong>context_module</strong>(<var>-Module</var>)</a></dt>
326285 <dd class="defbody">
327286 Unify <var>Module</var> with the context module of the current goal.
328 <a id="idx:contextmodule1:1749"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
287 <a name="idx:contextmodule1:1748"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
329288 itself is, of course, transparent.</dd>
330 <dt class="pubdef"><a id="strip_module/3"><strong>strip_module</strong>(<var>+Term,
289 <dt class="pubdef"><a name="strip_module/3"><strong>strip_module</strong>(<var>+Term,
331290 -Module, -Plain</var>)</a></dt>
332291 <dd class="defbody">
333292 Used in module-transparent predicates or meta-predicates to extract the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.17</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="syntax.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="jitindex.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:cyclic"><a id="sec:2.17"><span class="sec-nr">2.17</span> <span class="sec-title">Rational
194 <h2 id="sec:cyclic"><a name="sec:2.17"><span class="sec-nr">2.17</span> <span class="sec-title">Rational
236195 trees (cyclic terms)</span></a></h2>
237196
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
197 <a name="sec:cyclic"></a>
198
199 <p><a name="idx:rationaltrees:230"></a><a name="idx:infinitetrees:231"></a><a name="idx:cyclicterms:232"></a><a name="idx:termscyclic:233"></a>SWI-Prolog
241200 supports rational trees, also known as cyclic terms. `Supports' is so
242201 defined that most relevant built-in predicates terminate when faced with
243202 rational trees. Almost all SWI-Prolog's built-in term manipulation
255214 <a class="pred" href="compare.html#\==/2">\==/2</a>,
256215 <a class="pred" href="compare.html#\=@=/2">\=@=/2</a>,
257216 <a class="pred" href="compare.html#\=/2">\=/2</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>
217 <a name="idx:acyclicterm1:234"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>,
218 <a name="idx:bagof3:235"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
219 <a name="idx:compare3:236"></a><a class="pred" href="compare.html#compare/3">compare/3</a>,
220 <a name="idx:copyterm2:237"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
221 <a name="idx:cyclicterm1:238"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>,
222 <a name="idx:dif2:239"></a><a class="pred" href="coroutining.html#dif/2">dif/2</a>,
223 <a name="idx:duplicateterm2:240"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>,
224 <a name="idx:findall3:241"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>,
225 <a name="idx:ground1:242"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>,
226 <a name="idx:termhash2:243"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>,
227 <a name="idx:numbervars3:244"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>,
228 <a name="idx:numbervars4:245"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>,
229 <a name="idx:recorda3:246"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
230 <a name="idx:recordz3:247"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>,
231 <a name="idx:setof3:248"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>,
232 <a name="idx:subsumesterm2:249"></a><a class="pred" href="compare.html#subsumes_term/2">subsumes_term/2</a>,
233 <a name="idx:termvariables2:250"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>,
234 <a name="idx:throw1:251"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
235 <a name="idx:unifywithoccurscheck2:252"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>,
236 <a name="idx:unifiable3:253"></a><a class="pred" href="compare.html#unifiable/3">unifiable/3</a>,
237 <a name="idx:when2:254"></a><a class="pred" href="coroutining.html#when/2">when/2</a>,
238 <a name="idx:write1:255"></a><a class="pred" href="termrw.html#write/1">write/1</a>
280239 (and related predicates) .
281240
282241 <p>In addition, some built-ins recognise rational trees and raise an
283242 appropriate exception. Arithmetic evaluation belongs to this group. The
284 compiler (<a id="idx:asserta1:254"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>,
243 compiler (<a name="idx:asserta1:256"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>,
285244 etc.) also raises an exception. Future versions may support rational
286245 trees. Predicates that could provide meaningful processing of rational
287246 trees raise a <code>representation_error</code>. Predicates for which
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="DCG.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="dynamic.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>SWI-Prolog offers several ways to store data in globally accessible
240199 memory, i.e., outside the Prolog <em>stacks</em>. Data stored this way
243202 variables that can be assigned to. Typically, first consider
244203 representing data processed by your program as terms passed around as
245204 predicate arguments. If you need to reason over multiple solutions to 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>
205 goal, consider <a name="idx:findall3:794"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a name="idx:aggregate3:795"></a><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
247206 and related predicates.
248207
249208 <p>Nevertheless, there are scenarios where storing data outside the
254213 <dt><b>Using dynamic predicates</b></dt>
255214 <dd>
256215 Dynamic predicates are predicates for which the list of clauses is
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>
216 modified at runtime using <a name="idx:asserta1:796"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>, <a name="idx:assertz1:797"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:retract1:798"></a><a class="pred" href="db.html#retract/1">retract/1</a>
258217 or
259 <a id="idx:retractall1:797"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>.
218 <a name="idx:retractall1:799"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>.
260219 Following the ISO standard, predicates that are modified this way need
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>.
220 to be declared using the <a name="idx:dynamic1:800"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a> <em>directive</em>.
262221 These facilities are defined by the ISO standard and widely supported.
263222 The mechanism is often considered slow in the literature. Performance
264223 depends on the Prolog implementation. In SWI-Prolog, querying dynamic
265224 predicates has the same performance as static ones. The manipulation
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>
225 predicates are fast. Using <a name="idx:retract1:801"></a><a class="pred" href="db.html#retract/1">retract/1</a>
226 or <a name="idx:retractall1:802"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>
268227 on a predicate registers the predicate as `dirty'. Dirty predicates are
269228 cleaned by
270 <a id="idx:garbagecollectclauses0:801"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>,
229 <a name="idx:garbagecollectclauses0:803"></a><a class="pred" href="memory.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>,
271230 which is normally automatically invoked. Some workloads may result in
272231 significant performance reduction due to skipping retracted clauses
273232 and/or clause garbage collection.
276235 to maintain a backup of the data on disk. Dynamic predicates come in two
277236 flavours, <em>shared</em> between threads and <em>local</em> to each
278237 thread. The latter version is created using the directive
279 <a id="idx:threadlocal1:802"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
238 <a name="idx:threadlocal1:804"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
280239 <dt><b>The recorded database</b></dt>
281240 <dd>
282241 The `recorded database' registers a list of terms with a <em>key</em>,
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>.
242 an atom or compound term. The list is managed using <a name="idx:recorda3:805"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>, <a name="idx:recordz3:806"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>
243 and <a name="idx:erase1:807"></a><a class="pred" href="db.html#erase/1">erase/1</a>.
244 It is queried using <a name="idx:recorded3:808"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>.
286245 The recorded database is not part of the ISO standard but fairly widely
287246 supported, notably in implementations building on the `Edinburgh
288247 tradition'. There are few reasons to use this database in SWI-Prolog due
289248 to the good performance of dynamic predicates. Advantages are (1) the
290249 handle provides a direct reference to a term, (2) cyclic terms can be
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
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
295254 4.14.5</a> applies to the recorded database and (3) reduced portability.</dd>
296 <dt><b>The <a id="idx:flag3:807"></a><a class="pred" href="db.html#flag/3">flag/3</a>
255 <dt><b>The <a name="idx:flag3:809"></a><a class="pred" href="db.html#flag/3">flag/3</a>
297256 predicate</b></dt>
298257 <dd>
299 The predicate <a id="idx:flag3:808"></a><a class="pred" href="db.html#flag/3">flag/3</a>
258 The predicate <a name="idx:flag3:810"></a><a class="pred" href="db.html#flag/3">flag/3</a>
300259 associates one simple value (number or atom) with a key (atom, integer
301260 or compound). It is an old SWI-Prolog specific predicate that should be
302261 considered deprecated, although there is no plan to remove it.</dd>
303262 <dt><b>Using global variables</b></dt>
304263 <dd>
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>
264 The predicates <a name="idx:bsetval2:811"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
265 and <a name="idx:nbsetval2:812"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
307266 associate a term living on the Prolog stack with a name, either
308267 backtrackable or non-backtrackable. Backtrackable and non-backtrackable
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>
268 assignment without using a global name can be realised with <a name="idx:setarg3:813"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
269 and <a name="idx:nbsetarg3:814"></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:815"></a><a class="pred" href="aggregate.html#aggregate_all/3">aggregate_all/3</a>
312271 performs.</dd>
313272 <dt><b>Tries</b></dt>
314273 <dd>
315274 As of version 7.3.21, SWI-Prolog provides <em>tries</em> (prefix trees)
316275 to associate a term <em>variant</em> with a value. Tries have been
317 introduced to support <var>tabling</var> and are described in <a class="sec" href="db.html#sec:4.14.4">section
276 introduced to support <var>tabling</var> and are described in <a class="sec" href="db.html">section
318277 4.14.4</a>.
319278 </dd>
320279 </dl>
321280
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
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
323282 (dynamic) predicates</span></a></h3>
324283
325 <a id="sec:dynpreds"></a>
284 <a name="sec:dynpreds"></a>
326285
327286 <dl class="latex">
328 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="abolish/1"><strong>abolish</strong>(<var>:PredicateIndicator</var>)</a></dt>
287 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="abolish/1"><strong>abolish</strong>(<var>:PredicateIndicator</var>)</a></dt>
329288 <dd class="defbody">
330289 Removes all clauses of a predicate with functor <var>Functor</var> and
331290 arity
334293 imported predicate only removes the import link; the predicate will keep
335294 its old definition in its definition module.
336295
337 <p>According to the ISO standard, <a id="idx:abolish1:814"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
296 <p>According to the ISO standard, <a name="idx:abolish1:816"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
338297 can only be applied to dynamic procedures. This is odd, as for dealing
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>
298 with dynamic procedures there is already <a name="idx:retract1:817"></a><a class="pred" href="db.html#retract/1">retract/1</a>
299 and <a name="idx:retractall1:818"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>.
300 The <a name="idx:abolish1:819"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
342301 predicate was introduced in DEC-10 Prolog precisely for dealing with
343 static procedures. In SWI-Prolog, <a id="idx:abolish1:818"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
302 static procedures. In SWI-Prolog, <a name="idx:abolish1:820"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
344303 works on static procedures, unless the Prolog flag <a class="flag" href="flags.html#flag:iso">iso</a>
345304 is set to <code>true</code>.
346305
347 <p>It is advised to use <a id="idx:retractall1:819"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>
306 <p>It is advised to use <a name="idx:retractall1:821"></a><a class="pred" href="db.html#retractall/1">retractall/1</a>
348307 for erasing all clauses of a dynamic predicate.</dd>
349 <dt class="pubdef"><a id="abolish/2"><strong>abolish</strong>(<var>+Name,
308 <dt class="pubdef"><a name="abolish/2"><strong>abolish</strong>(<var>+Name,
350309 +Arity</var>)</a></dt>
351310 <dd class="defbody">
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>
311 Same as <code>abolish(Name/Arity)</code>. The predicate <a name="idx:abolish2:822"></a><a class="pred" href="db.html#abolish/2">abolish/2</a>
312 conforms to the Edinburgh standard, while <a name="idx:abolish1:823"></a><a class="pred" href="db.html#abolish/1">abolish/1</a>
354313 is ISO compliant.</dd>
355 <dt class="pubdef"><a id="copy_predicate_clauses/2"><strong>copy_predicate_clauses</strong>(<var>:From,
314 <dt class="pubdef"><a name="copy_predicate_clauses/2"><strong>copy_predicate_clauses</strong>(<var>:From,
356315 :To</var>)</a></dt>
357316 <dd class="defbody">
358317 Copy all clauses of predicate <var>From</var> to <var>To</var>. The
361320 undefined, it is created as a dynamic predicate holding a copy of the
362321 clauses of
363322 <var>From</var>. If <var>To</var> is a dynamic predicate, the clauses of
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>)
323 <var>From</var> are added (as in <a name="idx:assertz1:824"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>)
365324 to the clauses of <var>To</var>.
366325 <var>To</var> and <var>From</var> must have the same arity. Acts as if
367326 defined by the program below, but at a much better performance by
382341 </pre>
383342
384343 </dd>
385 <dt class="pubdef"><a id="redefine_system_predicate/1"><strong>redefine_system_predicate</strong>(<var>+Head</var>)</a></dt>
344 <dt class="pubdef"><a name="redefine_system_predicate/1"><strong>redefine_system_predicate</strong>(<var>+Head</var>)</a></dt>
386345 <dd class="defbody">
387346 This directive may be used both in module <code>user</code> and in
388347 normal modules to redefine any system predicate. If the system
393352
394353 <p>Redefining system predicate facilitates the definition of
395354 compatibility packages. Use in other contexts is discouraged.</dd>
396 <dt class="pubdef"><span class="pred-tag">[ISO,nondet]</span><a id="retract/1"><strong>retract</strong>(<var>+Term</var>)</a></dt>
355 <dt class="pubdef"><span class="pred-tag">[ISO,nondet]</span><a name="retract/1"><strong>retract</strong>(<var>+Term</var>)</a></dt>
397356 <dd class="defbody">
398357 When <var>Term</var> is an atom or a term it is unified with the first
399358 unifying fact or clause in the database. The fact or clause is removed
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>
359 from the database. The <a name="idx:retract1:825"></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:826"></a><a class="pred" href="db.html#retract/1">retract/1</a>
402361 succeeds for all clauses that match <var>Term</var> when the predicate
403362 was <em>called</em>. The example below illustrates that the first call
404 to <a id="idx:retract1:825"></a><a class="pred" href="db.html#retract/1">retract/1</a>
363 to <a name="idx:retract1:827"></a><a class="pred" href="db.html#retract/1">retract/1</a>
405364 succeeds on <code>bee</code> on backtracking despite the fact that <code>bee</code>
406 is already retracted.<sup class="fn">74<span class="fn-text">Example by
365 is already retracted.<sup class="fn">73<span class="fn-text">Example by
407366 Jan Burse</span></sup>.
408367
409368 <pre class="code">
425384 time their notion of the <em>entry generation</em> is adjusted such that
426385 they do not retract the same first clause. This implies that, if
427386 multiple threads use <code>once(retract(Term))</code>, no two threads
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>,
387 will retract the same clause. Note that on backtracking over <a name="idx:retract1:828"></a><a class="pred" href="db.html#retract/1">retract/1</a>,
429388 multiple threads may retract the same clause as both threads respect the
430389 logical update view.</dd>
431 <dt class="pubdef"><span class="pred-tag">[ISO,det]</span><a id="retractall/1"><strong>retractall</strong>(<var>+Head</var>)</a></dt>
390 <dt class="pubdef"><span class="pred-tag">[ISO,det]</span><a name="retractall/1"><strong>retractall</strong>(<var>+Head</var>)</a></dt>
432391 <dd class="defbody">
433392 All facts or clauses in the database for which the <var>head</var>
434393 unifies with <var>Head</var> are removed. If <var>Head</var> refers to a
435394 predicate that is not defined, it is implicitly created as a dynamic
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>
395 predicate. See also <a name="idx:dynamic1:829"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.<sup class="fn">74<span class="fn-text">The
396 ISO standard only allows using <a name="idx:dynamic1:830"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
438397 as a <em>directive</em>.</span></sup></dd>
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>
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>
442401 <dd class="defbody">
443402 Assert a clause (fact or rule) into the database. The predicate
444 <a id="idx:asserta1:829"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
403 <a name="idx:asserta1:831"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
445404 asserts the clause as first clause of the predicate while
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>
405 <a name="idx:assertz1:832"></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:833"></a><a class="pred" href="db.html#assert/1">assert/1</a>
407 is equivalent to <a name="idx:assertz1:834"></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:835"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>), <a name="idx:asserta1:836"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
450409 can raise a
451410 <code>resource_error(program_space)</code> exception. The example below
452411 adds two facts and a rule. Note the double parentheses around the rule.
460419 </pre>
461420
462421 </dd>
463 <dt class="pubdef"><a id="asserta/2"><strong>asserta</strong>(<var>+Term,
422 <dt class="pubdef"><a name="asserta/2"><strong>asserta</strong>(<var>+Term,
464423 -Reference</var>)</a></dt>
465 <dt class="pubdef"><a id="assertz/2"><strong>assertz</strong>(<var>+Term,
424 <dt class="pubdef"><a name="assertz/2"><strong>assertz</strong>(<var>+Term,
466425 -Reference</var>)</a></dt>
467 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="assert/2"><strong>assert</strong>(<var>+Term,
426 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="assert/2"><strong>assert</strong>(<var>+Term,
468427 -Reference</var>)</a></dt>
469428 <dd class="defbody">
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>,
429 Equivalent to <a name="idx:asserta1:837"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>, <a name="idx:assertz1:838"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>, <a name="idx:assert1:839"></a><a class="pred" href="db.html#assert/1">assert/1</a>,
471430 but in addition unifies
472431 <var>Reference</var> with a handle to the asserted clauses. The handle
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>.
432 can be used to access this clause with <a name="idx:clause3:840"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>
433 and <a name="idx:erase1:841"></a><a class="pred" href="db.html#erase/1">erase/1</a>.
475434 </dd>
476435 </dl>
477436
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
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
479438 recorded database</span></a></h3>
480439
481 <a id="sec:recdb"></a>
440 <a name="sec:recdb"></a>
482441
483442 <dl class="latex">
484 <dt class="pubdef"><a id="recorda/3"><strong>recorda</strong>(<var>+Key,
443 <dt class="pubdef"><a name="recorda/3"><strong>recorda</strong>(<var>+Key,
485444 +Term, -Reference</var>)</a></dt>
486445 <dd class="defbody">
487446 Assert <var>Term</var> in the recorded database under key <var>Key</var>.
490449 atom or compound term. If the key is a compound term, only the name and
491450 arity define the key.
492451 <var>Reference</var> is unified with an opaque handle to the record (see
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,
452 <a name="idx:erase1:842"></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,
495454 +Term</var>)</a></dt>
496455 <dd class="defbody">
497456 Equivalent to <code>recorda(<var>Key</var>, <var>Term</var>, _)</code>.</dd>
498 <dt class="pubdef"><a id="recordz/3"><strong>recordz</strong>(<var>+Key,
457 <dt class="pubdef"><a name="recordz/3"><strong>recordz</strong>(<var>+Key,
499458 +Term, -Reference</var>)</a></dt>
500459 <dd class="defbody">
501 Equivalent to <a id="idx:recorda3:841"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
460 Equivalent to <a name="idx:recorda3:843"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
502461 but puts the <var>Term</var> at the tail of the terms recorded under <var>Key</var>.</dd>
503 <dt class="pubdef"><a id="recordz/2"><strong>recordz</strong>(<var>+Key,
462 <dt class="pubdef"><a name="recordz/2"><strong>recordz</strong>(<var>+Key,
504463 +Term</var>)</a></dt>
505464 <dd class="defbody">
506465 Equivalent to <code>recordz(<var>Key</var>, <var>Term</var>, _)</code>.</dd>
507 <dt class="pubdef"><a id="recorded/3"><strong>recorded</strong>(<var>?Key,
466 <dt class="pubdef"><a name="recorded/3"><strong>recorded</strong>(<var>?Key,
508467 ?Value, ?Reference</var>)</a></dt>
509468 <dd class="defbody">
510469 True if <var>Value</var> is recorded under <var>Key</var> and has the
511470 given database <var>Reference</var>. If <var>Reference</var> is given,
512471 this predicate is semi-deterministic. Otherwise, it must be considered
513472 non-deterministic. If neither <var>Reference</var> nor <var>Key</var> is
514 given, the triples are generated as in the code snippet below.<sup class="fn">76<span class="fn-text">Note
473 given, the triples are generated as in the code snippet below.<sup class="fn">75<span class="fn-text">Note
515474 that, without a given <var>Key</var>, some implementations return
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>.
475 triples in the order defined by <a name="idx:recorda2:844"></a><a class="pred" href="db.html#recorda/2">recorda/2</a>
476 and <a name="idx:recordz2:845"></a><a class="pred" href="db.html#recordz/2">recordz/2</a>.</span></sup>
477 See also <a name="idx:currentkey1:846"></a><a class="pred" href="examineprog.html#current_key/1">current_key/1</a>.
519478
520479 <pre class="code">
521480 current_key(Key),
523482 </pre>
524483
525484 </dd>
526 <dt class="pubdef"><a id="recorded/2"><strong>recorded</strong>(<var>+Key,
485 <dt class="pubdef"><a name="recorded/2"><strong>recorded</strong>(<var>+Key,
527486 -Value</var>)</a></dt>
528487 <dd class="defbody">
529488 Equivalent to <code>recorded(<var>Key</var>, <var>Value</var>, _)</code>.</dd>
530 <dt class="pubdef"><a id="erase/1"><strong>erase</strong>(<var>+Reference</var>)</a></dt>
489 <dt class="pubdef"><a name="erase/1"><strong>erase</strong>(<var>+Reference</var>)</a></dt>
531490 <dd class="defbody">
532491 Erase a record or clause from the database. <var>Reference</var> is 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>.
492 db-reference returned by <a name="idx:recorda3:847"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>, <a name="idx:recordz3:848"></a><a class="pred" href="db.html#recordz/3">recordz/3</a>
493 or <a name="idx:recorded3:849"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>, <a name="idx:clause3:850"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>,
494 <a name="idx:assert2:851"></a><a class="pred" href="db.html#assert/2">assert/2</a>, <a name="idx:asserta2:852"></a><a class="pred" href="db.html#asserta/2">asserta/2</a>
495 or <a name="idx:assertz2:853"></a><a class="pred" href="db.html#assertz/2">assertz/2</a>.
537496 Fail silently if the referenced object no longer exists. Notably, if
538497 multiple threads attempt to erase the same clause one will succeed and
539498 the others will fail.</dd>
540 <dt class="pubdef"><a id="instance/2"><strong>instance</strong>(<var>+Reference,
499 <dt class="pubdef"><a name="instance/2"><strong>instance</strong>(<var>+Reference,
541500 -Term</var>)</a></dt>
542501 <dd class="defbody">
543502 Unify <var>Term</var> with the referenced clause or database record.
545504 </dd>
546505 </dl>
547506
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>
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:854"></a><a class="pred" href="db.html#flag/3">flag/3</a>
553512 is the oldest way to store global non-backtrackable data in SWI-Prolog.
554513 Flags are global and shared by all threads. Their value is limited to
555514 atoms, small (64-bit) integers and floating point numbers. Flags are
556515 thread-safe. The flags described in this section must not be confused
557516 with <em>Prolog flags</em> described in
558 <a class="sec" href="flags.html#sec:2.11">section 2.11</a>.
517 <a class="sec" href="flags.html">section 2.11</a>.
559518
560519 <dl class="latex">
561 <dt class="pubdef"><a id="get_flag/2"><strong>get_flag</strong>(<var>+Key,
520 <dt class="pubdef"><a name="get_flag/2"><strong>get_flag</strong>(<var>+Key,
562521 -Value</var>)</a></dt>
563522 <dd class="defbody">
564523 True when <var>Value</var> is the value currently associated with <var>Key</var>.
565524 If <var>Key</var> does not exist, a new flag with value `0' (zero) is
566525 created.
567526 </dd>
568 <dt class="pubdef"><a id="set_flag/2"><strong>set_flag</strong>(<var>+Key,
527 <dt class="pubdef"><a name="set_flag/2"><strong>set_flag</strong>(<var>+Key,
569528 Value</var>)</a></dt>
570529 <dd class="defbody">
571530 Set flag <var>Key</var> to <var>Value</var>. Value must be an atom,
572531 small (64-bit) integer or float.
573532 </dd>
574 <dt class="pubdef"><a id="flag/3"><strong>flag</strong>(<var>+Key, -Old,
575 +New</var>)</a></dt>
533 <dt class="pubdef"><a name="flag/3"><strong>flag</strong>(<var>+Key,
534 -Old, +New</var>)</a></dt>
576535 <dd class="defbody">
577536 True when <var>Old</var> is the current value of the flag <var>Key</var>
578537 and the flag has been set to <var>New</var>. <var>New</var> can be an
588547 <p></dd>
589548 </dl>
590549
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>
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>
594553
595554 <p>Tries (also called <em>digital tree</em>, <em>radix tree</em> or
596555 <em>prefix tree</em> maintain a mapping between a variant of a term (see
603562 <ul class="compact">
604563 <li>Tries are not thread-safe.
605564 <li>Tries should not be modified while non-deterministic predicates such
606 as <a id="idx:triegen3:853"></a><a class="pred" href="db.html#trie_gen/3">trie_gen/3</a>
565 as <a name="idx:triegen3:855"></a><a class="pred" href="db.html#trie_gen/3">trie_gen/3</a>
607566 are running on the trie.
608567 <li>Terms cannot have <em>attributed variables</em>.
609568 <li>Terms cannot be <em>cyclic</em>. Possibly this will not change
617576 considered stable.</b>
618577
619578 <dl class="latex">
620 <dt class="pubdef"><a id="trie_new/1"><strong>trie_new</strong>(<var>-Trie</var>)</a></dt>
579 <dt class="pubdef"><a name="trie_new/1"><strong>trie_new</strong>(<var>-Trie</var>)</a></dt>
621580 <dd class="defbody">
622581 Create a new trie and unify <var>Trie</var> with a handle to the trie.
623582 The trie handle is a <em>blob</em>. Tries are subject to atom garbage
624583 collection.</dd>
625 <dt class="pubdef"><a id="trie_destroy/1"><strong>trie_destroy</strong>(<var>+Trie</var>)</a></dt>
584 <dt class="pubdef"><a name="trie_destroy/1"><strong>trie_destroy</strong>(<var>+Trie</var>)</a></dt>
626585 <dd class="defbody">
627586 Destroy <var>Trie</var>. This removes all nodes from the trie and causes
628587 further access to <var>Trie</var> to raise an existence_error exception.
629588 The handle itself is reclaimed by atom garbage collection.</dd>
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>
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:856"></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>
634593 <dd class="defbody">
635594 True if <var>Trie</var> is a currently existing trie. As this enumerates
636595 and then filters all known atoms this predicate is slow and should only
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,
596 be used for debugging purposes. See also <a name="idx:istrie1:857"></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,
639598 +Key, +Value</var>)</a></dt>
640599 <dd class="defbody">
641600 Insert the term <var>Key</var> into <var>Trie</var> and associate it
645604 silently. If <var>Key</var> is in <var>Trie</var> associated with a
646605 different value, a
647606 <code>permission_error</code> is raised.</dd>
648 <dt class="pubdef"><a id="trie_update/3"><strong>trie_update</strong>(<var>+Trie,
607 <dt class="pubdef"><a name="trie_update/3"><strong>trie_update</strong>(<var>+Trie,
649608 +Key, +Value</var>)</a></dt>
650609 <dd class="defbody">
651 As <a id="idx:trieinsert3:856"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
610 As <a name="idx:trieinsert3:858"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
652611 but if <var>Key</var> is in <var>Trie</var>, its associated value is <em>updated</em>.</dd>
653 <dt class="pubdef"><a id="trie_insert/4"><strong>trie_insert</strong>(<var>+Trie,
612 <dt class="pubdef"><a name="trie_insert/4"><strong>trie_insert</strong>(<var>+Trie,
654613 +Term, +Value, -Handle</var>)</a></dt>
655614 <dd class="defbody">
656 As <a id="idx:trieinsert3:857"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
615 As <a name="idx:trieinsert3:859"></a><a class="pred" href="db.html#trie_insert/3">trie_insert/3</a>,
657616 returning a handle to the trie node. This predicate is currently unsafe
658617 as <var>Handle</var> is an integer used to encode a pointer. It was used
659618 to implement a pure Prolog version of the <code>library(tabling)</code>
660619 library.</dd>
661 <dt class="pubdef"><a id="trie_delete/3"><strong>trie_delete</strong>(<var>+Trie,
620 <dt class="pubdef"><a name="trie_delete/3"><strong>trie_delete</strong>(<var>+Trie,
662621 +Key, ?Value</var>)</a></dt>
663622 <dd class="defbody">
664623 Delete <var>Key</var> from <var>Trie</var> if the value associated with <var>Key</var>
665624 unifies with <var>Value</var>.</dd>
666 <dt class="pubdef"><a id="trie_lookup/3"><strong>trie_lookup</strong>(<var>+Trie,
625 <dt class="pubdef"><a name="trie_lookup/3"><strong>trie_lookup</strong>(<var>+Trie,
667626 +Key, -Value</var>)</a></dt>
668627 <dd class="defbody">
669628 True if the term <var>Key</var> is in <var>Trie</var> and associated
670629 with
671630 <var>Value</var>.</dd>
672 <dt class="pubdef"><a id="trie_term/2"><strong>trie_term</strong>(<var>+Handle,
631 <dt class="pubdef"><a name="trie_term/2"><strong>trie_term</strong>(<var>+Handle,
673632 -Term</var>)</a></dt>
674633 <dd class="defbody">
675634 True when <var>Term</var> is a copy of the term associated with <var>Handle</var>.
676635 The result is undefined (including crashes) if <var>Handle</var> is not
677 a handle returned by <a id="idx:trieinsertnew3:858"></a><span class="pred-ext">trie_insert_new/3</span>
636 a handle returned by <a name="idx:trieinsertnew3:860"></a><span class="pred-ext">trie_insert_new/3</span>
678637 or the node has been removed afterwards.</dd>
679 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="trie_gen/3"><strong>trie_gen</strong>(<var>+Trie,
638 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="trie_gen/3"><strong>trie_gen</strong>(<var>+Trie,
680639 ?Key, -Value</var>)</a></dt>
681640 <dd class="defbody">
682641 True when <var>Key</var> is associated with <var>Value</var> in <var>Trie</var>.
683642 Backtracking retrieves all pairs. Currently scans the entire trie, even
684643 if <var>Key</var> is partly known. Currently unsafe if <var>Trie</var>
685644 is modified while the values are being enumerated.</dd>
686 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="trie_property/2"><strong>trie_property</strong>(<var>?Trie,
645 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="trie_property/2"><strong>trie_property</strong>(<var>?Trie,
687646 ?Property</var>)</a></dt>
688647 <dd class="defbody">
689648 True if <var>Trie</var> exists with <var>Property</var>. Intended for
712671 </dd>
713672 </dl>
714673
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
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
716675 view</span></a></h3>
717676
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,
677 <a name="sec:update"></a>
678
679 <p><a name="idx:logicalupdateview:861"></a><a name="idx:immediateupdateview:862"></a><a name="idx:updateview:863"></a>Traditionally,
721680 Prolog systems used the <em>immediate update view</em>: new clauses
722681 became visible to predicates backtracking over dynamic predicates
723682 immediately, and retracted clauses became invisible immediately.
724683
725684 <p>Starting with SWI-Prolog 3.3.0 we adhere to the <em>logical update
726685 view</em>, where backtrackable predicates that enter the definition of 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>
686 predicate will not see any changes (either caused by <a name="idx:assert1:864"></a><a class="pred" href="db.html#assert/1">assert/1</a>
728687 or
729 <a id="idx:retract1:863"></a><a class="pred" href="db.html#retract/1">retract/1</a>)
688 <a name="idx:retract1:865"></a><a class="pred" href="db.html#retract/1">retract/1</a>)
730689 to the predicate. This view is the ISO standard, the most commonly used
731 and the most `safe'.<sup class="fn">77<span class="fn-text">For example,
690 and the most `safe'.<sup class="fn">76<span class="fn-text">For example,
732691 using the immediate update view, no call to a dynamic predicate is
733692 deterministic.</span></sup> Logical updates are realised by keeping
734693 reference counts on predicates and <em>generation</em> information on
739698 with a `created' ... `erased' interval that encloses the generation of
740699 the current goal are considered visible.
741700
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
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
743702 databases</span></a></h3>
744703
745 <a id="sec:hashterm"></a>
746
747 <p><a id="idx:indexingtermhashes:864"></a>The indexing capabilities of
704 <a name="sec:hashterm"></a>
705
706 <p><a name="idx:indexingtermhashes:866"></a>The indexing capabilities of
748707 SWI-Prolog are described in
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>
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:867"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
756715 and
757 <a id="idx:termhash4:866"></a><a class="pred" href="db.html#term_hash/4">term_hash/4</a>
716 <a name="idx:termhash4:868"></a><a class="pred" href="db.html#term_hash/4">term_hash/4</a>
758717 to design their database such that indexing on constant or functor
759718 (name/arity reference) on the first argument is sufficient.
760719
761720 <dl class="latex">
762 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="term_hash/2"><strong>term_hash</strong>(<var>+Term,
721 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="term_hash/2"><strong>term_hash</strong>(<var>+Term,
763722 -HashKey</var>)</a></dt>
764723 <dd class="defbody">
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>
724 If <var>Term</var> is a ground term (see <a name="idx:ground1:869"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>), <var>HashKey</var>
766725 is unified with a positive integer value that may be used as a hash key
767726 to the value. If <var>Term</var> is not ground, the predicate leaves <var>HashKey</var>
768727 an unbound variable. Hash keys are in the range <var>0 ... 16,777,215</var>,
774733
775734 <p>The hash key does not rely on temporary information like addresses of
776735 atoms and may be assumed constant over different invocations and
777 versions of SWI-Prolog.<sup class="fn">78<span class="fn-text">Last
736 versions of SWI-Prolog.<sup class="fn">77<span class="fn-text">Last
778737 change: version 5.10.4</span></sup> Hashes differ between big and little
779 endian machines. The <a id="idx:termhash2:868"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
738 endian machines. The <a name="idx:termhash2:870"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
780739 predicate is cycle-safe.<sup class="fn">bug<span class="fn-text">All
781740 arguments that (indirectly) lead to a cycle have the same hash key.</span></sup></dd>
782 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="term_hash/4"><strong>term_hash</strong>(<var>+Term,
741 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="term_hash/4"><strong>term_hash</strong>(<var>+Term,
783742 +Depth, +Range, -HashKey</var>)</a></dt>
784743 <dd class="defbody">
785 As <a id="idx:termhash2:869"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>,
744 As <a name="idx:termhash2:871"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>,
786745 but only considers <var>Term</var> to the specified
787746 <var>Depth</var>. The top-level term has depth 1, its arguments have
788747 depth 2, etc. That is, <var><var>Depth</var> = 0</var> hashes nothing; <var><var>Depth</var>
792751
793752 <p><var>HashKey</var> is in the range <var>[0 ...<var>Range</var>-1]</var>. <var>Range</var>
794753 must be in the range <var>[1 ... 2147483647]</var></dd>
795 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="variant_sha1/2"><strong>variant_sha1</strong>(<var>+Term,
754 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="variant_sha1/2"><strong>variant_sha1</strong>(<var>+Term,
796755 -SHA1</var>)</a></dt>
797756 <dd class="defbody">
798757 Compute a SHA1-hash from <var>Term</var>. The hash is represented as 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>
758 40-byte hexadecimal atom. Unlike <a name="idx:termhash2:872"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
800759 and friends, this predicate produces a hash key for non-ground terms.
801760 The hash is invariant over variable-renaming (see <a class="pred" href="compare.html#=@=/2">=@=/2</a>)
802761 and constants over different invocations of Prolog.<sup class="fn">bug<span class="fn-text">The
805764
806765 <p>This predicate raises an exception when trying to compute the hash on
807766 a cyclic term or attributed term. Attributed terms are not handled
808 because <a id="idx:subsumeschk2:871"></a><span class="pred-ext">subsumes_chk/2</span>
767 because <a name="idx:subsumeschk2:873"></a><span class="pred-ext">subsumes_chk/2</span>
809768 is not considered well defined for attributed terms. Cyclic terms are
810769 not supported because this would require establishing a canonical cycle.
811770 That is, given A=[a|A] and B=[a,a|B],
816775 table. By using a cryptographic hash, heuristic algorithms can often
817776 ignore the possibility of hash collisions and thus avoid storing the
818777 goal term itself as well as testing using <a class="pred" href="compare.html#=@=/2">=@=/2</a>.</dd>
819 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="variant_hash/2"><strong>variant_hash</strong>(<var>+Term,
778 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="variant_hash/2"><strong>variant_hash</strong>(<var>+Term,
820779 -HashKey</var>)</a></dt>
821780 <dd class="defbody">
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>.
781 Similar to <a name="idx:variantsha12:874"></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:875"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>.
824783 This version does deal with attributed variables, processing them as
825784 normal variables. This hash is primarily intended to speedup finding
826785 variant terms in a set of terms.
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>,
786 <sup class="fn">bug<span class="fn-text">As <a name="idx:variantsha12:876"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>,
828787 cyclic terms result in an exception.</span></sup>
829788 </dd>
830789 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="csv.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="error.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:debug"><a id="sec:A.11"><span class="sec-nr">A.11</span> <span class="sec-title">library(debug):
194 <h2 id="sec:debug"><a name="sec:A.11"><span class="sec-nr">A.11</span> <span class="sec-title">library(debug):
236195 Print debug messages and test assertions</span></a></h2>
237196
238 <p><a id="sec:debug"></a>
197 <p><a name="sec:debug"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">author</dt>
262221 debugger if the condition does not hold.
263222
264223 <dl class="latex">
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,
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,
268227 ?Bool</var>)</a></dt>
269228 <dd class="defbody">
270229 Examine debug topics. The form <code>debugging(+Topic)</code> may be
281240
282241 <p>The other two calls are intended to examine existing and enabled
283242 debugging tokens and are typically not used in user programs.</dd>
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>
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>
286245 <dd class="defbody">
287246 Add/remove a topic from being printed. <code>nodebug(_)</code> removes
288247 all topics. Gives a warning if the topic is not defined unless it is
293252 can be a term <var>Topic</var> <var>&gt;</var> Out, where Out is either
294253 a stream or stream-alias or a filename (atom). This redirects debug
295254 information on this topic to the given output.</dd>
296 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_debug_topics/0"><strong>list_debug_topics</strong></a></dt>
255 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_debug_topics/0"><strong>list_debug_topics</strong></a></dt>
297256 <dd class="defbody">
298257 List currently known debug topics and their setting.</dd>
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>
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>
300259 <dd class="defbody">
301260 Specify additional context for debug messages. <var>What</var> is one of
302261 +Context or -Context, and Context is one of <code>thread</code>, <code>time</code>
305264 <a class="pred" href="system.html#format_time/3">format_time/3</a>
306265 (default is <code>%T.%3f</code>). Initially, <a class="pred" href="debug.html#debug/3">debug/3</a>
307266 shows only thread information.</dd>
308 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="debug/3"><strong>debug</strong>(<var>+Topic,
267 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="debug/3"><strong>debug</strong>(<var>+Topic,
309268 +Format, :Args</var>)</a></dt>
310269 <dd class="defbody">
311270 <var>Format</var> a message if debug topic is enabled. Similar to <a class="pred" href="format.html#format/3">format/3</a>
332291 </dl>
333292
334293 </dd>
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,
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,
336295 +Format, +Args</var>)</a></dt>
337296 <dd class="defbody">
338297 Hook called by <a class="pred" href="debug.html#debug/3">debug/3</a>.
343302 </pre>
344303
345304 </dd>
346 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="assertion/1"><strong>assertion</strong>(<var>:Goal</var>)</a></dt>
305 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="assertion/1"><strong>assertion</strong>(<var>:Goal</var>)</a></dt>
347306 <dd class="defbody">
348307 Acts similar to C <code>assert()</code> macro. It has no effect if <var>Goal</var>
349308 succeeds. If <var>Goal</var> fails or throws an exception, the following
364323 </ul>
365324 </ul>
366325 </dd>
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,
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,
368327 +Goal</var>)</a></dt>
369328 <dd class="defbody">
370329 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.7.4 Reference Manual: Section 4.39</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="protocol.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="statistics.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:debugger"><a id="sec:4.39"><span class="sec-nr">4.39</span> <span class="sec-title">Debugging
194 <h2 id="sec:debugger"><a name="sec:4.39"><span class="sec-nr">4.39</span> <span class="sec-title">Debugging
236195 and Tracing Programs</span></a></h2>
237196
238 <a id="sec:debugger"></a>
197 <a name="sec:debugger"></a>
239198
240199 <p>This section is a reference to the debugger interaction predicates. A
241 more use-oriented overview of the debugger is in <a class="sec" href="debugoverview.html#sec:2.9">section
200 more use-oriented overview of the debugger is in <a class="sec" href="debugoverview.html">section
242201 2.9</a>.
243202
244203 <p>If you have installed XPCE, you can use the graphical front-end of
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>.
204 the tracer. This front-end is installed using the predicate <a name="idx:guitracer0:1543"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>.
246205
247206 <dl class="latex">
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>
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:1544"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
251210 itself cannot be seen in the tracer. Note that the Prolog top level
252 treats <a id="idx:trace0:1543"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
211 treats <a name="idx:trace0:1545"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
253212 special; it means `trace the next goal'.
254213 </dd>
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>
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:1546"></a><a class="pred" href="debugger.html#tracing/0">tracing/0</a>
258217 itself cannot be seen in the tracer.
259218 </dd>
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>
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:1547"></a><a class="pred" href="debugger.html#notrace/0">notrace/0</a>
263222 itself cannot be seen in the tracer.
264223 </dd>
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>)
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:1548"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>)
268227 into the system that redirect tracing information to a GUI front-end
269228 providing structured access to variable bindings, graphical overview of
270229 the stack and highlighting of relevant source code.
271230 </dd>
272 <dt class="pubdef"><a id="noguitracer/0"><strong>noguitracer</strong></a></dt>
231 <dt class="pubdef"><a name="noguitracer/0"><strong>noguitracer</strong></a></dt>
273232 <dd class="defbody">
274233 Revert back to the textual tracer.
275234 </dd>
276 <dt class="pubdef"><a id="trace/1"><strong>trace</strong>(<var>+Pred</var>)</a></dt>
235 <dt class="pubdef"><a name="trace/1"><strong>trace</strong>(<var>+Pred</var>)</a></dt>
277236 <dd class="defbody">
278237 Equivalent to <code>trace(<var>Pred</var>, +all)</code>.
279238 </dd>
280 <dt class="pubdef"><a id="trace/2"><strong>trace</strong>(<var>+Pred,
239 <dt class="pubdef"><a name="trace/2"><strong>trace</strong>(<var>+Pred,
281240 +Ports</var>)</a></dt>
282241 <dd class="defbody">
283242 Put a trace point on all predicates satisfying the predicate
288247 sign, the trace point is cleared for the port. If it is preceded by a <code><code>+</code></code>,
289248 the trace point is set.
290249
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>).
250 <p>The predicate <a name="idx:trace2:1549"></a><a class="pred" href="debugger.html#trace/2">trace/2</a>
251 activates debug mode (see <a name="idx:debug0:1550"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>).
293252 Each time a port (of the 4-port model) is passed that has a trace point
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>,
253 set, the goal is printed as with <a name="idx:trace0:1551"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>.
254 Unlike <a name="idx:trace0:1552"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>,
296255 however, the execution is continued without asking for further
297256 information. Examples:
298257
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>
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>
305265 </table>
306266
307 <p>The predicate <a id="idx:debugging0:1551"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>
267 <p>The predicate <a name="idx:debugging0:1553"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>
308268 shows all currently defined trace points.</dd>
309 <dt class="pubdef"><a id="notrace/1"><strong>notrace</strong>(<var>:Goal</var>)</a></dt>
269 <dt class="pubdef"><a name="notrace/1"><strong>notrace</strong>(<var>:Goal</var>)</a></dt>
310270 <dd class="defbody">
311271 Call <var>Goal</var>, but suspend the debugger while <var>Goal</var> is
312272 executing. The current implementation cuts the choice points of <var>Goal</var>
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>
273 after successful completion. See <a name="idx:once1:1554"></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:1555"></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>
316276 <dd class="defbody">
317277 Start debugger. In debug mode, Prolog stops at spy and trace points,
318278 disables last-call optimisation and aggressive destruction of choice
323283 enlarged to 8&nbsp;K cells if debugging is switched off in order to
324284 avoid excessive GC. GC complicates tracing because it renames the <i>_G&lt;NNN&gt;</i>
325285 variables and replaces unreachable variables with the atom
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>
286 <code>&lt;garbage_collected&gt;</code>. Calling <a name="idx:nodebug0:1556"></a><a class="pred" href="debugger.html#nodebug/0">nodebug/0</a>
327287 does <em>not</em> reset the initial free-margin because several parts of
328288 the top level and debugger disable debugging of system code regions. See
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>
289 also <a name="idx:setprologstack2:1557"></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>
331291 <dd class="defbody">
332292 Stop debugger. Implemented by the Prolog flag <a class="flag" href="flags.html#flag:debug">debug</a>.
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>
293 See also <a name="idx:debug0:1558"></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>
335295 <dd class="defbody">
336296 Print debug status and spy points on current output stream. See also the
337297 Prolog flag <a class="flag" href="flags.html#flag:debug">debug</a>.
338298 </dd>
339 <dt class="pubdef"><a id="spy/1"><strong>spy</strong>(<var>+Pred</var>)</a></dt>
299 <dt class="pubdef"><a name="spy/1"><strong>spy</strong>(<var>+Pred</var>)</a></dt>
340300 <dd class="defbody">
341301 Put a spy point on all predicates meeting the predicate specification
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>
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>
346305 <dd class="defbody">
347306 Remove spy point from all predicates meeting the predicate specification
348307 <var>Pred</var>.
349308 </dd>
350 <dt class="pubdef"><a id="nospyall/0"><strong>nospyall</strong></a></dt>
309 <dt class="pubdef"><a name="nospyall/0"><strong>nospyall</strong></a></dt>
351310 <dd class="defbody">
352311 Remove all spy points from the entire program.
353312 </dd>
354 <dt class="pubdef"><a id="leash/1"><strong>leash</strong>(<var>?Ports</var>)</a></dt>
313 <dt class="pubdef"><a name="leash/1"><strong>leash</strong>(<var>?Ports</var>)</a></dt>
355314 <dd class="defbody">
356315 Set/query leashing (ports which allow for user interaction). <var>Ports</var>
357316 is one of <var>+Name</var>, <var>-Name</var>, <var>?Name</var> or a list
367326 (default).
368327 <code>half</code> refers to the <code>call</code>, <code>redo</code> and <code>fail</code>
369328 port.</dd>
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>
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:1559"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>
373332 for a description of the <var>Ports</var> specification. Default is <code>full</code>.</dd>
374 <dt class="pubdef"><a id="unknown/2"><strong>unknown</strong>(<var>-Old,
333 <dt class="pubdef"><a name="unknown/2"><strong>unknown</strong>(<var>-Old,
375334 +New</var>)</a></dt>
376335 <dd class="defbody">
377336 Edinburgh-Prolog compatibility predicate, interfacing to the ISO Prolog
379338 are <code>trace</code> (meaning <code>error</code>) and <code>fail</code>.
380339 If the <a class="flag" href="flags.html#flag:unknown">unknown</a> flag
381340 is set to
382 <code>warning</code>, <a id="idx:unknown2:1558"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
341 <code>warning</code>, <a name="idx:unknown2:1560"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
383342 reports the value as <code>trace</code>.</dd>
384 <dt class="pubdef"><a id="style_check/1"><strong>style_check</strong>(<var>+Spec</var>)</a></dt>
343 <dt class="pubdef"><a name="style_check/1"><strong>style_check</strong>(<var>+Spec</var>)</a></dt>
385344 <dd class="defbody">
386345 Modify/query style checking options. <var>Spec</var> is one of the terms
387346 below or a list of these.
394353 is unbound, all active style check options are returned on backtracking.
395354 </ul>
396355
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>
356 <p>Loading a file using <a name="idx:loadfiles2:1561"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
398357 or one of its derived predicates reset the style checking options to
399358 their value before loading the file, scoping the option to the remainder
400359 of the file and all files loaded
403362 <dl class="latex">
404363 <dt><strong>singleton</strong>(<var>true</var>)</dt>
405364 <dd class="defbody">
406 The predicate <a id="idx:readclause3:1560"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a>
365 The predicate <a name="idx:readclause3:1562"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a>
407366 (used by the compiler to read source code) warns on variables appearing
408367 only once in a term (clause) which have a name not starting with an
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>
368 underscore. See <a class="sec" href="syntax.html">section 2.16.1.9</a>
369 for details on variable handling and warnings.</dd>
411370 <dt><strong>no_effect</strong>(<var>true</var>)</dt>
412371 <dd class="defbody">
413372 This warning is generated by the compiler for BIPs (built-in predicates)
456415 <dd class="defbody">
457416 Warn if the clauses for a predicate are not together in the same source
458417 file. It is advised to disable the warning for discontiguous predicates
459 using the <a id="idx:discontiguous1:1561"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
418 using the <a name="idx:discontiguous1:1563"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
460419 directive.</dd>
461420 <dt><strong>charset</strong>(<var>false</var>)</dt>
462421 <dd class="defbody">
463422 Warn on atoms and variable names holding non-ASCII characters that are
464 not quoted. See also <a class="sec" href="syntax.html#sec:2.16.1.1">section
465 2.16.1.1</a>.
423 not quoted. See also <a class="sec" href="syntax.html">section 2.16.1.1</a>.
466424 </dd>
467425 </dl>
468426
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="practical.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="examples.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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
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
238197 rather limited. Only tracing is currently available. To use the CHR
239198 debugging facilities for a CHR file it must be compiled for debugging.
240199 Generating debug info is controlled by the CHR option <a class="flag" href="flags.html#flag:debug">debug</a>,
242201 Therefore debug info is provided unless the <strong>-nodebug</strong> is
243202 used.
244203
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
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
248207 are defined:
249208
250209 <dl class="latex">
297256 </dd>
298257 </dl>
299258
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>
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:1817"></a><a class="pred" href="debugging.html#chr_trace/0">chr_trace/0</a>
262 predicate and disabled with the <a name="idx:chrnotrace0:1818"></a><a class="pred" href="debugging.html#chr_notrace/0">chr_notrace/0</a>
304263 predicate.
305264
306265 <p>When enabled the tracer will step through the <code>call</code>,
343302 </dd>
344303 <dt><strong>break</strong></dt>
345304 <dd class="defbody">
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>.
305 Enter a recursive Prolog top level. See <a name="idx:break0:1819"></a><a class="pred" href="toplevel.html#break/0">break/0</a>.
347306 </dd>
348307 <dt><strong>abort</strong></dt>
349308 <dd class="defbody">
350 Exit to the top level. See <a id="idx:abort0:1821"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
309 Exit to the top level. See <a name="idx:abort0:1820"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
351310 </dd>
352311 <dt><strong>fail</strong></dt>
353312 <dd class="defbody">
359318 </dd>
360319 </dl>
361320
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
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
363322 Debugging Predicates</span></a></h3>
364323
365 <a id="sec:predicates"></a> The <code>library(chr)</code> module
324 <a name="sec:predicates"></a> The <code>library(chr)</code> module
366325 contains several predicates that allow inspecting and printing the
367326 content of the constraint store.
368327
369328 <dl class="latex">
370 <dt class="pubdef"><a id="chr_trace/0"><strong>chr_trace</strong></a></dt>
329 <dt class="pubdef"><a name="chr_trace/0"><strong>chr_trace</strong></a></dt>
371330 <dd class="defbody">
372331 Activate the CHR tracer. By default the CHR tracer is activated and
373 deactivated automatically by the Prolog predicates <a id="idx:trace0:1822"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
332 deactivated automatically by the Prolog predicates <a name="idx:trace0:1821"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
374333 and
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>
334 <a name="idx:notrace0:1822"></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>
377336 <dd class="defbody">
378337 Deactivate the CHR tracer. By default the CHR tracer is activated and
379 deactivated automatically by the Prolog predicates <a id="idx:trace0:1824"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
338 deactivated automatically by the Prolog predicates <a name="idx:trace0:1823"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
380339 and
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>
340 <a name="idx:notrace0:1824"></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>
383342 <dd class="defbody">
384343 Define the set of CHR ports on which the CHR tracer asks for user
385344 intervention (i.e. stops). <var>Spec</var> is either a list of ports as
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>
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>
389348 to stop at the <code>call</code>,
390349 <code>exit</code>, <code>fail</code>, <code>wake</code> and <code>apply</code>
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>
350 ports. See also <a name="idx:leash1:1825"></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>
393352 <dd class="defbody">
394353 Prints all suspended constraints of module <var>Mod</var> to the
395354 standard output. This predicate is automatically called by the
398357 <code>chr_toplevel_show_store</code> controls whether the top level
399358 shows the constraint stores. The value <code>true</code> enables it. Any
400359 other value disables it.</dd>
401 <dt class="pubdef"><a id="find_chr_constraint/1"><strong>find_chr_constraint</strong>(<var>-Constraint</var>)</a></dt>
360 <dt class="pubdef"><a name="find_chr_constraint/1"><strong>find_chr_constraint</strong>(<var>-Constraint</var>)</a></dt>
402361 <dd class="defbody">
403362 Returns a constraint in the constraint store. Via backtracking, all
404363 constraints in the store can be enumerated.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="topvars.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="compilation.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:debugoverview"><a id="sec:2.9"><span class="sec-nr">2.9</span> <span class="sec-title">Overview
194 <h2 id="sec:debugoverview"><a name="sec:2.9"><span class="sec-nr">2.9</span> <span class="sec-title">Overview
236195 of the Debugger</span></a></h2>
237196
238 <a id="sec:debugoverview"></a>
197 <a name="sec:debugoverview"></a>
239198
240199 <p>SWI-Prolog has a 6-port tracer, extending the standard 4-port tracer
241200 <cite><a class="cite" href="Bibliography.html#Byrd:80">Byrd, 1980</a>, <a class="cite" href="Bibliography.html#Clocksin:87">Clocksin &amp;
242201 Melish, 1987</a></cite> with two additional ports. The optional
243202 <var>unify</var> port allows the user to inspect the result after
244203 unification of the head. The <var>exception</var> port shows exceptions
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
204 raised by <a name="idx:throw1:55"></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
247206 4.11</a>.
248207
249208 <p>The standard ports are called <code>call</code>, <code>exit</code>, <code>redo</code>,
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>
209 <code>fail</code> and <code>unify</code>. The tracer is started by the <a name="idx:trace0:56"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
251210 command, when a spy point is reached and the system is in debugging mode
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>),
211 (see <a name="idx:spy1:57"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
212 and <a name="idx:debug0:58"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>),
254213 or when an exception is raised that is not caught.
255214
256 <p>The interactive top-level goal <a id="idx:trace0:58"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
215 <p>The interactive top-level goal <a name="idx:trace0:59"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
257216 means ``trace the next query''. The tracer shows the port, displaying
258217 the port name, the current depth of the recursion and the goal. The goal
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>.
218 is printed using the Prolog predicate <a name="idx:writeterm2:60"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
260219 The style is defined by the Prolog flag
261220 <a class="flag" href="flags.html#flag:debugger_write_options">debugger_write_options</a>
262221 and can be modified using this flag or using the <code>w</code>, <code>p</code>
293252
294253 <div class="caption"><b>Figure 2 : </b>Example trace of the program
295254 above showing all ports. The lines marked <code><code>^</code></code>
296 indicate calls to <em>transparent</em> predicates. See <a class="sec" href="modules.html#sec:6">section
255 indicate calls to <em>transparent</em> predicates. See <a class="sec" href="modules.html">section
297256 6</a>.</div>
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>,
257 <a name="fig:tracer"></a>
258
259 <p>On <em>leashed ports</em> (set with the predicate <a name="idx:leash1:61"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>,
301260 default are
302261 <code>call</code>, <code>exit</code>, <code>redo</code> and <code>fail</code>)
303262 the user is prompted for an action. All actions are single-character
307266 <dl class="latex">
308267 <dt><strong>Spy</strong> (<code>+</code>)</dt>
309268 <dd class="defbody">
310 Set a spy point (see <a id="idx:spy1:61"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
269 Set a spy point (see <a name="idx:spy1:62"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
311270 on the current predicate.
312271 </dd>
313272 <dt><strong>No spy</strong> (<code>-</code>)</dt>
314273 <dd class="defbody">
315 Remove the spy point (see <a id="idx:nospy1:62"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>)
274 Remove the spy point (see <a name="idx:nospy1:63"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>)
316275 from the current predicate.
317276 </dd>
318277 <dt><strong>Find</strong> (<code>/</code>)</dt>
323282 unify with the goal run by the port. If no term is specified it is taken
324283 as a variable, searching for any port of the specified type. If an atom
325284 is given, any goal whose functor has a name equal to that atom matches.
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>
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:64"></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:65"></a><a class="pred" href="lists.html#member/2">member/2</a>. </td></tr>
334295 </table>
296 </div>
335297 </dd>
336298 <dt><strong>Repeat find</strong> (<code>.</code>)</dt>
337299 <dd class="defbody">
344306 <dt><strong>Context</strong> (<code>C</code>)</dt>
345307 <dd class="defbody">
346308 Toggle `Show Context'. If <code>on</code>, the context module of the
347 goal is displayed between square brackets (see <a class="sec" href="modules.html#sec:6">section
309 goal is displayed between square brackets (see <a class="sec" href="modules.html">section
348310 6</a>). Default is <code>off</code>.
349311 </dd>
350312 <dt><strong>Listing</strong> (<code>L</code>)</dt>
351313 <dd class="defbody">
352 List the current predicate with <a id="idx:listing1:65"></a><a class="pred" href="listing.html#listing/1">listing/1</a>.
314 List the current predicate with <a name="idx:listing1:66"></a><a class="pred" href="listing.html#listing/1">listing/1</a>.
353315 </dd>
354316 <dt><strong>Abort</strong> (<code>a</code>)</dt>
355317 <dd class="defbody">
356 Abort Prolog execution (see <a id="idx:abort0:66"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
318 Abort Prolog execution (see <a name="idx:abort0:67"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
357319 </dd>
358320 <dt><strong>Break</strong> (<code>b</code>)</dt>
359321 <dd class="defbody">
360 Enter a Prolog break environment (see <a id="idx:break0:67"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
322 Enter a Prolog break environment (see <a name="idx:break0:68"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
361323 </dd>
362324 <dt><strong>Creep</strong> (<code>c</code>)</dt>
363325 <dd class="defbody">
371333 </dd>
372334 <dt><strong>Exit</strong> (<code>e</code>)</dt>
373335 <dd class="defbody">
374 Terminate Prolog (see <a id="idx:halt0:68"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>).
336 Terminate Prolog (see <a name="idx:halt0:69"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>).
375337 </dd>
376338 <dt><strong>Fail</strong> (<code>f</code>)</dt>
377339 <dd class="defbody">
425387 <dd class="defbody">
426388 Set the Prolog flag <a class="flag" href="flags.html#flag:debugger_write_options">debugger_write_options</a>
427389 to <code>[quoted(true), attributes(write), priority(699)]</code>,
428 bypassing <a id="idx:portray1:69"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>,
390 bypassing <a name="idx:portray1:70"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>,
429391 etc.
430392 </dd>
431393 </dl>
437399 because code optimisation removes part of the choice and exit points.
438400 Backtrack points are not shown if either the goal succeeded
439401 deterministically or its alternatives were removed using the cut. When
440 running in debug mode (<a id="idx:debug0:70"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>)
402 running in debug mode (<a name="idx:debug0:71"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>)
441403 choice points are only destroyed when removed by the cut. In debug mode,
442404 last call optimisation is switched off.<sup class="fn">13<span class="fn-text">This
443405 implies the system can run out of stack in debug mode, while no problems
444406 arise when running in non-debug mode.</span></sup>
445407
446408 <p>Reference information to all predicates available for manipulating
447 the debugger is in <a class="sec" href="debugger.html#sec:4.39">section
448 4.39</a>.
409 the debugger is in <a class="sec" href="debugger.html">section 4.39</a>.
449410
450411 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="whymodules.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="import.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:defmodule"><a id="sec:6.2"><span class="sec-nr">6.2</span> <span class="sec-title">Defining
194 <h2 id="sec:defmodule"><a name="sec:6.2"><span class="sec-nr">6.2</span> <span class="sec-title">Defining
236195 a Module</span></a></h2>
237196
238 <a id="sec:defmodule"></a>
197 <a name="sec:defmodule"></a>
239198
240199 <p>Modules are normally created by loading a <em>module file</em>. 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>
200 module file is a file holding a <a name="idx:module2:1663"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
242201 directive as its first term. The
243 <a id="idx:module2:1665"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
202 <a name="idx:module2:1664"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
244203 directive declares the name and the public (i.e., externally visible)
245204 predicates of the module. The rest of the file is loaded into the
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>.
205 module. Below is an example of a module file, defining <a name="idx:reverse2:1665"></a><a class="pred" href="lists.html#reverse/2">reverse/2</a>
206 and hiding the helper predicate <a name="idx:rev3:1666"></a><span class="pred-ext">rev/3</span>.
248207 A module can use all built-in predicates and, by default, cannot
249208 redefine system predicates.
250209
268227 module explicitly in the source text.
269228
270229 <dl class="latex">
271 <dt class="pubdef"><a id="module/2">:- <strong>module</strong>(<var>+Module,
230 <dt class="pubdef"><a name="module/2">:- <strong>module</strong>(<var>+Module,
272231 +PublicList</var>)</a></dt>
273232 <dd class="defbody">
274233 This directive can only be used as the first term of a source file. It
278237 is a list of predicate indicators (name/arity or name//arity pairs) or
279238 operator declarations using the format <code>op(Precedence, Type, Name)</code>.
280239 Operators defined in the export list are available inside the module as
281 well as to modules importing this module. See also <a class="sec" href="operators.html#sec:4.25">section
240 well as to modules importing this module. See also <a class="sec" href="operators.html">section
282241 4.25</a>.
283242
284243 <p>Compatible to Ciao Prolog, if <var>Module</var> is unbound, it is
285244 unified with the basename without extension of the file being loaded.</dd>
286 <dt class="pubdef"><a id="module/3">:- <strong>module</strong>(<var>+Module,
245 <dt class="pubdef"><a name="module/3">:- <strong>module</strong>(<var>+Module,
287246 +PublicList, +Dialect</var>)</a></dt>
288247 <dd class="defbody">
289 Same as <a id="idx:module2:1668"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
248 Same as <a name="idx:module2:1667"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
290249 The additional <var>Dialect</var> argument provides a list of <em>language
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
250 options</em>. Each atom in the list <var>Dialect</var> is mapped to a <a name="idx:usemodule1:1668"></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
293252 C</a>. The third argument is supported for compatibility with the
294 <a class="url" href="http://prolog-commons.org/">Prolog Commons project</a>.
253 http://prolog-commons.org/Prolog Commons project .
295254
296255 <pre class="code">
297256 :- use_module(library(dialect/LangOption)).
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="metacall.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="exception.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:delcont"><a id="sec:4.10"><span class="sec-nr">4.10</span> <span class="sec-title">Delimited
194 <h2 id="sec:delcont"><a name="sec:4.10"><span class="sec-nr">4.10</span> <span class="sec-title">Delimited
236195 continuations</span></a></h2>
237196
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>
197 <a name="sec:delcont"></a>
198
199 <p>The predicates <a name="idx:reset3:680"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
200 and <a name="idx:shift1:681"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
242201 implement <em>delimited continuations</em> for Prolog. Delimited
243202 continuation for Prolog is described in <cite><a class="cite" href="Bibliography.html#DBLP:journals/tplp/SchrijversDDW13">Schrijvers <em>et
244203 al.</em>, 2013</a></cite>. The mechanism allows for proper <em>coroutines</em>,
245204 two or more routines whose execution is interleaved, while they exchange
246205 data. Note that coroutines in this sense differ from coroutines realised
247 using attributed variables as described in&nbsp;<a class="sec" href="clp.html#sec:7">chapter
206 using attributed variables as described in&nbsp;<a class="sec" href="clp.html">chapter
248207 7</a>.
249208
250209 <p>The suspension mechanism provided by delimited continuations is
253212 al.</em>, 2015</a></cite>, see library <code>library(tabling)</code>.
254213
255214 <dl class="latex">
256 <dt class="pubdef"><a id="reset/3"><strong>reset</strong>(<var>:Goal,
215 <dt class="pubdef"><a name="reset/3"><strong>reset</strong>(<var>:Goal,
257216 ?Ball, -Continuation</var>)</a></dt>
258217 <dd class="defbody">
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>
261 can be unified with <var>Ball</var>,<sup class="fn">67<span class="fn-text">The
218 Call <var>Goal</var>. If <var>Goal</var> calls <a name="idx:shift1:682"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
219 and the argument of <a name="idx:shift1:683"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
220 can be unified with <var>Ball</var>,<sup class="fn">66<span class="fn-text">The
262221 argument order described in <cite><a class="cite" href="Bibliography.html#DBLP:journals/tplp/SchrijversDDW13">Schrijvers <em>et
263222 al.</em>, 2013</a></cite> is <code>reset(Goal,Continuation,Ball)</code>.
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>
223 We swapped the argument order for compatibility with <a name="idx:catch3:684"></a><a class="pred" href="exception.html#catch/3">catch/3</a></span></sup> <a name="idx:shift1:685"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>
224 causes <a name="idx:reset3:686"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
266225 to return, unifying
267226 <var>Continuation</var> with a goal that represents the <em>continuation</em>
268 after <a id="idx:shift1:685"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>.
227 after <a name="idx:shift1:687"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>.
269228 In other words, meta-calling <var>Continuation</var> completes the
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>,
229 execution where shift left it. If <var>Goal</var> does not call <a name="idx:shift1:688"></a><a class="pred" href="delcont.html#shift/1">shift/1</a>,
271230 <var>Continuation</var> are unified with the integer <code>0</code>
272 (zero).<sup class="fn">68<span class="fn-text">Note that older versions
231 (zero).<sup class="fn">67<span class="fn-text">Note that older versions
273232 also unify <var>Ball</var> with <code>0</code>. Testing whether or not
274233 shift happened on <var>Ball</var> however is <em>always</em> ambiguous.</span></sup></dd>
275 <dt class="pubdef"><a id="shift/1"><strong>shift</strong>(<var>+Ball</var>)</a></dt>
234 <dt class="pubdef"><a name="shift/1"><strong>shift</strong>(<var>+Ball</var>)</a></dt>
276235 <dd class="defbody">
277236 Abandon the execution of the current goal, returning control to just
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>
237 <em>after</em> the matching <a name="idx:reset3:689"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
238 call. This is similar to <a name="idx:throw1:690"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
280239 except that (1) nothing is `undone' and (2) the 3th argument of
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>
240 <a name="idx:reset3:691"></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:692"></a><a class="pred" href="delcont.html#reset/3">reset/3</a>
283242 to <em>resume</em> the current goal.
284243 </dd>
285244 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="loadfilehook.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="portabilitystrategies.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:dialect"><a id="sec:C"><span class="sec-nr">C</span> <span class="sec-title">Compatibility
194 <h1 id="sec:dialect"><a name="sec:C"><span class="sec-nr">C</span> <span class="sec-title">Compatibility
236195 with other Prolog dialects</span></a></h1>
237196
238 <a id="sec:dialect"></a>
239
240 <p><a id="idx:YAPprolog:2247"></a><a id="idx:portableprologcode:2248"></a>This
197 <a name="sec:dialect"></a>
198
199 <p><a name="idx:YAPprolog:2246"></a><a name="idx:portableprologcode:2247"></a>This
241200 chapter explains issues for writing portable Prolog programs. It was
242201 started after discussion with Vitor Santos Costa, the leading developer
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>
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>
244203 YAP and SWI-Prolog have expressed the ambition to enhance the
245204 portability beyond the trivial Prolog examples, including complex
246205 libraries involving foreign code.
266225
267226 <p>
268227 <li>Conditional compilation using <code>:- if(Condition)</code> ...<code>:-
269 endif</code> is supported. See <a class="sec" href="consulting.html#sec:4.3.1.2">section
228 endif</code> is supported. See <a class="sec" href="consulting.html">section
270229 4.3.1.2</a>.
271230
272231 <p>
273 <li>The predicate <a id="idx:expectsdialect1:2249"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
232 <li>The predicate <a name="idx:expectsdialect1:2248"></a><a class="pred" href="dialect.html#expects_dialect/1">expects_dialect/1</a>
274233 allows for specifying for which Prolog system the code was written.
275234
276235 <p>
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>
236 <li>The predicates <a name="idx:existssource1:2249"></a><a class="pred" href="dialect.html#exists_source/1">exists_source/1</a>
237 and <a name="idx:sourceexports2:2250"></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:2251"></a><a class="pred" href="consulting.html#require/1">require/1</a>
280239 directive can be used to get access to predicates without knowing their
281240 location.
282241
283242 <p>
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>
243 <li>The module predicates <a name="idx:usemodule1:2252"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>, <a name="idx:usemodule2:2253"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
285244 have been extended with a notion for `import-except' and `import-as'.
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>
245 This is particularly useful together with <a name="idx:reexport1:2254"></a><a class="pred" href="reexport.html#reexport/1">reexport/1</a>
246 and <a name="idx:reexport2:2255"></a><a class="pred" href="reexport.html#reexport/2">reexport/2</a>
288247 to compose modules from other modules and mapping names.
289248
290249 <p>
293252 </ul>
294253
295254 <dl class="latex">
296 <dt class="pubdef"><a id="expects_dialect/1">:- <strong>expects_dialect</strong>(<var>+Dialect</var>)</a></dt>
255 <dt class="pubdef"><a name="expects_dialect/1">:- <strong>expects_dialect</strong>(<var>+Dialect</var>)</a></dt>
297256 <dd class="defbody">
298257 This directive states that the code following the directive is written
299258 for the given Prolog <var>Dialect</var>. See also <a class="flag" href="flags.html#flag:dialect">dialect</a>.
300259 The declaration holds until the end of the file in which it appears. The
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>.
260 current dialect is available using <a name="idx:prologloadcontext2:2256"></a><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a>.
302261
303262 <p>The exact behaviour of this predicate is still subject to discussion.
304263 Of course, if <var>Dialect</var> matches the running dialect the
311270 <li>Define system predicates of the requested dialect we do not have.
312271
313272 <p>
314 <li>Apply <a id="idx:goalexpansion2:2258"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
273 <li>Apply <a name="idx:goalexpansion2:2257"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
315274 rules that map conflicting predicates to versions emulating the
316275 requested dialect. These expansion rules reside in the dialect
317276 compatibility module, but are applied if prolog_load_context(dialect,
325284 <li>Setup support for the default filename extension of the dialect.
326285 </ul>
327286 </dd>
328 <dt class="pubdef"><a id="exists_source/1"><strong>exists_source</strong>(<var>+Spec</var>)</a></dt>
287 <dt class="pubdef"><a name="exists_source/1"><strong>exists_source</strong>(<var>+Spec</var>)</a></dt>
329288 <dd class="defbody">
330289 Is true if <var>Spec</var> exists as a Prolog source. <var>Spec</var>
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>.
290 uses the same conventions as <a name="idx:loadfiles2:2258"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
332291 Fails without error if <var>Spec</var> cannot be found.</dd>
333 <dt class="pubdef"><a id="source_exports/2"><strong>source_exports</strong>(<var>+Spec,
292 <dt class="pubdef"><a name="source_exports/2"><strong>source_exports</strong>(<var>+Spec,
334293 +Export</var>)</a></dt>
335294 <dd class="defbody">
336295 Is true if source <var>Spec</var> exports <var>Export</var>, a predicate
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ext-syntax.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ext-integration.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:dicts"><a id="sec:5.4"><span class="sec-nr">5.4</span> <span class="sec-title">Dicts:
194 <h2 id="sec:dicts"><a name="sec:5.4"><span class="sec-nr">5.4</span> <span class="sec-title">Dicts:
236195 structures with named arguments</span></a></h2>
237196
238 <a id="sec:dicts"></a>
197 <a name="sec:dicts"></a>
239198
240199 <p>SWI-Prolog version&nbsp;7 introduces dicts as an abstract object with
241200 a concrete modern syntax and functional notation for accessing members
254213 into an opaque internal representation that does <em>not</em> respect
255214 the order in which the key-value pairs appear in the input text. If a
256215 dict is written, the keys are written according to the standard order of
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.
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.
260219
261220 <pre class="code">
262221 ?- A = point{x:1, y:2}.
288247 into a new dict that has the union of the keys of the two original
289248 dicts.
290249
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
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
292251 on dicts</span></a></h3>
293252
294 <a id="sec:ext-dict-functions"></a>
253 <a name="sec:ext-dict-functions"></a>
295254
296255 <p>The infix operator dot (<code>op(100, yfx, .)</code> is used to
297256 extract values and evaluate functions on dicts. Functions are recognised
336295
337296 <p>Note that expansion of <code><code>.</code>/2</code> terms implies
338297 that such terms cannot be created by writing them explicitly in your
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>
298 source code. Such terms can still be created with <a name="idx:functor3:1634"></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:1635"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
341300 and
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
301 <a name="idx:compoundnamearguments3:1636"></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
343302 code is unlikely to use <code><code>.</code>/2</code> terms because they
344303 were practically reserved for usage in lists. We do not provide a
345304 quoting mechanism as found in functional languages because it would only
347306 rare and term manipulation provides an escape route.</span></sup>
348307
349308 <dl class="latex">
350 <dt class="pubdef"><a id="./3"><strong>.</strong>(<var>+Dict, +Function,
351 -Result</var>)</a></dt>
309 <dt class="pubdef"><a name="./3"><strong>.</strong>(<var>+Dict,
310 +Function, -Result</var>)</a></dt>
352311 <dd class="defbody">
353312 This predicate is called to evaluate <code><code>.</code>/2</code> terms
354313 found in the arguments of a goal. This predicate evaluates the field
355 extraction described above, which is mapped to <a id="idx:getdictex3:1634"></a><span class="pred-ext">get_dict_ex/3</span>.
314 extraction described above, which is mapped to <a name="idx:getdictex3:1637"></a><span class="pred-ext">get_dict_ex/3</span>.
356315 If <var>Function</var> is a compound term, it checks for the predefined
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
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
359318 5.4.1.1</a>.
360319 </dd>
361320 </dl>
362321
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
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
364323 defined functions on dicts</span></a></h4>
365324
366 <a id="sec:ext-dict-user-functions"></a>
325 <a name="sec:ext-dict-user-functions"></a>
367326
368327 <p>The tag of a dict associates the dict to a module. If the dot
369328 notation uses a compound term, this calls the goal below.
377336 predicates without worrying about the argument calling conventions. The
378337 code below defines a function <code>multiply(Times)</code> on a point
379338 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>
380 would result in a predicate <a id="idx:length2:1635"></a><a class="pred" href="builtinlist.html#length/2">length/2</a>,
339 would result in a predicate <a name="idx:length2:1638"></a><a class="pred" href="builtinlist.html#length/2">length/2</a>,
381340 this name cannot be used. This might change in future versions.</span></sup>
382341 to compute the length from the origin. The . and <code>:=</code>
383342 operators are used to abstract the location of the predicate arguments.
405364 X = 4.47213595499958.
406365 </pre>
407366
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
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
409368 functions on dicts</span></a></h4>
410369
411 <a id="sec:ext-dicts-predefined"></a>
370 <a name="sec:ext-dicts-predefined"></a>
412371
413372 <p>Dicts currently define the following reserved functions:
414373
415374 <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>
469375 </dl>
470376
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
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
472378 for managing dicts</span></a></h3>
473379
474 <a id="sec:ext-dict-predicates"></a>
380 <a name="sec:ext-dict-predicates"></a>
475381
476382 <p>This section documents the predicates that are defined on dicts. We
477383 use the naming and argument conventions of the traditional <code>library(assoc)</code>.
478384
479385 <dl class="latex">
480 <dt class="pubdef"><a id="is_dict/1"><strong>is_dict</strong>(<var>@Term</var>)</a></dt>
386 <dt class="pubdef"><a name="is_dict/1"><strong>is_dict</strong>(<var>@Term</var>)</a></dt>
481387 <dd class="defbody">
482388 True if <var>Term</var> is a dict. This is the same as <code>is_dict(Term,_)</code>.</dd>
483 <dt class="pubdef"><a id="is_dict/2"><strong>is_dict</strong>(<var>@Term,
389 <dt class="pubdef"><a name="is_dict/2"><strong>is_dict</strong>(<var>@Term,
484390 -Tag</var>)</a></dt>
485391 <dd class="defbody">
486392 True if <var>Term</var> is a dict of <var>Tag</var>.</dd>
487 <dt class="pubdef"><a id="get_dict/3"><strong>get_dict</strong>(<var>?Key,
393 <dt class="pubdef"><a name="get_dict/3"><strong>get_dict</strong>(<var>?Key,
488394 +Dict, -Value</var>)</a></dt>
489395 <dd class="defbody">
490396 Unify the value associated with <var>Key</var> in dict with <var>Value</var>.
492398 <var>Key</var> is unbound, all associations in <var>Dict</var> are
493399 returned on backtracking. The order in which the associations are
494400 returned is undefined. This predicate is normally accessed using the
495 functional notation <code>Dict.Key</code>. See <a class="sec" href="dicts.html#sec:5.4.1">section
401 functional notation <code>Dict.Key</code>. See <a class="sec" href="dicts.html">section
496402 5.4.1</a>.
497403
498404 <p>Fails silently if Key does not appear in Dict. This is different from
499405 the behavior of the functional `.`-notation, which throws an existence
500406 error in that case.</dd>
501 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="get_dict/5"><strong>get_dict</strong>(<var>+Key,
407 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="get_dict/5"><strong>get_dict</strong>(<var>+Key,
502408 +Dict, -Value, -NewDict, +NewValue</var>)</a></dt>
503409 <dd class="defbody">
504410 Create a new dict after updating the value for <var>Key</var>. Fails if
515421 </pre>
516422
517423 </dd>
518 <dt class="pubdef"><a id="dict_create/3"><strong>dict_create</strong>(<var>-Dict,
424 <dt class="pubdef"><a name="dict_create/3"><strong>dict_create</strong>(<var>-Dict,
519425 +Tag, +Data</var>)</a></dt>
520426 <dd class="defbody">
521427 Create a dict in <var>Tag</var> from <var>Data</var>. <var>Data</var> is
524430 An exception is raised if <var>Data</var> is not a proper list, one of
525431 the elements is not of the shape above, a key is neither an atom nor a
526432 small integer or there is a duplicate key.</dd>
527 <dt class="pubdef"><a id="dict_pairs/3"><strong>dict_pairs</strong>(<var>?Dict,
433 <dt class="pubdef"><a name="dict_pairs/3"><strong>dict_pairs</strong>(<var>?Dict,
528434 ?Tag, ?Pairs</var>)</a></dt>
529435 <dd class="defbody">
530 Bi-directional mapping between a dict and an ordered list of pairs (see <a class="sec" href="pairs.html#sec:A.22">section
436 Bi-directional mapping between a dict and an ordered list of pairs (see <a class="sec" href="pairs.html">section
531437 A.22</a>).</dd>
532 <dt class="pubdef"><a id="put_dict/3"><strong>put_dict</strong>(<var>+New,
438 <dt class="pubdef"><a name="put_dict/3"><strong>put_dict</strong>(<var>+New,
533439 +DictIn, -DictOut</var>)</a></dt>
534440 <dd class="defbody">
535441 <var>DictOut</var> is a new dict created by replacing or adding
536442 key-value pairs from <var>New</var> to <var>Dict</var>. <var>New</var>
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>.
443 is either a dict or a valid input for <a name="idx:dictcreate3:1639"></a><a class="pred" href="dicts.html#dict_create/3">dict_create/3</a>.
538444 This predicate is normally accessed using the functional notation. Below
539445 are some examples:
540446
550456 </pre>
551457
552458 </dd>
553 <dt class="pubdef"><a id="put_dict/4"><strong>put_dict</strong>(<var>+Key,
459 <dt class="pubdef"><a name="put_dict/4"><strong>put_dict</strong>(<var>+Key,
554460 +DictIn, +Value, -DictOut</var>)</a></dt>
555461 <dd class="defbody">
556462 <var>DictOut</var> is a new dict created by replacing or adding
570476 </pre>
571477
572478 </dd>
573 <dt class="pubdef"><a id="del_dict/4"><strong>del_dict</strong>(<var>+Key,
479 <dt class="pubdef"><a name="del_dict/4"><strong>del_dict</strong>(<var>+Key,
574480 +DictIn, ?Value, -DictOut</var>)</a></dt>
575481 <dd class="defbody">
576482 True when <var>Key</var>-<var>Value</var> is in <var>DictIn</var> and <var>DictOut</var>
577483 contains all associations of <var>DictIn</var> except for <var>Key</var>.</dd>
578 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id=":</2"><var>+Select</var> <strong>:&lt;</strong> <var>+From</var></a></dt>
484 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name=":</2"><var>+Select</var> <strong>:&lt;</strong> <var>+From</var></a></dt>
579485 <dd class="defbody">
580486 True when <var>Select</var> is a `sub dict' of <var>From</var>: the
581487 tages must unify and all keys in <var>Select</var> must appear with
595501
596502 <p>The goal <code>Select :&lt; From</code> is equivalent to
597503 <code>select_dict(Select, From, _)</code>.</dd>
598 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="select_dict/3"><strong>select_dict</strong>(<var>+Select,
504 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="select_dict/3"><strong>select_dict</strong>(<var>+Select,
599505 +From, -Rest</var>)</a></dt>
600506 <dd class="defbody">
601507 True when the tags of <var>Select</var> and <var>From</var> have been
611517 R = _G1705{z:2}.
612518 </pre>
613519
614 <p>See also <a id="idx:selectdict2:1641"></a><span class="pred-ext">select_dict/2</span>
520 <p>See also <a name="idx:selectdict2:1640"></a><span class="pred-ext">select_dict/2</span>
615521 to ignore <var>Rest</var> and <a class="pred" href="dicts.html#>:</2">&gt;:&lt;/2</a>
616522 for a symmetric partial unification of two dicts.</dd>
617 <dt class="pubdef"><a id=">:</2"><var>+Dict1</var> <strong>&gt;:&lt;</strong> <var>+Dict2</var></a></dt>
523 <dt class="pubdef"><a name=">:</2"><var>+Dict1</var> <strong>&gt;:&lt;</strong> <var>+Dict2</var></a></dt>
618524 <dd class="defbody">
619525 This operator specifies a <em>partial unification</em> between
620526 <var>Dict1</var> and <var>Dict2</var>. It is true when the tags and the
628534 Dict &gt;:&lt; point{x:0, y:Y}.
629535 </pre>
630536
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>.
537 <p>See also <a class="pred" href="dicts.html#:</2">:&lt;/2</a> and <a name="idx:selectdict3:1641"></a><a class="pred" href="dicts.html#select_dict/3">select_dict/3</a>.
632538 </dd>
633539 </dl>
634540
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
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
636542 assignment in dicts</span></a></h4>
637543
638 <a id="sec:ext-dict-assignment"></a>
544 <a name="sec:ext-dict-assignment"></a>
639545
640546 <p>This section describes the destructive update operations defined on
641547 dicts. These actions can only <em>update</em> keys and not add or remove
647553 with care because the system may copy or share identical Prolog terms at
648554 any time. Some of this behaviour can be avoided by adding an additional
649555 unbound value to the dict. This prevents unwanted sharing and ensures
650 that <a id="idx:copyterm2:1643"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
556 that <a name="idx:copyterm2:1642"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
651557 actually copies the dict. This pitfall is demonstrated in the example
652558 below:
653559
661567 </pre>
662568
663569 <dl class="latex">
664 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="b_set_dict/3"><strong>b_set_dict</strong>(<var>+Key,
570 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="b_set_dict/3"><strong>b_set_dict</strong>(<var>+Key,
665571 !Dict, +Value</var>)</a></dt>
666572 <dd class="defbody">
667573 Destructively update the value associated with <var>Key</var> in <var>Dict</var>
668574 to
669575 <var>Value</var>. The update is trailed and undone on backtracking. This
670576 predicate raises an existence error if <var>Key</var> does not appear in
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>
577 <var>Dict</var>. The update semantics are equivalent to <a name="idx:setarg3:1643"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
672578 and
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,
579 <a name="idx:bsetval2:1644"></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,
675581 !Dict, +Value</var>)</a></dt>
676582 <dd class="defbody">
677583 Destructively update the value associated with <var>Key</var> in <var>Dict</var>
678584 to a copy of <var>Value</var>. The update is <em>not</em> undone on
679585 backtracking. This predicate raises an existence error if <var>Key</var>
680586 does not appear in
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>
587 <var>Dict</var>. The update semantics are equivalent to <a name="idx:nbsetarg3:1645"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>
682588 and
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,
589 <a name="idx:nbsetval2:1646"></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,
685591 !Dict, +Value</var>)</a></dt>
686592 <dd class="defbody">
687593 Destructively update the value associated with <var>Key</var> in <var>Dict</var>
689595 <var>Value</var>. The update is <em>not</em> undone on backtracking.
690596 This predicate raises an existence error if <var>Key</var> does not
691597 appear in
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>
598 <var>Dict</var>. The update semantics are equivalent to <a name="idx:nblinkarg3:1647"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>
693599 and
694 <a id="idx:nblinkval2:1649"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>.
600 <a name="idx:nblinkval2:1648"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>.
695601 Use with extreme care and consult the documentation of
696 <a id="idx:nblinkval2:1650"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
602 <a name="idx:nblinkval2:1649"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
697603 before use.
698604 </dd>
699605 </dl>
700606
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
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
702608 to use dicts?</span></a></h3>
703609
704 <a id="sec:ext-dicts-usage"></a>
610 <a name="sec:ext-dicts-usage"></a>
705611
706612 <p>Dicts are a new type in the Prolog world. They compete with several
707613 other types and libraries. In the list below we have a closer look at
785691 code does not rely on ordered operations.</dd>
786692 <dt><b>Library <code>library(option)</code></b></dt>
787693 <dd>
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>,
694 Option lists are introduced by ISO Prolog, for example for <a name="idx:readterm3:1650"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
695 <a name="idx:open4:1651"></a><a class="pred" href="IO.html#open/4">open/4</a>,
790696 etc. The <code>library(option)</code> library provides operations to
791697 extract options, merge options lists, etc. Dicts are well suited to
792698 replace option lists because they are cheaper, can be processed faster
795701 <dd>
796702 This library is commonly used to process large name-value associations.
797703 In many cases this concerns short-lived datastructures that result from
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>
704 <a name="idx:findall3:1652"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a name="idx:maplist3:1653"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
799705 and similar list processing predicates. Dicts may play a role if
800706 frequent random key lookups are needed on the resulting association. For
801707 example, the skeleton `create a pairs list', `use
802 <a id="idx:listtoassoc2:1655"></a><a class="pred" href="assoc.html#list_to_assoc/2">list_to_assoc/2</a>
708 <a name="idx:listtoassoc2:1654"></a><a class="pred" href="assoc.html#list_to_assoc/2">list_to_assoc/2</a>
803709 to create an assoc', followed by frequent usage of
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>
710 <a name="idx:getassoc3:1655"></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:1656"></a><a class="pred" href="dicts.html#dict_pairs/3">dict_pairs/3</a>
806712 and the dict access functions. Using dicts in this scenario is more
807713 efficient and provides a more pleasant access syntax.
808714 </dd>
809715 </dl>
810716
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
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
812718 motivation for dicts as primary citizens</span></a></h3>
813719
814 <a id="sec:ext-dicts-motivation"></a>
720 <a name="sec:ext-dicts-motivation"></a>
815721
816722 <p>Dicts, or key-value associations, are a common data structure. A good
817723 old example are <em>property lists</em> as found in Lisp, while a good
842748 <code>library(assoc)</code> allows for efficient manipulation of
843749 changing associations, but the syntactical representation of an assoc is
844750 complex, which makes them unsuitable for e.g., <em>options lists</em> as
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
751 seen in predicates such as <a name="idx:open4:1657"></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
848754 notes about dicts</span></a></h3>
849755
850 <a id="sec:ext-dicts-implementation"></a>
756 <a name="sec:ext-dicts-implementation"></a>
851757
852758 <p>Although dicts are designed as an abstract data type and we
853759 deliberately reserve the possibility to change the representation and
857763 <p>Dicts are currently represented as a compound term using the functor
858764 <code>`dict`</code>. The first argument is the tag. The remaining
859765 arguments create an array of sorted key-value pairs. This representation
860 is compact and guarantees good locality. Lookup is order <var>log( N )</var>,
766 is compact and guarantees good locality. Lookup is order <var>N</var>,
861767 while adding values, deleting values and merging with other dicts has
862768 order
863769 <var>N</var>. The main disadvantage is that changing values in large
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="altmoduleapi.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ctxmodule.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:dynamic-modules"><a id="sec:6.12"><span class="sec-nr">6.12</span> <span class="sec-title">Dynamic
194 <h2 id="sec:dynamic-modules"><a name="sec:6.12"><span class="sec-nr">6.12</span> <span class="sec-title">Dynamic
236195 Modules</span></a></h2>
237196
238 <a id="sec:dynamic-modules"></a>
197 <a name="sec:dynamic-modules"></a>
239198
240199 <p>So far, we discussed modules that were created by loading a module
241200 file. These modules have been introduced to facilitate the development
262221
263222 <p>Import and export from a dynamically created world can be achieved
264223 using
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>
224 <a name="idx:import1:1737"></a><a class="pred" href="altmoduleapi.html#import/1">import/1</a>
225 and <a name="idx:export1:1738"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>
267226 or by specifying the import module as described in
268 <a class="sec" href="importmodule.html#sec:6.9">section 6.9</a>.
227 <a class="sec" href="importmodule.html">section 6.9</a>.
269228
270229 <pre class="code">
271230 ?- world_b:export(solve/2). % exports solve/2 from world_b
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="db.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="examineprog.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:declare"><a id="sec:4.15"><span class="sec-nr">4.15</span> <span class="sec-title">Declaring
194 <h2 id="sec:declare"><a name="sec:4.15"><span class="sec-nr">4.15</span> <span class="sec-title">Declaring
236195 predicate properties</span></a></h2>
237196
238 <a id="ch:dynamic"></a>
239 <a id="sec:declare"></a>
197 <a name="ch:dynamic"></a>
198 <a name="sec:declare"></a>
240199
241200 <p>This section describes directives which manipulate attributes of
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>),
201 predicate definitions. The functors <a name="idx:dynamic1:877"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>, <a name="idx:multifile1:878"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>,
202 <a name="idx:discontiguous1:879"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>
203 and <a name="idx:public1:880"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
204 are operators of priority 1150 (see <a name="idx:op3:881"></a><a class="pred" href="operators.html#op/3">op/3</a>),
246205 which implies that the list of predicates they involve can just be a
247206 comma-separated list:
248207
257216 want to maintain portability to other Prolog implementations.
258217
259218 <dl class="latex">
260 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="dynamic/1"><strong>dynamic</strong> <var>:PredicateIndicator,
219 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="dynamic/1"><strong>dynamic</strong> <var>:PredicateIndicator,
261220 ...</var></a></dt>
262221 <dd class="defbody">
263222 Informs the interpreter that the definition of the predicate(s) may
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>).
223 change during execution (using <a name="idx:assert1:882"></a><a class="pred" href="db.html#assert/1">assert/1</a>
224 and/or <a name="idx:retract1:883"></a><a class="pred" href="db.html#retract/1">retract/1</a>).
266225 In the multithreaded version, the clauses of dynamic predicates are
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>
226 shared between the threads. The directive <a name="idx:threadlocal1:884"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>
268227 provides an alternative where each thread has its own clause list for
269228 the predicate. Dynamic predicates can be turned into static ones using
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>
229 <a name="idx:compilepredicates1:885"></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:886"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
274233 and
275 <a id="idx:assert1:885"></a><a class="pred" href="db.html#assert/1">assert/1</a>)
234 <a name="idx:assert1:887"></a><a class="pred" href="db.html#assert/1">assert/1</a>)
276235 into normal static predicates. This call tells the Prolog environment
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>
236 the definition will not change anymore and further calls to <a name="idx:assert1:888"></a><a class="pred" href="db.html#assert/1">assert/1</a>
237 or <a name="idx:retract1:889"></a><a class="pred" href="db.html#retract/1">retract/1</a>
279238 on the named predicates raise a permission error. This predicate is
280239 designed to deal with parts of the program that are generated at runtime
281 but do not change during the remainder of the program execution.<sup class="fn">79<span class="fn-text">The
240 but do not change during the remainder of the program execution.<sup class="fn">78<span class="fn-text">The
282241 specification of this predicate is from Richard O'Keefe. The
283242 implementation is allowed to optimise the predicate. This is not yet
284243 implemented. In multithreaded Prolog, however, static code runs faster
285244 as it does not require synchronisation. This is particularly true on SMP
286245 hardware.</span></sup></dd>
287 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="multifile/1"><strong>multifile</strong> <var>:PredicateIndicator,
246 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="multifile/1"><strong>multifile</strong> <var>:PredicateIndicator,
288247 ...</var></a></dt>
289248 <dd class="defbody">
290249 Informs the system that the specified predicate(s) may be defined over
291 more than one file. This stops <a id="idx:consult1:888"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
250 more than one file. This stops <a name="idx:consult1:890"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>
292251 from redefining a predicate when a new definition is found.</dd>
293 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="discontiguous/1"><strong>discontiguous</strong> <var>:PredicateIndicator,
252 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="discontiguous/1"><strong>discontiguous</strong> <var>:PredicateIndicator,
294253 ...</var></a></dt>
295254 <dd class="defbody">
296255 Informs the system that the clauses of the specified predicate(s) might
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,
256 not be together in the source file. See also <a name="idx:stylecheck1:891"></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,
299258 ...</var></a></dt>
300259 <dd class="defbody">
301260 Instructs the cross-referencer that the predicate can be called. It has
302 no semantics.<sup class="fn">80<span class="fn-text">This declaration is
303 compatible with SICStus. In YAP, <a id="idx:public1:890"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
261 no semantics.<sup class="fn">79<span class="fn-text">This declaration is
262 compatible with SICStus. In YAP, <a name="idx:public1:892"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
304263 instructs the compiler to keep the source. As the source is always
305264 available in SWI-Prolog, our current interpretation also enhances the
306265 compatibility with YAP.</span></sup> The public declaration can be
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>
266 queried using <a name="idx:predicateproperty2:893"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
267 The <a name="idx:public1:894"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
309268 directive does
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>).
269 <em>not</em> export the predicate (see <a name="idx:module1:895"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>
270 and <a name="idx:export1:896"></a><a class="pred" href="altmoduleapi.html#export/1">export/1</a>).
312271 The public directive is used for (1) direct calls into the module from,
313272 e.g., foreign code, (2) direct calls into the module from other modules,
314273 or (3) flag a predicate as being called if the call is generated by
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="consulting.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="listing.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:edit"><a id="sec:4.4"><span class="sec-nr">4.4</span> <span class="sec-title">Editor
194 <h2 id="sec:edit"><a name="sec:4.4"><span class="sec-nr">4.4</span> <span class="sec-title">Editor
236195 Interface</span></a></h2>
237196
238 <a id="sec:edit"></a>
197 <a name="sec:edit"></a>
239198
240199 <p>SWI-Prolog offers an extensible interface which allows the user to
241200 edit objects of the program: predicates, modules, files, etc. The editor
242 interface is implemented by <a id="idx:edit1:585"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
201 interface is implemented by <a name="idx:edit1:587"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
243202 and consists of three parts:
244203 <em>locating</em>, <em>selecting</em> and <em>starting</em> the editor.
245 Any of these parts may be customized. See <a class="sec" href="edit.html#sec:4.4.1">section
204 Any of these parts may be customized. See <a class="sec" href="edit.html">section
246205 4.4.1</a>.
247206
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>
207 <p>The built-in edit specifications for <a name="idx:edit1:588"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
249208 (see prolog_edit:locate/3) are described in the table below:
250209
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
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
254214 to a predicate </td></tr>
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
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
261225 to this predicate in any 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>
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>
265229 </table>
266230
267231 <dl class="latex">
268 <dt class="pubdef"><a id="edit/1"><strong>edit</strong>(<var>+Specification</var>)</a></dt>
232 <dt class="pubdef"><a name="edit/1"><strong>edit</strong>(<var>+Specification</var>)</a></dt>
269233 <dd class="defbody">
270234 First, exploit <a class="pred" href="edit.html#prolog_edit:locate/3">prolog_edit:locate/3</a>
271235 to translate
272236 <var>Specification</var> into a list of <em>Locations</em>. If there is
273237 more than one `hit', the user is asked to select from the locations
274238 found. Finally, <a class="pred" href="edit.html#prolog_edit:edit_source/1">prolog_edit:edit_source/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>
239 is used to invoke the user's preferred editor. Typically, <a name="idx:edit1:589"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
276240 can be handed the name of a predicate, module, basename of a file, XPCE
277241 class, XPCE method, etc.</dd>
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>.
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:590"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
281245 The default file is the file loaded with the command line option <strong>-s</strong>
282246 or, in Windows, the file loaded by double-clicking from the Windows
283247 shell.
284248 </dd>
285249 </dl>
286250
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
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
288252 the editor interface</span></a></h3>
289253
290 <a id="sec:customedit"></a>
254 <a name="sec:customedit"></a>
291255
292256 <p>The predicates described in this section are <em>hooks</em> that can
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>,
257 be defined to disambiguate specifications given to <a name="idx:edit1:591"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
294258 find the related source, and open an editor at the given source
295259 location.
296260
297261 <dl class="latex">
298 <dt class="pubdef"><a id="prolog_edit:locate/3"><strong>prolog_edit:locate</strong>(<var>+Spec,
262 <dt class="pubdef"><a name="prolog_edit:locate/3"><strong>prolog_edit:locate</strong>(<var>+Spec,
299263 -FullSpec, -Location</var>)</a></dt>
300264 <dd class="defbody">
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>.
265 Where <var>Spec</var> is the specification provided through <a name="idx:edit1:592"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
302266 This multifile predicate is used to enumerate locations where an object
303267 satisfying the given <var>Spec</var> can be found. <var>FullSpec</var>
304268 is unified with the complete specification for the object. This
310274 <p><var>Location</var> is a list of attributes of the location.
311275 Normally, this list will contain the term <code>file(File)</code> and,
312276 if available, the term <code>line(Line)</code>.</dd>
313 <dt class="pubdef"><a id="prolog_edit:locate/2"><strong>prolog_edit:locate</strong>(<var>+Spec,
277 <dt class="pubdef"><a name="prolog_edit:locate/2"><strong>prolog_edit:locate</strong>(<var>+Spec,
314278 -Location</var>)</a></dt>
315279 <dd class="defbody">
316280 Same as prolog_edit:locate/3, but only deals with fully specified
317281 objects.</dd>
318 <dt class="pubdef"><a id="prolog_edit:edit_source/1"><strong>prolog_edit:edit_source</strong>(<var>+Location</var>)</a></dt>
282 <dt class="pubdef"><a name="prolog_edit:edit_source/1"><strong>prolog_edit:edit_source</strong>(<var>+Location</var>)</a></dt>
319283 <dd class="defbody">
320284 Start editor on <var>Location</var>. See prolog_edit:locate/3 for the
321285 format of a location term. This multifile predicate is normally not
322 defined. If it succeeds, <a id="idx:edit1:591"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
286 defined. If it succeeds, <a name="idx:edit1:593"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
323287 assumes the editor is started.
324288
325 <p>If it fails, <a id="idx:edit1:592"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
289 <p>If it fails, <a name="idx:edit1:594"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
326290 uses its internal defaults, which are defined by the Prolog flag <a class="flag" href="flags.html#flag:editor">editor</a>
327291 and/or the environment variable
328292 <code>EDITOR</code>. The following rules apply. If the Prolog flag <a class="flag" href="flags.html#flag:editor">editor</a>
337301
338302 <p>See the default user preferences file <code>dotfiles/dotswiplrc</code>
339303 for examples.</dd>
340 <dt class="pubdef"><a id="prolog_edit:edit_command/2"><strong>prolog_edit:edit_command</strong>(<var>+Editor,
304 <dt class="pubdef"><a name="prolog_edit:edit_command/2"><strong>prolog_edit:edit_command</strong>(<var>+Editor,
341305 -Command</var>)</a></dt>
342306 <dd class="defbody">
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>
307 Determines how <var>Editor</var> is to be invoked using <a name="idx:shell1:595"></a><a class="pred" href="system.html#shell/1">shell/1</a>. <var>Editor</var>
344308 is the determined editor (see qpredrefprolog_editedit_source1), without
345309 the full path specification, and without a possible (<code>.exe</code>)
346310 extension. <var>Command</var> is an atom describing the command. The
347311 following %-sequences are replaced in <var>Command</var> before the
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>
312 result is handed to <a name="idx:shell1:596"></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>
354320 </table>
355321
356322 <p>If the editor can deal with starting at a specified line, two clauses
363329 a given line number.
364330
365331 <p>Please contribute your specifications to <a class="url" href="mailto:bugs@swi-prolog.org">bugs@swi-prolog.org</a>.</dd>
366 <dt class="pubdef"><a id="prolog_edit:load/0"><strong>prolog_edit:load</strong></a></dt>
332 <dt class="pubdef"><a name="prolog_edit:load/0"><strong>prolog_edit:load</strong></a></dt>
367333 <dd class="defbody">
368334 Normally an undefined multifile predicate. This predicate may be defined
369335 to provide loading hooks for user extensions to the edit module. For
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="usingmodules.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="pceemacs.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:editreload"><a id="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">The
194 <h2 id="sec:editreload"><a name="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">The
236195 test-edit-reload cycle</span></a></h2>
237196
238 <a id="sec:editreload"></a>
197 <a name="sec:editreload"></a>
239198
240199 <p>SWI-Prolog does not enforce the use of a particular editor for
241200 writing Prolog source code. Editors are complicated programs that must
247206
248207 <p>The use of a built-in editor, which is selected by setting the Prolog
249208 flag <a class="flag" href="flags.html#flag:editor">editor</a> to <code>pce_emacs</code>,
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
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
255214 things to edit</span></a></h3>
256215
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>,
216 <a name="sec:editfind"></a>
217
218 <p><a name="idx:TABcompletion:306"></a><a name="idx:completionTAB:307"></a>The
219 central predicate for editing something is <a name="idx:edit1:308"></a><a class="pred" href="edit.html#edit/1">edit/1</a>,
261220 an extensible front-end that searches for objects (files, predicates,
262221 modules, as well as XPCE classes and methods) in the Prolog database. If
263222 multiple matches are found it provides a choice. Together with the
274233 Your choice?
275234 </pre>
276235
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
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
278237 and incremental compilation</span></a></h3>
279238
280 <a id="sec:editcompile"></a>
239 <a name="sec:editcompile"></a>
281240
282241 <p>One of the nice features of Prolog is that the code can be modified
283242 while the program is running. Using pure Prolog you can trace a program,
288247 understanding the misbehaviour, edit the source, reload it and try
289248 again.
290249
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>,
250 <p>One of the nice features of SWI-Prolog is the availability of <a name="idx:make0:309"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
292251 a simple predicate that checks all loaded source files to see which ones
293252 you have modified. It then reloads these files, considering the module
294253 from which the file was loaded originally. This greatly simplifies the
300259 </pre>
301260
302261 <p>Now edit the source, possibly switching to other files and making
303 multiple changes. After finishing, invoke <a id="idx:make0:308"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
262 multiple changes. After finishing, invoke <a name="idx:make0:310"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
304263 either through the editor UI (<strong>Compile/Make</strong> (<code>Control-C
305264 Control-M</code>)) or on the top level, and watch the files being
306265 reloaded.<sup class="fn">37<span class="fn-text">Watching these files is
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 10.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="engines.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="engine-resources.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:engine-examples"><a id="sec:10.1"><span class="sec-nr">10.1</span> <span class="sec-title">Examples
194 <h2 id="sec:engine-examples"><a name="sec:10.1"><span class="sec-nr">10.1</span> <span class="sec-title">Examples
236195 using engines</span></a></h2>
237196
238 <a id="sec:engine-examples"></a>
197 <a name="sec:engine-examples"></a>
239198
240199 <p>We introduce engines by describing application areas and providing
241200 simple example programs. The predicates are defined in
242 <a class="sec" href="engine-predicates.html#sec:10.3">section 10.3</a>.
243 We identify the following application areas for engines.
201 <a class="sec" href="engine-predicates.html">section 10.3</a>. We
202 identify the following application areas for engines.
244203
245204 <p>
246205 <ol class="latex">
247206 <li>Aggregating solutions from one or more goals. See
248 <a class="sec" href="engine-examples.html#sec:10.1.1">section 10.1.1</a>.
207 <a class="sec" href="engine-examples.html">section 10.1.1</a>.
249208 <li>Access the terms produced in <em>forward execution</em> through
250 backtracking without collecting all of them first. <a class="sec" href="engine-examples.html#sec:10.1.1">Section
209 backtracking without collecting all of them first. <a class="sec" href="engine-examples.html">Section
251210 10.1.1</a> illustrates this as well.
252 <li>State accumulation and sharing. See <a class="sec" href="engine-examples.html#sec:10.1.2">section
211 <li>State accumulation and sharing. See <a class="sec" href="engine-examples.html">section
253212 10.1.2</a>.
254 <li>Scalable many-agent applications. See <a class="sec" href="engine-examples.html#sec:10.1.3">section
213 <li>Scalable many-agent applications. See <a class="sec" href="engine-examples.html">section
255214 10.1.3</a>.
256215 </ol>
257216
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
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
259218 using engines</span></a></h3>
260219
261 <a id="sec:engine-aggregation"></a>
220 <a name="sec:engine-aggregation"></a>
262221
263222 <p>Engines can be used to reason about solutions produced by a goal
264223 through backtracking. In this scenario we create an engine with the goal
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>,
224 we wish to backtrack over and we enumerate all its solution using <a name="idx:enginenext1:1968"></a><span class="pred-ext">engine_next/1</span>.
225 This usage scenario competes with the all solution predicates (<a name="idx:findall3:1969"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>, <a name="idx:bagof3:1970"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>,
267226 etc.) and the predicates from library
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>
227 <code>library(aggregate)</code>. Below we implement <a name="idx:findall3:1971"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
269228 using engines.
270229
271230 <pre class="code">
283242
284243 <p>The above is not a particularly attractive alternative for the
285244 built-in
286 <a id="idx:findall3:1973"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
245 <a name="idx:findall3:1972"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
287246 It is mostly slower due to time required to create and destroy the
288 engine as well as the (currently<sup class="fn">166<span class="fn-text">The
247 engine as well as the (currently<sup class="fn">165<span class="fn-text">The
289248 current implementation of engines is built on top of primitives that are
290249 not optimal for the engine use case. There is considerable opportunity
291250 to reduce the overhead.</span></sup>) higher overhead of copying terms
292251 between engines than the overhead required by the dedicated
293252 representation used by
294 <a id="idx:findall3:1974"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
253 <a name="idx:findall3:1973"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>.
295254
296255 <p>It gets more interesting if we wish to combine answers from multiple
297256 backtracking predicates. Assume we have two predicates that, on
372331 yield_remaining(S1, E).
373332 </pre>
374333
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
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
376335 accumulation using engines</span></a></h3>
377336
378 <a id="sec:engine-state"></a>
337 <a name="sec:engine-state"></a>
379338
380339 <p>Applications that need to manage a state can do so by passing the
381340 state around in an additional argument, storing it in a global variable
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>),
341 or update it in the dynamic database using <a name="idx:assertz1:1974"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
342 and <a name="idx:retract1:1975"></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:1976"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>),
385344 make the state subject to backtracking. This may or may not be
386345 desirable. If having a state is that subject to backtracking is
387346 required, using an additional argument or backtrackable global variable
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>)
347 is the right approach. Otherwise, non-backtrackable global variables (<a name="idx:nbsetval2:1977"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>)
389348 and dynamic database come into the picture, where global variables are
390349 always local to a thread and the dynamic database may or may not be
391 shared between threads (see <a id="idx:threadlocal1:1979"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>).
350 shared between threads (see <a name="idx:threadlocal1:1978"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>).
392351
393352 <p>Engines bring an alternative that packages a state inside the engine
394353 where it is typically represented in a (threaded) Prolog variable. The
400359 <p>
401360 <ul class="latex">
402361 <li>The programming style needed inside the engine is much more `Prolog
403 friendly', using <a id="idx:enginefetch1:1980"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>
362 friendly', using <a name="idx:enginefetch1:1979"></a><a class="pred" href="engine-predicates.html#engine_fetch/1">engine_fetch/1</a>
404363 to read a request and
405 <a id="idx:engineyield1:1981"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
364 <a name="idx:engineyield1:1980"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
406365 to reply to it.
407366 <li>The state is packaged and subject to (atom) garbage collection.
408367 <li>The state may be accessed from multiple threads. Access to the state
414373 typical update loop for maintaining state inside an engine: fetch a
415374 command, update the state, yield with the reply and call the updater
416375 recursively. The update step is guarded against failure. For robustness
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>.
376 one may also guard it against exceptions using <a name="idx:catch3:1981"></a><a class="pred" href="exception.html#catch/3">catch/3</a>.
418377 Note that heap_get/2 passes the <var>Priority</var> and <var>Key</var>
419378 it wishes to delete from the heap such that if the unification fails,
420379 the heap remains unchanged.
453412 engine_post(E, get(Priority, Key), Priority-Key).
454413 </pre>
455414
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
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
457416 many-agent applications</span></a></h3>
458417
459 <a id="sec:engine-agents"></a>
418 <a name="sec:engine-agents"></a>
460419
461420 <p>The final application area we touch are agent systems were we wish to
462421 capture an agent in a Prolog goal. Such systems can be implemented using
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>
422 threads (see <a class="sec" href="threads.html">section 9</a>) that use <a name="idx:threadsendmessage2:1982"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
465423 and
466 <a id="idx:threadgetmessage1:1984"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>
424 <a name="idx:threadgetmessage1:1983"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>
467425 to communicate. The main problem is that each thread is associated by an
468426 operating system thread. OS threads are, depending on the OS, relatively
469427 expensive. Scalability of this design typically ends, depending on OS
472430 <p>Engines provide an alternative. A detached Prolog engine currently
473431 requires approximately 20&nbsp;Kbytes memory on 64&nbsp;bit hardware,
474432 growing with the size of the Prolog stacks. The Prolog stacks may be
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>,
433 minimised by calling <a name="idx:garbagecollect0:1984"></a><a class="pred" href="memory.html#garbage_collect/0">garbage_collect/0</a>
434 followed by <a name="idx:trimstacks0:1985"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>,
477435 providing a
478436 <em>deep sleep</em> mode. The set of agents, each represented by an
479437 engine can be controlled by a static or dynamic pool of threads.
483441 <blockquote> This section needs an example. Preferably something that
484442 fits on one page and would not scale using threads. Engines might work
485443 nice to implement <i>Antrank: An ant colony algorithm for ranking web
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>
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>
487445 </blockquote>
488446
489447 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 10.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="engine-resources.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreign.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:engine-predicates"><a id="sec:10.3"><span class="sec-nr">10.3</span> <span class="sec-title">Engine
194 <h2 id="sec:engine-predicates"><a name="sec:10.3"><span class="sec-nr">10.3</span> <span class="sec-title">Engine
236195 predicate reference</span></a></h2>
237196
238 <a id="sec:engine-predicates"></a>
197 <a name="sec:engine-predicates"></a>
239198
240199 <p>This section documents the built-in predicates that deal with
241200 engines. In addition to these, most predicates dealing with threads and
242201 message queue can be used to access engines.
243202
244203 <dl class="latex">
245 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_create/3"><strong>engine_create</strong>(<var>+Template,
204 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_create/3"><strong>engine_create</strong>(<var>+Template,
246205 :Goal, ?Engine</var>)</a></dt>
247 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_create/4"><strong>engine_create</strong>(<var>+Template,
206 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_create/4"><strong>engine_create</strong>(<var>+Template,
248207 :Goal, -Engine, +Options</var>)</a></dt>
249208 <dd class="defbody">
250209 Create a new engine and unify <var>Engine</var> with a handle to it.
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>
210 <var>Template</var> and <var>Goal</var> form a pair similar to <a name="idx:findall3:1993"></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:1994"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
253212 after <var>Goal</var> succeeds. <var>Options</var> is a list of the
254 following options. See <a id="idx:threadcreate3:1996"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
213 following options. See <a name="idx:threadcreate3:1995"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
255214 for details.
256215
257216 <dl class="latex">
275234 </dd>
276235 </dl>
277236
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>
237 The <var>Engine</var> argument of <a name="idx:enginecreate3:1996"></a><a class="pred" href="engine-predicates.html#engine_create/3">engine_create/3</a>
279238 may be instantiated to an atom, creating an engine with the given alias.</dd>
280 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_destroy/1"><strong>engine_destroy</strong>(<var>+Engine</var>)</a></dt>
239 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_destroy/1"><strong>engine_destroy</strong>(<var>+Engine</var>)</a></dt>
281240 <dd class="defbody">
282241 Destroy <var>Engine</var>.</dd>
283 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="engine_next/2"><strong>engine_next</strong>(<var>+Engine,
242 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="engine_next/2"><strong>engine_next</strong>(<var>+Engine,
284243 -Term</var>)</a></dt>
285244 <dd class="defbody">
286245 Ask the engine <var>Engine</var> to produce a next answer. On this first
287246 call on a specific engine, the <var>Goal</var> of the engine is started.
288247 If a previous call returned an answer through completion, this causes
289248 the engine to backtrack and finally, if the engine produces a previous
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>
249 result using <a name="idx:engineyield1:1997"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>,
250 execution proceeds after the <a name="idx:engineyield1:1998"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
292251 call.</dd>
293 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_next_reified/2"><strong>engine_next_reified</strong>(<var>+Engine,
252 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_next_reified/2"><strong>engine_next_reified</strong>(<var>+Engine,
294253 -Term</var>)</a></dt>
295254 <dd class="defbody">
296 Similar to <a id="idx:enginenext2:2000"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>,
255 Similar to <a name="idx:enginenext2:1999"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>,
297256 but instead of success, failure or or raising an exception, <var>Term</var>
298257 is unified with one of terms below. This predicate is provided primarily
299258 for compatibility with Lean&nbsp;Prolog.
315274 </dl>
316275
317276 </dd>
318 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_post/2"><strong>engine_post</strong>(<var>+Engine,
277 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_post/2"><strong>engine_post</strong>(<var>+Engine,
319278 +Term</var>)</a></dt>
320279 <dd class="defbody">
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,
280 Make <var>Term</var> available to <a name="idx:enginefetch1:2000"></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:2001"></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:2002"></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,
325284 +Term, -Reply</var>)</a></dt>
326285 <dd class="defbody">
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>
286 Combines <a name="idx:enginepost2:2003"></a><a class="pred" href="engine-predicates.html#engine_post/2">engine_post/2</a>
287 and <a name="idx:enginenext2:2004"></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:2005"></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:2006"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>
333292 causes
334 <a id="idx:engineyield1:2008"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
293 <a name="idx:engineyield1:2007"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
335294 to `return'. This predicate can only be called if the engine is not
336295 involved in a callback from C, i.e., when the engine calls a predicate
337296 defined in C that calls back Prolog it is not possible to use this
338297 predicate. Trying to do so results in a
339298 <code>permission_error</code> exception.</dd>
340 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_fetch/1"><strong>engine_fetch</strong>(<var>-Term</var>)</a></dt>
299 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_fetch/1"><strong>engine_fetch</strong>(<var>-Term</var>)</a></dt>
341300 <dd class="defbody">
342301 Called from within the engine to fetch the term made available through
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>.
302 <a name="idx:enginepost2:2008"></a><a class="pred" href="engine-predicates.html#engine_post/2">engine_post/2</a>
303 or <a name="idx:enginepost3:2009"></a><a class="pred" href="engine-predicates.html#engine_post/3">engine_post/3</a>.
345304 If no term is available an existence_error exception is raised.</dd>
346 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="engine_self/1"><strong>engine_self</strong>(<var>-Engine</var>)</a></dt>
305 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="engine_self/1"><strong>engine_self</strong>(<var>-Engine</var>)</a></dt>
347306 <dd class="defbody">
348307 Called from within the engine to get access to the handle to the engine
349308 itself.</dd>
350 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_engine/1"><strong>is_engine</strong>(<var>@Term</var>)</a></dt>
309 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_engine/1"><strong>is_engine</strong>(<var>@Term</var>)</a></dt>
351310 <dd class="defbody">
352311 True if <var>Term</var> is a reference to or the alias name of an
353312 existing engine.</dd>
354 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_engine/1"><strong>current_engine</strong>(<var>-Engine</var>)</a></dt>
313 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_engine/1"><strong>current_engine</strong>(<var>-Engine</var>)</a></dt>
355314 <dd class="defbody">
356315 True when <var>Engine</var> is an existing engine.
357316 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 10.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="engine-examples.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="engine-predicates.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:engine-resources"><a id="sec:10.2"><span class="sec-nr">10.2</span> <span class="sec-title">Engine
194 <h2 id="sec:engine-resources"><a name="sec:10.2"><span class="sec-nr">10.2</span> <span class="sec-title">Engine
236195 resource usage</span></a></h2>
237196
238 <a id="sec:engine-resources"></a>
197 <a name="sec:engine-resources"></a>
239198
240199 <p>A Prolog engine consists of a virtual machine state that includes the
241200 Prolog stacks. An `empty' engine requires aout 20&nbsp;KBytes of memory.
242201 This grows when the engine requires additional stack space. Anonymous
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>.
202 engines are subject to atom garbage collection (see <a name="idx:garbagecollectatoms0:1986"></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:1987"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>.
245204 Calling
246 <a id="idx:enginedestroy1:1989"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
205 <a name="idx:enginedestroy1:1988"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
247206 destroys the virtual machine state, while the handle itself is left to
248207 atom garbage collection. The virtual machine is reclaimed as soon as an
249208 engine produced its last result, failed or raised an exception. This
250209 implies that it is only advantageous to call
251 <a id="idx:enginedestroy1:1990"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
210 <a name="idx:enginedestroy1:1989"></a><a class="pred" href="engine-predicates.html#engine_destroy/1">engine_destroy/1</a>
252211 explicitly if you are not interested in further answers.
253212
254213 <p>Engines that are expected to be left in inactive state for 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>
214 prelonged time can be minimized by calling <a name="idx:garbagecollect0:1990"></a><a class="pred" href="memory.html#garbage_collect/0">garbage_collect/0</a>
215 and <a name="idx:trimmstacks0:1991"></a><span class="pred-ext">trimm_stacks/0</span>
216 (in that order) before calling <a name="idx:engineyield1:1992"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
258217 or succeeding.
259218
260219 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="mt-xpce.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="engine-examples.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:engines"><a id="sec:10"><span class="sec-nr">10</span> <span class="sec-title">Coroutining
194 <h1 id="sec:engines"><a name="sec:10"><span class="sec-nr">10</span> <span class="sec-title">Coroutining
236195 using Prolog engines</span></a></h1>
237196
238 <a id="sec:engines"></a>
197 <a name="sec:engines"></a>
239198
240199 <p>Where the term <em>coroutine</em> in Prolog typically refer to hooks
241 triggered by <em>attributed variables</em> (<a class="sec" href="attvar.html#sec:7.1">section
200 triggered by <em>attributed variables</em> (<a class="sec" href="attvar.html">section
242201 7.1</a>), SWI-Prolog provides two other forms of coroutines. Delimited
243202 continuations (see
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
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
246205 restarting the <em>continuation</em>. This section discusses <em>engines</em>,
247206 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,
248207 2011</a></cite>. The API described in this chapter has been established
249208 together with Paul Tarau and Paulo Moura.
250209
251 <p>Engines are closely related to <em>threads</em> (<a class="sec" href="threads.html#sec:9">section
210 <p>Engines are closely related to <em>threads</em> (<a class="sec" href="threads.html">section
252211 9</a>). An engine is a Prolog virtual machine that has its own stacks
253212 and (virtual) machine state. Unlike normal Prolog threads though, they
254213 are not associated with an operating system thread. Instead, you <em>ask</em>
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>).
214 an engine for a next answer (<a name="idx:enginenext2:1966"></a><a class="pred" href="engine-predicates.html#engine_next/2">engine_next/2</a>).
256215 Asking an engine for the next answer attaches the engine to the calling
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>
216 operating system thread and cause it to run until the engine calls <a name="idx:engineyield1:1967"></a><a class="pred" href="engine-predicates.html#engine_yield/1">engine_yield/1</a>
258217 or its associated goal completes with an answer, failure or an
259218 exception. After the engine yields or completes, it is detached from the
260219 operating system thread and the answer term is made available to the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="debug.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="gensym.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:error"><a id="sec:A.12"><span class="sec-nr">A.12</span> <span class="sec-title">library(error):
194 <h2 id="sec:error"><a name="sec:A.12"><span class="sec-nr">A.12</span> <span class="sec-title">library(error):
236195 Error generating support</span></a></h2>
237196
238 <p><a id="sec:error"></a>
197 <p><a name="sec:error"></a>
239198
240199 <dl class="tags">
241200 <dt class="mtag">author</dt>
260219 to simplify throwing the most common ISO error terms.
261220
262221 <dl class="latex">
263 <dt class="pubdef"><a id="type_error/2"><strong>type_error</strong>(<var>+Type,
222 <dt class="pubdef"><a name="type_error/2"><strong>type_error</strong>(<var>+Type,
264223 +Term</var>)</a></dt>
265224 <dd class="defbody">
266225 Tell the user that <var>Term</var> is not of the expected <var>Type</var>.
277236 compound-term and any other compound term is a domain error. Most Prolog
278237 programmers consider each compound as a type and would consider a
279238 compoint that is not <code>point(_,_)</code> a <i>type_error</i>.</dd>
280 <dt class="pubdef"><a id="domain_error/2"><strong>domain_error</strong>(<var>+Type,
239 <dt class="pubdef"><a name="domain_error/2"><strong>domain_error</strong>(<var>+Type,
281240 +Term</var>)</a></dt>
282241 <dd class="defbody">
283242 The argument is of the proper type, but has a value that is outside the
284243 supported values. See <a class="pred" href="error.html#type_error/2">type_error/2</a>
285244 for a more elaborate discussion of the distinction between type- and
286245 domain-errors.</dd>
287 <dt class="pubdef"><a id="existence_error/2"><strong>existence_error</strong>(<var>+Type,
246 <dt class="pubdef"><a name="existence_error/2"><strong>existence_error</strong>(<var>+Type,
288247 +Term</var>)</a></dt>
289248 <dd class="defbody">
290249 <var>Term</var> is of the correct type and correct domain, but there is
291250 no existing (external) resource that is represented by it.</dd>
292 <dt class="pubdef"><a id="permission_error/3"><strong>permission_error</strong>(<var>+Action,
251 <dt class="pubdef"><a name="existence_error/3"><strong>existence_error</strong>(<var>+Type,
252 +Term, +Set</var>)</a></dt>
253 <dd class="defbody">
254 <var>Term</var> is of the correct type and correct domain, but there is
255 no existing (external) resource that is represented by it in the
256 provided set.
257
258 <dl class="tags">
259 <dt class="tag">Compatibility</dt>
260 <dd>
261 This error is not in ISO.
262 </dd>
263 </dl>
264
265 </dd>
266 <dt class="pubdef"><a name="permission_error/3"><strong>permission_error</strong>(<var>+Action,
293267 +Type, +Term</var>)</a></dt>
294268 <dd class="defbody">
295269 It is not allowed to perform <var>Action</var> on the object <var>Term</var>
296270 that is of the given <var>Type</var>.</dd>
297 <dt class="pubdef"><a id="instantiation_error/1"><strong>instantiation_error</strong>(<var>+Term</var>)</a></dt>
271 <dt class="pubdef"><a name="instantiation_error/1"><strong>instantiation_error</strong>(<var>+Term</var>)</a></dt>
298272 <dd class="defbody">
299273 An argument is under-instantiated. I.e. it is not acceptable as it is,
300274 but if some variables are bound to appropriate values it would be
301275 acceptable.
302276 <table class="arglist">
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>
277 <tr valign="top"><td><var>Term</var> </td><td>is the term that needs
278 (further) instantiation. Unfortunately, the ISO error does not allow for
279 passing this term along with the error, but we pass it to this predicate
280 for documentation purposes and to allow for future enhancement. </td></tr>
307281 </table>
308282 </dd>
309 <dt class="pubdef"><a id="uninstantiation_error/1"><strong>uninstantiation_error</strong>(<var>+Term</var>)</a></dt>
283 <dt class="pubdef"><a name="uninstantiation_error/1"><strong>uninstantiation_error</strong>(<var>+Term</var>)</a></dt>
310284 <dd class="defbody">
311285 An argument is over-instantiated. This error is used for output
312286 arguments whose value cannot be known upfront. For example, the goal <code>open(File, read, input)</code>
313287 cannot succeed because the system will allocate a new unique stream
314288 handle that will never unify with <code>input</code>.</dd>
315 <dt class="pubdef"><a id="representation_error/1"><strong>representation_error</strong>(<var>+Reason</var>)</a></dt>
289 <dt class="pubdef"><a name="representation_error/1"><strong>representation_error</strong>(<var>+Reason</var>)</a></dt>
316290 <dd class="defbody">
317291 A representation error indicates a limitation of the implementation.
318292 SWI-Prolog has no such limits that are not covered by other errors, but
319293 an example of a representation error in another Prolog implementation
320294 could be an attempt to create a term with an arity higher than supported
321295 by the system.</dd>
322 <dt class="pubdef"><a id="syntax_error/1"><strong>syntax_error</strong>(<var>+Culprit</var>)</a></dt>
296 <dt class="pubdef"><a name="syntax_error/1"><strong>syntax_error</strong>(<var>+Culprit</var>)</a></dt>
323297 <dd class="defbody">
324298 A text has invalid syntax. The error is described by <var>Culprit</var>.
325299
333307 </dl>
334308
335309 </dd>
336 <dt class="pubdef"><a id="resource_error/1"><strong>resource_error</strong>(<var>+Culprit</var>)</a></dt>
310 <dt class="pubdef"><a name="resource_error/1"><strong>resource_error</strong>(<var>+Culprit</var>)</a></dt>
337311 <dd class="defbody">
338312 A goal cannot be completed due to lack of resources.</dd>
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="must_be/2"><strong>must_be</strong>(<var>+Type,
313 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="must_be/2"><strong>must_be</strong>(<var>+Type,
340314 @Term</var>)</a></dt>
341315 <dd class="defbody">
342316 True if <var>Term</var> satisfies the type constraints for <var>Type</var>.
350324 <p>Most of these types are defined by an arity-1 built-in predicate of
351325 the same name. Below is a brief definition of the other types.
352326 <blockquote>
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
327 <table border="2" frame="box" rules="groups">
328 <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>
329 <tr valign="top"><td>any</td></tr>
330 <tr valign="top"><td><code>between(FloatL,FloatU)</code> </td><td>Number
357331 [FloatL..FloatU] </td></tr>
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>
332 <tr valign="top"><td><code>between(IntL,IntU)</code> </td><td>Integer
333 [IntL..IntU] </td></tr>
334 <tr valign="top"><td>boolean</td><td>One of <code>true</code> or <code>false</code> </td></tr>
335 <tr valign="top"><td>char</td><td>Atom of length 1 </td></tr>
336 <tr valign="top"><td>chars</td><td>Proper list of 1-character atoms </td></tr>
337 <tr valign="top"><td>code</td><td>Representation Unicode code point </td></tr>
338 <tr valign="top"><td>codes</td><td>Proper list of Unicode character
339 codes </td></tr>
340 <tr valign="top"><td>constant</td><td>Same as <code>atomic</code> </td></tr>
341 <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>
342 <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>
343 <tr valign="top"><td>encoding</td><td>Valid name for a character
344 encoding; see <span class="pred-ext">current_encoding/1</span> </td></tr>
345 <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>
346 <tr valign="top"><td>negative_integer</td><td>Integer <var>&lt;</var> 0 </td></tr>
347 <tr valign="top"><td>nonneg</td><td>Integer <code>&gt;=</code> 0 </td></tr>
348 <tr valign="top"><td><code>oneof(L)</code> </td><td>Ground term that is
349 member of L </td></tr>
350 <tr valign="top"><td>positive_integer</td><td>Integer <var>&gt;</var> 0 </td></tr>
351 <tr valign="top"><td>proper_list</td><td>Same as list </td></tr>
352 <tr valign="top"><td><code>list(Type)</code> </td><td>Proper list with
353 elements of <var>Type</var> </td></tr>
354 <tr valign="top"><td>list_or_partial_list</td><td>A list or an open list
355 (ending in a variable); see <span class="pred-ext">is_list_or_partial_list/1</span> </td></tr>
356 <tr valign="top"><td>stream</td><td>A stream name or valid stream
357 handle; see <a class="pred" href="IO.html#is_stream/1">is_stream/1</a> </td></tr>
358 <tr valign="top"><td>symbol</td><td>Same as <code>atom</code> </td></tr>
359 <tr valign="top"><td>text</td><td>One of <code>atom</code>, <code>string</code>, <code>chars</code>
380360 or <code>codes</code> </td></tr>
381361 </table>
382362 </blockquote>
394374 </dl>
395375
396376 </dd>
397 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_of_type/2"><strong>is_of_type</strong>(<var>+Type,
377 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_of_type/2"><strong>is_of_type</strong>(<var>+Type,
398378 @Term</var>)</a></dt>
399379 <dd class="defbody">
400380 True if <var>Term</var> satisfies <var>Type</var>.</dd>
401 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="has_type/2"><strong>has_type</strong>(<var>+Type,
381 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="has_type/2"><strong>has_type</strong>(<var>+Type,
402382 @Term</var>)</a></dt>
403383 <dd class="defbody">
404384 True if <var>Term</var> satisfies <var>Type</var>.</dd>
405 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_type/3"><strong>current_type</strong>(<var>?Type,
385 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_type/3"><strong>current_type</strong>(<var>?Type,
406386 @Var, -Body</var>)</a></dt>
407387 <dd class="defbody">
408388 True when <var>Type</var> is a currently defined type and <var>Var</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="guidelines.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="threads.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:errors"><a id="sec:8.8"><span class="sec-nr">8.8</span> <span class="sec-title">Compiler
194 <h2 id="sec:errors"><a name="sec:8.8"><span class="sec-nr">8.8</span> <span class="sec-title">Compiler
236195 Errors and Warnings</span></a></h2>
237196
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
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
242201 Compiler Errors</span></a></h3>
243202
244 <a id="sec:chr-errors"></a>
203 <a name="sec:chr-errors"></a>
245204
246205 <dl class="latex">
247206 <dt><b>Type clash</b></dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.16</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="dynamic.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="IO.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:examineprog"><a id="sec:4.16"><span class="sec-nr">4.16</span> <span class="sec-title">Examining
194 <h2 id="sec:examineprog"><a name="sec:4.16"><span class="sec-nr">4.16</span> <span class="sec-title">Examining
236195 the program</span></a></h2>
237196
238 <a id="sec:examineprog"></a>
197 <a name="sec:examineprog"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="current_atom/1"><strong>current_atom</strong>(<var>-Atom</var>)</a></dt>
200 <dt class="pubdef"><a name="current_atom/1"><strong>current_atom</strong>(<var>-Atom</var>)</a></dt>
242201 <dd class="defbody">
243202 Successively unifies <var>Atom</var> with all atoms known to the system.
244 Note that <a id="idx:currentatom1:895"></a><a class="pred" href="examineprog.html#current_atom/1">current_atom/1</a>
203 Note that <a name="idx:currentatom1:897"></a><a class="pred" href="examineprog.html#current_atom/1">current_atom/1</a>
245204 always succeeds if <var>Atom</var> is instantiated to an atom.</dd>
246 <dt class="pubdef"><a id="current_blob/2"><strong>current_blob</strong>(<var>?Blob,
205 <dt class="pubdef"><a name="current_blob/2"><strong>current_blob</strong>(<var>?Blob,
247206 ?Type</var>)</a></dt>
248207 <dd class="defbody">
249208 Examine the type or enumerate blobs of the given <var>Type</var>. Typed
250209 blobs are supported through the foreign language interface for storing
251210 arbitrary BLOBs (Binary Large Object) or handles to external entities.
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,
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,
255214 ?Arity</var>)</a></dt>
256215 <dd class="defbody">
257216 True when <var>Name</var>/<var>Arity</var> is a known functor. This
260219 garbage collection. Due to timing, t/2 below with instantiated
261220 <var>Name</var> and <var>Arity</var> can theoretically fail, i.e., a
262221 functor may be visible in instantiated mode while it is not yet visible
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>
222 in unbound mode. Considering that the only practical value of <a name="idx:currentfunctor2:898"></a><a class="pred" href="examineprog.html#current_functor/2">current_functor/2</a>
264223 we are aware of is to analyse resource usage we accept this impure
265224 behaviour.
266225
273232 </pre>
274233
275234 </dd>
276 <dt class="pubdef"><a id="current_flag/1"><strong>current_flag</strong>(<var>-FlagKey</var>)</a></dt>
235 <dt class="pubdef"><a name="current_flag/1"><strong>current_flag</strong>(<var>-FlagKey</var>)</a></dt>
277236 <dd class="defbody">
278237 Successively unifies <var>FlagKey</var> with all keys used for flags
279238 (see
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>
239 <a name="idx:flag3:899"></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>
282241 <dd class="defbody">
283242 Successively unifies <var>Key</var> with all keys used for records (see
284 <a id="idx:recorda3:898"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
243 <a name="idx:recorda3:900"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>,
285244 etc.).</dd>
286 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_predicate/1"><strong>current_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
245 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_predicate/1"><strong>current_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
287246 <dd class="defbody">
288247 True if <var>PredicateIndicator</var> is a currently defined predicate.
289248 A predicate is considered defined if it exists in the specified module,
290249 is imported into the module or is defined in one of the modules from
291250 which the predicate will be imported if it is called (see
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>
251 <a class="sec" href="importmodule.html">section 6.9</a>). Note that <a name="idx:currentpredicate1:901"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>
294252 does <em>not</em> succeed for predicates that can be <em>autoloaded</em>.
295253 See also
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>.
254 <a name="idx:currentpredicate2:902"></a><a class="pred" href="examineprog.html#current_predicate/2">current_predicate/2</a>
255 and <a name="idx:predicateproperty2:903"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
298256
299257 <p>If <var>PredicateIndicator</var> is not fully specified, the
300258 predicate only generates values that are defined in or already imported
301259 into the target module. Generating all callable predicates therefore
302 requires enumerating modules using <a id="idx:currentmodule1:902"></a><a class="pred" href="manipmodule.html#current_module/1">current_module/1</a>.
260 requires enumerating modules using <a name="idx:currentmodule1:904"></a><a class="pred" href="manipmodule.html#current_module/1">current_module/1</a>.
303261 Generating predicates callable in a given module requires enumerating
304 the import modules using <a id="idx:importmodule2:903"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>
262 the import modules using <a name="idx:importmodule2:905"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>
305263 and the autoloadable predicates using the
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,
264 <a name="idx:predicateproperty2:906"></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,
308266 :Head</var>)</a></dt>
309267 <dd class="defbody">
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>,
268 Classical pre-ISO implementation of <a name="idx:currentpredicate1:907"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>,
311269 where the predicate is represented by the head term. The advantage is
312270 that this can be used for checking the existence of a predicate before
313 calling it without the need for <a id="idx:functor3:906"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>:
271 calling it without the need for <a name="idx:functor3:908"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>:
314272
315273 <pre class="code">
316274 call_if_exists(G) :-
318276 call(G).
319277 </pre>
320278
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>
279 <p>Because of this intended usage, <a name="idx:currentpredicate2:909"></a><a class="pred" href="examineprog.html#current_predicate/2">current_predicate/2</a>
322280 also succeeds if the predicate can be autoloaded. Unfortunately,
323281 checking the autoloader makes this predicate relatively slow, in
324282 particular because a failed lookup of the autoloader will cause the
325283 autoloader to verify that its index is up-to-date.</dd>
326 <dt class="pubdef"><a id="predicate_property/2"><strong>predicate_property</strong>(<var>:Head,
284 <dt class="pubdef"><a name="predicate_property/2"><strong>predicate_property</strong>(<var>:Head,
327285 ?Property</var>)</a></dt>
328286 <dd class="defbody">
329287 True when <var>Head</var> refers to a predicate that has property
330288 <var>Property</var>. With sufficiently instantiated <var>Head</var>,
331 <a id="idx:predicateproperty2:908"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
289 <a name="idx:predicateproperty2:910"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
332290 tries to resolve the predicate the same way as calling it would do: if
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>)
291 the predicate is not defined it scans the default modules (see <a name="idx:defaultmodule2:911"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
334292 and finally tries the autoloader. Unlike calling, failure to find the
335293 target predicate causes
336 <a id="idx:predicateproperty2:910"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
294 <a name="idx:predicateproperty2:912"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
337295 to fail silently. If <var>Head</var> is not sufficiently bound, only
338296 currently locally defined and already imported predicates are
339 enumerated. See <a id="idx:currentpredicate1:911"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>
297 enumerated. See <a name="idx:currentpredicate1:913"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>
340298 for enumerating all predicates. A common issue concerns <em>generating</em>
341299 all built-in predicates. This can be achieved using the code below:
342300
364322 True if the predicate is defined. This property is aware of sources
365323 being <em>reloaded</em>, in which case it claims the predicate defined
366324 only if it is defined in another source or it has seen a definition in
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>
325 the current source. See <a name="idx:compileauxclauses1:914"></a><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a>.</dd>
368326 <dt><strong>dynamic</strong></dt>
369327 <dd class="defbody">
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>
328 True if <a name="idx:assert1:915"></a><a class="pred" href="db.html#assert/1">assert/1</a>
329 and <a name="idx:retract1:916"></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:917"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.</dd>
373331 <dt><strong>exported</strong></dt>
374332 <dd class="defbody">
375333 True if the predicate is in the public list of the context module.</dd>
379337 <dt><strong>file</strong>(<var>FileName</var>)</dt>
380338 <dd class="defbody">
381339 Unify <var>FileName</var> with the name of the source file in which the
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>
340 predicate is defined. See also <a name="idx:sourcefile2:918"></a><a class="pred" href="consulting.html#source_file/2">source_file/2</a>
383341 and the property
384342 <code>line_count</code>. Note that this reports the file of the first
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>
343 clause of a predicate. A more robust interface can be achieved using <a name="idx:nthclause3:919"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
344 and <a name="idx:clauseproperty2:920"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
387345 <dt><strong>foreign</strong></dt>
388346 <dd class="defbody">
389347 True if the predicate is defined in the C language.</dd>
394352 mechanism as when the an undefined predicate is encountered, but does
395353 not perform any loading. It searches (1) the module inheritence
396354 hierarchy (see
397 <a id="idx:defaultmodule2:919"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
355 <a name="idx:defaultmodule2:921"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
398356 and (2) the autoload index if the <a class="flag" href="flags.html#flag:unknown">unknown</a>
399357 flag is not set to <code>fail</code> in the target module.</dd>
400358 <dt><strong>indexed</strong>(<var>Indexes</var>)</dt>
401359 <dd class="defbody">
402 <var>Indexes</var><sup class="fn">81<span class="fn-text">This predicate
360 <var>Indexes</var><sup class="fn">80<span class="fn-text">This predicate
403361 property should be used for analysis and statistics only. The exact
404362 representation of <var>Indexes</var> may change between versions.</span></sup>
405363 is a list of additional (hash) indexes on the predicate. Each element of
423381 <dd class="defbody">
424382 Unify <var>LineNumber</var> with the line number of the first clause of
425383 the predicate. Fails if the predicate is not associated with a file. See
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>
384 also <a name="idx:sourcefile2:922"></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:923"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
428386 <dt><strong>multifile</strong></dt>
429387 <dd class="defbody">
430388 True if there may be multiple (or no) files providing clauses for the
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>
389 predicate. This property is set using <a name="idx:multifile1:924"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>.</dd>
432390 <dt><strong>meta_predicate</strong>(<var>Head</var>)</dt>
433391 <dd class="defbody">
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>,
392 If the predicate is declared as a meta-predicate using <a name="idx:metapredicate1:925"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>,
435393 unify <var>Head</var> with the head-pattern. The head-pattern is a
436394 compound term with the same name and arity as the predicate where each
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>
395 argument of the term is a meta-predicate specifier. See <a name="idx:metapredicate1:926"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
438396 for details.</dd>
439397 <dt><strong>nodebug</strong></dt>
440398 <dd class="defbody">
461419 time. Intended to quickly assesses the validity of caches.</dd>
462420 <dt><strong>public</strong></dt>
463421 <dd class="defbody">
464 Predicate is declared public using <a id="idx:public1:925"></a><a class="pred" href="dynamic.html#public/1">public/1</a>.
422 Predicate is declared public using <a name="idx:public1:927"></a><a class="pred" href="dynamic.html#public/1">public/1</a>.
465423 Note that without further definition, public predicates are considered
466424 undefined and this property is <em>not</em> reported.</dd>
467425 <dt><strong>quasi_quotation_syntax</strong></dt>
468426 <dd class="defbody">
469427 The predicate (with arity&nbsp;4) is declared to provide quasi quotation
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>
428 syntax with <a name="idx:quasiquotationsyntax1:928"></a><a class="pred" href="quasiquotations.html#quasi_quotation_syntax/1">quasi_quotation_syntax/1</a>.</dd>
471429 <dt><strong>static</strong></dt>
472430 <dd class="defbody">
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>
431 The definition can <em>not</em> be modified using <a name="idx:assertz1:929"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
474432 and friends. This property is the opposite from <code>dynamic</code>,
475433 i.e., for each defined predicate, either <code>static</code> or <code>dynamic</code>
476434 is true but never both.</dd>
478436 <dd class="defbody">
479437 If true (only possible on the multithreaded version) each thread has its
480438 own clauses for the predicate. This property is set using
481 <a id="idx:threadlocal1:928"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
439 <a name="idx:threadlocal1:930"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>.</dd>
482440 <dt><strong>transparent</strong></dt>
483441 <dd class="defbody">
484442 True if the predicate is declared transparent using the
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>
443 <a name="idx:moduletransparent1:931"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
444 or <a name="idx:metapredicate1:932"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
487445 declaration. In the latter case the property <code>meta_predicate(Head)</code>
488 is also provided. See <a class="sec" href="modules.html#sec:6">chapter 6</a>
446 is also provided. See <a class="sec" href="modules.html">chapter 6</a>
489447 for details.</dd>
490448 <dt><strong>undefined</strong></dt>
491449 <dd class="defbody">
495453 attempt to call it has been made via one of the meta-call predicates,
496454 the predicate has been declared as e.g., a meta-predicate or the
497455 predicate had a definition in the past. Originally used to find missing
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>
456 predicate definitions. The current implementation of <a name="idx:listundefined0:933"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>
499457 used cross-referencing. Deprecated.</dd>
500458 <dt><strong>visible</strong></dt>
501459 <dd class="defbody">
502460 True when predicate can be called without raising a predicate existence
503461 error. This means that the predicate is (1) defined, (2) can be
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>)
462 inherited from one of the default modules (see <a name="idx:defaultmodule2:934"></a><a class="pred" href="importmodule.html#default_module/2">default_module/2</a>)
505463 or (3) can be autoloaded. The behaviour is logically consistent iff the
506464 property
507465 <code>visible</code> is provided explicitly. If the property is left
508466 unbound, only defined predicates are enumerated.</dd>
509467 <dt><strong>volatile</strong></dt>
510468 <dd class="defbody">
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>.
469 If true, the clauses are not saved into a saved state by <a name="idx:qsaveprogram12:935"></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:936"></a><a class="pred" href="runtime.html#volatile/1">volatile/1</a>.
513471 </dd>
514472 </dl>
515473
516474 </dd>
517 <dt class="pubdef"><a id="dwim_predicate/2"><strong>dwim_predicate</strong>(<var>+Term,
475 <dt class="pubdef"><a name="dwim_predicate/2"><strong>dwim_predicate</strong>(<var>+Term,
518476 -Dwim</var>)</a></dt>
519477 <dd class="defbody">
520478 `Do What I Mean' (`dwim') support predicate. <var>Term</var> is a term,
522480 is instantiated with the most general term built from <var>Name</var>
523481 and the arity of a defined predicate that matches the predicate
524482 specified by
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>
483 <var>Term</var> in the `Do What I Mean' sense. See <a name="idx:dwimmatch2:937"></a><a class="pred" href="miscpreds.html#dwim_match/2">dwim_match/2</a>
526484 for `Do What I Mean' string matching. Internal system predicates are not
527485 generated, unless the access level is <code>system</code> (see
528486 <a class="flag" href="flags.html#flag:access_level">access_level</a>).
529487 Backtracking provides all alternative matches.</dd>
530 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="clause/2"><strong>clause</strong>(<var>:Head,
488 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="clause/2"><strong>clause</strong>(<var>:Head,
531489 ?Body</var>)</a></dt>
532490 <dd class="defbody">
533491 True if <var>Head</var> can be unified with a clause head and <var>Body</var>
534492 with the corresponding clause body. Gives alternative clauses on
535493 backtracking. For facts, <var>Body</var> is unified with the atom <var>true</var>.</dd>
536 <dt class="pubdef"><a id="clause/3"><strong>clause</strong>(<var>:Head,
494 <dt class="pubdef"><a name="clause/3"><strong>clause</strong>(<var>:Head,
537495 ?Body, ?Reference</var>)</a></dt>
538496 <dd class="defbody">
539 Equivalent to <a id="idx:clause2:936"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>,
497 Equivalent to <a name="idx:clause2:938"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>,
540498 but unifies <var>Reference</var> with a unique reference to the clause
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>).
499 (see also <a name="idx:assert2:939"></a><a class="pred" href="db.html#assert/2">assert/2</a>, <a name="idx:erase1:940"></a><a class="pred" href="db.html#erase/1">erase/1</a>).
542500 If <var>Reference</var> is instantiated to a reference the clause's head
543501 and body will be unified with <var>Head</var> and <var>Body</var>.</dd>
544 <dt class="pubdef"><a id="nth_clause/3"><strong>nth_clause</strong>(<var>?Pred,
502 <dt class="pubdef"><a name="nth_clause/3"><strong>nth_clause</strong>(<var>?Pred,
545503 ?Index, ?Reference</var>)</a></dt>
546504 <dd class="defbody">
547505 Provides access to the clauses of a predicate using their index number.
552510 is provided, <var>Reference</var> will be unified with the clause
553511 reference. If <var>Index</var> is unbound, backtracking will yield both
554512 the indexes and the references of all clauses of the predicate. The
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>:
513 following example finds the 2nd clause of <a name="idx:append3:941"></a><a class="pred" href="lists.html#append/3">append/3</a>:
556514
557515 <pre class="code">
558516 ?- use_module(library(lists)).
564522 </pre>
565523
566524 </dd>
567 <dt class="pubdef"><a id="clause_property/2"><strong>clause_property</strong>(<var>+ClauseRef,
525 <dt class="pubdef"><a name="clause_property/2"><strong>clause_property</strong>(<var>+ClauseRef,
568526 -Property</var>)</a></dt>
569527 <dd class="defbody">
570528 Queries properties of a clause. <var>ClauseRef</var> is a reference to 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>
529 clause as produced by <a name="idx:clause3:942"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>, <a name="idx:nthclause3:943"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
572530 or
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>
531 <a name="idx:prologframeattribute3:944"></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:945"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>
575533 may be used to get information about erased clauses that have not yet
576534 been reclaimed. <var>Property</var> is one of the following:
577535
580538 <dd class="defbody">
581539 Unify <var>FileName</var> with the name of the file from which the
582540 clause is loaded. Fails if the clause was not created by loading a file
583 (e.g., clauses added using <a id="idx:assertz1:944"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>).
541 (e.g., clauses added using <a name="idx:assertz1:946"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>).
584542 See also <code>source</code>.
585543 </dd>
586544 <dt><strong>line_count</strong>(<var>LineNumber</var>)</dt>
601559 the clause. This is the same as the <code>file</code> property, unless
602560 the file is loaded from a file that is textually included into source
603561 using
604 <a id="idx:include1:945"></a><a class="pred" href="consulting.html#include/1">include/1</a>.
562 <a name="idx:include1:947"></a><a class="pred" href="consulting.html#include/1">include/1</a>.
605563 In this scenario, <code>file</code> is the included file, while the <code>source</code>
606564 property refers to the <em>main</em> file.
607565 </dd>
618576 <dd class="defbody">
619577 <var>PredicateIndicator</var> denotes the predicate to which this clause
620578 belongs. This is needed to obtain information on erased clauses because
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>
579 the usual way to obtain this information using <a name="idx:clause3:948"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>
622580 fails for erased clauses.
623581 </dd>
624582 <dt><strong>module</strong>(<var>Module</var>)</dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="debugging.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="sicstus-chr.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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
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
238197 written in CHR.
239198
240199 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="breakpoint.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="exception3.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:excepthook"><a id="sec:B.5"><span class="sec-nr">B.5</span> <span class="sec-title">Adding
194 <h2 id="sec:excepthook"><a name="sec:B.5"><span class="sec-nr">B.5</span> <span class="sec-title">Adding
236195 context to errors: prolog_exception_hook</span></a></h2>
237196
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>
197 <a name="sec:excepthook"></a>
198
199 <p>The hook <a name="idx:prologexceptionhook4:2207"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
241200 has been introduced in SWI-Prolog 5.6.5 to provide dedicated exception
242201 handling facilities for application frameworks, for example
243202 non-interactive server applications that wish to provide extensive
244203 context for exceptions for offline debugging.
245204
246205 <dl class="latex">
247 <dt class="pubdef"><a id="prolog_exception_hook/4"><strong>prolog_exception_hook</strong>(<var>+ExceptionIn,
206 <dt class="pubdef"><a name="prolog_exception_hook/4"><strong>prolog_exception_hook</strong>(<var>+ExceptionIn,
248207 -ExceptionOut, +Frame, +CatcherFrame</var>)</a></dt>
249208 <dd class="defbody">
250209 This hook predicate, if defined in the module <code>user</code>, is
251210 between raising an exception and handling it. It is intended to allow a
252211 program adding additional context to an exception to simplify diagnosing
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>
212 the problem. <var>ExceptionIn</var> is the exception term as raised by <a name="idx:throw1:2208"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
254213 or one of the built-in predicates. The output argument <var>ExceptionOut</var>
255214 describes the exception that is actually raised. <var>Frame</var> is the
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>
215 innermost frame. See <a name="idx:prologframeattribute3:2209"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>
257216 and the library
258217 <code>library(prolog_stack)</code> for getting information from this.
259218 <var>CatcherFrame</var> is a reference to the frame calling the matching
260 <a id="idx:catch3:2211"></a><a class="pred" href="exception.html#catch/3">catch/3</a>, <code>none</code>
219 <a name="idx:catch3:2210"></a><a class="pred" href="exception.html#catch/3">catch/3</a>, <code>none</code>
261220 if the exception is not caught or <code>'C'</code> if the exception is
262221 caught in C calling Prolog using the flag
263222 <code>PL_Q_CATCH_EXCEPTION</code>.
268227 recursively. The hook is <em>not</em> allowed to modify <var>ExceptionOut</var>
269228 in such a way that it no longer unifies with the catching frame.
270229
271 <p>Typically, <a id="idx:prologexceptionhook4:2212"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
230 <p>Typically, <a name="idx:prologexceptionhook4:2211"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
272231 is used to fill the second argument of <code>error(Formal, Context)</code>
273232 exceptions. <var>Formal</var> is defined by the ISO standard, while
274233 SWI-Prolog defines <var>Context</var> as a term <code>context(Location,
280239 a quick test of the environment before starting expensive gathering
281240 information on the state of the program.
282241
283 <p>The hook can call <a id="idx:trace0:2213"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
242 <p>The hook can call <a name="idx:trace0:2212"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
284243 to enter trace mode immediately. For example, imagine an application
285244 performing an unwanted division by zero while all other errors are
286245 expected and handled. We can force the debugger using the hook
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>)
246 definition below. Run the program in debug mode (see <a name="idx:debug0:2213"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>)
288247 to preserve as much as possible of the error context.
289248
290249 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="delcont.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="signal.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:exception"><a id="sec:4.11"><span class="sec-nr">4.11</span> <span class="sec-title">Exception
194 <h2 id="sec:exception"><a name="sec:4.11"><span class="sec-nr">4.11</span> <span class="sec-title">Exception
236195 handling</span></a></h2>
237196
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>
197 <a name="sec:exception"></a>
198
199 <p>The predicates <a name="idx:catch3:693"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
200 and <a name="idx:throw1:694"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
242201 provide ISO compliant raising and catching of exceptions.
243202
244203 <dl class="latex">
245 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="catch/3"><strong>catch</strong>(<var>:Goal,
204 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="catch/3"><strong>catch</strong>(<var>:Goal,
246205 +Catcher, :Recover</var>)</a></dt>
247206 <dd class="defbody">
248 Behaves as <a id="idx:call1:693"></a><a class="pred" href="metacall.html#call/1">call/1</a>
207 Behaves as <a name="idx:call1:695"></a><a class="pred" href="metacall.html#call/1">call/1</a>
249208 if no exception is raised when executing <var>Goal</var>. If an
250 exception is raised using <a id="idx:throw1:694"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
209 exception is raised using <a name="idx:throw1:696"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
251210 while <var>Goal</var> executes, and the <var>Goal</var> is the innermost
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>,
211 goal for which <var>Catcher</var> unifies with the argument of <a name="idx:throw1:697"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
253212 all choice points generated by <var>Goal</var> are cut, the system
254 backtracks to the start of <a id="idx:catch3:696"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
213 backtracks to the start of <a name="idx:catch3:698"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
255214 while preserving the thrown exception term, and <var>Recover</var> is
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>
215 called as in <a name="idx:call1:699"></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:700"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
259218 is comparable to
260 <a id="idx:call1:699"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
219 <a name="idx:call1:701"></a><a class="pred" href="metacall.html#call/1">call/1</a>.
261220 Recovery from an exception is much slower, especially if the exception
262221 term is large due to the copying thereof or is decorated with a stack
263222 trace using, e.g., the library <code>library(prolog_stack)</code> based
264223 on the
265 <a id="idx:prologexceptionhook4:700"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
224 <a name="idx:prologexceptionhook4:702"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
266225 hook predicate to rewrite exceptions.</dd>
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>
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:703"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
270229 ancestor for which <var>Exception</var> unifies with the <var>Catcher</var>
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>
230 argument of the <a name="idx:catch3:704"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
231 call. See <a name="idx:catch3:705"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
273232 for details.
274233
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>
234 <p>ISO demands that <a name="idx:throw1:706"></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:707"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
277236 call, backtrack and try to unify the copy of
278237 <var>Exception</var> with <var>Catcher</var>. SWI-Prolog delays
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>
238 backtracking until it actually finds a matching <a name="idx:catch3:708"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
280239 goal. The advantage is that we can start the debugger at the first
281240 possible location while preserving the entire exception context if there
282 is no matching <a id="idx:catch3:707"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
241 is no matching <a name="idx:catch3:709"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
283242 goal. This approach can lead to different behaviour if <var>Goal</var>
284 and <var>Catcher</var> of <a id="idx:catch3:708"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
243 and <var>Catcher</var> of <a name="idx:catch3:710"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
285244 call shared variables. We assume this to be highly unlikely and could
286 not think of a scenario where this is useful.<sup class="fn">69<span class="fn-text">I'd
245 not think of a scenario where this is useful.<sup class="fn">68<span class="fn-text">I'd
287246 like to acknowledge Bart Demoen for his clarifications on these matters.</span></sup>
288247
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>,
248 <p>In addition to explicit calls to <a name="idx:throw1:711"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
290249 many built-in predicates throw exceptions directly from C. If the <var>Exception</var>
291250 term cannot be copied due to lack of stack space, the following actions
292251 are tried in order:
297256 ImplementationDefined)</code>, try to raise the exception without the <var>ImplementationDefined</var>
298257 part.
299258 <li>Try to raise <code>error(<code>resource_error(stack)</code>, global)</code>.
300 <li>Abort (see <a id="idx:abort0:710"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
259 <li>Abort (see <a name="idx:abort0:712"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
301260 </ol>
302261
303 <p>If an exception is raised in a call-back from C (see <a class="sec" href="foreign.html#sec:11">chapter
262 <p>If an exception is raised in a call-back from C (see <a class="sec" href="foreign.html">chapter
304263 11</a>) and not caught in the same call-back, <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>
305264 fails and the exception context can be retrieved using <a class="func" href="foreigninclude.html#PL_exception()">PL_exception()</a>.
306265 </dd>
307266 </dl>
308267
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
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
310269 of exceptions</span></a></h3>
311270
312 <a id="sec:urgentexceptions"></a>
271 <a name="sec:urgentexceptions"></a>
313272
314273 <p>Under some conditions an exception may be raised as a result of
315274 handling another exception. Below are some of the scenarios:
316275
317276 <p>
318277 <ul class="latex">
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>
278 <li>The predicate <a name="idx:setupcallcleanup3:713"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
320279 calls the cleanup handler as a result of an exception and the cleanup
321280 handler raises an exception itself. In this case the most <em>urgent</em>
322281 exception is propagated into the environment.
324283 stack space to store the exception. In this case a resource exception is
325284 raised. If that too fails the system tries to raise a resource exception
326285 without (stack) context. If that fails it will raise the exception
327 <code>'$aborted'</code>, also raised by <a id="idx:abort0:712"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
286 <code>'$aborted'</code>, also raised by <a name="idx:abort0:714"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
328287 As no stack space is required for processing this atomic exception, this
329288 should always succeed.
330289 <li>Certain <em>callback</em> operations raise an exception while
331290 processing another exception or a previous callback already raised an
332291 exception before there was an opportunity to process the exception. The
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>
292 most notable <em>callback</em> subject to this issue are <a name="idx:prologeventhook1:715"></a><span class="pred-ext">prolog_event_hook/1</span>
293 (supporting e.g., the graphical debugger), <a name="idx:prologexceptionhook4:716"></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:717"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
336295 when called from the core facilities such as the internal debugger. As
337296 with
338 <a id="idx:setupcallcleanup3:716"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>,
297 <a name="idx:setupcallcleanup3:718"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>,
339298 the most <em>urgent</em> exception is preserved.
340299 </ul>
341300
344303
345304 <p>
346305 <ol class="latex">
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>)
306 <li><code>'$aborted'</code> (<a name="idx:abort0:719"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>)
307 <li><code>time_limit_exceeded</code> (<a name="idx:callwithtimelimit2:720"></a><span class="pred-ext">call_with_time_limit/2</span>)
349308 <li><code>error(<code>resource_error(Resource)</code>, Context)</code>
350309 <li><code>error(Formal, Context)</code>
351310 <li>All other exceptions
353312
354313 <p><b>Note</b> The above resolution is not described in the ISO
355314 standard. This is not needed either because ISO does not specify
356 <a id="idx:setupcallcleanup3:719"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
315 <a name="idx:setupcallcleanup3:721"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
357316 and does not deal with environment management issues such as (debugger)
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>
317 callbacks. Neither does it define <a name="idx:abort0:722"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
318 or timeout handling. Notably <a name="idx:abort0:723"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
360319 and timeout are non-logical control structures. They are implemented on
361320 top of exceptions as they need to unwind the stack, destroy choice
362321 points and call cleanup handlers in the same way. However, the pending
363322 exception should not be replaced by another one before the intended
364323 handler is reached. The abort exception cannot be caught, something
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>
324 which is achieved by wrapping the <em>cleanup handler</em> of <a name="idx:catch3:724"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
366325 into
367326 <code>call_cleanup(Handler, abort)</code>.
368327
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
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
370329 and exceptions</span></a></h3>
371330
372 <a id="sec:debugexceptions"></a>
373
374 <p><a id="idx:exceptionsdebugging:723"></a><a id="idx:debuggingexceptions:724"></a>Before
331 <a name="sec:debugexceptions"></a>
332
333 <p><a name="idx:exceptionsdebugging:725"></a><a name="idx:debuggingexceptions:726"></a>Before
375334 the introduction of exceptions in SWI-Prolog a runtime error was handled
376335 by printing an error message, after which the predicate failed. If the
377336 Prolog flag <a class="flag" href="flags.html#flag:debug_on_error">debug_on_error</a>
380339 locate the error.
381340
382341 <p>With exception handling, things are different. A programmer may wish
383 to trap an exception using <a id="idx:catch3:725"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
342 to trap an exception using <a name="idx:catch3:727"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
384343 to avoid it reaching the user. If the exception is not handled by user
385344 code, the interactive top level will trap it to prevent termination.
386345
387346 <p>If we do not take special precautions, the context information
388347 associated with an unexpected exception (i.e., a programming error) is
389348 lost. Therefore, if an exception is raised which is not caught using
390 <a id="idx:catch3:726"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
349 <a name="idx:catch3:728"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
391350 and the top level is running, the error will be printed, and the system
392351 will enter trace mode.
393352
394353 <p>If the system is in a non-interactive call-back from foreign code and
395 there is no <a id="idx:catch3:727"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
354 there is no <a name="idx:catch3:729"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
396355 active in the current context, it cannot determine whether or not the
397356 exception will be caught by the external routine calling Prolog. It will
398357 then base its behaviour on the Prolog flag
410369 </ul>
411370
412371 <p>While looking for the context in which an exception takes place, it
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>.
372 is advised to switch on debug mode using the predicate <a name="idx:debug0:730"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.
414373 The hook
415 <a id="idx:prologexceptionhook4:729"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
374 <a name="idx:prologexceptionhook4:731"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>
416375 can be used to add more debugging facilities to exceptions. An example
417376 is the library <code>library(http/http_error)</code>, generating a full
418377 stack trace on errors in the HTTP server library.
419378
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
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
421380 exception term</span></a></h3>
422381
423 <a id="sec:exceptterm"></a>
382 <a name="sec:exceptterm"></a>
424383
425384 <p>Built-in predicates generate exceptions using a term
426385 <code>error(Formal, Context)</code>. The first argument is the `formal'
434393 description of the error. Any part of this structure may be a variable
435394 if no information was present.
436395
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
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
438397 messages</span></a></h3>
439398
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>
399 <a name="sec:printmsg"></a>
400
401 <p>The predicate <a name="idx:printmessage2:732"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
443402 is used to print a message term in a human-readable format. The other
444403 predicates from this section allow the user to refine and extend the
445404 message system. A common usage of
446 <a id="idx:printmessage2:731"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
405 <a name="idx:printmessage2:733"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
447406 is to print error messages from exceptions. The code below prints errors
448407 encountered during the execution of <var>Goal</var>, without further
449408 propagating the exception and without starting the debugger.
457416 ...
458417 </pre>
459418
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>
419 <p>Another common use is to define <a name="idx:messagehook3:734"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
461420 for printing messages that are normally <em>silent</em>, suppressing
462421 messages, redirecting messages or make something happen in addition to
463422 printing the message.
464423
465424 <dl class="latex">
466 <dt class="pubdef"><a id="print_message/2"><strong>print_message</strong>(<var>+Kind,
425 <dt class="pubdef"><a name="print_message/2"><strong>print_message</strong>(<var>+Kind,
467426 +Term</var>)</a></dt>
468427 <dd class="defbody">
469 The predicate <a id="idx:printmessage2:733"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
428 The predicate <a name="idx:printmessage2:735"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
470429 is used by the system and libraries to print messages. <var>Kind</var>
471430 describes the nature of the message, while
472431 <var>Term</var> is a Prolog term that describes the content. Printing
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>
432 messages through this indirection instead of using <a name="idx:format3:736"></a><a class="pred" href="format.html#format/3">format/3</a>
474433 to the stream <code>user_error</code> allows displaying the message
475434 appropriate to the application (terminal, logfile, graphics), acting on
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>)
435 messages based on their content instead of a string (see <a name="idx:messagehook3:737"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>)
477436 and creating language specific versions of the messages. See also
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:
437 <a class="sec" href="exception.html">section 4.11.4.1</a>. The following
438 message kinds are known:
480439
481440 <dl class="latex">
482441 <dt><strong>banner</strong></dt>
486445 to <code>silent</code>.</dd>
487446 <dt><strong>debug</strong>(<var>Topic</var>)</dt>
488447 <dd class="defbody">
489 Message from library(debug). See <a id="idx:debug3:736"></a><a class="pred" href="debug.html#debug/3">debug/3</a>.</dd>
448 Message from library(debug). See <a name="idx:debug3:738"></a><a class="pred" href="debug.html#debug/3">debug/3</a>.</dd>
490449 <dt><strong>error</strong></dt>
491450 <dd class="defbody">
492451 The message indicates an erroneous situation. This kind is used to print
493452 uncaught exceptions of type <code>error(Formal, Context)</code>. See
494 section introduction (<a class="sec" href="exception.html#sec:4.11.4">section
453 section introduction (<a class="sec" href="exception.html">section
495454 4.11.4</a>).</dd>
496455 <dt><strong>help</strong></dt>
497456 <dd class="defbody">
499458 prompt.</dd>
500459 <dt><strong>information</strong></dt>
501460 <dd class="defbody">
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>
461 Information that is requested by the user. An example is <a name="idx:statistics0:739"></a><a class="pred" href="statistics.html#statistics/0">statistics/0</a>.</dd>
503462 <dt><strong>informational</strong></dt>
504463 <dd class="defbody">
505464 Typically messages of events are progres that are considered useful to a
508467 <dt><strong>silent</strong></dt>
509468 <dd class="defbody">
510469 Message that is normally not printed. Applications may define
511 <a id="idx:messagehook3:738"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
470 <a name="idx:messagehook3:740"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
512471 to act upon such messages.</dd>
513472 <dt><strong>trace</strong></dt>
514473 <dd class="defbody">
516475 <dt><strong>warning</strong></dt>
517476 <dd class="defbody">
518477 The message indicates something dubious that is not considered fatal.
519 For example, discontiguous predicates (see <a id="idx:discontiguous1:739"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>).
478 For example, discontiguous predicates (see <a name="idx:discontiguous1:741"></a><a class="pred" href="dynamic.html#discontiguous/1">discontiguous/1</a>).
520479 </dd>
521480 </dl>
522481
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>
482 <p>The predicate <a name="idx:printmessage2:742"></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:743"></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:744"></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:745"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
527486 fails it prints the message unless <var>Kind</var> is silent.
528487
529 <p>The <a id="idx:printmessage2:744"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
488 <p>The <a name="idx:printmessage2:746"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
530489 predicate and its rules are in the file
531490 <code>&lt;<var>plhome</var>&gt;/boot/messages.pl</code>, which may be
532491 inspected for more information on the error messages and related error
535494 existing message term is applicable, invent a fairly unique term that
536495 represents the event and define a rule for the multifile predicate
537496 prolog:message//1. See
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,
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:747"></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,
543502 +Prefix, +Lines</var>)</a></dt>
544503 <dd class="defbody">
545 Print a message (see <a id="idx:printmessage2:746"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>)
504 Print a message (see <a name="idx:printmessage2:748"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>)
546505 that has been translated to a list of message elements. The elements of
547506 this list are:
548507
550509 <dt><strong>&lt;<var>Format</var>&gt;-&lt;<var>Args</var>&gt;</strong></dt>
551510 <dd class="defbody">
552511 Where <var>Format</var> is an atom and <var>Args</var> is a list of
553 format arguments. Handed to <a id="idx:format3:747"></a><a class="pred" href="format.html#format/3">format/3</a>.
512 format arguments. Handed to <a name="idx:format3:749"></a><a class="pred" href="format.html#format/3">format/3</a>.
554513 </dd>
555514 <dt><strong>flush</strong></dt>
556515 <dd class="defbody">
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>)
516 If this appears as the last element, <var>Stream</var> is flushed (see <a name="idx:flushoutput1:750"></a><a class="pred" href="chario.html#flush_output/1">flush_output/1</a>)
558517 and no final newline is generated. This is combined with a subsequent
559518 message that starts with
560519 <code>at_same_line</code> to complete the line.
562521 <dt><strong>at_same_line</strong></dt>
563522 <dd class="defbody">
564523 If this appears as first element, no prefix is printed for the first
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>).
524 line and the line position is not forced to 0 (see <a name="idx:format1:751"></a><a class="pred" href="format.html#format/1">format/1</a>, <code>~N</code>).
566525 </dd>
567526 <dt><strong>ansi</strong>(<var>+Attributes, +Format, +Args</var>)</dt>
568527 <dd class="defbody">
585544 </dd>
586545 <dt><strong>&lt;<var>Format</var>&gt;</strong></dt>
587546 <dd class="defbody">
588 Handed to <a id="idx:format3:750"></a><a class="pred" href="format.html#format/3">format/3</a>
547 Handed to <a name="idx:format3:752"></a><a class="pred" href="format.html#format/3">format/3</a>
589548 as <code>format(Stream, Format,[])</code>. Deprecated because it is
590549 ambiguous if <var>Format</var> collides with one of the atomic commands.
591550 </dd>
592551 </dl>
593552
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,
553 <p>See also <a name="idx:printmessage2:753"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
554 and <a name="idx:messagehook3:754"></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,
597556 +Kind, +Lines</var>)</a></dt>
598557 <dd class="defbody">
599558 Hook predicate that may be defined in the module <code>user</code> to
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>.
559 intercept messages from <a name="idx:printmessage2:755"></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:756"></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:757"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>.
603562 See also
604 <a id="idx:messagetostring2:756"></a><a class="pred" href="exception.html#message_to_string/2">message_to_string/2</a>.
563 <a name="idx:messagetostring2:758"></a><a class="pred" href="exception.html#message_to_string/2">message_to_string/2</a>.
605564
606565 <p>This predicate must be defined dynamic and multifile to allow other
607566 modules defining clauses for it too.</dd>
608 <dt class="pubdef"><a id="thread_message_hook/3"><strong>thread_message_hook</strong>(<var>+Term,
567 <dt class="pubdef"><a name="thread_message_hook/3"><strong>thread_message_hook</strong>(<var>+Term,
609568 +Kind, +Lines</var>)</a></dt>
610569 <dd class="defbody">
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>.
570 As <a name="idx:messagehook3:759"></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:760"></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:761"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.
614573 The `pre-hook' is indented to catch messages they may be produced by
615574 calling some goal without affecting other threads.</dd>
616 <dt class="pubdef"><a id="message_property/2"><strong>message_property</strong>(<var>+Kind,
575 <dt class="pubdef"><a name="message_property/2"><strong>message_property</strong>(<var>+Kind,
617576 ?Property</var>)</a></dt>
618577 <dd class="defbody">
619578 This hook can be used to define additional message kinds and the way
622581 <dl class="latex">
623582 <dt><strong>color</strong>(<var>-Attributes</var>)</dt>
624583 <dd class="defbody">
625 Print message using ANSI terminal attributes. See <a id="idx:ansiformat3:760"></a><span class="pred-ext">ansi_format/3</span>
584 Print message using ANSI terminal attributes. See <a name="idx:ansiformat3:762"></a><span class="pred-ext">ansi_format/3</span>
626585 for details. Here is an example, printing help messages in blue:
627586
628587 <pre class="code">
634593 </dd>
635594 <dt><strong>prefix</strong>(<var>-Prefix</var>)</dt>
636595 <dd class="defbody">
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>.
596 Prefix printed before each line. This argument is handed to <a name="idx:format3:763"></a><a class="pred" href="format.html#format/3">format/3</a>.
638597 The default is <code>'~N'</code>. For example, messages of kind
639598 <code>warning</code> use <code>'~NWarning: '</code>.</dd>
640599 <dt><strong>location_prefix</strong>(<var>+Location, -FirstPrefix,
663622 </dl>
664623
665624 </dd>
666 <dt class="pubdef"><a id="prolog:message_line_element/2"><strong>prolog:message_line_element</strong>(<var>+Stream,
625 <dt class="pubdef"><a name="prolog:message_line_element/2"><strong>prolog:message_line_element</strong>(<var>+Stream,
667626 +Term</var>)</a></dt>
668627 <dd class="defbody">
669628 This hook is called to print the individual elements of a message from
670 <a id="idx:printmessagelines3:762"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>.
629 <a name="idx:printmessagelines3:764"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>.
671630 This hook is used by e.g., library
672631 <code>library(ansi_term)</code> to colour messages on ANSI-capable
673632 terminals.</dd>
674 <dt class="pubdef"><a id="message_to_string/2"><strong>message_to_string</strong>(<var>+Term,
633 <dt class="pubdef"><a name="message_to_string/2"><strong>message_to_string</strong>(<var>+Term,
675634 -String</var>)</a></dt>
676635 <dd class="defbody">
677 Translates a message term into a string object (see <a class="sec" href="strings.html#sec:5.2">section
636 Translates a message term into a string object (see <a class="sec" href="strings.html">section
678637 5.2</a>).</dd>
679 <dt class="pubdef"><a id="version/0"><strong>version</strong></a></dt>
638 <dt class="pubdef"><a name="version/0"><strong>version</strong></a></dt>
680639 <dd class="defbody">
681640 Write the SWI-Prolog banner message as well as additional messages
682 registered using <a id="idx:version1:763"></a><a class="pred" href="exception.html#version/1">version/1</a>.
641 registered using <a name="idx:version1:765"></a><a class="pred" href="exception.html#version/1">version/1</a>.
683642 This is the default <em>initialization goal</em> which can be modified
684643 using <strong>-g</strong>.</dd>
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>.
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:766"></a><a class="pred" href="exception.html#version/0">version/0</a>.
688647 Each registered message is handed to the message translation DCG and can
689648 thus be defined using the hook prolog:message//1. If not defined, it is
690649 simply printed.
691650 </dd>
692651 </dl>
693652
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
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
695654 from libraries</span></a></h4>
696655
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>
656 <a name="sec:libprintmsg"></a>
657
658 <p>Libraries should <em>not</em> use <a name="idx:format3:767"></a><a class="pred" href="format.html#format/3">format/3</a>
700659 or other output predicates directly. Libraries that print informational
701660 output directly to the console are hard to use from code that depend on
702 your textual output, such as a CGI script. The predicates in <a class="sec" href="exception.html#sec:4.11.4">section
661 your textual output, such as a CGI script. The predicates in <a class="sec" href="exception.html">section
703662 4.11.4</a> define the API for dealing with messages. The idea behind
704663 this is that a library that wants to provide information about its
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>.
664 status, progress, events or problems calls <a name="idx:printmessage2:768"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
706665 The first argument is the
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>.
666 <em>level</em>. The supported levels are described with <a name="idx:printmessage2:769"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
708667 Libraries typically use <code>informational</code> and <code>warning</code>,
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>,
668 while libraries should use exceptions for errors (see <a name="idx:throw1:770"></a><a class="pred" href="exception.html#throw/1">throw/1</a>, <a name="idx:typeerror2:771"></a><a class="pred" href="error.html#type_error/2">type_error/2</a>,
710669 etc.).
711670
712671 <p>The second argument is an arbitrary Prolog term that carries the
717676 into a progress bar).
718677
719678 <p>For example, suppose we have a library that must download data from
720 the Internet (e.g., based on <a id="idx:httpopen3:770"></a><span class="pred-ext">http_open/3</span>).
679 the Internet (e.g., based on <a name="idx:httpopen3:772"></a><span class="pred-ext">http_open/3</span>).
721680 The library wants to print the progress after each downloaded file. The
722681 code below is a good skeleton:
723682
736695 different languages. This, and the user-hook example below are the
737696 reason to represent the message as a compound term rather than a string.
738697 This is similar to using message numbers in non-symbolic languages. The
739 documentation of <a id="idx:printmessagelines3:771"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>
698 documentation of <a name="idx:printmessagelines3:773"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a>
740699 describes the elements that may appear in the output list.
741700
742701 <pre class="code">
748707 [ 'Downloaded ~w; ~D from ~D (~d%)'-[URL, I, Total, Perc] ].
749708 </pre>
750709
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>.
710 <p>A <em>user</em> of the library may define rules for <a name="idx:messagehook3:774"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>.
752711 The rule below acts on the message content. Other applications can act
753712 on the message level and, for example, popup a message box for warnings
754713 and errors.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="excepthook.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="intlibs.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:exception3"><a id="sec:B.6"><span class="sec-nr">B.6</span> <span class="sec-title">Hooks
194 <h2 id="sec:exception3"><a name="sec:B.6"><span class="sec-nr">B.6</span> <span class="sec-title">Hooks
236195 using the exception predicate</span></a></h2>
237196
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>,
197 <a name="sec:exception3"></a>
198
199 <p>This section describes the predicate <a name="idx:exception3:2214"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>,
241200 which can be defined by the user in the module <code>user</code> as a
242201 multifile predicate. Unlike the name suggests, this is actually a <em>hook</em>
243202 predicate that has no relation to Prolog exceptions as defined by the
244203 ISO predicates
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>
204 <a name="idx:catch3:2215"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
205 and <a name="idx:throw1:2216"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
206
207 <p>The predicate <a name="idx:exception3:2217"></a><a class="pred" href="exception3.html#exception/3">exception/3</a>
249208 is called by the kernel on a couple of events, allowing the user to
250209 `fix' errors just-in-time. The mechanism allows for
251210 <em>lazy</em> creation of objects such as predicates.
252211
253212 <dl class="latex">
254 <dt class="pubdef"><a id="exception/3"><strong>exception</strong>(<var>+Exception,
213 <dt class="pubdef"><a name="exception/3"><strong>exception</strong>(<var>+Exception,
255214 +Context, -Action</var>)</a></dt>
256215 <dd class="defbody">
257216 Dynamic predicate, normally not defined. Called by the Prolog system on
258217 run-time exceptions that can be repaired `just-in-time'. The values for <var>Exception</var>
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>.
218 are described below. See also <a name="idx:catch3:2218"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
219 and <a name="idx:throw1:2219"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
261220
262221 <p>If this hook predicate succeeds it must instantiate the <var>Action</var>
263222 argument to the atom <code>fail</code> to make the operation fail
275234 exception. The hook is intended to implement alternatives to the
276235 built-in autoloader, such as autoloading code from a database. Do <em>not</em>
277236 use this hook to suppress existence errors on predicates. See also <a class="flag" href="flags.html#flag:unknown">unknown</a>
278 and <a class="sec" href="autoload.html#sec:2.13">section 2.13</a>.</dd>
237 and <a class="sec" href="autoload.html">section 2.13</a>.</dd>
279238 <dt><strong>undefined_global_variable</strong></dt>
280239 <dd class="defbody">
281240 <var>Context</var> is instantiated to the name of the missing global
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>
241 variable. The hook must call <a name="idx:nbsetval2:2220"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
242 or <a name="idx:bsetval2:2221"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
284243 before returning with the action <code>retry</code>.
285244 </dd>
286245 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="dicts.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ext-issues.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ext-integration"><a id="sec:5.5"><span class="sec-nr">5.5</span> <span class="sec-title">Integration
194 <h2 id="sec:ext-integration"><a name="sec:5.5"><span class="sec-nr">5.5</span> <span class="sec-title">Integration
236195 of strings and dicts in the libraries</span></a></h2>
237196
238 <a id="sec:ext-integration"></a>
197 <a name="sec:ext-integration"></a>
239198
240199 <p>While lacking proper string support and dicts when designed, many
241200 predicates and libraries use interfaces that must be classified as
248207 must make a choice. We plan to resolve that using either options that
249208 specify the desired output or provide an alternative library.
250209
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
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
252211 and option processing</span></a></h3>
253212
254 <a id="sec:ext-dict-options"></a>
213 <a name="sec:ext-dict-options"></a>
255214
256215 <p>System predicates and predicates based on library <code>library(options)</code>
257216 process dicts as an alternative to traditional option lists.
258217
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
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
260219 in core data structures</span></a></h3>
261220
262 <a id="sec:ext-dict-in-core-data"></a>
221 <a name="sec:ext-dict-in-core-data"></a>
263222
264223 <p>Some predicates now produce structured data using compound terms and
265224 access predicates. We consider migrating these to dicts. Below is a
272231 <li>Date and time records
273232 </ul>
274233
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,
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,
276235 strings and XML</span></a></h3>
277236
278 <a id="sec:ext-xml"></a>
237 <a name="sec:ext-xml"></a>
279238
280239 <p>The XML representation could benefit significantly from the new
281240 features. In due time we plan to provide an set of alternative
291250 <li>CDATA in element content will be represented as strings
292251 </ul>
293252
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,
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,
295254 strings and JSON</span></a></h3>
296255
297 <a id="sec:ext-json"></a>
256 <a name="sec:ext-json"></a>
298257
299258 <p>The JSON representation could benefit significantly from the new
300259 features. In due time we plan to provide an set of alternative
315274 will be represented as atoms.
316275 </ul>
317276
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,
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,
319278 strings and HTTP</span></a></h3>
320279
321 <a id="sec:ext-http"></a>
280 <a name="sec:ext-http"></a>
322281
323282 <p>The HTTP library and related data structures would profit from
324283 exploiting dicts. Below is a list of data structures that might be
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ext-integration.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="modules.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ext-issues"><a id="sec:5.6"><span class="sec-nr">5.6</span> <span class="sec-title">Remaining
194 <h2 id="sec:ext-issues"><a name="sec:5.6"><span class="sec-nr">5.6</span> <span class="sec-title">Remaining
236195 issues</span></a></h2>
237196
238 <a id="sec:ext-issues"></a>
197 <a name="sec:ext-issues"></a>
239198
240199 <p>The changes and extensions described in this chapter resolve a many
241200 limitations of the Prolog language we have encountered. Still, there are
249208 representations, a list of <em>character codes</em> (`codes' for short)
250209 and a list of <em>one-character atoms</em> (`chars' for short). There
251210 are two sets of predicates, named *_code(s) and *_char(s) that provide
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>)
211 the same functionality (e.g., <a name="idx:atomcodes2:1658"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
212 and <a name="idx:atomchars2:1659"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>)
254213 using their own representation of characters. Codes can be used in
255214 arithmetic expressions, while chars are more readable. Neither can
256215 unambiguously be interpreted as a representation for text because codes
270229 that involve arrays require <em>mutable</em> arrays, while Prolog data
271230 is immutable by design. Second, standard Prolog has no good syntax
272231 support for arrays. SWI-Prolog version&nbsp;7 has `block operators' (see
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.
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.
276234
277235 <p><b>Lambda expressions</b>
278236
279 <p>Although many alternatives<sup class="fn">152<span class="fn-text">See
237 <p>Although many alternatives<sup class="fn">151<span class="fn-text">See
280238 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>
281239 have been proposed, we still feel uneasy with them.
282240
286244 Prolog for simple iterations over data. ECLiPSe have proposed
287245 <em>logical loops</em> <cite><a class="cite" href="Bibliography.html#logicalloops:2002">Schimpf,
288246 2002</a></cite>, while B-Prolog introduced <em>declarative loops</em>
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>
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:1660"></a><a class="pred" href="apply.html#maplist/2">maplist/2</a>
291249 can achieve similar results.
292250 </body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="extensions.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="strings.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ext-lists"><a id="sec:5.1"><span class="sec-nr">5.1</span> <span class="sec-title">Lists
194 <h2 id="sec:ext-lists"><a name="sec:5.1"><span class="sec-nr">5.1</span> <span class="sec-title">Lists
236195 are special</span></a></h2>
237196
238 <a id="sec:ext-lists"></a>
197 <a name="sec:ext-lists"></a>
239198
240199 <p>As of version&nbsp;7, SWI-Prolog lists can be distinguished
241200 unambiguously at runtime from <code><code>.</code>/2</code> terms and
256215 <p>The `cons' operator for creating list cells has changed from the
257216 pretty atom <code>'.'</code> to the ugly atom <code>'[|]'</code>, so we
258217 can use the
259 <code>'.'</code> for other purposes. See <a class="sec" href="dicts.html#sec:5.4.1">section
218 <code>'.'</code> for other purposes. See <a class="sec" href="dicts.html">section
260219 5.4.1</a>.
261220
262221 <p>This modification has minimal impact on typical Prolog code. It does
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
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
268227 <code>SWI-Prolog.h</code>.
269228
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>
229 <p>Another place that is affected is <a name="idx:writecanonical1:1592"></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:1593"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
272231 and
273 <a id="idx:writeterm2:1591"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
232 <a name="idx:writeterm2:1594"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
274233 support the option <code>dotlists(true)</code>, which causes
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>
234 <a name="idx:readterm2:1595"></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:1596"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
277236 to write <code>[a]</code> as <code>.(a,[])</code>.
278237
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
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
280239 '<code>[|]</code>' and <code>[]</code> for lists</span></a></h3>
281240
282 <a id="sec:ext-list-motivation"></a>
241 <a name="sec:ext-list-motivation"></a>
283242
284243 <p>Representing lists the conventional way using <code><code>.</code>/2</code>
285244 as cons-cell and '[]' as list terminator both (independently) poses
292251 distinguished from <code>[a|B]</code>. Freeing <code><code>.</code>/2</code>
293252 provides us with a unique term that we can use for functional notation
294253 on dicts as described in
295 <a class="sec" href="dicts.html#sec:5.4.1">section 5.4.1</a>.
254 <a class="sec" href="dicts.html">section 5.4.1</a>.
296255
297256 <p>
298257 <li>Using <code>'[]'</code> as list terminator prevents dynamic
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="strings.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="dicts.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ext-syntax"><a id="sec:5.3"><span class="sec-nr">5.3</span> <span class="sec-title">Syntax
194 <h2 id="sec:ext-syntax"><a name="sec:5.3"><span class="sec-nr">5.3</span> <span class="sec-title">Syntax
236195 changes</span></a></h2>
237196
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
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
241200 and quoted atoms</span></a></h3>
242201
243 <a id="sec:ext-syntax-op"></a>
202 <a name="sec:ext-syntax-op"></a>
244203
245204 <p>As of SWI-Prolog version&nbsp;7, quoted atoms loose their operator
246205 property. This means that expressions such as <code>A = 'dynamic'/1</code>
263222 Y = 1790400.0'J'.
264223 </pre>
265224
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
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
267226 terms with zero arguments</span></a></h3>
268227
269 <a id="sec:ext-compound-zero"></a>
228 <a name="sec:ext-compound-zero"></a>
270229
271230 <p>As of SWI-Prolog version&nbsp;7, the system supports compound terms
272231 that have no arguments. This implies that e.g., <code>name()</code> is
273 valid syntax. This extension aims at functions on dicts (see <a class="sec" href="dicts.html#sec:5.4">section
232 valid syntax. This extension aims at functions on dicts (see <a class="sec" href="dicts.html">section
274233 5.4</a>) as well as the implementation of domain specific languages
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>
234 (DSLs). To minimise the consequences, the classic predicates <a name="idx:functor3:1628"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
276235 and <a class="pred" href="manipterm.html#=../2">=../2</a> have not been
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>
236 modified. The predicates <a name="idx:compoundnamearity3:1629"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
278237 and
279 <a id="idx:compoundnamearguments3:1627"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
238 <a name="idx:compoundnamearguments3:1630"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
280239 have been added. These predicates operate only on compound terms and
281240 behave consistently for compounds with zero arguments. Code that <em>generalises</em>
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>.
241 a term using the sequence below should generally be changed to use <a name="idx:compoundnamearity3:1631"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.
283242
284243 <pre class="code">
285244 ...,
289248 </pre>
290249
291250 <p>Replacement of <a class="pred" href="manipterm.html#=../2">=../2</a>
292 by <a id="idx:compoundnamearguments3:1629"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
251 by <a name="idx:compoundnamearguments3:1632"></a><a class="pred" href="manipterm.html#compound_name_arguments/3">compound_name_arguments/3</a>
293252 is typically needed to deal with code that follow the skeleton below.
294253
295254 <pre class="code">
322281
323282 <p>Note that the <em>cannonical</em> representation of predicate heads
324283 and functions without arguments is an atom. Thus, <code>clause(go(),
325 Body)</code> returns the clauses for <a id="idx:go0:1630"></a><span class="pred-ext">go/0</span>,
284 Body)</code> returns the clauses for <a name="idx:go0:1633"></a><span class="pred-ext">go/0</span>,
326285 but <code>clause(-Head, -Body, +Ref)</code> unifies <var>Head</var> with
327286 an atom if the clause specified by <var>Ref</var> is part of a predicate
328287 with zero arguments.
329288
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
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
331290 operators</span></a></h3>
332291
333 <a id="sec:ext-blockop"></a>
292 <a name="sec:ext-blockop"></a>
334293
335294 <p>Introducing curly bracket and array subscripting.<sup class="fn">148<span class="fn-text">Introducing
336295 block operators was proposed by Jose Morales. It was discussed in the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="miscpreds.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ext-lists.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:extensions"><a id="sec:5"><span class="sec-nr">5</span> <span class="sec-title">SWI-Prolog
194 <h1 id="sec:extensions"><a name="sec:5"><span class="sec-nr">5</span> <span class="sec-title">SWI-Prolog
236195 extensions</span></a></h1>
237196
238 <a id="sec:extensions"></a>
197 <a name="sec:extensions"></a>
239198
240199 <p>This chapter describes extensions to the Prolog language introduced
241200 with SWI-Prolog version&nbsp;7. The changes bring more modern
252211
253212 <p>While many programs run unmodified in SWI-Prolog version&nbsp;7,
254213 especially those that pass double quoted strings to general purpose list
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>)
214 processing predicates require modifications. We provide a tool (<a name="idx:liststrings0:1591"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>)
256215 that we used to port a huge code base in half a day.
257216
258217 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.36</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="system.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="toplevel.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:files"><a id="sec:4.36"><span class="sec-nr">4.36</span> <span class="sec-title">File
194 <h2 id="sec:files"><a name="sec:4.36"><span class="sec-nr">4.36</span> <span class="sec-title">File
236195 System Interaction</span></a></h2>
237196
238 <a id="sec:files"></a>
197 <a name="sec:files"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="access_file/2"><strong>access_file</strong>(<var>+File,
200 <dt class="pubdef"><a name="access_file/2"><strong>access_file</strong>(<var>+File,
242201 +Mode</var>)</a></dt>
243202 <dd class="defbody">
244203 True if <var>File</var> exists and can be accessed by this Prolog
261220 note that checking access never provides a guarantee that a subsequent
262221 open succeeds without errors due to inherent concurrency in file
263222 operations. It is generally more robust to try and open the file and
264 handle possible exceptions. See <a id="idx:open4:1493"></a><a class="pred" href="IO.html#open/4">open/4</a>
223 handle possible exceptions. See <a name="idx:open4:1495"></a><a class="pred" href="IO.html#open/4">open/4</a>
265224 and
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>
225 <a name="idx:catch3:1496"></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>
268227 <dd class="defbody">
269228 True if <var>File</var> exists and is a regular file. This does not
270229 imply the user has read and/or write permission for the file. This is
271230 the same as <code>access_file(File, exist)</code>.</dd>
272 <dt class="pubdef"><a id="file_directory_name/2"><strong>file_directory_name</strong>(<var>+File,
231 <dt class="pubdef"><a name="file_directory_name/2"><strong>file_directory_name</strong>(<var>+File,
273232 -Directory</var>)</a></dt>
274233 <dd class="defbody">
275234 Extracts the directory part of <var>File</var>. The returned <var>Directory</var>
281240 it is not a valid file name. In this case the final <code><code>/</code></code>
282241 is removed from <var>File</var>, e.g., <code>'/hello'</code>.
283242
284 <p>See also <a id="idx:directoryfilepath3:1495"></a><span class="pred-ext">directory_file_path/3</span>
243 <p>See also <a name="idx:directoryfilepath3:1497"></a><span class="pred-ext">directory_file_path/3</span>
285244 from <code>library(filesex)</code>. The system ensures that for every
286245 valid <var>Path</var> using the Prolog (POSIX) directory separators,
287246 following is true on systems with a sound implementation of
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
247 <a name="idx:samefile2:1498"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>.<sup class="fn">133<span class="fn-text">On
289248 some systems, <var>Path</var> and <var>Path2</var> refer to the same
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>.
249 entry in the file system, but <a name="idx:samefile2:1499"></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:1500"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.
292251
293252 <pre class="code">
294253 ...,
299258 </pre>
300259
301260 </dd>
302 <dt class="pubdef"><a id="file_base_name/2"><strong>file_base_name</strong>(<var>+File,
261 <dt class="pubdef"><a name="file_base_name/2"><strong>file_base_name</strong>(<var>+File,
303262 -BaseName</var>)</a></dt>
304263 <dd class="defbody">
305264 Extracts the filename part from a path specification. If <var>File</var>
306265 does not contain any directory separators, <var>File</var> is returned
307266 in
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>.
267 <var>BaseName</var>. See also <a name="idx:filedirectoryname2:1501"></a><a class="pred" href="files.html#file_directory_name/2">file_directory_name/2</a>.
309268 If the <var>File</var> arguments ends with a <code><code>/</code></code>,
310269 e.g., <code>'/hello/'</code>, <var>BaseName</var> is unified with the
311270 empty atom (<code>''</code>).</dd>
312 <dt class="pubdef"><a id="same_file/2"><strong>same_file</strong>(<var>+File1,
271 <dt class="pubdef"><a name="same_file/2"><strong>same_file</strong>(<var>+File1,
313272 +File2</var>)</a></dt>
314273 <dd class="defbody">
315274 True if both filenames refer to the same physical file. That is, if
316275 <var>File1</var> and <var>File2</var> are the same string or both names
317276 exist and point to the same file (due to hard or symbolic links and/or
318277 relative vs. absolute paths). On systems that provide stat() with
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>
278 meaningful values for <code>st_dev</code> and <code>st_inode</code>, <a name="idx:samefile2:1502"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
320279 is implemented by comparing the device and inode identifiers. On
321280 Windows,
322 <a id="idx:samefile2:1501"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
281 <a name="idx:samefile2:1503"></a><a class="pred" href="files.html#same_file/2">same_file/2</a>
323282 compares the strings returned by the GetFullPathName() system call.</dd>
324 <dt class="pubdef"><a id="exists_directory/1"><strong>exists_directory</strong>(<var>+Directory</var>)</a></dt>
283 <dt class="pubdef"><a name="exists_directory/1"><strong>exists_directory</strong>(<var>+Directory</var>)</a></dt>
325284 <dd class="defbody">
326285 True if <var>Directory</var> exists and is a directory. This does not
327286 imply the user has read, search or write permission for the directory.</dd>
328 <dt class="pubdef"><a id="delete_file/1"><strong>delete_file</strong>(<var>+File</var>)</a></dt>
287 <dt class="pubdef"><a name="delete_file/1"><strong>delete_file</strong>(<var>+File</var>)</a></dt>
329288 <dd class="defbody">
330289 Remove <var>File</var> from the file system.</dd>
331 <dt class="pubdef"><a id="rename_file/2"><strong>rename_file</strong>(<var>+File1,
290 <dt class="pubdef"><a name="rename_file/2"><strong>rename_file</strong>(<var>+File1,
332291 +File2</var>)</a></dt>
333292 <dd class="defbody">
334293 Rename <var>File1</var> as <var>File2</var>. The semantics is compatible
336295 operating system allows. Notably, if <var>File2</var> exists, the
337296 operation succeeds (except for possible permission errors) and is <em>atomic</em>
338297 (meaning there is no window where <var>File2</var> does not exist).</dd>
339 <dt class="pubdef"><a id="size_file/2"><strong>size_file</strong>(<var>+File,
298 <dt class="pubdef"><a name="size_file/2"><strong>size_file</strong>(<var>+File,
340299 -Size</var>)</a></dt>
341300 <dd class="defbody">
342301 Unify <var>Size</var> with the size of <var>File</var> in bytes.</dd>
343 <dt class="pubdef"><a id="time_file/2"><strong>time_file</strong>(<var>+File,
302 <dt class="pubdef"><a name="time_file/2"><strong>time_file</strong>(<var>+File,
344303 -Time</var>)</a></dt>
345304 <dd class="defbody">
346305 Unify the last modification time of <var>File</var> with <var>Time</var>.
347306 <var>Time</var> is a floating point number expressing the seconds
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,
307 elapsed since Jan&nbsp;1, 1970. See also <a name="idx:converttime28:1504"></a><span class="pred-ext">convert_time/[2,8]</span>
308 and <a name="idx:gettime1:1505"></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,
351310 -Absolute</var>)</a></dt>
352311 <dd class="defbody">
353312 Expand a local filename into an absolute path. The absolute path is
355314 deleted. This predicate ensures that expanding a filename returns the
356315 same absolute path regardless of how the file is addressed. SWI-Prolog
357316 uses absolute filenames to register source files independent of the
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,
317 current working directory. See also <a name="idx:absolutefilename3:1506"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
318 and <a name="idx:expandfilename2:1507"></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,
361320 -Absolute, +Options</var>)</a></dt>
362321 <dd class="defbody">
363322 Convert the given file specification into an absolute path. <var>Spec</var>
370329 <dt><strong>extensions</strong>(<var>ListOfExtensions</var>)</dt>
371330 <dd class="defbody">
372331 List of file extensions to try. Default is <code>''</code>. For each
373 extension, <a id="idx:absolutefilename3:1506"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
332 extension, <a name="idx:absolutefilename3:1508"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
374333 will first add the extension and then verify the conditions imposed by
375334 the other options. If the condition fails, the next extension on the
376335 list is tried. Extensions may be specified both as <code>.ext</code> or
379338 <dd class="defbody">
380339 Resolve the path relative to the given directory or the directory
381340 holding the given file. Without this option, paths are resolved relative
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>
341 to the working directory (see <a name="idx:workingdirectory2:1509"></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:1510"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>
384343 is executed in a directive, it uses the current source file as
385344 reference.</dd>
386345 <dt><strong>access</strong>(<var>Mode</var>)</dt>
387346 <dd class="defbody">
388347 Imposes the condition access_file(<var>File</var>, <var>Mode</var>). <var>Mode</var>
389348 is one of <code>read</code>, <code>write</code>, <code>append</code>,
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>
349 <code>execute</code>, <code>exist</code> or <code>none</code>. See also <a name="idx:accessfile2:1511"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>.</dd>
391350 <dt><strong>file_type</strong>(<var>Type</var>)</dt>
392351 <dd class="defbody">
393352 Defines extensions. Current mapping: <code>txt</code> implies <code>['']</code>,
397356 and
398357 <code>directory</code> implies <code>['']</code>. The file type <code>source</code>
399358 is an alias for <code>prolog</code> for compatibility with SICStus
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>.
359 Prolog. See also <a name="idx:prologfiletype2:1512"></a><a class="pred" href="consulting.html#prolog_file_type/2">prolog_file_type/2</a>.
401360 This predicate only returns non-directories, unless the option <code>file_type(directory)</code>
402361 is specified.</dd>
403362 <dt><strong>file_errors</strong>(<var>fail/error</var>)</dt>
404363 <dd class="defbody">
405364 If <code>error</code> (default), throw an <code>existence_error</code>
406365 exception if the file cannot be found. If <code>fail</code>, stay
407 silent.<sup class="fn">135<span class="fn-text">Silent operation was the
366 silent.<sup class="fn">134<span class="fn-text">Silent operation was the
408367 default up to version 3.2.6.</span></sup></dd>
409368 <dt><strong>solutions</strong>(<var>first/all</var>)</dt>
410369 <dd class="defbody">
414373 <dt><strong>expand</strong>(<var>Boolean</var>)</dt>
415374 <dd class="defbody">
416375 If <code>true</code> (default is <code>false</code>) and <var>Spec</var>
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>
376 is atomic, call <a name="idx:expandfilename2:1513"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
377 followed by <a name="idx:member2:1514"></a><a class="pred" href="lists.html#member/2">member/2</a>
419378 on <var>Spec</var> before proceeding. This is a SWI-Prolog extension
420379 intended to minimise porting effort after SWI-Prolog stopped expanding
421380 environment variables and the <code><code>~</code></code> by default.
432391 argument order was <code>absolute_file_name(+Spec, +Options, -Path)</code>.
433392 The argument order has been changed for compatibility with ISO and
434393 SICStus. The Quintus argument order is still accepted.</dd>
435 <dt class="pubdef"><a id="is_absolute_file_name/1"><strong>is_absolute_file_name</strong>(<var>+File</var>)</a></dt>
394 <dt class="pubdef"><a name="is_absolute_file_name/1"><strong>is_absolute_file_name</strong>(<var>+File</var>)</a></dt>
436395 <dd class="defbody">
437396 True if <var>File</var> specifies an absolute path name. On Unix
438397 systems, this implies the path starts with a `/'. For Microsoft-based
439398 systems this implies the path starts with <code>&lt;<var>letter</var>&gt;:</code>.
440399 This predicate is intended to provide platform-independent checking for
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,
400 absolute paths. See also <a name="idx:absolutefilename2:1515"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>
401 and <a name="idx:prologtoosfilename2:1516"></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,
444403 ?Extension, ?Name</var>)</a></dt>
445404 <dd class="defbody">
446405 This predicate is used to add, remove or test filename extensions. The
449408 testing for an extension will also be done case-insensitive. <var>Extension</var>
450409 may be specified with or without a leading dot (<code><code>.</code></code>).
451410 If an <var>Extension</var> is generated, it will not have a leading dot.</dd>
452 <dt class="pubdef"><a id="directory_files/2"><strong>directory_files</strong>(<var>+Directory,
411 <dt class="pubdef"><a name="directory_files/2"><strong>directory_files</strong>(<var>+Directory,
453412 -Entries</var>)</a></dt>
454413 <dd class="defbody">
455414 Unify <var>Entries</var> with a list of entries in <var>Directory</var>.
457416 to <var>Directory</var>. <var>Entries</var> contains all entries,
458417 including hidden files and, if supplied by the OS, the special entries <code><code>.</code></code>
459418 and
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
419 <code>..</code>. See also <a name="idx:expandfilename2:1517"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.<sup class="fn">135<span class="fn-text">This
461420 predicate should be considered a misnomer because it returns entries
462421 rather than files. We stick to this name for compatibility with, e.g.,
463422 SICStus, Ciao and YAP.</span></sup></dd>
464 <dt class="pubdef"><a id="expand_file_name/2"><strong>expand_file_name</strong>(<var>+WildCard,
423 <dt class="pubdef"><a name="expand_file_name/2"><strong>expand_file_name</strong>(<var>+WildCard,
465424 -List</var>)</a></dt>
466425 <dd class="defbody">
467426 Unify <var>List</var> with a sorted list of files or directories
481440 <p>Before expanding wildcards, the construct <code>$<var>var</var></code>
482441 is expanded to the value of the environment variable <var>var</var>, and
483442 a possible leading <code>~</code> character is expanded to the user's
484 home directory.<sup class="fn">137<span class="fn-text">On Windows, the
443 home directory.<sup class="fn">136<span class="fn-text">On Windows, the
485444 home directory is determined as follows: if the environment variable <code>HOME</code>
486445 exists, this is used. If the variables <code>HOMEDRIVE</code> and <code>HOMEPATH</code>
487446 exist (Windows-NT), these are used. At initialisation, the system will
488447 set the environment variable <code>HOME</code> to point to the
489448 SWI-Prolog home directory if neither <code>HOME</code> nor <code>HOMEPATH</code>
490449 and <code>HOMEDRIVE</code> are defined.</span></sup></dd>
491 <dt class="pubdef"><a id="prolog_to_os_filename/2"><strong>prolog_to_os_filename</strong>(<var>?PrologPath,
450 <dt class="pubdef"><a name="prolog_to_os_filename/2"><strong>prolog_to_os_filename</strong>(<var>?PrologPath,
492451 ?OsPath</var>)</a></dt>
493452 <dd class="defbody">
494453 Convert between the internal Prolog path name conventions and the
496455 the POSIX standard, which implies that this predicate is equivalent to
497456 =/2 (unify) on POSIX (e.g., Unix) systems. On Windows systems it changes
498457 the directory separator from <code><code>\</code></code> into <code><code>/</code></code>.</dd>
499 <dt class="pubdef"><a id="read_link/3"><strong>read_link</strong>(<var>+File,
458 <dt class="pubdef"><a name="read_link/3"><strong>read_link</strong>(<var>+File,
500459 -Link, -Target</var>)</a></dt>
501460 <dd class="defbody">
502461 If <var>File</var> points to a symbolic link, unify <var>Link</var> with
505464 <var>Target</var> points to a file, directory or non-existing entry in
506465 the file system, but never to a link. Fails if <var>File</var> is not a
507466 link. Fails always on systems that do not support symbolic links.</dd>
508 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="tmp_file/2"><strong>tmp_file</strong>(<var>+Base,
467 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="tmp_file/2"><strong>tmp_file</strong>(<var>+Base,
509468 -TmpName</var>)</a></dt>
510469 <dd class="defbody">
511470 Create a name for a temporary file. <var>Base</var> is an identifier for
517476
518477 <p>Because it is possible to guess the generated filename, attackers may
519478 create the filesystem entry as a link and possibly create a security
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,
479 issue. New code should use <a name="idx:tmpfilestream3:1518"></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,
522481 -FileName, -Stream</var>)</a></dt>
523482 <dd class="defbody">
524483 Create a temporary filename <var>FileName</var> and open it for writing
528487 supports it, the created file is only accessible to the current user. If
529488 the OS supports it, the file is created using the open()-flag <code>O_EXCL</code>,
530489 which guarantees that the file did not exist before this call. This
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>.
490 predicate is a safe replacement of <a name="idx:tmpfile2:1519"></a><a class="pred" href="files.html#tmp_file/2">tmp_file/2</a>.
532491 Note that in those cases where the temporary file is needed to store
533492 output from an external command, the file must be closed first. E.g.,
534493 the following downloads a file from a URL to a temporary file and opens
545504 </pre>
546505
547506 <p>Temporary files created using this call are removed if the Prolog
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>
507 process terminates <em>gracefully</em>. Calling <a name="idx:deletefile1:1520"></a><a class="pred" href="files.html#delete_file/1">delete_file/1</a>
549508 using
550509 <var>FileName</var> removes the file and removes the entry from the
551510 administration of files-to-be-deleted.</dd>
552 <dt class="pubdef"><a id="make_directory/1"><strong>make_directory</strong>(<var>+Directory</var>)</a></dt>
511 <dt class="pubdef"><a name="make_directory/1"><strong>make_directory</strong>(<var>+Directory</var>)</a></dt>
553512 <dd class="defbody">
554513 Create a new directory (folder) on the filesystem. Raises an exception
555514 on failure. On Unix systems, the directory is created with default
556515 permissions (defined by the process <em>umask</em> setting).</dd>
557 <dt class="pubdef"><a id="delete_directory/1"><strong>delete_directory</strong>(<var>+Directory</var>)</a></dt>
516 <dt class="pubdef"><a name="delete_directory/1"><strong>delete_directory</strong>(<var>+Directory</var>)</a></dt>
558517 <dd class="defbody">
559518 Delete directory (folder) from the filesystem. Raises an exception on
560519 failure. Please note that in general it will not be possible to delete a
561520 non-empty directory.</dd>
562 <dt class="pubdef"><a id="working_directory/2"><strong>working_directory</strong>(<var>-Old,
521 <dt class="pubdef"><a name="working_directory/2"><strong>working_directory</strong>(<var>-Old,
563522 +New</var>)</a></dt>
564523 <dd class="defbody">
565524 Unify <var>Old</var> with an absolute path to the current working
566525 directory and change working directory to <var>New</var>. Use the
567526 pattern
568527 <code>working_directory(CWD, CWD)</code> to get the current directory.
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
528 See also <a name="idx:absolutefilename2:1521"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>
529 and <a name="idx:chdir1:1522"></a><a class="pred" href="files.html#chdir/1">chdir/1</a>.<sup class="fn">bug<span class="fn-text">Some
571530 of the file I/O predicates use local filenames. Changing directory while
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>
531 file-bound streams are open causes wrong results on <a name="idx:telling1:1523"></a><a class="pred" href="IO.html#telling/1">telling/1</a>, <a name="idx:seeing1:1524"></a><a class="pred" href="IO.html#seeing/1">seeing/1</a>
532 and <a name="idx:currentstream3:1525"></a><a class="pred" href="IO.html#current_stream/3">current_stream/3</a>.</span></sup>
574533 Note that the working directory is shared between all threads.</dd>
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>.
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:1526"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
578537 </dd>
579538 </dl>
580539
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="useresource.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="libpl.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:findappfile"><a id="sec:12.4"><span class="sec-nr">12.4</span> <span class="sec-title">Finding
194 <h2 id="sec:findappfile"><a name="sec:12.4"><span class="sec-nr">12.4</span> <span class="sec-title">Finding
236195 Application files</span></a></h2>
237196
238 <a id="sec:findappfile"></a>
197 <a name="sec:findappfile"></a>
239198
240199 <p>If your application uses files that are not part of the saved program
241200 such as database files, configuration files, etc., the runtime version
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>
201 has to be able to locate these files. The <a name="idx:filesearchpath2:2132"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
243202 mechanism in combination with the <strong>-p</strong>alias command line
244203 argument is the preferred way to locate runtime files. The first step is
245204 to define an alias for the top-level directory of your application. We
268227 ).
269228 </pre>
270229
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
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
272231 a file search path from the command line</span></a></h3>
273232
274 <a id="sec:runtime-file-search-path"></a>
233 <a name="sec:runtime-file-search-path"></a>
275234
276235 <p>Suppose the system administrator has installed the SWI-Prolog runtime
277236 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.7.4 Reference Manual: Section 11.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="plld.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreignxmp.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:findhome"><a id="sec:11.6"><span class="sec-nr">11.6</span> <span class="sec-title">The
194 <h2 id="sec:findhome"><a name="sec:11.6"><span class="sec-nr">11.6</span> <span class="sec-title">The
236195 Prolog `home' directory</span></a></h2>
237196
238 <a id="sec:findhome"></a>
197 <a name="sec:findhome"></a>
239198
240199 <p>Executables embedding SWI-Prolog should be able to find the `home'
241200 directory of the development environment unless a self-contained saved
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>).
201 state has been added to the executable (see <a name="idx:qsaveprogram12:2091"></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>).
244203
245204 <p>If Prolog starts up, it will try to locate the development
246205 environment. To do so, it will try the following steps until one
268227 SWI-Prolog gives up. If a state is attached, the current working
269228 directory is used.
270229
271 <p>The <a id="idx:filesearchpath2:2093"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
230 <p>The <a name="idx:filesearchpath2:2092"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
272231 alias <code>swi</code> is set to point to the home directory located.
273232
274233 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.11</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="compilation.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="hooks.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:flags"><a id="sec:2.11"><span class="sec-nr">2.11</span> <span class="sec-title">Environment
194 <h2 id="sec:flags"><a name="sec:2.11"><span class="sec-nr">2.11</span> <span class="sec-title">Environment
236195 Control (Prolog flags)</span></a></h2>
237196
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>
197 <a name="sec:flags"></a>
198
199 <p>The predicates <a name="idx:currentprologflag2:81"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
200 and <a name="idx:setprologflag2:82"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
242201 allow the user to examine and modify the execution environment. It
243202 provides access to whether optional features are available on this
244203 version, operating system, foreign code environment, command line
247206 Prolog environments.
248207
249208 <dl class="latex">
250 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_prolog_flag/2"><strong>current_prolog_flag</strong>(<var>?Key,
209 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_prolog_flag/2"><strong>current_prolog_flag</strong>(<var>?Key,
251210 -Value</var>)</a></dt>
252211 <dd class="defbody">
253 The predicate <a id="idx:currentprologflag2:82"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
212 The predicate <a name="idx:currentprologflag2:83"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>
254213 defines an interface to installation features: options compiled in,
255214 version, home, etc. With both arguments unbound, it will generate all
256215 defined Prolog flags. With <var>Key</var> instantiated, it unifies <var>Value</var>
258217 a Prolog flag.
259218
260219 <p>Flags marked <b>rw</b> can be modified by the user using
261 <a id="idx:setprologflag2:83"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>.
220 <a name="idx:setprologflag2:84"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>.
262221 Flag values are typed. Flags marked as <code>bool</code> can have the
263222 values <code>true</code> or <code>false</code>. The predicate
264 <a id="idx:createprologflag3:84"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
223 <a name="idx:createprologflag3:85"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
265224 may be used to create flags that describe or control behaviour of
266225 libraries and applications. The library
267226 <code>library(settings)</code> provides an alternative interface for
287246 <a class="flag" href="flags.html#flag:generate_debug_info">generate_debug_info</a>
288247 and <a class="flag" href="flags.html#flag:optimise">optimise</a>.
289248
290 <p>A new thread (see <a class="sec" href="threads.html#sec:9">section 9</a>) <em>copies</em>
249 <p>A new thread (see <a class="sec" href="threads.html">section 9</a>) <em>copies</em>
291250 all flags from the thread that created the new thread (its <em>parent</em>).<sup class="fn">17<span class="fn-text">This
292251 is implemented using the copy-on-write tecnhnique.</span></sup> As a
293252 consequence, modifying a flag inside a thread does not affect other
294253 threads.
295254
296255 <dl class="latex">
297 <dt class="pubdef"><a id="flag:access_level"><strong>access_level</strong>(<var>atom</var>, changeable)</a></dt>
256 <dt class="pubdef"><a name="flag:access_level"><strong>access_level</strong>(<var>atom</var>, changeable)</a></dt>
298257 <dd class="defbody">
299258 This flag defines a normal `user' view (<code>user</code>, default) or a
300259 `system' view. In system view all system code is fully accessible as if
302261 permitted and some details are kept invisible. We leave the exact
303262 consequences undefined, but, for example, system code can be traced
304263 using system access and system predicates can be redefined.</dd>
305 <dt class="pubdef"><a id="flag:address_bits"><strong>address_bits</strong>(<var>integer</var>)</a></dt>
264 <dt class="pubdef"><a name="flag:address_bits"><strong>address_bits</strong>(<var>integer</var>)</a></dt>
306265 <dd class="defbody">
307266 Address size of the hosting machine. Typically 32 or 64. Except for the
308267 maximum stack limit, this has few implications to the user. See also the
309268 Prolog flag <a class="flag" href="flags.html#flag:arch">arch</a>.</dd>
310 <dt class="pubdef"><a id="flag:agc_margin"><strong>agc_margin</strong>(<var>integer</var>, changeable)</a></dt>
269 <dt class="pubdef"><a name="flag:agc_margin"><strong>agc_margin</strong>(<var>integer</var>, changeable)</a></dt>
311270 <dd class="defbody">
312271 If this amount of atoms possible garbage atoms exist perform atom
313272 garbage collection at the first opportunity. Initial value is 10,000.
315274 See also <a class="func" href="foreigninclude.html#PL_register_atom()">PL_register_atom()</a>.<sup class="fn">18<span class="fn-text">Given
316275 that SWI-Prolog has no limit on the length of atoms, 10,000 atoms may
317276 still occupy a lot of memory. Applications using extremely large atoms
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>
277 may wish to call <a name="idx:garbagecollectatoms0:86"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>
319278 explicitly or lower the margin.</span></sup></dd>
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
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:87"></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
325284 <code>__APPLE__</code>. Note that the <a class="flag" href="flags.html#flag:unix">unix</a>
326285 is also defined for MacOSX.</dd>
327 <dt class="pubdef"><a id="flag:allow_dot_in_atom"><strong>allow_dot_in_atom</strong>(<var>bool</var>, changeable)</a></dt>
286 <dt class="pubdef"><a name="flag:allow_dot_in_atom"><strong>allow_dot_in_atom</strong>(<var>bool</var>, changeable)</a></dt>
328287 <dd class="defbody">
329288 If <code>true</code> (default <code>false</code>), dots may be embedded
330289 into atoms that are not quoted and start with a letter. The embedded dot
334293 that this conflicts with cascading functional notation. For example,
335294 <code>Post.meta.author</code> is read as <code>.(Post, 'meta.author'</code>
336295 if this flag is set to <code>true</code>.</dd>
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>
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>
338297 <dd class="defbody">
339298 If true (default is false), <code>Functor(arg)</code> is read as if it
340299 were written <code>'Functor'(arg)</code>. Some applications use the
341 Prolog <a id="idx:read1:87"></a><a class="pred" href="termrw.html#read/1">read/1</a>
300 Prolog <a name="idx:read1:88"></a><a class="pred" href="termrw.html#read/1">read/1</a>
342301 predicate for reading an application-defined script language. In these
343302 cases, it is often difficult to explain to non-Prolog users of the
344303 application that constants and functions can only start with a lowercase
345304 letter. Variables can be turned into atoms starting with an uppercase
346 atom by calling <a id="idx:readterm2:88"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
305 atom by calling <a name="idx:readterm2:89"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
347306 using the option <code>variable_names</code> and binding the variables
348307 to their name. Using this feature, F(x) can be turned into valid syntax
349308 for such script languages. Suggested by Robert van Engelen. SWI-Prolog
350309 specific.</dd>
351 <dt class="pubdef"><a id="flag:argv"><strong>argv</strong>(<var>list</var>, changeable)</a></dt>
310 <dt class="pubdef"><a name="flag:argv"><strong>argv</strong>(<var>list</var>, changeable)</a></dt>
352311 <dd class="defbody">
353312 List is a list of atoms representing the application command line
354313 arguments. Application command line arguments are those that have
359318 was defined as <a class="flag" href="flags.html#flag:os_argv">os_argv</a>
360319 is now. The change was made for compatibility reasons and because the
361320 current definition is more practical.</span></sup></dd>
362 <dt class="pubdef"><a id="flag:arch"><strong>arch</strong>(<var>atom</var>)</a></dt>
321 <dt class="pubdef"><a name="flag:arch"><strong>arch</strong>(<var>atom</var>)</a></dt>
363322 <dd class="defbody">
364323 Identifier for the hardware and operating system SWI-Prolog is running
365324 on. Used to select foreign files for the right architecture. See also
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>
325 <a class="sec" href="foreignlink.html">section 11.2.3</a> and <a name="idx:filesearchpath2:90"></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:91"></a><a class="pred" href="edit.html#edit/0">edit/0</a>
370329 to edit the initial file.</dd>
371 <dt class="pubdef"><a id="flag:autoload"><strong>autoload</strong>(<var>bool</var>, changeable)</a></dt>
330 <dt class="pubdef"><a name="flag:autoload"><strong>autoload</strong>(<var>bool</var>, changeable)</a></dt>
372331 <dd class="defbody">
373332 If <code>true</code> (default) autoloading of library functions is
374333 enabled.</dd>
375 <dt class="pubdef"><a id="flag:back_quotes"><strong>back_quotes</strong>(<var>codes,chars,string,symbol_char</var>, changeable)</a></dt>
334 <dt class="pubdef"><a name="flag:back_quotes"><strong>back_quotes</strong>(<var>codes,chars,string,symbol_char</var>, changeable)</a></dt>
376335 <dd class="defbody">
377336 Defines the term-representation for back-quoted material. The default is <code>codes</code>.
378337 If <strong>--traditional</strong> is given, the default is <code>symbol_char</code>,
379338 which allows using <code>`</code> in operators composed of symbols.<sup class="fn">20<span class="fn-text">Older
380339 versions had a boolean flag <code>backquoted_strings</code>, which
381340 toggled between <code>string</code> and <code>symbol_char</code></span></sup>.
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>
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>
384343 <dd class="defbody">
385344 If <code>true</code> (default), print a backtrace on an uncaught
386345 exception.</dd>
387 <dt class="pubdef"><a id="flag:backtrace_depth"><strong>backtrace_depth</strong>(<var>integer</var>, changeable)</a></dt>
346 <dt class="pubdef"><a name="flag:backtrace_depth"><strong>backtrace_depth</strong>(<var>integer</var>, changeable)</a></dt>
388347 <dd class="defbody">
389348 If backtraces on errors are enabled, this flag defines the maximum
390349 number of frames that is printed (default&nbsp;20).</dd>
391 <dt class="pubdef"><a id="flag:backtrace_goal_depth"><strong>backtrace_goal_depth</strong>(<var>integer</var>, changeable)</a></dt>
350 <dt class="pubdef"><a name="flag:backtrace_goal_depth"><strong>backtrace_goal_depth</strong>(<var>integer</var>, changeable)</a></dt>
392351 <dd class="defbody">
393352 The frame of a backtrace is printed after making a shallow copy of the
394353 goal. This flag determines the depth to which the goal term is copied.
395354 Default is `3'.</dd>
396 <dt class="pubdef"><a id="flag:backtrace_show_lines"><strong>backtrace_show_lines</strong>(<var>bool</var>, changeable)</a></dt>
355 <dt class="pubdef"><a name="flag:backtrace_show_lines"><strong>backtrace_show_lines</strong>(<var>bool</var>, changeable)</a></dt>
397356 <dd class="defbody">
398357 If <code>true</code> (default), try to reconstruct the line number at
399358 which the exception happened.</dd>
400 <dt class="pubdef"><a id="flag:bounded"><strong>bounded</strong>(<var>bool</var>)</a></dt>
359 <dt class="pubdef"><a name="flag:bounded"><strong>bounded</strong>(<var>bool</var>)</a></dt>
401360 <dd class="defbody">
402361 ISO Prolog flag. If <code>true</code>, integer representation is bound
403362 by
405364 If <code>false</code> integers can be arbitrarily large and the <a class="flag" href="flags.html#flag:min_integer">min_integer</a>
406365 and
407366 <a class="flag" href="flags.html#flag:max_integer">max_integer</a> are
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>
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>
411369 <dd class="defbody">
412370 Current break-level. The initial top level (started with
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>.
371 <strong>-t</strong>) has value 0. See <a name="idx:break0:92"></a><a class="pred" href="toplevel.html#break/0">break/0</a>.
414372 This flag is absent from threads that are not running a top-level loop.</dd>
415 <dt class="pubdef"><a id="flag:c_cc"><strong>c_cc</strong>(<var>atom</var>, changeable)</a></dt>
373 <dt class="pubdef"><a name="flag:c_cc"><strong>c_cc</strong>(<var>atom</var>, changeable)</a></dt>
416374 <dd class="defbody">
417375 Name of the C compiler used to compile SWI-Prolog. Normally either gcc
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
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
422380 11.5</a>.</dd>
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
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
426384 11.5</a>.</dd>
427 <dt class="pubdef"><a id="flag:c_libs"><strong>c_libs</strong>(<var>atom</var>, changeable)</a></dt>
385 <dt class="pubdef"><a name="flag:c_libs"><strong>c_libs</strong>(<var>atom</var>, changeable)</a></dt>
428386 <dd class="defbody">
429387 Libraries needed to link executables that embed SWI-Prolog. Typically
430388 <code>-lswipl</code> if the SWI-Prolog kernel is a shared (DLL). If the
431389 SWI-Prolog kernel is in a static library, this flag also contains the
432390 dependencies.</dd>
433 <dt class="pubdef"><a id="flag:c_libplso"><strong>c_libplso</strong>(<var>atom</var>, changeable)</a></dt>
391 <dt class="pubdef"><a name="flag:c_libplso"><strong>c_libplso</strong>(<var>atom</var>, changeable)</a></dt>
434392 <dd class="defbody">
435393 Libraries needed to link extensions (shared object, DLL) to SWI-Prolog.
436394 Typically empty on ELF systems and <code>-lswipl</code> on COFF-based
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>
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>
439397 <dd class="defbody">
440398 Determines whether character conversion takes place while reading terms.
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>
399 See also <a name="idx:charconversion2:93"></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:94"></a><a class="pred" href="termrw.html#read/1">read/1</a>
445403 interprets <code>\</code> escape sequences in quoted atoms and strings.
446404 May be changed. This flag is local to the module in which it is changed.
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>
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>
449407 <dd class="defbody">
450408 Using the construct &lt;<var>module</var>&gt;:&lt;<var>goal</var>&gt;
451409 sets the <em>calling context</em> for executing &lt;<var>goal</var>&gt;.
452 This flag is defined by ISO/IEC 13211-2 (Prolog modules standard). See <a class="sec" href="modules.html#sec:6">section
410 This flag is defined by ISO/IEC 13211-2 (Prolog modules standard). See <a class="sec" href="modules.html">section
453411 6</a>.</dd>
454 <dt class="pubdef"><a id="flag:color_term"><strong>color_term</strong>(<var>bool</var>, changeable)</a></dt>
412 <dt class="pubdef"><a name="flag:color_term"><strong>color_term</strong>(<var>bool</var>, changeable)</a></dt>
455413 <dd class="defbody">
456414 This flag is managed by library <code>library(ansi_term)</code>, which
457415 is loaded at startup if the two conditions below are both true. Note
458416 that this implies that setting this flag to <code>false</code> from the
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>
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:95"></a><a class="pred" href="exception.html#message_property/2">message_property/2</a>
461419 can be used to control the actual color scheme depending in the message
462420 type passed to
463 <a id="idx:printmessage2:95"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
421 <a name="idx:printmessage2:96"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
464422
465423 <p>
466424 <ul class="latex">
468426 <li><code>\+ current_prolog_flag(color_term, false)</code>
469427 </ul>
470428 </dd>
471 <dt class="pubdef"><a id="flag:compile_meta_arguments"><strong>compile_meta_arguments</strong>(<var>atom</var>, changeable)</a></dt>
429 <dt class="pubdef"><a name="flag:compile_meta_arguments"><strong>compile_meta_arguments</strong>(<var>atom</var>, changeable)</a></dt>
472430 <dd class="defbody">
473431 Experimental flag that controls compilation of arguments passed to
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>).
432 meta-calls marked `0' or `<code><code>^</code></code>' (see <a name="idx:metapredicate1:97"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>).
475433 Supported values are:
476434
477435 <dl class="latex">
491449 <dd class="defbody">
492450 Also compile references to normal user predicates. This harms
493451 performance (a little), but enhances the power of poor-mens consistency
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>.
452 check used by <a name="idx:make0:98"></a><a class="pred" href="consulting.html#make/0">make/0</a>
453 and implemented by <a name="idx:listundefined0:99"></a><a class="pred" href="check.html#list_undefined/0">list_undefined/0</a>.
496454 </dd>
497455 <dt><strong>always</strong></dt>
498456 <dd class="defbody">
499457 Always create an intermediate clause, even for system predicates. This
500458 prepares for replacing the normal head of the generated predicate with a
501459 special reference (similar to database references as used by, e.g.,
502 <a id="idx:assert2:99"></a><a class="pred" href="db.html#assert/2">assert/2</a>)
460 <a name="idx:assert2:100"></a><a class="pred" href="db.html#assert/2">assert/2</a>)
503461 that provides direct access to the executable code, thus avoiding
504462 runtime lookup of predicates for meta-calling.
505463 </dd>
506464 </dl>
507465
508466 </dd>
509 <dt class="pubdef"><a id="flag:compiled_at"><strong>compiled_at</strong>(<var>atom</var>)</a></dt>
467 <dt class="pubdef"><a name="flag:compiled_at"><strong>compiled_at</strong>(<var>atom</var>)</a></dt>
510468 <dd class="defbody">
511469 Describes when the system has been compiled. Only available if the C
512470 compiler used to compile SWI-Prolog provides the __DATE__ and __TIME__
513471 macros.</dd>
514 <dt class="pubdef"><a id="flag:console_menu"><strong>console_menu</strong>(<var>bool</var>)</a></dt>
472 <dt class="pubdef"><a name="flag:console_menu"><strong>console_menu</strong>(<var>bool</var>)</a></dt>
515473 <dd class="defbody">
516474 Set to <code>true</code> in <b>swipl-win.exe</b> to indicate that the
517 console supports menus. See also <a class="sec" href="system.html#sec:4.35.3">section
475 console supports menus. See also <a class="sec" href="system.html">section
518476 4.35.3</a>.</dd>
519 <dt class="pubdef"><a id="flag:cpu_count"><strong>cpu_count</strong>(<var>integer</var>, changeable)</a></dt>
477 <dt class="pubdef"><a name="flag:cpu_count"><strong>cpu_count</strong>(<var>integer</var>, changeable)</a></dt>
520478 <dd class="defbody">
521479 Number of physical CPUs or cores in the system. The flag is marked
522480 read-write both to allow pretending the system has more or less
523 processors. See also <a id="idx:threadsetconcurrency2:100"></a><a class="pred" href="threadcreate.html#thread_setconcurrency/2">thread_setconcurrency/2</a>
481 processors. See also <a name="idx:threadsetconcurrency2:101"></a><a class="pred" href="threadcreate.html#thread_setconcurrency/2">thread_setconcurrency/2</a>
524482 and the library
525483 <code>library(thread)</code>. This flag is not available on systems
526484 where we do not know how to get the number of CPUs. This flag is not
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>
485 included in a saved state (see <a name="idx:qsaveprogram1:102"></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>
529487 <dd class="defbody">
530488 Set to <code>true</code> if this instance of Prolog supports DDE as
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>
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>
533491 <dd class="defbody">
534492 Switch debugging mode on/off. If debug mode is activated the system
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>).
493 traps encountered spy points (see <a name="idx:spy1:103"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
494 and trace points (see <a name="idx:trace1:104"></a><a class="pred" href="debugger.html#trace/1">trace/1</a>).
537495 In addition, last-call optimisation is disabled and the system is more
538496 conservative in destroying choice points to simplify debugging.
539497
540498 <p>Disabling these optimisations can cause the system to run out of
541499 memory on programs that behave correctly if debug mode is off.</dd>
542 <dt class="pubdef"><a id="flag:debug_on_error"><strong>debug_on_error</strong>(<var>bool</var>, changeable)</a></dt>
500 <dt class="pubdef"><a name="flag:debug_on_error"><strong>debug_on_error</strong>(<var>bool</var>, changeable)</a></dt>
543501 <dd class="defbody">
544502 If <code>true</code>, start the tracer after an error is detected.
545503 Otherwise just continue execution. The goal that raised the error will
546504 normally fail. See also the Prolog flag <a class="flag" href="flags.html#flag:report_error">report_error</a>.
547505 Default is <code>true</code>.</dd>
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>
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:105"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
551509 for printing goals by the debugger. Modified by the `w', `p' and `&lt;N&gt;
552510 d' commands of the debugger. Default is <code>[quoted(true),
553511 portray(true), max_depth(10), attributes(portray)]</code>.</dd>
554 <dt class="pubdef"><a id="flag:debugger_show_context"><strong>debugger_show_context</strong>(<var>bool</var>, changeable)</a></dt>
512 <dt class="pubdef"><a name="flag:debugger_show_context"><strong>debugger_show_context</strong>(<var>bool</var>, changeable)</a></dt>
555513 <dd class="defbody">
556514 If <code>true</code>, show the context module while printing a
557515 stack-frame in the tracer. Normally controlled using the `C' option of
558516 the tracer.</dd>
559 <dt class="pubdef"><a id="flag:dialect"><strong>dialect</strong>(<var>atom</var>)</a></dt>
517 <dt class="pubdef"><a name="flag:dialect"><strong>dialect</strong>(<var>atom</var>)</a></dt>
560518 <dd class="defbody">
561519 Fixed to <code>swi</code>. The code below is a reliable and portable way
562520 to detect SWI-Prolog.
567525 </pre>
568526
569527 </dd>
570 <dt class="pubdef"><a id="flag:double_quotes"><strong>double_quotes</strong>(<var>codes,chars,atom,string</var>, changeable)</a></dt>
528 <dt class="pubdef"><a name="flag:double_quotes"><strong>double_quotes</strong>(<var>codes,chars,atom,string</var>, changeable)</a></dt>
571529 <dd class="defbody">
572530 This flag determines how double quoted strings are read by Prolog and is
573531 ---like <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
574532 and <a class="flag" href="flags.html#flag:back_quotes">back_quotes</a>---
575533 maintained for each module. The default is <code>string</code>, which
576 produces a string as described in <a class="sec" href="strings.html#sec:5.2">section
534 produces a string as described in <a class="sec" href="strings.html">section
577535 5.2</a>. If
578536 <strong>--traditional</strong> is given, the default is <code>codes</code>,
579537 which produces a list of character codes, integers that represent a
580538 Unicode code-point. The value <code>chars</code> produces a list of
581539 one-character atoms and the value <code>atom</code> makes double quotes
582 the same as single quotes, creating a atom. See also <a class="sec" href="extensions.html#sec:5">section
540 the same as single quotes, creating a atom. See also <a class="sec" href="extensions.html">section
583541 5</a>.</dd>
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>
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:106"></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>
590548 <dd class="defbody">
591549 If true, SWI-Prolog is running as an <em>inferior process</em> of
592550 (GNU/X-)Emacs. SWI-Prolog assumes this is the case if the environment
593551 variable <code>EMACS</code> is <code>t</code> and <code>INFERIOR</code>
594552 is <code>yes</code>.</dd>
595 <dt class="pubdef"><a id="flag:encoding"><strong>encoding</strong>(<var>atom</var>, changeable)</a></dt>
553 <dt class="pubdef"><a name="flag:encoding"><strong>encoding</strong>(<var>atom</var>, changeable)</a></dt>
596554 <dd class="defbody">
597555 Default encoding used for opening files in <code>text</code> mode. The
598 initial value is deduced from the environment. See <a class="sec" href="widechars.html#sec:2.19.1">section
556 initial value is deduced from the environment. See <a class="sec" href="widechars.html">section
599557 2.19.1</a> for details.</dd>
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>
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:107"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
603561 as default emulator.</dd>
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>
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:108"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>
607565 to its argument, making the exit status available to hooks registered
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>
566 with <a name="idx:athalt1:109"></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>
610568 <dd class="defbody">
611569 This flag defines how Prolog handles the case of file names. The flag is
612570 used for case normalization and to determine whether two names refer to
635593 </dl>
636594
637595 </dd>
638 <dt class="pubdef"><a id="flag:file_name_variables"><strong>file_name_variables</strong>(<var>bool</var>, changeable)</a></dt>
596 <dt class="pubdef"><a name="flag:file_name_variables"><strong>file_name_variables</strong>(<var>bool</var>, changeable)</a></dt>
639597 <dd class="defbody">
640598 If <code>true</code> (default <code>false</code>), expand <code>$<var>varname</var></code>
641599 and <code><code>~</code></code> in arguments of built-in predicates that
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>,
600 accept a file name (<a name="idx:open3:110"></a><a class="pred" href="IO.html#open/3">open/3</a>, <a name="idx:existsfile1:111"></a><a class="pred" href="files.html#exists_file/1">exists_file/1</a>, <a name="idx:accessfile2:112"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>,
643601 etc.). The predicate
644 <a id="idx:expandfilename2:112"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
602 <a name="idx:expandfilename2:113"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>
645603 can be used to expand environment variables and wildcard patterns. This
646604 Prolog flag is intended for backward compatibility with older versions
647605 of SWI-Prolog.</dd>
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>
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:114"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
651609 are cached. Within this time limit, the system will first check that the
652610 old search result satisfies the conditions. Default is 10 seconds, which
653611 typically avoids most repetitive searches for (library) files during
654612 compilation. Setting this value to 0 (zero) disables the cache.</dd>
655 <dt class="pubdef"><a id="flag:gc"><strong>gc</strong>(<var>bool</var>, changeable)</a></dt>
613 <dt class="pubdef"><a name="flag:gc"><strong>gc</strong>(<var>bool</var>, changeable)</a></dt>
656614 <dd class="defbody">
657615 If true (default), the garbage collector is active. If false, neither
658616 garbage collection, nor stack shifts will take place, even not on
659617 explicit request. May be changed.</dd>
660 <dt class="pubdef"><a id="flag:rc_thread"><strong>rc_thread</strong>(<var>bool</var>, changeable)</a></dt>
618 <dt class="pubdef"><a name="flag:gc_thread"><strong>gc_thread</strong>(<var>bool</var>)</a></dt>
661619 <dd class="defbody">
662620 If <code>true</code> (default if threading is enabled), atom and clause
663621 garbage collection are executed in a seperate thread with the
664622 <em>alias</em> <code>gc</code>. Otherwise the thread the detect
665623 sufficient garbage executes the garbage collector. As running these
666624 global collectors may take relatively using a seperate thread improves
667 real time behaviour.</dd>
668 <dt class="pubdef"><a id="flag:generate_debug_info"><strong>generate_debug_info</strong>(<var>bool</var>, changeable)</a></dt>
625 real time behaviour. The <code>gc</code> thread can be controlled using
626 <a name="idx:setprologgcthread1:115"></a><span class="pred-ext">set_prolog_gc_thread/1</span>.</dd>
627 <dt class="pubdef"><a name="flag:generate_debug_info"><strong>generate_debug_info</strong>(<var>bool</var>, changeable)</a></dt>
669628 <dd class="defbody">
670629 If <code>true</code> (default) generate code that can be debugged using
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>,
630 <a name="idx:trace0:116"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>, <a name="idx:spy1:117"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
672631 etc. Can be set to <code>false</code> using the
673632 <strong>-nodebug</strong>. This flag is scoped within a source file.
674633 Many of the libraries have
677636 the current implementation this only causes a flag to be set on the
678637 predicate that causes children to be hidden from the debugger. The name
679638 anticipates further changes to the compiler.</span></sup></dd>
680 <dt class="pubdef"><a id="flag:gmp_version"><strong>gmp_version</strong>(<var>integer</var>)</a></dt>
639 <dt class="pubdef"><a name="flag:gmp_version"><strong>gmp_version</strong>(<var>integer</var>)</a></dt>
681640 <dd class="defbody">
682641 If Prolog is linked with GMP, this flag gives the major version of the
683 GMP library used. See also <a class="sec" href="foreigninclude.html#sec:11.4.8">section
642 GMP library used. See also <a class="sec" href="foreigninclude.html">section
684643 11.4.8</a>.</dd>
685 <dt class="pubdef"><a id="flag:gui"><strong>gui</strong>(<var>bool</var>)</a></dt>
644 <dt class="pubdef"><a name="flag:gui"><strong>gui</strong>(<var>bool</var>)</a></dt>
686645 <dd class="defbody">
687646 Set to <code>true</code> if XPCE is around and can be used for graphics.</dd>
688 <dt class="pubdef"><a id="flag:history"><strong>history</strong>(<var>integer</var>, changeable)</a></dt>
647 <dt class="pubdef"><a name="flag:history"><strong>history</strong>(<var>integer</var>, changeable)</a></dt>
689648 <dd class="defbody">
690649 If <var><var>integer</var>&gt; 0</var>, support Unix <b>csh(1)</b>-like
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
650 history as described in <a class="sec" href="history.html">section 2.7</a>.
651 Otherwise, only support reusing commands through the command line
652 editor. The default is to set this Prolog flag to 0 if a command line
653 editor is provided (see Prolog flag
695654 <a class="flag" href="flags.html#flag:readline">readline</a>) and 15
696655 otherwise.</dd>
697 <dt class="pubdef"><a id="flag:home"><strong>home</strong>(<var>atom</var>)</a></dt>
656 <dt class="pubdef"><a name="flag:home"><strong>home</strong>(<var>atom</var>)</a></dt>
698657 <dd class="defbody">
699658 SWI-Prolog's notion of the home directory. SWI-Prolog uses its home
700659 directory to find its startup file as
702661 <code>&lt;<var>home</var>&gt;/boot64.prc</code> (64-bit machines) and to
703662 find its library as
704663 <code>&lt;<var>home</var>&gt;/library</code>.</dd>
705 <dt class="pubdef"><a id="flag:hwnd"><strong>hwnd</strong>(<var>integer</var>)</a></dt>
664 <dt class="pubdef"><a name="flag:hwnd"><strong>hwnd</strong>(<var>integer</var>)</a></dt>
706665 <dd class="defbody">
707666 In <b>swipl-win.exe</b>, this refers to the MS-Windows window handle of
708667 the console window.</dd>
709 <dt class="pubdef"><a id="flag:integer_rounding_function"><strong>integer_rounding_function</strong>(<var>down,toward_zero</var>)</a></dt>
668 <dt class="pubdef"><a name="flag:integer_rounding_function"><strong>integer_rounding_function</strong>(<var>down,toward_zero</var>)</a></dt>
710669 <dd class="defbody">
711670 ISO Prolog flag describing rounding by <code>//</code> and <code>rem</code>
712671 arithmetic functions. Value depends on the C compiler used.</dd>
713 <dt class="pubdef"><a id="flag:iso"><strong>iso</strong>(<var>bool</var>, changeable)</a></dt>
672 <dt class="pubdef"><a name="flag:iso"><strong>iso</strong>(<var>bool</var>, changeable)</a></dt>
714673 <dd class="defbody">
715674 Include some weird ISO compatibility that is incompatible with normal
716675 SWI-Prolog behaviour. Currently it has the following effect:
717676 <ul class="latex">
718677 <li>The <code><code>/</code>/2</code> (float division) <em>always</em>
719678 returns a float, even if applied to integers that can be divided.
720 <li>In the standard order of terms (see <a class="sec" href="compare.html#sec:4.7.1">section
679 <li>In the standard order of terms (see <a class="sec" href="compare.html">section
721680 4.7.1</a>), all floats are before all integers.
722 <li><a id="idx:atomlength2:116"></a><a class="pred" href="manipatom.html#atom_length/2">atom_length/2</a>
681 <li><a name="idx:atomlength2:118"></a><a class="pred" href="manipatom.html#atom_length/2">atom_length/2</a>
723682 yields a type error if the first argument is a number.
724 <li><a id="idx:clause23:117"></a><a class="pred" href="examineprog.html#clause/2">clause/[2,3]</a>
683 <li><a name="idx:clause23:119"></a><a class="pred" href="examineprog.html#clause/2">clause/[2,3]</a>
725684 raises a permission error when accessing static predicates.
726 <li><a id="idx:abolish12:118"></a><a class="pred" href="db.html#abolish/1">abolish/[1,2]</a>
685 <li><a name="idx:abolish12:120"></a><a class="pred" href="db.html#abolish/1">abolish/[1,2]</a>
727686 raises a permission error when accessing static predicates.
728687 <li>Syntax is closer to the ISO standard:
729688 <ul class="latex">
744703 == -, true.</code> write <code>X == (-), true.</code> Currently, this is
745704 not entirely enforced.
746705 <li>Backslash-escaped newlines are interpreted according to the ISO
747 standard. See <a class="sec" href="syntax.html#sec:2.16.1.3">section
748 2.16.1.3</a>.
706 standard. See <a class="sec" href="syntax.html">section 2.16.1.3</a>.
749707 </ul>
750708 </ul>
751709 </dd>
752 <dt class="pubdef"><a id="flag:large_files"><strong>large_files</strong>(<var>bool</var>)</a></dt>
710 <dt class="pubdef"><a name="flag:large_files"><strong>large_files</strong>(<var>bool</var>)</a></dt>
753711 <dd class="defbody">
754712 If present and <code>true</code>, SWI-Prolog has been compiled with
755713 <em>large file support</em> (LFS) and is capable of accessing files
756714 larger than 2GB on 32-bit hardware. Large file support is default on
757715 installations built using <b>configure</b> that support it and may be
758716 switched off using the configure option <code>--disable-largefile</code>.</dd>
759 <dt class="pubdef"><a id="flag:last_call_optimisation"><strong>last_call_optimisation</strong>(<var>bool</var>, changeable)</a></dt>
717 <dt class="pubdef"><a name="flag:last_call_optimisation"><strong>last_call_optimisation</strong>(<var>bool</var>, changeable)</a></dt>
760718 <dd class="defbody">
761719 Determines whether or not last-call optimisation is enabled. Normally
762720 the value of this flag is the negation of the <a class="flag" href="flags.html#flag:debug">debug</a>
763721 flag. As programs may run out of stack if last-call optimisation is
764722 omitted, it is sometimes necessary to enable it during debugging.</dd>
765 <dt class="pubdef"><a id="flag:max_arity"><strong>max_arity</strong>(<var>unbounded</var>)</a></dt>
723 <dt class="pubdef"><a name="flag:max_arity"><strong>max_arity</strong>(<var>unbounded</var>)</a></dt>
766724 <dd class="defbody">
767725 ISO Prolog flag describing there is no maximum arity to compound terms.</dd>
768 <dt class="pubdef"><a id="flag:max_integer"><strong>max_integer</strong>(<var>integer</var>)</a></dt>
726 <dt class="pubdef"><a name="flag:max_integer"><strong>max_integer</strong>(<var>integer</var>)</a></dt>
769727 <dd class="defbody">
770728 Maximum integer value if integers are <em>bounded</em>. See also the
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
729 flag <a class="flag" href="flags.html#flag:bounded">bounded</a> and <a class="sec" href="arith.html">section
772730 4.27.2.1</a>.</dd>
773 <dt class="pubdef"><a id="flag:max_tagged_integer"><strong>max_tagged_integer</strong>(<var>integer</var>)</a></dt>
731 <dt class="pubdef"><a name="flag:max_tagged_integer"><strong>max_tagged_integer</strong>(<var>integer</var>)</a></dt>
774732 <dd class="defbody">
775733 Maximum integer value represented as a `tagged' value. Tagged integers
776734 require one word storage. Larger integers are represented as `indirect
777735 data' and require significantly more space.</dd>
778 <dt class="pubdef"><a id="flag:min_integer"><strong>min_integer</strong>(<var>integer</var>)</a></dt>
736 <dt class="pubdef"><a name="flag:min_integer"><strong>min_integer</strong>(<var>integer</var>)</a></dt>
779737 <dd class="defbody">
780738 Minimum integer value if integers are <em>bounded</em>. See also the
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
739 flag <a class="flag" href="flags.html#flag:bounded">bounded</a> and <a class="sec" href="arith.html">section
782740 4.27.2.1</a>.</dd>
783 <dt class="pubdef"><a id="flag:min_tagged_integer"><strong>min_tagged_integer</strong>(<var>integer</var>)</a></dt>
741 <dt class="pubdef"><a name="flag:min_tagged_integer"><strong>min_tagged_integer</strong>(<var>integer</var>)</a></dt>
784742 <dd class="defbody">
785743 Start of the tagged-integer value range.</dd>
786 <dt class="pubdef"><a id="flag:occurs_check"><strong>occurs_check</strong>(<var>atom</var>, changeable)</a></dt>
744 <dt class="pubdef"><a name="flag:occurs_check"><strong>occurs_check</strong>(<var>atom</var>, changeable)</a></dt>
787745 <dd class="defbody">
788746 This flag controls unification that creates an infinite tree (also
789747 called <em>cyclic term</em>) and can have three values. Using
790748 <code>false</code> (default), unification succeeds, creating an infinite
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>,
749 tree. Using <code>true</code>, unification behaves as <a name="idx:unifywithoccurscheck2:121"></a><a class="pred" href="compare.html#unify_with_occurs_check/2">unify_with_occurs_check/2</a>,
792750 failing silently. Using <code>error</code>, an attempt to create a
793751 cyclic term results in an <code>occurs_check</code> exception. The
794752 latter is intended for debugging unintentional creations of cyclic
795753 terms. Note that this flag is a global flag modifying fundamental
796754 behaviour of Prolog. Changing the flag from its default may cause
797755 libraries to stop functioning properly.</dd>
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>
756 <dt class="pubdef"><a name="flag:open_shared_object"><strong>open_shared_object</strong>(<var>bool</var>)</a></dt>
757 <dd class="defbody">
758 If true, <a name="idx:opensharedobject2:122"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
801759 and friends are implemented, providing access to shared libraries (<code>.so</code>
802760 files) or dynamic link libraries (<code>.DLL</code> files).</dd>
803 <dt class="pubdef"><a id="flag:optimise"><strong>optimise</strong>(<var>bool</var>, changeable)</a></dt>
761 <dt class="pubdef"><a name="flag:optimise"><strong>optimise</strong>(<var>bool</var>, changeable)</a></dt>
804762 <dd class="defbody">
805763 If <code>true</code>, compile in optimised mode. The initial value is
806764 <code>true</code> if Prolog was started with the <strong>-O</strong>
808766 flag is scoped to a source file.
809767
810768 <p>Currently optimised compilation implies compilation of arithmetic,
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>.
769 and deletion of redundant <a name="idx:true0:123"></a><a class="pred" href="control.html#true/0">true/0</a>
770 that may result from <a name="idx:expandgoal2:124"></a><a class="pred" href="consulting.html#expand_goal/2">expand_goal/2</a>.
813771
814772 <p>Later versions might imply various other optimisations such as
815773 integrating small predicates into their callers, eliminating constant
816774 expressions and other predictable constructs. Source code optimisation
817775 is never applied to predicates that are declared dynamic (see
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>
776 <a name="idx:dynamic1:125"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>).</dd>
777 <dt class="pubdef"><a name="flag:os_argv"><strong>os_argv</strong>(<var>list</var>, changeable)</a></dt>
820778 <dd class="defbody">
821779 List is a list of atoms representing the command line arguments used to
822780 invoke SWI-Prolog. Please note that <b>all</b> arguments are included in
823781 the list returned. See <a class="flag" href="flags.html#flag:argv">argv</a>
824782 to get the application options.</dd>
825 <dt class="pubdef"><a id="flag:pid"><strong>pid</strong>(<var>int</var>)</a></dt>
783 <dt class="pubdef"><a name="flag:pid"><strong>pid</strong>(<var>int</var>)</a></dt>
826784 <dd class="defbody">
827785 Process identifier of the running Prolog process. Existence of this flag
828786 is implementation-defined.</dd>
829 <dt class="pubdef"><a id="flag:pipe"><strong>pipe</strong>(<var>bool</var>, changeable)</a></dt>
787 <dt class="pubdef"><a name="flag:pipe"><strong>pipe</strong>(<var>bool</var>, changeable)</a></dt>
830788 <dd class="defbody">
831789 If true, <code>open(pipe(command), mode, Stream)</code>, etc. are
832790 supported. Can be changed to disable the use of pipes in applications
833791 testing this feature. Not recommended.</dd>
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
792 <dt class="pubdef"><a name="flag:print_write_options"><strong>print_write_options</strong>(<var>term</var>, changeable)</a></dt>
793 <dd class="defbody">
794 Specifies the options for <a name="idx:writeterm2:126"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
795 used by <a name="idx:print1:127"></a><a class="pred" href="termrw.html#print/1">print/1</a>
796 and <a name="idx:print2:128"></a><a class="pred" href="termrw.html#print/2">print/2</a>.</dd>
797 <dt class="pubdef"><a name="flag:prompt_alternatives_on"><strong>prompt_alternatives_on</strong>(<var>atom</var>, changeable)</a></dt>
798 <dd class="defbody">
799 <a name="idx:promptalternatives:129"></a>Determines prompting for
842800 alternatives in the Prolog top level. Default is
843801 <code>determinism</code>, which implies the system prompts for
844802 alternatives if the goal succeeded while leaving choice points. Many
845803 classical Prolog systems behave as <code>groundness</code>: they prompt
846804 for alternatives if and only if the query contains variables.</dd>
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>
805 <dt class="pubdef"><a name="flag:protect_static_code"><strong>protect_static_code</strong>(<var>bool</var>, changeable)</a></dt>
806 <dd class="defbody">
807 If <code>true</code> (default <code>false</code>), <a name="idx:clause2:130"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
850808 does not operate on static code, providing some basic protection from
851809 hackers that wish to list the static code of your Prolog program. Once
852810 the flag is
853811 <code>true</code>, it cannot be changed back to <code>false</code>.
854812 Protection is default in ISO mode (see Prolog flag <a class="flag" href="flags.html#flag:iso">iso</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>
813 Note that many parts of the development environment require <a name="idx:clause2:131"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
856814 to work on static code, and enabling this flag should thus only be used
857815 for production code.</dd>
858 <dt class="pubdef"><a id="flag:qcompile"><strong>qcompile</strong>(<var>atom</var>, changeable)</a></dt>
816 <dt class="pubdef"><a name="flag:qcompile"><strong>qcompile</strong>(<var>atom</var>, changeable)</a></dt>
859817 <dd class="defbody">
860818 This option provides the default for the <code>qcompile(+Atom)</code>
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>
819 option of <a name="idx:loadfiles2:132"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
820 <dt class="pubdef"><a name="flag:readline"><strong>readline</strong>(<var>atom</var>, changeable)</a></dt>
863821 <dd class="defbody">
864822 Specifies which form of command line editing is provided. Possible
865823 values are below. The flag may be set from the user's init file (see
866 <a class="sec" href="initgoal.html#sec:2.3">section 2.3</a>) to one of <code>false</code>, <code>readline</code>
824 <a class="sec" href="initgoal.html">section 2.3</a>) to one of <code>false</code>, <code>readline</code>
867825 or
868826 <code>editline</code>. This causes the toplevel not to load a command
869827 line editor (<code>false</code>) or load the specified one. If loading
890848 </dl>
891849
892850 </dd>
893 <dt class="pubdef"><a id="flag:resource_database"><strong>resource_database</strong>(<var>atom</var>)</a></dt>
851 <dt class="pubdef"><a name="flag:resource_database"><strong>resource_database</strong>(<var>atom</var>)</a></dt>
894852 <dd class="defbody">
895853 Set to the absolute filename of the attached state. Typically this is
896854 the file <code>boot32.prc</code>, the file specified with <strong>-x</strong>
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>
855 or the running executable. See also <a name="idx:resource3:133"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.</dd>
856 <dt class="pubdef"><a name="flag:report_error"><strong>report_error</strong>(<var>bool</var>, changeable)</a></dt>
899857 <dd class="defbody">
900858 If <code>true</code>, print error messages; otherwise suppress them. May
901859 be changed. See also the <a class="flag" href="flags.html#flag:debug_on_error">debug_on_error</a>
902860 Prolog flag. Default is <code>true</code>, except for the runtime
903861 version.</dd>
904 <dt class="pubdef"><a id="flag:runtime"><strong>runtime</strong>(<var>bool</var>)</a></dt>
862 <dt class="pubdef"><a name="flag:runtime"><strong>runtime</strong>(<var>bool</var>)</a></dt>
905863 <dd class="defbody">
906864 If present and <code>true</code>, SWI-Prolog is compiled with
907865 -DO_RUNTIME, disabling various useful development features (currently
908866 the tracer and profiler).</dd>
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>
867 <dt class="pubdef"><a name="flag:sandboxed_load"><strong>sandboxed_load</strong>(<var>bool</var>, changeable)</a></dt>
868 <dd class="defbody">
869 If <code>true</code> (default <code>false</code>), <a name="idx:loadfiles2:134"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
912870 calls hooks to allow library(sandbox) to verify the safety of
913871 directives.</dd>
914 <dt class="pubdef"><a id="flag:saved_program"><strong>saved_program</strong>(<var>bool</var>)</a></dt>
872 <dt class="pubdef"><a name="flag:saved_program"><strong>saved_program</strong>(<var>bool</var>)</a></dt>
915873 <dd class="defbody">
916874 If present and <code>true</code>, Prolog has been started from a state
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>
875 saved with <a name="idx:qsaveprogram12:135"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.</dd>
876 <dt class="pubdef"><a name="flag:shared_object_extension"><strong>shared_object_extension</strong>(<var>atom</var>)</a></dt>
919877 <dd class="defbody">
920878 Extension used by the operating system for shared objects. <code>.so</code>
921879 for most Unix systems and <code>.dll</code> for Windows. Used for
922880 locating files using the <code>file_type</code> <code>executable</code>.
923881 See also
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>
882 <a name="idx:absolutefilename3:136"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
883 <dt class="pubdef"><a name="flag:shared_object_search_path"><strong>shared_object_search_path</strong>(<var>atom</var>)</a></dt>
926884 <dd class="defbody">
927885 Name of the environment variable used by the system to search for shared
928886 objects.</dd>
929 <dt class="pubdef"><a id="flag:signals"><strong>signals</strong>(<var>bool</var>)</a></dt>
887 <dt class="pubdef"><a name="flag:signals"><strong>signals</strong>(<var>bool</var>)</a></dt>
930888 <dd class="defbody">
931889 Determine whether Prolog is handling signals (software interrupts). This
932890 flag is <code>false</code> if the hosting OS does not support signal
933891 handling or the command line option <strong>-nosignals</strong> is
934892 active. See
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>
893 <a class="sec" href="foreigninclude.html">section 11.4.21.1</a> for
894 details.</dd>
895 <dt class="pubdef"><a name="flag:stream_type_check"><strong>stream_type_check</strong>(<var>atom</var>, changeable)</a></dt>
938896 <dd class="defbody">
939897 Defines whether and how strictly the system validates that byte I/O
940898 should not be applied to text streams and text I/O should not be applied
942900 (full checking) and <code>loose</code>. Using checking mode <code>loose</code>
943901 (default), the system accepts byte I/O from text stream that use ISO
944902 Latin-1 encoding and accepts writing text to binary streams.</dd>
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
903 <dt class="pubdef"><a name="flag:system_thread_id"><strong>system_thread_id</strong>(<var>int</var>)</a></dt>
904 <dd class="defbody">
905 Available in multithreaded version (see <a class="sec" href="threads.html">section
948906 9</a>) where the operating system provides system-wide integer thread
949907 identifiers. The integer is the thread identifier used by the operating
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>
908 system for the calling thread. See also <a name="idx:threadself1:137"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>.</dd>
909 <dt class="pubdef"><a name="flag:table_space"><strong>table_space</strong>(<var>integer</var>, changeable)</a></dt>
952910 <dd class="defbody">
953911 Space reserved for storing answer tables for <em>tabled predicates</em>
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
912 (see <a name="idx:table1:138"></a><a class="pred" href="tabling.html#table/1">table/1</a>).<sup class="fn">bug<span class="fn-text">Currently
955913 only counts the space occupied by the nodes in the answer tries.</span></sup>
956914 When exceeded a
957915 <code>resource_error(table_space)</code> exception is raised.</dd>
958 <dt class="pubdef"><a id="flag:timezone"><strong>timezone</strong>(<var>integer</var>)</a></dt>
916 <dt class="pubdef"><a name="flag:timezone"><strong>timezone</strong>(<var>integer</var>)</a></dt>
959917 <dd class="defbody">
960918 Offset in seconds west of GMT of the current time zone. Set at
961919 initialization time from the <code>timezone</code> variable associated
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>
920 with the POSIX tzset() function. See also <a name="idx:formattime3:139"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>.</dd>
921 <dt class="pubdef"><a name="flag:toplevel_goal"><strong>toplevel_goal</strong>(<var>term</var>, changeable)</a></dt>
964922 <dd class="defbody">
965923 Defines the goal that is executed after running the initialization goals
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>
924 and entry point (see <strong>-g</strong>, <a name="idx:initialization2:140"></a><a class="pred" href="consulting.html#initialization/2">initialization/2</a>
967925 and
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>.
926 <a class="sec" href="compilation.html">section 2.10.2.1</a>. The initial
927 value is <code>default</code>, starting a normal interactive session.
928 This value may be changed using the command line option <strong>-t</strong>.
971929 The explicit value <code>prolog</code> is equavalent to <code>default</code>.
972930 If <code>initialization(Goal,main)</code> is used and the toplevel is <code>default</code>,
973931 the toplevel is set to
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>
932 <code>halt</code> (see <a name="idx:halt0:141"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>).</dd>
933 <dt class="pubdef"><a name="flag:toplevel_mode"><strong>toplevel_mode</strong>(<var>atom</var>, changeable)</a></dt>
976934 <dd class="defbody">
977935 If <code>backtracking</code> (default), the toplevel backtracks after
978936 completing a query. If <code>recursive</code>, the toplevel is
979937 implemented as a recursive loop. This implies that global variables set
980938 using
981 <a id="idx:bsetval2:140"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
939 <a name="idx:bsetval2:142"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
982940 are maintained between queries. In <em>recursive</em> mode, answers to
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
941 toplevel variables (see <a class="sec" href="topvars.html">section 2.8</a>)
942 are kept in backtrackable global variables and thus <b>not copied</b>.
943 In
986944 <em>backtracking</em> mode answers to toplevel variables are kept in the
987 recorded database (see <a class="sec" href="db.html#sec:4.14.2">section
988 4.14.2</a>).
945 recorded database (see <a class="sec" href="db.html">section 4.14.2</a>).
989946
990947 <p>The recursive mode has been added for interactive usage of CHR (see
991 <a class="sec" href="chr.html#sec:8">section 8</a>),<sup class="fn">22<span class="fn-text">Suggested
948 <a class="sec" href="chr.html">section 8</a>),<sup class="fn">22<span class="fn-text">Suggested
992949 by Falco Nogatz</span></sup> which maintains the global constraint store
993950 in backtrackable global variables.</dd>
994 <dt class="pubdef"><a id="flag:toplevel_print_anon"><strong>toplevel_print_anon</strong>(<var>bool</var>, changeable)</a></dt>
951 <dt class="pubdef"><a name="flag:toplevel_print_anon"><strong>toplevel_print_anon</strong>(<var>bool</var>, changeable)</a></dt>
995952 <dd class="defbody">
996953 If <code>true</code>, top-level variables starting with an underscore (<code>_</code>)
997954 are printed normally. If <code>false</code> they are hidden. This may be
998955 used to hide bindings in complex queries from the top level.</dd>
999 <dt class="pubdef"><a id="flag:toplevel_print_factorized"><strong>toplevel_print_factorized</strong>(<var>bool</var>, changeable)</a></dt>
956 <dt class="pubdef"><a name="flag:toplevel_print_factorized"><strong>toplevel_print_factorized</strong>(<var>bool</var>, changeable)</a></dt>
1000957 <dd class="defbody">
1001958 If <code>true</code> (default <code>false</code>) show the internal
1002959 sharing of subterms in the answer substitution. The example below
1003960 reveals internal sharing of leaf nodes in <em>red-black trees</em> as
1004961 implemented by the
1005 <code>library(rbtrees)</code> predicate rb_new/1 :
962 <code>library(rbtrees)</code> predicate rb_new1:
1006963
1007964 <pre class="code">
1008965 ?- set_prolog_flag(toplevel_print_factorized, true).
1024981 </pre>
1025982
1026983 </dd>
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>
984 <dt class="pubdef"><a name="flag:answer_write_options"><strong>answer_write_options</strong>(<var>term</var>, changeable)</a></dt>
985 <dd class="defbody">
986 This argument is given as option-list to <a name="idx:writeterm2:143"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
1030987 for printing results of queries. Default is <code>[quoted(true),
1031988 portray(true), max_depth(10), attributes(portray)]</code>.</dd>
1032 <dt class="pubdef"><a id="flag:toplevel_prompt"><strong>toplevel_prompt</strong>(<var>atom</var>, changeable)</a></dt>
989 <dt class="pubdef"><a name="flag:toplevel_prompt"><strong>toplevel_prompt</strong>(<var>atom</var>, changeable)</a></dt>
1033990 <dd class="defbody">
1034991 Define the prompt that is used by the interactive top level. The
1035992 following <code>~</code> (tilde) sequences are replaced:
1036993
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>
994 <p><table border="2" frame="hsides" rules="groups" style="margin:auto">
995 <tr valign="top"><td><code><code>~</code></code>m</td><td><em>Type in</em>
996 module if not <code>user</code> (see <a name="idx:module1:144"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>) </td></tr>
997 <tr valign="top"><td><code><code>~</code></code>l</td><td><em>Break
998 level</em> if not 0 (see <a name="idx:break0:145"></a><a class="pred" href="toplevel.html#break/0">break/0</a>) </td></tr>
999 <tr valign="top"><td><code><code>~</code></code>d</td><td><em>Debugging
1000 state</em> if not normal execution (see <a name="idx:debug0:146"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>, <a name="idx:trace0:147"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>) </td></tr>
1001 <tr valign="top"><td><code><code>~</code></code>!</td><td><em>History
1002 event</em> if history is enabled (see flag <a class="flag" href="flags.html#flag:history">history</a>) </td></tr>
10461003 </table>
10471004 </dd>
1048 <dt class="pubdef"><a id="flag:toplevel_var_size"><strong>toplevel_var_size</strong>(<var>int</var>, changeable)</a></dt>
1005 <dt class="pubdef"><a name="flag:toplevel_var_size"><strong>toplevel_var_size</strong>(<var>int</var>, changeable)</a></dt>
10491006 <dd class="defbody">
10501007 Maximum size counted in literals of a term returned as a binding for a
10511008 variable in a top-level query that is saved for re-use using the
1052 <code><code>$</code></code> variable reference. See <a class="sec" href="topvars.html#sec:2.8">section
1009 <code><code>$</code></code> variable reference. See <a class="sec" href="topvars.html">section
10531010 2.8</a>.</dd>
1054 <dt class="pubdef"><a id="flag:trace_gc"><strong>trace_gc</strong>(<var>bool</var>, changeable)</a></dt>
1011 <dt class="pubdef"><a name="flag:trace_gc"><strong>trace_gc</strong>(<var>bool</var>, changeable)</a></dt>
10551012 <dd class="defbody">
10561013 If <code>true</code> (default <code>false</code>), garbage collections
10571014 and stack-shifts will be reported on the terminal. May be changed.
10671024 </pre>
10681025
10691026 </dd>
1070 <dt class="pubdef"><a id="flag:traditional"><strong>traditional</strong>(<var>bool</var>)</a></dt>
1027 <dt class="pubdef"><a name="flag:traditional"><strong>traditional</strong>(<var>bool</var>)</a></dt>
10711028 <dd class="defbody">
10721029 Available in SWI-Prolog version&nbsp;7. If <code>true</code>,
10731030 `traditional' mode has been selected using <strong>--traditional</strong>.
10741031 Notice that some SWI7 features, like the functional notation on dicts,
1075 do not work in this mode. See also <a class="sec" href="extensions.html#sec:5">section
1032 do not work in this mode. See also <a class="sec" href="extensions.html">section
10761033 5</a>.</dd>
1077 <dt class="pubdef"><a id="flag:tty_control"><strong>tty_control</strong>(<var>bool</var>, changeable)</a></dt>
1034 <dt class="pubdef"><a name="flag:tty_control"><strong>tty_control</strong>(<var>bool</var>, changeable)</a></dt>
10781035 <dd class="defbody">
10791036 Determines whether the terminal is switched to raw mode for
1080 <a id="idx:getsinglechar1:146"></a><a class="pred" href="chario.html#get_single_char/1">get_single_char/1</a>,
1037 <a name="idx:getsinglechar1:148"></a><a class="pred" href="chario.html#get_single_char/1">get_single_char/1</a>,
10811038 which also reads the user actions for the trace. May be set. If this
10821039 flag is <code>false</code> at startup, command line editing is disabled.
10831040 See also the <strong>+/-tty</strong> command line option.</dd>
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>
1041 <dt class="pubdef"><a name="flag:unix"><strong>unix</strong>(<var>bool</var>)</a></dt>
1042 <dd class="defbody">
1043 <a name="idx:unix:149"></a>If present and <code>true</code>, the
1044 operating system is some version of Unix. Defined if the C compiler used
1045 to compile this version of SWI-Prolog either defines <code>__unix__</code>
10891046 or <code>unix</code>. On other systems this flag is not available. See
10901047 also <a class="flag" href="flags.html#flag:apple">apple</a> and <a class="flag" href="flags.html#flag:windows">windows</a>.</dd>
1091 <dt class="pubdef"><a id="flag:unknown"><strong>unknown</strong>(<var>fail,warning,error</var>, changeable)</a></dt>
1048 <dt class="pubdef"><a name="flag:unknown"><strong>unknown</strong>(<var>fail,warning,error</var>, changeable)</a></dt>
10921049 <dd class="defbody">
10931050 Determines the behaviour if an undefined procedure is encountered. If
10941051 <code>fail</code>, the predicate fails silently. If <code>warn</code>, a
11001057 which in turn inherit the value <code>error</code> from <code>system</code>.
11011058 The user may change the flag for module <code>user</code> to change the
11021059 default for all application modules or for a specific module. It is
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>
1060 strongly advised to keep the <code>error</code> default and use <a name="idx:dynamic1:150"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>
1061 and/or <a name="idx:multifile1:151"></a><a class="pred" href="dynamic.html#multifile/1">multifile/1</a>
11051062 to specify possible non-existence of a predicate.</dd>
1106 <dt class="pubdef"><a id="flag:unload_foreign_libraries"><strong>unload_foreign_libraries</strong>(<var>bool</var>, changeable)</a></dt>
1063 <dt class="pubdef"><a name="flag:unload_foreign_libraries"><strong>unload_foreign_libraries</strong>(<var>bool</var>, changeable)</a></dt>
11071064 <dd class="defbody">
11081065 If <code>true</code> (default <code>false</code>), unload all loaded
11091066 foreign libraries. Default is <code>false</code> because modern OSes
11101067 reclaim the resources anyway and unloading the foreign code may cause
11111068 registered hooks to point to no longer existing data or code.</dd>
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>
1069 <dt class="pubdef"><a name="flag:user_flags"><strong>user_flags</strong>(<var>Atom</var>, changeable)</a></dt>
1070 <dd class="defbody">
1071 Define the behaviour of <a name="idx:setprologflag2:152"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
11151072 if the flag is not known. Values are <code>silent</code>, <code>warning</code>
11161073 and <code>error</code>. The first two create the flag on-the-fly, where <code>warning</code>
11171074 prints a message. The value <code>error</code> is consistent with ISO:
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>.
1075 it raises an existence error and does not create the flag. See also <a name="idx:createprologflag3:153"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>.
11191076 The default is <code>silent</code>, but future versions may change that.
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>
1077 Developers are encouraged to use another value and ensure proper use of <a name="idx:createprologflag3:154"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
11211078 to create flags for their library.</dd>
1122 <dt class="pubdef"><a id="flag:var_prefix"><strong>var_prefix</strong>(<var>bool</var>, changeable)</a></dt>
1079 <dt class="pubdef"><a name="flag:var_prefix"><strong>var_prefix</strong>(<var>bool</var>, changeable)</a></dt>
11231080 <dd class="defbody">
11241081 If <code>true</code> (default <code>false</code>), variables must start
11251082 with an underscore (<code>_</code>). May be changed. This flag is local
1126 to the module in which it is changed. See <a class="sec" href="syntax.html#sec:2.16.1.7">section
1083 to the module in which it is changed. See <a class="sec" href="syntax.html">section
11271084 2.16.1.7</a>.</dd>
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>.
1085 <dt class="pubdef"><a name="flag:verbose"><strong>verbose</strong>(<var>atom</var>, changeable)</a></dt>
1086 <dd class="defbody">
1087 This flag is used by <a name="idx:printmessage2:155"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
11311088 If its value is <code>silent</code>, messages of type <code>informational</code>
11321089 and <code>banner</code> are suppressed. The <strong>-q</strong> switches
11331090 the value from the initial
11341091 <code>normal</code> to <code>silent</code>.</dd>
1135 <dt class="pubdef"><a id="flag:verbose_autoload"><strong>verbose_autoload</strong>(<var>bool</var>, changeable)</a></dt>
1092 <dt class="pubdef"><a name="flag:verbose_autoload"><strong>verbose_autoload</strong>(<var>bool</var>, changeable)</a></dt>
11361093 <dd class="defbody">
11371094 If <code>true</code> the normal consult message will be printed if a
11381095 library is autoloaded. By default this message is suppressed. Intended
11391096 to be used for debugging purposes.</dd>
1140 <dt class="pubdef"><a id="flag:verbose_load"><strong>verbose_load</strong>(<var>atom</var>, changeable)</a></dt>
1097 <dt class="pubdef"><a name="flag:verbose_load"><strong>verbose_load</strong>(<var>atom</var>, changeable)</a></dt>
11411098 <dd class="defbody">
11421099 Determines messages printed for loading (compiling) Prolog files.
11431100 Current values are <code>full</code> (print a message at the start and
11461103 loading the toplevel file), and <code>silent</code> (no messages are
11471104 printed, default). The value of this flag is normally controlled by the
11481105 option
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>
1106 <code>silent(Bool)</code> provided by <a name="idx:loadfiles2:156"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.</dd>
1107 <dt class="pubdef"><a name="flag:verbose_file_search"><strong>verbose_file_search</strong>(<var>bool</var>, changeable)</a></dt>
11511108 <dd class="defbody">
11521109 If <code>true</code> (default <code>false</code>), print messages
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>
1110 indicating the progress of <a name="idx:absolutefilename23:157"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/[2,3]</a>
11541111 in locating files. Intended for debugging complicated file-search paths.
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>
1112 See also <a name="idx:filesearchpath2:158"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.</dd>
1113 <dt class="pubdef"><a name="flag:version"><strong>version</strong>(<var>integer</var>)</a></dt>
11571114 <dd class="defbody">
11581115 The version identifier is an integer with value:
11591116 <blockquote><var>10000 &times; <var>Major</var> + 100 &times; <var>Minor</var>
11601117 + <var>Patch</var></var></blockquote>
11611118 </dd>
1162 <dt class="pubdef"><a id="flag:version_data"><strong>version_data</strong>(<var>swi(Major, Minor, Patch, Extra)</var>)</a></dt>
1119 <dt class="pubdef"><a name="flag:version_data"><strong>version_data</strong>(<var>swi(Major, Minor, Patch, Extra)</var>)</a></dt>
11631120 <dd class="defbody">
11641121 Part of the dialect compatibility layer; see also the Prolog flag
1165 <a class="flag" href="flags.html#flag:dialect">dialect</a> and <a class="sec" href="dialect.html#sec:C">section
1122 <a class="flag" href="flags.html#flag:dialect">dialect</a> and <a class="sec" href="dialect.html">section
11661123 C</a>. <var>Extra</var> provides platform-specific version information
11671124 as a list. <var>Extra</var> is used for
11681125 <em>tagged versions</em> such as ``7.4.0-rc1'', in which case
11691126 <var>Extra</var> contains a term <code>tag(rc1)</code>.</dd>
1170 <dt class="pubdef"><a id="flag:version_git"><strong>version_git</strong>(<var>atom</var>)</a></dt>
1127 <dt class="pubdef"><a name="flag:version_git"><strong>version_git</strong>(<var>atom</var>)</a></dt>
11711128 <dd class="defbody">
11721129 Available if created from a git repository. See <b>git-describe</b> for
11731130 details.</dd>
1174 <dt class="pubdef"><a id="flag:warn_override_implicit_import"><strong>warn_override_implicit_import</strong>(<var>bool</var>, changeable)</a></dt>
1131 <dt class="pubdef"><a name="flag:warn_override_implicit_import"><strong>warn_override_implicit_import</strong>(<var>bool</var>, changeable)</a></dt>
11751132 <dd class="defbody">
11761133 If <code>true</code> (default), a warning is printed if an implicitly
11771134 imported predicate is clobbered by a local definition. See
1178 <a id="idx:usemodule1:157"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
1135 <a name="idx:usemodule1:159"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
11791136 for details.</dd>
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>
1137 <dt class="pubdef"><a name="flag:win_file_access_check"><strong>win_file_access_check</strong>(<var>atom</var>, changeable)</a></dt>
1138 <dd class="defbody">
1139 Controls the behaviour or <a name="idx:accessfile2:160"></a><a class="pred" href="files.html#access_file/2">access_file/2</a>
11831140 under Windows. There is no reliable way to check access to files and
11841141 directories on Windows. This flag allows for switching between three
11851142 alternative approximations.
12051162 </dl>
12061163
12071164 </dd>
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
1165 <dt class="pubdef"><a name="flag:windows"><strong>windows</strong>(<var>bool</var>)</a></dt>
1166 <dd class="defbody">
1167 <a name="idx:windows:161"></a>If present and <code>true</code>, the
12111168 operating system is an implementation of Microsoft Windows. This flag is
12121169 only available on MS-Windows based versions. See also <a class="flag" href="flags.html#flag:unix">unix</a>.</dd>
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>
1170 <dt class="pubdef"><a name="flag:write_attributes"><strong>write_attributes</strong>(<var>atom</var>, changeable)</a></dt>
1171 <dd class="defbody">
1172 Defines how <a name="idx:write1:162"></a><a class="pred" href="termrw.html#write/1">write/1</a>
12161173 and friends write attributed variables. The option values are described
12171174 with the <code>attributes</code> option of
1218 <a id="idx:writeterm3:161"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
1175 <a name="idx:writeterm3:163"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
12191176 Default is <code>ignore</code>.</dd>
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>
1177 <dt class="pubdef"><a name="flag:write_help_with_overstrike"><strong>write_help_with_overstrike</strong>(<var>bool</var>)</a></dt>
1178 <dd class="defbody">
1179 Internal flag used by <a name="idx:help1:164"></a><a class="pred" href="help.html#help/1">help/1</a>
12231180 when writing to a terminal. If present and <code>true</code> it prints
12241181 bold and underlined text using
12251182 <em>overstrike</em>.</dd>
1226 <dt class="pubdef"><a id="flag:xpce"><strong>xpce</strong>(<var>bool</var>)</a></dt>
1183 <dt class="pubdef"><a name="flag:xpce"><strong>xpce</strong>(<var>bool</var>)</a></dt>
12271184 <dd class="defbody">
12281185 Available and set to <code>true</code> if the XPCE graphics system is
12291186 loaded.</dd>
1230 <dt class="pubdef"><a id="flag:xpce_version"><strong>xpce_version</strong>(<var>atom</var>)</a></dt>
1187 <dt class="pubdef"><a name="flag:xpce_version"><strong>xpce_version</strong>(<var>atom</var>)</a></dt>
12311188 <dd class="defbody">
12321189 Available and set to the version of the loaded XPCE system.</dd>
1233 <dt class="pubdef"><a id="flag:xref"><strong>xref</strong>(<var>bool</var>, changeable)</a></dt>
1190 <dt class="pubdef"><a name="flag:xref"><strong>xref</strong>(<var>bool</var>, changeable)</a></dt>
12341191 <dd class="defbody">
12351192 If <code>true</code>, source code is being read for <em>analysis</em>
12361193 purposes such as cross-referencing. Otherwise (default) it is being read
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>
1194 to be compiled. This flag is used at several places by <a name="idx:termexpansion2:165"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
12381195 and
1239 <a id="idx:goalexpansion2:164"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
1196 <a name="idx:goalexpansion2:166"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
12401197 hooks, notably if these hooks use side effects. See also the libraries <code>library(prolog_source)</code>
12411198 and <code>library(prolog_xref)</code>.
12421199 </dd>
12431200 </dl>
12441201
12451202 </dd>
1246 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="set_prolog_flag/2"><strong>set_prolog_flag</strong>(<var>:Key,
1203 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="set_prolog_flag/2"><strong>set_prolog_flag</strong>(<var>:Key,
12471204 +Value</var>)</a></dt>
12481205 <dd class="defbody">
12491206 Define a new Prolog flag or change its value. <var>Key</var> is an atom.
12681225
12691226 <p>The behaviour when <var>Key</var> denotes a non-existent key depends
12701227 on the Prolog flag <a class="flag" href="flags.html#flag:user_flags">user_flags</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>
1228 The default is to define them silently. New code is encouraged to use <a name="idx:createprologflag3:167"></a><a class="pred" href="flags.html#create_prolog_flag/3">create_prolog_flag/3</a>
12721229 for portability.</dd>
1273 <dt class="pubdef"><span class="pred-tag">[YAP]</span><a id="create_prolog_flag/3"><strong>create_prolog_flag</strong>(<var>+Key,
1230 <dt class="pubdef"><span class="pred-tag">[YAP]</span><a name="create_prolog_flag/3"><strong>create_prolog_flag</strong>(<var>+Key,
12741231 +Value, +Options</var>)</a></dt>
12751232 <dd class="defbody">
12761233 Create a new Prolog flag. The ISO standard does not foresee creation of
12911248 <dt><strong>keep</strong>(<var>+Boolean</var>)</dt>
12921249 <dd class="defbody">
12931250 If <code>true</code>, do not modify the flag if it already exists.
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>
1251 Otherwise (default), this predicate behaves as <a name="idx:setprologflag2:168"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
12951252 if the flag already exists.
12961253 </dd>
12971254 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.31</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="allsolutions.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="format.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <dl class="latex">
240 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="forall/2"><strong>forall</strong>(<var>:Cond,
199 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="forall/2"><strong>forall</strong>(<var>:Cond,
241200 :Action</var>)</a></dt>
242201 <dd class="defbody">
243202 For all alternative bindings of <var>Cond</var>, <var>Action</var> can
250209 Result =:= Formula).
251210 </pre>
252211
253 <p>The predicate <a id="idx:forall2:1375"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
212 <p>The predicate <a name="idx:forall2:1377"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
254213 is implemented as <code>\+ ( Cond, \+ Action)</code>, i.e., <i>There is
255214 no instantiation of <var>Cond</var> for which <var>Action</var> is
256215 false.</i>. The use of double negation implies that
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>
216 <a name="idx:forall2:1378"></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:1379"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
259218 control structure can be used for its side-effects. E.g., the following
260219 asserts relations in a list into the dynamic database:
261220
264223 assertz(child_of(Child, Parent))).
265224 </pre>
266225
267 <p>Using <a id="idx:forall2:1378"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
226 <p>Using <a name="idx:forall2:1380"></a><a class="pred" href="forall2.html#forall/2">forall/2</a>
268227 as <code>forall(Generator, SideEffect)</code> is preferred over the
269228 classical <em>failure driven loop</em> as shown below because it makes
270229 it explicit which part of the construct is the generator and which part
282241 )
283242 </pre>
284243
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>.
244 <p>If your intent is to create variable bindings, the <a name="idx:forall2:1381"></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:1382"></a><a class="pred" href="apply.html#maplist/2">maplist/2</a>,
246 <a name="idx:findall3:1383"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a>
247 or <a name="idx:foreach2:1384"></a><a class="pred" href="aggregate.html#foreach/2">foreach/2</a>.
289248 </dd>
290249 </dl>
291250
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="engine-predicates.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreignoverview.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:foreign"><a id="sec:11"><span class="sec-nr">11</span> <span class="sec-title">Foreign
194 <h1 id="sec:foreign"><a name="sec:11"><span class="sec-nr">11</span> <span class="sec-title">Foreign
236195 Language Interface</span></a></h1>
237196
238 <a id="sec:foreign"></a>
197 <a name="sec:foreign"></a>
239198
240199 <p>SWI-Prolog offers a powerful interface to C <cite><a class="cite" href="Bibliography.html#Kernighan:78">Kernighan &amp;
241200 Ritchie, 1978</a></cite>. The main design objectives of the foreign
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreigntypes.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="plld.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:foreigninclude"><a id="sec:11.4"><span class="sec-nr">11.4</span> <span class="sec-title">The
194 <h2 id="sec:foreigninclude"><a name="sec:11.4"><span class="sec-nr">11.4</span> <span class="sec-title">The
236195 Foreign Include File</span></a></h2>
237196
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
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
241200 Passing and Control</span></a></h3>
242201
243 <a id="sec:foreign-control"></a>
202 <a name="sec:foreign-control"></a>
244203
245204 <p>If Prolog encounters a foreign predicate at run time it will call a
246205 function specified in the predicate definition of the foreign predicate.
251210 alternatives to return control back to Prolog:
252211
253212 <dl class="latex">
254 <dt class="pubdef"><a id="PL_succeed()"><var>(return) foreign_t</var> <strong>PL_succeed</strong>(<var></var>)</a></dt>
213 <dt class="pubdef"><a name="PL_succeed()"><var>(return) foreign_t</var> <strong>PL_succeed</strong>(<var></var>)</a></dt>
255214 <dd class="defbody">
256215 Succeed deterministically. PL_succeed is defined as
257216 <code>return <code>TRUE</code></code>.
258217 </dd>
259 <dt class="pubdef"><a id="PL_fail()"><var>(return) foreign_t</var> <strong>PL_fail</strong>(<var></var>)</a></dt>
218 <dt class="pubdef"><a name="PL_fail()"><var>(return) foreign_t</var> <strong>PL_fail</strong>(<var></var>)</a></dt>
260219 <dd class="defbody">
261220 Fail and start Prolog backtracking. PL_fail is defined as <code>return <code>FALSE</code></code>.
262221 </dd>
263222 </dl>
264223
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
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
266225 Foreign Predicates</span></a></h4>
267226
268 <a id="sec:foreignnondet"></a>
227 <a name="sec:foreignnondet"></a>
269228
270229 <p>By default foreign predicates are deterministic. Using the
271230 <code>PL_FA_NONDETERMINISTIC</code> attribute (see <a class="func" href="foreigninclude.html#PL_register_foreign()">PL_register_foreign()</a>)
315274 <code>PL_foreign_context*()</code> macro.
316275
317276 <dl class="latex">
318 <dt class="pubdef"><a id="PL_retry()"><var>(return) foreign_t</var> <strong>PL_retry</strong>(<var>intptr_t
277 <dt class="pubdef"><a name="PL_retry()"><var>(return) foreign_t</var> <strong>PL_retry</strong>(<var>intptr_t
319278 value</var>)</a></dt>
320279 <dd class="defbody">
321280 The foreign function succeeds while leaving a choice point. On
327286 or 62 bits (two bits are used for status indication). Defined as <code>return
328287 _<a class="func" href="foreigninclude.html#PL_retry()">PL_retry(n)</a></code>.
329288 See also <a class="func" href="foreigninclude.html#PL_succeed()">PL_succeed()</a>.</dd>
330 <dt class="pubdef"><a id="PL_retry_address()"><var>(return) foreign_t</var> <strong>PL_retry_address</strong>(<var>void
289 <dt class="pubdef"><a name="PL_retry_address()"><var>(return) foreign_t</var> <strong>PL_retry_address</strong>(<var>void
331290 *</var>)</a></dt>
332291 <dd class="defbody">
333292 As <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a>,
335294 Defined as <code>return _<a class="func" href="foreigninclude.html#PL_retry_address()">PL_retry_address(n)</a></code>.
336295 See also
337296 <a class="func" href="foreigninclude.html#PL_succeed()">PL_succeed()</a>.</dd>
338 <dt class="pubdef"><a id="PL_foreign_control()"><var>int</var> <strong>PL_foreign_control</strong>(<var>control_t</var>)</a></dt>
297 <dt class="pubdef"><a name="PL_foreign_control()"><var>int</var> <strong>PL_foreign_control</strong>(<var>control_t</var>)</a></dt>
339298 <dd class="defbody">
340299 Extracts the type of call from the control argument. The return values
341300 are described above. Note that the function should be prepared to handle
342301 the <code>PL_PRUNED</code> case and should be aware that the other
343302 arguments are not valid in this case.</dd>
344 <dt class="pubdef"><a id="PL_foreign_context()"><var>intptr_t</var> <strong>PL_foreign_context</strong>(<var>control_t</var>)</a></dt>
303 <dt class="pubdef"><a name="PL_foreign_context()"><var>intptr_t</var> <strong>PL_foreign_context</strong>(<var>control_t</var>)</a></dt>
345304 <dd class="defbody">
346305 Extracts the context from the context argument. If the call type is
347306 <code>PL_FIRST_CALL</code> the context value is 0L. Otherwise it is the
348307 value returned by the last <a class="func" href="foreigninclude.html#PL_retry()">PL_retry()</a>
349308 associated with this goal (both if the call type is <code>PL_REDO</code>
350309 or <code>PL_PRUNED</code>).</dd>
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>
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>
352311 <dd class="defbody">
353312 Extracts an address as passed in by <a class="func" href="foreigninclude.html#PL_retry_address()">PL_retry_address()</a>.</dd>
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>
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>
355314 <dd class="defbody">
356315
357316 <p>Fetch the Prolog predicate that is executing this function. Note that
402361
403362 <div class="caption"><b>Figure 6 : </b>Skeleton for non-deterministic
404363 foreign functions</div>
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
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
408367 and functors</span></a></h3>
409368
410 <a id="sec:foreign-atoms"></a>
369 <a name="sec:foreign-atoms"></a>
411370
412371 <p>The following functions provide for communication using atoms and
413372 functors.
414373
415374 <dl class="latex">
416 <dt class="pubdef"><a id="PL_new_atom()"><var>atom_t</var> <strong>PL_new_atom</strong>(<var>const
375 <dt class="pubdef"><a name="PL_new_atom()"><var>atom_t</var> <strong>PL_new_atom</strong>(<var>const
417376 char *</var>)</a></dt>
418377 <dd class="defbody">
419378 Return an atom handle for the given C-string. This function always
420379 succeeds. The returned handle is valid as long as the atom is referenced
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>
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>
425384 and <code>ATOM_dot</code> is the same as
426385 <code><a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom(".")</a></code>.
427386 This is no long the case in SWI-Prolog version&nbsp;7.
428387
429388 <dl class="latex">
430 <dt class="pubdef"><a id="ATOM_nil()"><var>atom_t</var> <strong>ATOM_nil</strong>(<var>ATOM_nil</var>)</a></dt>
389 <dt class="pubdef"><a name="ATOM_nil()"><var>atom_t</var> <strong>ATOM_nil</strong>(<var>ATOM_nil</var>)</a></dt>
431390 <dd class="defbody">
432391 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>
433392 or <a class="func" href="foreigninclude.html#PL_unify_nil()">PL_unify_nil()</a>
434393 where applicable.</dd>
435 <dt class="pubdef"><a id="ATOM_dot()"><var>atom_t</var> <strong>ATOM_dot</strong>(<var>ATOM_dot</var>)</a></dt>
394 <dt class="pubdef"><a name="ATOM_dot()"><var>atom_t</var> <strong>ATOM_dot</strong>(<var>ATOM_dot</var>)</a></dt>
436395 <dd class="defbody">
437396 tomic constant that represents the name of the list constructor. The
438397 list constructor itself is created using
445404 </dl>
446405
447406 </dd>
448 <dt class="pubdef"><a id="PL_new_atom_mbchars()"><var>atom_t</var> <strong>PL_new_atom_mbchars</strong>(<var>int
407 <dt class="pubdef"><a name="PL_new_atom_mbchars()"><var>atom_t</var> <strong>PL_new_atom_mbchars</strong>(<var>int
449408 rep, size_t len, const char *s</var>)</a></dt>
450409 <dd class="defbody">
451410 This function generalizes <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>
456415 If
457416 <var>len</var> is <code>(size_t)-1</code>, it is computed from <var>s</var>
458417 using strlen().</dd>
459 <dt class="pubdef"><a id="PL_atom_chars()"><var>const char*</var> <strong>PL_atom_chars</strong>(<var>atom_t
418 <dt class="pubdef"><a name="PL_atom_chars()"><var>const char*</var> <strong>PL_atom_chars</strong>(<var>atom_t
460419 atom</var>)</a></dt>
461420 <dd class="defbody">
462421 Return a C-string for the text represented by the given atom. The
463422 returned text will not be changed by Prolog. It is not allowed to modify
464423 the contents, not even `temporary' as the string may reside in read-only
465424 memory. The returned string becomes invalid if the atom is garbage
466 collected (see <a class="sec" href="foreigninclude.html#sec:11.4.2.1">section
425 collected (see <a class="sec" href="foreigninclude.html">section
467426 11.4.2.1</a>). Foreign functions that require the text from an atom
468427 passed in a <code>term_t</code> normally use
469428 <a class="func" href="foreigninclude.html#PL_get_atom_chars()">PL_get_atom_chars()</a>
470429 or <a class="func" href="foreigninclude.html#PL_get_atom_nchars()">PL_get_atom_nchars()</a>.</dd>
471 <dt class="pubdef"><a id="PL_new_functor()"><var>functor_t</var> <strong>PL_new_functor</strong>(<var>atom_t
430 <dt class="pubdef"><a name="PL_new_functor()"><var>functor_t</var> <strong>PL_new_functor</strong>(<var>atom_t
472431 name, int arity</var>)</a></dt>
473432 <dd class="defbody">
474433 Returns a <em>functor identifier</em>, a handle for the name/arity pair.
475434 The returned handle is valid for the entire Prolog session.
476435 </dd>
477 <dt class="pubdef"><a id="PL_functor_name()"><var>atom_t</var> <strong>PL_functor_name</strong>(<var>functor_t
436 <dt class="pubdef"><a name="PL_functor_name()"><var>atom_t</var> <strong>PL_functor_name</strong>(<var>functor_t
478437 f</var>)</a></dt>
479438 <dd class="defbody">
480439 Return an atom representing the name of the given functor.
481440 </dd>
482 <dt class="pubdef"><a id="PL_functor_arity()"><var>size_t</var> <strong>PL_functor_arity</strong>(<var>functor_t
441 <dt class="pubdef"><a name="PL_functor_arity()"><var>size_t</var> <strong>PL_functor_arity</strong>(<var>functor_t
483442 f</var>)</a></dt>
484443 <dd class="defbody">
485444 Return the arity of the given functor.
486445 </dd>
487446 </dl>
488447
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
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
490449 and atom garbage collection</span></a></h4>
491450
492 <a id="sec:atomgc"></a>
451 <a name="sec:atomgc"></a>
493452
494453 <p>With the introduction of atom garbage collection in version 3.3.0,
495454 atoms no longer live as long as the process. Instead, their lifetime is
496455 guaranteed only as long as they are referenced. In the single-threaded
497456 version, atom garbage collections are only invoked at the
498 <em>call-port</em>. In the multithreaded version (see <a class="sec" href="threads.html#sec:9">chapter
457 <em>call-port</em>. In the multithreaded version (see <a class="sec" href="threads.html">chapter
499458 9</a>), they appear asynchronously, except for the invoking thread.
500459
501460 <p>For dealing with atom garbage collection, two additional functions
502461 are provided:
503462
504463 <dl class="latex">
505 <dt class="pubdef"><a id="PL_register_atom()"><var>void</var> <strong>PL_register_atom</strong>(<var>atom_t
464 <dt class="pubdef"><a name="PL_register_atom()"><var>void</var> <strong>PL_register_atom</strong>(<var>atom_t
506465 atom</var>)</a></dt>
507466 <dd class="defbody">
508467 Increment the reference count of the atom by one. <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>
509468 performs this automatically, returning an atom with a reference count of
510 at least one.<sup class="fn">170<span class="fn-text">Otherwise
469 at least one.<sup class="fn">169<span class="fn-text">Otherwise
511470 asynchronous atom garbage collection might destroy the atom before it is
512471 used.</span></sup></dd>
513 <dt class="pubdef"><a id="PL_unregister_atom()"><var>void</var> <strong>PL_unregister_atom</strong>(<var>atom_t
472 <dt class="pubdef"><a name="PL_unregister_atom()"><var>void</var> <strong>PL_unregister_atom</strong>(<var>atom_t
514473 atom</var>)</a></dt>
515474 <dd class="defbody">
516475 Decrement the reference count of the atom. If the reference count drops
531490 advised to use the *_chars() or *_nchars() functions whenever
532491 applicable.
533492
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
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
535494 Terms via the Foreign Interface</span></a></h3>
536495
537 <a id="sec:foreign-term-analysis"></a>
496 <a name="sec:foreign-term-analysis"></a>
538497
539498 <p>Each argument of a foreign function (except for the control argument)
540499 is of type <code>term_t</code>, an opaque handle to a Prolog term. Three
541500 groups of functions are available for the analysis of terms. The first
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>,
501 just validates the type, like the Prolog predicates <a name="idx:var1:2018"></a><a class="pred" href="typetest.html#var/1">var/1</a>, <a name="idx:atom1:2019"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>,
543502 etc., and are called <code>PL_is_*()</code>. The second group attempts
544503 to translate the argument into a C primitive type. These predicates take
545504 a <code>term_t</code> and a pointer to the appropriate C type and return <code>TRUE</code>
547506 <code>FALSE</code> depending on successful or unsuccessful translation.
548507 If the translation fails, the pointed-to data is never modified.
549508
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
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
551510 the type of a term</span></a></h4>
552511
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>
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>
557516 <dd class="defbody">
558517 Obtain the type of a term, which should be a term returned by one of the
559518 other interface predicates or passed as an argument. The function
582541 classify <code>PL_NIL</code> and <code>PL_BLOB</code> as <code>PL_ATOM</code>,
583542 <code>PL_LIST_PAIR</code> as <code>PL_TERM</code> and do not have dicts.
584543
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
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
591550 11.4.7.2</a>) </td></tr>
592 <tr><td><code>PL_STRING</code> </td><td>A string (see <a class="sec" href="strings.html#sec:5.2">section
551 <tr valign="top"><td><code>PL_STRING</code> </td><td>A string (see <a class="sec" href="strings.html">section
593552 5.2</a>) </td></tr>
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
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
599559 5.4</a>)) </td></tr>
600560 </table>
601561 </dd>
611571 functions below. All these functions return either <code>TRUE</code> or <code>FALSE</code>.
612572
613573 <dl class="latex">
614 <dt class="pubdef"><a id="PL_is_variable()"><var>int</var> <strong>PL_is_variable</strong>(<var>term_t</var>)</a></dt>
574 <dt class="pubdef"><a name="PL_is_variable()"><var>int</var> <strong>PL_is_variable</strong>(<var>term_t</var>)</a></dt>
615575 <dd class="defbody">
616576 Returns non-zero if <var>term</var> is a variable.</dd>
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>.
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:2020"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>.
620580 This function is cycle-safe.</dd>
621 <dt class="pubdef"><a id="PL_is_atom()"><var>int</var> <strong>PL_is_atom</strong>(<var>term_t</var>)</a></dt>
581 <dt class="pubdef"><a name="PL_is_atom()"><var>int</var> <strong>PL_is_atom</strong>(<var>term_t</var>)</a></dt>
622582 <dd class="defbody">
623583 Returns non-zero if <var>term</var> is an atom.</dd>
624 <dt class="pubdef"><a id="PL_is_string()"><var>int</var> <strong>PL_is_string</strong>(<var>term_t</var>)</a></dt>
584 <dt class="pubdef"><a name="PL_is_string()"><var>int</var> <strong>PL_is_string</strong>(<var>term_t</var>)</a></dt>
625585 <dd class="defbody">
626586 Returns non-zero if <var>term</var> is a string.</dd>
627 <dt class="pubdef"><a id="PL_is_integer()"><var>int</var> <strong>PL_is_integer</strong>(<var>term_t</var>)</a></dt>
587 <dt class="pubdef"><a name="PL_is_integer()"><var>int</var> <strong>PL_is_integer</strong>(<var>term_t</var>)</a></dt>
628588 <dd class="defbody">
629589 Returns non-zero if <var>term</var> is an integer.</dd>
630 <dt class="pubdef"><a id="PL_is_float()"><var>int</var> <strong>PL_is_float</strong>(<var>term_t</var>)</a></dt>
590 <dt class="pubdef"><a name="PL_is_float()"><var>int</var> <strong>PL_is_float</strong>(<var>term_t</var>)</a></dt>
631591 <dd class="defbody">
632592 Returns non-zero if <var>term</var> is a float.</dd>
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>
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:2021"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>
636596 for details.</dd>
637 <dt class="pubdef"><a id="PL_is_compound()"><var>int</var> <strong>PL_is_compound</strong>(<var>term_t</var>)</a></dt>
597 <dt class="pubdef"><a name="PL_is_compound()"><var>int</var> <strong>PL_is_compound</strong>(<var>term_t</var>)</a></dt>
638598 <dd class="defbody">
639599 Returns non-zero if <var>term</var> is a compound term.</dd>
640 <dt class="pubdef"><a id="PL_is_functor()"><var>int</var> <strong>PL_is_functor</strong>(<var>term_t,
600 <dt class="pubdef"><a name="PL_is_functor()"><var>int</var> <strong>PL_is_functor</strong>(<var>term_t,
641601 functor_t</var>)</a></dt>
642602 <dd class="defbody">
643603 Returns non-zero if <var>term</var> is compound and its functor is <var>functor</var>.
644604 This test is equivalent to <a class="func" href="foreigninclude.html#PL_get_functor()">PL_get_functor()</a>,
645605 followed by testing the functor, but easier to write and faster.</dd>
646 <dt class="pubdef"><a id="PL_is_list()"><var>int</var> <strong>PL_is_list</strong>(<var>term_t</var>)</a></dt>
606 <dt class="pubdef"><a name="PL_is_list()"><var>int</var> <strong>PL_is_list</strong>(<var>term_t</var>)</a></dt>
647607 <dd class="defbody">
648608 Returns non-zero if <var>term</var> is a compound term using the list
649609 constructor or the list terminator. See also <a class="func" href="foreigninclude.html#PL_is_pair()">PL_is_pair()</a>
650610 and
651611 <a class="func" href="foreigninclude.html#PL_skip_list()">PL_skip_list()</a>.</dd>
652 <dt class="pubdef"><a id="PL_is_pair()"><var>int</var> <strong>PL_is_pair</strong>(<var>term_t</var>)</a></dt>
612 <dt class="pubdef"><a name="PL_is_pair()"><var>int</var> <strong>PL_is_pair</strong>(<var>term_t</var>)</a></dt>
653613 <dd class="defbody">
654614 Returns non-zero if <var>term</var> is a compound term using the list
655615 constructor. See also <a class="func" href="foreigninclude.html#PL_is_list()">PL_is_list()</a>
656616 and <a class="func" href="foreigninclude.html#PL_skip_list()">PL_skip_list()</a>.</dd>
657 <dt class="pubdef"><a id="PL_is_atomic()"><var>int</var> <strong>PL_is_atomic</strong>(<var>term_t</var>)</a></dt>
617 <dt class="pubdef"><a name="PL_is_atomic()"><var>int</var> <strong>PL_is_atomic</strong>(<var>term_t</var>)</a></dt>
658618 <dd class="defbody">
659619 Returns non-zero if <var>term</var> is atomic (not variable or
660620 compound).</dd>
661 <dt class="pubdef"><a id="PL_is_number()"><var>int</var> <strong>PL_is_number</strong>(<var>term_t</var>)</a></dt>
621 <dt class="pubdef"><a name="PL_is_number()"><var>int</var> <strong>PL_is_number</strong>(<var>term_t</var>)</a></dt>
662622 <dd class="defbody">
663623 Returns non-zero if <var>term</var> is an integer or float.</dd>
664 <dt class="pubdef"><a id="PL_is_acyclic()"><var>int</var> <strong>PL_is_acyclic</strong>(<var>term_t</var>)</a></dt>
624 <dt class="pubdef"><a name="PL_is_acyclic()"><var>int</var> <strong>PL_is_acyclic</strong>(<var>term_t</var>)</a></dt>
665625 <dd class="defbody">
666626 Returns non-zero if <var>term</var> is acyclic (i.e. a finite tree).
667627 </dd>
668628 </dl>
669629
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
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
671631 data from a term</span></a></h4>
672632
673 <a id="sec:foreign-extract-from-term"></a>
633 <a name="sec:foreign-extract-from-term"></a>
674634
675635 <p>The functions <code>PL_get_*()</code> read information from a Prolog
676636 term. Most of them take two arguments. The first is the input term and
677637 the second is a pointer to the output value or a term reference.
678638
679639 <dl class="latex">
680 <dt class="pubdef"><a id="PL_get_atom()"><var>int</var> <strong>PL_get_atom</strong>(<var>term_t
640 <dt class="pubdef"><a name="PL_get_atom()"><var>int</var> <strong>PL_get_atom</strong>(<var>term_t
681641 +t, atom_t *a</var>)</a></dt>
682642 <dd class="defbody">
683643 If <var>t</var> is an atom, store the unique atom identifier over <var>a</var>.
687647 advised to manipulate atoms using their handle. As the atom is
688648 referenced by <var>t</var>, it will live at least as long as <var>t</var>
689649 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>
690 <dt class="pubdef"><a id="PL_get_atom_chars()"><var>int</var> <strong>PL_get_atom_chars</strong>(<var>term_t
650 <dt class="pubdef"><a name="PL_get_atom_chars()"><var>int</var> <strong>PL_get_atom_chars</strong>(<var>term_t
691651 +t, char **s</var>)</a></dt>
692652 <dd class="defbody">
693653 If <var>t</var> is an atom, store a pointer to a 0-terminated C-string
696656 the contents of this string. Some built-in atoms may have the string
697657 allocated in read-only memory, so `temporary manipulation' can cause an
698658 error.</dd>
699 <dt class="pubdef"><a id="PL_get_string_chars()"><var>int</var> <strong>PL_get_string_chars</strong>(<var>term_t
659 <dt class="pubdef"><a name="PL_get_string_chars()"><var>int</var> <strong>PL_get_string_chars</strong>(<var>term_t
700660 +t, char **s, size_t *len</var>)</a></dt>
701661 <dd class="defbody">
702662 If <var>t</var> is a string object, store a pointer to a 0-terminated
704664 Note that this pointer is invalidated by backtracking, garbage
705665 collection and stack-shifts, so generally the only save operations are
706666 to pass it immediately to a C function that doesn't involve Prolog.</dd>
707 <dt class="pubdef"><a id="PL_get_chars()"><var>int</var> <strong>PL_get_chars</strong>(<var>term_t
667 <dt class="pubdef"><a name="PL_get_chars()"><var>int</var> <strong>PL_get_chars</strong>(<var>term_t
708668 +t, char **s, unsigned flags</var>)</a></dt>
709669 <dd class="defbody">
710670 Convert the argument term <var>t</var> to a 0-terminated C-string. <em>flags</em>
718678 using <a class="func" href="foreignnotes.html#PL_free()">PL_free()</a>
719679 when no longer needed.
720680
721 <p>With the introduction of wide characters (see <a class="sec" href="widechars.html#sec:2.19.1">section
681 <p>With the introduction of wide characters (see <a class="sec" href="widechars.html">section
722682 2.19.1</a>), not all atoms can be converted into a <code>char*</code>.
723683 This function fails if <var>t</var> is of the wrong type, but also if
724684 the text cannot be represented. See the <code>REP_*</code> flags below
740700 <dt><strong>CVT_FLOAT</strong></dt>
741701 <dd class="defbody">
742702 Convert if term is a float. The characters returned are the same as
743 <a id="idx:write1:2023"></a><a class="pred" href="termrw.html#write/1">write/1</a>
703 <a name="idx:write1:2022"></a><a class="pred" href="termrw.html#write/1">write/1</a>
744704 would write for the floating point number.</dd>
745705 <dt><strong>CVT_NUMBER</strong></dt>
746706 <dd class="defbody">
754714 <dt><strong>CVT_WRITE</strong></dt>
755715 <dd class="defbody">
756716 Convert any term that is not converted by any of the other flags using
757 <a id="idx:write1:2024"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
717 <a name="idx:write1:2023"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
758718 If no <code>BUF_*</code> is provided, <code>BUF_RING</code> is implied.</dd>
759719 <dt><strong>CVT_WRITE_CANONICAL</strong></dt>
760720 <dd class="defbody">
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>
721 As <code>CVT_WRITE</code>, but using <a name="idx:writecanonical2:2024"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.</dd>
762722 <dt><strong>CVT_WRITEQ</strong></dt>
763723 <dd class="defbody">
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>
724 As <code>CVT_WRITE</code>, but using <a name="idx:writeq2:2025"></a><a class="pred" href="termrw.html#writeq/2">writeq/2</a>.</dd>
765725 <dt><strong>CVT_ALL</strong></dt>
766726 <dd class="defbody">
767727 Convert if term is any of the above, except for <code>CVT_VARIABLE</code>
797757 </dl>
798758
799759 </dd>
800 <dt class="pubdef"><a id="PL_get_list_chars()"><var>int</var> <strong>PL_get_list_chars</strong>(<var>+term_t
760 <dt class="pubdef"><a name="PL_get_list_chars()"><var>int</var> <strong>PL_get_list_chars</strong>(<var>+term_t
801761 l, char **s, unsigned flags</var>)</a></dt>
802762 <dd class="defbody">
803763 Same as <code><a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars(<var>l</var>, <var>s</var>,
804764 CVT_LIST|<var>flags</var>)</a></code>, provided <var>flags</var>
805765 contains none of the <code>CVT_*</code> flags.
806766 </dd>
807 <dt class="pubdef"><a id="PL_get_integer()"><var>int</var> <strong>PL_get_integer</strong>(<var>+term_t
767 <dt class="pubdef"><a name="PL_get_integer()"><var>int</var> <strong>PL_get_integer</strong>(<var>+term_t
808768 t, int *i</var>)</a></dt>
809769 <dd class="defbody">
810770 If <var>t</var> is a Prolog integer, assign its value over <var>i</var>.
811771 On 32-bit machines, this is the same as <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>,
812772 but avoids a warning from the compiler. See also <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>.</dd>
813 <dt class="pubdef"><a id="PL_get_long()"><var>int</var> <strong>PL_get_long</strong>(<var>term_t
773 <dt class="pubdef"><a name="PL_get_long()"><var>int</var> <strong>PL_get_long</strong>(<var>term_t
814774 +t, long *i</var>)</a></dt>
815775 <dd class="defbody">
816776 If <var>t</var> is a Prolog integer that can be represented as a long,
818778 cannot be represented by a C long, this function returns <code>FALSE</code>.
819779 If <var>t</var> is a floating point number that can be represented as a
820780 long, this function succeeds as well. See also <a class="func" href="foreigninclude.html#PL_get_int64()">PL_get_int64()</a>.</dd>
821 <dt class="pubdef"><a id="PL_get_int64()"><var>int</var> <strong>PL_get_int64</strong>(<var>term_t
781 <dt class="pubdef"><a name="PL_get_int64()"><var>int</var> <strong>PL_get_int64</strong>(<var>term_t
822782 +t, int64_t *i</var>)</a></dt>
823783 <dd class="defbody">
824784 If <var>t</var> is a Prolog integer or float that can be represented as
825785 a
826786 <code>int64_t</code>, assign its value over <var>i</var>.</dd>
827 <dt class="pubdef"><a id="PL_get_intptr()"><var>int</var> <strong>PL_get_intptr</strong>(<var>term_t
787 <dt class="pubdef"><a name="PL_get_intptr()"><var>int</var> <strong>PL_get_intptr</strong>(<var>term_t
828788 +t, intptr_t *i</var>)</a></dt>
829789 <dd class="defbody">
830790 Get an integer that is at least as wide as a pointer. On most platforms
831791 this is the same as <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>,
832792 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>,
833793 the value is not modified.</dd>
834 <dt class="pubdef"><a id="PL_get_bool()"><var>int</var> <strong>PL_get_bool</strong>(<var>term_t
794 <dt class="pubdef"><a name="PL_get_bool()"><var>int</var> <strong>PL_get_bool</strong>(<var>term_t
835795 +t, int *val</var>)</a></dt>
836796 <dd class="defbody">
837797 If <var>t</var> has the value <code>true</code> or <code>false</code>,
838798 set <var>val</var> to the C constant <code>TRUE</code> or <code>FALSE</code>
839799 and return success, otherwise return failure.
840800 </dd>
841 <dt class="pubdef"><a id="PL_get_pointer()"><var>int</var> <strong>PL_get_pointer</strong>(<var>term_t
801 <dt class="pubdef"><a name="PL_get_pointer()"><var>int</var> <strong>PL_get_pointer</strong>(<var>term_t
842802 +t, void **ptr</var>)</a></dt>
843803 <dd class="defbody">
844804 In the current system, pointers are represented by Prolog integers, but
848808 guarantee pointers in the range of malloc() are handled without
849809 truncating.
850810 </dd>
851 <dt class="pubdef"><a id="PL_get_float()"><var>int</var> <strong>PL_get_float</strong>(<var>term_t
811 <dt class="pubdef"><a name="PL_get_float()"><var>int</var> <strong>PL_get_float</strong>(<var>term_t
852812 +t, double *f</var>)</a></dt>
853813 <dd class="defbody">
854814 If <var>t</var> is a float or integer, its value is assigned over <var>f</var>.
855815 </dd>
856 <dt class="pubdef"><a id="PL_get_functor()"><var>int</var> <strong>PL_get_functor</strong>(<var>term_t
816 <dt class="pubdef"><a name="PL_get_functor()"><var>int</var> <strong>PL_get_functor</strong>(<var>term_t
857817 +t, functor_t *f</var>)</a></dt>
858818 <dd class="defbody">
859819 If <var>t</var> is compound or an atom, the Prolog representation of the
860820 name-arity pair will be assigned over <var>f</var>. See also
861821 <a class="func" href="foreigninclude.html#PL_get_name_arity()">PL_get_name_arity()</a>
862822 and <a class="func" href="foreigninclude.html#PL_is_functor()">PL_is_functor()</a>.</dd>
863 <dt class="pubdef"><a id="PL_get_name_arity()"><var>int</var> <strong>PL_get_name_arity</strong>(<var>term_t
823 <dt class="pubdef"><a name="PL_get_name_arity()"><var>int</var> <strong>PL_get_name_arity</strong>(<var>term_t
864824 +t, atom_t *name, size_t *arity</var>)</a></dt>
865825 <dd class="defbody">
866826 If <var>t</var> is compound or an atom, the functor name will be
868828 also
869829 <a class="func" href="foreigninclude.html#PL_get_functor()">PL_get_functor()</a>
870830 and <a class="func" href="foreigninclude.html#PL_is_functor()">PL_is_functor()</a>.
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
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
874833 +t, atom_t *name, size_t *arity</var>)</a></dt>
875834 <dd class="defbody">
876835 If <var>t</var> is compound term, the functor name will be assigned over
877836 <var>name</var> and the arity over <var>arity</var>. This is the same as
878837 <a class="func" href="foreigninclude.html#PL_get_name_arity()">PL_get_name_arity()</a>,
879838 but this function fails if <var>t</var> is an atom.</dd>
880 <dt class="pubdef"><a id="PL_get_module()"><var>int</var> <strong>PL_get_module</strong>(<var>term_t
839 <dt class="pubdef"><a name="PL_get_module()"><var>int</var> <strong>PL_get_module</strong>(<var>term_t
881840 +t, module_t *module</var>)</a></dt>
882841 <dd class="defbody">
883842 If <var>t</var> is an atom, the system will look up or create the
884843 corresponding module and assign an opaque pointer to it over <em>module</em>.
885844 </dd>
886 <dt class="pubdef"><a id="PL_get_arg()"><var>int</var> <strong>PL_get_arg</strong>(<var>size_t
845 <dt class="pubdef"><a name="PL_get_arg()"><var>int</var> <strong>PL_get_arg</strong>(<var>size_t
887846 index, term_t +t, term_t -a</var>)</a></dt>
888847 <dd class="defbody">
889848 If <var>t</var> is compound and index is between 1 and arity
890849 (inclusive), assign <var>a</var> with a term reference to the argument.
891850 </dd>
892 <dt class="pubdef"><a id="_PL_get_arg()"><var>int</var> <strong>_PL_get_arg</strong>(<var>size_t
851 <dt class="pubdef"><a name="_PL_get_arg()"><var>int</var> <strong>_PL_get_arg</strong>(<var>size_t
893852 index, term_t +t, term_t -a</var>)</a></dt>
894853 <dd class="defbody">
895854 Same as <a class="func" href="foreigninclude.html#PL_get_arg()">PL_get_arg()</a>,
898857 </dd>
899858 </dl>
900859
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
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
902861 text using length and string</span></a></h4>
903862
904 <a id="sec:foreign-text-with-length"></a>
863 <a name="sec:foreign-text-with-length"></a>
905864
906865 <p>All internal text representation in SWI-Prolog is represented using
907866 <code>char *</code> plus length and allow for <em>0-bytes</em> in them.
911870 *_chars() function.
912871
913872 <dl class="latex">
914 <dt class="pubdef"><a id="PL_get_atom_nchars()"><var>int</var> <strong>PL_get_atom_nchars</strong>(<var>term_t
873 <dt class="pubdef"><a name="PL_get_atom_nchars()"><var>int</var> <strong>PL_get_atom_nchars</strong>(<var>term_t
915874 t, size_t *len, char **s</var>)</a></dt>
916875 <dd class="defbody">
917876 See <a class="func" href="foreigninclude.html#PL_get_atom_chars()">PL_get_atom_chars()</a>.
918877 </dd>
919 <dt class="pubdef"><a id="PL_get_list_nchars()"><var>int</var> <strong>PL_get_list_nchars</strong>(<var>term_t
878 <dt class="pubdef"><a name="PL_get_list_nchars()"><var>int</var> <strong>PL_get_list_nchars</strong>(<var>term_t
920879 t, size_t *len, char **s</var>)</a></dt>
921880 <dd class="defbody">
922881 See <a class="func" href="foreigninclude.html#PL_get_list_chars()">PL_get_list_chars()</a>.
923882 </dd>
924 <dt class="pubdef"><a id="PL_get_nchars()"><var>int</var> <strong>PL_get_nchars</strong>(<var>term_t
883 <dt class="pubdef"><a name="PL_get_nchars()"><var>int</var> <strong>PL_get_nchars</strong>(<var>term_t
925884 t, size_t *len, char **s, unsigned int flags</var>)</a></dt>
926885 <dd class="defbody">
927886 See <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>.
928887 </dd>
929 <dt class="pubdef"><a id="PL_put_atom_nchars()"><var>int</var> <strong>PL_put_atom_nchars</strong>(<var>term_t
888 <dt class="pubdef"><a name="PL_put_atom_nchars()"><var>int</var> <strong>PL_put_atom_nchars</strong>(<var>term_t
930889 t, size_t len, const char *s</var>)</a></dt>
931890 <dd class="defbody">
932891 See <a class="func" href="foreigninclude.html#PL_put_atom_chars()">PL_put_atom_chars()</a>.
933892 </dd>
934 <dt class="pubdef"><a id="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
893 <dt class="pubdef"><a name="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
935894 t, size_t len, const char *s</var>)</a></dt>
936895 <dd class="defbody">
937896 See <a class="func" href="foreigninclude.html#PL_put_string_chars()">PL_put_string_chars()</a>.
938897 </dd>
939 <dt class="pubdef"><a id="PL_put_list_ncodes()"><var>int</var> <strong>PL_put_list_ncodes</strong>(<var>term_t
898 <dt class="pubdef"><a name="PL_put_list_ncodes()"><var>int</var> <strong>PL_put_list_ncodes</strong>(<var>term_t
940899 t, size_t len, const char *s</var>)</a></dt>
941900 <dd class="defbody">
942901 See <b>PL_put_list_codes()</b>.
943902 </dd>
944 <dt class="pubdef"><a id="PL_put_list_nchars()"><var>int</var> <strong>PL_put_list_nchars</strong>(<var>term_t
903 <dt class="pubdef"><a name="PL_put_list_nchars()"><var>int</var> <strong>PL_put_list_nchars</strong>(<var>term_t
945904 t, size_t len, const char *s</var>)</a></dt>
946905 <dd class="defbody">
947906 See <a class="func" href="foreigninclude.html#PL_put_list_chars()">PL_put_list_chars()</a>.
948907 </dd>
949 <dt class="pubdef"><a id="PL_unify_atom_nchars()"><var>int</var> <strong>PL_unify_atom_nchars</strong>(<var>term_t
908 <dt class="pubdef"><a name="PL_unify_atom_nchars()"><var>int</var> <strong>PL_unify_atom_nchars</strong>(<var>term_t
950909 t, size_t len, const char *s</var>)</a></dt>
951910 <dd class="defbody">
952911 See <a class="func" href="foreigninclude.html#PL_unify_atom_chars()">PL_unify_atom_chars()</a>.
953912 </dd>
954 <dt class="pubdef"><a id="PL_unify_string_nchars()"><var>int</var> <strong>PL_unify_string_nchars</strong>(<var>term_t
913 <dt class="pubdef"><a name="PL_unify_string_nchars()"><var>int</var> <strong>PL_unify_string_nchars</strong>(<var>term_t
955914 t, size_t len, const char *s</var>)</a></dt>
956915 <dd class="defbody">
957916 See <a class="func" href="foreigninclude.html#PL_unify_string_chars()">PL_unify_string_chars()</a>.
958917 </dd>
959 <dt class="pubdef"><a id="PL_unify_list_ncodes()"><var>int</var> <strong>PL_unify_list_ncodes</strong>(<var>term_t
918 <dt class="pubdef"><a name="PL_unify_list_ncodes()"><var>int</var> <strong>PL_unify_list_ncodes</strong>(<var>term_t
960919 t, size_t len, const char *s</var>)</a></dt>
961920 <dd class="defbody">
962921 See <b>PL_unify_codes()</b>.
963922 </dd>
964 <dt class="pubdef"><a id="PL_unify_list_nchars()"><var>int</var> <strong>PL_unify_list_nchars</strong>(<var>term_t
923 <dt class="pubdef"><a name="PL_unify_list_nchars()"><var>int</var> <strong>PL_unify_list_nchars</strong>(<var>term_t
965924 t, size_t len, const char *s</var>)</a></dt>
966925 <dd class="defbody">
967926 See <a class="func" href="foreigninclude.html#PL_unify_list_chars()">PL_unify_list_chars()</a>.
972931 inspecting atoms:
973932
974933 <dl class="latex">
975 <dt class="pubdef"><a id="PL_new_atom_nchars()"><var>atom_t</var> <strong>PL_new_atom_nchars</strong>(<var>size_t
934 <dt class="pubdef"><a name="PL_new_atom_nchars()"><var>atom_t</var> <strong>PL_new_atom_nchars</strong>(<var>size_t
976935 len, const char *s</var>)</a></dt>
977936 <dd class="defbody">
978937 Create a new atom as <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>,
979938 but using the given length and characters. If <var>len</var> is <code>(size_t)-1</code>,
980939 it is computed from <var>s</var> using strlen().</dd>
981 <dt class="pubdef"><a id="PL_atom_nchars()"><var>const char *</var> <strong>PL_atom_nchars</strong>(<var>atom_t
940 <dt class="pubdef"><a name="PL_atom_nchars()"><var>const char *</var> <strong>PL_atom_nchars</strong>(<var>atom_t
982941 a, size_t *len</var>)</a></dt>
983942 <dd class="defbody">
984943 Extract the text and length of an atom.
985944 </dd>
986945 </dl>
987946
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
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
989948 versions</span></a></h4>
990949
991 <a id="sec:foreign-unicode"></a>
950 <a name="sec:foreign-unicode"></a>
992951
993952 <p>Support for exchange of wide-character strings is still under
994953 consideration. The functions dealing with 8-bit character strings return
1001960 using the GNU C library (glibc) this represents 32-bit UCS4 characters.
1002961
1003962 <dl class="latex">
1004 <dt class="pubdef"><a id="PL_new_atom_wchars()"><var>atom_t</var> <strong>PL_new_atom_wchars</strong>(<var>size_t
963 <dt class="pubdef"><a name="PL_new_atom_wchars()"><var>atom_t</var> <strong>PL_new_atom_wchars</strong>(<var>size_t
1005964 len, const pl_wchar_t *s</var>)</a></dt>
1006965 <dd class="defbody">
1007966 Create atom from wide-character string as <a class="func" href="foreigninclude.html#PL_new_atom_nchars()">PL_new_atom_nchars()</a>
1008967 does for ISO-Latin-1 strings. If <var>s</var> only contains ISO-Latin-1
1009968 characters a normal byte-array atom is created. If <var>len</var> is <code>(size_t)-1</code>,
1010969 it is computed from <var>s</var> using wcslen().</dd>
1011 <dt class="pubdef"><a id="PL_atom_wchars()"><var>pl_wchar_t*</var> <strong>PL_atom_wchars</strong>(<var>atom_t
970 <dt class="pubdef"><a name="PL_atom_wchars()"><var>pl_wchar_t*</var> <strong>PL_atom_wchars</strong>(<var>atom_t
1012971 atom, int *len</var>)</a></dt>
1013972 <dd class="defbody">
1014973 Extract characters from a wide-character atom. Succeeds on any atom
1016975 returned pointer is a pointer into the atom structure. If it is an
1017976 ISO-Latin-1 character, the returned pointer comes from Prolog's `buffer
1018977 ring' (see <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>).</dd>
1019 <dt class="pubdef"><a id="PL_get_wchars()"><var>int</var> <strong>PL_get_wchars</strong>(<var>term_t
978 <dt class="pubdef"><a name="PL_get_wchars()"><var>int</var> <strong>PL_get_wchars</strong>(<var>term_t
1020979 t, size_t *len, pl_wchar_t **s, unsigned flags</var>)</a></dt>
1021980 <dd class="defbody">
1022981 Wide-character version of <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>.
1023982 The <var>flags</var> argument is the same as for <a class="func" href="foreigninclude.html#PL_get_chars()">PL_get_chars()</a>.</dd>
1024 <dt class="pubdef"><a id="PL_unify_wchars()"><var>int</var> <strong>PL_unify_wchars</strong>(<var>term_t
983 <dt class="pubdef"><a name="PL_unify_wchars()"><var>int</var> <strong>PL_unify_wchars</strong>(<var>term_t
1025984 t, int type, size_t len, const pl_wchar_t *s</var>)</a></dt>
1026985 <dd class="defbody">
1027986 Unify <var>t</var> with a textual representation of the C wide-character
1029988 representation and is one of <code>PL_ATOM</code>, <code>PL_STRING</code>,
1030989 <code>PL_CODE_LIST</code> or <code>PL_CHAR_LIST</code>.
1031990 </dd>
1032 <dt class="pubdef"><a id="PL_unify_wchars_diff()"><var>int</var> <strong>PL_unify_wchars_diff</strong>(<var>term_t
991 <dt class="pubdef"><a name="PL_unify_wchars_diff()"><var>int</var> <strong>PL_unify_wchars_diff</strong>(<var>term_t
1033992 +t, term_t -tail, int type, size_t len, const pl_wchar_t *s</var>)</a></dt>
1034993 <dd class="defbody">
1035994 Difference list version of <a class="func" href="foreigninclude.html#PL_unify_wchars()">PL_unify_wchars()</a>,
10421001 </dd>
10431002 </dl>
10441003
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
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
10461005 a list</span></a></h4>
10471006
1048 <a id="sec:foreign-read-list"></a>
1007 <a name="sec:foreign-read-list"></a>
10491008
10501009 <p>The functions from this section are intended to read a Prolog list
10511010 from C. Suppose we expect a list of atoms; the following code will print
10711030 </pre>
10721031
10731032 <p>Note that as of version&nbsp;7, lists have a new representation
1074 unless the option <strong>--traditional</strong> is used. see <a class="sec" href="ext-lists.html#sec:5.1">section
1033 unless the option <strong>--traditional</strong> is used. see <a class="sec" href="ext-lists.html">section
10751034 5.1</a>.
10761035
10771036 <dl class="latex">
1078 <dt class="pubdef"><a id="PL_get_list()"><var>int</var> <strong>PL_get_list</strong>(<var>term_t
1037 <dt class="pubdef"><a name="PL_get_list()"><var>int</var> <strong>PL_get_list</strong>(<var>term_t
10791038 +l, term_t -h, term_t -t</var>)</a></dt>
10801039 <dd class="defbody">
10811040 If <var>l</var> is a list and not the empty list, assign a term
10821041 reference to the head to <var>h</var> and to the tail to <var>t</var>.</dd>
1083 <dt class="pubdef"><a id="PL_get_head()"><var>int</var> <strong>PL_get_head</strong>(<var>term_t
1042 <dt class="pubdef"><a name="PL_get_head()"><var>int</var> <strong>PL_get_head</strong>(<var>term_t
10841043 +l, term_t -h</var>)</a></dt>
10851044 <dd class="defbody">
10861045 If <var>l</var> is a list and not the empty list, assign a term
10871046 reference to the head to <var>h</var>.</dd>
1088 <dt class="pubdef"><a id="PL_get_tail()"><var>int</var> <strong>PL_get_tail</strong>(<var>term_t
1047 <dt class="pubdef"><a name="PL_get_tail()"><var>int</var> <strong>PL_get_tail</strong>(<var>term_t
10891048 +l, term_t -t</var>)</a></dt>
10901049 <dd class="defbody">
10911050 If <var>l</var> is a list and not the empty list, assign a term
10921051 reference to the tail to <var>t</var>.</dd>
1093 <dt class="pubdef"><a id="PL_get_nil()"><var>int</var> <strong>PL_get_nil</strong>(<var>term_t
1052 <dt class="pubdef"><a name="PL_get_nil()"><var>int</var> <strong>PL_get_nil</strong>(<var>term_t
10941053 +l</var>)</a></dt>
10951054 <dd class="defbody">
10961055 Succeeds if <var>l</var> represents the list termination constant.</dd>
1097 <dt class="pubdef"><a id="PL_skip_list()"><var>int</var> <strong>PL_skip_list</strong>(<var>term_t
1056 <dt class="pubdef"><a name="PL_skip_list()"><var>int</var> <strong>PL_skip_list</strong>(<var>term_t
10981057 +list, term_t -tail, size_t *len</var>)</a></dt>
10991058 <dd class="defbody">
11001059 This is a multi-purpose function to deal with lists. It allows for
11041063 return value indicates the status of the list:
11051064
11061065 <dl class="latex">
1107 <dt><a id="PL_LIST"><strong>PL_LIST</strong></a></dt>
1066 <dt><a name="PL_LIST"><strong>PL_LIST</strong></a></dt>
11081067 <dd class="defbody">
11091068 The list is a `proper' list: one that ends in the list terminator
11101069 constant and <var>tail</var> is filled with the terminator constant.</dd>
1111 <dt><a id="PL_PARTIAL_LIST"><strong>PL_PARTIAL_LIST</strong></a></dt>
1070 <dt><a name="PL_PARTIAL_LIST"><strong>PL_PARTIAL_LIST</strong></a></dt>
11121071 <dd class="defbody">
11131072 The list is a `partial' list: one that ends in a variable and
11141073 <var>tail</var> is a reference to this variable.</dd>
1115 <dt><a id="PL_CYCLIC_TERM"><strong>PL_CYCLIC_TERM</strong></a></dt>
1074 <dt><a name="PL_CYCLIC_TERM"><strong>PL_CYCLIC_TERM</strong></a></dt>
11161075 <dd class="defbody">
11171076 The list is cyclic (e.g. X = [a|X]). <var>tail</var> points to an
11181077 arbitrary cell of the list and <var>len</var> is at most twice the cycle
11191078 length of the list.</dd>
1120 <dt><a id="PL_NOT_A_LIST"><strong>PL_NOT_A_LIST</strong></a></dt>
1079 <dt><a name="PL_NOT_A_LIST"><strong>PL_NOT_A_LIST</strong></a></dt>
11211080 <dd class="defbody">
11221081 The term <var>list</var> is not a list at all. <var>tail</var> is bound
11231082 to the non-list term and <var>len</var> is set to the number of
11291088 </dd>
11301089 </dl>
11311090
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
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
11331092 example: defining write/1 in C</span></a></h4>
11341093
1135 <a id="sec:foreign-write"></a>
1094 <a name="sec:foreign-write"></a>
11361095
11371096 <p><a class="fig" href="foreigninclude.html#fig:pl-display">Figure 7</a>
1138 shows a simplified definition of <a id="idx:write1:2028"></a><a class="pred" href="termrw.html#write/1">write/1</a>
1097 shows a simplified definition of <a name="idx:write1:2027"></a><a class="pred" href="termrw.html#write/1">write/1</a>
11391098 to illustrate the described functions. This simplified version does not
1140 deal with operators. It is called <a id="idx:display1:2029"></a><span class="pred-ext">display/1</span>,
1099 deal with operators. It is called <a name="idx:display1:2028"></a><span class="pred-ext">display/1</span>,
11411100 because it mimics closely the behaviour of this Edinburgh predicate.
11421101
11431102 <pre class="code">
11811140 }
11821141 </pre>
11831142
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
1143 <div class="caption"><b>Figure 7 : </b>A Foreign definition of <a name="idx:display1:2029"></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
11881147 Terms</span></a></h3>
11891148
1190 <a id="sec:foreign-term-construct"></a>
1149 <a name="sec:foreign-term-construct"></a>
11911150
11921151 <p>Terms can be constructed using functions from the <code>PL_put_*()</code>
11931152 and
12011160 <a class="func" href="foreigninclude.html#PL_open_query()">PL_open_query()</a>.
12021161
12031162 <dl class="latex">
1204 <dt class="pubdef"><a id="PL_put_variable()"><var>void</var> <strong>PL_put_variable</strong>(<var>term_t
1163 <dt class="pubdef"><a name="PL_put_variable()"><var>void</var> <strong>PL_put_variable</strong>(<var>term_t
12051164 -t</var>)</a></dt>
12061165 <dd class="defbody">
12071166 Put a fresh variable in the term, resetting the term reference to its
1208 initial state.<sup class="fn">171<span class="fn-text">Older versions
1167 initial state.<sup class="fn">170<span class="fn-text">Older versions
12091168 created a variable on the global stack.</span></sup>
12101169 </dd>
1211 <dt class="pubdef"><a id="PL_put_atom()"><var>void</var> <strong>PL_put_atom</strong>(<var>term_t
1170 <dt class="pubdef"><a name="PL_put_atom()"><var>void</var> <strong>PL_put_atom</strong>(<var>term_t
12121171 -t, atom_t a</var>)</a></dt>
12131172 <dd class="defbody">
12141173 Put an atom in the term reference from a handle. See also
12151174 <a class="func" href="foreigninclude.html#PL_new_atom()">PL_new_atom()</a>
12161175 and <a class="func" href="foreigninclude.html#PL_atom_chars()">PL_atom_chars()</a>.
12171176 </dd>
1218 <dt class="pubdef"><a id="PL_put_bool()"><var>void</var> <strong>PL_put_bool</strong>(<var>term_t
1177 <dt class="pubdef"><a name="PL_put_bool()"><var>void</var> <strong>PL_put_bool</strong>(<var>term_t
12191178 -t, int val</var>)</a></dt>
12201179 <dd class="defbody">
12211180 Put one of the atoms <code>true</code> or <code>false</code> in the term
12221181 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>
12231182 and <a class="func" href="foreigninclude.html#PL_get_bool()">PL_get_bool()</a>.
12241183 </dd>
1225 <dt class="pubdef"><a id="PL_put_chars()"><var>int</var> <strong>PL_put_chars</strong>(<var>term_t
1184 <dt class="pubdef"><a name="PL_put_chars()"><var>int</var> <strong>PL_put_chars</strong>(<var>term_t
12261185 -t, int flags, size_t len, const char *chars</var>)</a></dt>
12271186 <dd class="defbody">
12281187 New function to deal with setting a term from a <code>char*</code> with
12391198 zero-terminated and the length is computed from <var>chars</var> using
12401199 strlen().
12411200 </dd>
1242 <dt class="pubdef"><a id="PL_put_atom_chars()"><var>int</var> <strong>PL_put_atom_chars</strong>(<var>term_t
1201 <dt class="pubdef"><a name="PL_put_atom_chars()"><var>int</var> <strong>PL_put_atom_chars</strong>(<var>term_t
12431202 -t, const char *chars</var>)</a></dt>
12441203 <dd class="defbody">
12451204 Put an atom in the term reference constructed from the zero-terminated
12461205 string. The string itself will never be referenced by Prolog after this
12471206 function.
12481207 </dd>
1249 <dt class="pubdef"><a id="PL_put_string_chars()"><var>int</var> <strong>PL_put_string_chars</strong>(<var>term_t
1208 <dt class="pubdef"><a name="PL_put_string_chars()"><var>int</var> <strong>PL_put_string_chars</strong>(<var>term_t
12501209 -t, const char *chars</var>)</a></dt>
12511210 <dd class="defbody">
12521211 Put a zero-terminated string in the term reference. The data will be
12531212 copied. See also <a class="func" href="foreigninclude.html#PL_put_string_nchars()">PL_put_string_nchars()</a>.
12541213 </dd>
1255 <dt class="pubdef"><a id="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
1214 <dt class="pubdef"><a name="PL_put_string_nchars()"><var>int</var> <strong>PL_put_string_nchars</strong>(<var>term_t
12561215 -t, size_t len, const char *chars</var>)</a></dt>
12571216 <dd class="defbody">
12581217
12591218 <p>Put a string, represented by a length/start pointer pair in the term
12601219 reference. The data will be copied. This interface can deal with 0-bytes
1261 in the string. See also <a class="sec" href="foreigninclude.html#sec:11.4.20">section
1220 in the string. See also <a class="sec" href="foreigninclude.html">section
12621221 11.4.20</a>.
12631222 </dd>
1264 <dt class="pubdef"><a id="PL_put_list_chars()"><var>int</var> <strong>PL_put_list_chars</strong>(<var>term_t
1223 <dt class="pubdef"><a name="PL_put_list_chars()"><var>int</var> <strong>PL_put_list_chars</strong>(<var>term_t
12651224 -t, const char *chars</var>)</a></dt>
12661225 <dd class="defbody">
12671226 Put a list of ASCII values in the term reference.
12681227 </dd>
1269 <dt class="pubdef"><a id="PL_put_integer()"><var>int</var> <strong>PL_put_integer</strong>(<var>term_t
1228 <dt class="pubdef"><a name="PL_put_integer()"><var>int</var> <strong>PL_put_integer</strong>(<var>term_t
12701229 -t, long i</var>)</a></dt>
12711230 <dd class="defbody">
12721231 Put a Prolog integer in the term reference.
12731232 </dd>
1274 <dt class="pubdef"><a id="PL_put_int64()"><var>int</var> <strong>PL_put_int64</strong>(<var>term_t
1233 <dt class="pubdef"><a name="PL_put_int64()"><var>int</var> <strong>PL_put_int64</strong>(<var>term_t
12751234 -t, int64_t i</var>)</a></dt>
12761235 <dd class="defbody">
12771236 Put a Prolog integer in the term reference.
12781237 </dd>
1279 <dt class="pubdef"><a id="PL_put_pointer()"><var>int</var> <strong>PL_put_pointer</strong>(<var>term_t
1238 <dt class="pubdef"><a name="PL_put_pointer()"><var>int</var> <strong>PL_put_pointer</strong>(<var>term_t
12801239 -t, void *ptr</var>)</a></dt>
12811240 <dd class="defbody">
12821241 Put a Prolog integer in the term reference. Provided <var>ptr</var> is
12831242 in the `malloc()-area', <a class="func" href="foreigninclude.html#PL_get_pointer()">PL_get_pointer()</a>
12841243 will get the pointer back.
12851244 </dd>
1286 <dt class="pubdef"><a id="PL_put_float()"><var>int</var> <strong>PL_put_float</strong>(<var>term_t
1245 <dt class="pubdef"><a name="PL_put_float()"><var>int</var> <strong>PL_put_float</strong>(<var>term_t
12871246 -t, double f</var>)</a></dt>
12881247 <dd class="defbody">
12891248 Put a floating-point value in the term reference.</dd>
1290 <dt class="pubdef"><a id="PL_put_functor()"><var>int</var> <strong>PL_put_functor</strong>(<var>term_t
1249 <dt class="pubdef"><a name="PL_put_functor()"><var>int</var> <strong>PL_put_functor</strong>(<var>term_t
12911250 -t, functor_t functor</var>)</a></dt>
12921251 <dd class="defbody">
12931252 Create a new compound term from <var>functor</var> and bind <var>t</var>
12941253 to this term. All arguments of the term will be variables. To create a
12951254 term with instantiated arguments, either instantiate the arguments using
12961255 the <code>PL_unify_*()</code> functions or use <a class="func" href="foreigninclude.html#PL_cons_functor()">PL_cons_functor()</a>.</dd>
1297 <dt class="pubdef"><a id="PL_put_list()"><var>int</var> <strong>PL_put_list</strong>(<var>term_t
1256 <dt class="pubdef"><a name="PL_put_list()"><var>int</var> <strong>PL_put_list</strong>(<var>term_t
12981257 -l</var>)</a></dt>
12991258 <dd class="defbody">
13001259 As <a class="func" href="foreigninclude.html#PL_put_functor()">PL_put_functor()</a>,
13021261 SWI-Prolog using the option
13031262 <strong>--traditional</strong>, this is <code><code>.</code>/2</code>,
13041263 while on SWI-Prolog version&nbsp;7 this is <code><code>[|]</code>/2</code>.</dd>
1305 <dt class="pubdef"><a id="PL_put_nil()"><var>int</var> <strong>PL_put_nil</strong>(<var>term_t
1264 <dt class="pubdef"><a name="PL_put_nil()"><var>int</var> <strong>PL_put_nil</strong>(<var>term_t
13061265 -l</var>)</a></dt>
13071266 <dd class="defbody">
13081267 Put the list terminator constant in <var>l</var>. Always returns
13101269 SWI-Prolog using the option <strong>--traditional</strong>, this is the
13111270 same as
13121271 <code><a class="func" href="foreigninclude.html#PL_put_atom_chars()">PL_put_atom_chars("[]")</a></code>.
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
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
13151274 -t1, term_t +t2</var>)</a></dt>
13161275 <dd class="defbody">
13171276 Make <var>t1</var> point to the same term as <var>t2</var>.</dd>
1318 <dt class="pubdef"><a id="PL_cons_functor()"><var>int</var> <strong>PL_cons_functor</strong>(<var>term_t
1277 <dt class="pubdef"><a name="PL_cons_functor()"><var>int</var> <strong>PL_cons_functor</strong>(<var>term_t
13191278 -h, functor_t f, ...</var>)</a></dt>
13201279 <dd class="defbody">
13211280 Create a term whose arguments are filled from a variable argument list
13421301 <p>After this sequence, the term references <var>a1</var> and <var>a2</var>
13431302 may be used for other purposes.
13441303 </dd>
1345 <dt class="pubdef"><a id="PL_cons_functor_v()"><var>int</var> <strong>PL_cons_functor_v</strong>(<var>term_t
1304 <dt class="pubdef"><a name="PL_cons_functor_v()"><var>int</var> <strong>PL_cons_functor_v</strong>(<var>term_t
13461305 -h, functor_t f, term_t a0</var>)</a></dt>
13471306 <dd class="defbody">
13481307 Create a compound term like <a class="func" href="foreigninclude.html#PL_cons_functor()">PL_cons_functor()</a>,
13501309 The length of this array should match the number of arguments required
13511310 by the functor.
13521311 </dd>
1353 <dt class="pubdef"><a id="PL_cons_list()"><var>int</var> <strong>PL_cons_list</strong>(<var>term_t
1312 <dt class="pubdef"><a name="PL_cons_list()"><var>int</var> <strong>PL_cons_list</strong>(<var>term_t
13541313 -l, term_t +h, term_t +t</var>)</a></dt>
13551314 <dd class="defbody">
13561315 Create a list (cons-) cell in <var>l</var> from the head <var>h</var>
13771336 </dd>
13781337 </dl>
13791338
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
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
13811340 data</span></a></h3>
13821341
1383 <a id="sec:foreign-unify"></a>
1342 <a name="sec:foreign-unify"></a>
13841343
13851344 <p>The functions of this section <em>unify</em> terms with other terms
13861345 or translated C data structures. Except for <a class="func" href="foreigninclude.html#PL_unify()">PL_unify()</a>,
14281387 for details.
14291388
14301389 <dl class="latex">
1431 <dt class="pubdef"><a id="PL_unify()"><var>int</var> <strong>PL_unify</strong>(<var>term_t
1390 <dt class="pubdef"><a name="PL_unify()"><var>int</var> <strong>PL_unify</strong>(<var>term_t
14321391 ?t1, term_t ?t2</var>)</a></dt>
14331392 <dd class="defbody">
14341393 Unify two Prolog terms and return <code>TRUE</code> on success.
14691428 encounter an exception must return <code>FAIL</code> to Prolog as soon
14701429 as possible or call <a class="func" href="foreigninclude.html#PL_clear_exception()">PL_clear_exception()</a>
14711430 if they wish to ignore the exception.</dd>
1472 <dt class="pubdef"><a id="PL_unify_atom()"><var>int</var> <strong>PL_unify_atom</strong>(<var>term_t
1431 <dt class="pubdef"><a name="PL_unify_atom()"><var>int</var> <strong>PL_unify_atom</strong>(<var>term_t
14731432 ?t, atom_t a</var>)</a></dt>
14741433 <dd class="defbody">
14751434 Unify <var>t</var> with the atom <var>a</var> and return non-zero on
14761435 success.</dd>
1477 <dt class="pubdef"><a id="PL_unify_bool()"><var>int</var> <strong>PL_unify_bool</strong>(<var>term_t
1436 <dt class="pubdef"><a name="PL_unify_bool()"><var>int</var> <strong>PL_unify_bool</strong>(<var>term_t
14781437 ?t, int a</var>)</a></dt>
14791438 <dd class="defbody">
14801439 Unify <var>t</var> with either <code>true</code> or <code>false</code>.</dd>
1481 <dt class="pubdef"><a id="PL_unify_chars()"><var>int</var> <strong>PL_unify_chars</strong>(<var>term_t
1440 <dt class="pubdef"><a name="PL_unify_chars()"><var>int</var> <strong>PL_unify_chars</strong>(<var>term_t
14821441 ?t, int flags, size_t len, const char *chars</var>)</a></dt>
14831442 <dd class="defbody">
14841443 New function to deal with unification of <code>char*</code> with various
15021461 converted to a <em>difference list</em>. The tail of the difference list
15031462 is
15041463 <var>t+1</var>.</dd>
1505 <dt class="pubdef"><a id="PL_unify_atom_chars()"><var>int</var> <strong>PL_unify_atom_chars</strong>(<var>term_t
1464 <dt class="pubdef"><a name="PL_unify_atom_chars()"><var>int</var> <strong>PL_unify_atom_chars</strong>(<var>term_t
15061465 ?t, const char *chars</var>)</a></dt>
15071466 <dd class="defbody">
15081467 Unify <var>t</var> with an atom created from <var>chars</var> and return
15091468 non-zero on success.</dd>
1510 <dt class="pubdef"><a id="PL_unify_list_chars()"><var>int</var> <strong>PL_unify_list_chars</strong>(<var>term_t
1469 <dt class="pubdef"><a name="PL_unify_list_chars()"><var>int</var> <strong>PL_unify_list_chars</strong>(<var>term_t
15111470 ?t, const char *chars</var>)</a></dt>
15121471 <dd class="defbody">
15131472 Unify <var>t</var> with a list of ASCII characters constructed from
15141473 <var>chars</var>.</dd>
1515 <dt class="pubdef"><a id="PL_unify_string_chars()"><var>void</var> <strong>PL_unify_string_chars</strong>(<var>term_t
1474 <dt class="pubdef"><a name="PL_unify_string_chars()"><var>void</var> <strong>PL_unify_string_chars</strong>(<var>term_t
15161475 ?t, const char *chars</var>)</a></dt>
15171476 <dd class="defbody">
15181477 Unify <var>t</var> with a Prolog string object created from the
15191478 zero-terminated string <var>chars</var>. The data will be copied. See
15201479 also <a class="func" href="foreigninclude.html#PL_unify_string_nchars()">PL_unify_string_nchars()</a>.
15211480 </dd>
1522 <dt class="pubdef"><a id="PL_unify_integer()"><var>int</var> <strong>PL_unify_integer</strong>(<var>term_t
1481 <dt class="pubdef"><a name="PL_unify_integer()"><var>int</var> <strong>PL_unify_integer</strong>(<var>term_t
15231482 ?t, intptr_t n</var>)</a></dt>
15241483 <dd class="defbody">
15251484 Unify <var>t</var> with a Prolog integer from <var>n</var>.
15261485 </dd>
1527 <dt class="pubdef"><a id="PL_unify_int64()"><var>int</var> <strong>PL_unify_int64</strong>(<var>term_t
1486 <dt class="pubdef"><a name="PL_unify_int64()"><var>int</var> <strong>PL_unify_int64</strong>(<var>term_t
15281487 ?t, int64_t n</var>)</a></dt>
15291488 <dd class="defbody">
15301489 Unify <var>t</var> with a Prolog integer from <var>n</var>.
15311490 </dd>
1532 <dt class="pubdef"><a id="PL_unify_uint64()"><var>int</var> <strong>PL_unify_uint64</strong>(<var>term_t
1491 <dt class="pubdef"><a name="PL_unify_uint64()"><var>int</var> <strong>PL_unify_uint64</strong>(<var>term_t
15331492 ?t, uint64_t n</var>)</a></dt>
15341493 <dd class="defbody">
15351494 Unify <var>t</var> with a Prolog integer from <var>n</var>. Note that
15371496 <code>int64_t</code>. If unbounded integers are not supported a
15381497 <code>representation_error</code> is raised.
15391498 </dd>
1540 <dt class="pubdef"><a id="PL_unify_float()"><var>int</var> <strong>PL_unify_float</strong>(<var>term_t
1499 <dt class="pubdef"><a name="PL_unify_float()"><var>int</var> <strong>PL_unify_float</strong>(<var>term_t
15411500 ?t, double f</var>)</a></dt>
15421501 <dd class="defbody">
15431502 Unify <var>t</var> with a Prolog float from <var>f</var>.
15441503 </dd>
1545 <dt class="pubdef"><a id="PL_unify_pointer()"><var>int</var> <strong>PL_unify_pointer</strong>(<var>term_t
1504 <dt class="pubdef"><a name="PL_unify_pointer()"><var>int</var> <strong>PL_unify_pointer</strong>(<var>term_t
15461505 ?t, void *ptr</var>)</a></dt>
15471506 <dd class="defbody">
15481507 Unify <var>t</var> with a Prolog integer describing the pointer. See
15491508 also
15501509 <a class="func" href="foreigninclude.html#PL_put_pointer()">PL_put_pointer()</a>
15511510 and <a class="func" href="foreigninclude.html#PL_get_pointer()">PL_get_pointer()</a>.</dd>
1552 <dt class="pubdef"><a id="PL_unify_functor()"><var>int</var> <strong>PL_unify_functor</strong>(<var>term_t
1511 <dt class="pubdef"><a name="PL_unify_functor()"><var>int</var> <strong>PL_unify_functor</strong>(<var>term_t
15531512 ?t, functor_t f</var>)</a></dt>
15541513 <dd class="defbody">
15551514 If <var>t</var> is a compound term with the given functor, just succeed.
15571516 that this function does not create a term if the argument is already
15581517 instantiated. If <var>f</var> is a functor with arity 0, <var>t</var> is
15591518 unified with an atom. See also <a class="func" href="foreigninclude.html#PL_unify_compound()">PL_unify_compound()</a>.</dd>
1560 <dt class="pubdef"><a id="PL_unify_compound()"><var>int</var> <strong>PL_unify_compound</strong>(<var>term_t
1519 <dt class="pubdef"><a name="PL_unify_compound()"><var>int</var> <strong>PL_unify_compound</strong>(<var>term_t
15611520 ?t, functor_t f</var>)</a></dt>
15621521 <dd class="defbody">
15631522 If <var>t</var> is a compound term with the given functor, just succeed.
15661525 instantiated. If <var>f</var> is a functor with arity 0, <var>t</var> is
15671526 unified with compound without arguments. See also
15681527 <a class="func" href="foreigninclude.html#PL_unify_functor()">PL_unify_functor()</a>.</dd>
1569 <dt class="pubdef"><a id="PL_unify_list()"><var>int</var> <strong>PL_unify_list</strong>(<var>term_t
1528 <dt class="pubdef"><a name="PL_unify_list()"><var>int</var> <strong>PL_unify_list</strong>(<var>term_t
15701529 ?l, term_t -h, term_t -t</var>)</a></dt>
15711530 <dd class="defbody">
15721531 Unify <var>l</var> with a list-cell (<code>./2</code>). If successful,
16031562 </pre>
16041563
16051564 </dd>
1606 <dt class="pubdef"><a id="PL_unify_nil()"><var>int</var> <strong>PL_unify_nil</strong>(<var>term_t
1565 <dt class="pubdef"><a name="PL_unify_nil()"><var>int</var> <strong>PL_unify_nil</strong>(<var>term_t
16071566 ?l</var>)</a></dt>
16081567 <dd class="defbody">
16091568 Unify <var>l</var> with the atom <code>[]</code>.
16101569 </dd>
1611 <dt class="pubdef"><a id="PL_unify_arg()"><var>int</var> <strong>PL_unify_arg</strong>(<var>int
1570 <dt class="pubdef"><a name="PL_unify_arg()"><var>int</var> <strong>PL_unify_arg</strong>(<var>int
16121571 index, term_t ?t, term_t ?a</var>)</a></dt>
16131572 <dd class="defbody">
16141573 Unifies the <em>index-th</em> argument (1-based) of <var>t</var> with
16151574 <var>a</var>.
16161575 </dd>
1617 <dt class="pubdef"><a id="PL_unify_term()"><var>int</var> <strong>PL_unify_term</strong>(<var>term_t
1576 <dt class="pubdef"><a name="PL_unify_term()"><var>int</var> <strong>PL_unify_term</strong>(<var>term_t
16181577 ?t, ...</var>)</a></dt>
16191578 <dd class="defbody">
16201579 Unify <var>t</var> with a (normally) compound term. The remaining
17991758 </pre>
18001759
18011760 </dd>
1802 <dt class="pubdef"><a id="PL_chars_to_term()"><var>int</var> <strong>PL_chars_to_term</strong>(<var>const
1761 <dt class="pubdef"><a name="PL_chars_to_term()"><var>int</var> <strong>PL_chars_to_term</strong>(<var>const
18031762 char *chars, term_t -t</var>)</a></dt>
18041763 <dd class="defbody">
18051764 Parse the string <var>chars</var> and put the resulting Prolog term into
18071766 full-stop (i.e., a dot followed by a blank). Returns <code>FALSE</code>
18081767 if a syntax error was encountered and <code>TRUE</code> after successful
18091768 completion. In addition to returning <code>FALSE</code>, the
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>.
1769 exception-term is returned in <var>t</var> on a syntax error. See also <a name="idx:termtoatom2:2030"></a><a class="pred" href="manipatom.html#term_to_atom/2">term_to_atom/2</a>.
18111770
18121771 <p>The following example builds a goal term from a string and calls it.
18131772
18321791 </pre>
18331792
18341793 </dd>
1835 <dt class="pubdef"><a id="PL_wchars_to_term()"><var>int</var> <strong>PL_wchars_to_term</strong>(<var>const
1794 <dt class="pubdef"><a name="PL_wchars_to_term()"><var>int</var> <strong>PL_wchars_to_term</strong>(<var>const
18361795 pl_wchar_t *chars, term_t -t</var>)</a></dt>
18371796 <dd class="defbody">
18381797 Wide character version of <a class="func" href="foreigninclude.html#PL_chars_to_term()">PL_chars_to_term()</a>.</dd>
1839 <dt class="pubdef"><a id="PL_quote()"><var>char *</var> <strong>PL_quote</strong>(<var>int
1798 <dt class="pubdef"><a name="PL_quote()"><var>char *</var> <strong>PL_quote</strong>(<var>int
18401799 chr, const char *string</var>)</a></dt>
18411800 <dd class="defbody">
18421801 Return a quoted version of <var>string</var>. If <var>chr</var> is
18531812 </dd>
18541813 </dl>
18551814
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
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
18571816 functions to generate Prolog exceptions</span></a></h3>
18581817
1859 <a id="sec:cerror"></a>
1818 <a name="sec:cerror"></a>
18601819
18611820 <p>The typical implementation of a foreign predicate first uses the
18621821 PL_get_*() functions to extract C data types from the Prolog terms.
18851844 </pre>
18861845
18871846 <dl class="latex">
1888 <dt class="pubdef"><a id="PL_get_atom_ex()"><var>int</var> <strong>PL_get_atom_ex</strong>(<var>term_t
1847 <dt class="pubdef"><a name="PL_get_atom_ex()"><var>int</var> <strong>PL_get_atom_ex</strong>(<var>term_t
18891848 t, atom_t *a</var>)</a></dt>
18901849 <dd class="defbody">
18911850 As <a class="func" href="foreigninclude.html#PL_get_atom()">PL_get_atom()</a>,
18921851 but raises a type or instantiation error if
18931852 <var>t</var> is not an atom.</dd>
1894 <dt class="pubdef"><a id="PL_get_integer_ex()"><var>int</var> <strong>PL_get_integer_ex</strong>(<var>term_t
1853 <dt class="pubdef"><a name="PL_get_integer_ex()"><var>int</var> <strong>PL_get_integer_ex</strong>(<var>term_t
18951854 t, int *i</var>)</a></dt>
18961855 <dd class="defbody">
18971856 As <a class="func" href="foreigninclude.html#PL_get_integer()">PL_get_integer()</a>,
18981857 but raises a type or instantiation error if
18991858 <var>t</var> is not an integer, or a representation error if the Prolog
19001859 integer does not fit in a C <code>int</code>.</dd>
1901 <dt class="pubdef"><a id="PL_get_long_ex()"><var>int</var> <strong>PL_get_long_ex</strong>(<var>term_t
1860 <dt class="pubdef"><a name="PL_get_long_ex()"><var>int</var> <strong>PL_get_long_ex</strong>(<var>term_t
19021861 t, long *i</var>)</a></dt>
19031862 <dd class="defbody">
19041863 As <a class="func" href="foreigninclude.html#PL_get_long()">PL_get_long()</a>,
19051864 but raises a type or instantiation error if
19061865 <var>t</var> is not an atom, or a representation error if the Prolog
19071866 integer does not fit in a C <code>long</code>.</dd>
1908 <dt class="pubdef"><a id="PL_get_int64_ex()"><var>int</var> <strong>PL_get_int64_ex</strong>(<var>term_t
1867 <dt class="pubdef"><a name="PL_get_int64_ex()"><var>int</var> <strong>PL_get_int64_ex</strong>(<var>term_t
19091868 t, int64_t *i</var>)</a></dt>
19101869 <dd class="defbody">
19111870 As <a class="func" href="foreigninclude.html#PL_get_int64()">PL_get_int64()</a>,
19121871 but raises a type or instantiation error if
19131872 <var>t</var> is not an atom, or a representation error if the Prolog
19141873 integer does not fit in a C <code>int64_t</code>.</dd>
1915 <dt class="pubdef"><a id="PL_get_intptr_ex()"><var>int</var> <strong>PL_get_intptr_ex</strong>(<var>term_t
1874 <dt class="pubdef"><a name="PL_get_intptr_ex()"><var>int</var> <strong>PL_get_intptr_ex</strong>(<var>term_t
19161875 t, intptr_t *i</var>)</a></dt>
19171876 <dd class="defbody">
19181877 As <a class="func" href="foreigninclude.html#PL_get_intptr()">PL_get_intptr()</a>,
19191878 but raises a type or instantiation error if
19201879 <var>t</var> is not an atom, or a representation error if the Prolog
19211880 integer does not fit in a C <code>intptr_t</code>.</dd>
1922 <dt class="pubdef"><a id="PL_get_size_ex()"><var>int</var> <strong>PL_get_size_ex</strong>(<var>term_t
1881 <dt class="pubdef"><a name="PL_get_size_ex()"><var>int</var> <strong>PL_get_size_ex</strong>(<var>term_t
19231882 t, size_t *i</var>)</a></dt>
19241883 <dd class="defbody">
19251884 As <b>PL_get_size()</b>, but raises a type or instantiation error if
19261885 <var>t</var> is not an atom, or a representation error if the Prolog
19271886 integer does not fit in a C <code>size_t</code>.</dd>
1928 <dt class="pubdef"><a id="PL_get_bool_ex()"><var>int</var> <strong>PL_get_bool_ex</strong>(<var>term_t
1887 <dt class="pubdef"><a name="PL_get_bool_ex()"><var>int</var> <strong>PL_get_bool_ex</strong>(<var>term_t
19291888 t, int *i</var>)</a></dt>
19301889 <dd class="defbody">
19311890 As <a class="func" href="foreigninclude.html#PL_get_bool()">PL_get_bool()</a>,
19321891 but raises a type or instantiation error if
19331892 <var>t</var> is not an boolean.</dd>
1934 <dt class="pubdef"><a id="PL_get_float_ex()"><var>int</var> <strong>PL_get_float_ex</strong>(<var>term_t
1893 <dt class="pubdef"><a name="PL_get_float_ex()"><var>int</var> <strong>PL_get_float_ex</strong>(<var>term_t
19351894 t, double *f</var>)</a></dt>
19361895 <dd class="defbody">
19371896 As <a class="func" href="foreigninclude.html#PL_get_float()">PL_get_float()</a>,
19381897 but raises a type or instantiation error if
19391898 <var>t</var> is not a float.</dd>
1940 <dt class="pubdef"><a id="PL_get_char_ex()"><var>int</var> <strong>PL_get_char_ex</strong>(<var>term_t
1899 <dt class="pubdef"><a name="PL_get_char_ex()"><var>int</var> <strong>PL_get_char_ex</strong>(<var>term_t
19411900 t, int *p, int eof</var>)</a></dt>
19421901 <dd class="defbody">
19431902 Get a character code from <var>t</var>, where <var>t</var> is either an
19441903 integer or an atom with length one. If <var>eof</var> is <code>TRUE</code>
19451904 and <var>t</var> is -1, <var>p</var> is filled with -1. Raises an
19461905 appropriate error if the conversion is not possible.</dd>
1947 <dt class="pubdef"><a id="PL_get_pointer_ex()"><var>int</var> <strong>PL_get_pointer_ex</strong>(<var>term_t
1906 <dt class="pubdef"><a name="PL_get_pointer_ex()"><var>int</var> <strong>PL_get_pointer_ex</strong>(<var>term_t
19481907 t, void **addrp</var>)</a></dt>
19491908 <dd class="defbody">
19501909 As <a class="func" href="foreigninclude.html#PL_get_pointer()">PL_get_pointer()</a>,
19511910 but raises a type or instantiation error if
19521911 <var>t</var> is not a pointer.</dd>
1953 <dt class="pubdef"><a id="PL_get_list_ex()"><var>int</var> <strong>PL_get_list_ex</strong>(<var>term_t
1912 <dt class="pubdef"><a name="PL_get_list_ex()"><var>int</var> <strong>PL_get_list_ex</strong>(<var>term_t
19541913 l, term_t h, term_t t</var>)</a></dt>
19551914 <dd class="defbody">
19561915 As <a class="func" href="foreigninclude.html#PL_get_list()">PL_get_list()</a>,
19571916 but raises a type or instantiation error if
19581917 <var>t</var> is not a list.</dd>
1959 <dt class="pubdef"><a id="PL_get_nil_ex()"><var>int</var> <strong>PL_get_nil_ex</strong>(<var>term_t
1918 <dt class="pubdef"><a name="PL_get_nil_ex()"><var>int</var> <strong>PL_get_nil_ex</strong>(<var>term_t
19601919 l</var>)</a></dt>
19611920 <dd class="defbody">
19621921 As <a class="func" href="foreigninclude.html#PL_get_nil()">PL_get_nil()</a>,
19631922 but raises a type or instantiation error if
19641923 <var>t</var> is not the empty list.</dd>
1965 <dt class="pubdef"><a id="PL_unify_list_ex()"><var>int</var> <strong>PL_unify_list_ex</strong>(<var>term_t
1924 <dt class="pubdef"><a name="PL_unify_list_ex()"><var>int</var> <strong>PL_unify_list_ex</strong>(<var>term_t
19661925 l, term_t h, term_t t</var>)</a></dt>
19671926 <dd class="defbody">
19681927 As <a class="func" href="foreigninclude.html#PL_unify_list()">PL_unify_list()</a>,
19691928 but raises a type error if <var>t</var> is not a variable, list-cell or
19701929 the empty list.</dd>
1971 <dt class="pubdef"><a id="PL_unify_nil_ex()"><var>int</var> <strong>PL_unify_nil_ex</strong>(<var>term_t
1930 <dt class="pubdef"><a name="PL_unify_nil_ex()"><var>int</var> <strong>PL_unify_nil_ex</strong>(<var>term_t
19721931 l</var>)</a></dt>
19731932 <dd class="defbody">
19741933 As <a class="func" href="foreigninclude.html#PL_unify_nil()">PL_unify_nil()</a>,
19751934 but raises a type error if <var>t</var> is not a variable, list-cell or
19761935 the empty list.</dd>
1977 <dt class="pubdef"><a id="PL_unify_bool_ex()"><var>int</var> <strong>PL_unify_bool_ex</strong>(<var>term_t
1936 <dt class="pubdef"><a name="PL_unify_bool_ex()"><var>int</var> <strong>PL_unify_bool_ex</strong>(<var>term_t
19781937 t, int val</var>)</a></dt>
19791938 <dd class="defbody">
19801939 As <a class="func" href="foreigninclude.html#PL_unify_bool()">PL_unify_bool()</a>,
19901949 context. See also <a class="func" href="foreigninclude.html#PL_raise_exception()">PL_raise_exception()</a>.
19911950
19921951 <dl class="latex">
1993 <dt class="pubdef"><a id="PL_instantiation_error()"><var>int</var> <strong>PL_instantiation_error</strong>(<var>term_t
1952 <dt class="pubdef"><a name="PL_instantiation_error()"><var>int</var> <strong>PL_instantiation_error</strong>(<var>term_t
19941953 culprit</var>)</a></dt>
19951954 <dd class="defbody">
19961955 Raise <code>instantiation_error</code>. <var>Culprit</var> is ignored,
19971956 but should be bound to the term that is insufficiently instantiated. See
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
1957 <a name="idx:instantiationerror1:2031"></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
20001959 culprit</var>)</a></dt>
20011960 <dd class="defbody">
20021961 Raise <code>uninstantiation_error(culprit)</code>. This should be called
20031962 if an argument that must be unbound at entry is bound to <var>culprit</var>.
20041963 This error is typically raised for a pure output arguments such as a
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
1964 newly created stream handle (e.g., the third argument of <a name="idx:open3:2032"></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
20071966 char *resource</var>)</a></dt>
20081967 <dd class="defbody">
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
1968 Raise <code>representation_error(resource)</code>. See <a name="idx:representationerror1:2033"></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
20111970 char *expected, term_t culprit</var>)</a></dt>
20121971 <dd class="defbody">
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
1972 Raise <code>type_error(expected, culprit)</code>. See <a name="idx:typeerror2:2034"></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
20151974 char *expected, term_t culprit</var>)</a></dt>
20161975 <dd class="defbody">
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
1976 Raise <code>domain_error(expected, culprit)</code>. See <a name="idx:domainerror2:2035"></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
20191978 char *type, term_t culprit</var>)</a></dt>
20201979 <dd class="defbody">
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
1980 Raise <code>existence_error(type, culprit)</code>. See <a name="idx:typeerror2:2036"></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
20231982 char *operation, const char *type, term_t culprit</var>)</a></dt>
20241983 <dd class="defbody">
20251984 Raise <code>permission_error(operation, type, culprit)</code>. See
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
1985 <a name="idx:permissionerror3:2037"></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
20291988 char *resource</var>)</a></dt>
20301989 <dd class="defbody">
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
1990 Raise <code>resource_error(resource)</code>. See <a name="idx:resourceerror1:2038"></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
20341993 char *message, IOSTREAM *in</var>)</a></dt>
20351994 <dd class="defbody">
20361995 Raise <code>syntax_error(message)</code>. If <var>arg</var> is not <code>NULL</code>,
20381997 </dd>
20391998 </dl>
20401999
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:
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:
20422001 Using atoms to store arbitrary binary data</span></a></h3>
20432002
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.
2003 <a name="sec:blob"></a>
2004
2005 <p><a name="idx:Java:2039"></a><a name="idx:COM:2040"></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.
20542014
20552015 <p>To exploit these features safely and in an organised manner, the
20562016 SWI-Prolog foreign interface allows for creating `atoms' with additional
20622022 <a class="func" href="foreigninclude.html#compare()">compare()</a>
20632023 function. Rank numbers are assigned when the type is registered.
20642024
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
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
20662026 a BLOB type</span></a></h4>
20672027
2068 <a id="sec:blobtype"></a>
2028 <a name="sec:blobtype"></a>
20692029
20702030 <p>The type <code>PL_blob_t</code> represents a structure with the
20712031 layout displayed below. The structure contains additional fields at the
20892049 <var>flags</var> is a bitwise <em>or</em> of the following constants:
20902050
20912051 <dl class="latex">
2092 <dt><a id="PL_BLOB_TEXT"><strong>PL_BLOB_TEXT</strong></a></dt>
2052 <dt><a name="PL_BLOB_TEXT"><strong>PL_BLOB_TEXT</strong></a></dt>
20932053 <dd class="defbody">
20942054 If specified the blob is assumed to contain text and is considered a
20952055 normal Prolog atom.</dd>
2096 <dt><a id="PL_BLOB_UNIQUE"><strong>PL_BLOB_UNIQUE</strong></a></dt>
2056 <dt><a name="PL_BLOB_UNIQUE"><strong>PL_BLOB_UNIQUE</strong></a></dt>
20972057 <dd class="defbody">
20982058 If specified the system ensures that the blob-handle is a unique
20992059 reference for a blob with the given type, length and content. If this
21002060 flag is not specified, each lookup creates a new blob.</dd>
2101 <dt><a id="PL_BLOB_NOCOPY"><strong>PL_BLOB_NOCOPY</strong></a></dt>
2061 <dt><a name="PL_BLOB_NOCOPY"><strong>PL_BLOB_NOCOPY</strong></a></dt>
21022062 <dd class="defbody">
21032063 By default the content of the blob is copied. Using this flag the blob
21042064 references the external data directly. The user must ensure the provided
21092069 </dl>
21102070
21112071 <p>The <var>name</var> field represents the type name as available to
2112 Prolog. See also <a id="idx:currentblob2:2042"></a><a class="pred" href="examineprog.html#current_blob/2">current_blob/2</a>.
2072 Prolog. See also <a name="idx:currentblob2:2041"></a><a class="pred" href="examineprog.html#current_blob/2">current_blob/2</a>.
21132073 The other fields are function pointers that must be initialised to
21142074 proper functions or <code>NULL</code> to get the default behaviour of
21152075 built-in atoms. Below are the defined member functions:
21162076
21172077 <dl class="latex">
2118 <dt class="pubdef"><a id="acquire()"><var>void</var> <strong>acquire</strong>(<var>atom_t
2078 <dt class="pubdef"><a name="acquire()"><var>void</var> <strong>acquire</strong>(<var>atom_t
21192079 a</var>)</a></dt>
21202080 <dd class="defbody">
21212081 Called if a new blob of this type is created through <a class="func" href="foreigninclude.html#PL_put_blob()">PL_put_blob()</a>
21222082 or <a class="func" href="foreigninclude.html#PL_unify_blob()">PL_unify_blob()</a>.
21232083 This callback may be used together with the release hook to deal with
21242084 reference-counted external objects.</dd>
2125 <dt class="pubdef"><a id="release()"><var>int</var> <strong>release</strong>(<var>atom_t
2085 <dt class="pubdef"><a name="release()"><var>int</var> <strong>release</strong>(<var>atom_t
21262086 a</var>)</a></dt>
21272087 <dd class="defbody">
21282088 The blob (atom) <var>a</var> is about to be released. This function can
21292089 retrieve the data of the blob using <a class="func" href="foreigninclude.html#PL_blob_data()">PL_blob_data()</a>.
21302090 If it returns <code>FALSE</code> the atom garbage collector will <em>not</em>
21312091 reclaim the atom.</dd>
2132 <dt class="pubdef"><a id="compare()"><var>int</var> <strong>compare</strong>(<var>atom_t
2092 <dt class="pubdef"><a name="compare()"><var>int</var> <strong>compare</strong>(<var>atom_t
21332093 a, atom_t b</var>)</a></dt>
21342094 <dd class="defbody">
21352095 Compare the blobs <var>a</var> and <var>b</var>, both of which are of
21372097 <var>&lt; 0</var> if <var>a</var> is less than <var>b</var>, <var>= 0</var>
21382098 if both are equal, and
21392099 <var>&gt; 0</var> otherwise.</dd>
2140 <dt class="pubdef"><a id="write()"><var>int</var> <strong>write</strong>(<var>IOSTREAM
2100 <dt class="pubdef"><a name="write()"><var>int</var> <strong>write</strong>(<var>IOSTREAM
21412101 *s, atom_t a, int flags</var>)</a></dt>
21422102 <dd class="defbody">
21432103 Write the content of the blob <var>a</var> to the stream <var>s</var>
21472107 undocumented <code>SWI-Stream.h</code> is included <em>before</em>
21482108 <code>SWI-Prolog.h</code>.
21492109
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>
2110 <p>If this function is not provided, <a name="idx:write1:2042"></a><a class="pred" href="termrw.html#write/1">write/1</a>
21512111 emits the content of the blob for blobs of type <code>PL_BLOB_TEXT</code>
21522112 or a string of the format <code>&lt;#</code><i>hex data</i><code>&gt;</code>
21532113 for binary blobs.
21592119 released.
21602120
21612121 <dl class="latex">
2162 <dt class="pubdef"><a id="PL_unregister_blob_type()"><var>int</var> <strong>PL_unregister_blob_type</strong>(<var>PL_blob_t
2122 <dt class="pubdef"><a name="PL_unregister_blob_type()"><var>int</var> <strong>PL_unregister_blob_type</strong>(<var>PL_blob_t
21632123 *type</var>)</a></dt>
21642124 <dd class="defbody">
21652125 Unlink the blob type from the registered type and transform the type of
21722132 </dd>
21732133 </dl>
21742134
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
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
21762136 blobs</span></a></h4>
21772137
2178 <a id="sec:blobaccess"></a>
2138 <a name="sec:blobaccess"></a>
21792139
21802140 <p>The blob access functions are similar to the atom accessing
21812141 functions. Blobs being atoms, the atom functions operate on blobs and
21832143 however, it is not advised to rely on this.
21842144
21852145 <dl class="latex">
2186 <dt class="pubdef"><a id="PL_is_blob()"><var>int</var> <strong>PL_is_blob</strong>(<var>term_t
2146 <dt class="pubdef"><a name="PL_is_blob()"><var>int</var> <strong>PL_is_blob</strong>(<var>term_t
21872147 t, PL_blob_t **type</var>)</a></dt>
21882148 <dd class="defbody">
21892149 Succeeds if <var>t</var> refers to a blob, in which case <var>type</var>
21902150 is filled with the type of the blob.</dd>
2191 <dt class="pubdef"><a id="PL_unify_blob()"><var>int</var> <strong>PL_unify_blob</strong>(<var>term_t
2151 <dt class="pubdef"><a name="PL_unify_blob()"><var>int</var> <strong>PL_unify_blob</strong>(<var>term_t
21922152 t, void *blob, size_t len, PL_blob_t *type</var>)</a></dt>
21932153 <dd class="defbody">
21942154 Unify <var>t</var> to a new blob constructed from the given data and
21952155 associated to the given type. See also <a class="func" href="foreigninclude.html#PL_unify_atom_nchars()">PL_unify_atom_nchars()</a>.</dd>
2196 <dt class="pubdef"><a id="PL_put_blob()"><var>int</var> <strong>PL_put_blob</strong>(<var>term_t
2156 <dt class="pubdef"><a name="PL_put_blob()"><var>int</var> <strong>PL_put_blob</strong>(<var>term_t
21972157 t, void *blob, size_t len, PL_blob_t *type</var>)</a></dt>
21982158 <dd class="defbody">
21992159 Store the described blob in <var>t</var>. The return value indicates
22042164 count must be incremented, and it must be decremented on blob
22052165 destruction callback. See also
22062166 <a class="func" href="foreigninclude.html#PL_put_atom_nchars()">PL_put_atom_nchars()</a>.</dd>
2207 <dt class="pubdef"><a id="PL_get_blob()"><var>int</var> <strong>PL_get_blob</strong>(<var>term_t
2167 <dt class="pubdef"><a name="PL_get_blob()"><var>int</var> <strong>PL_get_blob</strong>(<var>term_t
22082168 t, void **blob, size_t *len, PL_blob_t **type</var>)</a></dt>
22092169 <dd class="defbody">
22102170 If <var>t</var> holds a blob or atom, get the data and type and return
22112171 <code>TRUE</code>. Otherwise return <code>FALSE</code>. Each result
22122172 pointer may be <code>NULL</code>, in which case the requested
22132173 information is ignored.</dd>
2214 <dt class="pubdef"><a id="PL_blob_data()"><var>void *</var> <strong>PL_blob_data</strong>(<var>atom_t
2174 <dt class="pubdef"><a name="PL_blob_data()"><var>void *</var> <strong>PL_blob_data</strong>(<var>atom_t
22152175 a, size_t *len, PL_blob_t **type</var>)</a></dt>
22162176 <dd class="defbody">
22172177 Get the data and type associated to a blob. This function is mainly used
2218 from the callback functions described in <a class="sec" href="foreigninclude.html#sec:11.4.7.1">section
2178 from the callback functions described in <a class="sec" href="foreigninclude.html">section
22192179 11.4.7.1</a>.
22202180 </dd>
22212181 </dl>
22222182
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
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
22242184 GMP numbers</span></a></h3>
22252185
2226 <a id="sec:gmpforeign"></a>
2186 <a name="sec:gmpforeign"></a>
22272187
22282188 <p>If SWI-Prolog is linked with the GNU Multiple Precision Arithmetic
22292189 Library (GMP, used by default), the foreign interface provides functions
22802240 </pre>
22812241
22822242 <dl class="latex">
2283 <dt class="pubdef"><a id="PL_get_mpz()"><var>int</var> <strong>PL_get_mpz</strong>(<var>term_t
2243 <dt class="pubdef"><a name="PL_get_mpz()"><var>int</var> <strong>PL_get_mpz</strong>(<var>term_t
22842244 t, mpz_t mpz</var>)</a></dt>
22852245 <dd class="defbody">
22862246 If <var>t</var> represents an integer, <var>mpz</var> is filled with the
22882248 is untouched and the function returns <code>FALSE</code>. Note that <var>mpz</var>
22892249 must have been initialised before calling this function and must be
22902250 cleared using mpz_clear() to reclaim any storage associated with it.</dd>
2291 <dt class="pubdef"><a id="PL_get_mpq()"><var>int</var> <strong>PL_get_mpq</strong>(<var>term_t
2251 <dt class="pubdef"><a name="PL_get_mpq()"><var>int</var> <strong>PL_get_mpq</strong>(<var>term_t
22922252 t, mpq_t mpq</var>)</a></dt>
22932253 <dd class="defbody">
22942254 If <var>t</var> is an integer or rational number (term <code>rdiv/2</code>),
22972257 untouched and the function returns <code>FALSE</code>. Note that <var>mpq</var>
22982258 must have been initialised before calling this function and must be
22992259 cleared using mpq_clear() to reclaim any storage associated with it.</dd>
2300 <dt class="pubdef"><a id="PL_unify_mpz()"><var>int</var> <strong>PL_unify_mpz</strong>(<var>term_t
2260 <dt class="pubdef"><a name="PL_unify_mpz()"><var>int</var> <strong>PL_unify_mpz</strong>(<var>term_t
23012261 t, mpz_t mpz</var>)</a></dt>
23022262 <dd class="defbody">
23032263 Unify <var>t</var> with the integer value represented by <var>mpz</var>
23042264 and return
23052265 <code>TRUE</code> on success. The <var>mpz</var> argument is not
23062266 changed.</dd>
2307 <dt class="pubdef"><a id="PL_unify_mpq()"><var>int</var> <strong>PL_unify_mpq</strong>(<var>term_t
2267 <dt class="pubdef"><a name="PL_unify_mpq()"><var>int</var> <strong>PL_unify_mpq</strong>(<var>term_t
23082268 t, mpq_t mpq</var>)</a></dt>
23092269 <dd class="defbody">
23102270 Unify <var>t</var> with a rational number represented by <var>mpq</var>
23152275 </dd>
23162276 </dl>
23172277
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
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
23192279 Prolog from C</span></a></h3>
23202280
2321 <a id="sec:calling-prolog-from-c"></a>
2281 <a name="sec:calling-prolog-from-c"></a>
23222282
23232283 <p>The Prolog engine can be called from C. There are two interfaces for
23242284 this. For the first, a term is created that could be used as an argument
2325 to <a id="idx:call1:2044"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
2285 to <a name="idx:call1:2043"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
23262286 and then <a class="func" href="foreigninclude.html#PL_call()">PL_call()</a>
23272287 is used to call Prolog. This system is simple, but does not allow to
23282288 inspect the different answers to a non-deterministic goal and is
23342294 <a class="func" href="foreigninclude.html#PL_close_query()">PL_close_query()</a>.
23352295 This mechanism is more powerful, but also more complicated to use.
23362296
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
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
23382298 references</span></a></h4>
23392299
2340 <a id="sec:foreign-predicate-handle"></a>
2300 <a name="sec:foreign-predicate-handle"></a>
23412301
23422302 <p>This section discusses the functions used to communicate about
23432303 predicates. Though a Prolog predicate may be defined or not, redefined,
23452305 moved. This handle is known by the type <code>predicate_t</code>.
23462306
23472307 <dl class="latex">
2348 <dt class="pubdef"><a id="PL_pred()"><var>predicate_t</var> <strong>PL_pred</strong>(<var>functor_t
2308 <dt class="pubdef"><a name="PL_pred()"><var>predicate_t</var> <strong>PL_pred</strong>(<var>functor_t
23492309 f, module_t m</var>)</a></dt>
23502310 <dd class="defbody">
23512311 Return a handle to a predicate for the specified name/arity in the given
23522312 module. This function always succeeds, creating a handle for an
23532313 undefined predicate if no handle was available. If the module argument
23542314 <var>m</var> is <code>NULL</code>, the current context module is used.</dd>
2355 <dt class="pubdef"><a id="PL_predicate()"><var>predicate_t</var> <strong>PL_predicate</strong>(<var>const
2315 <dt class="pubdef"><a name="PL_predicate()"><var>predicate_t</var> <strong>PL_predicate</strong>(<var>const
23562316 char *name, int arity, const char* module</var>)</a></dt>
23572317 <dd class="defbody">
23582318 Same as <a class="func" href="foreigninclude.html#PL_pred()">PL_pred()</a>,
23592319 but provides a more convenient interface to the C programmer.</dd>
2360 <dt class="pubdef"><a id="PL_predicate_info()"><var>void</var> <strong>PL_predicate_info</strong>(<var>predicate_t
2320 <dt class="pubdef"><a name="PL_predicate_info()"><var>void</var> <strong>PL_predicate_info</strong>(<var>predicate_t
23612321 p, atom_t *n, size_t *a, module_t *m</var>)</a></dt>
23622322 <dd class="defbody">
23632323 Return information on the predicate <var>p</var>. The name is stored
23742334 </dd>
23752335 </dl>
23762336
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
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
23782338 a query from C</span></a></h4>
23792339
2380 <a id="sec:foreign-create-query"></a>
2340 <a name="sec:foreign-create-query"></a>
23812341
23822342 <p>This section discusses the functions for creating and manipulating
23832343 queries from C. Note that a foreign context can have at most one active
23912351 back to Prolog.
23922352
23932353 <dl class="latex">
2394 <dt class="pubdef"><a id="PL_open_query()"><var>qid_t</var> <strong>PL_open_query</strong>(<var>module_t
2354 <dt class="pubdef"><a name="PL_open_query()"><var>qid_t</var> <strong>PL_open_query</strong>(<var>module_t
23952355 ctx, int flags, predicate_t p, term_t +t0</var>)</a></dt>
23962356 <dd class="defbody">
23972357
23992359 module</em> of the goal. When <code>NULL</code>, the context module of
24002360 the calling context will be used, or <code>user</code> if there is no
24012361 calling context (as may happen in embedded systems). Note that the
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>.
2362 context module only matters for <em>meta-predicates</em>. See <a name="idx:metapredicate1:2044"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>,
2363 <a name="idx:contextmodule1:2045"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
2364 and <a name="idx:moduletransparent1:2046"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>.
24052365 The <var>p</var> argument specifies the predicate, and should be the
24062366 result of a call to <a class="func" href="foreigninclude.html#PL_pred()">PL_pred()</a>
24072367 or <a class="func" href="foreigninclude.html#PL_predicate()">PL_predicate()</a>.
24192379 <dd class="defbody">
24202380 Normal operation. The debugger inherits its settings from the
24212381 environment. If an exception occurs that is not handled in Prolog, a
2422 message is printed and the tracer is started to debug the error.<sup class="fn">172<span class="fn-text">Do
2382 message is printed and the tracer is started to debug the error.<sup class="fn">171<span class="fn-text">Do
24232383 not pass the integer 0 for normal operation, as this is interpreted as <code>PL_Q_NODEBUG</code>
24242384 for backward compatibility reasons.</span></sup>
24252385 </dd>
24262386 <dt><b><code>PL_Q_NODEBUG</code></b></dt>
24272387 <dd class="defbody">
24282388 Switch off the debugger while executing the goal. This option is used by
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>
2389 many calls to hook-predicates to avoid tracing the hooks. An example is <a name="idx:print1:2047"></a><a class="pred" href="termrw.html#print/1">print/1</a>
2390 calling <a name="idx:portray1:2048"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
24312391 from foreign code.
24322392 </dd>
24332393 <dt><b><code>PL_Q_CATCH_EXCEPTION</code></b></dt>
24532413 <code>TRUE</code> or <code>FALSE</code> extended status as illustrated
24542414 in the following table:
24552415
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
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
24592420 available through <a class="func" href="foreigninclude.html#PL_exception()">PL_exception()</a> </td></tr>
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
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
24632423 choicepoint </td></tr>
2424 <tr valign="top"><td>PL_S_LAST</td><td>TRUE</td><td>Query succeeded
2425 without choicepoint </td></tr>
24642426 </table>
24652427 </dd>
24662428 </dl>
24922454 </pre>
24932455
24942456 </dd>
2495 <dt class="pubdef"><a id="PL_next_solution()"><var>int</var> <strong>PL_next_solution</strong>(<var>qid_t
2457 <dt class="pubdef"><a name="PL_next_solution()"><var>int</var> <strong>PL_next_solution</strong>(<var>qid_t
24962458 qid</var>)</a></dt>
24972459 <dd class="defbody">
24982460 Generate the first (next) solution for the given query. The return value
25002462 indicate the query could not be proven. This function may be called
25012463 repeatedly until it fails to generate all solutions to the query.
25022464 </dd>
2503 <dt class="pubdef"><a id="PL_cut_query()"><var>void</var> <strong>PL_cut_query</strong>(<var>qid_t
2465 <dt class="pubdef"><a name="PL_cut_query()"><var>void</var> <strong>PL_cut_query</strong>(<var>qid_t
25042466 qid</var>)</a></dt>
25052467 <dd class="defbody">
25062468 Discards the query, but does not delete any of the data created by the
25072469 query. It just invalidates <var>qid</var>, allowing for a new call to
25082470 <a class="func" href="foreigninclude.html#PL_open_query()">PL_open_query()</a>
25092471 in this context.</dd>
2510 <dt class="pubdef"><a id="PL_close_query()"><var>void</var> <strong>PL_close_query</strong>(<var>qid_t
2472 <dt class="pubdef"><a name="PL_close_query()"><var>void</var> <strong>PL_close_query</strong>(<var>qid_t
25112473 qid</var>)</a></dt>
25122474 <dd class="defbody">
25132475 As <a class="func" href="foreigninclude.html#PL_cut_query()">PL_cut_query()</a>,
25142476 but all data and bindings created by the query are destroyed.</dd>
2515 <dt class="pubdef"><a id="PL_current_query()"><var>qid_t</var> <strong>PL_current_query</strong>(<var>void</var>)</a></dt>
2477 <dt class="pubdef"><a name="PL_current_query()"><var>qid_t</var> <strong>PL_current_query</strong>(<var>void</var>)</a></dt>
25162478 <dd class="defbody">
25172479 Returns the query id of of the current query or <code>0</code> if the
25182480 current thread is not executing any queries.</dd>
2519 <dt class="pubdef"><a id="PL_call_predicate()"><var>int</var> <strong>PL_call_predicate</strong>(<var>module_t
2481 <dt class="pubdef"><a name="PL_call_predicate()"><var>int</var> <strong>PL_call_predicate</strong>(<var>module_t
25202482 m, int flags, predicate_t pred, term_t +t0</var>)</a></dt>
25212483 <dd class="defbody">
25222484 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>,
25242486 <a class="func" href="foreigninclude.html#PL_open_query()">PL_open_query()</a>,
25252487 the return value is the same as <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>.
25262488 </dd>
2527 <dt class="pubdef"><a id="PL_call()"><var>int</var> <strong>PL_call</strong>(<var>term_t
2489 <dt class="pubdef"><a name="PL_call()"><var>int</var> <strong>PL_call</strong>(<var>term_t
25282490 t, module_t m</var>)</a></dt>
25292491 <dd class="defbody">
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>
2492 Call term <var>t</var> just like the Prolog predicate <a name="idx:once1:2049"></a><a class="pred" href="metacall.html#once/1">once/1</a>. <var>t</var>
25312493 is called in the module <var>m</var>, or in the context module if <var>m</var>
25322494 == NULL. Returns <code>TRUE</code> if the call succeeds, <code>FALSE</code>
25332495 otherwise.
25372499 </dd>
25382500 </dl>
25392501
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
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
25412503 Data</span></a></h3>
25422504
2543 <a id="sec:foreign-discard-term-t"></a>
2505 <a name="sec:foreign-discard-term-t"></a>
25442506
25452507 <p>The Prolog data created and term references needed to set up the call
25462508 and/or analyse the result can in most cases be discarded right after the
25502512 8</a> for an example.
25512513
25522514 <dl class="latex">
2553 <dt class="pubdef"><a id="PL_open_foreign_frame()"><var>fid_t</var> <strong>PL_open_foreign_frame</strong>(<var></var>)</a></dt>
2515 <dt class="pubdef"><a name="PL_open_foreign_frame()"><var>fid_t</var> <strong>PL_open_foreign_frame</strong>(<var></var>)</a></dt>
25542516 <dd class="defbody">
25552517 Create a foreign frame, holding a mark that allows the system to undo
25562518 bindings and destroy data created after it, as well as providing the
25572519 environment for creating term references. This function is called by the
25582520 kernel before calling a foreign predicate.
25592521 </dd>
2560 <dt class="pubdef"><a id="PL_close_foreign_frame()"><var>void</var> <strong>PL_close_foreign_frame</strong>(<var>fid_t
2522 <dt class="pubdef"><a name="PL_close_foreign_frame()"><var>void</var> <strong>PL_close_foreign_frame</strong>(<var>fid_t
25612523 id</var>)</a></dt>
25622524 <dd class="defbody">
25632525 Discard all term references created after the frame was opened. All
25642526 other Prolog data is retained. This function is called by the kernel
25652527 whenever a foreign function returns control back to Prolog.
25662528 </dd>
2567 <dt class="pubdef"><a id="PL_discard_foreign_frame()"><var>void</var> <strong>PL_discard_foreign_frame</strong>(<var>fid_t
2529 <dt class="pubdef"><a name="PL_discard_foreign_frame()"><var>void</var> <strong>PL_discard_foreign_frame</strong>(<var>fid_t
25682530 id</var>)</a></dt>
25692531 <dd class="defbody">
25702532 Same as <a class="func" href="foreigninclude.html#PL_close_foreign_frame()">PL_close_foreign_frame()</a>,
25712533 but also undo all bindings made since the open and destroy all Prolog
25722534 data.
25732535 </dd>
2574 <dt class="pubdef"><a id="PL_rewind_foreign_frame()"><var>void</var> <strong>PL_rewind_foreign_frame</strong>(<var>fid_t
2536 <dt class="pubdef"><a name="PL_rewind_foreign_frame()"><var>void</var> <strong>PL_rewind_foreign_frame</strong>(<var>fid_t
25752537 id</var>)</a></dt>
25762538 <dd class="defbody">
25772539 Undo all bindings and discard all term references created since the
26052567 </pre>
26062568
26072569 <div class="caption"><b>Figure 8 : </b>Calling Prolog</div>
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
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
26112573 Code and Modules</span></a></h3>
26122574
2613 <a id="sec:foreign-modules"></a>
2575 <a name="sec:foreign-modules"></a>
26142576
26152577 <p>Modules are identified via a unique handle. The following functions
26162578 are available to query and manipulate modules.
26172579
26182580 <dl class="latex">
2619 <dt class="pubdef"><a id="PL_context()"><var>module_t</var> <strong>PL_context</strong>(<var></var>)</a></dt>
2581 <dt class="pubdef"><a name="PL_context()"><var>module_t</var> <strong>PL_context</strong>(<var></var>)</a></dt>
26202582 <dd class="defbody">
26212583 Return the module identifier of the context module of the currently
26222584 active foreign predicate.</dd>
2623 <dt class="pubdef"><a id="PL_strip_module()"><var>int</var> <strong>PL_strip_module</strong>(<var>term_t
2585 <dt class="pubdef"><a name="PL_strip_module()"><var>int</var> <strong>PL_strip_module</strong>(<var>term_t
26242586 +raw, module_t *m, term_t -plain</var>)</a></dt>
26252587 <dd class="defbody">
26262588 Utility function. If <var>raw</var> is a term, possibly holding the
26462608 </pre>
26472609
26482610 </dd>
2649 <dt class="pubdef"><a id="PL_module_name()"><var>atom_t</var> <strong>PL_module_name</strong>(<var>module_t
2611 <dt class="pubdef"><a name="PL_module_name()"><var>atom_t</var> <strong>PL_module_name</strong>(<var>module_t
26502612 module</var>)</a></dt>
26512613 <dd class="defbody">
26522614 Return the name of <var>module</var> as an atom.
26532615 </dd>
2654 <dt class="pubdef"><a id="PL_new_module()"><var>module_t</var> <strong>PL_new_module</strong>(<var>atom_t
2616 <dt class="pubdef"><a name="PL_new_module()"><var>module_t</var> <strong>PL_new_module</strong>(<var>atom_t
26552617 name</var>)</a></dt>
26562618 <dd class="defbody">
26572619 Find an existing module or create a new module with the name <var>name</var>.
26582620 </dd>
26592621 </dl>
26602622
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
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
26622624 exceptions in foreign code</span></a></h3>
26632625
2664 <a id="sec:foreign-exceptions"></a>
2626 <a name="sec:foreign-exceptions"></a>
26652627
26662628 <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>
26672629 and
26922654 or
26932655 <a class="func" href="foreigninclude.html#PL_discard_foreign_frame()">PL_discard_foreign_frame()</a>
26942656 afterwards, as this will invalidate the exception term. Below is the
2695 code that calls a Prolog-defined arithmetic function (see <a id="idx:arithmeticfunction1:2051"></a><span class="pred-ext">arithmetic_function/1</span>).
2657 code that calls a Prolog-defined arithmetic function (see <a name="idx:arithmeticfunction1:2050"></a><span class="pred-ext">arithmetic_function/1</span>).
26962658
26972659 <p>If <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>
26982660 succeeds, the result is analysed and translated to a number, after which
27422704 </pre>
27432705
27442706 <dl class="latex">
2745 <dt class="pubdef"><a id="PL_raise_exception()"><var>int</var> <strong>PL_raise_exception</strong>(<var>term_t
2707 <dt class="pubdef"><a name="PL_raise_exception()"><var>int</var> <strong>PL_raise_exception</strong>(<var>term_t
27462708 exception</var>)</a></dt>
27472709 <dd class="defbody">
2748 Generate an exception (as <a id="idx:throw1:2052"></a><a class="pred" href="exception.html#throw/1">throw/1</a>)
2710 Generate an exception (as <a name="idx:throw1:2051"></a><a class="pred" href="exception.html#throw/1">throw/1</a>)
27492711 and return <code>FALSE</code>. Below is an example returning an
27502712 exception from a foreign predicate:
27512713
27722734 </pre>
27732735
27742736 </dd>
2775 <dt class="pubdef"><a id="PL_throw()"><var>int</var> <strong>PL_throw</strong>(<var>term_t
2737 <dt class="pubdef"><a name="PL_throw()"><var>int</var> <strong>PL_throw</strong>(<var>term_t
27762738 exception</var>)</a></dt>
27772739 <dd class="defbody">
27782740 Similar to <a class="func" href="foreigninclude.html#PL_raise_exception()">PL_raise_exception()</a>,
27792741 but returns using the C longjmp() function to the innermost <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>.</dd>
2780 <dt class="pubdef"><a id="PL_exception()"><var>term_t</var> <strong>PL_exception</strong>(<var>qid_t
2742 <dt class="pubdef"><a name="PL_exception()"><var>term_t</var> <strong>PL_exception</strong>(<var>qid_t
27812743 qid</var>)</a></dt>
27822744 <dd class="defbody">
27832745 If <a class="func" href="foreigninclude.html#PL_next_solution()">PL_next_solution()</a>
27842746 fails, this can be due to normal failure of the Prolog call, or because
2785 an exception was raised using <a id="idx:throw1:2053"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
2747 an exception was raised using <a name="idx:throw1:2052"></a><a class="pred" href="exception.html#throw/1">throw/1</a>.
27862748 This function returns a handle to the exception term if an exception was
27872749 raised, or 0 if the Prolog goal simply failed. If there is an exception,
27882750 <a class="func" href="foreigninclude.html#PL_exception()">PL_exception()</a>
27932755 pending exception in the current query or 0 if no exception is pending.
27942756 This can be used to check the error status after a failing call to,
27952757 e.g., one of the unification functions.</dd>
2796 <dt class="pubdef"><a id="PL_clear_exception()"><var>void</var> <strong>PL_clear_exception</strong>(<var>void</var>)</a></dt>
2758 <dt class="pubdef"><a name="PL_clear_exception()"><var>void</var> <strong>PL_clear_exception</strong>(<var>void</var>)</a></dt>
27972759 <dd class="defbody">
27982760 Tells Prolog that the encountered exception must be ignored. This
27992761 function must be called if control remains in C after a previous API
2800 call fails with an exception.<sup class="fn">173<span class="fn-text">This
2762 call fails with an exception.<sup class="fn">172<span class="fn-text">This
28012763 feature is non-portable. Other Prolog systems (e.g., YAP) have no
28022764 facilities to ignore raised exceptions, and the design of YAP's
28032765 exception handling does not support such a facility.</span></sup>
28042766 </dd>
28052767 </dl>
28062768
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
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
28082770 Signals (Software Interrupts)</span></a></h3>
28092771
2810 <a id="sec:csignal"></a>
2772 <a name="sec:csignal"></a>
28112773
28122774 <p>SWI-Prolog offers both a C and Prolog interface to deal with software
28132775 interrupts (signals). The Prolog mapping is defined in
2814 <a class="sec" href="signal.html#sec:4.12">section 4.12</a>. This
2815 subsection deals with handling signals from C.
2776 <a class="sec" href="signal.html">section 4.12</a>. This subsection
2777 deals with handling signals from C.
28162778
28172779 <p>If a signal is not used by Prolog and the handler does not call
28182780 Prolog in any way, the native signal interface routines may be used.
28252787 Prolog.
28262788
28272789 <dl class="latex">
2828 <dt class="pubdef"><a id="PL_sigaction()"><var>int</var> <strong>PL_sigaction</strong>(<var>int
2790 <dt class="pubdef"><a name="PL_sigaction()"><var>int</var> <strong>PL_sigaction</strong>(<var>int
28292791 sig, pl_sigaction_t *act, pl_sigaction_t *oldact</var>)</a></dt>
28302792 <dd class="defbody">
28312793 Install or query the status for signal <var>sig</var>. The signal is an
28562818 <p>Finally, 0 (zero) may be passsed for <var>sig</var>. In that case the
28572819 system allocates a free signal in the <i>Prolog range</i> (32 ... 64).
28582820 Such signal handler are activated using <b>PL_thread_raise()</b>.</dd>
2859 <dt class="pubdef"><a id="PL_signal()"><var>void (*)()</var> <strong>PL_signal</strong>(<var>sig,
2821 <dt class="pubdef"><a name="PL_signal()"><var>void (*)()</var> <strong>PL_signal</strong>(<var>sig,
28602822 func</var>)</a></dt>
28612823 <dd class="defbody">
28622824 This function is equivalent to the BSD-Unix signal() function,
28792841 which is checked by <a class="func" href="foreigninclude.html#PL_handle_signals()">PL_handle_signals()</a>
28802842 at the call- and redo-port. This behaviour is realised by <em>or</em>-ing <var>sig</var>
28812843 with the constant
2882 <code>PL_SIGSYNC</code>.<sup class="fn">174<span class="fn-text">A
2844 <code>PL_SIGSYNC</code>.<sup class="fn">173<span class="fn-text">A
28832845 better default would be to use synchronous handling, but this interface
28842846 preserves backward compatibility.</span></sup>
28852847
28882850 The use of <a class="func" href="foreigninclude.html#PL_throw()">PL_throw()</a>
28892851 is not safe. If a synchronous handler raises an exception, the exception
28902852 is delayed to the next call to <a class="func" href="foreigninclude.html#PL_handle_signals()">PL_handle_signals()</a>;</dd>
2891 <dt class="pubdef"><a id="PL_raise()"><var>int</var> <strong>PL_raise</strong>(<var>int
2853 <dt class="pubdef"><a name="PL_raise()"><var>int</var> <strong>PL_raise</strong>(<var>int
28922854 sig</var>)</a></dt>
28932855 <dd class="defbody">
28942856 Register <var>sig</var> for <em>synchronous</em> handling by Prolog.
28952857 Synchronous signals are handled at the call-port or if foreign code
28962858 calls <a class="func" href="foreigninclude.html#PL_handle_signals()">PL_handle_signals()</a>.
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>
2859 See also <a name="idx:threadsignal2:2053"></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>
28992861 <dd class="defbody">
29002862 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>
29012863 is called at each pass through the call- and redo-port at a safe point.
29072869 signals handled. If a handler raises an exception, the return value is
29082870 -1 and the calling routine should return with <code>FALSE</code> as soon
29092871 as possible.</dd>
2910 <dt class="pubdef"><a id="PL_get_signum_ex()"><var>int</var> <strong>PL_get_signum_ex</strong>(<var>term_t
2872 <dt class="pubdef"><a name="PL_get_signum_ex()"><var>int</var> <strong>PL_get_signum_ex</strong>(<var>term_t
29112873 t, int *sig</var>)</a></dt>
29122874 <dd class="defbody">
29132875 Extract a signal specification from a Prolog term and store as an
29192881 </dd>
29202882 </dl>
29212883
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
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
29272889 Comparison</span></a></h4>
29282890
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
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
29332895 t1, term_t t2</var>)</a></dt>
29342896 <dd class="defbody">
29352897 Compares two terms using the standard order of terms and returns -1, 0
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
2898 or 1. See also <a name="idx:compare3:2054"></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
29392901 t1, term_t t2</var>)</a></dt>
29402902 <dd class="defbody">
29412903 Yields <code>TRUE</code> if <var>t1</var> and <var>t2</var> refer to
29432905 </dd>
29442906 </dl>
29452907
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
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
29472909 database</span></a></h4>
29482910
2949 <a id="sec:foreign-recorded"></a>
2911 <a name="sec:foreign-recorded"></a>
29502912
29512913 <p>In some applications it is useful to store and retrieve Prolog terms
29522914 from C code. For example, the XPCE graphical environment does this for
29602922
29612923 <p>Two groups of functions are provided. The first group (<a class="func" href="foreigninclude.html#PL_record()">PL_record()</a>
29622924 and friends) store Prolog terms on the Prolog heap for retrieval during
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>
2925 the same session. These functions are also used by <a name="idx:recorda3:2055"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
29642926 and friends. The recorded database may be used to communicate Prolog
29652927 terms between threads.
29662928
29672929 <dl class="latex">
2968 <dt class="pubdef"><a id="PL_record()"><var>record_t</var> <strong>PL_record</strong>(<var>term_t
2930 <dt class="pubdef"><a name="PL_record()"><var>record_t</var> <strong>PL_record</strong>(<var>term_t
29692931 +t</var>)</a></dt>
29702932 <dd class="defbody">
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>
2933 Record the term <var>t</var> into the Prolog database as <a name="idx:recorda3:2056"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
29722934 and return an opaque handle to the term. The returned handle remains
29732935 valid until <a class="func" href="foreigninclude.html#PL_erase()">PL_erase()</a>
29742936 is called on it. <a class="func" href="foreigninclude.html#PL_recorded()">PL_recorded()</a>
29752937 is used to copy recorded terms back to the Prolog stack.</dd>
2976 <dt class="pubdef"><a id="PL_duplicate_record()"><var>record_t</var> <strong>PL_duplicate_record</strong>(<var>record_t
2938 <dt class="pubdef"><a name="PL_duplicate_record()"><var>record_t</var> <strong>PL_duplicate_record</strong>(<var>record_t
29772939 record</var>)</a></dt>
29782940 <dd class="defbody">
29792941 Return a duplicate of <var>record</var>. As records are read-only
29802942 objects this function merely increments the records reference count.</dd>
2981 <dt class="pubdef"><a id="PL_recorded()"><var>int</var> <strong>PL_recorded</strong>(<var>record_t
2943 <dt class="pubdef"><a name="PL_recorded()"><var>int</var> <strong>PL_recorded</strong>(<var>record_t
29822944 record, term_t -t</var>)</a></dt>
29832945 <dd class="defbody">
29842946 Copy a recorded term back to the Prolog stack. The same record may be
29862948 on success, and <code>FALSE</code> if there is not enough space on the
29872949 stack to accommodate the term. See also <a class="func" href="foreigninclude.html#PL_record()">PL_record()</a>
29882950 and <a class="func" href="foreigninclude.html#PL_erase()">PL_erase()</a>.</dd>
2989 <dt class="pubdef"><a id="PL_erase()"><var>void</var> <strong>PL_erase</strong>(<var>record_t
2951 <dt class="pubdef"><a name="PL_erase()"><var>void</var> <strong>PL_erase</strong>(<var>record_t
29902952 record</var>)</a></dt>
29912953 <dd class="defbody">
29922954 Remove the recorded term from the Prolog database, reclaiming all
30252987 </ul>
30262988
30272989 <dl class="latex">
3028 <dt class="pubdef"><a id="PL_record_external()"><var>char *</var> <strong>PL_record_external</strong>(<var>term_t
2990 <dt class="pubdef"><a name="PL_record_external()"><var>char *</var> <strong>PL_record_external</strong>(<var>term_t
30292991 +t, size_t *len</var>)</a></dt>
30302992 <dd class="defbody">
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>
2993 Record the term <var>t</var> into the Prolog database as <a name="idx:recorda3:2057"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>
30322994 and return an opaque handle to the term. The returned handle remains
30332995 valid until <a class="func" href="foreigninclude.html#PL_erase_external()">PL_erase_external()</a>
30342996 is called on it.
30413003 <p><a class="func" href="foreigninclude.html#PL_recorded_external()">PL_recorded_external()</a>
30423004 is used to copy such recorded terms back to the Prolog stack.
30433005 </dd>
3044 <dt class="pubdef"><a id="PL_recorded_external()"><var>int</var> <strong>PL_recorded_external</strong>(<var>const
3006 <dt class="pubdef"><a name="PL_recorded_external()"><var>int</var> <strong>PL_recorded_external</strong>(<var>const
30453007 char *record, term_t -t</var>)</a></dt>
30463008 <dd class="defbody">
30473009 Copy a recorded term back to the Prolog stack. The same record may be
30493011 also <a class="func" href="foreigninclude.html#PL_record_external()">PL_record_external()</a>
30503012 and <a class="func" href="foreigninclude.html#PL_erase_external()">PL_erase_external()</a>.
30513013 </dd>
3052 <dt class="pubdef"><a id="PL_erase_external()"><var>int</var> <strong>PL_erase_external</strong>(<var>char
3014 <dt class="pubdef"><a name="PL_erase_external()"><var>int</var> <strong>PL_erase_external</strong>(<var>char
30533015 *record</var>)</a></dt>
30543016 <dd class="defbody">
30553017 Remove the recorded term from the Prolog database, reclaiming all
30573019 </dd>
30583020 </dl>
30593021
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
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
30613023 file names</span></a></h4>
30623024
3063 <a id="sec:cfilenames"></a>
3025 <a name="sec:cfilenames"></a>
30643026
30653027 <p>The function <a class="func" href="foreigninclude.html#PL_get_file_name()">PL_get_file_name()</a>
30663028 provides access to Prolog filenames and its file-search mechanism
3067 described with <a id="idx:absolutefilename3:2059"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
3029 described with <a name="idx:absolutefilename3:2058"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.
30683030 Its existence is motivated to realise a uniform interface to deal with
30693031 file properties, search, naming conventions, etc., from foreign code.
30703032
30713033 <dl class="latex">
3072 <dt class="pubdef"><a id="PL_get_file_name()"><var>int</var> <strong>PL_get_file_name</strong>(<var>term_t
3034 <dt class="pubdef"><a name="PL_get_file_name()"><var>int</var> <strong>PL_get_file_name</strong>(<var>term_t
30733035 spec, char **name, int flags</var>)</a></dt>
30743036 <dd class="defbody">
30753037 Translate a Prolog term into a file name. The name is stored in the
30933055 </dd>
30943056 <dt><b><code>PL_FILE_SEARCH</code></b></dt>
30953057 <dd class="defbody">
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>
3058 Invoke <a name="idx:absolutefilename3:2059"></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:2060"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
30983060 are used.
30993061 </dd>
31003062 <dt><b><code>PL_FILE_EXIST</code></b></dt>
31203082 </dl>
31213083
31223084 </dd>
3123 <dt class="pubdef"><a id="PL_get_file_nameW()"><var>int</var> <strong>PL_get_file_nameW</strong>(<var>term_t
3085 <dt class="pubdef"><a name="PL_get_file_nameW()"><var>int</var> <strong>PL_get_file_nameW</strong>(<var>term_t
31243086 spec, wchar_t **name, int flags</var>)</a></dt>
31253087 <dd class="defbody">
31263088 Same as <a class="func" href="foreigninclude.html#PL_get_file_name()">PL_get_file_name()</a>,
31313093 </dd>
31323094 </dl>
31333095
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
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
31353097 with Prolog flags from C</span></a></h4>
31363098
3137 <a id="sec:cprologflags"></a>
3099 <a name="sec:cprologflags"></a>
31383100
31393101 <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>.
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
3102 See <a name="idx:setprologflag2:2061"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>
3103 and <a name="idx:createprologflag3:2062"></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
31423104 current C API does not provide for a dedicated mechanism for fetching
31433105 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>
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
3106 using <a name="idx:currentprologflag2:2063"></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
31483110 char *name, int type, ...</var>)</a></dt>
31493111 <dd class="defbody">
31503112 Set/create a Prolog flag from C. <var>name</var> is the name of the
31753137 </dd>
31763138 </dl>
31773139
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
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
31793141 and warnings</span></a></h3>
31803142
3181 <a id="sec:foreign-print-warning"></a>
3143 <a name="sec:foreign-print-warning"></a>
31823144
31833145 <p><a class="func" href="foreigninclude.html#PL_warning()">PL_warning()</a>
31843146 prints a standard Prolog warning message to the standard error (<code>user_error</code>)
31853147 stream. Please note that new code should consider using <a class="func" href="foreigninclude.html#PL_raise_exception()">PL_raise_exception()</a>
3186 to raise a Prolog exception. See also <a class="sec" href="exception.html#sec:4.11">section
3148 to raise a Prolog exception. See also <a class="sec" href="exception.html">section
31873149 4.11</a>.
31883150
31893151 <dl class="latex">
3190 <dt class="pubdef"><a id="PL_warning()"><var>int</var> <strong>PL_warning</strong>(<var>format,
3152 <dt class="pubdef"><a name="PL_warning()"><var>int</var> <strong>PL_warning</strong>(<var>format,
31913153 a1, ...</var>)</a></dt>
31923154 <dd class="defbody">
31933155 Print an error message starting with `<code>[WARNING: </code>', followed
31973159 </dd>
31983160 </dl>
31993161
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
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
32013163 Control from Foreign Code</span></a></h3>
32023164
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,
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,
32073169 ...</var>)</a></dt>
32083170 <dd class="defbody">
32093171 Perform some action on the Prolog system. <var>int</var> describes the
32133175 <dl class="latex">
32143176 <dt><strong>PL_ACTION_TRACE</strong></dt>
32153177 <dd class="defbody">
3216 Start Prolog tracer (<a id="idx:trace0:2065"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>).
3178 Start Prolog tracer (<a name="idx:trace0:2064"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>).
32173179 Requires no arguments.</dd>
32183180 <dt><strong>PL_ACTION_DEBUG</strong></dt>
32193181 <dd class="defbody">
3220 Switch on Prolog debug mode (<a id="idx:debug0:2066"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>).
3182 Switch on Prolog debug mode (<a name="idx:debug0:2065"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>).
32213183 Requires no arguments.</dd>
32223184 <dt><strong>PL_ACTION_BACKTRACE</strong></dt>
32233185 <dd class="defbody">
32273189 <dd class="defbody">
32283190 Halt Prolog execution. This action should be called rather than Unix
32293191 exit() to give Prolog the opportunity to clean up. This call does not
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>
3192 return. The argument (an <code>int</code>) is the exit code. See <a name="idx:halt1:2066"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>.</dd>
32313193 <dt><strong>PL_ACTION_ABORT</strong></dt>
32323194 <dd class="defbody">
3233 Generate a Prolog abort (<a id="idx:abort0:2068"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
3195 Generate a Prolog abort (<a name="idx:abort0:2067"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>).
32343196 This call does not return. Requires no arguments.</dd>
32353197 <dt><strong>PL_ACTION_BREAK</strong></dt>
32363198 <dd class="defbody">
3237 Create a standard Prolog break environment (<a id="idx:break0:2069"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
3199 Create a standard Prolog break environment (<a name="idx:break0:2068"></a><a class="pred" href="toplevel.html#break/0">break/0</a>).
32383200 Returns after the user types the end-of-file character. Requires no
32393201 arguments.</dd>
32403202 <dt><strong>PL_ACTION_GUIAPP</strong></dt>
32573219 <dt><strong>PL_ACTION_ATTACH_CONSOLE</strong></dt>
32583220 <dd class="defbody">
32593221 Attach a console to a thread if it does not have one. See
3260 <a id="idx:attachconsole0:2070"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.</dd>
3222 <a name="idx:attachconsole0:2069"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.</dd>
32613223 <dt><strong>PL_GMP_SET_ALLOC_FUNCTIONS</strong></dt>
32623224 <dd class="defbody">
32633225 Takes an integer argument. If <code>TRUE</code>, the GMP allocations are
32723234 </dd>
32733235 </dl>
32743236
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
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
32763238 Prolog</span></a></h3>
32773239
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>
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>
32823244 <dd class="defbody">
32833245 Obtain status information on the Prolog system. The actual argument type
32843246 depends on the information required. <var>int</var> describes what
3285 information is wanted.<sup class="fn">176<span class="fn-text">Returning
3247 information is wanted.<sup class="fn">175<span class="fn-text">Returning
32863248 pointers and integers as a long is bad style. The signature of this
32873249 function should be changed.</span></sup> The options are given in <a class="tab" href="foreigninclude.html#tab:query">table
32883250 9</a>.
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
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
33023264 <var>10,000 &times; M + 100 &times; m + p</var>, where
33033265 <var>M</var> is the major, <var>m</var> the minor version number and <var>p</var>
33043266 the patch level. For example,
33053267 <code>20717</code> means <code>2.7.17</code>. </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>
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>
33103272 </table>
33113273 </blockquote>
33123274 <div class="caption"><b>Table 9 : </b><a class="func" href="foreigninclude.html#PL_query()">PL_query()</a>
33133275 options</div>
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
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
33193281 Foreign Predicates</span></a></h3>
33203282
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
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
33253287 *mod, char *name, int arity, foreign_t (*f)(), int flags, ...</var>)</a></dt>
33263288 <dd class="defbody">
33273289 Register the C function <var>f</var> to implement a Prolog predicate.
33363298 form a bitwise <em>or</em>'ed list of options for the installation.
33373299 These are:
33383300
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>
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>
33503312 </table>
33513313
33523314 <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>
33543316 This string must be exactly as long as the number of arguments of the
33553317 predicate and filled with characters from the set <code>0-9:^-+?</code>.
33563318 See
3357 <a id="idx:metapredicate1:2071"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
3319 <a name="idx:metapredicate1:2070"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
33583320 for details. <code>PL_FA_TRANSPARENT</code> is implied if at least one
33593321 meta-argument is provided (<code>0-9:^</code>). Note that meta-arguments
33603322 are <em>not always</em> passed as &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;.
33613323 Always use <a class="func" href="foreigninclude.html#PL_strip_module()">PL_strip_module()</a>
3362 to extract the module and plain term from a meta-argument.<sup class="fn">177<span class="fn-text">It
3324 to extract the module and plain term from a meta-argument.<sup class="fn">176<span class="fn-text">It
33633325 is encouraged to pass an additional <code>NULL</code> pointer for
33643326 non-meta-predicates.</span></sup>
33653327
33723334 is passed the same number of <code>term_t</code> arguments as the arity
33733335 of the predicate and, if the predicate is non-deterministic, an extra
33743336 argument of type
3375 <code>control_t</code> (see <a class="sec" href="foreigninclude.html#sec:11.4.1.1">section
3337 <code>control_t</code> (see <a class="sec" href="foreigninclude.html">section
33763338 11.4.1.1</a>). If <code>PL_FA_VARARGS</code> is provided, <var>function</var>
33773339 is called with three arguments. The first argument is a <code>term_t</code>
33783340 handle to the first argument. Further arguments can be reached by adding
34083370 </pre>
34093371
34103372 </dd>
3411 <dt class="pubdef"><a id="PL_register_foreign()"><var>int</var> <strong>PL_register_foreign</strong>(<var>const
3373 <dt class="pubdef"><a name="PL_register_foreign()"><var>int</var> <strong>PL_register_foreign</strong>(<var>const
34123374 char *name, int arity, foreign_t (*function)(), int flags, ...</var>)</a></dt>
34133375 <dd class="defbody">
34143376 Same as <a class="func" href="foreigninclude.html#PL_register_foreign_in_module()">PL_register_foreign_in_module()</a>,
34153377 passing <code>NULL</code> for the
34163378 <var>module</var>.</dd>
3417 <dt class="pubdef"><a id="PL_register_extensions_in_module()"><var>void</var> <strong>PL_register_extensions_in_module</strong>(<var>const
3379 <dt class="pubdef"><a name="PL_register_extensions_in_module()"><var>void</var> <strong>PL_register_extensions_in_module</strong>(<var>const
34183380 char *module, PL_extension *e</var>)</a></dt>
34193381 <dd class="defbody">
34203382 Register a series of predicates from an array of definitions of the type
34543416 </pre>
34553417
34563418 </dd>
3457 <dt class="pubdef"><a id="PL_register_extensions()"><var>void</var> <strong>PL_register_extensions</strong>(<var>
3419 <dt class="pubdef"><a name="PL_register_extensions()"><var>void</var> <strong>PL_register_extensions</strong>(<var>
34583420 PL_extension *e</var>)</a></dt>
34593421 <dd class="defbody">
34603422 Same as <a class="func" href="foreigninclude.html#PL_register_extensions_in_module()">PL_register_extensions_in_module()</a>
34623424 </dd>
34633425 </dl>
34643426
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
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
34663428 Code Hooks</span></a></h3>
34673429
3468 <a id="sec:foreign-hooks"></a>
3430 <a name="sec:foreign-hooks"></a>
34693431
34703432 <p>For various specific applications some hooks are provided.
34713433
34723434 <dl class="latex">
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>
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>
34743436 <dd class="defbody">
34753437 If this hook is not NULL, this function is called when reading from the
34763438 terminal. It is supposed to dispatch events when SWI-Prolog is connected
34853447 </pre>
34863448
34873449 </dd>
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>
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:2071"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
3453 is executed. SWI-Prolog <a name="idx:abort0:2072"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>
34923454 is implemented using C setjmp()/longjmp() construct. The hooks are
34933455 executed in the reverse order of their registration after the longjmp()
34943456 took place and before the Prolog top level is reinvoked. The type
34993461 </pre>
35003462
35013463 </dd>
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>
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>
35033465 <dd class="defbody">
35043466 Remove a hook installed with <a class="func" href="foreigninclude.html#PL_abort_hook()">PL_abort_hook()</a>.
35053467 Returns <code>FALSE</code> if no such hook is found, <code>TRUE</code>
35063468 otherwise.</dd>
3507 <dt class="pubdef"><a id="PL_on_halt()"><var>void</var> <strong>PL_on_halt</strong>(<var>int
3469 <dt class="pubdef"><a name="PL_on_halt()"><var>void</var> <strong>PL_on_halt</strong>(<var>int
35083470 (*f)(int, void *), void *closure</var>)</a></dt>
35093471 <dd class="defbody">
35103472 Register the function <var>f</var> to be called if SWI-Prolog is halted.
35123474 (0 if this cannot be determined) and the <var>closure</var> argument
35133475 passed to the <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>
35143476 call. Handlers <em>must</em> return 0. Other return values are reserved
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
3477 for future use. See also <a name="idx:athalt1:2073"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>.<sup class="fn">bug<span class="fn-text">Although
35163478 both <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</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>
3479 and <a name="idx:athalt1:2074"></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:2075"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
35193481 handlers are called before <em>all</em> <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>
35203482 handlers.</span></sup> These handlers are called <em>before</em> system
35213483 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>
3522 <dt class="pubdef"><a id="PL_exit_hook()"><var>void</var> <strong>PL_exit_hook</strong>(<var>int
3484 <dt class="pubdef"><a name="PL_exit_hook()"><var>void</var> <strong>PL_exit_hook</strong>(<var>int
35233485 (*f)(int, void *), void *closure</var>)</a></dt>
35243486 <dd class="defbody">
35253487 Similar to <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>,
35263488 but the hooks are executed by <a class="func" href="foreigninclude.html#PL_halt()">PL_halt()</a>
35273489 instead of <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</a>
35283490 just before calling exit().</dd>
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
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
35303492 new</var>)</a></dt>
35313493 <dd class="defbody">
35323494 Register a hook with the atom-garbage collector (see
3533 <a id="idx:garbagecollectatoms0:2077"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>)
3495 <a name="idx:garbagecollectatoms0:2076"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>)
35343496 that is called on any atom that is reclaimed. The old hook is returned.
35353497 If no hook is currently defined, <code>NULL</code> is returned. The
35363498 argument of the called hook is the atom that is to be garbage collected.
35683530 <p></dd>
35693531 </dl>
35703532
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
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
35723534 foreign data</span></a></h3>
35733535
3574 <a id="sec:foreigndata"></a>
3536 <a name="sec:foreigndata"></a>
35753537
35763538 <p>When combining foreign code with Prolog, it can be necessary to make
35773539 data represented in the foreign language available to Prolog. For
35953557 <p>
35963558 <li><i>Opaque packed data on the stacks</i><br>
35973559 It is possible to represent the raw binary representation of the foreign
3598 object as a Prolog string (see <a class="sec" href="strings.html#sec:5.2">section
3560 object as a Prolog string (see <a class="sec" href="strings.html">section
35993561 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>
36003562 and retrieved using
36013563 <a class="func" href="foreigninclude.html#PL_get_string_chars()">PL_get_string_chars()</a>.
36023564 It is good practice to wrap the string in a compound term with arity 1,
36033565 so Prolog can identify the type. The hook
3604 <a id="idx:portray1:2078"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
3566 <a name="idx:portray1:2077"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
36053567 rules may be used to streamline printing such terms during development.
36063568
36073569 <p>
36083570 <li><i>Opaque packed data in a blob</i><br>
36093571 Similar to the above solution, binary data can be stored in an atom. The
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.
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.
36143575
36153576 <p>
36163577 <li><i>Natural foreign data, passed as a pointer</i><br>
36523613 implements a predicate. If the predicate is deterministic, foreign
36533614 automatic variables are suitable. If the predicate is non-deterministic,
36543615 the data may be allocated using malloc() and a pointer may be passed.
3655 See <a class="sec" href="foreigninclude.html#sec:11.4.1.1">section
3656 11.4.1.1</a>.
3616 See <a class="sec" href="foreigninclude.html">section 11.4.1.1</a>.
36573617 </ol>
36583618 </ul>
36593619
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
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
36613621 for storing foreign data</span></a></h4>
36623622
3663 <a id="sec:foreign-store-data"></a>
3623 <a name="sec:foreign-store-data"></a>
36643624
36653625 <p>In this section, we outline some examples, covering typical cases. In
36663626 the first example, we will deal with extending Prolog's data
37523712 }
37533713 </pre>
37543714
3755 <p><b>The DDE interface</b> (see <a class="sec" href="DDE.html#sec:4.43">section
3715 <p><b>The DDE interface</b> (see <a class="sec" href="DDE.html">section
37563716 4.43</a>) represents another common usage of the foreign interface:
37573717 providing communication to new operating system features. The DDE
37583718 interface requires knowledge about active DDE server and client
37783738 debugging purposes, wrapping the handle in a compound is a good
37793739 suggestion.
37803740
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
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
37823742 SWI-Prolog in other applications</span></a></h3>
37833743
3784 <a id="sec:embedded"></a>
3744 <a name="sec:embedded"></a>
37853745
37863746 <p>With embedded Prolog we refer to the situation where the `main'
37873747 program is not the Prolog application. Prolog is sometimes embedded in
38123772 </pre>
38133773
38143774 <dl class="latex">
3815 <dt class="pubdef"><a id="PL_initialise()"><var>int</var> <strong>PL_initialise</strong>(<var>int
3775 <dt class="pubdef"><a name="PL_initialise()"><var>int</var> <strong>PL_initialise</strong>(<var>int
38163776 argc, char **argv</var>)</a></dt>
38173777 <dd class="defbody">
38183778 Initialises the SWI-Prolog heap and stacks, restores the Prolog state,
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>
3779 loads the system and personal initialisation files, runs the <a name="idx:initialization1:2078"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
38203780 hooks and finally runs the
38213781 <strong>-g</strong> <var>goal</var> hook.
38223782
38323792 <ul class="latex">
38333793 <li>See whether a Prolog saved state is appended to the file. If this is
38343794 the case, this state will be loaded instead of the default <code>boot.prc</code>
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>.
3795 file from the SWI-Prolog home directory. See also <a name="idx:qsaveprogram12:2079"></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>.
38373797 <li>Find the Prolog home directory. This process is described in detail
3838 in <a class="sec" href="findhome.html#sec:11.6">section 11.6</a>.
3798 in <a class="sec" href="findhome.html">section 11.6</a>.
38393799 </ul>
38403800
38413801 <p><a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
38773837 <code>"libpl.dll"</code> as <code>argv[0]</code>. If the Prolog state is
38783838 attached to a DLL (see the <strong>-dll</strong> option of <b>swipl-ld</b>),
38793839 pass the name of this DLL.</dd>
3880 <dt class="pubdef"><a id="PL_is_initialised()"><var>int</var> <strong>PL_is_initialised</strong>(<var>int
3840 <dt class="pubdef"><a name="PL_is_initialised()"><var>int</var> <strong>PL_is_initialised</strong>(<var>int
38813841 *argc, char ***argv</var>)</a></dt>
38823842 <dd class="defbody">
38833843 Test whether the Prolog engine is already initialised. Returns
38853845 otherwise. If the engine is initialised and <var>argc</var> is not <code>NULL</code>,
38863846 the argument count used with <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
38873847 is stored in <var>argc</var>. Same for the argument vector <var>argv</var>.</dd>
3888 <dt class="pubdef"><a id="PL_set_resource_db_mem()"><var>int</var> <strong>PL_set_resource_db_mem</strong>(<var>const
3848 <dt class="pubdef"><a name="PL_set_resource_db_mem()"><var>int</var> <strong>PL_set_resource_db_mem</strong>(<var>const
38893849 unsigned char *data, size_t size</var>)</a></dt>
38903850 <dd class="defbody">
38913851 This function must be called at most once and <em>before</em> calling
38923852 <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>.
38933853 The memory area designated by <var>data</var> and <var>size</var> must
38943854 contain the resource data and be in the format as produced by
3895 <a id="idx:qsaveprogram2:2081"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
3855 <a name="idx:qsaveprogram2:2080"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
38963856 The memory area is accessed by <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
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
3857 as well as calls to <a name="idx:openresource3:2081"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.<sup class="fn">177<span class="fn-text">This
38983858 implies that the data must remain accessible during the lifetime of the
3899 process if <a id="idx:openresource3:2083"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
3859 process if <a name="idx:openresource3:2082"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
39003860 is used. Future versions may provide a function to detach the resource
3901 database and cause <a id="idx:openresource3:2084"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
3861 database and cause <a name="idx:openresource3:2083"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
39023862 to raise an exception.</span></sup>
39033863
39043864 <p>For example, we can include the bootstrap data into an embedded
39073867
39083868 <p>
39093869 <ol class="latex">
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>
3870 <li>Create a saved state using <a name="idx:qsaveprogram2:2084"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
39113871 or
39123872
39133873 <pre class="code">
39843944 <p>As Jose Morales pointed at
39853945 <a class="url" href="https://github.com/graphitemaster/incbin">https://github.com/graphitemaster/incbin</a>,
39863946 which contains a portability layer on top of the above idea.</dd>
3987 <dt class="pubdef"><a id="PL_toplevel()"><var>int</var> <strong>PL_toplevel</strong>(<var></var>)</a></dt>
3947 <dt class="pubdef"><a name="PL_toplevel()"><var>int</var> <strong>PL_toplevel</strong>(<var></var>)</a></dt>
39883948 <dd class="defbody">
39893949 Runs the goal of the <strong>-t</strong> <var>toplevel</var> switch
3990 (default <a id="idx:prolog0:2086"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>)
3950 (default <a name="idx:prolog0:2085"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>)
39913951 and returns 1 if successful, 0 otherwise.</dd>
3992 <dt class="pubdef"><a id="PL_cleanup()"><var>int</var> <strong>PL_cleanup</strong>(<var>int
3952 <dt class="pubdef"><a name="PL_cleanup()"><var>int</var> <strong>PL_cleanup</strong>(<var>int
39933953 status</var>)</a></dt>
39943954 <dd class="defbody">
39953955 This function performs the reverse of <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>.
39963956 It runs the
39973957 <a class="func" href="foreigninclude.html#PL_on_halt()">PL_on_halt()</a>
3998 and <a id="idx:athalt1:2087"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
3958 and <a name="idx:athalt1:2086"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
39993959 handlers, closes all streams (except for the `standard I/O' streams
40003960 which are flushed only), deallocates all memory if <var>status</var>
40013961 equals `0' and restores all signal handlers. The
40053965 <p>The function returns <code>TRUE</code> if successful and <code>FALSE</code>
40063966 otherwise. Currently, <code>FALSE</code> is returned when an attempt is
40073967 made to call <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</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>.
3968 recursively or if one of the exit handlers cancels the termination using <a name="idx:cancelhalt1:2087"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>.
40093969 Exit handlers may only cancel termination if <var>status</var> is 0.
40103970
40113971 <p>In theory, this function allows deleting and restarting the Prolog
40173977 you want to use Prolog temporarily, consider running it in a separate
40183978 process. If you want to be able to reset Prolog, your options are
40193979 (again) a separate process, modules or threads.</dd>
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>.
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:2088"></a><a class="pred" href="profile.html#profile/1">profile/1</a>.
40233983 The call is intended to be used in combination with fork():
40243984
40253985 <pre class="code">
40313991
40323992 <p>The call behaves the same on Windows, though there is probably no
40333993 meaningful application.</dd>
4034 <dt class="pubdef"><a id="PL_halt()"><var>int</var> <strong>PL_halt</strong>(<var>int
3994 <dt class="pubdef"><a name="PL_halt()"><var>int</var> <strong>PL_halt</strong>(<var>int
40353995 status</var>)</a></dt>
40363996 <dd class="defbody">
40373997 Clean up the Prolog environment using <a class="func" href="foreigninclude.html#PL_cleanup()">PL_cleanup()</a>
40404000 </dd>
40414001 </dl>
40424002
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,
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,
40444004 Signals and embedded Prolog</span></a></h4>
40454005
4046 <a id="sec:sigembedded"></a>
4006 <a name="sec:sigembedded"></a>
40474007
40484008 <p>This section applies to Unix-based environments that have signals or
40494009 multithreading. The Windows version is compiled for multithreading, and
40684028 <dd>
40694029 has an empty signal handler. This signal is sent to a thread after
40704030 sending a thread-signal (see
4071 <a id="idx:threadsignal2:2090"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>).
4031 <a name="idx:threadsignal2:2089"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>).
40724032 It causes blocking system calls to return with <code>EINTR</code>, which
40734033 gives them the opportunity to react to thread-signals.
40744034
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreignoverview.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreigntypes.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:foreignlink"><a id="sec:11.2"><span class="sec-nr">11.2</span> <span class="sec-title">Linking
194 <h2 id="sec:foreignlink"><a name="sec:11.2"><span class="sec-nr">11.2</span> <span class="sec-title">Linking
236195 Foreign Modules</span></a></h2>
237196
238 <a id="sec:foreignlink"></a>
197 <a name="sec:foreignlink"></a>
239198
240199 <p>Foreign modules may be linked to Prolog in two ways. Using
241200 <em>static linking</em>, the extensions, a (short) file defining main()
244203 executable. Using <em>dynamic linking</em>, the extensions are linked to
245204 a shared library (<code>.so</code> file on most Unix systems) or dynamic
246205 link library (<code>.DLL</code> file on Microsoft platforms) and loaded
247 into the running Prolog process.<sup class="fn">168<span class="fn-text">The
206 into the running Prolog process.<sup class="fn">167<span class="fn-text">The
248207 system also contains code to load <code>.o</code> files directly for
249208 some operating systems, notably Unix systems using the BSD <code>a.out</code>
250209 executable format. As the number of Unix platforms supporting this
251210 quickly gets smaller and this interface is difficult to port and slow,
252211 it is no longer described in this manual. The best alternative would be
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
212 to use the <a name="idx:dld:2010">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
257216 linking is provided?</span></a></h3>
258217
259 <a id="sec:foreign-linking"></a>
218 <a name="sec:foreign-linking"></a>
260219
261220 <p>The <em>static linking</em> schema can be used on all versions of
262221 SWI-Prolog. Whether or not dynamic linking is supported can be deduced
263222 from the Prolog flag <a class="flag" href="flags.html#flag:open_shared_object">open_shared_object</a>
264223 (see
265 <a id="idx:currentprologflag2:2012"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
224 <a name="idx:currentprologflag2:2011"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
266225 If this Prolog flag yields <code>true</code>,
267 <a id="idx:opensharedobject2:2013"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
226 <a name="idx:opensharedobject2:2012"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
268227 and related predicates are defined. See
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
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
273232 kind of loading should I be using?</span></a></h3>
274233
275 <a id="sec:foreign-linking-options"></a>
234 <a name="sec:foreign-linking-options"></a>
276235
277236 <p>All described approaches have their advantages and disadvantages.
278237 Static linking is portable and allows for debugging on all platforms. It
279238 is relatively cumbersome and the libraries you need to pass to the
280239 linker may vary from system to system, though the utility program
281 <b>swipl-ld</b> described in <a class="sec" href="plld.html#sec:11.5">section
240 <b>swipl-ld</b> described in <a class="sec" href="plld.html">section
282241 11.5</a> often hides these problems from the user.
283242
284243 <p>Loading shared objects (DLL files on Windows) provides sharing and
285244 protection and is generally the best choice. If a saved state is created
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>
245 using <a name="idx:qsaveprogram12:2013"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>,
246 an <a name="idx:initialization1:2014"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
288247 directive may be used to load the appropriate library at startup.
289248
290249 <p>Note that the definition of the foreign predicates is the same,
291250 regardless of the linking type used.
292251
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):
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):
294253 Utility library for loading foreign objects (DLLs, shared objects)</span></a></h3>
295254
296 <p><a id="sec:shlib"></a>
255 <p><a name="sec:shlib"></a>
297256
298257 <p>This section discusses the functionality of the (autoload)
299258 <code>library(shlib)</code>, providing an interface to manage shared
348307 and provides the predicate defined in C.
349308
350309 <dl class="latex">
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,
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,
353312 +Entry:atom</var>)</a></dt>
354313 <dd class="defbody">
355314 Load a <i>shared object</i> or <i>DLL</i>. After loading the <var>Entry</var>
366325 </pre>
367326
368327 <table class="arglist">
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>.
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>.
370329 If searching the file fails, the plain name is passed to the OS to try
371330 the default method of the OS for locating foreign objects. The default
372331 definition of <a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
384343 </dl>
385344
386345 </dd>
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,
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,
389348 +Entry:atom</var>)</a></dt>
390349 <dd class="defbody">
391350 Load and install a foreign library as <a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>,2
402361 loads the library
403362 <i>immediately</i>. I.e. the difference is only relevant if the
404363 remainder of the file uses functionality of the C-library.</dd>
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,
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,
407366 +Exit:atom</var>)</a></dt>
408367 <dd class="defbody">
409368 Unload a <i>shared object</i> or <i>DLL</i>. After calling the <var>Exit</var>
410369 function, the shared object is removed from the process. The default
411370 exit function is composed from =uninstall_=, followed by the file
412371 base-name.</dd>
413 <dt class="pubdef"><a id="current_foreign_library/2"><strong>current_foreign_library</strong>(<var>?File,
372 <dt class="pubdef"><a name="current_foreign_library/2"><strong>current_foreign_library</strong>(<var>?File,
414373 ?Public</var>)</a></dt>
415374 <dd class="defbody">
416375 Query currently loaded shared libraries.</dd>
417 <dt class="pubdef"><a id="reload_foreign_libraries/0"><strong>reload_foreign_libraries</strong></a></dt>
376 <dt class="pubdef"><a name="reload_foreign_libraries/0"><strong>reload_foreign_libraries</strong></a></dt>
418377 <dd class="defbody">
419378 Reload all foreign libraries loaded (after restore of a state created
420379 using <a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
421380 </dd>
422381 </dl>
423382
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
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
425384 operations on shared libraries</span></a></h3>
426385
427 <a id="sec:sharedobj"></a>
386 <a name="sec:sharedobj"></a>
428387
429388 <p>The interface defined in this section allows the user to load shared
430389 libraries (<code>.so</code> files on most Unix systems, <code>.dll</code>
431390 files on Windows). This interface is portable to Windows as well as to
432391 Unix machines providing <strong>dlopen</strong>(2) (Solaris, Linux,
433392 FreeBSD, Irix and many more) or <strong>shl_open</strong>(2) (HP/UX). It
434 is advised to use the predicates from <a class="sec" href="foreignlink.html#sec:11.2.3">section
393 is advised to use the predicates from <a class="sec" href="foreignlink.html">section
435394 11.2.3</a> in your application.
436395
437396 <dl class="latex">
438 <dt class="pubdef"><a id="open_shared_object/2"><strong>open_shared_object</strong>(<var>+File,
397 <dt class="pubdef"><a name="open_shared_object/2"><strong>open_shared_object</strong>(<var>+File,
439398 -Handle</var>)</a></dt>
440399 <dd class="defbody">
441400 <var>File</var> is the name of a shared object file (DLL in MS-Windows).
442401 This file is attached to the current process, and
443402 <var>Handle</var> is unified with a handle to the library. Equivalent to
444403 <code>open_shared_object(File, Handle, [])</code>. See also
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>.
404 <a name="idx:opensharedobject3:2015"></a><a class="pred" href="foreignlink.html#open_shared_object/3">open_shared_object/3</a>
405 and <a name="idx:loadforeignlibrary1:2016"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>.
447406
448407 <p>On errors, an exception <code>shared_object(Action, Message)</code>
449408 is raised. <var>Message</var> is the return value from dlerror().</dd>
450 <dt class="pubdef"><a id="open_shared_object/3"><strong>open_shared_object</strong>(<var>+File,
409 <dt class="pubdef"><a name="open_shared_object/3"><strong>open_shared_object</strong>(<var>+File,
451410 -Handle, +Options</var>)</a></dt>
452411 <dd class="defbody">
453 As <a id="idx:opensharedobject2:2018"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>,
412 As <a name="idx:opensharedobject2:2017"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>,
454413 but allows for additional flags to be passed.
455414 <var>Options</var> is a list of atoms. <code>now</code> implies the
456415 symbols are resolved immediately rather than lazy (default). <code>global</code>
459418 not be supported by your operating system. Check the documentation of
460419 dlopen() or equivalent on your operating system. Unsupported flags are
461420 silently ignored.</dd>
462 <dt class="pubdef"><a id="close_shared_object/1"><strong>close_shared_object</strong>(<var>+Handle</var>)</a></dt>
421 <dt class="pubdef"><a name="close_shared_object/1"><strong>close_shared_object</strong>(<var>+Handle</var>)</a></dt>
463422 <dd class="defbody">
464423 Detach the shared object identified by <var>Handle</var>.</dd>
465 <dt class="pubdef"><a id="call_shared_object_function/2"><strong>call_shared_object_function</strong>(<var>+Handle,
424 <dt class="pubdef"><a name="call_shared_object_function/2"><strong>call_shared_object_function</strong>(<var>+Handle,
466425 +Function</var>)</a></dt>
467426 <dd class="defbody">
468427 Call the named function in the loaded shared library. The function is
472431 </dd>
473432 </dl>
474433
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
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
476435 Linking</span></a></h3>
477436
478 <a id="sec:staticl"></a>
437 <a name="sec:staticl"></a>
479438
480439 <p>Below is an outline of the file structure required for statically
481440 linking SWI-Prolog with foreign extensions. <code>.../swipl</code>
483442 <code>&lt;<var>arch</var>&gt;</code> refers to the architecture
484443 identifier that may be obtained using the Prolog flag <a class="flag" href="flags.html#flag:arch">arch</a>.
485444
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
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
489448 file </td></tr>
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
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
493452 declarations (AIX only) </td></tr>
494 <tr><td><code>.../swipl/include/stub.c</code> </td><td>Extension stub</td></tr>
453 <tr valign="top"><td><code>.../swipl/include/stub.c</code> </td><td>Extension
454 stub</td></tr>
495455 </table>
496456
497457 <p>The definition of the foreign predicates is the same as for dynamic
532492 libraries required by both the extensions and the SWI-Prolog kernel.
533493 This may be done by hand, or by using the <b>swipl-ld</b> utility
534494 described in
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.
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.
540500
541501 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreignxmp.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="runtime.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:foreignnotes"><a id="sec:11.8"><span class="sec-nr">11.8</span> <span class="sec-title">Notes
194 <h2 id="sec:foreignnotes"><a name="sec:11.8"><span class="sec-nr">11.8</span> <span class="sec-title">Notes
236195 on Using Foreign Code</span></a></h2>
237196
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
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
241200 debugging functions</span></a></h3>
242201
243 <a id="sec:foreign-debug"></a>
202 <a name="sec:foreign-debug"></a>
244203
245204 <p>The functions in this section are primarily intended for debugging
246205 foreign extensions or embedded Prolog. Violating the constraints of the
261220 critical location in your code or the system code.
262221
263222 <dl class="latex">
264 <dt class="pubdef"><a id="PL_backtrace()"><var>void</var> <strong>PL_backtrace</strong>(<var>int
223 <dt class="pubdef"><a name="PL_backtrace()"><var>void</var> <strong>PL_backtrace</strong>(<var>int
265224 depth, int flags</var>)</a></dt>
266225 <dd class="defbody">
267226 Dump a Prolog backtrace to the <code>user_error</code> stream. <var>Depth</var>
284243 </dl>
285244
286245 </dd>
287 <dt class="pubdef"><a id="PL_backtrace_string()"><var>char *</var> <strong>PL_backtrace_string</strong>(<var>int
246 <dt class="pubdef"><a name="PL_backtrace_string()"><var>char *</var> <strong>PL_backtrace_string</strong>(<var>int
288247 depth, int flags</var>)</a></dt>
289248 <dd class="defbody">
290249 As <a class="func" href="foreignnotes.html#PL_backtrace()">PL_backtrace()</a>,
303262 that exploits <b>gdb</b> and <a class="func" href="foreignnotes.html#PL_backtrace_string()">PL_backtrace_string()</a>
304263 to print stack traces in various formats for a SWI-Prolog process, given
305264 its process id.</dd>
306 <dt class="pubdef"><a id="PL_check_data()"><var>int</var> <strong>PL_check_data</strong>(<var>term_t
265 <dt class="pubdef"><a name="PL_check_data()"><var>int</var> <strong>PL_check_data</strong>(<var>term_t
307266 data</var>)</a></dt>
308267 <dd class="defbody">
309268 Check the consistency of the term <var>data</var>. Returns <code>TRUE</code>
311270 <code>FALSE</code> otherwise. The actual implementation only exists if
312271 the system is compiled with the cflag <code>-DO_DEBUG</code> or
313272 <code>-DO_MAINTENANCE</code>. This is <em>not</em> the default.</dd>
314 <dt class="pubdef"><a id="PL_check_stacks()"><var>int</var> <strong>PL_check_stacks</strong>(<var></var>)</a></dt>
273 <dt class="pubdef"><a name="PL_check_stacks()"><var>int</var> <strong>PL_check_stacks</strong>(<var></var>)</a></dt>
315274 <dd class="defbody">
316275 Check the consistency of the runtime stacks of the calling thread.
317276 Returns <code>TRUE</code> this is actually implemented in the current
325284 <p>The Prolog kernel sources use the macro <b>DEBUG(Topic, Code)</b>.
326285 These macros are disabled in the production version and must be enabled
327286 by recompiling the system as described above. Specific topics can be
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>
287 enabled and disabled using the predicates <a name="idx:prologdebug1:2093"></a><a class="pred" href="foreignnotes.html#prolog_debug/1">prolog_debug/1</a>
329288 and
330 <a id="idx:prolognodebug1:2095"></a><a class="pred" href="foreignnotes.html#prolog_nodebug/1">prolog_nodebug/1</a>.
289 <a name="idx:prolognodebug1:2094"></a><a class="pred" href="foreignnotes.html#prolog_nodebug/1">prolog_nodebug/1</a>.
331290 In addition, they can be activated from the commandline using
332291 commandline option <code>-d topics</code>, where
333292 <var>topics</var> is a comma-separated list of debug topics to enable.
339298 </pre>
340299
341300 <dl class="latex">
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>
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>
344303 <dd class="defbody">
345304 Enable/disable a debug topic. <var>Topic</var> is an atom that
346305 identifies the desired topic. The available topics are defined in
361320 </dd>
362321 </dl>
363322
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
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
365324 Allocation</span></a></h3>
366325
367 <a id="sec:foreign-malloc"></a>
326 <a name="sec:foreign-malloc"></a>
368327
369328 <p>SWI-Prolog's heap memory allocation is based on the <strong>malloc</strong>(3)
370329 library routines. SWI-Prolog provides the functions below as a wrapper
381340 functions on the same memory.
382341
383342 <dl class="latex">
384 <dt class="pubdef"><a id="PL_malloc()"><var>void *</var> <strong>PL_malloc</strong>(<var>size_t
343 <dt class="pubdef"><a name="PL_malloc()"><var>void *</var> <strong>PL_malloc</strong>(<var>size_t
385344 bytes</var>)</a></dt>
386345 <dd class="defbody">
387346 Allocate <var>bytes</var> of memory. On failure SWI-Prolog's fatal-error
389348 does not return. Memory allocated using these functions must use <a class="func" href="foreignnotes.html#PL_realloc()">PL_realloc()</a>
390349 and <a class="func" href="foreignnotes.html#PL_free()">PL_free()</a>
391350 rather than realloc() and free().</dd>
392 <dt class="pubdef"><a id="PL_realloc()"><var>void *</var> <strong>PL_realloc</strong>(<var>void
351 <dt class="pubdef"><a name="PL_realloc()"><var>void *</var> <strong>PL_realloc</strong>(<var>void
393352 *mem, size_t size</var>)</a></dt>
394353 <dd class="defbody">
395354 Change the size of the allocated chunk, possibly moving it. The
397356 or
398357 <a class="func" href="foreignnotes.html#PL_realloc()">PL_realloc()</a>
399358 call.</dd>
400 <dt class="pubdef"><a id="PL_free()"><var>void</var> <strong>PL_free</strong>(<var>void
359 <dt class="pubdef"><a name="PL_free()"><var>void</var> <strong>PL_free</strong>(<var>void
401360 *mem</var>)</a></dt>
402361 <dd class="defbody">
403362 Release memory. The <var>mem</var> argument must be obtained from a
407366 </dd>
408367 </dl>
409368
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
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
411370 support</span></a></h4>
412371
413 <a id="sec:boehm-gc"></a>
372 <a name="sec:boehm-gc"></a>
414373 <blockquote> This section is obsolete. Although the Boehm-GC interfaces
415374 still exist, it turns out that the scalability is not good enough for
416375 SWI-Prolog. It is unlikely that SWI-Prolog will ever switch to Boehm-GC.
417376 </blockquote>
418377
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>
378 <p><a name="idx:BoehmGC:2095"></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>
421380 for heap memory allocation, the interface provides the functions
422381 described below. Foreign extensions that wish to use the Boehm-GC
423382 facilities can use these wrappers. Please note that if SWI-Prolog is not
425384 to reclaim memory.
426385
427386 <dl class="latex">
428 <dt class="pubdef"><a id="PL_malloc_atomic()"><var>void*</var> <strong>PL_malloc_atomic</strong>(<var>size_t
387 <dt class="pubdef"><a name="PL_malloc_atomic()"><var>void*</var> <strong>PL_malloc_atomic</strong>(<var>size_t
429388 bytes</var>)</a></dt>
430 <dt class="pubdef"><a id="PL_malloc_uncollectable()"><var>void*</var> <strong>PL_malloc_uncollectable</strong>(<var>size_t
389 <dt class="pubdef"><a name="PL_malloc_uncollectable()"><var>void*</var> <strong>PL_malloc_uncollectable</strong>(<var>size_t
431390 bytes</var>)</a></dt>
432 <dt class="pubdef"><a id="PL_malloc_atomic_uncollectable()"><var>void*</var> <strong>PL_malloc_atomic_uncollectable</strong>(<var>size_t
391 <dt class="pubdef"><a name="PL_malloc_atomic_uncollectable()"><var>void*</var> <strong>PL_malloc_atomic_uncollectable</strong>(<var>size_t
433392 bytes</var>)</a></dt>
434393 <dd class="defbody">
435394 If Boehm-GC is not used, these are all the same as <a class="func" href="foreignnotes.html#PL_malloc()">PL_malloc()</a>.
438397 pointers, and <em>uncollectable</em> means that the object should never
439398 be garbage collected.
440399 </dd>
441 <dt class="pubdef"><a id="PL_malloc_stubborn()"><var>void*</var> <strong>PL_malloc_stubborn</strong>(<var>size_t
400 <dt class="pubdef"><a name="PL_malloc_stubborn()"><var>void*</var> <strong>PL_malloc_stubborn</strong>(<var>size_t
442401 bytes</var>)</a></dt>
443 <dt class="pubdef"><a id="PL_end_stubborn_change()"><var>void</var> <strong>PL_end_stubborn_change</strong>(<var>void
402 <dt class="pubdef"><a name="PL_end_stubborn_change()"><var>void</var> <strong>PL_end_stubborn_change</strong>(<var>void
444403 *memory</var>)</a></dt>
445404 <dd class="defbody">
446405 These functions allow creating objects, promising GC that the content
448407 </dd>
449408 </dl>
450409
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
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
452411 between Prolog versions</span></a></h3>
453412
454 <a id="sec:foreign-compat"></a>
413 <a name="sec:foreign-compat"></a>
455414
456415 <p>Great care is taken to ensure binary compatibility of foreign
457416 extensions between different Prolog versions. Only the much less
458417 frequently used stream interface has been responsible for binary
459418 incompatibilities.
460419
461 <p><a id="idx:PLVERSION:2097"></a>Source code that relies on new
420 <p><a name="idx:PLVERSION:2096"></a>Source code that relies on new
462421 features of the foreign interface can use the macro <code>PLVERSION</code>
463422 to find the version of
464423 <code>SWI-Prolog.h</code> and <a class="func" href="foreigninclude.html#PL_query()">PL_query()</a>
466425 <code>PL_QUERY_VERSION</code> to find the version of the attached Prolog
467426 system. Both follow the same numbering schema explained with <a class="func" href="foreigninclude.html#PL_query()">PL_query()</a>.
468427
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
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
470429 and profiling foreign code (valgrind)</span></a></h3>
471430
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
431 <a name="sec:foreign-debug-and-profile"></a>
432
433 <p><a name="idx:valgrind:2097"></a><a name="idx:profilingforeigncode:2098"></a>This
475434 section is only relevant for Unix users on platforms supported by
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().
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().
480438
481439 <p>The <b>callgrind</b> tool can be used to profile foreign code loaded
482440 under SWI-Prolog. Compile the foreign library adding <strong>-g</strong>
484442 variable <code>VALGRIND</code> to <code>yes</code>, SWI-Prolog will <em>not</em>
485443 release loaded shared objects using dlclose(). This trick is required to
486444 get source information on the loaded library. Without, valgrind claims
487 that the shared object has no debugging information.<sup class="fn">180<span class="fn-text">Tested
445 that the shared object has no debugging information.<sup class="fn">179<span class="fn-text">Tested
488446 using valgrind version 3.2.3 on x64.</span></sup> Here is the complete
489447 sequence using <b>bash</b> as login shell:
490448
494452 % kcachegrind callgrind.out.&lt;pid&gt;
495453 </pre>
496454
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
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
498456 Conflicts in C modules</span></a></h3>
499457
500 <a id="sec:foreign-name-conflicts"></a>
458 <a name="sec:foreign-name-conflicts"></a>
501459
502460 <p>In the current version of the system all public C functions of
503461 SWI-Prolog are in the symbol table. This can lead to name clashes with
516474 library loader will only look for symbols in the main executable for
517475 symbols that are not defined in the library itself.
518476
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
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
520478 of the Foreign Interface</span></a></h3>
521479
522 <a id="sec:foreign-quintus-sicstus"></a>
480 <a name="sec:foreign-quintus-sicstus"></a>
523481
524482 <p>The term reference mechanism was first used by Quintus Prolog version&nbsp;3.
525483 SICStus Prolog version 3 is strongly based on the Quintus interface. The
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreign.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreignlink.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:foreignoverview"><a id="sec:11.1"><span class="sec-nr">11.1</span> <span class="sec-title">Overview
194 <h2 id="sec:foreignoverview"><a name="sec:11.1"><span class="sec-nr">11.1</span> <span class="sec-title">Overview
236195 of the Interface</span></a></h2>
237196
238 <a id="sec:foreignoverview"></a>
197 <a name="sec:foreignoverview"></a>
239198
240199 <p>A special include file called <code>SWI-Prolog.h</code> should be
241200 included with each C source file that is to be loaded via the foreign
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="thutil.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="mt-xpce.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:foreignthread"><a id="sec:9.6"><span class="sec-nr">9.6</span> <span class="sec-title">Multithreaded
194 <h2 id="sec:foreignthread"><a name="sec:9.6"><span class="sec-nr">9.6</span> <span class="sec-title">Multithreaded
236195 mixed C and Prolog applications</span></a></h2>
237196
238 <a id="sec:foreignthread"></a>
197 <a name="sec:foreignthread"></a>
239198
240199 <p>All foreign code linked to the multithreading version of SWI-Prolog
241200 should be thread-safe (<em>reentrant</em>) or guarded in Prolog using
242 <a id="idx:withmutex2:1957"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
201 <a name="idx:withmutex2:1956"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
243202 from simultaneous access from multiple Prolog threads. If you want to
244203 write mixed multithreaded C and Prolog applications you should first
245204 familiarise yourself with writing multithreaded applications in C (C++).
250209 Without creating an engine, a thread can only use functions that do
251210 <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>).
252211
253 <p>The system supports two models. <a class="sec" href="foreignthread.html#sec:9.6.1">Section
212 <p>The system supports two models. <a class="sec" href="foreignthread.html">Section
254213 9.6.1</a> describes the original one-to-one mapping. In this schema a
255214 native thread attaches a Prolog thread if it needs to call Prolog and
256 detaches it when finished, as opposed to the model from <a class="sec" href="foreignthread.html#sec:9.6.2">section
215 detaches it when finished, as opposed to the model from <a class="sec" href="foreignthread.html">section
257216 9.6.2</a>, where threads temporarily use a Prolog engine.
258217
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
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
260219 Prolog thread for each native thread (one-to-one)</span></a></h3>
261220
262 <a id="sec:threadoneone"></a>
221 <a name="sec:threadoneone"></a>
263222
264223 <p>In the one-to-one model, the thread that called <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>
265224 has a Prolog engine attached. If another C thread in the system wishes
266225 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>
267226 and call <a class="func" href="foreignthread.html#PL_thread_destroy_engine()">PL_thread_destroy_engine()</a>
268227 after all Prolog work is finished. This model is especially suitable
269 with long running threads that need to do Prolog work regularly. See <a class="sec" href="foreignthread.html#sec:9.6.2">section
228 with long running threads that need to do Prolog work regularly. See <a class="sec" href="foreignthread.html">section
270229 9.6.2</a> for the alternative many-to-many model.
271230
272231 <dl class="latex">
273 <dt class="pubdef"><a id="PL_thread_self()"><var>int</var> <strong>PL_thread_self</strong>(<var></var>)</a></dt>
232 <dt class="pubdef"><a name="PL_thread_self()"><var>int</var> <strong>PL_thread_self</strong>(<var></var>)</a></dt>
274233 <dd class="defbody">
275234 Returns the integer Prolog identifier of the engine or -1 if the calling
276235 thread has no Prolog engine. This function is also provided in the
277236 single-threaded version of SWI-Prolog, where it returns -2.</dd>
278 <dt class="pubdef"><a id="PL_unify_thread_id()"><var>int</var> <strong>PL_unify_thread_id</strong>(<var>term_t
237 <dt class="pubdef"><a name="PL_unify_thread_id()"><var>int</var> <strong>PL_unify_thread_id</strong>(<var>term_t
279238 t, int i</var>)</a></dt>
280239 <dd class="defbody">
281240 Unify <var>t</var> with the Prolog thread identifier for thread <var>i</var>.
282241 Thread identifiers are normally returned from <a class="func" href="foreignthread.html#PL_thread_self()">PL_thread_self()</a>.
283242 Returns -1 if the thread does not exist or the unification fails.</dd>
284 <dt class="pubdef"><a id="PL_thread_attach_engine()"><var>int</var> <strong>PL_thread_attach_engine</strong>(<var>const
243 <dt class="pubdef"><a name="PL_thread_attach_engine()"><var>int</var> <strong>PL_thread_attach_engine</strong>(<var>const
285244 PL_thread_attr_t *attr</var>)</a></dt>
286245 <dd class="defbody">
287246 Creates a new Prolog engine in the calling thread. If the calling thread
320279 (as returned by <a class="func" href="foreignthread.html#PL_thread_self()">PL_thread_self()</a>).
321280 If an error occurs, -1 is returned. If this Prolog is not compiled for
322281 multithreading, -2 is returned.</dd>
323 <dt class="pubdef"><a id="PL_thread_destroy_engine()"><var>int</var> <strong>PL_thread_destroy_engine</strong>(<var></var>)</a></dt>
282 <dt class="pubdef"><a name="PL_thread_destroy_engine()"><var>int</var> <strong>PL_thread_destroy_engine</strong>(<var></var>)</a></dt>
324283 <dd class="defbody">
325284 Destroy the Prolog engine in the calling thread. Only takes effect if
326285 <a class="func" href="foreignthread.html#PL_thread_destroy_engine()">PL_thread_destroy_engine()</a>
333292 <p>Please note that construction and destruction of engines are
334293 relatively expensive operations. Only destroy an engine if performance
335294 is not critical and memory is a critical resource.</dd>
336 <dt class="pubdef"><a id="PL_thread_at_exit()"><var>int</var> <strong>PL_thread_at_exit</strong>(<var>void
295 <dt class="pubdef"><a name="PL_thread_at_exit()"><var>int</var> <strong>PL_thread_at_exit</strong>(<var>void
337296 (*function)(void *), void *closure, int global</var>)</a></dt>
338297 <dd class="defbody">
339298 Register a handle to be called as the Prolog engine is destroyed. The
343302 <em>for all threads</em>. Globally installed handlers are executed after
344303 the thread-local handlers. If the handler is installed local for the
345304 current thread only (<var>global</var> == <code>FALSE</code>) it is
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>.
305 stored in the same FIFO queue as used by <a name="idx:threadatexit1:1957"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>.
347306 </dd>
348307 </dl>
349308
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
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
351310 Prolog engines (many-to-many)</span></a></h3>
352311
353 <a id="sec:threadmanymany"></a>
312 <a name="sec:threadmanymany"></a>
354313
355314 <p>In this model Prolog engines live as entities that are independent
356315 from threads. If a thread needs to call Prolog it takes one of the
381340 </ul>
382341
383342 <dl class="latex">
384 <dt class="pubdef"><a id="PL_create_engine()"><var>PL_engine_t</var> <strong>PL_create_engine</strong>(<var>PL_thread_attr_t
343 <dt class="pubdef"><a name="PL_create_engine()"><var>PL_engine_t</var> <strong>PL_create_engine</strong>(<var>PL_thread_attr_t
385344 *attributes</var>)</a></dt>
386345 <dd class="defbody">
387346 Create a new Prolog engine. <var>attributes</var> is described with
394353
395354 <p>In the single-threaded version this call always returns <code>NULL</code>,
396355 indicating failure.</dd>
397 <dt class="pubdef"><a id="PL_destroy_engine()"><var>int</var> <strong>PL_destroy_engine</strong>(<var>PL_engine_t
356 <dt class="pubdef"><a name="PL_destroy_engine()"><var>int</var> <strong>PL_destroy_engine</strong>(<var>PL_engine_t
398357 e</var>)</a></dt>
399358 <dd class="defbody">
400359 Destroy the given engine. Destroying an engine is only allowed if the
401360 engine is not attached to any thread or attached to the calling thread.
402361 On success this function returns <code>TRUE</code>, on failure the
403362 return value is <code>FALSE</code>.</dd>
404 <dt class="pubdef"><a id="PL_set_engine()"><var>int</var> <strong>PL_set_engine</strong>(<var>PL_engine_t
363 <dt class="pubdef"><a name="PL_set_engine()"><var>int</var> <strong>PL_set_engine</strong>(<var>PL_engine_t
405364 engine, PL_engine_t *old</var>)</a></dt>
406365 <dd class="defbody">
407366 Make the calling thread ready to use <var>engine</var>. If <var>old</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreignlink.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreigninclude.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:foreigntypes"><a id="sec:11.3"><span class="sec-nr">11.3</span> <span class="sec-title">Interface
194 <h2 id="sec:foreigntypes"><a name="sec:11.3"><span class="sec-nr">11.3</span> <span class="sec-title">Interface
236195 Data Types</span></a></h2>
237196
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>:
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>:
241200 a reference to a Prolog term</span></a></h3>
242201
243 <a id="sec:type-term-t"></a>
202 <a name="sec:type-term-t"></a>
244203
245204 <p>The principal data type is <code>term_t</code>. Type <code>term_t</code>
246205 is what Quintus calls <code>QP_term_ref</code>. This name indicates
275234 <em>write</em> to term references. In this document we use the following
276235 notation for arguments of type <code>term_t</code>:
277236 <blockquote>
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>
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>
283244 </table>
284245 </blockquote>
285246
286247 <p><b>WARNING</b> Term references that are accessed in `write' (-) mode
287248 will refer to an invalid term if the term is allocated on the global
288249 stack and backtracking takes us back to a point before the term was
289 written.<sup class="fn">169<span class="fn-text">This could have been
250 written.<sup class="fn">168<span class="fn-text">This could have been
290251 avoided by <em>trailing</em> term references when data is written to
291252 them. This seriously hurds performance in some scenarios though. If this
292253 is desired, use <a class="func" href="foreigninclude.html#PL_put_variable()">PL_put_variable()</a>
343304 <code>term_t</code>, but all copies will always refer to the same term.
344305
345306 <dl class="latex">
346 <dt class="pubdef"><a id="PL_new_term_ref()"><var>term_t</var> <strong>PL_new_term_ref</strong>(<var></var>)</a></dt>
307 <dt class="pubdef"><a name="PL_new_term_ref()"><var>term_t</var> <strong>PL_new_term_ref</strong>(<var></var>)</a></dt>
347308 <dd class="defbody">
348309 Return a fresh reference to a term. The reference is allocated on the
349310 <em>local</em> stack. Allocating a term reference may trigger a
351312 allocation of the Prolog stacks. The returned reference describes a
352313 variable.
353314 </dd>
354 <dt class="pubdef"><a id="PL_new_term_refs()"><var>term_t</var> <strong>PL_new_term_refs</strong>(<var>int
315 <dt class="pubdef"><a name="PL_new_term_refs()"><var>term_t</var> <strong>PL_new_term_refs</strong>(<var>int
355316 n</var>)</a></dt>
356317 <dd class="defbody">
357318 Return <var>n</var> new term references. The first term reference is
371332 </pre>
372333
373334 </dd>
374 <dt class="pubdef"><a id="PL_copy_term_ref()"><var>term_t</var> <strong>PL_copy_term_ref</strong>(<var>term_t
335 <dt class="pubdef"><a name="PL_copy_term_ref()"><var>term_t</var> <strong>PL_copy_term_ref</strong>(<var>term_t
375336 from</var>)</a></dt>
376337 <dd class="defbody">
377338 Create a new term reference and make it point initially to the same term
378339 as <var>from</var>. This function is commonly used to copy a predicate
379340 argument to a term reference that may be written.
380341 </dd>
381 <dt class="pubdef"><a id="PL_reset_term_refs()"><var>void</var> <strong>PL_reset_term_refs</strong>(<var>term_t
342 <dt class="pubdef"><a name="PL_reset_term_refs()"><var>void</var> <strong>PL_reset_term_refs</strong>(<var>term_t
382343 after</var>)</a></dt>
383344 <dd class="defbody">
384345 Destroy all term references that have been created after <var>after</var>,
394355 </dd>
395356 </dl>
396357
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
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
398359 with the garbage collector and stack-shifter</span></a></h4>
399360
400 <a id="sec:foreign-gc"></a>
361 <a name="sec:foreign-gc"></a>
401362
402363 <p>Prolog implements two mechanisms for avoiding stack overflow: garbage
403364 collection and stack expansion. On machines that allow for it, Prolog
409370 the information necessary to perform its memory management without
410371 special precautions from the C programmer.
411372
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
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
413374 foreign interface types</span></a></h3>
414375
415 <a id="sec:foreign-types"></a>
376 <a name="sec:foreign-types"></a>
416377
417378 <dl class="latex">
418379 <dt><b>atom_t</b></dt>
469430 <dt><b>install_t</b></dt>
470431 <dd>
471432 Type for the install() and uninstall() functions of shared or dynamic
472 link libraries. See <a class="sec" href="foreignlink.html#sec:11.2.3">section
433 link libraries. See <a class="sec" href="foreignlink.html">section
473434 11.2.3</a>.
474435 </dd>
475436 <dt><b>int64_t</b></dt>
488449 </dd>
489450 </dl>
490451
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>
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>
494455
495456 <p>As of SWI-Prolog 7.3.12, the arity of terms has changed from <code>int</code>
496457 to <code>size_t</code>. To deal with this transition, all affecting
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="findhome.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreignnotes.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:foreignxmp"><a id="sec:11.7"><span class="sec-nr">11.7</span> <span class="sec-title">Example
194 <h2 id="sec:foreignxmp"><a name="sec:11.7"><span class="sec-nr">11.7</span> <span class="sec-title">Example
236195 of Using the Foreign Interface</span></a></h2>
237196
238 <a id="sec:foreignxmp"></a>
197 <a name="sec:foreignxmp"></a>
239198
240199 <p>Below is an example showing all stages of the declaration of a
241200 foreign predicate that transforms atoms possibly holding uppercase
277236 </pre>
278237
279238 <div class="caption"><b>Figure 10 : </b>Lowercase source file</div>
280 <a id="fig:lowercase-c"></a>
239 <a name="fig:lowercase-c"></a>
281240
282241 <pre class="code">
283242 % gcc -I/usr/local/lib/swipl-\plversion/include -fpic -c lowercase.c
295254
296255 <div class="caption"><b>Figure 11 : </b>Compiling the C source and
297256 loading the object file</div>
298 <a id="fig:load-foreign"></a>
257 <a name="fig:load-foreign"></a>
299258 </body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.32</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="forall2.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="gvar.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:format"><a id="sec:4.32"><span class="sec-nr">4.32</span> <span class="sec-title">Formatted
194 <h2 id="sec:format"><a name="sec:4.32"><span class="sec-nr">4.32</span> <span class="sec-title">Formatted
236195 Write</span></a></h2>
237196
238 <a id="sec:format"></a>
197 <a name="sec:format"></a>
239198
240199 <p>The current version of SWI-Prolog provides two formatted write
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>),
200 predicates. The `writef' family (<a name="idx:writef1:1385"></a><a class="pred" href="format.html#writef/1">writef/1</a>, <a name="idx:writef2:1386"></a><a class="pred" href="format.html#writef/2">writef/2</a>, <a name="idx:swritef3:1387"></a><a class="pred" href="format.html#swritef/3">swritef/3</a>),
242201 is compatible with Edinburgh C-Prolog and should be considered
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>),
202 <em>deprecated</em>. The `format' family (<a name="idx:format1:1388"></a><a class="pred" href="format.html#format/1">format/1</a>, <a name="idx:format2:1389"></a><a class="pred" href="format.html#format/2">format/2</a>, <a name="idx:format3:1390"></a><a class="pred" href="format.html#format/3">format/3</a>),
244203 was defined by Quintus Prolog and currently available in many Prolog
245204 systems, although the details vary.
246205
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>
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>
250209
251210 <dl class="latex">
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>
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:1391"></a><a class="pred" href="format.html#writef/2">writef/2</a>
255214 for details.
256215 </dd>
257 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="writef/2"><strong>writef</strong>(<var>+Format,
216 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="writef/2"><strong>writef</strong>(<var>+Format,
258217 +Arguments</var>)</a></dt>
259218 <dd class="defbody">
260219 Formatted write. <var>Format</var> is an atom whose characters will be
265224
266225 <p>Escape sequences to generate a single special character:
267226
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>
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:1392"></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>
275237 is output </td></tr>
276 <tr><td><code>\%</code> </td><td>The character <code><code>%</code></code>
238 <tr valign="top"><td><code>\%</code> </td><td>The character <code><code>%</code></code>
277239 is output </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>
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>
281243 </table>
282244
283245 <p>Note that <code>\l</code>, <code>\nnn</code> and <code>\\</code> are
284246 interpreted differently when character escapes are in effect. See
285 <a class="sec" href="syntax.html#sec:2.16.1.3">section 2.16.1.3</a>.
247 <a class="sec" href="syntax.html">section 2.16.1.3</a>.
286248
287249 <p>Escape sequences to include arguments from <var>Arguments</var>. Each
288250 time a
289251 % escape sequence is found in <var>Format</var> the next argument from <var>Arguments</var>
290252 is formatted according to the specification.
291253
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>
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:1393"></a><a class="pred" href="termrw.html#print/1">print/1</a>
294256 the next item (mnemonic: term) </td></tr>
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>
257 <tr valign="top"><td><code>%w</code> </td><td><a name="idx:write1:1394"></a><a class="pred" href="termrw.html#write/1">write/1</a>
296258 the next item </td></tr>
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>
259 <tr valign="top"><td><code>%q</code> </td><td><a name="idx:writeq1:1395"></a><a class="pred" href="termrw.html#writeq/1">writeq/1</a>
298260 the next item </td></tr>
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>
261 <tr valign="top"><td><code>%d</code> </td><td>Write the term, ignoring
262 operators. See also
263 <a name="idx:writeterm2:1396"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
264 Mnemonic: old Edinburgh <a name="idx:display1:1397"></a><span class="pred-ext">display/1</span> </td></tr>
265 <tr valign="top"><td><code>%p</code> </td><td><a name="idx:print1:1398"></a><a class="pred" href="termrw.html#print/1">print/1</a>
304266 the next item (identical to <code>%t</code>) </td></tr>
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>
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:1399"></a><a class="pred" href="chario.html#ttyflush/0">ttyflush/0</a>
312274 (no items used) </td></tr>
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.
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.
319281 <var>N</var> is a decimal number with at least one digit. The item must
320282 be an atom, integer, float or string. </td></tr>
321283 </table>
322284 </dd>
323 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="swritef/3"><strong>swritef</strong>(<var>-String,
285 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="swritef/3"><strong>swritef</strong>(<var>-String,
324286 +Format, +Arguments</var>)</a></dt>
325287 <dd class="defbody">
326 Equivalent to <a id="idx:writef2:1398"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
288 Equivalent to <a name="idx:writef2:1400"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
327289 but ``writes'' the result on <var>String</var> instead of the current
328290 output stream. Example:
329291
334296 </pre>
335297
336298 </dd>
337 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="swritef/2"><strong>swritef</strong>(<var>-String,
299 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="swritef/2"><strong>swritef</strong>(<var>-String,
338300 +Format</var>)</a></dt>
339301 <dd class="defbody">
340302 Equivalent to <code>swritef(String, Format, []).</code>
341303 </dd>
342304 </dl>
343305
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>
347
348 <p>The format family of predicates is the most versatile and portable<sup class="fn">126<span class="fn-text">Unfortunately
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>
309
310 <p>The format family of predicates is the most versatile and portable<sup class="fn">125<span class="fn-text">Unfortunately
349311 not covered by any standard.</span></sup> way to produce textual output.
350312
351313 <dl class="latex">
352 <dt class="pubdef"><a id="format/1"><strong>format</strong>(<var>+Format</var>)</a></dt>
314 <dt class="pubdef"><a name="format/1"><strong>format</strong>(<var>+Format</var>)</a></dt>
353315 <dd class="defbody">
354316 Defined as `<code>format(Format) :- format(Format, []).</code>'. See
355 <a id="idx:format2:1399"></a><a class="pred" href="format.html#format/2">format/2</a>
317 <a name="idx:format2:1401"></a><a class="pred" href="format.html#format/2">format/2</a>
356318 for details.</dd>
357 <dt class="pubdef"><a id="format/2"><strong>format</strong>(<var>+Format,
319 <dt class="pubdef"><a name="format/2"><strong>format</strong>(<var>+Format,
358320 :Arguments</var>)</a></dt>
359321 <dd class="defbody">
360322 <var>Format</var> is an atom, list of character codes, or a Prolog
367329 <p>Special sequences start with the tilde (<code><code>~</code></code>),
368330 followed by an optional numeric argument, optionally followed by a colon
369331 modifier (:),
370 <sup class="fn">127<span class="fn-text">The colon modifiers is a
332 <sup class="fn">126<span class="fn-text">The colon modifiers is a
371333 SWI-Prolog extension, proposed by Richard O'Keefe.</span></sup> followed
372334 by a character describing the action to be undertaken. A numeric
373335 argument is either a sequence of digits, representing a positive decimal
387349 <p>Numeric conversion (<code>d</code>, <code>D</code>, <code>e</code>, <code>E</code>, <code>f</code>, <code>g</code>
388350 and <code>G</code>) accept an arithmetic expression as argument. This is
389351 introduced to handle rational numbers transparently (see
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'.
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'.
394356
395357 <pre class="code">
396358 ?- format('~50f', [10 rdiv 3]).
415377 the actually emitted bytes are defined by the character encoding of the
416378 output stream and an exception may be raised if the output stream is not
417379 capable of representing the requested Unicode character. See
418 <a class="sec" href="widechars.html#sec:2.19.1">section 2.19.1</a> for
419 details.
380 <a class="sec" href="widechars.html">section 2.19.1</a> for details.
420381
421382 <p>
422383 <li><code>d</code><br>
426387 integers, such as handling amounts of money).
427388
428389 <p>The colon modifier (e.g., <code>~:d</code>) causes the number to be
429 printed according to the locale of the output stream. See <a class="sec" href="locale.html#sec:4.23">section
390 printed according to the locale of the output stream. See <a class="sec" href="locale.html">section
430391 4.23</a>.
431392
432393 <p>
472433 <li><code>I</code><br>
473434 Emit a decimal number using Prolog digit grouping (the underscore,
474435 <code>_</code>). The argument describes the size of each digit group.
475 The default is 3. See also <a class="sec" href="syntax.html#sec:2.16.1.5">section
436 The default is 3. See also <a class="sec" href="syntax.html">section
476437 2.16.1.5</a>. For example:
477438
478439 <pre class="code">
482443
483444 <p>
484445 <li><code>k</code><br>
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>.
446 Give the next argument to <a name="idx:writecanonical1:1402"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>.
486447 <li><code>n</code><br>
487448 Output a newline character.
488449 <li><code>N</code><br>
489450 Only output a newline if the last character output on this stream was
490451 not a newline. Not properly implemented yet.
491452 <li><code>p</code><br>
492 Give the next argument to <a id="idx:print1:1401"></a><a class="pred" href="termrw.html#print/1">print/1</a>.
453 Give the next argument to <a name="idx:print1:1403"></a><a class="pred" href="termrw.html#print/1">print/1</a>.
493454 <li><code>q</code><br>
494 Give the next argument to <a id="idx:writeq1:1402"></a><a class="pred" href="termrw.html#writeq/1">writeq/1</a>.
455 Give the next argument to <a name="idx:writeq1:1404"></a><a class="pred" href="termrw.html#writeq/1">writeq/1</a>.
495456
496457 <p>
497458 <li><code>r</code><br>
505466 <li><code>R</code><br>
506467 Same as <b>r</b>, but uses uppercase letters for digits above 9.
507468 <li><code>s</code><br>
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>
469 Output text from a list of character codes or a string (see <a name="idx:string1:1405"></a><a class="pred" href="typetest.html#string/1">string/1</a>
509470 and
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>
471 <a class="sec" href="strings.html">section 5.2</a>) from the next
472 argument.<sup class="fn">127<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>
514475 <li><code>@</code><br>
515476 Interpret the next argument as a goal and execute it. Output written to
516477 the <code>current_output</code> stream is inserted at this place. Goal
517 is called in the module calling <a id="idx:format3:1404"></a><a class="pred" href="format.html#format/3">format/3</a>.
478 is called in the module calling <a name="idx:format3:1406"></a><a class="pred" href="format.html#format/3">format/3</a>.
518479 This option is not present in the original definition by Quintus, but
519480 supported by some other Prolog systems.
520481 <li><code>t</code><br>
547508
548509 <p>
549510 <li><code>w</code><br>
550 Give the next argument to <a id="idx:write1:1405"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
511 Give the next argument to <a name="idx:write1:1407"></a><a class="pred" href="termrw.html#write/1">write/1</a>.
551512 <li><code>W</code><br>
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>.
513 Give the next two arguments to <a name="idx:writeterm2:1408"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
553514 For example,
554515 <code>format('~W', [Term, [numbervars(true)]])</code>. This option is
555516 SWI-Prolog specific.
575536 </pre>
576537
577538 </dd>
578 <dt class="pubdef"><a id="format/3"><strong>format</strong>(<var>+Output,
539 <dt class="pubdef"><a name="format/3"><strong>format</strong>(<var>+Output,
579540 +Format, :Arguments</var>)</a></dt>
580541 <dd class="defbody">
581 As <a id="idx:format2:1407"></a><a class="pred" href="format.html#format/2">format/2</a>,
542 As <a name="idx:format2:1409"></a><a class="pred" href="format.html#format/2">format/2</a>,
582543 but write the output on the given <var>Output</var>. The de-facto
583544 standard only allows <var>Output</var> to be a stream. The SWI-Prolog
584545 implementation allows all valid arguments for
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
546 <a name="idx:withoutputto2:1410"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>.<sup class="fn">128<span class="fn-text">Earlier
586547 versions defined sformat/3 . These predicates have been moved to the
587548 library <code>library(backcomp)</code>.</span></sup> For example:
588549
594555 <p></dd>
595556 </dl>
596557
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
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
598559 Format</span></a></h3>
599560
600 <a id="sec:format-hook"></a>
561 <a name="sec:format-hook"></a>
601562
602563 <dl class="latex">
603 <dt class="pubdef"><a id="format_predicate/2"><strong>format_predicate</strong>(<var>+Char,
564 <dt class="pubdef"><a name="format_predicate/2"><strong>format_predicate</strong>(<var>+Char,
604565 +Head</var>)</a></dt>
605566 <dd class="defbody">
606567 If a sequence <code>~c</code> (tilde, followed by some character) is
607 found, the <a id="idx:format3:1409"></a><a class="pred" href="format.html#format/3">format/3</a>
568 found, the <a name="idx:format3:1411"></a><a class="pred" href="format.html#format/3">format/3</a>
608569 and friends first check whether the user has defined a predicate to
609570 handle the format. If not, the built-in formatting rules described above
610571 are used. <var>Char</var> is either a character code or a one-character
615576 if no argument is specified. The remaining arguments are filled from the
616577 argument list. The example below defines <code>~T</code> to print a
617578 timestamp in ISO8601 format (see
618 <a id="idx:formattime3:1410"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>).
579 <a name="idx:formattime3:1412"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>).
619580 The subsequent block illustrates a possible call.
620581
621582 <pre class="code">
634595 </pre>
635596
636597 </dd>
637 <dt class="pubdef"><a id="current_format_predicate/2"><strong>current_format_predicate</strong>(<var>?Code,
598 <dt class="pubdef"><a name="current_format_predicate/2"><strong>current_format_predicate</strong>(<var>?Code,
638599 ?:Head</var>)</a></dt>
639600 <dd class="defbody">
640601 True when <code><code>~</code></code><var>Code</var> is handled by the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="library.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="opsummary.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:funcsummary"><a id="sec:F.3"><span class="sec-nr">F.3</span> <span class="sec-title">Arithmetic
194 <h2 id="sec:funcsummary"><a name="sec:F.3"><span class="sec-nr">F.3</span> <span class="sec-title">Arithmetic
236195 Functions</span></a></h2>
237196
238 <a id="sec:funcsummary"></a>
197 <a name="sec:funcsummary"></a>
239198 <table>
240199 <tr><td><a class="function" href="arith.html#f-*/2">*/2</a></td><td>Multiplication</td></tr>
241200 <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.7.4 Reference Manual: Section 2.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="packs.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="syntax.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:gc"><a id="sec:2.15"><span class="sec-nr">2.15</span> <span class="sec-title">Garbage
194 <h2 id="sec:gc"><a name="sec:2.15"><span class="sec-nr">2.15</span> <span class="sec-title">Garbage
236195 Collection</span></a></h2>
237196
238 <a id="sec:gc"></a>
197 <a name="sec:gc"></a>
239198
240199 <p>SWI-Prolog provides garbage collection, last-call optimization and
241200 atom garbage collection. These features are controlled using Prolog
242 flags (see <a id="idx:currentprologflag2:211"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
201 flags (see <a name="idx:currentprologflag2:213"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>).
243202
244203 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="cmdline.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="help.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:gemacs"><a id="sec:2.5"><span class="sec-nr">2.5</span> <span class="sec-title">GNU
194 <h2 id="sec:gemacs"><a name="sec:2.5"><span class="sec-nr">2.5</span> <span class="sec-title">GNU
236195 Emacs Interface</span></a></h2>
237196
238 <a id="sec:gemacs"></a>
239
240 <p><a id="idx:GNUEmacs:46"></a><a id="idx:Emacs:47"></a>Unfortunately
197 <a name="sec:gemacs"></a>
198
199 <p><a name="idx:GNUEmacs:47"></a><a name="idx:Emacs:48"></a>Unfortunately
241200 the default Prolog mode of GNU&nbsp;Emacs is not very good. There are
242201 several alternatives though:
243202
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.13</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="error.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="iostream.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:gensym"><a id="sec:A.13"><span class="sec-nr">A.13</span> <span class="sec-title">library(gensym):
194 <h2 id="sec:gensym"><a name="sec:A.13"><span class="sec-nr">A.13</span> <span class="sec-title">library(gensym):
236195 Generate unique identifiers</span></a></h2>
237196
238 <a id="sec:gensym"></a>
197 <a name="sec:gensym"></a>
239198
240199 <p>Gensym (<b>Gen</b>erate <b>Sym</b>bols) is an old library for
241200 generating unique symbols (atoms). Such symbols are generated from a
248207 over all threads.
249208
250209 <dl class="latex">
251 <dt class="pubdef"><a id="gensym/2"><strong>gensym</strong>(<var>+Base,
210 <dt class="pubdef"><a name="gensym/2"><strong>gensym</strong>(<var>+Base,
252211 -Unique</var>)</a></dt>
253212 <dd class="defbody">
254213 Generate a unique atom from base <var>Base</var> and unify it with <var>Unique</var>.
255214 <var>Base</var> should be an atom. The first call will return &lt;<var>base</var>&gt;1
256215 , the next &lt;<var>base</var>&gt;2 , etc. Note that this is no
257216 guarantee that the atom is unique in the system.</dd>
258 <dt class="pubdef"><a id="reset_gensym/1"><strong>reset_gensym</strong>(<var>+Base</var>)</a></dt>
217 <dt class="pubdef"><a name="reset_gensym/1"><strong>reset_gensym</strong>(<var>+Base</var>)</a></dt>
259218 <dd class="defbody">
260219 Restart generation of identifiers from <var>Base</var> at &lt;<var>Base</var>&gt;1.
261220 Used to make sure a program produces the same results on subsequent
262221 runs. Use with care.</dd>
263 <dt class="pubdef"><a id="reset_gensym/0"><strong>reset_gensym</strong></a></dt>
222 <dt class="pubdef"><a name="reset_gensym/0"><strong>reset_gensym</strong></a></dt>
264223 <dd class="defbody">
265224 Reset gensym for all registered keys. This predicate is available for
266225 compatibility only. New code is strongly advised to avoid the use of
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="portabilitystrategies.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="license.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:glossary"><a id="sec:D"><span class="sec-nr">D</span> <span class="sec-title">Glossary
194 <h1 id="sec:glossary"><a name="sec:D"><span class="sec-nr">D</span> <span class="sec-title">Glossary
236195 of Terms</span></a></h1>
237196
238 <a id="sec:glossary"></a>
197 <a name="sec:glossary"></a>
239198
240199 <dl class="latex">
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
200 <dt><a name="gloss:anonymou"><strong>anonymous [variable]</strong></a></dt>
201 <dd class="defbody">
202 <a name="idx:anonymousvariable:2269"></a><a name="idx:variableanonymous:2270"></a>The
244203 variable <code>_</code> is called the <a class="gloss" href="glossary.html#gloss:anonymou">anonymous</a>
245204 variable. Multiple occurrences of <code>_</code> in a single <a class="gloss" href="glossary.html#gloss:term">term</a>
246205 are not <a class="gloss" href="glossary.html#gloss:shared">shared</a>.</dd>
247 <dt><a id="gloss:argument"><strong>arguments</strong></a></dt>
206 <dt><a name="gloss:argument"><strong>arguments</strong></a></dt>
248207 <dd class="defbody">
249208 Arguments are <a class="gloss" href="glossary.html#gloss:term">terms</a>
250209 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>
251210 and <var>a2</var> are the first and second argument of the term
252211 <code>myterm(A1, a2)</code>.</dd>
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>
212 <dt><a name="gloss:arity"><strong>arity</strong></a></dt>
213 <dd class="defbody">
214 <a name="idx:arity:2271"></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:2272"></a>Add a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
259218 to a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>.
260219 Clauses can be added at either end of the clause-list of a <a class="gloss" href="glossary.html#gloss:predicate">predicate</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>
220 See <a name="idx:asserta1:2273"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
221 and <a name="idx:assertz1:2274"></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:2275"></a>Textual constant. Used as name for <a class="gloss" href="glossary.html#gloss:compound">compound</a>
266225 terms, to represent constants or text.</dd>
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
226 <dt><a name="gloss:backtracking"><strong>backtracking</strong></a></dt>
227 <dd class="defbody">
228 <a name="idx:backtracking:2276"></a>Search process used by Prolog. If a
270229 predicate offers multiple
271230 <a class="gloss" href="glossary.html#gloss:clause">clauses</a> to solve
272231 a <a class="gloss" href="glossary.html#gloss:goal">goal</a>, they are
277236 the <a class="gloss" href="glossary.html#gloss:variable">variables</a>),
278237 causing Prolog to reject the previously chosen <a class="gloss" href="glossary.html#gloss:clause">clause</a>
279238 and try the next one.</dd>
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>.
239 <dt><a name="gloss:binding"><strong>binding [of a variable]</strong></a></dt>
240 <dd class="defbody">
241 <a name="idx:binding:2277"></a>Current value of the <a class="gloss" href="glossary.html#gloss:variable">variable</a>.
283242 See also <a class="gloss" href="glossary.html#gloss:backtracking">backtracking</a>
284243 and
285244 <a class="gloss" href="glossary.html#gloss:query">query</a>.</dd>
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
245 <dt><a name="gloss:built-in"><strong>built-in [predicate]</strong></a></dt>
246 <dd class="defbody">
247 <a name="idx:builtinpredicate:2278"></a>Predicate that is part of the
289248 Prolog system. Built-in predicates cannot be redefined by the user,
290249 unless this is overruled using
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>
250 <a name="idx:redefinesystempredicate1:2279"></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:2280"></a>Part of a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
295254 behind the <a class="gloss" href="glossary.html#gloss:neck">neck</a>
296255 operator (<code><code>:-</code></code>).</dd>
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>
256 <dt><a name="gloss:choice-point"><strong>choice point</strong></a></dt>
257 <dd class="defbody">
258 <a name="idx:choicepoint:2281"></a>A <a class="gloss" href="glossary.html#gloss:choice-point">choice point</a>
300259 represents a choice in the search for a <a class="gloss" href="glossary.html#gloss:solution">solution</a>.
301260 Choice points are created if multiple clauses match a <a class="gloss" href="glossary.html#gloss:query">query</a>
302261 or using disjunction (<a class="pred" href="control.html#;/2">;/2</a>).
305264 is restored and search continues with the next alternative (i.e., next
306265 clause or second branch of
307266 <a class="pred" href="control.html#;/2">;/2</a>).</dd>
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>
267 <dt><a name="gloss:clause"><strong>clause</strong></a></dt>
268 <dd class="defbody">
269 <a name="idx:clause:2282"></a>`Sentence' of a Prolog program. A <a class="gloss" href="glossary.html#gloss:clause">clause</a>
311270 consists of a <a class="gloss" href="glossary.html#gloss:head">head</a>
312271 and
313272 <a class="gloss" href="glossary.html#gloss:body">body</a> separated by
322281
323282 <p>Expressed as ``X is a parent if X is a father of someone''. See also
324283 <a class="gloss" href="glossary.html#gloss:variable">variable</a> and <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>.</dd>
325 <dt><a id="gloss:compile"><strong>compile</strong></a></dt>
284 <dt><a name="gloss:compile"><strong>compile</strong></a></dt>
326285 <dd class="defbody">
327286 Process where a Prolog <a class="gloss" href="glossary.html#gloss:program">program</a>
328287 is translated to a sequence of instructions. See also <a class="gloss" href="glossary.html#gloss:interpreted">interpreted</a>.
329288 SWI-Prolog always compiles your program before executing it.</dd>
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>.
289 <dt><a name="gloss:compound"><strong>compound [term]</strong></a></dt>
290 <dd class="defbody">
291 <a name="idx:compound:2283"></a>Also called <a class="gloss" href="glossary.html#gloss:structure">structure</a>.
333292 It consists of a name followed by <var>N</var>
334293 <a class="gloss" href="glossary.html#gloss:argument">arguments</a>, each
335294 of which are <a class="gloss" href="glossary.html#gloss:term">terms</a>. <var>N</var>
336295 is called the
337296 <a class="gloss" href="glossary.html#gloss:arity">arity</a> of the term.</dd>
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
297 <dt><a name="gloss:context-module"><strong>context module</strong></a></dt>
298 <dd class="defbody">
299 <a name="idx:contextmodule:2284"></a><a name="idx:modulecontex:2285"></a>If
341300 a <a class="gloss" href="glossary.html#gloss:term">term</a> is referring
342301 to a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
343302 in a <a class="gloss" href="glossary.html#gloss:module">module</a>, the
348307 is <a class="gloss" href="glossary.html#gloss:module-transparent">module transparent</a>,
349308 in which case the <a class="gloss" href="glossary.html#gloss:context-module">context module</a>
350309 is inherited from the parent
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>
310 <a class="gloss" href="glossary.html#gloss:goal">goal</a>. See also <a name="idx:moduletransparent1:2286"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
352311 and <a class="gloss" href="glossary.html#gloss:meta-predicate">meta-predicate</a>.</dd>
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>
312 <dt><a name="gloss:dcg"><strong>dcg</strong></a></dt>
313 <dd class="defbody">
314 <a name="idx:dcg:2287"></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:2288"></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:2289"></a>How many solutions a <a class="gloss" href="glossary.html#gloss:goal">goal</a>
362321 can provide. Values are `nondet' (zero to infinite), `multi' (one to
363322 infinite), `det' (exactly one) and `semidet' (zero or one).</dd>
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>
323 <dt><a name="gloss:deterministic"><strong>deterministic</strong></a></dt>
324 <dd class="defbody">
325 <a name="idx:deterministic:2290"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
367326 is <a class="gloss" href="glossary.html#gloss:deterministic">deterministic</a>
368327 if it succeeds exactly one time without leaving a <a class="gloss" href="glossary.html#gloss:choice-point">choice point</a>.</dd>
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>
328 <dt><a name="gloss:dynamic"><strong>dynamic [predicate]</strong></a></dt>
329 <dd class="defbody">
330 <a name="idx:dynamicpredicate:2291"></a><a name="idx:predicatedynamic:2292"></a>A <a class="gloss" href="glossary.html#gloss:dynamic">dynamic</a>
372331 predicate is a predicate to which <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
373332 may be
374333 <a class="gloss" href="glossary.html#gloss:assert">assert</a>ed and from
375334 which <a class="gloss" href="glossary.html#gloss:clause">clauses</a> may
376335 be <a class="gloss" href="glossary.html#gloss:retract">retract</a>ed
377336 while the program is running. See also <a class="gloss" href="glossary.html#gloss:update-view">update view</a>.</dd>
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>
337 <dt><a name="gloss:exported"><strong>exported [predicate]</strong></a></dt>
338 <dd class="defbody">
339 <a name="idx:exportedpredicate:2293"></a><a name="idx:predicateexported:2294"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
381340 is said to be <a class="gloss" href="glossary.html#gloss:exported">exported</a>
382341 from a <a class="gloss" href="glossary.html#gloss:module">module</a> if
383342 it appears in the <a class="gloss" href="glossary.html#gloss:public-list">public list</a>.
384343 This implies that the predicate can be <a class="gloss" href="glossary.html#gloss:imported">imported</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>
344 into another module to make it visible there. See also <a name="idx:usemodule12:2295"></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:2296"></a><a class="gloss" href="glossary.html#gloss:clause">Clause</a>
389348 without a <a class="gloss" href="glossary.html#gloss:body">body</a>.
390349 This is called a fact because, interpreted as logic, there is no
391350 condition to be satisfied. The example below states <code>john</code> is
396355 </pre>
397356
398357 </dd>
399 <dt><a id="gloss:fail"><strong>fail</strong></a></dt>
358 <dt><a name="gloss:fail"><strong>fail</strong></a></dt>
400359 <dd class="defbody">
401360 A <a class="gloss" href="glossary.html#gloss:goal">goal</a> is said to
402361 haved failed if it could not be <a class="gloss" href="glossary.html#gloss:prove">proven</a>.</dd>
403 <dt><a id="gloss:float"><strong>float</strong></a></dt>
362 <dt><a name="gloss:float"><strong>float</strong></a></dt>
404363 <dd class="defbody">
405364 Computer's crippled representation of a real number. Represented as
406365 `IEEE double'.</dd>
407 <dt><a id="gloss:foreign"><strong>foreign</strong></a></dt>
366 <dt><a name="gloss:foreign"><strong>foreign</strong></a></dt>
408367 <dd class="defbody">
409368 Computer code expressed in languages other than Prolog. SWI-Prolog can
410369 only cooperate directly with the C and C++ computer languages.</dd>
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>
370 <dt><a name="gloss:functor"><strong>functor</strong></a></dt>
371 <dd class="defbody">
372 <a name="idx:functor:2297"></a>Combination of name and <a class="gloss" href="glossary.html#gloss:arity">arity</a>
414373 of a <a class="gloss" href="glossary.html#gloss:compound">compound</a>
415374 term. The term
416375 <code>foo(a, b, c)</code> is said to be a term belonging to the functor
417376 foo/3 . foo/0 is used to refer to the <a class="gloss" href="glossary.html#gloss:atom">atom</a>
418377 <code>foo</code>.</dd>
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>
378 <dt><a name="gloss:goal"><strong>goal</strong></a></dt>
379 <dd class="defbody">
380 <a name="idx:goal:2298"></a><a name="idx:query:2299"></a>Question stated
381 to the Prolog engine. A <a class="gloss" href="glossary.html#gloss:goal">goal</a>
423382 is either an <a class="gloss" href="glossary.html#gloss:atom">atom</a>
424383 or a <a class="gloss" href="glossary.html#gloss:compound">compound</a>
425384 term. A <a class="gloss" href="glossary.html#gloss:goal">goal</a> either
429388 terms have a <a class="gloss" href="glossary.html#gloss:binding">binding</a>,
430389 or it <a class="gloss" href="glossary.html#gloss:fail">fails</a> if
431390 Prolog fails to prove it.</dd>
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>
391 <dt><a name="gloss:hashing"><strong>hashing</strong></a></dt>
392 <dd class="defbody">
393 <a name="idx:hashing:2300"></a><a class="gloss" href="glossary.html#gloss:indexing">Indexing</a>
435394 technique used for quick lookup.</dd>
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>
395 <dt><a name="gloss:head"><strong>head</strong></a></dt>
396 <dd class="defbody">
397 <a name="idx:head:2301"></a>Part of a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
439398 before the <a class="gloss" href="glossary.html#gloss:neck">neck</a>
440399 operator (<code><code>:-</code></code>). This is an <a class="gloss" href="glossary.html#gloss:atom">atom</a>
441400 or <a class="gloss" href="glossary.html#gloss:compound">compound</a>
442401 term.</dd>
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>
402 <dt><a name="gloss:imported"><strong>imported [predicate]</strong></a></dt>
403 <dd class="defbody">
404 <a name="idx:importedpredicate:2302"></a><a name="idx:predicateimported:2303"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
446405 is said to be <a class="gloss" href="glossary.html#gloss:imported">imported</a>
447406 into a <a class="gloss" href="glossary.html#gloss:module">module</a> if
448407 it is defined in another <a class="gloss" href="glossary.html#gloss:module">module</a>
449408 and made available in this <a class="gloss" href="glossary.html#gloss:module">module</a>.
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
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:2304"></a>Indexing is a technique used to quickly
454413 select candidate <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
455414 of a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
456415 for a specific <a class="gloss" href="glossary.html#gloss:goal">goal</a>.
463422 is used to quickly select all <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
464423 where the first argument may <a class="gloss" href="glossary.html#gloss:unify">unify</a>
465424 with the first argument of the <a class="gloss" href="glossary.html#gloss:goal">goal</a>.
466 SWI-Prolog supports just-in-time and multi-argument indexing. See <a class="sec" href="jitindex.html#sec:2.18">section
425 SWI-Prolog supports just-in-time and multi-argument indexing. See <a class="sec" href="jitindex.html">section
467426 2.18</a>.</dd>
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
427 <dt><a name="gloss:integer"><strong>integer</strong></a></dt>
428 <dd class="defbody">
429 <a name="idx:integer:2305"></a>Whole number. On all implementations of
471430 SWI-Prolog integers are at least 64-bit signed values. When linked to
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>,
431 the GNU GMP library, integer arithmetic is unbounded. See also <a name="idx:currentprologflag2:2306"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>,
473432 flags <a class="flag" href="flags.html#flag:bounded">bounded</a>, <a class="flag" href="flags.html#flag:max_integer">max_integer</a>
474433 and <a class="flag" href="flags.html#flag:min_integer">min_integer</a>.</dd>
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>,
434 <dt><a name="gloss:interpreted"><strong>interpreted</strong></a></dt>
435 <dd class="defbody">
436 <a name="idx:interpreted:2307"></a>As opposed to <a class="gloss" href="glossary.html#gloss:compile">compiled</a>,
478437 interpreted means the Prolog system attempts to prove a <a class="gloss" href="glossary.html#gloss:goal">goal</a>
479438 by directly reading the <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
480439 rather than executing instructions from an (abstract) instruction set
481440 that is not or only indirectly related to Prolog.</dd>
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
441 <dt><a name="gloss:instantiation"><strong>instantiation [of an argument]</strong></a></dt>
442 <dd class="defbody">
443 <a name="idx:instantiation:2308"></a>To what extend a term is bound to a
485444 value. Typical levels are `unbound' (a <a class="gloss" href="glossary.html#gloss:variable">variable</a>),
486445 `ground' (term without variables) or `partially bound' (term with
487446 embedded variables).</dd>
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>
447 <dt><a name="gloss:meta-predicate"><strong>meta-predicate</strong></a></dt>
448 <dd class="defbody">
449 <a name="idx:metapredicate:2309"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
491450 that reasons about other <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>,
492451 either by calling them, (re)defining them or querying <a class="gloss" href="glossary.html#gloss:property">properties</a>.</dd>
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>
452 <dt><a name="gloss:mode"><strong>mode [declaration]</strong></a></dt>
453 <dd class="defbody">
454 <a name="idx:mode:2310"></a>Declaration of an argument <a class="gloss" href="glossary.html#gloss:instantiation">instantiation</a>
496455 pattern for a
497456 <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>,
498457 often accompanied with a <a class="gloss" href="glossary.html#gloss:determinism">determinism</a>.</dd>
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
458 <dt><a name="gloss:module"><strong>module</strong></a></dt>
459 <dd class="defbody">
460 <a name="idx:module:2311"></a>Collection of predicates. Each module
502461 defines a name-space for predicates. <a class="gloss" href="glossary.html#gloss:built-in">built-in</a>
503462 predicates are accessible from all modules. Predicates can be published
504463 (<a class="gloss" href="glossary.html#gloss:exported">exported</a>) and <a class="gloss" href="glossary.html#gloss:imported">imported</a>
505464 to make their definition available to other modules.</dd>
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>
465 <dt><a name="gloss:module-transparent"><strong>module transparent [predicate]</strong></a></dt>
466 <dd class="defbody">
467 <a name="idx:moduletransparent:2312"></a><a name="idx:transparent:2313"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
509468 that does not change the <a class="gloss" href="glossary.html#gloss:context-module">context module</a>.
510469 Sometimes also called a <a class="gloss" href="glossary.html#gloss:meta-predicate">meta-predicate</a>.</dd>
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>
470 <dt><a name="gloss:multi"><strong>multi [determinism]</strong></a></dt>
471 <dd class="defbody">
472 <a name="idx:multi:2314"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
514473 is said to have <a class="gloss" href="glossary.html#gloss:determinism">determinism</a>
515474 multi if it generates at
516475 <em>least</em> one answer.</dd>
517 <dt><a id="gloss:multifile"><strong>multifile [predicate]</strong></a></dt>
476 <dt><a name="gloss:multifile"><strong>multifile [predicate]</strong></a></dt>
518477 <dd class="defbody">
519478 Predicate for which the definition is distributed over multiple source
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>)
479 files. See <a name="idx:multifile1:2315"></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:2316"></a>Operator (<code><code>:-</code></code>)
524483 separating <a class="gloss" href="glossary.html#gloss:head">head</a>
525484 from <a class="gloss" href="glossary.html#gloss:body">body</a> in a <a class="gloss" href="glossary.html#gloss:clause">clause</a>.</dd>
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>
485 <dt><a name="gloss:nondet"><strong>nondet</strong></a></dt>
486 <dd class="defbody">
487 <a name="idx:nondet:2317"></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:2318"></a>A <a class="gloss" href="glossary.html#gloss:non-deterministic">non deterministic</a>
532491 predicate is a predicate that mail fail or succeed any number of times.</dd>
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>)
492 <dt><a name="gloss:operator"><strong>operator</strong></a></dt>
493 <dd class="defbody">
494 <a name="idx:operator:2319"></a>Symbol (<a class="gloss" href="glossary.html#gloss:atom">atom</a>)
536495 that may be placed before its <a class="gloss" href="glossary.html#gloss:operand">operand</a>
537496 (prefix), after its <a class="gloss" href="glossary.html#gloss:operand">operand</a>
538497 (postfix) or between its two <a class="gloss" href="glossary.html#gloss:operand">operands</a>
540499
541500 <p>In Prolog, the expression <code>a+b</code> is exactly the same as the
542501 canonical term <code>+(a,b)</code>.</dd>
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>
502 <dt><a name="gloss:operand"><strong>operand</strong></a></dt>
503 <dd class="defbody">
504 <a name="idx:operand:2320"></a><a class="gloss" href="glossary.html#gloss:argument">Argument</a>
546505 of an <a class="gloss" href="glossary.html#gloss:operator">operator</a>.</dd>
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>
506 <dt><a name="gloss:precedence"><strong>precedence</strong></a></dt>
507 <dd class="defbody">
508 <a name="idx:precedence:2321"></a>The <a class="gloss" href="glossary.html#gloss:priority">priority</a>
550509 of an <a class="gloss" href="glossary.html#gloss:operator">operator</a>.
551510 Operator precedence is used to interpret <code>a+b*c</code> as <code>+(a, *(b,c))</code>.</dd>
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>
511 <dt><a name="gloss:predicate"><strong>predicate</strong></a></dt>
512 <dd class="defbody">
513 <a name="idx:predicate:2322"></a>Collection of <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
555514 with the same <a class="gloss" href="glossary.html#gloss:functor">functor</a>
556515 (name/<a class="gloss" href="glossary.html#gloss:arity">arity</a>). If a <a class="gloss" href="glossary.html#gloss:goal">goal</a>
557516 is proved, the system looks for a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
559518 to select candidate <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
560519 and then tries these <a class="gloss" href="glossary.html#gloss:clause">clauses</a>
561520 one-by-one. See also <a class="gloss" href="glossary.html#gloss:backtracking">backtracking</a>.</dd>
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
521 <dt><a name="gloss:predicate-indicator"><strong>predicate indicator</strong></a></dt>
522 <dd class="defbody">
523 <a name="idx:predicateindicator:2323"></a>Term of the form Name/Arity
565524 (traditional) or Name//Arity (ISO DCG proposal), where Name is an atom
566525 and Arity a non-negative integer. It acts as an <em>indicator</em> (or
567526 reference) to a predicate or
568527 <a class="gloss" href="glossary.html#gloss:dcg">DCG</a> rule.</dd>
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>
528 <dt><a name="gloss:priority"><strong>priority</strong></a></dt>
529 <dd class="defbody">
530 <a name="idx:priority:2324"></a>In the context of <a class="gloss" href="glossary.html#gloss:operator">operators</a>
572531 a synonym for <a class="gloss" href="glossary.html#gloss:precedence">precedence</a>.</dd>
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
532 <dt><a name="gloss:program"><strong>program</strong></a></dt>
533 <dd class="defbody">
534 <a name="idx:program:2325"></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:2326"></a>Attribute of an object. SWI-Prolog
538 defines various <em>*_property</em> predicates to query the status of
580539 predicates, clauses. etc.</dd>
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>
540 <dt><a name="gloss:prove"><strong>prove</strong></a></dt>
541 <dd class="defbody">
542 <a name="idx:prove:2327"></a>Process where Prolog attempts to prove a <a class="gloss" href="glossary.html#gloss:query">query</a>
584543 using the available
585544 <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>.</dd>
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>
545 <dt><a name="gloss:public-list"><strong>public list</strong></a></dt>
546 <dd class="defbody">
547 <a name="idx:publiclist:2328"></a>List of <a class="gloss" href="glossary.html#gloss:predicate">predicates</a>
589548 exported from a <a class="gloss" href="glossary.html#gloss:module">module</a>.</dd>
590 <dt><a id="gloss:query"><strong>query</strong></a></dt>
549 <dt><a name="gloss:query"><strong>query</strong></a></dt>
591550 <dd class="defbody">
592551 See <a class="gloss" href="glossary.html#gloss:goal">goal</a>.</dd>
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>
552 <dt><a name="gloss:retract"><strong>retract</strong></a></dt>
553 <dd class="defbody">
554 <a name="idx:retract:2329"></a>Remove a <a class="gloss" href="glossary.html#gloss:clause">clause</a>
596555 from a <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>.
597556 See also <a class="gloss" href="glossary.html#gloss:dynamic">dynamic</a>,
598557 <a class="gloss" href="glossary.html#gloss:update-view">update view</a>
599558 and <a class="gloss" href="glossary.html#gloss:assert">assert</a>.</dd>
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>
559 <dt><a name="gloss:semidet"><strong>semidet</strong></a></dt>
560 <dd class="defbody">
561 <a name="idx:semidet:2330"></a>Shorthand for </dd>
562 <dt><a name="gloss:semi-deterministic"><strong>semi deterministic</strong></a></dt>
604563 <dd class="defbody">
605564 .</dd>
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>
565 <dt><a name="gloss:semi-deterministic"><strong>semi deterministic</strong></a></dt>
566 <dd class="defbody">
567 <a name="idx:semideterministic:2331"></a>A <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
609568 that is <a class="gloss" href="glossary.html#gloss:semi-deterministic">semi deterministic</a>
610569 either fails or succeeds exactly once without a <a class="gloss" href="glossary.html#gloss:choice-point">choice point</a>.
611570 See also
612571 <a class="gloss" href="glossary.html#gloss:deterministic">deterministic</a>.</dd>
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>
572 <dt><a name="gloss:shared"><strong>shared</strong></a></dt>
573 <dd class="defbody">
574 <a name="idx:shared:2332"></a>Two <a class="gloss" href="glossary.html#gloss:variable">variables</a>
616575 are called <a class="gloss" href="glossary.html#gloss:shared">shared</a>
617576 after they are <a class="gloss" href="glossary.html#gloss:unify">unified</a>.
618577 This implies if either of them is <a class="gloss" href="glossary.html#gloss:binding">bound</a>,
624583 </pre>
625584
626585 </dd>
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>
586 <dt><a name="gloss:singleton"><strong>singleton [variable]</strong></a></dt>
587 <dd class="defbody">
588 <a name="idx:singleton:2333"></a><a class="gloss" href="glossary.html#gloss:variable">Variable</a>
630589 appearing only one time in a <a class="gloss" href="glossary.html#gloss:clause">clause</a>.
631590 SWI-Prolog normally warns for this to avoid you making spelling
632591 mistakes. If a variable appears on purpose only once in a clause, write
633592 it as <code>_</code> (see <a class="gloss" href="glossary.html#gloss:anonymou">anonymous</a>).
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
593 Rules for naming a variable and avoiding a warning are given in <a class="sec" href="syntax.html">section
635594 2.16.1.9</a>.</dd>
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>
595 <dt><a name="gloss:solution"><strong>solution</strong></a></dt>
596 <dd class="defbody">
597 <a name="idx:solution:2334"></a><a class="gloss" href="glossary.html#gloss:binding">Bindings</a>
639598 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>
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>
599 <dt><a name="gloss:structure"><strong>structure</strong></a></dt>
600 <dd class="defbody">
601 <a name="idx:structure:2335"></a>Synonym for <a class="gloss" href="glossary.html#gloss:compound">compound</a>
643602 term.</dd>
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
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
647606 5.2</a>, SWI-Prolog specific), a list of character codes or a list of
648607 one-character <a class="gloss" href="glossary.html#gloss:atom">atoms</a>.</dd>
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>
608 <dt><a name="gloss:succeed"><strong>succeed</strong></a></dt>
609 <dd class="defbody">
610 <a name="idx:succeed:2336"></a>A <a class="gloss" href="glossary.html#gloss:goal">goal</a>
652611 is said to have <a class="gloss" href="glossary.html#gloss:succeed">succeeded</a>
653612 if it has been <a class="gloss" href="glossary.html#gloss:prove">proven</a>.</dd>
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>
613 <dt><a name="gloss:term"><strong>term</strong></a></dt>
614 <dd class="defbody">
615 <a name="idx:term:2337"></a>Value in Prolog. A <a class="gloss" href="glossary.html#gloss:term">term</a>
657616 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>,
658617 <a class="gloss" href="glossary.html#gloss:float">float</a> or <a class="gloss" href="glossary.html#gloss:compound">compound</a>
659618 term. In addition, SWI-Prolog also defines the type <a class="gloss" href="glossary.html#gloss:string">string</a>.</dd>
660 <dt><a id="gloss:transparent"><strong>transparent</strong></a></dt>
619 <dt><a name="gloss:transparent"><strong>transparent</strong></a></dt>
661620 <dd class="defbody">
662621 See <a class="gloss" href="glossary.html#gloss:module-transparent">module transparent</a>.</dd>
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
622 <dt><a name="gloss:unify"><strong>unify</strong></a></dt>
623 <dd class="defbody">
624 <a name="idx:unify:2338"></a>Prolog process to make two terms equal by
666625 assigning variables in one term to values at the corresponding location
667626 of the other term. For example:
668627
674633
675634 <p>Unlike assignment (which does not exist in Prolog), unification is
676635 not directed.</dd>
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
636 <dt><a name="gloss:update-view"><strong>update view</strong></a></dt>
637 <dd class="defbody">
638 <a name="idx:updateview:2339"></a><a name="idx:viewupdate:2340"></a>How
680639 Prolog behaves when a <a class="gloss" href="glossary.html#gloss:dynamic">dynamic</a> <a class="gloss" href="glossary.html#gloss:predicate">predicate</a>
681640 is changed while it is running. There are two models. In most older
682641 Prolog systems the change becomes immediately visible to the <a class="gloss" href="glossary.html#gloss:goal">goal</a>,
683642 in modern systems including SWI-Prolog, the running <a class="gloss" href="glossary.html#gloss:goal">goal</a>
684643 is not affected. Only new <a class="gloss" href="glossary.html#gloss:goal">goals</a>
685644 `see' the new definition.</dd>
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>
645 <dt><a name="gloss:variable"><strong>variable</strong></a></dt>
646 <dd class="defbody">
647 <a name="idx:variable:2341"></a>A Prolog variable is a value that `is
648 not yet bound'. After <a class="gloss" href="glossary.html#gloss:binding">binding</a>
690649 a variable, it cannot be modified. <a class="gloss" href="glossary.html#gloss:backtracking">Backtracking</a>
691650 to a point in the execution before the variable was bound will turn it
692651 back into a variable:
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="sicstus-chr.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="errors.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:guidelines"><a id="sec:8.7"><span class="sec-nr">8.7</span> <span class="sec-title">Programming
194 <h2 id="sec:guidelines"><a name="sec:8.7"><span class="sec-nr">8.7</span> <span class="sec-title">Programming
236195 Tips and Tricks</span></a></h2>
237196
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.
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.
241200
242201 <p>
243202 <ul class="latex">
272231 into Prolog code. When you disable optimizations the CHR compiler will
273232 be a lot quicker, but you may lose performance. Alternatively, you can
274233 just use SWI-Prolog's
275 <a id="idx:qcompile1:1830"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
234 <a name="idx:qcompile1:1829"></a><a class="pred" href="consulting.html#qcompile/1">qcompile/1</a>
276235 to generate a <code>.qlf</code> file once from your
277236 <code>.pl</code> file. This <code>.qlf</code> contains the generated
278237 code of the CHR compiler (be it in a binary format). When you consult
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="pceemacs.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="navigator.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:guitracer"><a id="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">The
194 <h2 id="sec:guitracer"><a name="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">The
236195 Graphical Debugger</span></a></h2>
237196
238 <a id="sec:guitracer"></a>
197 <a name="sec:guitracer"></a>
239198
240199 <p>SWI-Prolog offers two debuggers. One is the traditional text
241200 console-based 4-port Prolog tracer and the other is a window-based
242201 source level debugger. The window-based debugger requires XPCE
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
202 installed. It operates based on the <a name="idx:prologtraceinterception4:316"></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
245204 B</a>.
246205
247206 <p>Window-based tracing provides a much better overview due to the
252211 the graphical debugger just presents a (much better) overview of the
253212 current state.
254213
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
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
256215 the window-based debugger</span></a></h3>
257216
258 <a id="sec:start-guitracer"></a>
217 <a name="sec:start-guitracer"></a>
259218
260219 <p>Whether the text-based or window-based debugger is used is controlled
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>
220 using the predicates <a name="idx:guitracer0:317"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>
221 and <a name="idx:noguitracer0:318"></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:319"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
264223 and
265 <a id="idx:spy1:318"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>.
224 <a name="idx:spy1:320"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>.
266225 In addition, PceEmacs prolog mode provides the command
267226 <strong>Prolog/Break at</strong> (<code>Control-c b</code>) to insert a
268227 break-point at a specific location in the source code.
272231 used from a background thread.
273232
274233 <dl class="latex">
275 <dt class="pubdef"><a id="guitracer/0"><strong>guitracer</strong></a></dt>
234 <dt class="pubdef"><a name="guitracer/0"><strong>guitracer</strong></a></dt>
276235 <dd class="defbody">
277236 This predicate installs the above-mentioned hooks that redirect tracing
278237 to the window-based environment. No window appears. The debugger window
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>
238 appears as actual tracing is started through <a name="idx:trace0:321"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>,
239 by hitting a spy point defined by <a name="idx:spy1:322"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
281240 or a break point defined using the PceEmacs command <strong>Prolog/Break
282241 at</strong> (<code>Control-c b</code>).</dd>
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>,
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:323"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>,
286245 reverting to normal text console-based tracing.</dd>
287 <dt class="pubdef"><a id="gtrace/0"><strong>gtrace</strong></a></dt>
246 <dt class="pubdef"><a name="gtrace/0"><strong>gtrace</strong></a></dt>
288247 <dd class="defbody">
289248 Utility defined as <code>guitracer,trace</code>.</dd>
290 <dt class="pubdef"><a id="gdebug/0"><strong>gdebug</strong></a></dt>
249 <dt class="pubdef"><a name="gdebug/0"><strong>gdebug</strong></a></dt>
291250 <dd class="defbody">
292251 Utility defined as <code>guitracer,debug</code>.</dd>
293 <dt class="pubdef"><a id="gspy/1"><strong>gspy</strong>(<var>+Predicate</var>)</a></dt>
252 <dt class="pubdef"><a name="gspy/1"><strong>gspy</strong>(<var>+Predicate</var>)</a></dt>
294253 <dd class="defbody">
295254 Utility defined as <code>guitracer,spy(Predicate)</code>.
296255 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.33</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="format.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="tty.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:gvar"><a id="sec:4.33"><span class="sec-nr">4.33</span> <span class="sec-title">Global
194 <h2 id="sec:gvar"><a name="sec:4.33"><span class="sec-nr">4.33</span> <span class="sec-title">Global
236195 variables</span></a></h2>
237196
238 <a id="sec:gvar"></a>
197 <a name="sec:gvar"></a>
239198
240199 <p>Global variables are associations between names (atoms) and terms.
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>.
200 They differ in various ways from storing information using <a name="idx:assert1:1413"></a><a class="pred" href="db.html#assert/1">assert/1</a>
201 or <a name="idx:recorda3:1414"></a><a class="pred" href="db.html#recorda/3">recorda/3</a>.
243202
244203 <p>
245204 <ul class="latex">
249208 the CHR global constraint store.
250209
251210 <p>
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>.
211 <li>They support both global assignment using <a name="idx:nbsetval2:1415"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
212 and backtrackable assignment using <a name="idx:bsetval2:1416"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>.
254213
255214 <p>
256215 <li>Only one value (which can be an arbitrary complex Prolog term) can
265224 module scoping in future versions.
266225 </ul>
267226
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>
227 <p>Both <a name="idx:bsetval2:1417"></a><a class="pred" href="gvar.html#b_setval/2">b_setval/2</a>
228 and <a name="idx:nbsetval2:1418"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
270229 implicitly create a variable if the referenced name does not already
271230 refer to a variable.
272231
273232 <p>Global variables may be initialised from directives to make them
274233 available during the program lifetime, but some considerations are
275234 necessary for saved states and threads. Saved states do not store global
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>
235 variables, which implies they have to be declared with <a name="idx:initialization1:1419"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
277236 to recreate them after loading the saved state. Each thread has its own
278237 set of global variables, starting with an empty set. Using
279 <a id="idx:threadinitialization1:1418"></a><a class="pred" href="threadcreate.html#thread_initialization/1">thread_initialization/1</a>
238 <a name="idx:threadinitialization1:1420"></a><a class="pred" href="threadcreate.html#thread_initialization/1">thread_initialization/1</a>
280239 to define a global variable it will be defined, restored after reloading
281240 a saved state and created in all threads that are created <em>after</em>
282241 the registration. Finally, global variables can be initialised using the
283242 exception hook
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
243 <a name="idx:exception3:1421"></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
286245 8</a>).
287246
288247 <dl class="latex">
289 <dt class="pubdef"><a id="b_setval/2"><strong>b_setval</strong>(<var>+Name,
248 <dt class="pubdef"><a name="b_setval/2"><strong>b_setval</strong>(<var>+Name,
290249 +Value</var>)</a></dt>
291250 <dd class="defbody">
292251 Associate the term <var>Value</var> with the atom <var>Name</var> or
295254 value
296255 <code>[]</code> is created (the empty list). On backtracking the
297256 assignment is reversed.</dd>
298 <dt class="pubdef"><a id="b_getval/2"><strong>b_getval</strong>(<var>+Name,
257 <dt class="pubdef"><a name="b_getval/2"><strong>b_getval</strong>(<var>+Name,
299258 -Value</var>)</a></dt>
300259 <dd class="defbody">
301260 Get the value associated with the global variable <var>Name</var> and
302261 unify it with <var>Value</var>. Note that this unification may further
303262 instantiate the value of the global variable. If this is undesirable the
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>)
263 normal precautions (double negation or <a name="idx:copyterm2:1422"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>)
305264 must be taken. The
306 <a id="idx:bgetval2:1421"></a><a class="pred" href="gvar.html#b_getval/2">b_getval/2</a>
265 <a name="idx:bgetval2:1423"></a><a class="pred" href="gvar.html#b_getval/2">b_getval/2</a>
307266 predicate generates errors if <var>Name</var> is not an atom or the
308267 requested variable does not exist.
309268 </dd>
310269 </dl>
311270
312271 <dl class="latex">
313 <dt class="pubdef"><a id="nb_setval/2"><strong>nb_setval</strong>(<var>+Name,
272 <dt class="pubdef"><a name="nb_setval/2"><strong>nb_setval</strong>(<var>+Name,
314273 +Value</var>)</a></dt>
315274 <dd class="defbody">
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>
275 Associates a copy of <var>Value</var> created with <a name="idx:duplicateterm2:1424"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>
317276 with the atom <var>Name</var>. Note that this can be used to set an
318277 initial value other than <code>[]</code> prior to backtrackable
319278 assignment.</dd>
320 <dt class="pubdef"><a id="nb_getval/2"><strong>nb_getval</strong>(<var>+Name,
279 <dt class="pubdef"><a name="nb_getval/2"><strong>nb_getval</strong>(<var>+Name,
321280 -Value</var>)</a></dt>
322281 <dd class="defbody">
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>,
282 The <a name="idx:nbgetval2:1425"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
283 predicate is a synonym for <a name="idx:bgetval2:1426"></a><a class="pred" href="gvar.html#b_getval/2">b_getval/2</a>,
325284 introduced for compatibility and symmetry. As most scenarios will use a
326285 particular global variable using either non-backtrackable or
327 backtrackable assignment, using <a id="idx:nbgetval2:1425"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
286 backtrackable assignment, using <a name="idx:nbgetval2:1427"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
328287 can be used to document that the variable is non-backtrackable. Raises <code>existence_error(variable,
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>
288 Name)</code> if the variable does not exist. Alternatively, <a name="idx:nbcurrent2:1428"></a><a class="pred" href="gvar.html#nb_current/2">nb_current/2</a>
330289 can used to query a global variable. This version <em>fails</em> if the
331290 variable does not exist rather than raising an exception.</dd>
332 <dt class="pubdef"><a id="nb_linkval/2"><strong>nb_linkval</strong>(<var>+Name,
291 <dt class="pubdef"><a name="nb_linkval/2"><strong>nb_linkval</strong>(<var>+Name,
333292 +Value</var>)</a></dt>
334293 <dd class="defbody">
335294 Associates the term <var>Value</var> with the atom <var>Name</var>
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>
295 without copying it. This is a fast special-purpose variation of <a name="idx:nbsetval2:1429"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
337296 intended for expert users only because the semantics on backtracking to
338297 a point before creating the link are poorly defined for compound terms.
339298 The principal term is always left untouched, but backtracking behaviour
354313 </pre>
355314
356315 </dd>
357 <dt class="pubdef"><a id="nb_current/2"><strong>nb_current</strong>(<var>?Name,
316 <dt class="pubdef"><a name="nb_current/2"><strong>nb_current</strong>(<var>?Name,
358317 ?Value</var>)</a></dt>
359318 <dd class="defbody">
360319 Enumerate all defined variables with their value. The order of
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>
320 enumeration is undefined. Note that <a name="idx:nbcurrent2:1430"></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:1431"></a><a class="pred" href="gvar.html#nb_getval/2">nb_getval/2</a>
363322 to request the value of a variable and fail silently if the variable
364323 does not exists.</dd>
365 <dt class="pubdef"><a id="nb_delete/1"><strong>nb_delete</strong>(<var>+Name</var>)</a></dt>
324 <dt class="pubdef"><a name="nb_delete/1"><strong>nb_delete</strong>(<var>+Name</var>)</a></dt>
366325 <dd class="defbody">
367326 Delete the named global variable. Succeeds also if the named variable
368327 does not exist.
369328 </dd>
370329 </dl>
371330
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
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
373332 of SWI-Prolog Global Variables</span></a></h3>
374333
375 <a id="sec:gvars-compat"></a>
334 <a name="sec:gvars-compat"></a>
376335
377336 <p>Global variables have been introduced by various Prolog
378337 implementations recently. The implementation of them in SWI-Prolog is
379338 based on hProlog by Bart Demoen. In discussion with Bart it was decided
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>,
339 that the semantics of hProlog <a name="idx:nbsetval2:1432"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>,
340 which is equivalent to <a name="idx:nblinkval2:1433"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>,
382341 is not acceptable for normal Prolog users as the behaviour is influenced
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>,
342 by how built-in predicates that construct terms (<a name="idx:read1:1434"></a><a class="pred" href="termrw.html#read/1">read/1</a>,
384343 =../2, etc.) are implemented.
385344
386345 <p>GNU-Prolog provides a rich set of global variables, including arrays.
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>
346 Arrays can be implemented easily in SWI-Prolog using <a name="idx:functor3:1435"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
388347 and
389 <a id="idx:setarg3:1434"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
348 <a name="idx:setarg3:1436"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
390349 due to the unrestricted arity of compound terms.
391350
392351 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="yall.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="manipstack.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:hack"><a id="sec:B"><span class="sec-nr">B</span> <span class="sec-title">Hackers
194 <h1 id="sec:hack"><a name="sec:B"><span class="sec-nr">B</span> <span class="sec-title">Hackers
236195 corner</span></a></h1>
237196
238 <a id="sec:hack"></a>
197 <a name="sec:hack"></a>
239198
240199 <p>This appendix describes a number of predicates which enable the
241200 Prolog user to inspect the Prolog environment and manipulate (or even
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="gemacs.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="history.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:help"><a id="sec:2.6"><span class="sec-nr">2.6</span> <span class="sec-title">Online
194 <h2 id="sec:help"><a name="sec:2.6"><span class="sec-nr">2.6</span> <span class="sec-title">Online
236195 Help</span></a></h2>
237196
238 <a id="sec:help"></a>
197 <a name="sec:help"></a>
239198
240199 <p>SWI-Prolog provides an online help system that covers this manual. If
241200 the XPCE graphics system is available, online help opens a graphical
249208 and following the instructions in the <code>README</code> file.
250209
251210 <dl class="latex">
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>
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:49"></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>
256215 <dd class="defbody">
257216 Show specified part of the manual. <var>What</var> is one of:
258 <table class="latex frame-void center">
259 <tr><td>&lt;<var>Name</var>&gt;/&lt;<var>Arity</var>&gt; </td><td>Give
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
260219 help on specified predicate </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>
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:50"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>.</td></tr>
266225 </table>
226 </div>
267227
268228 <p>Examples:
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>
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>
276236 </table>
277
278 <p>See also <a id="idx:apropos1:50"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
237 </div>
238
239 <p>See also <a name="idx:apropos1:51"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
279240 and the SWI-Prolog home page at
280241 <a class="url" href="http://www.swi-prolog.org">http://www.swi-prolog.org</a>,
281242 which provides a FAQ, an HTML version of the manual for online browsing,
282243 and HTML and PDF versions for downloading.</dd>
283 <dt class="pubdef"><a id="apropos/1"><strong>apropos</strong>(<var>+Pattern</var>)</a></dt>
244 <dt class="pubdef"><a name="apropos/1"><strong>apropos</strong>(<var>+Pattern</var>)</a></dt>
284245 <dd class="defbody">
285246 Display all predicates, functions and sections that have <em>Pattern</em>
286247 in their name or summary description. Lowercase letters in
287248 <var>Pattern</var> also match a corresponding uppercase letter. Example:
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>
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>
292253 </table>
254 </div>
293255 </dd>
294 <dt class="pubdef"><a id="explain/1"><strong>explain</strong>(<var>+ToExplain</var>)</a></dt>
256 <dt class="pubdef"><a name="explain/1"><strong>explain</strong>(<var>+ToExplain</var>)</a></dt>
295257 <dd class="defbody">
296258 Give an explanation on the given `object'. The argument may be any
297259 Prolog data object. If the argument is an atom, a term of the form
298260 <var>Name/Arity</var> or a term of the form <em>Module:Name/Arity</em>,
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,
261 <a name="idx:explain1:52"></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:53"></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,
302264 -Explanation</var>)</a></dt>
303265 <dd class="defbody">
304266 Unify <var>Explanation</var> with an explanation for <var>ToExplain</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="help.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="topvars.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:history"><a id="sec:2.7"><span class="sec-nr">2.7</span> <span class="sec-title">Command
194 <h2 id="sec:history"><a name="sec:2.7"><span class="sec-nr">2.7</span> <span class="sec-title">Command
236195 line history</span></a></h2>
237196
238 <a id="sec:history"></a>
197 <a name="sec:history"></a>
239198
240199 <p>SWI-Prolog offers a query substitution mechanism similar to what is
241200 seen in Unix shells. The availability of this feature is controlled by
242 <a id="idx:setprologflag2:53"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>,
201 <a name="idx:setprologflag2:54"></a><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a>,
243202 using the <a class="flag" href="flags.html#flag:history">history</a>
244203 Prolog flag. By default, history is available if no interactive command
245204 line editor is available. To enable history, remembering the last 50
246 commands, put the following into your startup file (see <a class="sec" href="initfile.html#sec:2.2">section
205 commands, put the following into your startup file (see <a class="sec" href="initfile.html">section
247206 2.2</a>):
248207
249208 <pre class="code">
256215 1</a>. History expansion is not done if these sequences appear in quoted
257216 atoms or strings.
258217
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>
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>
265225 </table>
266226 <div class="caption"><b>Table 1 : </b>History commands</div>
267 <a id="tab:history"></a>
227 <a name="tab:history"></a>
268228
269229 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="flags.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="autoload.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:hooks"><a id="sec:2.12"><span class="sec-nr">2.12</span> <span class="sec-title">An
194 <h2 id="sec:hooks"><a name="sec:2.12"><span class="sec-nr">2.12</span> <span class="sec-title">An
236195 overview of hook predicates</span></a></h2>
237196
238 <a id="sec:hooks"></a>
239
240 <p><a id="idx:hooks:167"></a>SWI-Prolog provides a large number of
197 <a name="sec:hooks"></a>
198
199 <p><a name="idx:hooks:169"></a>SWI-Prolog provides a large number of
241200 hooks, mainly to control handling messages, debugging, startup,
242201 shut-down, macro-expansion, etc. Below is a summary of all defined hooks
243202 with an indication of their portability.
245204 <p>
246205 <ul class="latex">
247206 <li><i>portray/1</i><br>
248 Hook into <a id="idx:writeterm3:168"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>
207 Hook into <a name="idx:writeterm3:170"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>
249208 to alter the way terms are printed (ISO).
250209 <li><i>message_hook/3</i><br>
251 Hook into <a id="idx:printmessage2:169"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
210 Hook into <a name="idx:printmessage2:171"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
252211 to alter the way system messages are printed (Quintus/SICStus).
253212 <li><i>message_property/2</i><br>
254 Hook into <a id="idx:printmessage2:170"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
213 Hook into <a name="idx:printmessage2:172"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
255214 that defines prefix, output stream, color, etc.
256215 <li><i>library_directory/1</i><br>
257 Hook into <a id="idx:absolutefilename3:171"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
216 Hook into <a name="idx:absolutefilename3:173"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
258217 to define new library directories (most Prolog systems).
259218 <li><i>file_search_path/2</i><br>
260 Hook into <a id="idx:absolutefilename3:172"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
219 Hook into <a name="idx:absolutefilename3:174"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
261220 to define new search paths (Quintus/SICStus).
262221 <li><i>term_expansion/2</i><br>
263 Hook into <a id="idx:loadfiles2:173"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
222 Hook into <a name="idx:loadfiles2:175"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
264223 to modify read terms before they are compiled (macro-processing) (most
265224 Prolog systems).
266225 <li><i>goal_expansion/2</i><br>
267 Same as <a id="idx:termexpansion2:174"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
226 Same as <a name="idx:termexpansion2:176"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
268227 for individual goals (SICStus).
269228 <li><i>prolog_load_file/2</i><br>
270 Hook into <a id="idx:loadfiles2:175"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
229 Hook into <a name="idx:loadfiles2:177"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
271230 to load other data formats for Prolog sources from `non-file' resources.
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>,
231 The <a name="idx:loadfiles2:178"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
232 predicate is the ancestor of <a name="idx:consult1:179"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>, <a name="idx:usemodule1:180"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,
274233 etc.
275234 <li><i>qpredrefprolog_editlocate3</i><br>
276 Hook into <a id="idx:edit1:179"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
235 Hook into <a name="idx:edit1:181"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
277236 to locate objects (SWI).
278237 <li><i>qpredrefprolog_editedit_source1</i><br>
279 Hook into <a id="idx:edit1:180"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
238 Hook into <a name="idx:edit1:182"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
280239 to call an internal editor (SWI).
281240 <li><i>prolog_edit:edit_command/2</i><br>
282 Hook into <a id="idx:edit1:181"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
241 Hook into <a name="idx:edit1:183"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
283242 to define the external editor to use (SWI).
284243 <li><i>prolog_list_goal/1</i><br>
285244 Hook into the tracer to list the code associated to a particular goal
287246 <li><i>prolog_trace_interception/4</i><br>
288247 Hook into the tracer to handle trace events (SWI).
289248 <li><i>qpredrefprologdebug_control_hook1</i><br>
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>
249 Hook in <a name="idx:spy1:184"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>, <a name="idx:nospy1:185"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>, <a name="idx:nospyall0:186"></a><a class="pred" href="debugger.html#nospyall/0">nospyall/0</a>
250 and <a name="idx:debugging0:187"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>
292251 to extend these control predicates to higher-level libraries.
293252 <li><i>qpredrefprologhelp_hook1</i><br>
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>
253 Hook in <a name="idx:help0:188"></a><a class="pred" href="help.html#help/0">help/0</a>, <a name="idx:help1:189"></a><a class="pred" href="help.html#help/1">help/1</a>
254 and <a name="idx:apropos1:190"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
296255 to extend the help system.
297256 <li><i>resource/3</i><br>
298257 Define a new resource (not really a hook, but similar) (SWI).
301260 (SWI).
302261 <li><i>attr_unify_hook/2</i><br>
303262 Unification hook for attributed variables. Can be defined in any module.
304 See <a class="sec" href="attvar.html#sec:7.1">section 7.1</a> for
305 details.
263 See <a class="sec" href="attvar.html">section 7.1</a> for details.
306264 </ul>
307265
308266 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="xref.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="idesummary.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:idepreds"><a id="sec:3.8"><span class="sec-nr">3.8</span> <span class="sec-title">Accessing
194 <h2 id="sec:idepreds"><a name="sec:3.8"><span class="sec-nr">3.8</span> <span class="sec-title">Accessing
236195 the IDE from your program</span></a></h2>
237196
238 <a id="sec:idepreds"></a>
197 <a name="sec:idepreds"></a>
239198
240199 <p>Over the years a collection of IDE components have been developed,
241200 each with its own interface. In addition, some of these components
242201 require each other, and loading IDE components must be on demand to
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>).
202 avoid the IDE being part of a saved state (see <a name="idx:qsaveprogram2:327"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>).
244203 For this reason, access to the IDE is concentrated on a single interface
245 called <a id="idx:prologide1:326"></a><a class="pred" href="idepreds.html#prolog_ide/1">prolog_ide/1</a>:
204 called <a name="idx:prologide1:328"></a><a class="pred" href="idepreds.html#prolog_ide/1">prolog_ide/1</a>:
246205
247206 <dl class="latex">
248 <dt class="pubdef"><a id="prolog_ide/1"><strong>prolog_ide</strong>(<var>+Action</var>)</a></dt>
207 <dt class="pubdef"><a name="prolog_ide/1"><strong>prolog_ide</strong>(<var>+Action</var>)</a></dt>
249208 <dd class="defbody">
250209 This predicate ensures the IDE-enabling XPCE component is loaded,
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:
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:
254213
255214 <dl class="latex">
256215 <dt><strong>open_navigator</strong>(<var>+Directory</var>)</dt>
257216 <dd class="defbody">
258 Open the Prolog Navigator (see <a class="sec" href="navigator.html#sec:3.6">section
217 Open the Prolog Navigator (see <a class="sec" href="navigator.html">section
259218 3.6</a>) in the given
260219 <var>Directory</var>.</dd>
261220 <dt><strong>open_debug_status</strong></dt>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="idepreds.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="builtin.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:idesummary"><a id="sec:3.9"><span class="sec-nr">3.9</span> <span class="sec-title">Summary
194 <h2 id="sec:idesummary"><a name="sec:3.9"><span class="sec-nr">3.9</span> <span class="sec-title">Summary
236195 of the IDE</span></a></h2>
237196
238 <a id="sec:idesummary"></a>
197 <a name="sec:idesummary"></a>
239198
240199 <p>The SWI-Prolog development environment consists of a number of
241200 interrelated but not (yet) integrated tools. Here is a list of the most
251210 alternatives on the command <code>Alt-?</code>.
252211
253212 <p>
254 <li><i>Use <a id="idx:edit1:327"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
213 <li><i>Use <a name="idx:edit1:329"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
255214 for finding locations</i><br>
256 The command <a id="idx:edit1:328"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
215 The command <a name="idx:edit1:330"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
257216 takes the name of a file, module, predicate or other entity registered
258217 through extensions and starts the user's preferred editor at the right
259218 location.
266225
267226 <p>
268227 <li><i>Update Prolog after editing</i><br>
269 Using <a id="idx:make0:329"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
228 Using <a name="idx:make0:331"></a><a class="pred" href="consulting.html#make/0">make/0</a>,
270229 all files you have edited are re-loaded.
271230
272231 <p>
276235
277236 <p>
278237 <li><i>Using the graphical debugger</i><br>
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>
238 The predicates <a name="idx:guitracer0:332"></a><a class="pred" href="guitracer.html#guitracer/0">guitracer/0</a>
239 and <a name="idx:noguitracer0:333"></a><a class="pred" href="guitracer.html#noguitracer/0">noguitracer/0</a>
281240 switch between traditional text-based and window-based debugging. The
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>
241 tracer is activated using the <a name="idx:trace0:334"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>, <a name="idx:spy1:335"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
283242 or menu items from PceEmacs or the Prolog Navigator.
284243
285244 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="sponsor.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="acknowledge.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:implhistory"><a id="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Implementation
194 <h2 id="sec:implhistory"><a name="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Implementation
236195 history</span></a></h2>
237196
238 <a id="sec:implhistory"></a>
197 <a name="sec:implhistory"></a>
239198
240199 <p>SWI-Prolog started back in 1986 with the requirement for a Prolog
241200 that could handle recursive interaction with the C-language: Prolog
270229 of compiled code. The extensions include specialised instructions for
271230 unification, predicate invocation, some frequently used built-in
272231 predicates, arithmetic, and control (<a class="pred" href="control.html#;/2">;/2</a>, <a class="pred" href="control.html#|/2">|/2</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>).
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>).
275234
276235 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="defmodule.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="metapred.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:import"><a id="sec:6.3"><span class="sec-nr">6.3</span> <span class="sec-title">Importing
194 <h2 id="sec:import"><a name="sec:6.3"><span class="sec-nr">6.3</span> <span class="sec-title">Importing
236195 Predicates into a Module</span></a></h2>
237196
238 <a id="sec:import"></a>
197 <a name="sec:import"></a>
239198
240199 <p>Predicates can be added to a module by <em>importing</em> them from
241200 another module. Importing adds predicates to the namespace of a module.
244203 module in which it has been defined.
245204
246205 <p>Importing the predicates from another module is achieved using the
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>.
206 directives <a name="idx:usemodule1:1669"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
207 or <a name="idx:usemodule2:1670"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>.
249208 Note that both directives take
250209 <var>filename(s)</var> as arguments. That is, modules are imported based
251210 on their filename rather than their module name.
252211
253212 <dl class="latex">
254 <dt class="pubdef"><a id="use_module/1"><strong>use_module</strong>(<var>+Files</var>)</a></dt>
213 <dt class="pubdef"><a name="use_module/1"><strong>use_module</strong>(<var>+Files</var>)</a></dt>
255214 <dd class="defbody">
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>.
215 Load the file(s) specified with <var>Files</var> just like <a name="idx:ensureloaded1:1671"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>.
257216 The files must all be module files. All exported predicates from the
258217 loaded files are imported into the module from which this predicate is
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>,
218 called. This predicate is equivalent to <a name="idx:ensureloaded1:1672"></a><a class="pred" href="consulting.html#ensure_loaded/1">ensure_loaded/1</a>,
260219 except that it raises an error if <var>Files</var> are not module files.
261220
262221 <p>The imported predicates act as <em>weak symbols</em> in the module
264223 predicate overrides (clobbers) the imported definition. If the flag
265224 <a class="flag" href="flags.html#flag:warn_override_implicit_import">warn_override_implicit_import</a>
266225 is <code>true</code> (default), a warning is printed. Below is an
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>,
226 example of a module that uses library(lists), but redefines <a name="idx:flatten2:1673"></a><a class="pred" href="lists.html#flatten/2">flatten/2</a>,
268227 giving it a totally different meaning:
269228
270229 <pre class="code">
283242 overrides weak import from lists
284243 </pre>
285244
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>
245 <p>This warning can be avoided by (1) using <a name="idx:usemodule2:1674"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
287246 to only import the predicates from the <code>lists</code> library that
288247 are actually used in the `shapes' module, (2) using the <code>except([flatten/2])</code>
289 option of <a id="idx:usemodule2:1676"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>,
248 option of <a name="idx:usemodule2:1675"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>,
290249 (3) use
291 <code>:- abolish(<a id="idx:flatten2:1677"></a><a class="pred" href="lists.html#flatten/2">flatten/2</a>).</code>
250 <code>:- abolish(<a name="idx:flatten2:1676"></a><a class="pred" href="lists.html#flatten/2">flatten/2</a>).</code>
292251 before the local definition or (4) setting
293252 <a class="flag" href="flags.html#flag:warn_override_implicit_import">warn_override_implicit_import</a>
294253 to <code>false</code>. Globally disabling this warning is only
296255 design choices or the program is ported from a system that silently
297256 overrides imported predicates.
298257
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>
258 <p>Note that it is always an error to import two modules with <a name="idx:usemodule1:1677"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
300259 that export the same predicate. Such conflicts must be resolved with
301 <a id="idx:usemodule2:1679"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
260 <a name="idx:usemodule2:1678"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
302261 as described above.</dd>
303 <dt class="pubdef"><a id="use_module/2"><strong>use_module</strong>(<var>+File,
262 <dt class="pubdef"><a name="use_module/2"><strong>use_module</strong>(<var>+File,
304263 +ImportList</var>)</a></dt>
305264 <dd class="defbody">
306265 Load <var>File</var>, which must be a module file, and import the
309268 imported from the loaded module. <var>ImportList</var> also allows for
310269 renaming or import-everything-except. See also the <code>import</code>
311270 option of
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>
271 <a name="idx:loadfiles2:1679"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
272 The first example below loads <a name="idx:member2:1680"></a><a class="pred" href="lists.html#member/2">member/2</a>
273 from the <code>lists</code> library and <a name="idx:append2:1681"></a><a class="pred" href="lists.html#append/2">append/2</a>
315274 under the name <code>list_concat</code>, which is how this predicate is
316275 named in YAP. The second example loads all exports from library <code>option</code>
317 except for <a id="idx:metaoptions3:1683"></a><a class="pred" href="option.html#meta_options/3">meta_options/3</a>.
276 except for <a name="idx:metaoptions3:1682"></a><a class="pred" href="option.html#meta_options/3">meta_options/3</a>.
318277 These renaming facilities are generally used to deal with portability
319 issues with as few changes as possible to the actual code. See also <a class="sec" href="dialect.html#sec:C">section
278 issues with as few changes as possible to the actual code. See also <a class="sec" href="dialect.html">section
320279 C</a> and
321 <a class="sec" href="reexport.html#sec:6.7">section 6.7</a>.
280 <a class="sec" href="reexport.html">section 6.7</a>.
322281
323282 <pre class="code">
324283 :- use_module(library(lists), [ member/2,
332291
333292 <p>In most cases a module is imported because some of its predicates are
334293 being used. However, sometimes a module is imported for other reasons,
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>
294 e.g., for its declarations. In such cases it is best practice to use <a name="idx:usemodule2:1683"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
336295 with empty ImportList. This distinguishes an imported module that is
337296 used, although not for its predicates, from a module that is needlessly
338297 imported.
339298
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>
299 <p>The <a name="idx:module2:1684"></a><a class="pred" href="defmodule.html#module/2">module/2</a>, <a name="idx:usemodule1:1685"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
300 and <a name="idx:usemodule2:1686"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
342301 directives are sufficient to partition a simple Prolog program into
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>
302 modules. The SWI-Prolog graphical cross-referencing tool <a name="idx:gxref0:1687"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
344303 can be used to analyse the dependencies between non-module files and
345304 propose module declarations for each file.
346305
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="moduleop.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="resmodules.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:importmodule"><a id="sec:6.9"><span class="sec-nr">6.9</span> <span class="sec-title">Dynamic
194 <h2 id="sec:importmodule"><a name="sec:6.9"><span class="sec-nr">6.9</span> <span class="sec-title">Dynamic
236195 importing using import modules</span></a></h2>
237196
238 <a id="sec:importmodule"></a>
197 <a name="sec:importmodule"></a>
239198
240199 <p>Until now we discussed the public module interface that is, at least
241200 to some extent, portable between Prolog implementations with a module
251210 and
252211 <code>system</code> for all system library modules. Module <code>user</code>
253212 imports from <code>system</code> where all built-in predicates reside.
254 These special modules are described in more detail in <a class="sec" href="resmodules.html#sec:6.10">section
213 These special modules are described in more detail in <a class="sec" href="resmodules.html">section
255214 6.10</a>.
256215
257216 <p>The list of import modules can be manipulated and queried using the
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>.
217 following predicates, as well as using <a name="idx:setmodule1:1721"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>.
259218
260219 <dl class="latex">
261 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="import_module/2"><strong>import_module</strong>(<var>+Module,
220 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="import_module/2"><strong>import_module</strong>(<var>+Module,
262221 -Import</var>)</a></dt>
263222 <dd class="defbody">
264223 True if <var>Module</var> inherits directly from <var>Import</var>. All
265224 normal modules only import from <code>user</code>, which imports from
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>
225 <code>system</code>. The predicates <a name="idx:addimportmodule3:1722"></a><a class="pred" href="importmodule.html#add_import_module/3">add_import_module/3</a>
267226 and
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,
227 <a name="idx:deleteimportmodule2:1723"></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:1724"></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,
271230 -Default</var>)</a></dt>
272231 <dd class="defbody">
273232 True if predicates and operators in <var>Default</var> are visible in
274233 <var>Module</var>. Modules are returned in the same search order used
275234 for predicates and operators. That is, <var>Default</var> is first
276235 unified with <var>Module</var>, followed by the depth-first transitive
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,
236 closure of <a name="idx:importmodule2:1725"></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,
279238 +Import, +StartOrEnd</var>)</a></dt>
280239 <dd class="defbody">
281240 If <var>Import</var> is not already an import module for <var>Module</var>,
282241 add it to this list at the <code>start</code> or <code>end</code>
283242 depending on
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,
243 <var>StartOrEnd</var>. See also <a name="idx:importmodule2:1726"></a><a class="pred" href="importmodule.html#import_module/2">import_module/2</a>
244 and <a name="idx:deleteimportmodule2:1727"></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,
287246 +Import</var>)</a></dt>
288247 <dd class="defbody">
289248 Delete <var>Import</var> from the list of import modules for <var>Module</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="contents" href="Contents.html">
4 <title>SWI-Prolog 7.6.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, 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; }
18 dt.pubdef
19 { background-color: #c5e1ff;
20 }
21
22 dt.multidef
23 { background-color: #c8ffc7;
24 }
2925
3026 .bib dd
3127 { margin-bottom: 1em;
119115 padding-top: 0.2em;
120116 font-size: 80%;
121117 font-style: italic;
122 color: #fff;
118 color: #202020;
123119 }
124120
125121 div.caption
129125 }
130126
131127 /* Footnotes */
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;
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;
153139 }
154140
155141 /* Lists */
193179 font-size: +1;
194180 margin-top: 1ex;
195181 }
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
223182 </style>
224183 </head>
225184 <body style="background:white">
228187 <a class="nav" href="summary.html"><img src="info.gif" alt="Summary"></a>
229188 <a class="nav" href="Contents.html"><img src="next.gif" alt="Next"></a>
230189 </div>
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>
190 <div class="title">SWI-Prolog 7.6.4 Reference Manual</div>
191 <div class="author">mailto:J.Wielemaker@vu.nlJan Wielemaker <br>
234192 Department of Computer Science <br>
235193 VU University Amsterdam <br>
236194 De Boelelaan 1081a, 1081 HV&nbsp;&nbsp;Amsterdam
272230 sources. From the same source we generate the plain-text version and
273231 index used by the online help system (located in the file <code>MANUAL</code>
274232 in the library directory) as well as the PDF version. Sources, binaries
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>.
233 and documentation can be downloaded from the http://www.swi-prolog.org/Download.htmlSWI-Prolog
234 download page .
277235
278236 <p>The SWI-Prolog project <b>home page</b> is
279 <a class="url" href="http://www.swi-prolog.org">http://www.swi-prolog.org</a>
280
281 <p><img src="by-sa.png">
237 http://www.swi-prolog.orghttp://www.swi-prolog.org
282238
283239 <p>This work is licensed under the Creative Commons
284240 Attribution-ShareAlike 3.0 Unported License. To view a copy of this
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="quickstart.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="initgoal.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:initfile"><a id="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">The
194 <h2 id="sec:initfile"><a name="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">The
236195 user's initialisation file</span></a></h2>
237196
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
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
241200 the system initialisation, the system consults (see
242 <a id="idx:consult1:21"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
201 <a name="idx:consult1:21"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>)
243202 the user's startup file. The basename of this file follows conventions
244203 of the operating system. On MS-Windows, it is the file
245204 <code>swipl.ini</code> and on Unix systems <code>.swiplrc</code>. The
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>
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>
247206 clauses for
248207 <code>user_profile</code>.<sup class="fn">9<span class="fn-text">Older
249208 versions first searched in the current working directory. This feature
252211 The table below shows the default value for this search path. The phrase &lt;<var>appdata</var>&gt;
253212 refers to the Windows CSIDL name for the folder. The actual name depends
254213 on the Windows language. English versions typically use <code>ApplicationData</code>.
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>
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>
260220 </table>
261221
262222 <p>After the first startup file is found it is loaded and Prolog stops
275235 system skeleton.
276236
277237 <p>See also the <strong>-s</strong> (script) and <strong>-F</strong>
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>.
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>.
280240
281241 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="initfile.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="cmdline.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:initgoal"><a id="sec:2.3"><span class="sec-nr">2.3</span> <span class="sec-title">Initialisation
194 <h2 id="sec:initgoal"><a name="sec:2.3"><span class="sec-nr">2.3</span> <span class="sec-title">Initialisation
236195 files and goals</span></a></h2>
237196
238 <a id="sec:initgoal"></a>
239
240 <p>Using command line arguments (see <a class="sec" href="cmdline.html#sec:2.4">section
197 <a name="sec:initgoal"></a>
198
199 <p>Using command line arguments (see <a class="sec" href="cmdline.html">section
241200 2.4</a>), SWI-Prolog can be forced to load files and execute queries for
242201 initialisation purposes or non-interactive operation. The most commonly
243202 used options are
279238 :- halt. % and exit
280239 </pre>
281240
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
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
285244 generation of runtime executables. Runtime executables are a means to
286245 deliver executables that do not require the Prolog system.
287246
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="exception3.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="loadfilehook.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:intlibs"><a id="sec:B.7"><span class="sec-nr">B.7</span> <span class="sec-title">Hooks
194 <h2 id="sec:intlibs"><a name="sec:B.7"><span class="sec-nr">B.7</span> <span class="sec-title">Hooks
236195 for integrating libraries</span></a></h2>
237196
238 <a id="sec:intlibs"></a>
197 <a name="sec:intlibs"></a>
239198
240199 <p>Some libraries realise an entirely new programming paradigm on top of
241200 Prolog. An example is XPCE which adds an object system to Prolog as well
242201 as an extensive set of graphical primitives. SWI-Prolog provides several
243202 hooks to improve the integration of such libraries. See also
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.
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.
247205
248206 <dl class="latex">
249 <dt class="pubdef"><a id="prolog_list_goal/1"><strong>prolog_list_goal</strong>(<var>:Goal</var>)</a></dt>
207 <dt class="pubdef"><a name="prolog_list_goal/1"><strong>prolog_list_goal</strong>(<var>:Goal</var>)</a></dt>
250208 <dd class="defbody">
251209 Hook, normally not defined. This hook is called by the 'L' command of
252210 the tracer in the module <code>user</code> to list the currently called
253211 predicate. This hook may be defined to list only relevant clauses of the
254212 indicated <var>Goal</var> and/or show the actual source code in an
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>
213 editor. See also <a name="idx:portray1:2222"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
214 and <a name="idx:multifile1:2223"></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>
258216 <dd class="defbody">
259217 Hook for the debugger control predicates that allows the creator of more
260218 high-level programming languages to use the common front-end predicates
264222 <dl class="latex">
265223 <dt><strong>spy</strong>(<var>Spec</var>)</dt>
266224 <dd class="defbody">
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>
225 Hook in <a name="idx:spy1:2224"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>.
226 If the hook succeeds <a name="idx:spy1:2225"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
269227 takes no further action.
270228 </dd>
271229 <dt><strong>nospy</strong>(<var>Spec</var>)</dt>
272230 <dd class="defbody">
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>
231 Hook in <a name="idx:nospy1:2226"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
232 If the hook succeeds <a name="idx:nospy1:2227"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>
233 takes no further action. If <a name="idx:spy1:2228"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
276234 is hooked, it is advised to place a complementary hook for
277 <a id="idx:nospy1:2230"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
235 <a name="idx:nospy1:2229"></a><a class="pred" href="debugger.html#nospy/1">nospy/1</a>.
278236 </dd>
279237 <dt><strong>nospyall</strong></dt>
280238 <dd class="defbody">
281 Hook in <a id="idx:nospyall0:2231"></a><a class="pred" href="debugger.html#nospyall/0">nospyall/0</a>.
239 Hook in <a name="idx:nospyall0:2230"></a><a class="pred" href="debugger.html#nospyall/0">nospyall/0</a>.
282240 Should remove all spy points. This hook is called in a failure-driven
283241 loop.
284242 </dd>
285243 <dt><strong>debugging</strong></dt>
286244 <dd class="defbody">
287 Hook in <a id="idx:debugging0:2232"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>.
245 Hook in <a name="idx:debugging0:2231"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>.
288246 It can be used in two ways. It can report the status of the additional
289247 debug points controlled by the above hooks and fail to let the system
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>.
248 report the others, or it succeeds, overruling the entire behaviour of <a name="idx:debugging0:2232"></a><a class="pred" href="debugger.html#debugging/0">debugging/0</a>.
291249 </dd>
292250 </dl>
293251
294252 </dd>
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>.
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:2233"></a><a class="pred" href="help.html#help/0">help/0</a>
256 and <a name="idx:help1:2234"></a><a class="pred" href="help.html#help/1">help/1</a>.
299257 If the hook succeeds, the built-in actions are not executed. For
300258 example, <code>?- help(picture).</code> is caught by the XPCE help hook
301259 to give help on the class <em>picture</em>. Defined actions are:
303261 <dl class="latex">
304262 <dt><strong>help</strong></dt>
305263 <dd class="defbody">
306 User entered plain <a id="idx:help0:2236"></a><a class="pred" href="help.html#help/0">help/0</a>
264 User entered plain <a name="idx:help0:2235"></a><a class="pred" href="help.html#help/0">help/0</a>
307265 to give default help. The default performs
308 <code>help(<a id="idx:help1:2237"></a><a class="pred" href="help.html#help/1">help/1</a>)</code>,
266 <code>help(<a name="idx:help1:2236"></a><a class="pred" href="help.html#help/1">help/1</a>)</code>,
309267 giving help on help.
310268 </dd>
311269 <dt><strong>help</strong>(<var>What</var>)</dt>
312270 <dd class="defbody">
313 Hook in <a id="idx:help1:2238"></a><a class="pred" href="help.html#help/1">help/1</a>
271 Hook in <a name="idx:help1:2237"></a><a class="pred" href="help.html#help/1">help/1</a>
314272 on the topic <var>What</var>.
315273 </dd>
316274 <dt><strong>apropos</strong>(<var>What</var>)</dt>
317275 <dd class="defbody">
318 Hook in <a id="idx:apropos1:2239"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
276 Hook in <a name="idx:apropos1:2238"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
319277 on the topic <var>What</var>.
320278 </dd>
321279 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="Contents.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="swiprolog.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>This document is a <em>reference manual</em>. That means that it
240199 documents the system, but it does not explain the basics of the Prolog
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="gensym.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="lists.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:iostream"><a id="sec:A.14"><span class="sec-nr">A.14</span> <span class="sec-title">library(iostream):
194 <h2 id="sec:iostream"><a name="sec:A.14"><span class="sec-nr">A.14</span> <span class="sec-title">library(iostream):
236195 Utilities to deal with streams</span></a></h2>
237196
238 <p><a id="sec:iostream"></a>
197 <p><a name="sec:iostream"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">See also</dt>
270229 <a class="pred" href="iostream.html#open_any/5">open_any/5</a>.
271230
272231 <dl class="latex">
273 <dt class="pubdef"><a id="open_any/5"><strong>open_any</strong>(<var>+Specification,
232 <dt class="pubdef"><a name="open_any/5"><strong>open_any</strong>(<var>+Specification,
274233 +Mode, -Stream, -Close, +Options</var>)</a></dt>
275234 <dd class="defbody">
276235 Establish a stream from <var>Specification</var> that should be closed
340299 </dl>
341300
342301 </dd>
343 <dt class="pubdef"><a id="close_any/1"><strong>close_any</strong>(<var>+Goal</var>)</a></dt>
302 <dt class="pubdef"><a name="close_any/1"><strong>close_any</strong>(<var>+Goal</var>)</a></dt>
344303 <dd class="defbody">
345304 Execute the <var>Close</var> closure returned by <a class="pred" href="iostream.html#open_any/5">open_any/5</a>.
346305 The closure can also be called directly. Using <a class="pred" href="iostream.html#close_any/1">close_any/1</a>
347306 can be considered better style and enhances tractability of the source
348307 code.</dd>
349 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="open_hook/6"><strong>open_hook</strong>(<var>+Spec,
308 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="open_hook/6"><strong>open_hook</strong>(<var>+Spec,
350309 +Mode, -Stream, -Close, +Options0, -Options</var>)</a></dt>
351310 <dd class="defbody">
352311 Open <var>Spec</var> in <var>Mode</var>, producing <var>Stream</var>.
353312 <table class="arglist">
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>
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>
359320 </table>
360321 </dd>
361322 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.18</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="cyclic.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="widechars.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:jitindex"><a id="sec:2.18"><span class="sec-nr">2.18</span> <span class="sec-title">Just-in-time
194 <h2 id="sec:jitindex"><a name="sec:2.18"><span class="sec-nr">2.18</span> <span class="sec-title">Just-in-time
236195 clause indexing</span></a></h2>
237196
238 <a id="sec:jitindex"></a>
239
240 <p><a id="idx:jitindex:255"></a>SWI-Prolog provides `just-in-time'
197 <a name="sec:jitindex"></a>
198
199 <p><a name="idx:jitindex:257"></a>SWI-Prolog provides `just-in-time'
241200 indexing over multiple arguments.<sup class="fn">31<span class="fn-text">JIT
242201 indexing was added in version 5.11.29 (Oct. 2011).</span></sup>
243202 `Just-in-time' means that clause indexes are not built by the compiler
244 (or <a id="idx:asserta1:256"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
203 (or <a name="idx:asserta1:258"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
245204 for dynamic predicates), but on the first call to such a predicate where
246205 an index might help (i.e., a call where at least one argument is
247206 instantiated). This section describes the rules used by the indexing
299258 approach will recreate a suitable index on the next call. Indexes of
300259 running predicates cannot be deleted. They are added to a `removed index
301260 list' associated to the predicate. Outdated indexes of predicates are
302 reclaimed by <a id="idx:garbagecollectclauses0:257"></a><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
261 reclaimed by <a name="idx:garbagecollectclauses0:259"></a><a class="pred" href="memory.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>.
303262 The clause garbage collector is scheduled automatically, based on time
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>
263 and space based heuristics. See <a name="idx:garbagecollectclauses0:260"></a><a class="pred" href="memory.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a>
305264 for details.
306265 </ul>
307266
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
267 <p>The library <code>library(prolog_jiti)</code> provides <a name="idx:jitilist0:261"></a><span class="pred-ext">jiti_list/0</span>,1
309268 to list the characteristics of all or some of the created hash tables.
310269
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
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
312271 directions</span></a></h3>
313272
314 <a id="sec:indexfut"></a>
273 <a name="sec:indexfut"></a>
315274
316275 <p>
317276 <ul class="latex">
327286 lookup is too costly.
328287 </ul>
329288
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
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
331290 and portability</span></a></h3>
332291
333 <a id="sec:indexport"></a>
292 <a name="sec:indexport"></a>
334293
335294 <p>The base-line functionality of Prolog implementations provides
336295 indexing on constants and functor (name/arity) on the first argument.
337296 This must be your assumption if wide portability of your program is
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>
297 important. This can typically be achieved by exploiting <a name="idx:termhash2:262"></a><a class="pred" href="db.html#term_hash/2">term_hash/2</a>
298 or <a name="idx:termhash4:263"></a><a class="pred" href="db.html#term_hash/4">term_hash/4</a>
340299 and/or maintaining multiple copies of a predicate with reordered
341300 arguments and wrappers that update all implementations (assert/retract)
342301 and selects the appropriate implementation (query).
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="findappfile.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="aggregate.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:libpl"><a id="sec:A"><span class="sec-nr">A</span> <span class="sec-title">The
194 <h1 id="sec:libpl"><a name="sec:A"><span class="sec-nr">A</span> <span class="sec-title">The
236195 SWI-Prolog library</span></a></h1>
237196
238 <a id="sec:libpl"></a>
197 <a name="sec:libpl"></a>
239198
240199 <p>This chapter documents the SWI-Prolog library. As SWI-Prolog provides
241200 auto-loading, there is little difference between library predicates and
250209
251210 <p>
252211 <li>If autoloading is disabled explicitly or because trapping unknown
253 predicates is disabled (see <a id="idx:unknown2:2134"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
212 predicates is disabled (see <a name="idx:unknown2:2133"></a><a class="pred" href="debugger.html#unknown/2">unknown/2</a>
254213 and
255 <a id="idx:currentprologflag2:2135"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>),
214 <a name="idx:currentprologflag2:2134"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>),
256215 library predicates must be loaded explicitly.
257216
258217 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="predsummary.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="funcsummary.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:library"><a id="sec:F.2"><span class="sec-nr">F.2</span> <span class="sec-title">Library
194 <h2 id="sec:library"><a name="sec:F.2"><span class="sec-nr">F.2</span> <span class="sec-title">Library
236195 predicates</span></a></h2>
237196
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>
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>
243202 <table>
244203 <tr><td><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a></td><td>Aggregate
245204 bindings in Goal according to Template.</td></tr>
255214 free variables in bagof/setof template.</td></tr>
256215 </table>
257216
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>
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>
261220 <table>
262221 <tr><td><a class="pred" href="apply.html#convlist/3">convlist/3</a></td><td>Similar
263222 to maplist/3, but elements for which call(Goal, ElemIn, _) fails are
296255 scan of list.</td></tr>
297256 </table>
298257
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>
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>
302261 <table>
303262 <tr><td><a class="pred" href="assoc.html#assoc_to_list/2">assoc_to_list/2</a></td><td>Translate
304263 assoc into a pairs list</td></tr>
330289 association to an assoc</td></tr>
331290 </table>
332291
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>
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>
336295 <table>
337296 <tr><td><a class="pred" href="broadcast.html#broadcast/1">broadcast/1</a></td><td>Send
338297 event notification</td></tr>
352311 is listening to event notifications?</td></tr>
353312 </table>
354313
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>
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>
358317 <table>
359318 <tr><td><a class="pred" href="charsio.html#atom_to_chars/2">atom_to_chars/2</a></td><td>Convert
360319 Atom into a list of character codes.</td></tr>
386345 a term to a code list.</td></tr>
387346 </table>
388347
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>
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>
392351 <table>
393352 <tr><td><a class="pred" href="check.html#check/0">check/0</a></td><td>Run
394353 all consistency checks defined by checker/2.</td></tr>
422381 hook that qualifies Goal as valid for list_strings/0.</td></tr>
423382 </table>
424383
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>
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>
428387 <table>
429388 <tr><td><a class="pred" href="clpb.html#labeling/1">labeling/1</a></td><td>Enumerate
430389 concrete solutions.</td></tr>
440399 weighted optima over admissible assignments.</td></tr>
441400 </table>
442401
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>
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>
446405 <table>
447406 <tr><td><a class="pred" href="clpfd.html##/\/2">#/\/2</a></td><td>P and
448407 Q hold.</td></tr>
531490 to compare/3, with finite domain variables A and B.</td></tr>
532491 </table>
533492
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>
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>
537496 <table>
538497 <tr><td><a class="pred" href="clpqr.html#entailed/1">entailed/1</a></td><td>Check
539498 if constraint is entailed</td></tr>
555514 constraints on variables</td></tr>
556515 </table>
557516
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>
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>
561520 <table>
562521 <tr><td><a class="pred" href="csv.html#csv_options/2">csv_options/2</a></td><td>Compiled
563522 is the compiled representation of the CSV processing options as they may
576535 a list of Prolog terms to a CSV file.</td></tr>
577536 <tr><td><a class="pred" href="csv.html#csv_write_stream/3">csv_write_stream/3</a></td><td>Write
578537 the rows in Data to Stream.</td></tr>
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>
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>
588545 <table>
589546 <tr><td><a class="pred" href="debug.html#assertion/1">assertion/1</a></td><td>Acts
590547 similar to C assert() macro.</td></tr>
608565 a topic from being printed.</td></tr>
609566 </table>
610567
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>
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>
614571 <table>
615572 <tr><td><a class="pred" href="error.html#current_type/3">current_type/3</a></td><td>True
616573 when Type is a currently defined type and Var satisfies Type of the body
621578 <tr><td><a class="pred" href="error.html#existence_error/2">existence_error/2</a></td><td>Term
622579 is of the correct type and correct domain, but there is no existing
623580 (external) resource that is represented by it.</td></tr>
581 <tr><td><a class="pred" href="error.html#existence_error/3">existence_error/3</a></td><td>Term
582 is of the correct type and correct domain, but there is no existing
583 (external) resource that is represented by it in the provided set.</td></tr>
624584 <tr><td><a class="pred" href="error.html#has_type/2">has_type/2</a></td><td>True
625585 if Term satisfies Type.</td></tr>
626586 <tr><td><a class="pred" href="error.html#instantiation_error/1">instantiation_error/1</a></td><td>An
644604 argument is over-instantiated.</td></tr>
645605 </table>
646606
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>
607 <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>
608
609 <a name="sec:summary-lib-iostream"></a>
610 <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>
611
612 <a name="sec:summary-lib-summaries.d-iostream-tex"></a>
613
614 <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>
615
616 <a name="sec:summary-lib-lists"></a>
657617 <table>
658618 <tr><td><a class="pred" href="lists.html#append/2">append/2</a></td><td>Concatenate
659619 a list of lists.</td></tr>
721681 if Set3 unifies with the union of the lists Set1 and Set2.</td></tr>
722682 </table>
723683
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>
684 <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>
685
686 <a name="sec:summary-lib-main"></a>
727687 <table>
728688 <tr><td><a class="pred" href="main.html#argv_options/3">argv_options/3</a></td><td>Generic
729689 transformation of long commandline arguments to options.</td></tr>
731691 main/1 using the passed command-line arguments.</td></tr>
732692 </table>
733693
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>
694 <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>
695
696 <a name="sec:summary-lib-option"></a>
737697 <table>
738698 <tr><td><a class="pred" href="option.html#dict_options/2">dict_options/2</a></td><td>Convert
739699 between an option list and a dictionary.</td></tr>
751711 and remove Option with default value.</td></tr>
752712 </table>
753713
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>
714 <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>
715
716 <a name="sec:summary-lib-optparse"></a>
757717 <table>
758718 <tr><td><a class="pred" href="optparse.html#opt_arguments/3">opt_arguments/3</a></td><td>Extract
759719 commandline options according to a specification.</td></tr>
767727 to parse option text Codes to an object of type Type.</td></tr>
768728 </table>
769729
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>
730 <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>
731
732 <a name="sec:summary-lib-ordsets"></a>
773733 <table>
774734 <tr><td><a class="pred" href="ordsets.html#is_ordset/1">is_ordset/1</a></td><td>True
775735 if Term is an ordered set.</td></tr>
813773 iff ord_union(Set1, Set2, Union) and ord_subtract(Set2, Set1, New).</td></tr>
814774 </table>
815775
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>
776 <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>
777
778 <a name="sec:summary-lib-persistency"></a>
819779 <table>
820780 <tr><td><a class="pred" href="persistency.html#current_persistent_predicate/1">current_persistent_predicate/1</a></td><td>True
821781 if PI is a predicate that provides access to the persistent database DB.</td></tr>
834794 dynamic database terms.</td></tr>
835795 </table>
836796
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>
797 <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>
798
799 <a name="sec:summary-lib-predicate_options"></a>
840800 <table>
841801 <tr><td><a class="pred" href="predicate_options.html#assert_predicate_options/4">assert_predicate_options/4</a></td><td>As
842802 predicate_options(:PI, +Arg, +Options).</td></tr>
862822 all dynamically (derived) predicate options.</td></tr>
863823 </table>
864824
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>
825 <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>
826
827 <a name="sec:summary-lib-prologpack"></a>
868828 <table>
869829 <tr><td><a class="pred" href="prologpack.html#environment/2">environment/2</a></td><td>Hook
870830 to define the environment for building packs.</td></tr>
894854 if File is a unique id for the referenced pack and version.</td></tr>
895855 </table>
896856
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>
857 <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>
858
859 <a name="sec:summary-lib-prologxref"></a>
900860 <table>
901861 <tr><td><a class="pred" href="prolog_xref.html#prolog:called_by/2">prolog:called_by/2</a></td><td><i>(hook)</i>
902862 Extend cross-referencer</td></tr>
918878 analysis of source</td></tr>
919879 </table>
920880
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>
881 <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>
882
883 <a name="sec:summary-lib-pairs"></a>
924884 <table>
925885 <tr><td><a class="pred" href="pairs.html#group_pairs_by_key/2">group_pairs_by_key/2</a></td><td>Group
926886 values with equivalent (==/2) consecutive keys.</td></tr>
936896 Key-Value to Value-Key.</td></tr>
937897 </table>
938898
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>
899 <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>
900
901 <a name="sec:summary-lib-pio"></a>
902 <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>
903
904 <a name="sec:summary-lib-pure-input"></a>
945905 <table>
946906 <tr><td><a class="pred" href="pio.html#phrase_from_file/2">phrase_from_file/2</a></td><td>Process
947907 the content of File using the DCG rule Grammar.</td></tr>
951911 Grammer against the character codes on Stream.</td></tr>
952912 <tr><td><a class="pred" href="pio.html#stream_to_lazy_list/2">stream_to_lazy_list/2</a></td><td>Create
953913 a lazy list representing the character codes in Stream.</td></tr>
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>
914 lazy_list_character_count1True when CharCount is the current character
915 count in the Lazy list.
916 lazy_list_location1Determine current (error) location in a lazy list.
917 syntax_error1Throw the syntax error Error at the current location of the
918 input.
919 </table>
920
921 <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>
922
923 <a name="sec:summary-lib-random"></a>
965924 <table>
966925 <tr><td><a class="pred" href="random.html#getrand/1">getrand/1</a></td><td>Query/set
967926 the state of the random generator.</td></tr>
993952 the state of the random generator.</td></tr>
994953 </table>
995954
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>
955 <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>
956
957 <a name="sec:summary-lib-readutil"></a>
999958 <table>
1000959 <tr><td><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a></td><td>Read
1001960 line from a stream</td></tr>
1011970 contents of file to Prolog terms</td></tr>
1012971 </table>
1013972
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>
973 <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>
974
975 <a name="sec:summary-lib-record"></a>
1017976 <table>
1018977 <tr><td><a class="pred" href="record.html#record/1">record/1</a></td><td>Define
1019978 named fields in a term</td></tr>
1020979 </table>
1021980
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>
981 <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>
982
983 <a name="sec:summary-lib-registry"></a>
1025984
1026985 <p>This library is only available on Windows systems.
1027986 <table>
10431002 Prolog</td></tr>
10441003 </table>
10451004
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>
1005 <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>
1006
1007 <a name="sec:summary-lib-simplex"></a>
10491008 <table>
10501009 <tr><td><a class="pred" href="simplex.html#assignment/2">assignment/2</a></td><td>Solve
10511010 assignment problem</td></tr>
10711030 value of variable in solved state</td></tr>
10721031 </table>
10731032
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>
1033 <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>
1034
1035 <a name="sec:summary-lib-ugraphs"></a>
10771036 <table>
10781037 <tr><td><a class="pred" href="ugraphs.html#vertices_edges_to_ugraph/3">vertices_edges_to_ugraph/3</a></td><td>Create
10791038 unweighted graph</td></tr>
11101069 of two graphs</td></tr>
11111070 </table>
11121071
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>
1072 <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>
1073
1074 <a name="sec:summary-lib-url"></a>
11161075 <table>
11171076 <tr><td><a class="pred" href="url.html#file_name_to_url/2">file_name_to_url/2</a></td><td>Translate
11181077 between a filename and a file:<code>//</code> URL.</td></tr>
11361095 to/from application/x-www-form-encoded.</td></tr>
11371096 </table>
11381097
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>
1098 <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>
1099
1100 <a name="sec:summary-lib-www_browser"></a>
11421101 <table>
11431102 <tr><td><a class="pred" href="www_browser.html#www_open_url/1">www_open_url/1</a></td><td>Open
11441103 a web-page in a browser</td></tr>
11451104 </table>
11461105
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>
1106 <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>
1107
1108 <a name="sec:summary-lib-solution_sequences"></a>
1109 <table>
11531110 <tr><td><a class="pred" href="solutionsequences.html#distinct/1">distinct/1</a></td><td>True
11541111 if Goal is true and no previous solution of Goal bound Witness to the
11551112 same value.</td></tr>
11721129 a limited amount of memory.</td></tr>
11731130 </table>
11741131
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>
1132 <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>
1133
1134 <a name="sec:summary-lib-thread_pool"></a>
11781135 <table>
11791136 <tr><td><a class="pred" href="threadpool.html#create_pool/1">create_pool/1</a></td><td>Hook
11801137 to create a thread pool lazily.</td></tr>
11901147 if Property is a property of thread pool Name.</td></tr>
11911148 </table>
11921149
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>
1150 <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>
1151
1152 <a name="sec:summary-lib-varnumbers"></a>
11961153 <table>
11971154 <tr><td><a class="pred" href="varnumbers.html#max_var_number/3">max_var_number/3</a></td><td>True
11981155 when Max is the max of Start and the highest numbered $VAR(N) term.</td></tr>
12091166 the `X` terms with the variable it is mapped to.</td></tr>
12101167 </table>
12111168
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>
1169 <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>
1170
1171 <a name="sec:summary-lib-yall"></a>
12151172 <table>
12161173 <tr><td><a class="pred" href="yall.html#//2">//2</a></td><td>Shorthand
12171174 for `Free/[]<code>&gt;&gt;</code>Lambda`.</td></tr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="glossary.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="contrib.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:license"><a id="sec:E"><span class="sec-nr">E</span> <span class="sec-title">SWI-Prolog
194 <h1 id="sec:license"><a name="sec:E"><span class="sec-nr">E</span> <span class="sec-title">SWI-Prolog
236195 License Conditions and Tools</span></a></h1>
237196
238 <a id="sec:license"></a>
239
240 <p>As of version 7.4.0<sup class="fn">189<span class="fn-text">Actually
197 <a name="sec:license"></a>
198
199 <p>As of version 7.4.0<sup class="fn">188<span class="fn-text">Actually
241200 pre-release 7.3.33</span></sup>, the SWI-Prolog source code is
242201 distributed under the
243 <a class="url" href="https://opensource.org/licenses/BSD-2-Clause">Simplified
244 BSD</a> license:
202 https://opensource.org/licenses/BSD-2-ClauseSimplified BSD license:
245203
246204 <pre class="code">
247205 Redistribution and use in source and binary forms, with or without
275233 linked to libraries that are more restrictive and in addition your code
276234 may have loaded extension packages that have more restrictive
277235 conditions. In particular, the core is by default linked to
278 <a class="url" href="https://gmplib.org/">libgmp</a>, distributed under
279 the Lesser GNU Public license.
236 https://gmplib.org/libgmp, distributed under the Lesser GNU Public
237 license.
280238
281239 <p>The above implies you need to configure and recompile the system
282240 without these components. For this we provide options to the <b>configure</b>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.20</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="widechars.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="64bits.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:limits"><a id="sec:2.20"><span class="sec-nr">2.20</span> <span class="sec-title">System
194 <h2 id="sec:limits"><a name="sec:2.20"><span class="sec-nr">2.20</span> <span class="sec-title">System
236195 limits</span></a></h2>
237196
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
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
241200 on memory areas</span></a></h3>
242201
243 <a id="sec:memlimit"></a>
202 <a name="sec:memlimit"></a>
244203
245204 <p>SWI-Prolog has a number of memory areas which are only enlarged to a
246205 certain limit. The internal data representation limits the local, global
254213 data.
255214
256215 <p>The limits can be changed from the command line as well as at runtime
257 using <a id="idx:setprologstack2:278"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
216 using <a name="idx:setprologstack2:280"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>.
258217 The table below shows these areas. The first column gives the option
259218 name to modify the size of the area. The option character is immediately
260219 followed by a number and optionally by a
262221 indicator, the value is interpreted in Kbytes (1024&nbsp;bytes); with <code>m</code>,
263222 the value is interpreted in Mbytes (<var>1024 &times; 1024</var> bytes).
264223
265 <p>The PrologScript facility described in <a class="sec" href="compilation.html#sec:2.10.2.1">section
224 <p>The PrologScript facility described in <a class="sec" href="compilation.html">section
266225 2.10.2.1</a> provides a mechanism for specifying options with the load
267226 file. On Windows the default stack sizes are controlled using the
268 Windows <a id="idx:registry:279">registry</a> on the key <code>HKEY_CURRENT_USER\Software\SWI\Prolog</code>
227 Windows <a name="idx:registry:281">registry</a> on the key <code>HKEY_CURRENT_USER\Software\SWI\Prolog</code>
269228 using the names <code>localSize</code>, <code>globalSize</code> and <code>trailSize</code>.
270229 The value is a <code>DWORD</code> expressing the default stack size in
271230 Kbytes. A GUI for modifying these values is provided using the XPCE
272 package. To use this, start the XPCE manual tools using manpce/0 , after
231 package. To use this, start the XPCE manual tools using manpce0, after
273232 which you find <i>Preferences</i> in the <i>File</i> menu.
274233
275234 <p>Considering portability, applications that need to modify the default
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
235 limits are advised to do so using <a name="idx:setprologstack2:282"></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
280239 name</td><td>Description </td></tr>
281 <tr class="hline"><td align=center><strong>-L</strong> </td><td align=center>128M</td><td><b>local
240 <tbody>
241 <tr valign="top"><td align=center><strong>-L</strong> </td><td align=center>128M</td><td><b>local
282242 stack</b></td><td>The local stack is used to store the execution
283243 environments of procedure invocations. The space for an environment is
284244 reclaimed when it fails, exits without leaving choice points, the
285245 alternatives are cut off with the !/0 predicate or no choice points have
286246 been created since the invocation and the last subclause is started
287247 (last call optimisation). </td></tr>
288 <tr><td align=center><strong>-G</strong> </td><td align=center>128M</td><td><b>global
248 <tr valign="top"><td align=center><strong>-G</strong> </td><td align=center>128M</td><td><b>global
289249 stack</b></td><td>The global stack is used to store terms created during
290250 Prolog's execution. Terms on this stack will be reclaimed by
291251 backtracking to a point before the term was created or by garbage
292252 collection (provided the term is no longer referenced). </td></tr>
293 <tr><td align=center><strong>-T</strong> </td><td align=center>128M</td><td><b>trail
253 <tr valign="top"><td align=center><strong>-T</strong> </td><td align=center>128M</td><td><b>trail
294254 stack</b></td><td>The trail stack is used to store assignments during
295255 execution. Entries on this stack remain alive until backtracking before
296256 the point of creation or the garbage collector determines they are no
297257 longer needed. </td></tr>
298258 </table>
299259 <div class="caption"><b>Table 2 : </b>Memory areas</div>
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
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
303263 heap</span></a></h4>
304264
305 <a id="sec:heap"></a>
306
307 <p><a id="idx:stackmemorymanagement:281"></a><a id="idx:memorylayout:282"></a>With
265 <a name="sec:heap"></a>
266
267 <p><a name="idx:stackmemorymanagement:283"></a><a name="idx:memorylayout:284"></a>With
308268 the heap, we refer to the memory area used by malloc() and friends.
309269 SWI-Prolog uses the area to store atoms, functors, predicates and their
310270 clauses, records and other dynamic data. No limits are imposed on the
311271 addresses returned by malloc() and friends.
312272
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
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
314274 Limits</span></a></h3>
315275
316 <a id="sec:morelimits"></a>
276 <a name="sec:morelimits"></a>
317277
318278 <dl class="latex">
319279 <dt><b>Clauses</b></dt>
325285 <dd>
326286 SWI-Prolog has no limits on the length of atoms and strings. The number
327287 of atoms is limited to 16777216 (16M) on 32-bit machines. On 64-bit
328 machines this is virtually unlimited. See also <a class="sec" href="foreigninclude.html#sec:11.4.2.1">section
288 machines this is virtually unlimited. See also <a class="sec" href="foreigninclude.html">section
329289 11.4.2.1</a>.</dd>
330290 <dt><b>Memory areas</b></dt>
331291 <dd>
340300 managed stack and perform optimization for processing the last argument
341301 of a term. This implies they can process deeply nested terms at constant
342302 and low usage of the C stack, and the system raises a resource error if
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>
303 no more stack can be allocated. Currently only <a name="idx:read1:285"></a><a class="pred" href="termrw.html#read/1">read/1</a>
304 and <a name="idx:write1:286"></a><a class="pred" href="termrw.html#write/1">write/1</a>
345305 (and all variations thereof) still use the C stack and may cause the
346306 system to crash in an uncontrolled way (i.e., not mapped to a Prolog
347307 exception that can be caught).</dd>
364324 </dd>
365325 </dl>
366326
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
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
368328 Names</span></a></h3>
369329
370 <a id="sec:resnames"></a>
330 <a name="sec:resnames"></a>
371331
372332 <p>The boot compiler (see <strong>-b</strong> option) does not support
373333 the module system. As large parts of the system are written in Prolog
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="edit.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="typetest.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:listing"><a id="sec:4.5"><span class="sec-nr">4.5</span> <span class="sec-title">List
194 <h2 id="sec:listing"><a name="sec:4.5"><span class="sec-nr">4.5</span> <span class="sec-title">List
236195 the program, predicates or clauses</span></a></h2>
237196
238 <a id="sec:listing"></a>
197 <a name="sec:listing"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="listing/1"><strong>listing</strong>(<var>:Pred</var>)</a></dt>
200 <dt class="pubdef"><a name="listing/1"><strong>listing</strong>(<var>:Pred</var>)</a></dt>
242201 <dd class="defbody">
243202 List predicates specified by <var>Pred</var>. <var>Pred</var> may be a
244203 predicate name (atom), which lists all predicates with this name,
250209
251210 <p>A listing is produced by enumerating the clauses of the predicate
252211 using
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>.
212 <a name="idx:clause2:597"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>
213 and printing each clause using <a name="idx:portrayclause1:598"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>.
255214 This implies that the variable names are generated (<var>A</var>, <var>B</var>,
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>.
215 ... ) and the layout is defined by rules in <a name="idx:portrayclause1:599"></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:600"></a><a class="pred" href="listing.html#listing/1">listing/1</a>.
260219 For example,
261220 <code>?- listing.</code> lists clauses in the default <code>user</code>
262221 module and <code>?- lists:listing.</code> lists the clauses in the
263222 module
264223 <code>lists</code>.</dd>
265 <dt class="pubdef"><a id="portray_clause/1"><strong>portray_clause</strong>(<var>+Clause</var>)</a></dt>
224 <dt class="pubdef"><a name="portray_clause/1"><strong>portray_clause</strong>(<var>+Clause</var>)</a></dt>
266225 <dd class="defbody">
267226 Pretty print a clause. A clause should be specified as a term `<code>&lt;<var>Head</var>&gt;
268227 :- &lt;<var>Body</var>&gt;</code>'. Facts are represented as `<code>&lt;<var>Head</var>&gt;
269228 :- true</code>' or simply <code>&lt;<var>Head</var>&gt;</code>.
270229 Variables in the clause are written as <var>A</var>, <var>B</var>, ... .
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,
230 Singleton variables are written as <code>_</code>. See also <a name="idx:portrayclause2:601"></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,
273232 +Clause</var>)</a></dt>
274233 <dd class="defbody">
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>
234 Pretty print a clause to <var>Stream</var>. See <a name="idx:portrayclause1:602"></a><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a>
276235 for details.
277236 </dd>
278237 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="iostream.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="main.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:lists"><a id="sec:A.15"><span class="sec-nr">A.15</span> <span class="sec-title">library(lists):
194 <h2 id="sec:lists"><a name="sec:A.15"><span class="sec-nr">A.15</span> <span class="sec-title">library(lists):
236195 List Manipulation</span></a></h2>
237196
238 <p><a id="sec:lists"></a>
197 <p><a name="sec:lists"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">Compatibility</dt>
256215 their specification by Quintus and SICStus.
257216
258217 <dl class="latex">
259 <dt class="pubdef"><a id="member/2"><strong>member</strong>(<var>?Elem,
218 <dt class="pubdef"><a name="member/2"><strong>member</strong>(<var>?Elem,
260219 ?List</var>)</a></dt>
261220 <dd class="defbody">
262221 True if <var>Elem</var> is a member of <var>List</var>. The SWI-Prolog
276235 </dl>
277236
278237 </dd>
279 <dt class="pubdef"><a id="append/3"><strong>append</strong>(<var>?List1,
238 <dt class="pubdef"><a name="append/3"><strong>append</strong>(<var>?List1,
280239 ?List2, ?List1AndList2</var>)</a></dt>
281240 <dd class="defbody">
282241 <var>List1AndList2</var> is the concatenation of <var>List1</var> and <var>List2</var></dd>
283 <dt class="pubdef"><a id="append/2"><strong>append</strong>(<var>+ListOfLists,
242 <dt class="pubdef"><a name="append/2"><strong>append</strong>(<var>+ListOfLists,
284243 ?List</var>)</a></dt>
285244 <dd class="defbody">
286245 Concatenate a list of lists. Is true if <var>ListOfLists</var> is a list
287246 of lists, and <var>List</var> is the concatenation of these lists.
288247 <table class="arglist">
289 <tr><td><var>ListOfLists</var> </td><td>must be a list of <i>possibly</i>
248 <tr valign="top"><td><var>ListOfLists</var> </td><td>must be a list of <i>possibly</i>
290249 partial lists </td></tr>
291250 </table>
292251 </dd>
293 <dt class="pubdef"><a id="prefix/2"><strong>prefix</strong>(<var>?Part,
252 <dt class="pubdef"><a name="prefix/2"><strong>prefix</strong>(<var>?Part,
294253 ?Whole</var>)</a></dt>
295254 <dd class="defbody">
296255 True iff <var>Part</var> is a leading substring of <var>Whole</var>.
297256 This is the same as <code>append(Part, _, Whole)</code>.</dd>
298 <dt class="pubdef"><a id="select/3"><strong>select</strong>(<var>?Elem,
257 <dt class="pubdef"><a name="select/3"><strong>select</strong>(<var>?Elem,
299258 ?List1, ?List2</var>)</a></dt>
300259 <dd class="defbody">
301260 Is true when <var>List1</var>, with <var>Elem</var> removed, results in <var>List2</var>.</dd>
302 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="selectchk/3"><strong>selectchk</strong>(<var>+Elem,
261 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="selectchk/3"><strong>selectchk</strong>(<var>+Elem,
303262 +List, -Rest</var>)</a></dt>
304263 <dd class="defbody">
305264 Semi-deterministic removal of first element in <var>List</var> that
306265 unifies with <var>Elem</var>.</dd>
307 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="select/4"><strong>select</strong>(<var>?X,
266 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="select/4"><strong>select</strong>(<var>?X,
308267 ?XList, ?Y, ?YList</var>)</a></dt>
309268 <dd class="defbody">
310269 Select from two lists at the same positon. True if <var>XList</var> is
330289 </dl>
331290
332291 </dd>
333 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="selectchk/4"><strong>selectchk</strong>(<var>?X,
292 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="selectchk/4"><strong>selectchk</strong>(<var>?X,
334293 ?XList, ?Y, ?YList</var>)</a></dt>
335294 <dd class="defbody">
336295 Semi-deterministic version of <a class="pred" href="lists.html#select/4">select/4</a>.</dd>
337 <dt class="pubdef"><a id="nextto/3"><strong>nextto</strong>(<var>?X, ?Y,
338 ?List</var>)</a></dt>
296 <dt class="pubdef"><a name="nextto/3"><strong>nextto</strong>(<var>?X,
297 ?Y, ?List</var>)</a></dt>
339298 <dd class="defbody">
340299 True if <var>Y</var> directly follows <var>X</var> in <var>List</var>.</dd>
341 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="delete/3"><strong>delete</strong>(<var>+List1,
300 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="delete/3"><strong>delete</strong>(<var>+List1,
342301 @Elem, -List2</var>)</a></dt>
343302 <dd class="defbody">
344303 Delete matching elements from a list. True when <var>List2</var> is a
362321 </dl>
363322
364323 </dd>
365 <dt class="pubdef"><a id="nth0/3"><strong>nth0</strong>(<var>?Index,
324 <dt class="pubdef"><a name="nth0/3"><strong>nth0</strong>(<var>?Index,
366325 ?List, ?Elem</var>)</a></dt>
367326 <dd class="defbody">
368327 True when <var>Elem</var> is the <var>Index</var>'th element of <var>List</var>.
381340 </dl>
382341
383342 </dd>
384 <dt class="pubdef"><a id="nth1/3"><strong>nth1</strong>(<var>?Index,
343 <dt class="pubdef"><a name="nth1/3"><strong>nth1</strong>(<var>?Index,
385344 ?List, ?Elem</var>)</a></dt>
386345 <dd class="defbody">
387346 Is true when <var>Elem</var> is the <var>Index</var>'th element of <var>List</var>.
395354 </dl>
396355
397356 </dd>
398 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="nth0/4"><strong>nth0</strong>(<var>?N,
357 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="nth0/4"><strong>nth0</strong>(<var>?N,
399358 ?List, ?Elem, ?Rest</var>)</a></dt>
400359 <dd class="defbody">
401360 Select/insert element at index. True when <var>Elem</var> is the <var>N</var>'th
418377 </pre>
419378
420379 </dd>
421 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="nth1/4"><strong>nth1</strong>(<var>?N,
380 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="nth1/4"><strong>nth1</strong>(<var>?N,
422381 ?List, ?Elem, ?Rest</var>)</a></dt>
423382 <dd class="defbody">
424383 As <a class="pred" href="lists.html#nth0/4">nth0/4</a>, but counting
425384 starts at 1.</dd>
426 <dt class="pubdef"><a id="last/2"><strong>last</strong>(<var>?List,
385 <dt class="pubdef"><a name="last/2"><strong>last</strong>(<var>?List,
427386 ?Last</var>)</a></dt>
428387 <dd class="defbody">
429388 Succeeds when <var>Last</var> is the last element of <var>List</var>.
441400 </dl>
442401
443402 </dd>
444 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="proper_length/2"><strong>proper_length</strong>(<var>@List,
403 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="proper_length/2"><strong>proper_length</strong>(<var>@List,
445404 -Length</var>)</a></dt>
446405 <dd class="defbody">
447406 True when <var>Length</var> is the number of elements in the proper list
454413 </pre>
455414
456415 </dd>
457 <dt class="pubdef"><a id="same_length/2"><strong>same_length</strong>(<var>?List1,
416 <dt class="pubdef"><a name="same_length/2"><strong>same_length</strong>(<var>?List1,
458417 ?List2</var>)</a></dt>
459418 <dd class="defbody">
460419 Is true when <var>List1</var> and <var>List2</var> are lists with the
470429 </dl>
471430
472431 </dd>
473 <dt class="pubdef"><a id="reverse/2"><strong>reverse</strong>(<var>?List1,
432 <dt class="pubdef"><a name="reverse/2"><strong>reverse</strong>(<var>?List1,
474433 ?List2</var>)</a></dt>
475434 <dd class="defbody">
476435 Is true when the elements of <var>List2</var> are in reverse order
477436 compared to
478437 <var>List1</var>.</dd>
479 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="permutation/2"><strong>permutation</strong>(<var>?Xs,
438 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="permutation/2"><strong>permutation</strong>(<var>?Xs,
480439 ?Ys</var>)</a></dt>
481440 <dd class="defbody">
482441 True when <var>Xs</var> is a permutation of <var>Ys</var>. This can
521480 </dl>
522481
523482 </dd>
524 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="flatten/2"><strong>flatten</strong>(<var>+NestedList,
483 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="flatten/2"><strong>flatten</strong>(<var>+NestedList,
525484 -FlatList</var>)</a></dt>
526485 <dd class="defbody">
527486 Is true if <var>FlatList</var> is a non-nested version of <var>NestedList</var>.
543502 </dl>
544503
545504 </dd>
546 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="max_member/2"><strong>max_member</strong>(<var>-Max,
505 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="max_member/2"><strong>max_member</strong>(<var>-Max,
547506 +List</var>)</a></dt>
548507 <dd class="defbody">
549508 True when <var>Max</var> is the largest member in the standard order of
559518 </dl>
560519
561520 </dd>
562 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="min_member/2"><strong>min_member</strong>(<var>-Min,
521 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="min_member/2"><strong>min_member</strong>(<var>-Min,
563522 +List</var>)</a></dt>
564523 <dd class="defbody">
565524 True when <var>Min</var> is the smallest member in the standard order of
575534 </dl>
576535
577536 </dd>
578 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="sum_list/2"><strong>sum_list</strong>(<var>+List,
537 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="sum_list/2"><strong>sum_list</strong>(<var>+List,
579538 -Sum</var>)</a></dt>
580539 <dd class="defbody">
581540 <var>Sum</var> is the result of adding all numbers in <var>List</var>.</dd>
582 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="max_list/2"><strong>max_list</strong>(<var>+List:list(number),
541 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="max_list/2"><strong>max_list</strong>(<var>+List:list(number),
583542 -Max:number</var>)</a></dt>
584543 <dd class="defbody">
585544 True if <var>Max</var> is the largest number in <var>List</var>. Fails
593552 </dl>
594553
595554 </dd>
596 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="min_list/2"><strong>min_list</strong>(<var>+List:list(number),
555 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="min_list/2"><strong>min_list</strong>(<var>+List:list(number),
597556 -Min:number</var>)</a></dt>
598557 <dd class="defbody">
599558 True if <var>Min</var> is the smallest number in <var>List</var>. Fails
607566 </dl>
608567
609568 </dd>
610 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="numlist/3"><strong>numlist</strong>(<var>+Low,
569 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="numlist/3"><strong>numlist</strong>(<var>+Low,
611570 +High, -List</var>)</a></dt>
612571 <dd class="defbody">
613572 <var>List</var> is a list [<var>Low</var>, <var>Low</var>+1, ... <var>High</var>].
622581 </dl>
623582
624583 </dd>
625 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_set/1"><strong>is_set</strong>(<var>@Set</var>)</a></dt>
584 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_set/1"><strong>is_set</strong>(<var>@Set</var>)</a></dt>
626585 <dd class="defbody">
627586 True if <var>Set</var> is a proper list without duplicates. Equivalence
628587 is based on <a class="pred" href="compare.html#==/2">==/2</a>. The
630589 which implies that the complexity is N*<code>log(N)</code> and the
631590 predicate may cause a resource-error. There are no other error
632591 conditions.</dd>
633 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="list_to_set/2"><strong>list_to_set</strong>(<var>+List,
592 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="list_to_set/2"><strong>list_to_set</strong>(<var>+List,
634593 ?Set</var>)</a></dt>
635594 <dd class="defbody">
636595 True when <var>Set</var> has the same elements as <var>List</var> in the
660619 </dl>
661620
662621 </dd>
663 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="intersection/3"><strong>intersection</strong>(<var>+Set1,
622 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="intersection/3"><strong>intersection</strong>(<var>+Set1,
664623 +Set2, -Set3</var>)</a></dt>
665624 <dd class="defbody">
666625 True if <var>Set3</var> unifies with the intersection of <var>Set1</var>
676635 </dl>
677636
678637 </dd>
679 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="union/3"><strong>union</strong>(<var>+Set1,
638 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="union/3"><strong>union</strong>(<var>+Set1,
680639 +Set2, -Set3</var>)</a></dt>
681640 <dd class="defbody">
682641 True if <var>Set3</var> unifies with the union of the lists <var>Set1</var>
692651 </dl>
693652
694653 </dd>
695 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="subset/2"><strong>subset</strong>(<var>+SubSet,
654 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="subset/2"><strong>subset</strong>(<var>+SubSet,
696655 +Set</var>)</a></dt>
697656 <dd class="defbody">
698657 True if all elements of <var>SubSet</var> belong to <var>Set</var> as
710669 </dl>
711670
712671 </dd>
713 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="subtract/3"><strong>subtract</strong>(<var>+Set,
672 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="subtract/3"><strong>subtract</strong>(<var>+Set,
714673 +Delete, -Result</var>)</a></dt>
715674 <dd class="defbody">
716675 <var>Delete</var> all elements in <var>Delete</var> from <var>Set</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="intlibs.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="dialect.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:loadfilehook"><a id="sec:B.8"><span class="sec-nr">B.8</span> <span class="sec-title">Hooks
194 <h2 id="sec:loadfilehook"><a name="sec:B.8"><span class="sec-nr">B.8</span> <span class="sec-title">Hooks
236195 for loading files</span></a></h2>
237196
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>.
197 <a name="sec:loadfilehook"></a>
198
199 <p>All loading of source files is achieved by <a name="idx:loadfiles2:2239"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>.
241200 The hook
242 <a id="idx:prologloadfile2:2241"></a><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a>
201 <a name="idx:prologloadfile2:2240"></a><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a>
243202 can be used to load Prolog code from non-files or even load entirely
244203 different information, such as foreign files.
245204
246205 <dl class="latex">
247 <dt class="pubdef"><a id="prolog_load_file/2"><strong>prolog_load_file</strong>(<var>+Spec,
206 <dt class="pubdef"><a name="prolog_load_file/2"><strong>prolog_load_file</strong>(<var>+Spec,
248207 +Options</var>)</a></dt>
249208 <dd class="defbody">
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>
209 Load a single object. If this call succeeds, <a name="idx:loadfiles2:2241"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a>
251210 assumes the action has been taken care of. This hook is only called if <var>Options</var>
252211 does not contain the <code>stream(Input)</code> option. The hook must be
253212 defined in the module <code>user</code>.
257216 server. It can also be used to load source in unusual forms, such as
258217 loading compressed files without decompressing them first. There is
259218 currently no example of that.</dd>
260 <dt class="pubdef"><a id="prolog:comment_hook/3"><strong>prolog:comment_hook</strong>(<var>+Comments,
219 <dt class="pubdef"><a name="prolog:comment_hook/3"><strong>prolog:comment_hook</strong>(<var>+Comments,
261220 +Pos, +Term</var>)</a></dt>
262221 <dd class="defbody">
263222 This hook allows for processing comments encountered by the compiler. If
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>
223 this hook is defined, the compiler calls <a name="idx:readterm2:2242"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
265224 with the option
266225 <code>comments(Comments)</code>. If the list of comments returned by
267 <a id="idx:readterm2:2244"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
226 <a name="idx:readterm2:2243"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
268227 is not empty it calls this comment hook with the following arguments.
269228
270229 <p>
271230 <ul class="latex">
272231 <li><var>Comments</var> is the non-empty list of comments. Each comment
273232 is a pair <var>Position</var>-<var>String</var>, where
274 <var>String</var> is a string object (see <a class="sec" href="strings.html#sec:5.2">section
233 <var>String</var> is a string object (see <a class="sec" href="strings.html">section
275234 5.2</a>) that contains the comment <em>including</em> delimiters.
276235 Consecutive line comments are returned as a single comment.
277236 <li><var>Pos</var> is a stream-position term that describes the starting
280239 </ul>
281240
282241 <p>This hook is exploited by the documentation system. See
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>.
242 <a name="idx:streampositiondata3:2244"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>.
243 See also <a name="idx:readterm3:2245"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
285244 </dd>
286245 </dl>
287246
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.23</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="manipatom.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="chartype.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:locale"><a id="sec:4.23"><span class="sec-nr">4.23</span> <span class="sec-title">Localization
194 <h2 id="sec:locale"><a name="sec:4.23"><span class="sec-nr">4.23</span> <span class="sec-title">Localization
236195 (locale) support</span></a></h2>
237196
238 <a id="sec:locale"></a>
197 <a name="sec:locale"></a>
239198
240199 <p>SWI-Prolog provides (currently limited) support for localized
241200 applications.
242201
243202 <p>
244203 <ul class="latex">
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>
204 <li>The predicates <a name="idx:chartype2:1282"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
205 and <a name="idx:codetype2:1283"></a><a class="pred" href="chartype.html#code_type/2">code_type/2</a>
247206 query character classes depending on the locale.
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>
207 <li>The predicates <a name="idx:collationkey2:1284"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
208 and <a name="idx:localesort2:1285"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>
250209 can be used for locale dependent sorting of atoms.
251 <li>The predicate <a id="idx:formattime3:1284"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>
210 <li>The predicate <a name="idx:formattime3:1286"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>
252211 can be used to format time and date representations, where some of the
253212 specifiers are locale dependent.
254 <li>The predicate <a id="idx:format2:1285"></a><a class="pred" href="format.html#format/2">format/2</a>
213 <li>The predicate <a name="idx:format2:1287"></a><a class="pred" href="format.html#format/2">format/2</a>
255214 provides locale-specific formating of numbers. This functionality is
256215 based on a more fine-grained localization model that is the subject of
257216 this section.
258217 </ul>
259218
260219 <p>A locale is a (optionally named) read-only object that provides
261 information to locale specific functions.<sup class="fn">105<span class="fn-text">The
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>
220 information to locale specific functions.<sup class="fn">104<span class="fn-text">The
221 locale interface described in this section and its effect on <a name="idx:format2:1288"></a><a class="pred" href="format.html#format/2">format/2</a>
263222 and reading integers from digit groups was discussed on the SWI-Prolog
264223 mailinglist. Most input in this discussion is from Ulrich Neumerkel and
265224 Richard O'Keefe. The predicates in this section were designed by Jan
267226 named
268227 <code>default</code> from the system locale. This locale is used as the
269228 initial locale for the three standard streams as well as the
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>
229 <code>main</code> thread. Locale sensitive output predicates such as <a name="idx:format3:1289"></a><a class="pred" href="format.html#format/3">format/3</a>
271230 get their locale from the stream to which they deliver their output. New
272231 streams get their locale from the thread that created the stream.
273232 Threads get their locale from the thread that created them.
274233
275234 <dl class="latex">
276 <dt class="pubdef"><a id="locale_create/3"><strong>locale_create</strong>(<var>-Locale,
235 <dt class="pubdef"><a name="locale_create/3"><strong>locale_create</strong>(<var>-Locale,
277236 +Default, +Options</var>)</a></dt>
278237 <dd class="defbody">
279238 Create a new locale object. <var>Default</var> is either an existing
314273 [ decimal_point('.'), thousands_sep(','), grouping([repeat(3)]) ]
315274 </pre>
316275
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>
276 <p>Named locales exists until they are destroyed using <a name="idx:localedestroy1:1290"></a><a class="pred" href="locale.html#locale_destroy/1">locale_destroy/1</a>
318277 and they are no longer referenced. Unnamed locales are subject to (atom)
319278 garbage collection.</dd>
320 <dt class="pubdef"><a id="locale_destroy/1"><strong>locale_destroy</strong>(<var>+Locale</var>)</a></dt>
279 <dt class="pubdef"><a name="locale_destroy/1"><strong>locale_destroy</strong>(<var>+Locale</var>)</a></dt>
321280 <dd class="defbody">
322281 Destroy a locale. If the locale is named, this removes the name
323282 association from the locale, after which the locale is left to be
324283 reclaimed by garbage collection.</dd>
325 <dt class="pubdef"><a id="locale_property/2"><strong>locale_property</strong>(<var>?Locale,
284 <dt class="pubdef"><a name="locale_property/2"><strong>locale_property</strong>(<var>?Locale,
326285 ?Property</var>)</a></dt>
327286 <dd class="defbody">
328287 True when <var>Locale</var> has <var>Property</var>. Properties are the
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>
288 same as the <var>Options</var> described with <a name="idx:localecreate3:1291"></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>
331290 <dd class="defbody">
332291 Set the default locale for the current thread, as well as the locale for
333292 the standard streams (<code>user_input</code>, <code>user_output</code>,
334293 <code>user_error</code>, <code>current_output</code> and <code>current_input</code>.
335294 This locale is used for new streams, unless overruled using the
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>
295 <code>locale(Locale)</code> option of <a name="idx:open4:1292"></a><a class="pred" href="IO.html#open/4">open/4</a>
296 or <a name="idx:setstream2:1293"></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>
339298 <dd class="defbody">
340299 True when <var>Locale</var> is the locale of the calling thread.
341300 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.16</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="lists.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="nb_set.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:main"><a id="sec:A.16"><span class="sec-nr">A.16</span> <span class="sec-title">library(main):
194 <h2 id="sec:main"><a name="sec:A.16"><span class="sec-nr">A.16</span> <span class="sec-title">library(main):
236195 Provide entry point for scripts</span></a></h2>
237196
238 <p><a id="sec:main"></a>
197 <p><a name="sec:main"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">See also</dt>
270229 </pre>
271230
272231 <dl class="latex">
273 <dt class="pubdef"><a id="main/0"><strong>main</strong></a></dt>
232 <dt class="pubdef"><a name="main/0"><strong>main</strong></a></dt>
274233 <dd class="defbody">
275234 Call <span class="pred-ext">main/1</span> using the passed command-line
276235 arguments. Before calling
277236 <span class="pred-ext">main/1</span> this predicate installs a signal
278237 handler for <code>SIGINT</code> (Control-C) that terminates the process
279238 with status 1.</dd>
280 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="argv_options/3"><strong>argv_options</strong>(<var>+Argv,
239 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="argv_options/3"><strong>argv_options</strong>(<var>+Argv,
281240 -RestArgv, -Options</var>)</a></dt>
282241 <dd class="defbody">
283242 Generic transformation of long commandline arguments to options. Each
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.22</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="manipterm.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="locale.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:manipatom"><a id="sec:4.22"><span class="sec-nr">4.22</span> <span class="sec-title">Analysing
194 <h2 id="sec:manipatom"><a name="sec:4.22"><span class="sec-nr">4.22</span> <span class="sec-title">Analysing
236195 and Constructing Atoms</span></a></h2>
237196
238 <a id="sec:manipatom"></a>
197 <a name="sec:manipatom"></a>
239198
240199 <p>These predicates convert between Prolog constants and lists of
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>
200 character codes. The predicates <a name="idx:atomcodes2:1242"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>, <a name="idx:numbercodes2:1243"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
201 and <a name="idx:name2:1244"></a><a class="pred" href="manipatom.html#name/2">name/2</a>
243202 behave the same when converting from a constant to a list of character
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>
203 codes. When converting the other way around, <a name="idx:atomcodes2:1245"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
204 will generate an atom, <a name="idx:numbercodes2:1246"></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:1247"></a><a class="pred" href="manipatom.html#name/2">name/2</a>
247206 will return a number if possible and an atom otherwise.
248207
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>
208 <p>The ISO standard defines <a name="idx:atomchars2:1248"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
250209 to describe the `broken-up' atom as a list of one-character atoms
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>
210 instead of a list of codes. Up to version 3.2.x, SWI-Prolog's <a name="idx:atomchars2:1249"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
252211 behaved like atom_codes, compatible with Quintus and SICStus Prolog. As
253212 of 3.3.x, SWI-Prolog
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>
213 <a name="idx:atomcodes2:1250"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
214 and <a name="idx:atomchars2:1251"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
256215 are compliant to the ISO standard.
257216
258217 <p>To ease the pain of all variations in the Prolog community, all
261220 `atom-side' accepts all atomic types (atom, number and string).
262221
263222 <dl class="latex">
264 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom_codes/2"><strong>atom_codes</strong>(<var>?Atom,
223 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom_codes/2"><strong>atom_codes</strong>(<var>?Atom,
265224 ?String</var>)</a></dt>
266225 <dd class="defbody">
267226 Convert between an atom and a list of character codes. If
269228 character codes and the result is unified with <var>String</var>. If <var>Atom</var>
270229 is unbound and <var>String</var> is a list of character codes,
271230 <var>Atom</var> will be unified with an atom constructed from this list.</dd>
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom_chars/2"><strong>atom_chars</strong>(<var>?Atom,
231 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom_chars/2"><strong>atom_chars</strong>(<var>?Atom,
273232 ?CharList</var>)</a></dt>
274233 <dd class="defbody">
275 As <a id="idx:atomcodes2:1250"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>,
234 As <a name="idx:atomcodes2:1252"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>,
276235 but <var>CharList</var> is a list of one-character atoms rather than a
277 list of character codes.<sup class="fn">100<span class="fn-text">Up to
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>.
236 list of character codes.<sup class="fn">99<span class="fn-text">Up to
237 version 3.2.x, <a name="idx:atomchars2:1253"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>
238 behaved as the current <a name="idx:atomcodes2:1254"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>.
280239 The current definition is compliant with the ISO standard.</span></sup>
281240
282241 <pre class="code">
286245 </pre>
287246
288247 </dd>
289 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="char_code/2"><strong>char_code</strong>(<var>?Atom,
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="char_code/2"><strong>char_code</strong>(<var>?Atom,
290249 ?Code</var>)</a></dt>
291250 <dd class="defbody">
292 Convert between character and character code for a single character.<sup class="fn">101<span class="fn-text">This
251 Convert between character and character code for a single character.<sup class="fn">100<span class="fn-text">This
293252 is also called atom_char/2 in older versions of SWI-Prolog as well as
294253 some other Prolog implementations. The atom_char/2 predicate is
295254 available from the library <code>backcomp.pl</code></span></sup></dd>
296 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="number_chars/2"><strong>number_chars</strong>(<var>?Number,
255 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="number_chars/2"><strong>number_chars</strong>(<var>?Number,
297256 ?CharList</var>)</a></dt>
298257 <dd class="defbody">
299 Similar to <a id="idx:atomchars2:1253"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>,
258 Similar to <a name="idx:atomchars2:1255"></a><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a>,
300259 but converts between a number and its representation as a list of
301260 one-character atoms. If <var>CharList</var> is a
302261 <em>proper list</em>, i.e., not unbound or a <em>partial list</em>,
309268 <p>If <var>CharList</var> is parsed, it is parsed using the Prolog
310269 syntax for numbers. Following the ISO standard, it allows for <em>leading</em>
311270 white space (including newlines) and does not allow for <em>trailing</em>
312 white space.<sup class="fn">102<span class="fn-text">ISO also allows for
271 white space.<sup class="fn">101<span class="fn-text">ISO also allows for
313272 Prolog comments in leading white space. We--and most other
314273 implementations--believe this is incorrect. We also beleive it would
315274 have been better not to allow for white space, or to allow for both
316275 leading and trailing white space. Prolog syntax-based conversion can
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>
276 also be achieved using <a name="idx:format3:1256"></a><a class="pred" href="format.html#format/3">format/3</a>
277 and <a name="idx:readfromchars2:1257"></a><a class="pred" href="charsio.html#read_from_chars/2">read_from_chars/2</a>.</span></sup>
319278 A <code>syntax_error</code> exception is raised if <var>CharList</var>
320279 does not represent a valid Prolog number.</dd>
321 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="number_codes/2"><strong>number_codes</strong>(<var>?Number,
280 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="number_codes/2"><strong>number_codes</strong>(<var>?Number,
322281 ?CodeList</var>)</a></dt>
323282 <dd class="defbody">
324 As <a id="idx:numberchars2:1256"></a><a class="pred" href="manipatom.html#number_chars/2">number_chars/2</a>,
283 As <a name="idx:numberchars2:1258"></a><a class="pred" href="manipatom.html#number_chars/2">number_chars/2</a>,
325284 but converts to a list of character codes rather than one-character
326285 atoms. In the mode (-,+), both predicates behave identically to improve
327286 handling of non-ISO source.</dd>
328 <dt class="pubdef"><a id="atom_number/2"><strong>atom_number</strong>(<var>?Atom,
287 <dt class="pubdef"><a name="atom_number/2"><strong>atom_number</strong>(<var>?Atom,
329288 ?Number</var>)</a></dt>
330289 <dd class="defbody">
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>
290 Realises the popular combination of <a name="idx:atomcodes2:1259"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>
291 and <a name="idx:numbercodes2:1260"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
333292 to convert between atom and number (integer or float) in one predicate,
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>
293 avoiding the intermediate list. Unlike the ISO <a name="idx:numbercodes2:1261"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
294 predicates, <a name="idx:atomnumber2:1262"></a><a class="pred" href="manipatom.html#atom_number/2">atom_number/2</a>
336295 fails silently in mode (+,-) if <var>Atom</var> does not represent a
337 number.<sup class="fn">103<span class="fn-text">Versions prior to 6.1.7
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>
296 number.<sup class="fn">102<span class="fn-text">Versions prior to 6.1.7
297 raised a syntax error, compliant to <a name="idx:numbercodes2:1263"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a></span></sup>
298 See also <a name="idx:atomiclistconcat2:1264"></a><a class="pred" href="manipatom.html#atomic_list_concat/2">atomic_list_concat/2</a>
340299 for assembling an atom from atoms and numbers.</dd>
341 <dt class="pubdef"><a id="name/2"><strong>name</strong>(<var>?Atomic,
300 <dt class="pubdef"><a name="name/2"><strong>name</strong>(<var>?Atomic,
342301 ?CodeList</var>)</a></dt>
343302 <dd class="defbody">
344303 <var>CodeList</var> is a list of character codes representing the same
358317 considered <em>deprecated</em> although, given its long tradition, it is
359318 unlikely to be removed from the system. It still has some value for
360319 converting input to, depending on the syntax, a number or atom. New code
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,
320 should consider the ISO predicates <a name="idx:atomcodes2:1265"></a><a class="pred" href="manipatom.html#atom_codes/2">atom_codes/2</a>, <a name="idx:numbercodes2:1266"></a><a class="pred" href="manipatom.html#number_codes/2">number_codes/2</a>
321 or the SWI-Prolog predicate <a name="idx:atomnumber2:1267"></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,
364323 ?Atom</var>)</a></dt>
365324 <dd class="defbody">
366325 True if <var>Atom</var> describes a term that unifies with <var>Term</var>.
369328 result unified with <var>Term</var>. If <var>Atom</var> has no valid
370329 syntax, a
371330 <code>syntax_error</code> exception is raised. Otherwise <var>Term</var>
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>
331 is ``written'' on <var>Atom</var> using <a name="idx:writeterm2:1268"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
373332 with the option
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>
333 <code>quoted(true)</code>. See also <a name="idx:format3:1269"></a><a class="pred" href="format.html#format/3">format/3</a>, <a name="idx:withoutputto2:1270"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
375334 and
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,
335 <a name="idx:termstring2:1271"></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,
378337 -Term, -Bindings</var>)</a></dt>
379338 <dd class="defbody">
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>
339 Use <var>Atom</var> as input to <a name="idx:readterm2:1272"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
381340 using the option
382341 <code>variable_names</code> and return the read term in <var>Term</var>
383342 and the variable bindings in <var>Bindings</var>. <var>Bindings</var> is
384343 a list of
385344 <var><var>Name</var> = <var>Var</var></var> couples, thus providing
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>.
345 access to the actual variable names. See also <a name="idx:readterm2:1273"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.
387346 If <var>Atom</var> has no valid syntax, a <code>syntax_error</code>
388347 exception is raised. New code should use
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,
348 <a name="idx:readtermfromatom3:1274"></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,
391350 ?Atom2, ?Atom3</var>)</a></dt>
392351 <dd class="defbody">
393352 <var>Atom3</var> forms the concatenation of <var>Atom1</var> and <var>Atom2</var>.
394353 At least two of the arguments must be instantiated to atoms. This
395354 predicate also allows for the mode (-,-,+), non-deterministically
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>
355 splitting the 3rd argument into two parts (as <a name="idx:append3:1275"></a><a class="pred" href="lists.html#append/3">append/3</a>
397356 does for lists). SWI-Prolog allows for atomic arguments. Portable code
398 must use <a id="idx:atomicconcat3:1274"></a><a class="pred" href="manipatom.html#atomic_concat/3">atomic_concat/3</a>
357 must use <a name="idx:atomicconcat3:1276"></a><a class="pred" href="manipatom.html#atomic_concat/3">atomic_concat/3</a>
399358 if non-atom arguments are involved.</dd>
400 <dt class="pubdef"><a id="atomic_concat/3"><strong>atomic_concat</strong>(<var>+Atomic1,
359 <dt class="pubdef"><a name="atomic_concat/3"><strong>atomic_concat</strong>(<var>+Atomic1,
401360 +Atomic2, -Atom</var>)</a></dt>
402361 <dd class="defbody">
403362 <var>Atom</var> represents the text after converting <var>Atomic1</var>
410369 </pre>
411370
412371 </dd>
413 <dt class="pubdef"><span class="pred-tag">[commons]</span><a id="atomic_list_concat/2"><strong>atomic_list_concat</strong>(<var>+List,
372 <dt class="pubdef"><span class="pred-tag">[commons]</span><a name="atomic_list_concat/2"><strong>atomic_list_concat</strong>(<var>+List,
414373 -Atom</var>)</a></dt>
415374 <dd class="defbody">
416375 <var>List</var> is a list of strings, atoms, integers or floating point
417376 numbers. Succeeds if <var>Atom</var> can be unified with the
418377 concatenated elements of <var>List</var>. Equivalent to <code>atomic_list_concat(List,
419378 '', Atom)</code>.</dd>
420 <dt class="pubdef"><span class="pred-tag">[commons]</span><a id="atomic_list_concat/3"><strong>atomic_list_concat</strong>(<var>+List,
379 <dt class="pubdef"><span class="pred-tag">[commons]</span><a name="atomic_list_concat/3"><strong>atomic_list_concat</strong>(<var>+List,
421380 +Separator, -Atom</var>)</a></dt>
422381 <dd class="defbody">
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>,
382 Creates an atom just like <a name="idx:atomiclistconcat2:1277"></a><a class="pred" href="manipatom.html#atomic_list_concat/2">atomic_list_concat/2</a>,
424383 but inserts <var>Separator</var> between each pair of inputs. For
425384 example:
426385
433392 <p>The SWI-Prolog version of this predicate can also be used to split
434393 atoms by instantiating <var>Separator</var> and <var>Atom</var> as shown
435394 below. We kept this functionality to simplify porting old SWI-Prolog
436 code where this predicate was called <a id="idx:concatatom3:1276"></a><span class="pred-ext">concat_atom/3</span>.
395 code where this predicate was called <a name="idx:concatatom3:1278"></a><span class="pred-ext">concat_atom/3</span>.
437396 When used in mode (-,+,+),
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>.
397 <var>Separator</var> must be a non-empty atom. See also <a name="idx:splitstring4:1279"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>.
439398
440399 <pre class="code">
441400 ?- atomic_list_concat(L, -, 'gnu-gnat').
444403 </pre>
445404
446405 </dd>
447 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom_length/2"><strong>atom_length</strong>(<var>+Atom,
406 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom_length/2"><strong>atom_length</strong>(<var>+Atom,
448407 -Length</var>)</a></dt>
449408 <dd class="defbody">
450409 True if <var>Atom</var> is an atom of <var>Length</var> characters. The
451410 SWI-Prolog version accepts all atomic types, as well as code-lists and
452411 character-lists. New code should avoid this feature and use
453 <a id="idx:writelength3:1278"></a><a class="pred" href="termrw.html#write_length/3">write_length/3</a>
412 <a name="idx:writelength3:1280"></a><a class="pred" href="termrw.html#write_length/3">write_length/3</a>
454413 to get the number of characters that would be written if the argument
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,
414 was handed to <a name="idx:writeterm3:1281"></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,
457416 +Prefix</var>)</a></dt>
458417 <dd class="defbody">
459418 True if <var>Atom</var> starts with the characters from <var>Prefix</var>.
460419 Its behaviour is equivalent to
461420 <code>?- sub_atom(<var>Atom</var>, 0, _, _, <var>Prefix</var>)</code>.
462421 Deprecated.</dd>
463 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="sub_atom/5"><strong>sub_atom</strong>(<var>+Atom,
422 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="sub_atom/5"><strong>sub_atom</strong>(<var>+Atom,
464423 ?Before, ?Len, ?After, ?Sub</var>)</a></dt>
465424 <dd class="defbody">
466425 ISO predicate for breaking atoms. It maintains the following relation:
478437 <p>The implementation minimises non-determinism and creation of atoms.
479438 This is a flexible predicate that can do search, prefix- and
480439 suffix-matching, etc.</dd>
481 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="sub_atom_icasechk/3"><strong>sub_atom_icasechk</strong>(<var>+Haystack,
440 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="sub_atom_icasechk/3"><strong>sub_atom_icasechk</strong>(<var>+Haystack,
482441 ?Start, +Needle</var>)</a></dt>
483442 <dd class="defbody">
484443 True when <var>Needle</var> is a sub atom of <var>Haystack</var>
487446 letters in <var>Needle</var> only match themselves, while lowercase
488447 letters in <var>Needle</var> match case insensitively. <var>Start</var>
489448 is the first 0-based offset inside <var>Haystack</var> where <var>Needle</var>
490 matches.<sup class="fn">104<span class="fn-text">This predicate replaces $apropos_match/2,
449 matches.<sup class="fn">103<span class="fn-text">This predicate replaces $apropos_match/2,
491450 used by the help system, while extending it with locating the (first)
492451 match and performing case insensitive prefix matching. We are still not
493452 happy with the name and interface.</span></sup>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ctxmodule.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="modulecompat.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:manipmodule"><a id="sec:6.14"><span class="sec-nr">6.14</span> <span class="sec-title">Module
194 <h2 id="sec:manipmodule"><a name="sec:6.14"><span class="sec-nr">6.14</span> <span class="sec-title">Module
236195 properties</span></a></h2>
237196
238 <a id="sec:manipmodule"></a>
197 <a name="sec:manipmodule"></a>
239198
240199 <p>The following predicates can be used to query the module system for
241200 reflexive programming:
242201
243202 <dl class="latex">
244 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_module/1"><strong>current_module</strong>(<var>?Module</var>)</a></dt>
203 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_module/1"><strong>current_module</strong>(<var>?Module</var>)</a></dt>
245204 <dd class="defbody">
246205 True if <var>Module</var> is a currently defined module. This predicate
247206 enumerates all modules, whether loaded from a file or created
248207 dynamically. Note that modules cannot be destroyed in the current
249208 version of SWI-Prolog.</dd>
250 <dt class="pubdef"><a id="module_property/2"><strong>module_property</strong>(<var>?Module,
209 <dt class="pubdef"><a name="module_property/2"><strong>module_property</strong>(<var>?Module,
251210 ?Property</var>)</a></dt>
252211 <dd class="defbody">
253212 True if <var>Property</var> is a property of <var>Module</var>. Defined
301260 indicators are in canonical form (i.e., always using name/arity and
302261 never the DCG form name//arity). Future versions may also use the DCG
303262 form and include public operators. See also
304 <a id="idx:predicateproperty2:1750"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
263 <a name="idx:predicateproperty2:1749"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
305264 </dd>
306265 <dt><strong>exported_operators</strong>(<var>-ListOfOperators</var>)</dt>
307266 <dd class="defbody">
317276 <dt><strong>program_space</strong>(<var>-Bytes</var>)</dt>
318277 <dd class="defbody">
319278 If present, this number limits the <code>program_size</code>. See
320 <a id="idx:setmodule1:1751"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>.
279 <a name="idx:setmodule1:1750"></a><a class="pred" href="manipmodule.html#set_module/1">set_module/1</a>.
321280 </dd>
322281 <dt><strong>last_modified_generation</strong>(<var>-Generation</var>)</dt>
323282 <dd class="defbody">
324283 Integer expression the last database generation where a clause was added
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>.
284 or removed from a predicate that is implemented in this module. See also <a name="idx:predicateproperty2:1751"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>.
326285 </dd>
327286 </dl>
328287
329288 </dd>
330 <dt class="pubdef"><a id="set_module/1"><strong>set_module</strong>(<var>:Property</var>)</a></dt>
289 <dt class="pubdef"><a name="set_module/1"><strong>set_module</strong>(<var>:Property</var>)</a></dt>
331290 <dd class="defbody">
332291 Modify properties of the module. Currently, the following properties may
333292 be modified:
338297 Set the default import module of the current module to <var>Module</var>.
339298 Typically, <var>Module</var> is one of <code>user</code> or <code>system</code>.
340299 See
341 <a class="sec" href="importmodule.html#sec:6.9">section 6.9</a>.
300 <a class="sec" href="importmodule.html">section 6.9</a>.
342301 </dd>
343302 <dt><strong>class</strong>(<var>+Class</var>)</dt>
344303 <dd class="defbody">
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>.
304 Set the class of the module. See <a name="idx:moduleproperty2:1752"></a><a class="pred" href="manipmodule.html#module_property/2">module_property/2</a>.
346305 </dd>
347306 <dt><strong>program_space</strong>(<var>+Bytes</var>)</dt>
348307 <dd class="defbody">
350309 module. Raises a permission error if the current usage is above the
351310 requested limit. Setting the limit to 0 (zero) removes the limit. An
352311 attempt to assert clauses that causes the limit to be exceeded causes 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>
312 <code>resource_error(program_space)</code> exception. See <a name="idx:assertz1:1753"></a><a class="pred" href="db.html#assertz/1">assertz/1</a>
354313 and
355 <a id="idx:moduleproperty2:1755"></a><a class="pred" href="manipmodule.html#module_property/2">module_property/2</a>.
314 <a name="idx:moduleproperty2:1754"></a><a class="pred" href="manipmodule.html#module_property/2">module_property/2</a>.
356315 </dd>
357316 </dl>
358317
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="hack.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ancestral-cut.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:manipstack"><a id="sec:B.1"><span class="sec-nr">B.1</span> <span class="sec-title">Examining
194 <h2 id="sec:manipstack"><a name="sec:B.1"><span class="sec-nr">B.1</span> <span class="sec-title">Examining
236195 the Environment Stack</span></a></h2>
237196
238 <a id="sec:manipstack"></a>
197 <a name="sec:manipstack"></a>
239198
240199 <dl class="latex">
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>
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>
242201 <dd class="defbody">
243202 Unify <var>Frame</var> with an integer providing a reference to the
244203 parent of the current local stack frame. A pointer to the current local
245204 frame cannot be provided as the predicate succeeds deterministically and
246205 therefore its frame is destroyed immediately after succeeding.</dd>
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>
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>
248207 <dd class="defbody">
249208 Unify <var>Choice</var> with an integer provided a reference to the last
250209 choice point. Fails if the current environment has no choice points. See
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,
210 also <a name="idx:prologchoiceattribute3:2180"></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,
253212 +Key, :Value</var>)</a></dt>
254213 <dd class="defbody">
255214 Obtain information about the local stack frame <var>Frame</var>. <var>Frame</var>
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>
215 is a frame reference as obtained through <a name="idx:prologcurrentframe1:2181"></a><a class="pred" href="manipstack.html#prolog_current_frame/1">prolog_current_frame/1</a>,
216 <a name="idx:prologtraceinterception4:2182"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
258217 or this predicate. The key values are described below.
259218
260219 <dl class="latex">
274233 context, the goal is represented as <code>&lt;<var>module</var>&gt;:&lt;<var>goal</var>&gt;</code>.
275234 Do not instantiate variables in this goal unless you <b>know</b> what
276235 you are doing! Note that the returned term may contain references to the
277 frame and should be discarded before the frame terminates.<sup class="fn">186<span class="fn-text">The
236 frame and should be discarded before the frame terminates.<sup class="fn">185<span class="fn-text">The
278237 returned term is actually an illegal Prolog term that may hold
279238 references from the global to the local stack to preserve the variable
280239 names.</span></sup></dd>
296255 <dd class="defbody">
297256 <var>Value</var> is unified with a reference to the currently running
298257 clause. Fails if the current goal is associated with a foreign (C)
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>
258 defined predicate. See also <a name="idx:nthclause3:2183"></a><a class="pred" href="examineprog.html#nth_clause/3">nth_clause/3</a>
259 and <a name="idx:clauseproperty2:2184"></a><a class="pred" href="examineprog.html#clause_property/2">clause_property/2</a>.</dd>
301260 <dt><strong>level</strong></dt>
302261 <dd class="defbody">
303262 <var>Value</var> is unified with the recursion level of <var>Frame</var>.
341300 </dl>
342301
343302 </dd>
344 <dt class="pubdef"><a id="prolog_choice_attribute/3"><strong>prolog_choice_attribute</strong>(<var>+ChoicePoint,
303 <dt class="pubdef"><a name="prolog_choice_attribute/3"><strong>prolog_choice_attribute</strong>(<var>+ChoicePoint,
345304 +Key, -Value</var>)</a></dt>
346305 <dd class="defbody">
347306 Extract attributes of a choice point. <var>ChoicePoint</var> is a
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>
307 reference to a choice point as passed to <a name="idx:prologtraceinterception4:2185"></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:2186"></a><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a>. <var>Key</var>
350309 specifies the requested information:
351310
352311 <dl class="latex">
363322 Requests the type. Defined values are <code>clause</code> (the goal has
364323 alternative clauses), <code>foreign</code> (non-deterministic foreign
365324 predicate), <code>jump</code> (clause internal choice point), <code>top</code>
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>
325 (first dummy choice point), <code>catch</code> (<a name="idx:catch3:2187"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
367326 to allow for undo),
368327 <code>debug</code> (help the debugger), or <code>none</code> (has been
369328 deleted).
372331
373332 <p>This predicate is used for the graphical debugger to show the choice
374333 point stack.</dd>
375 <dt class="pubdef"><a id="deterministic/1"><strong>deterministic</strong>(<var>-Boolean</var>)</a></dt>
334 <dt class="pubdef"><a name="deterministic/1"><strong>deterministic</strong>(<var>-Boolean</var>)</a></dt>
376335 <dd class="defbody">
377336 Unifies its argument with <code>true</code> if no choice point exists
378337 that is more recent than the entry of the clause in which it appears.
379338 There are few realistic situations for using this predicate. It is used
380339 by the
381 <a id="idx:prolog0:2189"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
340 <a name="idx:prolog0:2188"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
382341 top level to check whether Prolog should prompt the user for
383342 alternatives. Similar results can be achieved in a more portable fashion
384 using <a id="idx:callcleanup2:2190"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
343 using <a name="idx:callcleanup2:2189"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
385344 </dd>
386345 </dl>
387346
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.21</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="termrw.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="manipatom.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:manipterm"><a id="sec:4.21"><span class="sec-nr">4.21</span> <span class="sec-title">Analysing
194 <h2 id="sec:manipterm"><a name="sec:4.21"><span class="sec-nr">4.21</span> <span class="sec-title">Analysing
236195 and Constructing Terms</span></a></h2>
237196
238 <a id="sec:manipterm"></a>
197 <a name="sec:manipterm"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="functor/3"><strong>functor</strong>(<var>?Term,
200 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="functor/3"><strong>functor</strong>(<var>?Term,
242201 ?Name, ?Arity</var>)</a></dt>
243202 <dd class="defbody">
244203 True when <var>Term</var> is a term with functor <var>Name</var>/<var>Arity</var>.
252211
253212 <p>SWI-Prolog also supports terms with arity 0, as in <code>a()</code>
254213 (see
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>
214 <a class="sec" href="extensions.html">section 5</a>. Such terms must be
215 processed using
216 <a name="idx:compoundnamearity3:1192"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>.
217 The predicate <a name="idx:functor3:1193"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
259218 and <a class="pred" href="manipterm.html#=../2">=../2</a> raise a <code>domain_error</code>
260219 when faced with these terms. Without this precaution, the inconsistency
261 demonstrated below could happen silently.<sup class="fn">96<span class="fn-text">Raising
220 demonstrated below could happen silently.<sup class="fn">95<span class="fn-text">Raising
262221 a domain error was suggested by Jeff Schultz.</span></sup>
263222
264223 <pre class="code">
269228 </pre>
270229
271230 </dd>
272 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="arg/3"><strong>arg</strong>(<var>?Arg,
231 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="arg/3"><strong>arg</strong>(<var>?Arg,
273232 +Term, ?Value</var>)</a></dt>
274233 <dd class="defbody">
275234 <var>Term</var> should be instantiated to a term, <var>Arg</var> to an
279238 be unbound. In this case <var>Value</var> will be unified with the
280239 successive arguments of the term. On successful unification, <var>Arg</var>
281240 is unified with the argument number. Backtracking yields alternative
282 solutions.<sup class="fn">97<span class="fn-text">The instantiation
241 solutions.<sup class="fn">96<span class="fn-text">The instantiation
283242 pattern (-, +, ?) is an extension to `standard' Prolog. Some systems
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>
243 provide genarg/3 that covers this pattern.</span></sup> The predicate <a name="idx:arg3:1194"></a><a class="pred" href="manipterm.html#arg/3">arg/3</a>
285244 fails silently if <var><var>Arg</var> = 0</var> or
286245 <var><var>Arg</var> &gt; <em>arity</em></var> and raises the exception
287246 <code>domain_error(not_less_than_zero, <var>Arg</var>)</code> if <var><var>Arg</var>
288247 &lt; 0</var>.</dd>
289 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="=../2"><var>?Term</var> <strong>=..</strong> <var>?List</var></a></dt>
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="=../2"><var>?Term</var> <strong>=..</strong> <var>?List</var></a></dt>
290249 <dd class="defbody">
291250 <var>List</var> is a list whose head is the functor of <var>Term</var>
292251 and the remaining arguments are the arguments of the term. Either side
303262
304263 <p>SWI-Prolog also supports terms with arity 0, as in <code>a()</code>
305264 (see
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>.
265 <a class="sec" href="extensions.html">section 5</a>. Such terms must be
266 processed using
267 <a name="idx:compoundnamearguments3:1195"></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:1196"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>.
310269
311270 <pre class="code">
312271 ?- a() =.. L.
314273 </pre>
315274
316275 </dd>
317 <dt class="pubdef"><a id="compound_name_arity/3"><strong>compound_name_arity</strong>(<var>?Compound,
276 <dt class="pubdef"><a name="compound_name_arity/3"><strong>compound_name_arity</strong>(<var>?Compound,
318277 ?Name, ?Arity</var>)</a></dt>
319278 <dd class="defbody">
320 Rationalized version of <a id="idx:functor3:1195"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
279 Rationalized version of <a name="idx:functor3:1197"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
321280 that only works for compound terms and can examine and create compound
322281 terms with zero arguments (e.g,
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,
282 <code>name()</code>. See also <a name="idx:compoundnamearguments3:1198"></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,
325284 ?Name, ?Arguments</var>)</a></dt>
326285 <dd class="defbody">
327286 Rationalized version of <a class="pred" href="manipterm.html#=../2">=../2</a>
328287 that can compose and decompose compound terms with zero arguments. See
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,
288 also <a name="idx:compoundnamearity3:1199"></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,
331290 +Start, -End</var>)</a></dt>
332291 <dd class="defbody">
333292 Unify the free variables in <var>Term</var> with a term <code>$VAR(N)</code>,
354313 End = 2.
355314 </pre>
356315
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,
316 <p>See also the <code>numbervars</code> option to <a name="idx:writeterm3:1200"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>
317 and <a name="idx:numbervars4:1201"></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,
360319 +Start, -End, +Options</var>)</a></dt>
361320 <dd class="defbody">
362 As <a id="idx:numbervars3:1200"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>,
321 As <a name="idx:numbervars3:1202"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>,
363322 providing the following options:
364323
365324 <dl class="latex">
369328 <dt><strong>attvar</strong>(<var>+Action</var>)</dt>
370329 <dd class="defbody">
371330 What to do if an attributed variable is encountered. Options are
372 <code>skip</code>, which causes <a id="idx:numbervars3:1201"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
331 <code>skip</code>, which causes <a name="idx:numbervars3:1203"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
373332 to ignore the attributed variable, <code>bind</code> which causes it to
374333 treat it as a normal variable and assign the next <code>'$VAR'</code>(N)
375334 term to it, or (default)
376 <code>error</code> which raises a <code>type_error</code> exception.<sup class="fn">98<span class="fn-text">This
335 <code>error</code> which raises a <code>type_error</code> exception.<sup class="fn">97<span class="fn-text">This
377336 behaviour was decided after a long discussion between David Reitter,
378337 Richard O'Keefe, Bart Demoen and Tom Schrijvers.</span></sup></dd>
379338 <dt><strong>singletons</strong>(<var>+Bool</var>)</dt>
380339 <dd class="defbody">
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>
340 If <code>true</code> (default <code>false</code>), <a name="idx:numbervars4:1204"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>
382341 does singleton detection. Singleton variables are unified with <code>'$VAR'('_')</code>,
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
342 causing them to be printed as <code>_</code> by <a name="idx:writeterm2:1205"></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:1206"></a><a class="pred" href="listing.html#portray_clause/2">portray_clause/2</a>
344 and <a name="idx:writecanonical2:1207"></a><a class="pred" href="termrw.html#write_canonical/2">write_canonical/2</a>.<sup class="fn">bug<span class="fn-text">Currently
386345 this option is ignored for cyclic terms.</span></sup>
387346 </dd>
388347 </dl>
389348
390349 </dd>
391 <dt class="pubdef"><a id="var_number/2"><strong>var_number</strong>(<var>@Term,
350 <dt class="pubdef"><a name="var_number/2"><strong>var_number</strong>(<var>@Term,
392351 -VarNumber</var>)</a></dt>
393352 <dd class="defbody">
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>
353 True if <var>Term</var> is numbered by <a name="idx:numbervars3:1208"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
395354 and <var>VarNumber</var> is the number given to this variable. This
396355 predicate avoids the need for unification with <code>'$VAR'(X)</code>
397356 and opens the path for replacing this valid Prolog term by an internal
398357 representation that has no textual equivalent.</dd>
399 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="term_variables/2"><strong>term_variables</strong>(<var>+Term,
358 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="term_variables/2"><strong>term_variables</strong>(<var>+Term,
400359 -List</var>)</a></dt>
401360 <dd class="defbody">
402361 Unify <var>List</var> with a list of variables, each sharing with a
403 unique variable of <var>Term</var>.<sup class="fn">99<span class="fn-text">This
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>
362 unique variable of <var>Term</var>.<sup class="fn">98<span class="fn-text">This
363 predicate used to be called free_variables/2 . The name <a name="idx:termvariables2:1209"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>
405364 is more widely used. The old predicate is still available from the
406365 library <code>library(backcomp)</code>.</span></sup> The variables in <var>List</var>
407366 are ordered in order of appearance traversing <var>Term</var>
408367 depth-first and left-to-right. See also
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>.
368 <a name="idx:termvariables3:1210"></a><a class="pred" href="manipterm.html#term_variables/3">term_variables/3</a>
369 and <a name="idx:nonground2:1211"></a><a class="pred" href="manipterm.html#nonground/2">nonground/2</a>.
411370 For example:
412371
413372 <pre class="code">
416375 </pre>
417376
418377 </dd>
419 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="nonground/2"><strong>nonground</strong>(<var>+Term,
378 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="nonground/2"><strong>nonground</strong>(<var>+Term,
420379 -Var</var>)</a></dt>
421380 <dd class="defbody">
422381 True when <var>Var</var> is a variable in <var>Term</var>. Fails if <var>Term</var>
423 is <em>ground</em> (see <a id="idx:ground1:1210"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>).
382 is <em>ground</em> (see <a name="idx:ground1:1212"></a><a class="pred" href="typetest.html#ground/1">ground/1</a>).
424383 This predicate is intended for coroutining to trigger a wakeup if <var>Term</var>
425 becomes ground, e.g., using <a id="idx:when2:1211"></a><a class="pred" href="coroutining.html#when/2">when/2</a>.
384 becomes ground, e.g., using <a name="idx:when2:1213"></a><a class="pred" href="coroutining.html#when/2">when/2</a>.
426385 The current implemention always returns the first variable in
427386 depth-first left-right search. Ideally it should return a random member
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>)
387 of the set of variables (see <a name="idx:termvariables2:1214"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>)
429388 to realise logarithmetic complexity for the ground trigger. Compatible
430389 with ECLiPSe and hProlog.</dd>
431 <dt class="pubdef"><a id="term_variables/3"><strong>term_variables</strong>(<var>+Term,
390 <dt class="pubdef"><a name="term_variables/3"><strong>term_variables</strong>(<var>+Term,
432391 -List, ?Tail</var>)</a></dt>
433392 <dd class="defbody">
434 Difference list version of <a id="idx:termvariables2:1213"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.
393 Difference list version of <a name="idx:termvariables2:1215"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.
435394 That is, <var>Tail</var> is the tail of the variable list <var>List</var>.</dd>
436 <dt class="pubdef"><a id="term_singletons/2"><strong>term_singletons</strong>(<var>+Term,
395 <dt class="pubdef"><a name="term_singletons/2"><strong>term_singletons</strong>(<var>+Term,
437396 -List</var>)</a></dt>
438397 <dd class="defbody">
439398 Unify <var>List</var> with a list of variables, each sharing with a
442401 is raised.</span></sup> Note that, if a variable appears in a shared
443402 subterm, it is <em>not</em> considered singleton. Thus,
444403 <var>A</var> is <em>not</em> a singleton in the example below. See also
445 the <code>singleton</code> option of <a id="idx:numbervars4:1214"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>.
404 the <code>singleton</code> option of <a name="idx:numbervars4:1216"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>.
446405
447406 <pre class="code">
448407
451410 </pre>
452411
453412 </dd>
454 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="copy_term/2"><strong>copy_term</strong>(<var>+In,
413 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="copy_term/2"><strong>copy_term</strong>(<var>+In,
455414 -Out</var>)</a></dt>
456415 <dd class="defbody">
457416 Create a version of <var>In</var> with renamed (fresh) variables and
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>
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:1217"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
460419 can deal with infinite trees (cyclic terms). As pure Prolog cannot
461420 distinguish a ground term from another ground term with exactly the same
462421 structure, ground sub-terms are <em>shared</em> between <var>In</var>
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>.
422 and <var>Out</var>. Sharing ground terms does affect <a name="idx:setarg3:1218"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>.
464423 SWI-Prolog provides
465 <a id="idx:duplicateterm2:1217"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>
424 <a name="idx:duplicateterm2:1219"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>
466425 to create a true copy of a term.
467426 </dd>
468427 </dl>
469428
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
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
471430 operations on terms</span></a></h3>
472431
473 <a id="sec:setarg"></a>
432 <a name="sec:setarg"></a>
474433
475434 <p>Prolog is not able to <em>modify</em> instantiated parts of a term.
476435 Lacking that capability makes the language much safer, but unfortunately
477436 there are problems that suffer severely in terms of time and/or memory
478437 usage. Always try hard to avoid the use of these primitives, but they
479 can be a good alternative to using dynamic predicates. See also <a class="sec" href="gvar.html#sec:4.33">section
438 can be a good alternative to using dynamic predicates. See also <a class="sec" href="gvar.html">section
480439 4.33</a>, discussing the use of global variables.
481440
482441 <dl class="latex">
483 <dt class="pubdef"><a id="setarg/3"><strong>setarg</strong>(<var>+Arg,
442 <dt class="pubdef"><a name="setarg/3"><strong>setarg</strong>(<var>+Arg,
484443 +Term, +Value</var>)</a></dt>
485444 <dd class="defbody">
486445 Extra-logical predicate. Assigns the <var>Arg</var>-th argument of the
487446 compound term <var>Term</var> with the given <var>Value</var>. The
488447 assignment is undone if backtracking brings the state back into 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>.
448 position before the <a name="idx:setarg3:1220"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
449 call. See also <a name="idx:nbsetarg3:1221"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
491450
492451 <p>This predicate may be used for destructive assignment to terms, using
493452 them as an extra-logical storage bin. Always try hard to avoid the use
494 of <a id="idx:setarg3:1220"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
453 of <a name="idx:setarg3:1222"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
495454 as it is not supported by many Prolog systems and one has to be very
496455 careful about unexpected copying as well as unexpected noncopying of
497456 terms. A good practice to improve somewhat on this situation is to make
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>
457 sure that terms whose arguments are subject to <a name="idx:setarg3:1223"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
499458 have one unused and unshared variable in addition to the used arguments.
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>,
459 This variable avoids unwanted sharing in, e.g., <a name="idx:copyterm2:1224"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>,
501460 and causes the term to be considered as non-ground. An alternative is to
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
461 use <a name="idx:putattr3:1225"></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
504463 7.1</a>).</dd>
505 <dt class="pubdef"><a id="nb_setarg/3"><strong>nb_setarg</strong>(<var>+Arg,
464 <dt class="pubdef"><a name="nb_setarg/3"><strong>nb_setarg</strong>(<var>+Arg,
506465 +Term, +Value</var>)</a></dt>
507466 <dd class="defbody">
508467 Assigns the <var>Arg</var>-th argument of the compound term <var>Term</var>
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>,
468 with the given <var>Value</var> as <a name="idx:setarg3:1226"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>,
510469 but on backtracking the assignment is <em>not</em> reversed. If <var>Value</var>
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>.
470 is not atomic, it is duplicated using <a name="idx:duplicateterm2:1227"></a><a class="pred" href="manipterm.html#duplicate_term/2">duplicate_term/2</a>.
512471 This predicate uses the same technique as
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>
472 <a name="idx:nbsetval2:1228"></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:1229"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>
515474 for details on non-backtrackable assignment of terms. This predicate is
516475 compatible with GNU-Prolog <code>setarg(A,T,V,false)</code>, removing
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>.
476 the type restriction on <var>Value</var>. See also <a name="idx:nblinkarg3:1230"></a><a class="pred" href="manipterm.html#nb_linkarg/3">nb_linkarg/3</a>.
518477 Below is an example for counting the number of solutions of a goal. Note
519478 that this implementation is thread-safe, reentrant and capable of
520479 handling exceptions. Realising these features with a traditional
521 implementation based on assert/retract or <a id="idx:flag3:1229"></a><a class="pred" href="db.html#flag/3">flag/3</a>
480 implementation based on assert/retract or <a name="idx:flag3:1231"></a><a class="pred" href="db.html#flag/3">flag/3</a>
522481 is much more complicated.
523482
524483 <pre class="code">
537496 </pre>
538497
539498 </dd>
540 <dt class="pubdef"><a id="nb_linkarg/3"><strong>nb_linkarg</strong>(<var>+Arg,
499 <dt class="pubdef"><a name="nb_linkarg/3"><strong>nb_linkarg</strong>(<var>+Arg,
541500 +Term, +Value</var>)</a></dt>
542501 <dd class="defbody">
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>
502 As <a name="idx:nbsetarg3:1232"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>,
503 but like <a name="idx:nblinkval2:1233"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
545504 it does <em>not</em> duplicate
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>
505 <var>Value</var>. Use with extreme care and consult the documentation of <a name="idx:nblinkval2:1234"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>
547506 before use.</dd>
548 <dt class="pubdef"><a id="duplicate_term/2"><strong>duplicate_term</strong>(<var>+In,
507 <dt class="pubdef"><a name="duplicate_term/2"><strong>duplicate_term</strong>(<var>+In,
549508 -Out</var>)</a></dt>
550509 <dd class="defbody">
551 Version of <a id="idx:copyterm2:1233"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
510 Version of <a name="idx:copyterm2:1235"></a><a class="pred" href="manipterm.html#copy_term/2">copy_term/2</a>
552511 that also copies ground terms and therefore ensures that destructive
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,
512 modification using <a name="idx:setarg3:1236"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
513 does not affect the copy. See also <a name="idx:nbsetval2:1237"></a><a class="pred" href="gvar.html#nb_setval/2">nb_setval/2</a>, <a name="idx:nblinkval2:1238"></a><a class="pred" href="gvar.html#nb_linkval/2">nb_linkval/2</a>, <a name="idx:nbsetarg3:1239"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>
514 and <a name="idx:nblinkarg3:1240"></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,
557516 @T2</var>)</a></dt>
558517 <dd class="defbody">
559518 True if <var>T1</var> and <var>T2</var> are equivalent and will remain
560 equivalent, even if <a id="idx:setarg3:1239"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
519 equivalent, even if <a name="idx:setarg3:1241"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
561520 is used on either of them. This means
562521 <var>T1</var> and <var>T2</var> are the same variable, equivalent atomic
563522 data or a compound term allocated at the same address.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.42</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="profile.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="DDE.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:memory"><a id="sec:4.42"><span class="sec-nr">4.42</span> <span class="sec-title">Memory
194 <h2 id="sec:memory"><a name="sec:4.42"><span class="sec-nr">4.42</span> <span class="sec-title">Memory
236195 Management</span></a></h2>
237196
238 <a id="sec:memory"></a>
197 <a name="sec:memory"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="garbage_collect/0"><strong>garbage_collect</strong></a></dt>
200 <dt class="pubdef"><a name="garbage_collect/0"><strong>garbage_collect</strong></a></dt>
242201 <dd class="defbody">
243202 Invoke the global and trail stack garbage collector. Normally the
244203 garbage collector is invoked automatically if necessary. Explicit
245204 invocation might be useful to reduce the need for garbage collections in
246205 time-critical segments of the code. After the garbage collection
247 <a id="idx:trimstacks0:1575"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>
206 <a name="idx:trimstacks0:1577"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>
248207 is invoked to release the collected memory resources.</dd>
249 <dt class="pubdef"><a id="garbage_collect_atoms/0"><strong>garbage_collect_atoms</strong></a></dt>
208 <dt class="pubdef"><a name="garbage_collect_atoms/0"><strong>garbage_collect_atoms</strong></a></dt>
250209 <dd class="defbody">
251210 Reclaim unused atoms. Normally invoked after <a class="flag" href="flags.html#flag:agc_margin">agc_margin</a>
252211 (a Prolog flag) atoms have been created. On multithreaded versions the
253212 actual collection is delayed until there are no threads performing
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>
213 normal garbage collection. In this case <a name="idx:garbagecollectatoms0:1578"></a><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a>
255214 returns immediately. Note that there is no guarantee it will <em>ever</em>
256215 happen, as there may always be threads performing garbage collection.</dd>
257 <dt class="pubdef"><a id="trim_stacks/0"><strong>trim_stacks</strong></a></dt>
216 <dt class="pubdef"><a name="garbage_collect_clauses/0"><strong>garbage_collect_clauses</strong></a></dt>
217 <dd class="defbody">
218 Reclaim retracted clauses. During normal operation, retracting a clause
219 implies setting the <em>erased generation</em> to the current
220 <em>generation</em> of the database and increment the generation.
221 Keeping the clause around is both needed to realise the <em>logical
222 update view</em> and deal with the fact that other threads may be
223 executing the clause. Both static and dynamic code is processed this
224 way.<sup class="fn">140<span class="fn-text">Up to version 7.3.11,
225 dynamic code was handled using <em>reference counts</em>.</span></sup>.
226
227 <p>The clause garbage collector (CGC) scans the environment stacks of
228 all threads for referenced dirty predicates and at which generation this
229 reference accesses the predicate. It then removes the references for
230 clauses that have been retracted before the oldest access generation
231 from the clause list as well as the secondary clauses indexes of the
232 predicate. If the clause list is not being scanned, the clause
233 references and ultimately the clause itself is reclaimed.
234
235 <p>The clause garbage collector is called under three conditions, (1)
236 after
237 <em>reloading</em> a source file, (2) if the memory occupied by
238 retracted but not yet reclaimed clauses exceeds 12.5% of the program
239 store, or (3) if skipping dead clauses in the clause lists becomes too
240 costly. The cost of clause garbage collection is proportional with the
241 total size of the local stack of all threads (the scanning phase) and
242 the number of clauses in all `dirty' predicates (the reclaiming phase).</dd>
243 <dt class="pubdef"><a name="set_prolog_gc_thread/+Status"><strong>set_prolog_gc_thread</strong>(<var>+Status</var>)</a></dt>
244 <dd class="defbody">
245 ontrol whether or not atom and clause garbage collection are executed in
246 a dedicated thread. The default is <code>true</code>. Values for
247 <var>Status</var> are <code>true</code>, <code>false</code> and <code>stop</code>.
248 The latter stops the <code>gc</code> thread but allows is to be
249 recreated lazily. This is use by e.g., <a name="idx:fork1:1579"></a><span class="pred-ext">fork/1</span>
250 to avoid forking a multi-threaded application. See also <a class="flag" href="flags.html#flag:gc_thread">gc_thread</a>.</dd>
251 <dt class="pubdef"><a name="trim_stacks/0"><strong>trim_stacks</strong></a></dt>
258252 <dd class="defbody">
259253 Release stack memory resources that are not in use at this moment,
260254 returning them to the operating system. It can be used to release memory
272266
273267 <p>The Prolog top-level loop is written this way, reclaiming memory
274268 resources after every user query.</dd>
275 <dt class="pubdef"><a id="set_prolog_stack/2"><strong>set_prolog_stack</strong>(<var>+Stack,
269 <dt class="pubdef"><a name="set_prolog_stack/2"><strong>set_prolog_stack</strong>(<var>+Stack,
276270 +KeyValue</var>)</a></dt>
277271 <dd class="defbody">
278272 Set a parameter for one of the Prolog runtime stacks. <var>Stack</var>
285279 ?- set_prolog_stack(global, limit(2*10**9)).
286280 </pre>
287281
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>.
282 <p>Current settings can be retrieved with <a name="idx:prologstackproperty2:1580"></a><a class="pred" href="memory.html#prolog_stack_property/2">prolog_stack_property/2</a>.
289283
290284 <dl class="latex">
291285 <dt><strong>limit</strong>(<var>+Bytes</var>)</dt>
302296 amount is reported and specified in `cells'. A cell is 4 bytes in the
303297 32-bit version and 8 bytes on the 64-bit version. See
304298 <a class="flag" href="flags.html#flag:address_bits">address_bits</a>.
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>
299 See also <a name="idx:trimstacks0:1581"></a><a class="pred" href="memory.html#trim_stacks/0">trim_stacks/0</a>
300 and <a name="idx:debug0:1582"></a><a class="pred" href="debugger.html#debug/0">debug/0</a>.</dd>
301 <dt><strong>low</strong>(<var>+Cells</var>)</dt>
302 <dt><strong>factor</strong>(<var>+Number</var>)</dt>
303 <dd class="defbody">
304 These two figures determine whether, if the stacks are low, a stack
305 <em>shift</em> (expansion) or garbage collection is performed. This
306 depends on these two parameters, the current stack usage and the amount
307 of stack used after the last garbage collection. A garbage collection is
308 started if <var>used &gt; factor &times; lastused + low</var>.</dd>
307309 <dt><strong>spare</strong>(<var>+Cells</var>)</dt>
308310 <dd class="defbody">
309311 All stacks trigger overflow before actually reaching the limit, so the
310312 resulting error can be handled gracefully. The spare stack is used for
311 <a id="idx:printmessage2:1580"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
313 <a name="idx:printmessage2:1583"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
312314 from the garbage collector and for handling exceptions. The default
313315 suffices, unless the user redefines related hooks. Do
314316 <b>not</b> specify large values for this because it reduces the amount
315317 of memory available for your real task.
316318
317 <p>Related hooks are <a id="idx:messagehook3:1581"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
319 <p>Related hooks are <a name="idx:messagehook3:1584"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a>
318320 (redefining GC messages),
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>.
321 <a name="idx:prologtraceinterception4:1585"></a><a class="pred" href="tracehook.html#prolog_trace_interception/4">prolog_trace_interception/4</a>
322 and <a name="idx:prologexceptionhook4:1586"></a><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a>.
321323 </dd>
322324 </dl>
323325
324326 </dd>
325 <dt class="pubdef"><a id="prolog_stack_property/2"><strong>prolog_stack_property</strong>(<var>?Stack,
327 <dt class="pubdef"><a name="prolog_stack_property/2"><strong>prolog_stack_property</strong>(<var>?Stack,
326328 ?KeyValue</var>)</a></dt>
327329 <dd class="defbody">
328330 True if <var>KeyValue</var> is a current property of <var>Stack</var>.
329331 See
330 <a id="idx:setprologstack2:1584"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>
332 <a name="idx:setprologstack2:1587"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>
331333 for defined properties.
332334 </dd>
333335 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.9</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="control.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="delcont.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:metacall"><a id="sec:4.9"><span class="sec-nr">4.9</span> <span class="sec-title">Meta-Call
194 <h2 id="sec:metacall"><a name="sec:4.9"><span class="sec-nr">4.9</span> <span class="sec-title">Meta-Call
236195 Predicates</span></a></h2>
237196
238 <a id="sec:metacall"></a>
197 <a name="sec:metacall"></a>
239198
240199 <p>Meta-call predicates are used to call terms constructed at run time.
241200 The basic meta-call mechanism offered by SWI-Prolog is to use variables
245204 normal calls this search is done at compile time.
246205
247206 <dl class="latex">
248 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="call/1"><strong>call</strong>(<var>:Goal</var>)</a></dt>
207 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="call/1"><strong>call</strong>(<var>:Goal</var>)</a></dt>
249208 <dd class="defbody">
250209 Invoke <var>Goal</var> as a goal. Note that clauses may have variables
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,
210 as subclauses, which is identical to <a name="idx:call1:651"></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,
253212 +ExtraArg1, ...</var>)</a></dt>
254213 <dd class="defbody">
255214 Append <var>ExtraArg1, ExtraArg2, ...</var> to the argument list of
258217 3.
259218
260219 <p>The call/[2..] construct is handled by the compiler. The predicates
261 <a id="idx:call28:650"></a><a class="pred" href="metacall.html#call/2">call/[2-8]</a>
220 <a name="idx:call28:652"></a><a class="pred" href="metacall.html#call/2">call/[2-8]</a>
262221 are defined as real (meta-)predicates and are available to inspection
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>,
264 etc.<sup class="fn">64<span class="fn-text">Arities 2..8 are demanded by
222 through <a name="idx:currentpredicate1:653"></a><a class="pred" href="examineprog.html#current_predicate/1">current_predicate/1</a>, <a name="idx:predicateproperty2:654"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>,
223 etc.<sup class="fn">63<span class="fn-text">Arities 2..8 are demanded by
265224 ISO/IEC 13211-1:1995/Cor.2:2012.</span></sup> Higher arities are handled
266225 by the compiler and runtime system, but the predicates are not
267 accessible for inspection.<sup class="fn">65<span class="fn-text">Future
226 accessible for inspection.<sup class="fn">64<span class="fn-text">Future
268227 versions of the reflective predicate may fake the presence of call/9.. .
269228 Full logical behaviour, generating all these pseudo predicates, is
270229 probably undesirable and will become impossible if <em>max_arity</em> is
271230 removed.</span></sup></dd>
272 <dt class="pubdef"><a id="apply/2"><strong>apply</strong>(<var>:Goal,
231 <dt class="pubdef"><a name="apply/2"><strong>apply</strong>(<var>:Goal,
273232 +List</var>)</a></dt>
274233 <dd class="defbody">
275234 Append the members of <var>List</var> to the arguments of <var>Goal</var>
278237 <code>plus(1, 2, X)</code>. New code should use call/[2..] if the length
279238 of
280239 <var>List</var> is fixed.</dd>
281 <dt class="pubdef"><a id="not/1"><strong>not</strong>(<var>:Goal</var>)</a></dt>
240 <dt class="pubdef"><a name="not/1"><strong>not</strong>(<var>:Goal</var>)</a></dt>
282241 <dd class="defbody">
283242 True if <var>Goal</var> cannot be proven. Retained for compatibility
284243 only. New code should use <a class="pred" href="control.html#\+/1">\+/1</a>.</dd>
285 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="once/1"><strong>once</strong>(<var>:Goal</var>)</a></dt>
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="once/1"><strong>once</strong>(<var>:Goal</var>)</a></dt>
286245 <dd class="defbody">
287246 Make a possibly <em>nondet</em> goal <em>semidet</em>, i.e., succeed at
288247 most once. Defined as:
292251 call(Goal), !.
293252 </pre>
294253
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>.
254 <p><a name="idx:once1:655"></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>.
297256 The only difference is how the cut behaves (see !/0). The following two
298257 clauses below are identical. Be careful about the interaction with
299258 <a class="pred" href="control.html#;/2">;/2</a>. The <code>library(apply_macros)</code>
300 library defines an inline expansion of <a id="idx:once1:654"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
259 library defines an inline expansion of <a name="idx:once1:656"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
301260 mapping it to <code>(Goal\send{true};fail)</code>. Using the full
302261 if-then-else constructs prevents its semantics from being changed when
303262 embedded in a <a class="pred" href="control.html#;/2">;/2</a>
309268 </pre>
310269
311270 </dd>
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>,
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:657"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
315274 but succeeds, regardless of whether
316275 <var>Goal</var> succeeded or not. Defined as:
317276
322281 </pre>
323282
324283 </dd>
325 <dt class="pubdef"><a id="call_with_depth_limit/3"><strong>call_with_depth_limit</strong>(<var>:Goal,
284 <dt class="pubdef"><a name="call_with_depth_limit/3"><strong>call_with_depth_limit</strong>(<var>:Goal,
326285 +Limit, -Result</var>)</a></dt>
327286 <dd class="defbody">
328287 If <var>Goal</var> can be proven without recursion deeper than <var>Limit</var>
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>
288 levels, <a name="idx:callwithdepthlimit3:658"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
330289 succeeds, binding <var>Result</var> to the deepest recursion level used
331290 during the proof. Otherwise, <var>Result</var> is unified with <code>depth_limit_exceeded</code>
332291 if the limit was exceeded during the proof, or the entire predicate
334293
335294 <p>The depth limit is guarded by the internal machinery. This may differ
336295 from the depth computed based on a theoretical model. For example,
337 <a id="idx:true0:657"></a><a class="pred" href="control.html#true/0">true/0</a>
296 <a name="idx:true0:659"></a><a class="pred" href="control.html#true/0">true/0</a>
338297 is translated into an inline virtual machine instruction. Also,
339 <a id="idx:repeat0:658"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>
298 <a name="idx:repeat0:660"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>
340299 is not implemented as below, but as a non-deterministic foreign
341300 predicate.
342301
346305 repeat.
347306 </pre>
348307
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>
308 <p>As a result, <a name="idx:callwithdepthlimit3:661"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
350309 may still loop infinitely on programs that should theoretically finish
351310 in finite time. This problem can be cured by using Prolog equivalents to
352311 such built-in predicates.
353312
354313 <p>This predicate may be used for theorem provers to realise techniques
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>.
314 like <em>iterative deepening</em>. See also <a name="idx:callwithinferencelimit3:662"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>.
356315 It was implemented after discussion with Steve Moyle
357316 <a class="url" href="mailto:smoyle@ermine.ox.ac.uk">smoyle@ermine.ox.ac.uk</a>.</dd>
358 <dt class="pubdef"><a id="call_with_inference_limit/3"><strong>call_with_inference_limit</strong>(<var>:Goal,
317 <dt class="pubdef"><a name="call_with_inference_limit/3"><strong>call_with_inference_limit</strong>(<var>:Goal,
359318 +Limit, -Result</var>)</a></dt>
360319 <dd class="defbody">
361320 Equivalent to <code>call(Goal)</code>, but limits the number of
362321 inferences
363 <em>for each solution of <var>Goal</var></em>.<sup class="fn">66<span class="fn-text">This
322 <em>for each solution of <var>Goal</var></em>.<sup class="fn">65<span class="fn-text">This
364323 predicate was realised after discussion with Ulrich Neumerkel and Markus
365324 Triska.</span></sup>. Execution may terminate as follows:
366325
372331 <var>Result</var> is unified with the atom
373332 <code>inference_limit_exceeded</code>.
374333 <i>Otherwise</i>,
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>
334 <li>If <var>Goal</var> fails, <a name="idx:callwithinferencelimit3:663"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>
376335 fails.
377336 <li>If <var>Goal</var> succeeds <em>without a choice point</em>,
378337 <var>Result</var> is unified with <code><code>!</code></code>.
379338 <li>If <var>Goal</var> succeeds <em>with a choice point</em>,
380339 <var>Result</var> is unified with <code>true</code>.
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>
340 <li>If <var>Goal</var> throws an exception, <a name="idx:callwithinferencelimit3:664"></a><a class="pred" href="metacall.html#call_with_inference_limit/3">call_with_inference_limit/3</a>
382341 re-throws the exception.
383342 </ul>
384343
387346 instructions for which inferences are not counted. The execution of
388347 predicates defined in other languages (e.g., C, C++) count as a single
389348 inference. This includes potentially expensive built-in predicates such
390 as <a id="idx:sort2:663"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>.
349 as <a name="idx:sort2:665"></a><a class="pred" href="builtinlist.html#sort/2">sort/2</a>.
391350
392351 <p>Calls to this predicate may be nested. An inner call that sets the
393352 limit below the current is honoured. An inner call that would terminate
394353 after the current limit does not change the effective limit. See also
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,
354 <a name="idx:callwithdepthlimit3:666"></a><a class="pred" href="metacall.html#call_with_depth_limit/3">call_with_depth_limit/3</a>
355 and <a name="idx:callwithtimelimit2:667"></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,
398357 :Goal, :Cleanup</var>)</a></dt>
399358 <dd class="defbody">
400359 Calls <code>(once(Setup), Goal)</code>. If <var>Setup</var> succeeds, <var>Cleanup</var>
401360 will be called exactly once after <var>Goal</var> is finished: either on
402361 failure, deterministic success, commit, or an exception. The execution
403362 of <var>Setup</var> is protected from asynchronous interrupts like
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>.
363 <a name="idx:callwithtimelimit2:668"></a><span class="pred-ext">call_with_time_limit/2</span>
364 (package clib) or <a name="idx:threadsignal2:669"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.
406365 In most uses,
407366 <var>Setup</var> will perform temporary side-effects required by <var>Goal</var>
408367 that are finally undone by <var>Cleanup</var>.
409368
410369 <p>Success or failure of <var>Cleanup</var> is ignored, and choice
411 points it created are destroyed (as <a id="idx:once1:668"></a><a class="pred" href="metacall.html#once/1">once/1</a>).
370 points it created are destroyed (as <a name="idx:once1:670"></a><a class="pred" href="metacall.html#once/1">once/1</a>).
412371 If <var>Cleanup</var> throws an exception, this is executed as normal
413372 while it was not triggered as the result of an exception the exception
414373 is propagated as normal. If <var>Cleanup</var> was triggered by an
415374 exception the rules are described in
416 <a class="sec" href="exception.html#sec:4.11.1">section 4.11.1</a>
375 <a class="sec" href="exception.html">section 4.11.1</a>
417376
418377 <p>Typically, this predicate is used to cleanup permanent data storage
419378 required to execute <var>Goal</var>, close file descriptors, etc. The
437396
438397 <p>Note that it is impossible to implement this predicate in Prolog. The
439398 closest approximation would be to read all terms into a list, close the
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>
399 file and call <a name="idx:member2:671"></a><a class="pred" href="lists.html#member/2">member/2</a>.
400 Without <a name="idx:setupcallcleanup3:672"></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:673"></a><a class="pred" href="control.html#repeat/0">repeat/0</a>
443402 is removed by a cut or an exception.
444403
445 <p><a id="idx:setupcallcleanup3:672"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
404 <p><a name="idx:setupcallcleanup3:674"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
446405 can also be used to test determinism of a goal, providing a portable
447 alternative to <a id="idx:deterministic1:673"></a><a class="pred" href="manipstack.html#deterministic/1">deterministic/1</a>:
406 alternative to <a name="idx:deterministic1:675"></a><a class="pred" href="manipstack.html#deterministic/1">deterministic/1</a>:
448407
449408 <pre class="code">
450409 ?- setup_call_cleanup(true,(X=1;X=2), Det=yes).
456415 </pre>
457416
458417 <p>This predicate is under consideration for inclusion into the ISO
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,
418 standard. For compatibility with other Prolog implementations see <a name="idx:callcleanup2:676"></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,
461420 :Goal, +Catcher, :Cleanup</var>)</a></dt>
462421 <dd class="defbody">
463422 Similar to <code>setup_call_cleanup(Setup, Goal, Cleanup)</code> with
499458 </dl>
500459
501460 </dd>
502 <dt class="pubdef"><a id="call_cleanup/2"><strong>call_cleanup</strong>(<var>:Goal,
461 <dt class="pubdef"><a name="call_cleanup/2"><strong>call_cleanup</strong>(<var>:Goal,
503462 :Cleanup</var>)</a></dt>
504463 <dd class="defbody">
505464 Same as <code>setup_call_cleanup(true, Goal, Cleanup)</code>. This is
506465 provided for compatibility with a number of other Prolog implementations
507 only. Do not use <a id="idx:callcleanup2:675"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>
466 only. Do not use <a name="idx:callcleanup2:677"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>
508467 if you perform side-effects prior to calling that will be undone by <var>Cleanup</var>.
509468 Instead, use
510 <a id="idx:setupcallcleanup3:676"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
469 <a name="idx:setupcallcleanup3:678"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
511470 with an appropriate first argument to perform those side-effects.</dd>
512 <dt class="pubdef"><a id="call_cleanup/3"><strong>call_cleanup</strong>(<var>:Goal,
471 <dt class="pubdef"><a name="call_cleanup/3"><strong>call_cleanup</strong>(<var>:Goal,
513472 +Catcher, :Cleanup</var>)</a></dt>
514473 <dd class="defbody">
515474 Same as <code>setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup)</code>.
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>
475 The same warning as for <a name="idx:callcleanup2:679"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>
517476 applies.
518477 </dd>
519478 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="import.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="overrule.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:metapred"><a id="sec:6.4"><span class="sec-nr">6.4</span> <span class="sec-title">Defining
194 <h2 id="sec:metapred"><a name="sec:6.4"><span class="sec-nr">6.4</span> <span class="sec-title">Defining
236195 a meta-predicate</span></a></h2>
237196
238 <a id="sec:metapred"></a>
197 <a name="sec:metapred"></a>
239198
240199 <p>A meta-predicate is a predicate that calls other predicates
241200 dynamically, modifies a predicate, or reasons about properties of a
242201 predicate. Such predicates use either a compound term or a <em>predicate
243202 indicator</em> to describe the predicate they address, e.g., <code>assert(name(jan))</code>
244 or <code>abolish(<a id="idx:name1:1689"></a><span class="pred-ext">name/1</span>)</code>.
203 or <code>abolish(<a name="idx:name1:1688"></a><span class="pred-ext">name/1</span>)</code>.
245204 With modules, this simple schema no longer works as each module defines
246205 its own mapping from name+arity to predicate. This is resolved by
247206 wrapping the original description in a term &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;,
248207 e.g., <code>assert(person:name(jan))</code> or
249208 <code>abolish(person:name/1)</code>.
250209
251 <p>Of course, when calling <a id="idx:assert1:1690"></a><a class="pred" href="db.html#assert/1">assert/1</a>
210 <p>Of course, when calling <a name="idx:assert1:1689"></a><a class="pred" href="db.html#assert/1">assert/1</a>
252211 from inside a module, we expect to assert to a predicate local to this
253212 module. In other words, we do not wish to provide this <code><code>:</code>/2</code>
254 wrapper by hand. The <a id="idx:metapredicate1:1691"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
213 wrapper by hand. The <a name="idx:metapredicate1:1690"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
255214 directive tells the compiler that certain arguments are terms that will
256215 be used to look up a predicate and thus need to be wrapped (qualified)
257216 with &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;, unless they are
258217 already wrapped.
259218
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>
219 <p>In the example below, we use this to define <a name="idx:maplist3:1691"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
261220 inside a module. The argument `2' in the meta_predicate declaration
262221 means that the argument is module-sensitive and refers to a predicate
263222 with an arity that is two more than the term that is passed in. The
266225 and <code><code>?</code></code>, which denote
267226 <em>modes</em>. The values 0..9 are used by the
268227 <em>cross-referencer</em> and syntax highlighting. Note that the helper
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>
228 predicate <a name="idx:maplist3:1692"></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:1693"></a><a class="pred" href="apply.html#maplist/3">maplist/3</a>
271230 wrapper already ensures that
272231 <var>Goal</var> is qualified as &lt;<var>module</var>&gt;:<var>Goal</var>.
273232 See the description of
274 <a id="idx:metapredicate1:1695"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
233 <a name="idx:metapredicate1:1694"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
275234 for details.
276235
277236 <pre class="code">
293252 </pre>
294253
295254 <dl class="latex">
296 <dt class="pubdef"><a id="meta_predicate/1"><strong>meta_predicate</strong> <var>+Head,
255 <dt class="pubdef"><a name="meta_predicate/1"><strong>meta_predicate</strong> <var>+Head,
297256 ...</var></a></dt>
298257 <dd class="defbody">
299258 Define the predicates referenced by the comma-separated list <var>Head</var>
328287 <dd class="defbody">
329288 The argument is not module-sensitive and the mode is unspecified. The
330289 specification <code><code>*</code></code> is equivalent to <code><code>?</code></code>.
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>
290 It is accepted for compatibility reasons. The predicate <a name="idx:predicateproperty2:1695"></a><a class="pred" href="examineprog.html#predicate_property/2">predicate_property/2</a>
332291 reports arguments declared using <code><code>*</code></code> with <code><code>?</code></code>.
333292 </dd>
334293 <dt><strong><code>+</code></strong></dt>
339298 <dd class="defbody">
340299 This extension is used to denote the possibly <code>^</code>-annotated
341300 goal of
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>.
301 <a name="idx:setof3:1696"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>, <a name="idx:bagof3:1697"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>, <a name="idx:aggregate3:1698"></a><a class="pred" href="aggregate.html#aggregate/3">aggregate/3</a>
302 and <a name="idx:aggregate4:1699"></a><a class="pred" href="aggregate.html#aggregate/4">aggregate/4</a>.
344303 It is processed similar to `0', but leaving the <code><code>^</code></code>/2
345304 intact.
346305 </dd>
347306 <dt><strong><code>//</code></strong></dt>
348307 <dd class="defbody">
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>.
308 The argument is a DCG body. See <a name="idx:phrase3:1700"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>.
350309 </dd>
351310 </dl>
352311
383342 Module=42, Term = test
384343 </pre>
385344
386 <p>The <a id="idx:metapredicate1:1702"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
345 <p>The <a name="idx:metapredicate1:1701"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
387346 declaration is the portable mechanism for defining meta-predicates and
388347 replaces the old SWI-Prolog specific mechanism provided by the
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>.
348 deprecated predicates <a name="idx:moduletransparent1:1702"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>,
349 <a name="idx:contextmodule1:1703"></a><a class="pred" href="ctxmodule.html#context_module/1">context_module/1</a>
350 and <a name="idx:stripmodule3:1704"></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>.
393352 </dd>
394353 </dl>
395354
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.28</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="arith.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="builtinlist.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:miscarith"><a id="sec:4.28"><span class="sec-nr">4.28</span> <span class="sec-title">Misc
194 <h2 id="sec:miscarith"><a name="sec:4.28"><span class="sec-nr">4.28</span> <span class="sec-title">Misc
236195 arithmetic support predicates</span></a></h2>
237196
238 <a id="sec:miscarith"></a>
197 <a name="sec:miscarith"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="set_random/1"><strong>set_random</strong>(<var>+Option</var>)</a></dt>
200 <dt class="pubdef"><a name="set_random/1"><strong>set_random</strong>(<var>+Option</var>)</a></dt>
242201 <dd class="defbody">
243202 Controls the random number generator accessible through the
244203 <em>functions</em> <a class="function" href="arith.html#f-random/1">random/1</a>
265224 </dd>
266225 <dt><strong>state</strong>(<var>+State</var>)</dt>
267226 <dd class="defbody">
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>.
269 Using other values may lead to undefined behaviour.<sup class="fn">117<span class="fn-text">The
227 Set the generator to a state fetched using the state property of <a name="idx:randomproperty1:1342"></a><a class="pred" href="miscarith.html#random_property/1">random_property/1</a>.
228 Using other values may lead to undefined behaviour.<sup class="fn">116<span class="fn-text">The
270229 limitations of the underlying (GMP) library are unknown, which makes it
271230 impossible to validate the <var>State</var>.</span></sup>
272231 </dd>
273232 </dl>
274233
275234 </dd>
276 <dt class="pubdef"><a id="random_property/1"><strong>random_property</strong>(<var>?Option</var>)</a></dt>
235 <dt class="pubdef"><a name="random_property/1"><strong>random_property</strong>(<var>?Option</var>)</a></dt>
277236 <dd class="defbody">
278237 True when <var>Option</var> is a current property of the random
279238 generator. Currently, this predicate provides access to the state. This
285244 Describes the current state of the random generator. State is a normal
286245 Prolog term that can be asserted or written to a file. Applications
287246 should make no other assumptions about its representation. The only
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>
247 meaningful operation is to use as argument to <a name="idx:setrandom1:1343"></a><a class="pred" href="miscarith.html#set_random/1">set_random/1</a>
289248 using the
290249 <code>state(State)</code> option.<sup class="fn">bug<span class="fn-text">GMP
291250 provides no portable mechanism to fetch and restore the state. The
296255 </dl>
297256
298257 </dd>
299 <dt class="pubdef"><a id="current_arithmetic_function/1"><strong>current_arithmetic_function</strong>(<var>?Head</var>)</a></dt>
258 <dt class="pubdef"><a name="current_arithmetic_function/1"><strong>current_arithmetic_function</strong>(<var>?Head</var>)</a></dt>
300259 <dd class="defbody">
301260 True when <var>Head</var> is an evaluable function. For example:
302261
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.44</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="DDE.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="extensions.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <dl class="latex">
240 <dt class="pubdef"><a id="dwim_match/2"><strong>dwim_match</strong>(<var>+Atom1,
199 <dt class="pubdef"><a name="dwim_match/2"><strong>dwim_match</strong>(<var>+Atom1,
241200 +Atom2</var>)</a></dt>
242201 <dd class="defbody">
243202 True if <var>Atom1</var> matches <var>Atom2</var> in the `Do What I
254213 fileExists)
255214 </ul>
256215 </dd>
257 <dt class="pubdef"><a id="dwim_match/3"><strong>dwim_match</strong>(<var>+Atom1,
216 <dt class="pubdef"><a name="dwim_match/3"><strong>dwim_match</strong>(<var>+Atom1,
258217 +Atom2, -Difference</var>)</a></dt>
259218 <dd class="defbody">
260 Equivalent to <a id="idx:dwimmatch2:1586"></a><a class="pred" href="miscpreds.html#dwim_match/2">dwim_match/2</a>,
219 Equivalent to <a name="idx:dwimmatch2:1589"></a><a class="pred" href="miscpreds.html#dwim_match/2">dwim_match/2</a>,
261220 but unifies <var>Difference</var> with an atom identifying the
262221 difference between <var>Atom1</var> and <var>Atom2</var>. The return
263222 values are (in the same order as above): <code>equal</code>,
264223 <code>mismatched_char</code>, <code>inserted_char</code>, <code>transposed_char</code>,
265224 <code>separated</code> and <code>transposed_word</code>.
266225 </dd>
267 <dt class="pubdef"><a id="wildcard_match/2"><strong>wildcard_match</strong>(<var>+Pattern,
226 <dt class="pubdef"><a name="wildcard_match/2"><strong>wildcard_match</strong>(<var>+Pattern,
268227 +String</var>)</a></dt>
269228 <dd class="defbody">
270229 True if <var>String</var> matches the wildcard pattern <var>Pattern</var>.
271230 <var>Pattern</var> is very similar to the Unix <code>csh</code> pattern
272231 matcher. The patterns are given below:
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>
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>
282240 indicates a range. </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>
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>
285243 </table>
244 </div>
286245
287246 <p>Example:
288247
292251 </pre>
293252
294253 </dd>
295 <dt class="pubdef"><a id="sleep/1"><strong>sleep</strong>(<var>+Time</var>)</a></dt>
254 <dt class="pubdef"><a name="sleep/1"><strong>sleep</strong>(<var>+Time</var>)</a></dt>
296255 <dd class="defbody">
297256 Suspend execution <var>Time</var> seconds. <var>Time</var> is either a
298257 floating point number or an integer. Granularity is dependent on the
300259 immediately. On most non-realtime operating systems we can only ensure
301260 execution is suspended for <b>at least</b> <var>Time</var> seconds.
302261
303 <p>On Unix systems the <a id="idx:sleep1:1587"></a><a class="pred" href="miscpreds.html#sleep/1">sleep/1</a>
262 <p>On Unix systems the <a name="idx:sleep1:1590"></a><a class="pred" href="miscpreds.html#sleep/1">sleep/1</a>
304263 predicate is realised ---in order of preference--- by nanosleep(),
305264 usleep(), select() if the time is below 1 minute, or sleep(). On Windows
306265 systems Sleep() is used.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.15</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="manipmodule.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="clp.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:modulecompat"><a id="sec:6.15"><span class="sec-nr">6.15</span> <span class="sec-title">Compatibility
194 <h2 id="sec:modulecompat"><a name="sec:6.15"><span class="sec-nr">6.15</span> <span class="sec-title">Compatibility
236195 of the Module System</span></a></h2>
237196
238 <a id="sec:modulecompat"></a>
197 <a name="sec:modulecompat"></a>
239198
240199 <p>The SWI-Prolog module system is largely derived from the Quintus
241200 Prolog module system, which is also adopted by SICStus, Ciao and YAP.
242201 Originally, the mechanism for defining meta-predicates in SWI-Prolog was
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>
202 based on the <a name="idx:moduletransparent1:1755"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>
203 directive and <a name="idx:stripmodule3:1756"></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:1757"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
246205 directive for implementing meta-predicates, providing much better
247206 compatibility.
248207
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>
208 <p>The support for the <a name="idx:metapredicate1:1758"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>
250209 mechanism, however, is considerably different. On most systems, the <em>caller</em>
251210 of a meta-predicate is compiled differently to provide the required &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;
252211 qualification. This implies that the meta-declaration must be available
258217 <ul class="latex">
259218 <li>Modules that provide meta-predicates for a module to be compiled
260219 must be loaded explicitly by that module.
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>
220 <li>The meta-predicate directives of exported predicates must follow the <a name="idx:module2:1759"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
262221 directive immediately.
263222 <li>After changing a meta-declaration, all modules that <em>call</em>
264223 the modified predicates need to be recompiled.
280239 user-defined module is the <code>user</code> module. In turn, the
281240 <code>user</code> module imports from the module <code>system</code>
282241 that provides all built-in predicates. The auto-import hierarchy can be
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>.
242 changed using <a name="idx:addimportmodule3:1760"></a><a class="pred" href="importmodule.html#add_import_module/3">add_import_module/3</a>
243 and <a name="idx:deleteimportmodule2:1761"></a><a class="pred" href="importmodule.html#delete_import_module/2">delete_import_module/2</a>.
285244
286245 <p>This mechanism can be used to realise a simple object-oriented system
287246 or a hierarchical module system.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="reexport.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="importmodule.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:moduleop"><a id="sec:6.8"><span class="sec-nr">6.8</span> <span class="sec-title">Operators
194 <h2 id="sec:moduleop"><a name="sec:6.8"><span class="sec-nr">6.8</span> <span class="sec-title">Operators
236195 and modules</span></a></h2>
237196
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
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
242201 from the module <code>user</code> (see
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>
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:1719"></a><a class="pred" href="operators.html#op/3">op/3</a>
208 directive, operators can be declared in the <a name="idx:module2:1720"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
250209 directive as shown below. Such operator declarations are visible inside
251210 the module, and importing such a module makes the operators visible in
252211 the target module. Exporting operators is typically used by modules that
253212 implement sub-languages such as chr (see
254 <a class="sec" href="chr.html#sec:8">chapter 8</a>). The example below
255 is copied from the library
213 <a class="sec" href="chr.html">chapter 8</a>). The example below is
214 copied from the library
256215 <code>library(clpfd)</code>.
257216
258217 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ext-issues.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="whymodules.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>A Prolog module is a collection of predicates which defines a public
240199 interface by means of a set of provided predicates and operators. Prolog
250209
251210 <p>This chapter motivates and describes the SWI-Prolog module system.
252211 Novices can start using the module system after reading
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
212 <a class="sec" href="defmodule.html">section 6.2</a> and <a class="sec" href="import.html">section
254213 6.3</a>. The primitives defined in these sections suffice for basic
255214 usage until one needs to export predicates that call or manage other
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>,
215 predicates dynamically (e.g., use <a name="idx:call1:1661"></a><a class="pred" href="metacall.html#call/1">call/1</a>,
216 <a name="idx:assert1:1662"></a><a class="pred" href="db.html#assert/1">assert/1</a>,
258217 etc.). Such predicates are called <em>meta predicates</em> and are
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
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
262221 6.9</a>, we discuss more low-level aspects of the SWI-Prolog module
263222 system that are used to implement the visible module system, and can be
264223 used to build other code reuse mechanisms.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreignthread.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="engines.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:mt-xpce"><a id="sec:9.7"><span class="sec-nr">9.7</span> <span class="sec-title">Multithreading
194 <h2 id="sec:mt-xpce"><a name="sec:9.7"><span class="sec-nr">9.7</span> <span class="sec-title">Multithreading
236195 and the XPCE graphics system</span></a></h2>
237196
238 <a id="sec:mt-xpce"></a>
239 <a id="sec:xpcethread"></a>
197 <a name="sec:mt-xpce"></a>
198 <a name="sec:xpcethread"></a>
240199
241200 <p>GUI applications written in XPCE can benefit from Prolog threads if
242201 they need to do expensive computations that would otherwise block the
251210 <p>Traditionally, XPCE runs in the foreground (<code>main</code>)
252211 thread. We are working towards a situation where XPCE can run
253212 comfortably in a separate thread. A separate XPCE thread can be created
254 using <a id="idx:pcedispatch1:1959"></a><a class="pred" href="mt-xpce.html#pce_dispatch/1">pce_dispatch/1</a>.
213 using <a name="idx:pcedispatch1:1958"></a><a class="pred" href="mt-xpce.html#pce_dispatch/1">pce_dispatch/1</a>.
255214 It is also possible to create this thread as the <code>library(1)</code>pce)
256215 is loaded by setting the <b>xpce_threaded</b> to <code>true</code>.
257216
259218 two predicates to communicate with XPCE.
260219
261220 <dl class="latex">
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>
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>
263222 <dd class="defbody">
264223 Assuming XPCE is running in the foreground thread, this call gives
265224 background threads the opportunity to make calls to the XPCE thread. 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>
225 call to <a name="idx:inpcethread1:1959"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>
267226 succeeds immediately, copying <var>Goal</var> to the XPCE thread. <var>Goal</var>
268227 is added to the XPCE event queue and executed synchronous to normal user
269228 events like typing and clicking.</dd>
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>
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>
271230 <dd class="defbody">
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>,
231 Same as <a name="idx:inpcethread1:1960"></a><a class="pred" href="mt-xpce.html#in_pce_thread/1">in_pce_thread/1</a>,
273232 but wait for <var>Goal</var> to be completed. Success depends on the
274233 success of executing <var>Goal</var>. Variable bindings inside <var>Goal</var>
275234 are visible to the caller, but it should be noted that the values are
276235 being <em>copied</em>. If <var>Goal</var> throws an exception, this
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>
236 exception is re-thrown by <a name="idx:inpcethread1:1961"></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:1962"></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:1963"></a><span class="pred-ext">pce_thread/1</span>.
239
240 <p>Note that <a name="idx:inpcethreadsync1:1964"></a><a class="pred" href="mt-xpce.html#in_pce_thread_sync/1">in_pce_thread_sync/1</a>
282241 is expensive because it requires copying and thread communication. For
283242 example, <code>in_pce_thread_synctrue</code> runs at approximately
284243 50,000 calls per second (AMD Phenom 9600B, Ubuntu 11.04).</dd>
285 <dt class="pubdef"><a id="pce_dispatch/1"><strong>pce_dispatch</strong>(<var>+Options</var>)</a></dt>
244 <dt class="pubdef"><a name="pce_dispatch/1"><strong>pce_dispatch</strong>(<var>+Options</var>)</a></dt>
286245 <dd class="defbody">
287246 Create a Prolog thread with the alias name <code>pce</code> for XPCE
288247 event handling. In the X11 version this call creates a thread that
289248 executes the X11 event-dispatch loop. In MS-Windows it creates a thread
290249 that executes a windows event-dispatch loop. The XPCE event-handling
291250 thread has the alias <code>pce</code>. <var>Options</var> specifies the
292 thread attributes as <a id="idx:threadcreate3:1966"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>.
251 thread attributes as <a name="idx:threadcreate3:1965"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>.
293252 </dd>
294253 </dl>
295254
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="overrule.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="reexport.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:mtoplevel"><a id="sec:6.6"><span class="sec-nr">6.6</span> <span class="sec-title">Interacting
194 <h2 id="sec:mtoplevel"><a name="sec:6.6"><span class="sec-nr">6.6</span> <span class="sec-title">Interacting
236195 with modules from the top level</span></a></h2>
237196
238 <a id="sec:mtoplevel"></a>
197 <a name="sec:mtoplevel"></a>
239198
240199 <p>Debugging often requires interaction with predicates that reside in
241200 modules: running them, setting spy points on them, etc. This can be
242201 achieved using the &lt;<var>module</var>&gt;:&lt;<var>term</var>&gt;
243202 construct explicitly as described above. In SWI-Prolog, you may also
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>)
203 wish to omit the module qualification. Setting a spy point (<a name="idx:spy1:1708"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>)
245204 on a plain predicate sets a spy point on any predicate with that name in
246 any module. Editing (<a id="idx:edit1:1710"></a><a class="pred" href="edit.html#edit/1">edit/1</a>)
205 any module. Editing (<a name="idx:edit1:1709"></a><a class="pred" href="edit.html#edit/1">edit/1</a>)
247206 or calling an unqualified predicate invokes the DWIM (Do What I Mean)
248207 mechanism, which generally suggests the correct qualified query.
249208
250 <p>Mainly for compatibility, we provide <a id="idx:module1:1711"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>
209 <p>Mainly for compatibility, we provide <a name="idx:module1:1710"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>
251210 to switch the module with which the interactive top level interacts:
252211
253212 <dl class="latex">
254 <dt class="pubdef"><a id="module/1"><strong>module</strong>(<var>+Module</var>)</a></dt>
213 <dt class="pubdef"><a name="module/1"><strong>module</strong>(<var>+Module</var>)</a></dt>
255214 <dd class="defbody">
256215 The call <code>module(<var>Module</var>)</code> may be used to switch
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>).
216 the default working module for the interactive top level (see <a name="idx:prolog0:1711"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
258217 This may be used when debugging a module. The example below lists the
259 clauses of <a id="idx:fileoflabel2:1713"></a><span class="pred-ext">file_of_label/2</span>
218 clauses of <a name="idx:fileoflabel2:1712"></a><span class="pred-ext">file_of_label/2</span>
260219 in the module <code>tex</code>.
261220
262221 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="guitracer.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="xref.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:navigator"><a id="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">The
194 <h2 id="sec:navigator"><a name="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">The
236195 Prolog Navigator</span></a></h2>
237196
238 <a id="sec:navigator"></a>
197 <a name="sec:navigator"></a>
239198
240199 <p>Another tool is the <em>Prolog Navigator</em>. This tool can be
241200 started from PceEmacs using the command <strong>Browse/Prolog navigator</strong>,
242201 from the GUI debugger or using the programmatic IDE interface described
243202 in
244 <a class="sec" href="idepreds.html#sec:3.8">section 3.8</a>.
203 <a class="sec" href="idepreds.html">section 3.8</a>.
245204
246205 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.17</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="main.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="www_browser.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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):
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):
236195 Non-backtrackable set</span></a></h2>
237196
238 <a id="sec:nb_set"></a>
197 <a name="sec:nb_set"></a>
239198
240199 <p>The library <code>library(nb_set)</code> defines <em>non-backtrackable
241200 sets</em>, implemented as binary trees. The sets are represented as
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>.
201 compound terms and manipulated using <a name="idx:nbsetarg3:2148"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
243202 Non-backtrackable manipulation of datastructures is not supported by a
244203 large number of Prolog implementations, but it has several advantages
245204 over using the database. It produces less garbage, is thread-safe,
262221 </pre>
263222
264223 <dl class="latex">
265 <dt class="pubdef"><a id="empty_nb_set/1"><strong>empty_nb_set</strong>(<var>?Set</var>)</a></dt>
224 <dt class="pubdef"><a name="empty_nb_set/1"><strong>empty_nb_set</strong>(<var>?Set</var>)</a></dt>
266225 <dd class="defbody">
267226 True if <var>Set</var> is a non-backtrackable empty set.</dd>
268 <dt class="pubdef"><a id="add_nb_set/2"><strong>add_nb_set</strong>(<var>+Key,
227 <dt class="pubdef"><a name="add_nb_set/2"><strong>add_nb_set</strong>(<var>+Key,
269228 !Set</var>)</a></dt>
270229 <dd class="defbody">
271230 Add <var>Key</var> to <var>Set</var>. If <var>Key</var> is already a
272231 member of
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>
232 <var>Set</var>, <a name="idx:addnbset3:2149"></a><a class="pred" href="nb_set.html#add_nb_set/3">add_nb_set/3</a>
274233 succeeds without modifying <var>Set</var>.</dd>
275 <dt class="pubdef"><a id="add_nb_set/3"><strong>add_nb_set</strong>(<var>+Key,
234 <dt class="pubdef"><a name="add_nb_set/3"><strong>add_nb_set</strong>(<var>+Key,
276235 !Set, ?New</var>)</a></dt>
277236 <dd class="defbody">
278237 If <var>Key</var> is not in <var>Set</var> and <var>New</var> is unified
281240 is in <var>Set</var>, <var>New</var> is unified to <code>false</code>.
282241 It can be used for many purposes:
283242
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>
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>
289250 </table>
290251 </dd>
291 <dt class="pubdef"><a id="gen_nb_set/2"><strong>gen_nb_set</strong>(<var>+Set,
252 <dt class="pubdef"><a name="gen_nb_set/2"><strong>gen_nb_set</strong>(<var>+Set,
292253 -Key</var>)</a></dt>
293254 <dd class="defbody">
294255 Generate all members of <var>Set</var> on backtracking in the standard
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,
256 order of terms. To test membership, use <a name="idx:addnbset3:2150"></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,
297258 -Size</var>)</a></dt>
298259 <dd class="defbody">
299260 Unify <var>Size</var> with the number of elements in <var>Set</var>.</dd>
300 <dt class="pubdef"><a id="nb_set_to_list/2"><strong>nb_set_to_list</strong>(<var>+Set,
261 <dt class="pubdef"><a name="nb_set_to_list/2"><strong>nb_set_to_list</strong>(<var>+Set,
301262 -List</var>)</a></dt>
302263 <dd class="defbody">
303264 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.7.4 Reference Manual: Section 4.25</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="chartype.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="charconv.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>Operators are defined to improve the readability of source code. For
240199 example, without operators, to write <code>2*3+4*5</code> one would have
242201 have been predefined. All operators, except for the comma (,) can be
243202 redefined by the user.
244203
245 <p><a id="idx:operatorandmodules:1314"></a>Some care has to be taken
204 <p><a name="idx:operatorandmodules:1316"></a>Some care has to be taken
246205 before defining new operators. Defining too many operators might make
247206 your source `natural' looking, but at the same time make it hard to
248207 understand the limits of your syntax. To ease the pain, as of SWI-Prolog
250209 Operators can be exported from modules using a term
251210 <code>op(Precedence, Type, Name)</code> in the export list as specified
252211 by
253 <a id="idx:module2:1315"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
212 <a name="idx:module2:1317"></a><a class="pred" href="defmodule.html#module/2">module/2</a>.
254213 Many modern Prolog systems have module specific operators.
255214 Unfortunately, there is no established interface for exporting and
256215 importing operators. SWI-Prolog's convention has been addopted by YAP.
271230 <p>In SWI-Prolog, a <em>quoted atom</em> never acts as an operator. Note
272231 that the portable way to stop an atom acting as an operator is to
273232 enclose it in parentheses like this: (myop). See also
274 <a class="sec" href="ext-syntax.html#sec:5.3.1">section 5.3.1</a>.
233 <a class="sec" href="ext-syntax.html">section 5.3.1</a>.
275234
276235 <dl class="latex">
277 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="op/3"><strong>op</strong>(<var>+Precedence,
236 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="op/3"><strong>op</strong>(<var>+Precedence,
278237 +Type, :Name</var>)</a></dt>
279238 <dd class="defbody">
280239 Declare <var>Name</var> to be an operator of type <var>Type</var> with
315274 </ul>
316275
317276 <p>In SWI-Prolog, operators are <em>local</em> to a module (see also
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>
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:1318"></a><a class="pred" href="defmodule.html#module/2">module/2</a>
321280 directive keep the issues manageable. The module <code>system</code>
322281 provides the operators from <a class="tab" href="operators.html#tab:operators">table
323282 5</a> and these operators cannot be modified. Files that are loaded from
326285 library and development system modules independent of operator changes
327286 to the <code>user</code> module.
328287
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>,
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>,
333292 <strong>meta_predicate</strong>,
334293 <strong>module_transparent</strong>, <strong>multifile</strong>, <strong>public</strong>,
335294 <strong>thread_local</strong>, <strong>thread_initialization</strong>, <strong>volatile</strong> </td></tr>
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>,
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>,
342301 <strong><code>=:=</code></strong>, <strong><code>=&lt;</code></strong>, <strong><code>==</code></strong>,
343302 <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>,
344303 <strong><code>@&gt;=</code></strong>, <strong><code>\=</code></strong>, <strong><code>\==</code></strong>, <strong>as</strong>, <strong>is</strong>,
345304 <strong><code>&gt;:&lt;</code></strong>, <strong><code>:&lt;</code></strong>
346305 </td></tr>
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>,
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>,
351310 <strong><code>&lt;&lt;</code></strong>, <strong><code>&gt;&gt;</code></strong>, <strong>mod</strong>, <strong>rem</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>
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>
357316 </table>
358317 <div class="caption"><b>Table 5 : </b>System operators</div>
359 <a id="tab:operators"></a>
318 <a name="tab:operators"></a>
360319 </dd>
361 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="current_op/3"><strong>current_op</strong>(<var>?Precedence,
320 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="current_op/3"><strong>current_op</strong>(<var>?Precedence,
362321 ?Type, ?:Name</var>)</a></dt>
363322 <dd class="defbody">
364323 True if <var>Name</var> is currently defined as an operator of type <var>Type</var>
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>.
324 with precedence <var>Precedence</var>. See also <a name="idx:op3:1319"></a><a class="pred" href="operators.html#op/3">op/3</a>.
366325 </dd>
367326 </dl>
368327
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="funcsummary.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="Bibliography.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197 <table>
239198 <tr><td>1</td><td>fx</td><td>$</td><td>Bind top-level variable</td></tr>
240199 <tr><td>200</td><td>xfy</td><td>^</td><td>Existential qualification</td></tr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.19</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="www_browser.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="optparse.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:option"><a id="sec:A.19"><span class="sec-nr">A.19</span> <span class="sec-title">library(option):
194 <h2 id="sec:option"><a name="sec:A.19"><span class="sec-nr">A.19</span> <span class="sec-title">library(option):
236195 Option list processing</span></a></h2>
237196
238 <p><a id="sec:option"></a>
197 <p><a name="sec:option"></a>
239198
240199 <dl class="tags">
241200 <dt class="mtag">See also</dt>
304263 </ul>
305264
306265 <dl class="latex">
307 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="option/3"><strong>option</strong>(<var>?Option,
266 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="option/3"><strong>option</strong>(<var>?Option,
308267 +OptionList, +Default</var>)</a></dt>
309268 <dd class="defbody">
310269 Get an <var>Option</var> from <var>OptionList</var>. <var>OptionList</var>
311270 can use the Name=Value as well as the Name(Value) convention.
312271 <table class="arglist">
313 <tr><td><var>Option</var> </td><td>Term of the form Name(?Value). </td></tr>
272 <tr valign="top"><td><var>Option</var> </td><td>Term of the form
273 Name(?Value). </td></tr>
314274 </table>
315275 </dd>
316 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="option/2"><strong>option</strong>(<var>?Option,
276 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="option/2"><strong>option</strong>(<var>?Option,
317277 +OptionList</var>)</a></dt>
318278 <dd class="defbody">
319279 Get an <var>Option</var> from <var>OptionList</var>. <var>OptionList</var>
320280 can use the Name=Value as well as the Name(Value) convention. Fails
321281 silently if the option does not appear in <var>OptionList</var>.
322282 <table class="arglist">
323 <tr><td><var>Option</var> </td><td>Term of the form Name(?Value). </td></tr>
283 <tr valign="top"><td><var>Option</var> </td><td>Term of the form
284 Name(?Value). </td></tr>
324285 </table>
325286 </dd>
326 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="select_option/3"><strong>select_option</strong>(<var>?Option,
287 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="select_option/3"><strong>select_option</strong>(<var>?Option,
327288 +Options, -RestOptions</var>)</a></dt>
328289 <dd class="defbody">
329290 Get and remove <var>Option</var> from an option list. As <a class="pred" href="option.html#option/2">option/2</a>,
330291 removing the matching option from <var>Options</var> and unifying the
331292 remaining options with <var>RestOptions</var>.</dd>
332 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="select_option/4"><strong>select_option</strong>(<var>?Option,
293 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="select_option/4"><strong>select_option</strong>(<var>?Option,
333294 +Options, -RestOptions, +Default</var>)</a></dt>
334295 <dd class="defbody">
335296 Get and remove <var>Option</var> with default value. As <a class="pred" href="option.html#select_option/3">select_option/3</a>,
336297 but if <var>Option</var> is not in <var>Options</var>, its value is
337298 unified with
338299 <var>Default</var> and <var>RestOptions</var> with <var>Options</var>.</dd>
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="merge_options/3"><strong>merge_options</strong>(<var>+New,
300 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="merge_options/3"><strong>merge_options</strong>(<var>+New,
340301 +Old, -Merged</var>)</a></dt>
341302 <dd class="defbody">
342303 Merge two option lists. <var>Merged</var> is a sorted list of options
346307 <p>Multi-values options (e.g., <code>proxy(Host, Port)</code>) are
347308 allowed, where both option-name and arity define the identity of the
348309 option.</dd>
349 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="meta_options/3"><strong>meta_options</strong>(<var>+IsMeta,
310 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="meta_options/3"><strong>meta_options</strong>(<var>+IsMeta,
350311 :Options0, -Options</var>)</a></dt>
351312 <dd class="defbody">
352313 Perform meta-expansion on options that are module-sensitive. Whether an
372333 </dl>
373334
374335 </dd>
375 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="dict_options/2"><strong>dict_options</strong>(<var>?Dict,
336 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="dict_options/2"><strong>dict_options</strong>(<var>?Dict,
376337 ?Options</var>)</a></dt>
377338 <dd class="defbody">
378339 Convert between an option list and a dictionary. One of the arguments
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.20</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="option.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ordsets.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:optparse"><a id="sec:A.20"><span class="sec-nr">A.20</span> <span class="sec-title">library(optparse):
194 <h2 id="sec:optparse"><a name="sec:A.20"><span class="sec-nr">A.20</span> <span class="sec-title">library(optparse):
236195 command line parsing</span></a></h2>
237196
238 <p><a id="sec:optparse"></a>
197 <p><a name="sec:optparse"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">author</dt>
521480 <p>This representation may be preferable with the empty-flag
522481 configuration parameter style above (perhaps with asserting <span class="pred-ext">appl_config/2</span>).
523482
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
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
525484 and tips</span></a></h3>
526485
527 <p><a id="sec:optparse-notes"></a>
486 <p><a name="sec:optparse-notes"></a>
528487
529488 <p>
530489 <ul class="latex">
561520 </ul>
562521
563522 <dl class="latex">
564 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_arguments/3"><strong>opt_arguments</strong>(<var>+OptsSpec,
523 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_arguments/3"><strong>opt_arguments</strong>(<var>+OptsSpec,
565524 -Opts, -PositionalArgs</var>)</a></dt>
566525 <dd class="defbody">
567526 Extract commandline options according to a specification. Convenience
580539 they may go anywhere (although it is good practice to put them last).
581540 Any leading arguments for the runtime (up to and including '--') are
582541 discarded.</dd>
583 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_parse/4"><strong>opt_parse</strong>(<var>+OptsSpec,
542 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_parse/4"><strong>opt_parse</strong>(<var>+OptsSpec,
584543 +ApplArgs, -Opts, -PositionalArgs</var>)</a></dt>
585544 <dd class="defbody">
586545 Equivalent to <code>opt_parse(OptsSpec, ApplArgs, Opts, PositionalArgs, [])</code>.</dd>
587 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_parse/5"><strong>opt_parse</strong>(<var>+OptsSpec,
546 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_parse/5"><strong>opt_parse</strong>(<var>+OptsSpec,
588547 +ApplArgs, -Opts, -PositionalArgs, +ParseOptions</var>)</a></dt>
589548 <dd class="defbody">
590549 Parse the arguments Args (as list of atoms) according to <var>OptsSpec</var>.
630589 </dl>
631590
632591 </dd>
633 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="opt_help/2"><strong>opt_help</strong>(<var>+OptsSpec,
592 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="opt_help/2"><strong>opt_help</strong>(<var>+OptsSpec,
634593 -Help:atom</var>)</a></dt>
635594 <dd class="defbody">
636595 True when <var>Help</var> is a help string synthesized from <var>OptsSpec</var>.</dd>
637 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a id="parse_type/3"><strong>parse_type</strong>(<var>+Type,
596 <dt class="multidef"><span class="pred-tag">[semidet,multifile]</span><a name="parse_type/3"><strong>parse_type</strong>(<var>+Type,
638597 +Codes:list(code), -Result</var>)</a></dt>
639598 <dd class="defbody">
640599 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.7.4 Reference Manual: Section A.21</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="optparse.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="pairs.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ordsets"><a id="sec:A.21"><span class="sec-nr">A.21</span> <span class="sec-title">library(ordsets):
194 <h2 id="sec:ordsets"><a name="sec:A.21"><span class="sec-nr">A.21</span> <span class="sec-title">library(ordsets):
236195 Ordered set manipulation</span></a></h2>
237196
238 <p><a id="sec:ordsets"></a>
197 <p><a name="sec:ordsets"></a>
239198
240199 <p>Ordered sets are lists with unique elements sorted to the standard
241200 order of terms (see <a class="pred" href="builtinlist.html#sort/2">sort/2</a>).
266225 as an ordset because the order it relies on may have been changed.
267226
268227 <dl class="latex">
269 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_ordset/1"><strong>is_ordset</strong>(<var>@Term</var>)</a></dt>
228 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_ordset/1"><strong>is_ordset</strong>(<var>@Term</var>)</a></dt>
270229 <dd class="defbody">
271230 True if <var>Term</var> is an ordered set. All predicates in this
272231 library expect ordered sets as input arguments. Failing to fullfil this
274233 created by predicates from this library, <a class="pred" href="builtinlist.html#sort/2">sort/2</a>
275234 or
276235 <a class="pred" href="allsolutions.html#setof/3">setof/3</a>.</dd>
277 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_empty/1"><strong>ord_empty</strong>(<var>?List</var>)</a></dt>
236 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_empty/1"><strong>ord_empty</strong>(<var>?List</var>)</a></dt>
278237 <dd class="defbody">
279238 True when <var>List</var> is the empty ordered set. Simply unifies list
280239 with the empty list. Not part of Quintus.</dd>
281 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_seteq/2"><strong>ord_seteq</strong>(<var>+Set1,
240 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_seteq/2"><strong>ord_seteq</strong>(<var>+Set1,
282241 +Set2</var>)</a></dt>
283242 <dd class="defbody">
284243 True if <var>Set1</var> and <var>Set2</var> have the same elements. As
292251 </dl>
293252
294253 </dd>
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,
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,
296255 -OrdSet</var>)</a></dt>
297256 <dd class="defbody">
298257 Transform a list into an ordered set. This is the same as sorting the
299258 list.</dd>
300 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_intersect/2"><strong>ord_intersect</strong>(<var>+Set1,
259 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_intersect/2"><strong>ord_intersect</strong>(<var>+Set1,
301260 +Set2</var>)</a></dt>
302261 <dd class="defbody">
303262 True if both ordered sets have a non-empty intersection.</dd>
304 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_disjoint/2"><strong>ord_disjoint</strong>(<var>+Set1,
263 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_disjoint/2"><strong>ord_disjoint</strong>(<var>+Set1,
305264 +Set2</var>)</a></dt>
306265 <dd class="defbody">
307266 True if <var>Set1</var> and <var>Set2</var> have no common elements.
308267 This is the negation of <a class="pred" href="ordsets.html#ord_intersect/2">ord_intersect/2</a>.</dd>
309 <dt class="pubdef"><a id="ord_intersect/3"><strong>ord_intersect</strong>(<var>+Set1,
268 <dt class="pubdef"><a name="ord_intersect/3"><strong>ord_intersect</strong>(<var>+Set1,
310269 +Set2, -Intersection</var>)</a></dt>
311270 <dd class="defbody">
312271 <var>Intersection</var> holds the common elements of <var>Set1</var> and <var>Set2</var>.
319278 </dl>
320279
321280 </dd>
322 <dt class="pubdef"><a id="ord_intersection/2"><strong>ord_intersection</strong>(<var>+PowerSet,
281 <dt class="pubdef"><a name="ord_intersection/2"><strong>ord_intersection</strong>(<var>+PowerSet,
323282 -Intersection</var>)</a></dt>
324283 <dd class="defbody">
325284 <var>Intersection</var> of a powerset. True when <var>Intersection</var>
333292 </dl>
334293
335294 </dd>
336 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_intersection/3"><strong>ord_intersection</strong>(<var>+Set1,
295 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_intersection/3"><strong>ord_intersection</strong>(<var>+Set1,
337296 +Set2, -Intersection</var>)</a></dt>
338297 <dd class="defbody">
339298 <var>Intersection</var> holds the common elements of <var>Set1</var> and <var>Set2</var>.
340299 Uses
341300 <a class="pred" href="ordsets.html#ord_disjoint/2">ord_disjoint/2</a> if <var>Intersection</var>
342301 is bound to <code>[]</code> on entry.</dd>
343 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_intersection/4"><strong>ord_intersection</strong>(<var>+Set1,
302 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_intersection/4"><strong>ord_intersection</strong>(<var>+Set1,
344303 +Set2, ?Intersection, ?Difference</var>)</a></dt>
345304 <dd class="defbody">
346305 <var>Intersection</var> and difference between two ordered sets.
357316 </dl>
358317
359318 </dd>
360 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_add_element/3"><strong>ord_add_element</strong>(<var>+Set1,
319 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_add_element/3"><strong>ord_add_element</strong>(<var>+Set1,
361320 +Element, ?Set2</var>)</a></dt>
362321 <dd class="defbody">
363322 Insert an element into the set. This is the same as
364323 <code>ord_union(Set1, [Element], Set2)</code>.</dd>
365 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_del_element/3"><strong>ord_del_element</strong>(<var>+Set,
324 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_del_element/3"><strong>ord_del_element</strong>(<var>+Set,
366325 +Element, -NewSet</var>)</a></dt>
367326 <dd class="defbody">
368327 Delete an element from an ordered set. This is the same as
369328 <code>ord_subtract(Set, [Element], NewSet)</code>.</dd>
370 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_selectchk/3"><strong>ord_selectchk</strong>(<var>+Item,
329 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_selectchk/3"><strong>ord_selectchk</strong>(<var>+Item,
371330 ?Set1, ?Set2</var>)</a></dt>
372331 <dd class="defbody">
373332 Selectchk/3, specialised for ordered sets. Is true when
387346 </dl>
388347
389348 </dd>
390 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_memberchk/2"><strong>ord_memberchk</strong>(<var>+Element,
349 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_memberchk/2"><strong>ord_memberchk</strong>(<var>+Element,
391350 +OrdSet</var>)</a></dt>
392351 <dd class="defbody">
393352 True if <var>Element</var> is a member of <var>OrdSet</var>, compared
411370 </dl>
412371
413372 </dd>
414 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="ord_subset/2"><strong>ord_subset</strong>(<var>+Sub,
373 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="ord_subset/2"><strong>ord_subset</strong>(<var>+Sub,
415374 +Super</var>)</a></dt>
416375 <dd class="defbody">
417376 Is true if all elements of <var>Sub</var> are in <var>Super</var></dd>
418 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_subtract/3"><strong>ord_subtract</strong>(<var>+InOSet,
377 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_subtract/3"><strong>ord_subtract</strong>(<var>+InOSet,
419378 +NotInOSet, -Diff</var>)</a></dt>
420379 <dd class="defbody">
421380 <var>Diff</var> is the set holding all elements of <var>InOSet</var>
422381 that are not in
423382 <var>NotInOSet</var>.</dd>
424 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_union/2"><strong>ord_union</strong>(<var>+SetOfSets,
383 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_union/2"><strong>ord_union</strong>(<var>+SetOfSets,
425384 -Union</var>)</a></dt>
426385 <dd class="defbody">
427386 True if <var>Union</var> is the union of all elements in the superset
436395 </dl>
437396
438397 </dd>
439 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_union/3"><strong>ord_union</strong>(<var>+Set1,
398 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_union/3"><strong>ord_union</strong>(<var>+Set1,
440399 +Set2, ?Union</var>)</a></dt>
441400 <dd class="defbody">
442401 <var>Union</var> is the union of <var>Set1</var> and <var>Set2</var></dd>
443 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_union/4"><strong>ord_union</strong>(<var>+Set1,
402 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_union/4"><strong>ord_union</strong>(<var>+Set1,
444403 +Set2, -Union, -New</var>)</a></dt>
445404 <dd class="defbody">
446405 True iff <code>ord_union(Set1, Set2, Union)</code> and
447406 <code>ord_subtract(Set2, Set1, New)</code>.</dd>
448 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="ord_symdiff/3"><strong>ord_symdiff</strong>(<var>+Set1,
407 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="ord_symdiff/3"><strong>ord_symdiff</strong>(<var>+Set1,
449408 +Set2, ?Difference</var>)</a></dt>
450409 <dd class="defbody">
451410 Is true when <var>Difference</var> is the symmetric difference of <var>Set1</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section E.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="softlicense.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="summary.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:otherlicenses"><a id="sec:E.3"><span class="sec-nr">E.3</span> <span class="sec-title">License
194 <h2 id="sec:otherlicenses"><a name="sec:E.3"><span class="sec-nr">E.3</span> <span class="sec-title">License
236195 conditions inherited from used code</span></a></h2>
237196
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
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
241200 routines</span></a></h3>
242201
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>
202 <a name="sec:cryptlicense"></a>
203
204 <p>Cryptographic routines are used in <a name="idx:variantsha12:2347"></a><a class="pred" href="db.html#variant_sha1/2">variant_sha1/2</a>
246205 and <code>library(crypt)</code>. These routines are provided under the
247206 following conditions:
248207
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="metapred.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="mtoplevel.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:overrule"><a id="sec:6.5"><span class="sec-nr">6.5</span> <span class="sec-title">Overruling
194 <h2 id="sec:overrule"><a name="sec:6.5"><span class="sec-nr">6.5</span> <span class="sec-title">Overruling
236195 Module Boundaries</span></a></h2>
237196
238 <a id="sec:overrule"></a>
197 <a name="sec:overrule"></a>
239198
240199 <p>The module system described so far is sufficient to distribute
241200 programs over multiple modules. There are, however, cases in which we
247206 cannot be achieved using importing because importing a predicate with
248207 the same name and arity from two modules results in a name conflict.
249208 Asserting in a different module can be used to create models dynamically
250 in a new module. See <a class="sec" href="dynamic-modules.html#sec:6.12">section
209 in a new module. See <a class="sec" href="dynamic-modules.html">section
251210 6.12</a>.
252211
253212 <p>Direct addressing of modules is achieved using a <code><code>:</code>/2</code>
254213 explicitly in a program and relies on the module qualification mechanism
255 described in <a class="sec" href="metapred.html#sec:6.4">section 6.4</a>.
256 Here are a few examples:
214 described in <a class="sec" href="metapred.html">section 6.4</a>. Here
215 are a few examples:
257216
258217 <pre class="code">
259218 ?- assert(world:done). % asserts done/0 into module world
263222
264223 <p>Note that the second example is the same due to the Prolog flag
265224 <a class="flag" href="flags.html#flag:colon_sets_calling_context">colon_sets_calling_context</a>.
266 The system predicate <a id="idx:asserta1:1706"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
225 The system predicate <a name="idx:asserta1:1705"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
267226 is called in the module <code>world</code>, which is possible because
268227 system predicates are <em>visible</em> in all modules. At the same time,
269228 the
271230 arguments are qualified with the calling context, the resulting call is
272231 the same as the first example.
273232
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
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
275234 manipulation of the calling context</span></a></h3>
276235
277 <a id="sec:set-calling-context"></a>
236 <a name="sec:set-calling-context"></a>
278237
279238 <p>Quintus' derived module systems have no means to separate the lookup
280239 module (for finding predicates) from the calling context (for qualifying
284243 currently mainly to support compatibility layers.
285244
286245 <dl class="latex">
287 <dt class="pubdef"><a id="@/2"><strong>@</strong>(<var>:Goal, +Module</var>)</a></dt>
246 <dt class="pubdef"><a name="@/2"><strong>@</strong>(<var>:Goal, +Module</var>)</a></dt>
288247 <dd class="defbody">
289248 Execute <var>Goal</var>, setting the calling context to <var>Module</var>.
290249 Setting the calling context affects meta-predicates, for which meta
291250 arguments are qualified with <var>Module</var> and transparent
292251 predicates (see
293 <a id="idx:moduletransparent1:1707"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>).
252 <a name="idx:moduletransparent1:1706"></a><a class="pred" href="ctxmodule.html#module_transparent/1">module_transparent/1</a>).
294253 It has no implications for other predicates.
295254
296255 <p>For example, the code <code>asserta(done)@world</code> is the same as
297256 <code>asserta(world:done)</code>. Unlike in <code>world:asserta(done)</code>,
298 <a id="idx:asserta1:1708"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
257 <a name="idx:asserta1:1707"></a><a class="pred" href="db.html#asserta/1">asserta/1</a>
299258 is resolved in the current module rather than the module
300259 <code>world</code>. This makes no difference for system predicates, but
301260 usually does make a difference for user predicates.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="acknowledge.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="quickstart.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>
240199 <hr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.14</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="autoload.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="gc.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:packs"><a id="sec:2.14"><span class="sec-nr">2.14</span> <span class="sec-title">Packs:
194 <h2 id="sec:packs"><a name="sec:2.14"><span class="sec-nr">2.14</span> <span class="sec-title">Packs:
236195 community add-ons</span></a></h2>
237196
238 <a id="sec:packs"></a>
197 <a name="sec:packs"></a>
239198
240199 <p>SWI-Prolog has a mechanism for easy incorporation of community
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
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
245204 <code>library(prolog_pack)</code>.
246205
247206 <dl class="latex">
248 <dt class="pubdef"><a id="attach_packs/0"><strong>attach_packs</strong></a></dt>
207 <dt class="pubdef"><a name="attach_packs/0"><strong>attach_packs</strong></a></dt>
249208 <dd class="defbody">
250209 Attaches all packs in subdirectories of directories that are accessible
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>)
210 through the <em>file search path</em> (see <a name="idx:absolutefilename3:210"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>)
252211 <code>pack</code>. The default for this search path is:
253212
254213 <pre class="code">
256215 user:file_search_path(pack, swi(pack)).
257216 </pre>
258217
259 <p>The predicate <a id="idx:attachpacks0:209"></a><a class="pred" href="packs.html#attach_packs/0">attach_packs/0</a>
218 <p>The predicate <a name="idx:attachpacks0:211"></a><a class="pred" href="packs.html#attach_packs/0">attach_packs/0</a>
260219 is called on startup of SWI-Prolog.</dd>
261 <dt class="pubdef"><a id="attach_packs/1"><strong>attach_packs</strong>(<var>+Directory</var>)</a></dt>
220 <dt class="pubdef"><a name="attach_packs/1"><strong>attach_packs</strong>(<var>+Directory</var>)</a></dt>
262221 <dd class="defbody">
263222 Attach all packs in subdirectories of <var>Directory</var>. Same as
264223 <code>attach_packs(Directory,[])</code>.
265224 </dd>
266 <dt class="pubdef"><a id="attach_packs/2"><strong>attach_packs</strong>(<var>+Directory,
225 <dt class="pubdef"><a name="attach_packs/2"><strong>attach_packs</strong>(<var>+Directory,
267226 +Options</var>)</a></dt>
268227 <dd class="defbody">
269228 Attach all packs in subdirectories of <var>Directory</var>. Options is
285244 </dd>
286245 </dl>
287246
288 <p>The predicate <a id="idx:attachpacks2:210"></a><a class="pred" href="packs.html#attach_packs/2">attach_packs/2</a>
247 <p>The predicate <a name="idx:attachpacks2:212"></a><a class="pred" href="packs.html#attach_packs/2">attach_packs/2</a>
289248 can be used to attach packages that are bundled with an application.
290249 </dd>
291250 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.22</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ordsets.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="persistency.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:pairs"><a id="sec:A.22"><span class="sec-nr">A.22</span> <span class="sec-title">library(pairs):
194 <h2 id="sec:pairs"><a name="sec:A.22"><span class="sec-nr">A.22</span> <span class="sec-title">library(pairs):
236195 Operations on key-value lists</span></a></h2>
237196
238 <p><a id="sec:pairs"></a>
197 <p><a name="sec:pairs"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">author</dt>
259218 O'Keefe.
260219
261220 <dl class="latex">
262 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pairs_keys_values/3"><strong>pairs_keys_values</strong>(<var>?Pairs,
221 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pairs_keys_values/3"><strong>pairs_keys_values</strong>(<var>?Pairs,
263222 ?Keys, ?Values</var>)</a></dt>
264223 <dd class="defbody">
265224 True if <var>Keys</var> holds the keys of <var>Pairs</var> and <var>Values</var>
277236 </dl>
278237
279238 </dd>
280 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pairs_values/2"><strong>pairs_values</strong>(<var>+Pairs,
239 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pairs_values/2"><strong>pairs_values</strong>(<var>+Pairs,
281240 -Values</var>)</a></dt>
282241 <dd class="defbody">
283242 Remove the keys from a list of Key-Value pairs. Same as
284243 <code>pairs_keys_values(Pairs, _, Values)</code></dd>
285 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pairs_keys/2"><strong>pairs_keys</strong>(<var>+Pairs,
244 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pairs_keys/2"><strong>pairs_keys</strong>(<var>+Pairs,
286245 -Keys</var>)</a></dt>
287246 <dd class="defbody">
288247 Remove the values from a list of Key-Value pairs. Same as
289248 <code>pairs_keys_values(Pairs, Keys, _)</code></dd>
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,
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,
291250 -Joined:list(Key-Values)</var>)</a></dt>
292251 <dd class="defbody">
293252 Group values with equivalent (<a class="pred" href="compare.html#==/2">==/2</a>)
314273 is 1) ensures that the order of the values in the original list of pairs
315274 is maintained.
316275 <table class="arglist">
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
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
320279 consecutive Keys in the same order as they appear in <var>Pairs</var>. </td></tr>
321280 </table>
322281 </dd>
323 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="transpose_pairs/2"><strong>transpose_pairs</strong>(<var>+Pairs,
282 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="transpose_pairs/2"><strong>transpose_pairs</strong>(<var>+Pairs,
324283 -Transposed</var>)</a></dt>
325284 <dd class="defbody">
326285 Swap Key-Value to Value-Key. The resulting list is sorted using
327286 <a class="pred" href="builtinlist.html#keysort/2">keysort/2</a> on the
328287 new key.</dd>
329 <dt class="pubdef"><a id="map_list_to_pairs/3"><strong>map_list_to_pairs</strong>(<var>:Function,
288 <dt class="pubdef"><a name="map_list_to_pairs/3"><strong>map_list_to_pairs</strong>(<var>:Function,
330289 +List, -Keyed</var>)</a></dt>
331290 <dd class="defbody">
332291 Create a Key-Value list by mapping each element of <var>List</var>. For
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="editreload.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="guitracer.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:pceemacs"><a id="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Using
194 <h2 id="sec:pceemacs"><a name="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Using
236195 the PceEmacs built-in editor</span></a></h2>
237196
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
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
241200 PceEmacs</span></a></h3>
242201
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>
202 <a name="sec:runpceemacs"></a>
203
204 <p>Initially <a name="idx:edit1:311"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
246205 uses the editor specified in the <code>EDITOR</code> environment
247206 variable. There are two ways to force it to use the built-in editor. One
248207 is to set the Prolog flag <a class="flag" href="flags.html#flag:editor">editor</a>
249208 to
250209 <code>pce_emacs</code> and the other is by starting the editor
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
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
254213 through PceEmacs</span></a></h3>
255214
256 <a id="sec:emacsbluff"></a>
215 <a name="sec:emacsbluff"></a>
257216
258217 <p>PceEmacs closely mimics Richard Stallman's GNU-Emacs commands, adding
259218 features from modern window-based editors to make it more acceptable for
263222 important GNU-Emacs commands.</span></sup>
264223
265224 <p>At the basis, PceEmacs maps keyboard sequences to methods defined on
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
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
270229 Control-b</code>).
271230
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
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
273232 modes</span></a></h4>
274233
275 <a id="sec:pceemacsmodes"></a>
234 <a name="sec:pceemacsmodes"></a>
276235
277236 <p>Modes are the heart of (Pce)Emacs. Modes define dedicated editing
278237 support for a particular kind of (source) text. For our purpose we want
302261 Prolog mode explicitly.
303262 </ul>
304263
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
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
306265 used editor commands</span></a></h4>
307266
308 <a id="sec:pceemacscommands"></a>
267 <a name="sec:pceemacscommands"></a>
309268
310269 <p>Below we list a few important commands and how to activate them.
311270
407366 </ul>
408367
409368 <p>These are the most commonly used commands. In
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
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
414373 Mode</span></a></h3>
415374
416 <a id="sec:emacsprologmode"></a>
417
418 <p>In the previous section (<a class="sec" href="pceemacs.html#sec:3.4.2">section
375 <a name="sec:emacsprologmode"></a>
376
377 <p>In the previous section (<a class="sec" href="pceemacs.html">section
419378 3.4.2</a>) we explained the basics of PceEmacs. Here we continue with
420379 Prolog-specific functionality. Possibly the most interesting is <em>Syntax
421380 highlighting</em>. Unlike most editors where this is based on simple
466425 Other colours follow intuitive conventions. See <a class="tab" href="pceemacs.html#tab:plcolour">table
467426 3</a>.
468427
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>
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>
483447 </table>
484 <a id="tab:plcolour"></a>
448 <a name="tab:plcolour"></a>
485449 <div class="caption"><b>Table 3 : </b>Colour conventions</div>
486450
487451 <p><b>Layout support</b>
534498 calls (indented 1 tab), if-then-else, disjunction and argument lists
535499 broken across multiple lines as illustrated above.
536500
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
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
538502 your way around</span></a></h4>
539503
540 <a id="sec:pceemacshelp"></a>
504 <a name="sec:pceemacshelp"></a>
541505
542506 <p>The command <code>Alt-.</code> extracts name and arity from the caret
543507 location and jumps (after conformation or edit) to the definition of the
544508 predicate. It does so based on the source-location database of loaded
545 predicates also used by <a id="idx:edit1:310"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
509 predicates also used by <a name="idx:edit1:312"></a><a class="pred" href="edit.html#edit/1">edit/1</a>.
546510 This makes locating predicates reliable if all sources are loaded and
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>,
511 up-to-date (see <a name="idx:make0:313"></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:314"></a><a class="pred" href="import.html#use_module/1">use_module/[1,2]</a>, <a name="idx:consult1:315"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
550514 etc. are red if the file cannot be found and underlined blue if the file
551515 can be loaded. A popup allows for opening the referenced file.
552516
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.23</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="pairs.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="pio.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:persistency"><a id="sec:A.23"><span class="sec-nr">A.23</span> <span class="sec-title">library(persistency):
194 <h2 id="sec:persistency"><a name="sec:A.23"><span class="sec-nr">A.23</span> <span class="sec-title">library(persistency):
236195 Provide persistent dynamic predicates</span></a></h2>
237196
238 <p><a id="sec:persistency"></a>
197 <p><a name="sec:persistency"></a>
239198
240199 <dl class="tags">
241200 <dt class="mtag">To be done</dt>
304263 </pre>
305264
306265 <dl class="latex">
307 <dt class="pubdef"><a id="persistent/1"><strong>persistent</strong> <var>+Spec</var></a></dt>
266 <dt class="pubdef"><a name="persistent/1"><strong>persistent</strong> <var>+Spec</var></a></dt>
308267 <dd class="defbody">
309268 Declare dynamic database terms. Declarations appear in a directive and
310269 have the following format:
324283 </pre>
325284
326285 <p>Types are defined by <code>library(error)</code>.</dd>
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>
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>
328287 <dd class="defbody">
329288 True if <var>PI</var> is a predicate that provides access to the
330289 persistent database DB.</dd>
331 <dt class="pubdef"><a id="db_attach/2"><strong>db_attach</strong>(<var>:File,
290 <dt class="pubdef"><a name="db_attach/2"><strong>db_attach</strong>(<var>:File,
332291 +Options</var>)</a></dt>
333292 <dd class="defbody">
334293 Use <var>File</var> as persistent database for the calling module. The
346305
347306 <p>If <var>File</var> is already attached this operation may change the <code>sync</code>
348307 behaviour.</dd>
349 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="db_attached/1"><strong>db_attached</strong>(<var>:File</var>)</a></dt>
308 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="db_attached/1"><strong>db_attached</strong>(<var>:File</var>)</a></dt>
350309 <dd class="defbody">
351310 True if the context module attached to the persistent database <var>File</var>.</dd>
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="db_detach/0"><strong>db_detach</strong></a></dt>
311 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="db_detach/0"><strong>db_detach</strong></a></dt>
353312 <dd class="defbody">
354313 Detach persistency from the calling module and delete all persistent
355314 clauses from the Prolog database. Note that the file is not affected.
356315 After this operation another file may be attached, providing it
357316 satisfies the same persistency declaration.</dd>
358 <dt class="pubdef"><a id="db_sync/1"><strong>db_sync</strong>(<var>:What</var>)</a></dt>
317 <dt class="pubdef"><a name="db_sync/1"><strong>db_sync</strong>(<var>:What</var>)</a></dt>
359318 <dd class="defbody">
360319 Synchronise database with the associated file. <var>What</var> is one
361320 of:
399358 <p>With unbound <var>What</var>, <a class="pred" href="persistency.html#db_sync/1">db_sync/1</a>
400359 reloads the database if it was modified on disk, gc it if it is dirty
401360 and close it if it is opened.</dd>
402 <dt class="pubdef"><a id="db_sync_all/1"><strong>db_sync_all</strong>(<var>+What</var>)</a></dt>
361 <dt class="pubdef"><a name="db_sync_all/1"><strong>db_sync_all</strong>(<var>+What</var>)</a></dt>
403362 <dd class="defbody">
404363 Sync all registered databases.
405364 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.24</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="persistency.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="predicate_options.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:pio"><a id="sec:A.24"><span class="sec-nr">A.24</span> <span class="sec-title">library(pio):
194 <h2 id="sec:pio"><a name="sec:A.24"><span class="sec-nr">A.24</span> <span class="sec-title">library(pio):
236195 Pure I/O</span></a></h2>
237196
238 <a id="sec:pio"></a>
239 <a id="sec:lib:pio"></a>
197 <a name="sec:pio"></a>
198 <a name="sec:lib:pio"></a>
240199
241200 <p>This library provides pure list-based I/O processing for Prolog,
242201 where the communication to the actual I/O device is performed
243202 transparently through coroutining. This module itself is just an
244203 interface to the actual implementation modules.
245204
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):
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):
247206 Pure Input from files and streams</span></a></h3>
248207
249 <p><a id="sec:pureinput"></a>
208 <p><a name="sec:pureinput"></a>
250209
251210 <dl class="tags">
252211 <dt class="tag">To be done</dt>
273232 attribute handling to realise pure input on any (buffered) stream.
274233
275234 <dl class="latex">
276 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="phrase_from_file/2"><strong>phrase_from_file</strong>(<var>:Grammar,
235 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="phrase_from_file/2"><strong>phrase_from_file</strong>(<var>:Grammar,
277236 +File</var>)</a></dt>
278237 <dd class="defbody">
279238 Process the content of <var>File</var> using the DCG rule <var>Grammar</var>.
283242 on demand due to unification of the attributed tail variable. Below is
284243 an example that counts the number of times a string appears in a file.
285244 The library dcg/basics provides
286 <span class="pred-ext">string//1</span> matching an arbitrary string and <span class="pred-ext">remainder//1</span>
245 <span class="pred-ext">string/3</span> matching an arbitrary string and <span class="pred-ext">remainder/3</span>
287246 which matches the remainder of the input without parsing.
288247
289248 <pre class="code">
309268 </pre>
310269
311270 </dd>
312 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="phrase_from_file/3"><strong>phrase_from_file</strong>(<var>:Grammar,
271 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="phrase_from_file/3"><strong>phrase_from_file</strong>(<var>:Grammar,
313272 +File, +Options</var>)</a></dt>
314273 <dd class="defbody">
315274 As <a class="pred" href="pio.html#phrase_from_file/2">phrase_from_file/2</a>,
316275 providing additional <var>Options</var>. <var>Options</var> are passed
317276 to <a class="pred" href="IO.html#open/4">open/4</a>.</dd>
318 <dt class="pubdef"><a id="phrase_from_stream/2"><strong>phrase_from_stream</strong>(<var>:Grammar,
277 <dt class="pubdef"><a name="phrase_from_stream/2"><strong>phrase_from_stream</strong>(<var>:Grammar,
319278 +Stream</var>)</a></dt>
320279 <dd class="defbody">
321280 Run Grammer against the character codes on <var>Stream</var>. <var>Stream</var>
322281 must be buffered.</dd>
323 <dt class="pubdef"><a id="syntax_error//1"><strong>syntax_error</strong>(<var>+Error</var>)</a><code>//</code></dt>
282 <dt class="pubdef"><a name="syntax_error/1"><strong>syntax_error</strong>(<var>+Error</var>)</a><code>//</code></dt>
324283 <dd class="defbody">
325284 Throw the syntax error <var>Error</var> at the current location of the
326285 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>.
333292 </dl>
334293
335294 </dd>
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>
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>
337296 <dd class="defbody">
338297 Determine current (error) location in a lazy list. True when
339298 <var>Location</var> is an (error) location term that represents the
340299 current location in the DCG list.
341300 <table class="arglist">
342 <tr><td><var>Location</var> </td><td>is a term <code>file(Name, Line, LinePos, CharNo)</code>
301 <tr valign="top"><td><var>Location</var> </td><td>is a term <code>file(Name, Line, LinePos, CharNo)</code>
343302 or
344303 <code>stream(Stream, Line, LinePos, CharNo)</code> if no file is
345304 associated to the stream RestLazyList. Finally, if the Lazy list is
350309 <dl class="tags">
351310 <dt class="tag">See also</dt>
352311 <dd>
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>
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>
360319 <dd class="defbody">
361320 True when <var>CharCount</var> is the current character count in the
362321 Lazy list. The character count is computed by finding the distance to
371330 <dl class="tags">
372331 <dt class="tag">See also</dt>
373332 <dd>
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,
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,
381340 -List</var>)</a></dt>
382341 <dd class="defbody">
383342 Create a lazy list representing the character codes in <var>Stream</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 11.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreigninclude.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="findhome.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:plld"><a id="sec:11.5"><span class="sec-nr">11.5</span> <span class="sec-title">Linking
194 <h2 id="sec:plld"><a name="sec:11.5"><span class="sec-nr">11.5</span> <span class="sec-title">Linking
236195 embedded applications using swipl-ld</span></a></h2>
237196
238 <a id="sec:plld"></a>
197 <a name="sec:plld"></a>
239198
240199 <p>The utility program <b>swipl-ld</b> (Win32: swipl-ld.exe) may be used
241200 to link a combination of C files and Prolog files into a stand-alone
308267 <dt><strong>-shared</strong> <var></var></dt>
309268 <dd class="defbody">
310269 Link C, C++ or object files into a shared object (DLL) that can be
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>
270 loaded by the <a name="idx:loadforeignlibrary1:2090"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
312271 predicate. If used with
313272 <strong>-c</strong> it sets the proper options to compile a C or C++
314273 file ready for linking into a shared object.</dd>
395354 </dd>
396355 </dl>
397356
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
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
399358 simple example</span></a></h3>
400359
401 <a id="sec:foreign-example"></a>
360 <a name="sec:foreign-example"></a>
402361
403362 <p>The following is a very simple example going through all the steps
404363 outlined above. It provides an arithmetic expression evaluator. We will
468427 </pre>
469428
470429 <div class="caption"><b>Figure 9 : </b>C source for the calc application</div>
471 <a id="fig:calc"></a>
430 <a name="fig:calc"></a>
472431
473432 <p>The application is now created using the following command line:
474433
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section C.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="dialect.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="glossary.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:portabilitystrategies"><a id="sec:C.1"><span class="sec-nr">C.1</span> <span class="sec-title">Some
194 <h2 id="sec:portabilitystrategies"><a name="sec:C.1"><span class="sec-nr">C.1</span> <span class="sec-title">Some
236195 considerations for writing portable code</span></a></h2>
237196
238 <a id="sec:portabilitystrategies"></a>
197 <a name="sec:portabilitystrategies"></a>
239198
240199 <p>The traditional way to write portable code is to define custom
241200 predicates for all potentially non-portable code and define these
251210 the defined semantics are those of dialect <var>X</var>. Emulating all
252211 extreme cases and full error handling compatibility may be tedious and
253212 result in a much slower implementation that needed. Take for example
254 <a id="idx:callcleanup2:2260"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
213 <a name="idx:callcleanup2:2259"></a><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a>.
255214 The SICStus definition is fundamentally different from the SWI
256215 definition, but 99% of the applications just want to make calls like
257216 below to guarantee <var>StreamIn</var> is closed, even if process/1
279238 keeping compatibility with the original dialect(s). This problem is well
280239 known from the C/Unix world and we advise anyone to study the philosophy
281240 of
282 <a class="url" href="http://www.gnu.org/software/autoconf/">GNU autoconf</a>,
283 from which we will illustrate some highlights below.
241 http://www.gnu.org/software/autoconf/GNU autoconf , from which we will
242 illustrate some highlights below.
284243 </ul>
285244
286245 <p>The GNU autoconf suite, known to most people as <b>configure</b>, was
289248 dialects today. Writing a portable C program can only be achieved using
290249 cpp, the C preprocessor. The C preprocessor performs two tasks: macro
291250 expansion and conditional compilation. Prolog realises macro expansion
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>.
251 through <a name="idx:termexpansion2:2260"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
252 and <a name="idx:goalexpansion2:2261"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>.
294253 Conditional compilation is achieved using <code>:- if(Condition)</code>
295254 as explained in
296 <a class="sec" href="consulting.html#sec:4.3.1.2">section 4.3.1.2</a>.
297 The situation appears similar.
255 <a class="sec" href="consulting.html">section 4.3.1.2</a>. The situation
256 appears similar.
298257
299258 <p>The important lesson learned from GNU autoconf is that the <em>last</em>
300259 resort for conditional compilation to achieve portability is to switch
312271
313272 <p>We must learn from the distinction to test for features instead of
314273 platform (dialect), as this makes the platform-specific code robust for
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>
274 future changes of the dialect. Suppose we need <a name="idx:compare3:2262"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
275 as defined in this manual. The <a name="idx:compare3:2263"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
317276 predicate is not part of the ISO standard, but many systems support it
318277 and it is not unlikely it will become ISO standard or the intended
319278 dialect will start supporting it. GNU autoconf strongly advises to test
334293 dialect and, possibly at least as important, will provide compatibility
335294 with dialects you didn't even consider porting to right now.
336295
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>,
296 <p>In a more challenging case, the target Prolog has <a name="idx:compare3:2264"></a><a class="pred" href="compare.html#compare/3">compare/3</a>,
338297 but the semantics are different. What to do? One option is to write a
339 <a id="idx:mycompare3:2266"></a><span class="pred-ext">my_compare/3</span>
298 <a name="idx:mycompare3:2265"></a><span class="pred-ext">my_compare/3</span>
340299 and change all occurrences in the code. Alternatively you can rename
341 calls using <a id="idx:goalexpansion2:2267"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
300 calls using <a name="idx:goalexpansion2:2266"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>
342301 like below. This construct will not only deal with Prolog dialects
343 lacking <a id="idx:compare3:2268"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
302 lacking <a name="idx:compare3:2267"></a><a class="pred" href="compare.html#compare/3">compare/3</a>
344303 as well as those that only implement it for numeric comparison or have
345304 changed the argument order. Of course, writing rock-solid code would
346305 require a complete test-suite, but this example will probably cover all
347306 Prolog dialects that allow for conditional compilation, have core ISO
348 facilities and provide <a id="idx:goalexpansion2:2269"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>,
307 facilities and provide <a name="idx:goalexpansion2:2268"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a>,
349308 the things we claim a Prolog dialect should have to start writing
350309 portable code for it.
351310
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="SyntaxAndSemantics.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="debugging.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:practical"><a id="sec:8.3"><span class="sec-nr">8.3</span> <span class="sec-title">CHR
194 <h2 id="sec:practical"><a name="sec:8.3"><span class="sec-nr">8.3</span> <span class="sec-title">CHR
236195 in SWI-Prolog Programs</span></a></h2>
237196
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
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
240199 in Prolog Programs</span></a></h3>
241200
242 <a id="sec:chr-embedding"></a>
201 <a name="sec:chr-embedding"></a>
243202
244203 <p>The CHR constraints defined in a <code>.pl</code> file are associated
245204 with a module. The default module is <code>user</code>. One should never
246205 load different <code>.pl</code> files with the same CHR module name.
247206
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
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
249208 declaration</span></a></h3>
250209
251 <a id="sec:chr-declarations"></a>
210 <a name="sec:chr-declarations"></a>
252211
253212 <dl class="latex">
254 <dt class="pubdef"><a id="chr_constraint/1">:- <strong>chr_constraint</strong>(<var>+Specifier</var>)</a></dt>
213 <dt class="pubdef"><a name="chr_constraint/1">:- <strong>chr_constraint</strong>(<var>+Specifier</var>)</a></dt>
255214 <dd class="defbody">
256215 Every constraint used in CHR rules has to be declared with a
257 <a id="idx:chrconstraint1:1815"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
216 <a name="idx:chrconstraint1:1814"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
258217 declaration by the <em>constraint specifier</em>. For convenience
259218 multiple constraints may be declared at once with the same
260219 <a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
352311 </dl>
353312
354313 <dl class="latex">
355 <dt class="pubdef"><a id="chr_type/1">:- <strong>chr_type</strong>(<var>+TypeDeclaration</var>)</a></dt>
314 <dt class="pubdef"><a name="chr_type/1">:- <strong>chr_type</strong>(<var>+TypeDeclaration</var>)</a></dt>
356315 <dd class="defbody">
357316 User-defined types are algebraic data types, similar to those in Haskell
358317 or the discriminated unions in Mercury. An algebraic data type is
359 defined using <a id="idx:chrtype1:1816"></a><a class="pred" href="practical.html#chr_type/1">chr_type/1</a>:
318 defined using <a name="idx:chrtype1:1815"></a><a class="pred" href="practical.html#chr_type/1">chr_type/1</a>:
360319
361320 <pre class="code">
362321 :- chr_type type ---&gt; body.
490449 runtime overhead.
491450 </ol>
492451
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>
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:1816"></a><a class="pred" href="consulting.html#term_expansion/2">term_expansion/2</a>
496455 rules to translate the constraint handling rules to plain Prolog. These
497456 rules are loaded from the library <code>library(chr)</code>. They are
498457 activated if the compiled file has the <code>.chr</code> extension or
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="builtin.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="chars.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:preddesc"><a id="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Notation
194 <h2 id="sec:preddesc"><a name="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Notation
236195 of Predicate Descriptions</span></a></h2>
237196
238 <a id="sec:preddesc"></a>
197 <a name="sec:preddesc"></a>
239198
240199 <p>We have tried to keep the predicate descriptions clear and concise.
241200 First, the predicate name is printed in bold face, followed by the
247206 (-,+) are described as (?,?). The <code>@</code>-mode is often replaced
248207 by <code><code>+</code></code>.</span></sup>
249208
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
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
256215 <code>[_]</code> is a <em>list</em>, although its only member is
257216 unbound. </td></tr>
258 <tr><td>-</td><td>Argument is an <em>output</em> argument. Unless
259 specified otherwise, output arguments need not to be unbound. For
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
260219 example, the goal <code>findall(X, Goal, [T])</code> is good style and
261220 equivalent to <code>findall(X, Goal, Xs), Xs = [T]</code><sup class="fn">44<span class="fn-text">The
262221 ISO standard dictates that <code>findall(X, Goal, 1)</code> raises a <code>type_error</code>
264223 the standard here.</span></sup> Note that the
265224 <em>determinism</em> specification, e.g., ``det'' only applies if this
266225 argument is unbound. </td></tr>
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>
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:336"></a><a class="pred" href="IO.html#open/3">open/3</a>
270229 which creates a <em>stream</em>. </td></tr>
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
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
274234 <em>both</em> input and output. For example, in
275235 <code>stream_property(S, reposition(Bool))</code>, the <code>reposition</code>
276236 part of the term is input and the uninstantiated <var>Bool</var> is
277237 output. </td></tr>
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
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
280240 information on module handling. </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>
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:337"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>
246 or <a name="idx:nbsetarg3:338"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>. </td></tr>
287247 </table>
288248
289 <p><a id="idx:predicateindicator:337"></a>Referring to a predicate in
249 <p><a name="idx:predicateindicator:339"></a>Referring to a predicate in
290250 running text is done using a
291251 <em>predicate indicator</em>. The canonical and most generic form of a
292252 predicate indicator is a term &lt;<var>module</var>&gt;:&lt;<var>name</var>&gt;/&lt;<var>arity</var>&gt;.
293253 If the module is irrelevant (built-in predicate) or can be inferred from
294254 the context it is often omitted. Compliant to the ISO standard draft on
295255 DCG (see
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;
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;
298258 to refer to a grammar rule. For all non-negative arity, &lt;<var>name</var>&gt;//&lt;<var>arity</var>&gt;
299259 is the same as &lt;<var>name</var>&gt;/&lt;<var>arity</var>&gt;+2,
300260 regardless of whether or not the referenced predicate is defined or can
301261 be used as a grammar rule. The //-notation can be used in all places
302262 that traditionally allow for a predicate indicator, e.g., the module
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>.
263 declaration, <a name="idx:spy1:340"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
264 and <a name="idx:dynamic1:341"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>.
305265
306266 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.25</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="pio.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="prologpack.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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):
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):
236195 Declare option-processing of predicates</span></a></h2>
237196
238 <a id="sec:predicate_options"></a>
197 <a name="sec:predicate_options"></a>
239198
240199 <p><i>Discussions with Jeff Schultz helped shaping this library</i>
241200
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
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
243202 strength and weakness of predicate options</span></a></h3>
244203
245 <p><a id="sec:predopts-pro-cons"></a>
204 <p><a name="sec:predopts-pro-cons"></a>
246205
247206 <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>.
248207 Options offer an attractive alternative to proliferation into many
299258 Unfortunately, the consequences of a partial emulation cannot be
300259 assessed by tools.
301260
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
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
303262 as arguments or environment?</span></a></h3>
304263
305 <p><a id="sec:predopts-environment"></a>
264 <p><a name="sec:predopts-environment"></a>
306265
307266 <p>We distinguish two views on options. One is to see them as additional
308267 parameters that require strict existence, type and domain-checking and
335294 mistyped options are silently ignored. The option infrastructure
336295 described in this section tries to remedy these problems.
337296
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
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
339298 on the current situation</span></a></h3>
340299
341 <p><a id="sec:predopts-improving"></a>
300 <p><a name="sec:predopts-improving"></a>
342301
343302 <p>Whether we see options as arguments or locally scoped environment
344303 variables, the most obvious way to improve on the current situation is
347306 options can be used by the compiler and development environment as well
348307 as by the runtime system to warn or throw errors.
349308
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
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
351310 as types</span></a></h4>
352311
353 <p><a id="sec:predopts-as-types"></a>
312 <p><a name="sec:predopts-as-types"></a>
354313
355314 <p>An obvious approach to deal with options is to define the different
356315 possible option values as a type and type the argument that processes
378337 code.
379338 </ul>
380339
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
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
382341 access to options</span></a></h4>
383342
384 <p><a id="sec:predopts-reflextion"></a>
343 <p><a name="sec:predopts-reflextion"></a>
385344
386345 <p>From the above, we conclude that we require reflective access to find
387346 out whether an option is supported and valid for a particular predicate.
390349 values. Predicate options are declared using <a class="pred" href="predicate_options.html#predicate_options/3">predicate_options/3</a>:
391350
392351 <dl class="latex">
393 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="predicate_options/3"><strong>predicate_options</strong>(<var>:PI,
352 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="predicate_options/3"><strong>predicate_options</strong>(<var>:PI,
394353 +Arg, +Options</var>)</a></dt>
395354 <dd class="defbody">
396355 Declare that the predicate <var>PI</var> processes options on <var>Arg</var>. <var>Options</var>
427386 processed by <a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>.
428387 Option processing can be specified at runtime using <span class="pred-ext">assert_predicate_options/3</span>,
429388 which is intended to support program analysis.</dd>
430 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="assert_predicate_options/4"><strong>assert_predicate_options</strong>(<var>:PI,
389 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="assert_predicate_options/4"><strong>assert_predicate_options</strong>(<var>:PI,
431390 +Arg, +Options, ?New</var>)</a></dt>
432391 <dd class="defbody">
433392 As predicate_options(:<var>PI</var>, +<var>Arg</var>, +<var>Options</var>). <var>New</var>
441400 checking for supported options.
442401
443402 <dl class="latex">
444 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_predicate_option/3"><strong>current_predicate_option</strong>(<var>:PI,
403 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_predicate_option/3"><strong>current_predicate_option</strong>(<var>:PI,
445404 ?Arg, ?Option</var>)</a></dt>
446405 <dd class="defbody">
447406 True when <var>Arg</var> of <var>PI</var> processes <var>Option</var>.
457416 predicate
458417 <a class="pred" href="predicate_options.html#current_predicate_options/3">current_predicate_options/3</a>
459418 can be used to access the full capabilities of a predicate.</dd>
460 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="check_predicate_option/3"><strong>check_predicate_option</strong>(<var>:PI,
419 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="check_predicate_option/3"><strong>check_predicate_option</strong>(<var>:PI,
461420 +Arg, +Option</var>)</a></dt>
462421 <dd class="defbody">
463422 Verify predicate options at runtime. Similar to
482441 colouring option names and values.
483442
484443 <dl class="latex">
485 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_option_arg/2"><strong>current_option_arg</strong>(<var>:PI,
444 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_option_arg/2"><strong>current_option_arg</strong>(<var>:PI,
486445 ?Arg</var>)</a></dt>
487446 <dd class="defbody">
488447 True when <var>Arg</var> of <var>PI</var> processes predicate options.
489448 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>
490 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="current_predicate_options/3"><strong>current_predicate_options</strong>(<var>:PI,
449 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="current_predicate_options/3"><strong>current_predicate_options</strong>(<var>:PI,
491450 ?Arg, ?Options</var>)</a></dt>
492451 <dd class="defbody">
493452 True when <var>Options</var> is the current active option declaration
503462 <a class="pred" href="predicate_options.html#check_predicate_options/0">check_predicate_options/0</a>:
504463
505464 <dl class="latex">
506 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="check_predicate_options/0"><strong>check_predicate_options</strong></a></dt>
465 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="check_predicate_options/0"><strong>check_predicate_options</strong></a></dt>
507466 <dd class="defbody">
508467 Analyse loaded program for erroneous options. This predicate decompiles
509468 the current program and searches for calls to predicates that process
529488 the module system.
530489
531490 <dl class="latex">
532 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="derive_predicate_options/0"><strong>derive_predicate_options</strong></a></dt>
491 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="derive_predicate_options/0"><strong>derive_predicate_options</strong></a></dt>
533492 <dd class="defbody">
534493 Derive new predicate option declarations. This predicate analyses the
535494 loaded program to find clauses that process options using one of the
546505 </dl>
547506
548507 </dd>
549 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="retractall_predicate_options/0"><strong>retractall_predicate_options</strong></a></dt>
508 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="retractall_predicate_options/0"><strong>retractall_predicate_options</strong></a></dt>
550509 <dd class="defbody">
551510 Remove all dynamically (derived) predicate options.</dd>
552 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="derived_predicate_options/3"><strong>derived_predicate_options</strong>(<var>:PI,
511 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="derived_predicate_options/3"><strong>derived_predicate_options</strong>(<var>:PI,
553512 ?Arg, ?Options</var>)</a></dt>
554513 <dd class="defbody">
555514 Derive option arguments using static analysis. True when <var>Options</var>
556515 is the current <i>derived</i> active option declaration for <var>PI</var>
557516 on
558517 <var>Arg</var>.</dd>
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>
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>
560519 <dd class="defbody">
561520 Derive predicate option declarations for a module. The derived options
562521 are printed to the <code>current_output</code> stream.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section F.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="summary.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="library.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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:2348"></a><a class="pred" href="help.html#apropos/1">apropos/1</a>
240199 to suggest predicates from a keyword.
241200 <table>
242201 <tr><td><a class="pred" href="overrule.html#@/2">@/2</a></td><td>Call
245204 (discard choicepoints)</td></tr>
246205 <tr><td><a class="pred" href="control.html#,/2">,/2</a></td><td>Conjunction
247206 of goals</td></tr>
248 <tr><td><a class="pred" href="control.html#->/2">-&gt;/2</a></td><td>If-then-else</td></tr>
207 <tr><td><span class="pred-ext">-&gt;/2</span></td><td>If-then-else</td></tr>
249208 <tr><td><a class="pred" href="control.html#*->/2">*-&gt;/2</a></td><td>Soft-cut</td></tr>
250209 <tr><td><span class="pred-ext">./2</span></td><td>Consult. Also
251210 functional notation</td></tr>
286245 <tr><td><a class="pred" href="compare.html#@>=/2">@&gt;=/2</a></td><td>Standard
287246 order larger or equal</td></tr>
288247 <tr><td><a class="pred" href="control.html#\+/1">\+/1</a></td><td>Negation
289 by failure. Same as <a id="idx:not1:2350"></a><a class="pred" href="metacall.html#not/1">not/1</a></td></tr>
248 by failure. Same as <a name="idx:not1:2349"></a><a class="pred" href="metacall.html#not/1">not/1</a></td></tr>
290249 <tr><td><a class="pred" href="compare.html#\=/2">\=/2</a></td><td>True
291250 if arguments cannot be unified</td></tr>
292251 <tr><td><a class="pred" href="compare.html#\==/2">\==/2</a></td><td>True
294253 <tr><td><a class="pred" href="compare.html#\=@=/2">\=@=/2</a></td><td>Not
295254 structural identical</td></tr>
296255 <tr><td><span class="pred-ext">^/2</span></td><td>Existential
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>
256 quantification (<a name="idx:bagof3:2350"></a><a class="pred" href="allsolutions.html#bagof/3">bagof/3</a>, <a name="idx:setof3:2351"></a><a class="pred" href="allsolutions.html#setof/3">setof/3</a>)</td></tr>
298257 <tr><td><a class="pred" href="control.html#|/2">|/2</a></td><td>Disjunction
299258 in DCGs. Same as <a class="pred" href="control.html#;/2">;/2</a></td></tr>
300259 <tr><td><span class="pred-ext">/1</span></td><td>DCG escape; constraints</td></tr>
367326 <tr><td><a class="pred" href="chario.html#at_end_of_stream/1">at_end_of_stream/1</a></td><td>Test
368327 for end of file on stream</td></tr>
369328 <tr><td><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a></td><td>Register
370 goal to run at <a id="idx:halt1:2353"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a></td></tr>
329 goal to run at <a name="idx:halt1:2352"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a></td></tr>
371330 <tr><td><a class="pred" href="typetest.html#atom/1">atom/1</a></td><td>Type
372331 check for an atom</td></tr>
373332 <tr><td><a class="pred" href="manipatom.html#atom_chars/2">atom_chars/2</a></td><td>Convert
428387 a goal with a cleaup-handler</td></tr>
429388 <tr><td><a class="pred" href="metacall.html#call_cleanup/2">call_cleanup/2</a></td><td>Guard
430389 a goal with a cleaup-handler</td></tr>
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>
390 <tr><td><a class="pred" href="DCG.html#call_dcg/3">call_dcg/3</a></td><td>As <a name="idx:phrase3:2353"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>
432391 without type checking</td></tr>
433392 <tr><td><a class="pred" href="coroutining.html#call_residue_vars/2">call_residue_vars/2</a></td><td>Find
434393 residual attributed variables</td></tr>
440399 goal in limited inferences</td></tr>
441400 <tr><td><a class="pred" href="typetest.html#callable/1">callable/1</a></td><td>Test
442401 for atom or compound term</td></tr>
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>
402 <tr><td><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a></td><td>Cancel <a name="idx:halt0:2354"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
403 from an <a name="idx:athalt1:2355"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>
445404 hook</td></tr>
446405 <tr><td><a class="pred" href="exception.html#catch/3">catch/3</a></td><td>Call
447406 goal, watching for exceptions</td></tr>
490449 <tr><td><a class="pred" href="compare.html#compare/3">compare/3</a></td><td>Compare,
491450 using a predicate to determine the order</td></tr>
492451 <tr><td><a class="pred" href="consulting.html#compile_aux_clauses/1">compile_aux_clauses/1</a></td><td>Compile
493 predicates for <a id="idx:goalexpansion2:2357"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a></td></tr>
452 predicates for <a name="idx:goalexpansion2:2356"></a><a class="pred" href="consulting.html#goal_expansion/2">goal_expansion/2</a></td></tr>
494453 <tr><td><a class="pred" href="dynamic.html#compile_predicates/1">compile_predicates/1</a></td><td>Compile
495454 dynamic code to static</td></tr>
496455 <tr><td><a class="pred" href="consulting.html#compiling/0">compiling/0</a></td><td>Is
598557 <tr><td><a class="pred" href="debug.html#debug/3">debug/3</a></td><td>Print
599558 debugging message on topic</td></tr>
600559 <tr><td><span class="pred-ext">debug_control_hook/1</span></td><td><i>(hook)</i>
601 Extend <a id="idx:spy1:2358"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
560 Extend <a name="idx:spy1:2357"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>,
602561 etc.</td></tr>
603562 <tr><td><a class="pred" href="debugger.html#debugging/0">debugging/0</a></td><td>Show
604563 debugger status</td></tr>
737696 <tr><td><a class="pred" href="allsolutions.html#findall/3">findall/3</a></td><td>Find
738697 all solutions to a goal</td></tr>
739698 <tr><td><a class="pred" href="allsolutions.html#findall/4">findall/4</a></td><td>Difference
740 list version of <a id="idx:findall3:2359"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a></td></tr>
699 list version of <a name="idx:findall3:2358"></a><a class="pred" href="allsolutions.html#findall/3">findall/3</a></td></tr>
741700 <tr><td><a class="pred" href="allsolutions.html#findnsols/4">findnsols/4</a></td><td>Find
742701 first <var>N</var> solutions</td></tr>
743702 <tr><td><a class="pred" href="allsolutions.html#findnsols/5">findnsols/5</a></td><td>Difference
744 list version of <a id="idx:findnsols4:2360"></a><a class="pred" href="allsolutions.html#findnsols/4">findnsols/4</a></td></tr>
703 list version of <a name="idx:findnsols4:2359"></a><a class="pred" href="allsolutions.html#findnsols/4">findnsols/4</a></td></tr>
745704 <tr><td><a class="pred" href="chario.html#fill_buffer/1">fill_buffer/1</a></td><td>Fill
746705 the input buffer of a stream</td></tr>
747706 <tr><td><a class="pred" href="db.html#flag/3">flag/3</a></td><td>Simple
764723 strftime() like date/time formatter</td></tr>
765724 <tr><td><a class="pred" href="system.html#format_time/4">format_time/4</a></td><td>date/time
766725 formatter with explicit locale</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>
726 <tr><td><a class="pred" href="format.html#format_predicate/2">format_predicate/2</a></td><td>Program <a name="idx:format12:2360"></a><a class="pred" href="format.html#format/1">format/[1,2]</a></td></tr>
768727 <tr><td><a class="pred" href="attvar.html#term_attvars/2">term_attvars/2</a></td><td>Find
769728 attributed variables in a term</td></tr>
770729 <tr><td><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a></td><td>Find
783742 the garbage collector</td></tr>
784743 <tr><td><a class="pred" href="memory.html#garbage_collect_atoms/0">garbage_collect_atoms/0</a></td><td>Invoke
785744 the atom garbage collector</td></tr>
786 <tr><td><a class="pred" href="consulting.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a></td><td>Invoke
745 <tr><td><a class="pred" href="memory.html#garbage_collect_clauses/0">garbage_collect_clauses/0</a></td><td>Invoke
787746 clause garbage collector</td></tr>
788747 <tr><td><a class="pred" href="assoc.html#gen_assoc/3">gen_assoc/3</a></td><td>Enumerate
789748 members of association tree</td></tr>
979938 between dict and list of pairs</td></tr>
980939 <tr><td><a class="pred" href="assoc.html#max_assoc/3">max_assoc/3</a></td><td>Highest
981940 key in association tree</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>
941 <tr><td><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a></td><td>Deterministic <a name="idx:member2:2361"></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:2362"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a></td></tr>
984943 <tr><td><span class="pred-ext">message_line_element/2</span></td><td><i>(hook)</i>
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>
944 Intercept <a name="idx:printmessagelines3:2363"></a><a class="pred" href="exception.html#print_message_lines/3">print_message_lines/3</a></td></tr>
986945 <tr><td><a class="pred" href="exception.html#message_property/2">message_property/2</a></td><td><i>(hook)</i>
987946 Define display of a message</td></tr>
988947 <tr><td><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a></td><td>Create
11561115 <tr><td><a class="pred" href="arith.html#plus/3">plus/3</a></td><td>Logical
11571116 integer addition</td></tr>
11581117 <tr><td><a class="pred" href="termrw.html#portray/1">portray/1</a></td><td><i>(hook)</i>
1159 Modify behaviour of <a id="idx:print1:2365"></a><a class="pred" href="termrw.html#print/1">print/1</a></td></tr>
1118 Modify behaviour of <a name="idx:print1:2364"></a><a class="pred" href="termrw.html#print/1">print/1</a></td></tr>
11601119 <tr><td><a class="pred" href="listing.html#portray_clause/1">portray_clause/1</a></td><td>Pretty
11611120 print a clause</td></tr>
11621121 <tr><td><a class="pred" href="listing.html#portray_clause/2">portray_clause/2</a></td><td>Pretty
11831142 status of the profiler</td></tr>
11841143 <tr><td><a class="pred" href="toplevel.html#prolog/0">prolog/0</a></td><td>Run
11851144 interactive top level</td></tr>
1145 <tr><td><a class="pred" href="signal.html#prolog_alert_signal/2">prolog_alert_signal/2</a></td><td>Query/set
1146 unblock signal</td></tr>
11861147 <tr><td><a class="pred" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a></td><td>Examine
11871148 the choice point stack</td></tr>
11881149 <tr><td><a class="pred" href="manipstack.html#prolog_current_choice/1">prolog_current_choice/1</a></td><td>Reference
11921153 <tr><td><a class="pred" href="ancestral-cut.html#prolog_cut_to/1">prolog_cut_to/1</a></td><td>Realise
11931154 global cuts</td></tr>
11941155 <tr><td><a class="pred" href="edit.html#prolog_edit:locate/2">prolog_edit:locate/2</a></td><td>Locate
1195 targets for <a id="idx:edit1:2366"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
1156 targets for <a name="idx:edit1:2365"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
11961157 <tr><td><a class="pred" href="edit.html#prolog_edit:locate/3">prolog_edit:locate/3</a></td><td>Locate
1197 targets for <a id="idx:edit1:2367"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
1158 targets for <a name="idx:edit1:2366"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
11981159 <tr><td><a class="pred" href="edit.html#prolog_edit:edit_source/1">prolog_edit:edit_source/1</a></td><td>Call
1199 editor for <a id="idx:edit1:2368"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
1160 editor for <a name="idx:edit1:2367"></a><a class="pred" href="edit.html#edit/1">edit/1</a></td></tr>
12001161 <tr><td><a class="pred" href="edit.html#prolog_edit:edit_command/2">prolog_edit:edit_command/2</a></td><td>Specify
12011162 editor activation</td></tr>
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>
1163 <tr><td><a class="pred" href="edit.html#prolog_edit:load/0">prolog_edit:load/0</a></td><td>Load <a name="idx:edit1:2368"></a><a class="pred" href="edit.html#edit/1">edit/1</a>
12031164 extensions</td></tr>
12041165 <tr><td><a class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</a></td><td>Rewrite
12051166 exceptions</td></tr>
12141175 <tr><td><a class="pred" href="consulting.html#prolog_load_context/2">prolog_load_context/2</a></td><td>Context
12151176 information for directives</td></tr>
12161177 <tr><td><a class="pred" href="loadfilehook.html#prolog_load_file/2">prolog_load_file/2</a></td><td><i>(hook)</i>
1217 Program <a id="idx:loadfiles2:2370"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a></td></tr>
1178 Program <a name="idx:loadfiles2:2369"></a><a class="pred" href="consulting.html#load_files/2">load_files/2</a></td></tr>
12181179 <tr><td><a class="pred" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a></td><td>Indicate
12191180 deepest recursion to trace</td></tr>
12201181 <tr><td><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a></td><td>Perform
12301191 <tr><td><a class="pred" href="termrw.html#prompt1/1">prompt1/1</a></td><td>Change
12311192 prompt for 1 line</td></tr>
12321193 <tr><td><a class="pred" href="termrw.html#prompt/2">prompt/2</a></td><td>Change
1233 the prompt used by <a id="idx:read1:2371"></a><a class="pred" href="termrw.html#read/1">read/1</a></td></tr>
1194 the prompt used by <a name="idx:read1:2370"></a><a class="pred" href="termrw.html#read/1">read/1</a></td></tr>
12341195 <tr><td><a class="pred" href="protocol.html#protocol/1">protocol/1</a></td><td>Make
12351196 a log of the user interaction</td></tr>
12361197 <tr><td><a class="pred" href="protocol.html#protocola/1">protocola/1</a></td><td>Append
13811342 streams for interactive session</td></tr>
13821343 <tr><td><a class="pred" href="flags.html#set_prolog_flag/2">set_prolog_flag/2</a></td><td>Define
13831344 a system feature</td></tr>
1345 <tr><td><span class="pred-ext">set_prolog_gc_thread/1</span></td><td>Control
1346 the gc thread</td></tr>
13841347 <tr><td><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a></td><td>Modify
13851348 stack characteristics</td></tr>
13861349 <tr><td><a class="pred" href="miscarith.html#set_random/1">set_random/1</a></td><td>Control
14061369 <tr><td><a class="pred" href="system.html#shell/2">shell/2</a></td><td>Execute
14071370 OS command</td></tr>
14081371 <tr><td><a class="pred" href="delcont.html#shift/1">shift/1</a></td><td>Shift
1409 control to the closest <a id="idx:reset3:2372"></a><a class="pred" href="delcont.html#reset/3">reset/3</a></td></tr>
1372 control to the closest <a name="idx:reset3:2371"></a><a class="pred" href="delcont.html#reset/3">reset/3</a></td></tr>
14101373 <tr><td><a class="pred" href="profile.html#show_profile/1">show_profile/1</a></td><td>Show
14111374 results of the profiler</td></tr>
14121375 <tr><td><a class="pred" href="files.html#size_file/2">size_file/2</a></td><td>Get
15311494 for message in a queue</td></tr>
15321495 <tr><td><a class="pred" href="threadcreate.html#thread_initialization/1">thread_initialization/1</a></td><td>Run
15331496 action at start of thread</td></tr>
1534 <tr><td><span class="pred-ext">thread_join/1</span></td><td>Wait for
1535 Prolog task-completion</td></tr>
1497 <tr><td><a class="pred" href="threadcreate.html#thread_join/1">thread_join/1</a></td><td>Wait
1498 for Prolog task-completion</td></tr>
15361499 <tr><td><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a></td><td>Wait
15371500 for Prolog task-completion</td></tr>
15381501 <tr><td><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a></td><td>Declare
15391502 thread-specific clauses for a predicate</td></tr>
15401503 <tr><td><a class="pred" href="exception.html#thread_message_hook/3">thread_message_hook/3</a></td><td>Thread
1541 local <a id="idx:messagehook3:2373"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a></td></tr>
1504 local <a name="idx:messagehook3:2372"></a><a class="pred" href="exception.html#message_hook/3">message_hook/3</a></td></tr>
15421505 <tr><td><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a></td><td>Test
15431506 for message</td></tr>
15441507 <tr><td><a class="pred" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a></td><td>Test
15601523 <tr><td><a class="pred" href="thutil.html#threads/0">threads/0</a></td><td>List
15611524 running threads</td></tr>
15621525 <tr><td><a class="pred" href="exception.html#throw/1">throw/1</a></td><td>Raise
1563 an exception (see <a id="idx:catch3:2374"></a><a class="pred" href="exception.html#catch/3">catch/3</a>)</td></tr>
1526 an exception (see <a name="idx:catch3:2373"></a><a class="pred" href="exception.html#catch/3">catch/3</a>)</td></tr>
15641527 <tr><td><a class="pred" href="statistics.html#time/1">time/1</a></td><td>Determine
15651528 time needed to execute goal</td></tr>
15661529 <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.7.4 Reference Manual: Section 4.41</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="statistics.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="memory.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:profile"><a id="sec:4.41"><span class="sec-nr">4.41</span> <span class="sec-title">Execution
194 <h2 id="sec:profile"><a name="sec:4.41"><span class="sec-nr">4.41</span> <span class="sec-title">Execution
236195 profiling</span></a></h2>
237196
238 <a id="sec:profile"></a>
197 <a name="sec:profile"></a>
239198
240199 <p>This section describes the hierarchical execution profiler. This
241200 profiler is based on ideas from <b>gprof</b> described in
242201 <cite><a class="cite" href="Bibliography.html#graham82gprof">Graham <em>et
243202 al.</em>, 1982</a></cite>. The profiler consists of two parts: the
244 information-gathering component built into the kernel,<sup class="fn">139<span class="fn-text">There
203 information-gathering component built into the kernel,<sup class="fn">138<span class="fn-text">There
245204 are two implementations; one based on setitimer() using the <code>SIGPROF</code>
246205 signal and one using Windows Multi Media (MM) timers. On other systems
247206 the profiler is not provided.</span></sup> and a presentation component
250209 <code>library(swi/pce_profile)</code> to provide an interactive
251210 graphical frontend for the results.
252211
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
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
254213 predicates</span></a></h3>
255214
256 <a id="sec:profiling-predicates"></a>
215 <a name="sec:profiling-predicates"></a>
257216
258217 <p>The following predicates are defined to interact with the profiler.
259218
260219 <dl class="latex">
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>,
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:1568"></a><a class="pred" href="metacall.html#once/1">once/1</a>,
264223 collecting profiling statistics, and call <code>show_profile([])</code>.
265224 With XPCE installed this opens a graphical interface to examine the
266225 collected profiling data.</dd>
267 <dt class="pubdef"><a id="profile/3"><strong>profile</strong>(<var>:Goal,
226 <dt class="pubdef"><a name="profile/3"><strong>profile</strong>(<var>:Goal,
268227 +Options</var>)</a></dt>
269228 <dd class="defbody">
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>
229 Execute <var>Goal</var> just like <a name="idx:once1:1569"></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:1570"></a><a class="pred" href="profile.html#show_profile/1">show_profile/1</a>
272231 with <var>Options</var>. The default collects CPU profiling and opens a
273232 graphical interface when provided, printing the `plain' time usage of
274233 the top 25 predicates as a ballback. Options are described below.
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>.
234 Remaining options are passed to <a name="idx:showprofile1:1571"></a><a class="pred" href="profile.html#show_profile/1">show_profile/1</a>.
276235
277236 <dl class="latex">
278237 <dt><strong>time</strong>(<var>+Which</var>)</dt>
285244 </dl>
286245
287246 </dd>
288 <dt class="pubdef"><a id="show_profile/1"><strong>show_profile</strong>(<var>+Options</var>)</a></dt>
247 <dt class="pubdef"><a name="show_profile/1"><strong>show_profile</strong>(<var>+Options</var>)</a></dt>
289248 <dd class="defbody">
290249 This predicate first calls prolog:show_profile_hook/1. If XPCE is
291250 loaded, this hook is used to activate a GUI interface to visualise the
305264 </dl>
306265
307266 </dd>
308 <dt class="pubdef"><a id="profiler/2"><strong>profiler</strong>(<var>-Old,
267 <dt class="pubdef"><a name="profiler/2"><strong>profiler</strong>(<var>-Old,
309268 +New</var>)</a></dt>
310269 <dd class="defbody">
311270 Query or change the status of the profiler. The status is one of
327286
328287 <p>The value <code>true</code> is accepted as a synonym for <code>cputime</code>
329288 for compatibility reasons.</dd>
330 <dt class="pubdef"><a id="reset_profiler/0"><strong>reset_profiler</strong></a></dt>
289 <dt class="pubdef"><a name="reset_profiler/0"><strong>reset_profiler</strong></a></dt>
331290 <dd class="defbody">
332291 Switches the profiler to <code>false</code> and clears all collected
333292 statistics.</dd>
334 <dt class="pubdef"><a id="noprofile/1"><strong>noprofile</strong>(<var>+Name/+Arity,
293 <dt class="pubdef"><a name="noprofile/1"><strong>noprofile</strong>(<var>+Name/+Arity,
335294 ...</var>)</a></dt>
336295 <dd class="defbody">
337296 Declares the predicate <var>Name</var>/<var>Arity</var> to be invisible
338297 to the profiler. The time spent in the named predicate is added to the
339298 caller, and the callees are linked directly to the caller. This is
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>,
299 particularly useful for simple meta-predicates such as <a name="idx:call1:1572"></a><a class="pred" href="metacall.html#call/1">call/1</a>, <a name="idx:ignore1:1573"></a><a class="pred" href="metacall.html#ignore/1">ignore/1</a>, <a name="idx:catch3:1574"></a><a class="pred" href="exception.html#catch/3">catch/3</a>,
341300 etc.
342301 </dd>
343302 </dl>
344303
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
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
346305 profiling data</span></a></h3>
347306
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
307 <a name="sec:pceprofile"></a>
308
309 <p>Browsing the annotated call-tree as described in <a class="sec" href="profile.html">section
351310 4.41.3</a> itself is not very attractive. Therefore, the results are
352311 combined per predicate, collecting all <em>callers</em> and <em>callees</em>
353312 as well as the propagation of time and activations in both directions.
370329 detail window to the given caller or callee, showing the documentation
371330 (if it is a built-in) and/or jumping to the source.
372331
373 <p><a id="fig:profnode"></a><div style="text-align:center"><img src="profnode.gif"></div>
332 <p><a name="fig:profnode"></a><div style="text-align:center"><img src="profnode.gif"></div>
374333 <div class="caption"><b>Figure 5 : </b> Execution profiler showing the
375334 activity of the predicate chat:inv_map_list/5.</div>
376335
406365 the call-tree are not added to the call-tree.
407366 </ul>
408367
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
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
410369 gathering</span></a></h3>
411370
412 <a id="sec:profilegather"></a>
371 <a name="sec:profilegather"></a>
413372
414373 <p>While the program executes under the profiler, the system builds a
415374 <em>dynamic</em> call-tree. It does this using three hooks from the
427386 to recursion. For this reason the system performs detection of
428387 recursion. In the simplest case, recursive procedures increment the
429388 `recursive' count on the current node. Mutual recursion, however, is not
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>
389 easily detected. For example, <a name="idx:call1:1575"></a><a class="pred" href="metacall.html#call/1">call/1</a>
390 can call a predicate that uses <a name="idx:call1:1576"></a><a class="pred" href="metacall.html#call/1">call/1</a>
432391 itself. This can be viewed as a recursive invocation, but this is
433392 generally not desirable. Recursion is currently assumed if the same
434393 predicate <em>with the same parent</em> appears higher in the
440399 <code>SIGPROF</code>, it `ticks' the current node of the call-tree each
441400 time the timer fires. On Windows, a MM-timer in a separate thread checks
442401 100 times per second how much time is spent in the profiled thread and
443 adds this to the current node. See <a class="sec" href="profile.html#sec:4.41.3.1">section
402 adds this to the current node. See <a class="sec" href="profile.html">section
444403 4.41.3.1</a> for details.
445404
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
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
447406 in the Windows Implementation</span></a></h4>
448407
449 <a id="sec:winprofile"></a>
408 <a name="sec:winprofile"></a>
450409
451410 <p>Profiling in the Windows version is similar, but as profiling is a
452 statistical process it is good to be aware of the implementation<sup class="fn">140<span class="fn-text">We
411 statistical process it is good to be aware of the implementation<sup class="fn">139<span class="fn-text">We
453412 hereby acknowledge Lionel Fourquaux, who suggested the design described
454413 here after a newsnet enquiry.</span></sup> for proper interpretation of
455414 the results.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="IDE.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="usingmodules.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:projectfiles"><a id="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">The
194 <h2 id="sec:projectfiles"><a name="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">The
236195 project source files</span></a></h2>
237196
238 <a id="sec:projectfiles"></a>
197 <a name="sec:projectfiles"></a>
239198
240199 <p>Organisation of source files depends largely on the size of your
241200 project. If you are doing exercises for a Prolog course you'll normally
244203 all together. Even bigger projects will be organised in sub-projects,
245204 each using its own directory.
246205
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
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
248207 Names and Locations</span></a></h3>
249208
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
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
253212 Name Extensions</span></a></h4>
254213
255 <a id="sec:fileext"></a>
256
257 <p><a id="idx:pl:292"></a><a id="idx:pro:293"></a>The first
214 <a name="sec:fileext"></a>
215
216 <p><a name="idx:pl:294"></a><a name="idx:pro:295"></a>The first
258217 consideration is what extension to use for the source files. Tradition
259218 calls for <code>.pl</code>, but conflicts with Perl force the use of
260219 another extension on systems where extensions have global meaning, such
281240 </dd>
282241 </dl>
283242
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
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
285244 Directories</span></a></h4>
286245
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.
246 <a name="sec:projectdirs"></a>
247
248 <p><a name="idx:Sdiv:296"></a><a name="idx:chrSneg:297"></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.
294253
295254 <p>To improve portability, SWI-Prolog uses the POSIX notation for
296255 filenames, which uses the forward slash (<code><code>/</code></code>) to
297256 separate directories. Just before reaching the file system, SWI-Prolog
298257 uses
299 <a id="idx:prologtoosfilename2:296"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>
258 <a name="idx:prologtoosfilename2:298"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>
300259 to convert the filename to the conventions used by the hosting operating
301260 system. It is <em>strongly</em> advised to write paths using the <code><code>/</code></code>,
302261 especially on systems using the
304263 violates the portability rules and requires you to <em>double</em> the <code><code>\</code></code>
305264 due to the Prolog quoted-atom escape rules.
306265
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>
266 <p>Portable code should use <a name="idx:prologtoosfilename2:299"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>
308267 to convert computed paths into system paths when constructing commands
309 for <a id="idx:shell1:298"></a><a class="pred" href="system.html#shell/1">shell/1</a>
268 for <a name="idx:shell1:300"></a><a class="pred" href="system.html#shell/1">shell/1</a>
310269 and friends.
311270
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
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
313272 using search paths</span></a></h4>
314273
315 <a id="sec:projectpaths"></a>
274 <a name="sec:projectpaths"></a>
316275
317276 <p>Thanks to Quintus, Prolog adapted an extensible mechanism for
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>.
277 searching files using <a name="idx:filesearchpath2:301"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
319278 This mechanism allows for comfortable and readable specifications.
320279
321280 <p>Suppose you have extensive library packages on graph algorithms, set
326285 <p>Next, there are three options. One is to add the sub-projects to the
327286 directory hierarchy of the current project. Another is to use a
328287 completely dislocated directory. Third, the sub-project can be added to
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>
288 the SWI-Prolog hierarchy. Using local installation, a typical <a name="idx:filesearchpath2:302"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
330289 is:
331290
332291 <pre class="code">
342301 installation, use an absolute path.
343302
344303 <p>Extensive sub-projects with a small well-defined API should define 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>
304 load file with calls to <a name="idx:usemodule1:303"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
346305 to import the various library components and export the API.
347306
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
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
349308 Special Files</span></a></h3>
350309
351 <a id="sec:project-special-files"></a>
310 <a name="sec:project-special-files"></a>
352311
353312 <p>There are a number of tasks you typically carry out on your project,
354313 such as loading it, creating a saved state, debugging it, etc. Good
355314 practice on large projects is to define small files that hold the
356315 commands to execute such a task, name this file after the task and give
357316 it a file extension that makes starting easy (see
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:
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:
361319
362320 <p>
363321 <ul class="latex">
376334 <p>
377335 <li><i><code>save.pl</code></i><br>
378336 Use this file to create a saved state of the application by loading
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>
337 <code>load.pl</code> and calling <a name="idx:qsaveprogram2:304"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>
380338 to generate a saved state with the proper options.
381339
382340 <p>
383341 <li><i><code>debug.pl</code></i><br>
384342 Loads the program for debugging. In addition to loading <code>load.pl</code>
385 this file defines rules for <a id="idx:portray1:303"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
343 this file defines rules for <a name="idx:portray1:305"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
386344 to modify printing rules for complex terms and customisation rules for
387345 the debugger and editing environment. It may start some of these tools.
388346 </ul>
389347
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
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
391349 source files</span></a></h3>
392350
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.
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.
400357
401358 <p>SWI-Prolog can read files in any of the encodings described in
402 <a class="sec" href="widechars.html#sec:2.19">section 2.19</a>. Two
403 encodings are of particular interest. The
359 <a class="sec" href="widechars.html">section 2.19</a>. Two encodings are
360 of particular interest. The
404361 <code>text</code> encoding deals with the current <em>locale</em>, the
405362 default used by this computer for representing text files. The encodings
406363 <code>utf8</code>, <code>unicode_le</code> and <code>unicode_be</code>
437394 <li><i>Using UTF-8 files</i><br>
438395 The best way to specify source files with many NON-ASCII characters is
439396 definitely the use of UTF-8 encoding. Prolog can be notified of this
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
397 encoding in two ways, using a UTF-8 <em>BOM</em> (see <a class="sec" href="widechars.html">section
441398 2.19.1.1</a>) or using the directive <code>:- encoding(utf8).</code>
442399 Many of today's text editors, including PceEmacs, are capable of editing
443400 UTF-8 files. Projects that were started using local conventions can be
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.27</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="prologpack.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="quasiquotations.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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):
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):
236195 Cross-reference data collection library</span></a></h2>
237196
238 <a id="sec:prolog_xref"></a>
239 <a id="sec:lib:prologxref"></a>
197 <a name="sec:prolog_xref"></a>
198 <a name="sec:lib:prologxref"></a>
240199
241200 <p>This library collects information on defined and used objects in
242201 Prolog source files. Typically these are predicates, but we expect the
255214 consider this interface rock-solid.</b>
256215
257216 <p>The library is exploited by two graphical tools in the SWI-Prolog
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>
217 environment: the XPCE front-end started by <a name="idx:gxref0:2154"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
259218 and described in
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
219 <a class="sec" href="xref.html">section 3.7</a>, and PceEmacs (<a class="sec" href="pceemacs.html">section
261220 3.4</a>), which exploits this library for its syntax colouring.
262221
263222 <p>For all predicates described below, <var>Source</var> is the source
264223 that is processed. This is normally a filename in any notation
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
224 acceptable to the file loading predicates (see <a name="idx:loadfiles2:2155"></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
267226 A.27.1</a> it can be anything else that can be translated into a Prolog
268227 stream holding Prolog source text. <var>Callable</var> is a callable
269 term (see <a id="idx:callable1:2157"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>).
228 term (see <a name="idx:callable1:2156"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>).
270229 Callables do not carry a module qualifier unless the referred predicate
271230 is not in the module defined
272231 <var>Source</var>.
273232
274233 <dl class="latex">
275 <dt class="pubdef"><a id="xref_source/1"><strong>xref_source</strong>(<var>+Source</var>)</a></dt>
234 <dt class="pubdef"><a name="xref_source/1"><strong>xref_source</strong>(<var>+Source</var>)</a></dt>
276235 <dd class="defbody">
277236 Gather information on <var>Source</var>. If <var>Source</var> has
278237 already been processed and is still up-to-date according to the file
279238 timestamp, no action is taken. This predicate must be called on a file
280239 before information can be gathered.</dd>
281 <dt class="pubdef"><a id="xref_current_source/1"><strong>xref_current_source</strong>(<var>?Source</var>)</a></dt>
240 <dt class="pubdef"><a name="xref_current_source/1"><strong>xref_current_source</strong>(<var>?Source</var>)</a></dt>
282241 <dd class="defbody">
283242 <var>Source</var> has been processed.</dd>
284 <dt class="pubdef"><a id="xref_clean/1"><strong>xref_clean</strong>(<var>+Source</var>)</a></dt>
243 <dt class="pubdef"><a name="xref_clean/1"><strong>xref_clean</strong>(<var>+Source</var>)</a></dt>
285244 <dd class="defbody">
286245 Remove the information gathered for <var>Source</var></dd>
287 <dt class="pubdef"><a id="xref_defined/3"><strong>xref_defined</strong>(<var>?Source,
246 <dt class="pubdef"><a name="xref_defined/3"><strong>xref_defined</strong>(<var>?Source,
288247 ?Callable, -How</var>)</a></dt>
289248 <dd class="defbody">
290249 <var>Callable</var> is defined in <var>Source</var>. <var>How</var> is
291250 one of
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>
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>
301264 </table>
302265 </dd>
303 <dt class="pubdef"><a id="xref_called/3"><strong>xref_called</strong>(<var>?Source,
266 <dt class="pubdef"><a name="xref_called/3"><strong>xref_called</strong>(<var>?Source,
304267 ?Callable, ?By</var>)</a></dt>
305268 <dd class="defbody">
306269 <var>Callable</var> is called in <var>Source</var> by <var>By</var>.</dd>
307 <dt class="pubdef"><a id="xref_exported/2"><strong>xref_exported</strong>(<var>?Source,
270 <dt class="pubdef"><a name="xref_exported/2"><strong>xref_exported</strong>(<var>?Source,
308271 ?Callable</var>)</a></dt>
309272 <dd class="defbody">
310273 <var>Callable</var> is public (exported from the module).</dd>
311 <dt class="pubdef"><a id="xref_module/2"><strong>xref_module</strong>(<var>?Source,
274 <dt class="pubdef"><a name="xref_module/2"><strong>xref_module</strong>(<var>?Source,
312275 ?Module</var>)</a></dt>
313276 <dd class="defbody">
314277 <var>Source</var> is a module file defining the given module.</dd>
315 <dt class="pubdef"><a id="xref_built_in/1"><strong>xref_built_in</strong>(<var>?Callable</var>)</a></dt>
278 <dt class="pubdef"><a name="xref_built_in/1"><strong>xref_built_in</strong>(<var>?Callable</var>)</a></dt>
316279 <dd class="defbody">
317280 True if <var>Callable</var> is a built-in predicate. Currently this is
318281 assumed for all predicates defined in the <code>system</code> module and
321284 </dd>
322285 </dl>
323286
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
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
325288 the library</span></a></h3>
326289
327 <a id="sec:xrefhooks"></a>
290 <a name="sec:xrefhooks"></a>
328291
329292 <p>The library provides hooks for extending the rules it uses for
330293 finding predicates called by some programming construct.
331294
332295 <dl class="latex">
333 <dt class="pubdef"><a id="prolog:called_by/2"><strong>prolog:called_by</strong>(<var>+Goal,
296 <dt class="pubdef"><a name="prolog:called_by/2"><strong>prolog:called_by</strong>(<var>+Goal,
334297 -Called</var>)</a></dt>
335298 <dd class="defbody">
336299 <var>Goal</var> is a non-var subgoal appearing in the called object
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.26</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="predicate_options.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="prolog_xref.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:prologpack"><a id="sec:A.26"><span class="sec-nr">A.26</span> <span class="sec-title">library(prolog_pack):
194 <h2 id="sec:prologpack"><a name="sec:A.26"><span class="sec-nr">A.26</span> <span class="sec-title">library(prolog_pack):
236195 A package manager for Prolog</span></a></h2>
237196
238 <p><a id="sec:prologpack"></a>
197 <p><a name="sec:prologpack"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">See also</dt>
257216 that makes installed packages available as libaries.
258217
259218 <dl class="latex">
260 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_list_installed/0"><strong>pack_list_installed</strong></a></dt>
219 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_list_installed/0"><strong>pack_list_installed</strong></a></dt>
261220 <dd class="defbody">
262221 List currently installed packages. Unlike <a class="pred" href="prologpack.html#pack_list/1">pack_list/1</a>,
263222 only locally installed packages are displayed and no connection is made
272231 </dl>
273232
274233 </dd>
275 <dt class="pubdef"><a id="pack_info/1"><strong>pack_info</strong>(<var>+Pack</var>)</a></dt>
234 <dt class="pubdef"><a name="pack_info/1"><strong>pack_info</strong>(<var>+Pack</var>)</a></dt>
276235 <dd class="defbody">
277236 Print more detailed information about <var>Pack</var>.</dd>
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>
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>
280239 <dd class="defbody">
281240 <var>Query</var> package server and installed packages and display
282241 results.
319278 </dl>
320279
321280 </dd>
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>
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>
323282 <dd class="defbody">
324283 Install a package. <var>Spec</var> is one of
325284
336295
337296 <p>After resolving the type of package, <a class="pred" href="prologpack.html#pack_install/2">pack_install/2</a>
338297 is used to do the actual installation.</dd>
339 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_install/2"><strong>pack_install</strong>(<var>+Name,
298 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_install/2"><strong>pack_install</strong>(<var>+Name,
340299 +Options</var>)</a></dt>
341300 <dd class="defbody">
342301 Install package <var>Name</var>. Processes the options below. Default
378337 particular
379338 <i>trusted</i> URL instead of the plain pack name for unattented
380339 operation.</dd>
381 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_url_file/2"><strong>pack_url_file</strong>(<var>+URL,
340 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_url_file/2"><strong>pack_url_file</strong>(<var>+URL,
382341 -File</var>)</a></dt>
383342 <dd class="defbody">
384343 True if <var>File</var> is a unique id for the referenced pack and
385344 version. Normally, that is simply the base name, but GitHub archives
386345 destroy this picture. Needed by the pack manager.</dd>
387 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_rebuild/1"><strong>pack_rebuild</strong>(<var>+Pack</var>)</a></dt>
346 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_rebuild/1"><strong>pack_rebuild</strong>(<var>+Pack</var>)</a></dt>
388347 <dd class="defbody">
389348 Rebuilt possible foreign components of <var>Pack</var>.</dd>
390 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_rebuild/0"><strong>pack_rebuild</strong></a></dt>
349 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_rebuild/0"><strong>pack_rebuild</strong></a></dt>
391350 <dd class="defbody">
392351 Rebuild foreign components of all packages.</dd>
393 <dt class="multidef"><span class="pred-tag">[nondet,multifile]</span><a id="environment/2"><strong>environment</strong>(<var>-Name,
352 <dt class="multidef"><span class="pred-tag">[nondet,multifile]</span><a name="environment/2"><strong>environment</strong>(<var>-Name,
394353 -Value</var>)</a></dt>
395354 <dd class="defbody">
396355 Hook to define the environment for building packs. This Multifile hook
405364 </pre>
406365
407366 <table class="arglist">
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>
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>
412371 </table>
413372 </dd>
414 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="pack_upgrade/1"><strong>pack_upgrade</strong>(<var>+Pack</var>)</a></dt>
373 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="pack_upgrade/1"><strong>pack_upgrade</strong>(<var>+Pack</var>)</a></dt>
415374 <dd class="defbody">
416375 Try to upgrade the package <var>Pack</var>.
417376
423382 </dl>
424383
425384 </dd>
426 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="pack_remove/1"><strong>pack_remove</strong>(<var>+Name</var>)</a></dt>
385 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="pack_remove/1"><strong>pack_remove</strong>(<var>+Name</var>)</a></dt>
427386 <dd class="defbody">
428387 Remove the indicated package.</dd>
429 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="pack_property/2"><strong>pack_property</strong>(<var>?Pack,
388 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="pack_property/2"><strong>pack_property</strong>(<var>?Pack,
430389 ?Property</var>)</a></dt>
431390 <dd class="defbody">
432391 True when <var>Property</var> is a property of an installed <var>Pack</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.38</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="toplevel.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="debugger.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:protocol"><a id="sec:4.38"><span class="sec-nr">4.38</span> <span class="sec-title">Creating
194 <h2 id="sec:protocol"><a name="sec:4.38"><span class="sec-nr">4.38</span> <span class="sec-title">Creating
236195 a Protocol of the User Interaction</span></a></h2>
237196
238 <a id="sec:protocol"></a>
197 <a name="sec:protocol"></a>
239198
240199 <p>SWI-Prolog offers the possibility to log the interaction with the
241 user on a file.<sup class="fn">138<span class="fn-text">A similar
200 user on a file.<sup class="fn">137<span class="fn-text">A similar
242201 facility was added to Edinburgh C-Prolog by Wouter Jansweijer.</span></sup>
243202 All Prolog interaction, including warnings and tracer output, are
244203 written to the protocol file.
245204
246205 <dl class="latex">
247 <dt class="pubdef"><a id="protocol/1"><strong>protocol</strong>(<var>+File</var>)</a></dt>
206 <dt class="pubdef"><a name="protocol/1"><strong>protocol</strong>(<var>+File</var>)</a></dt>
248207 <dd class="defbody">
249208 Start protocolling on file <var>File</var>. If there is already a
250209 protocol file open, then close it first. If <var>File</var> exists it is
251210 truncated.
252211 </dd>
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>,
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:1540"></a><a class="pred" href="protocol.html#protocol/1">protocol/1</a>,
256215 but does not truncate the <var>File</var> if it exists.
257216 </dd>
258 <dt class="pubdef"><a id="noprotocol/0"><strong>noprotocol</strong></a></dt>
217 <dt class="pubdef"><a name="noprotocol/0"><strong>noprotocol</strong></a></dt>
259218 <dd class="defbody">
260219 Stop making a protocol of the user interaction. Pending output is
261220 flushed on the file.
262221 </dd>
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>
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:1541"></a><a class="pred" href="protocol.html#protocol/1">protocol/1</a>
225 or <a name="idx:protocola1:1542"></a><a class="pred" href="protocol.html#protocola/1">protocola/1</a>
267226 and unifies <var>File</var> with the current protocol output file.
268227 </dd>
269228 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="qsavelimits.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="useresource.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:qsaveforeign"><a id="sec:12.2"><span class="sec-nr">12.2</span> <span class="sec-title">Runtimes
194 <h2 id="sec:qsaveforeign"><a name="sec:12.2"><span class="sec-nr">12.2</span> <span class="sec-title">Runtimes
236195 and Foreign Code</span></a></h2>
237196
238 <a id="sec:qsaveforeign"></a>
239
240 <p><a id="sec:qforeign"></a> Some applications may need to use the
197 <a name="sec:qsaveforeign"></a>
198
199 <p><a name="sec:qforeign"></a> Some applications may need to use the
241200 foreign language interface. Object code is by definition
242201 machine-dependent and thus cannot be part of the saved program file.
243202
264223 have a source file <code>myextension.c</code> defining the installation
265224 function install().
266225
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>
226 <p>If this file is compiled into a shared library, <a name="idx:loadforeignlibrary1:2119"></a><a class="pred" href="foreignlink.html#load_foreign_library/1">load_foreign_library/1</a>
268227 will load this library and call the installation function to initialise
269228 the foreign code. If it is loaded as a static extension, define
270229 install() as the predicate install/0 :
298257 :- initialization load_foreign_extensions.
299258 </pre>
300259
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>.
260 <p>The path alias <code>foreign</code> is defined by <a name="idx:filesearchpath2:2120"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
302261 By default it searches the directories <code>&lt;<var>home</var>&gt;/lib/&lt;<var>arch</var>&gt;</code>
303262 and
304263 <code>&lt;<var>home</var>&gt;/lib</code>. The application can specify
305264 additional rules for
306 <a id="idx:filesearchpath2:2122"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
265 <a name="idx:filesearchpath2:2121"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>.
307266
308267 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="runtime.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="qsaveforeign.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:qsavelimits"><a id="sec:12.1"><span class="sec-nr">12.1</span> <span class="sec-title">Limitations
194 <h2 id="sec:qsavelimits"><a name="sec:12.1"><span class="sec-nr">12.1</span> <span class="sec-title">Limitations
236195 of qsave_program</span></a></h2>
237196
238 <a id="sec:qsavelimits"></a>
197 <a name="sec:qsavelimits"></a>
239198
240199 <p>There are three areas that require special attention when using
241 <a id="idx:qsaveprogram12:2116"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.
200 <a name="idx:qsaveprogram12:2115"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>.
242201
243202 <p>
244203 <ul class="latex">
245204 <li>If the program is an embedded Prolog application or uses the foreign
246205 language interface, care has to be taken to restore the appropriate
247 foreign context. See <a class="sec" href="qsaveforeign.html#sec:12.2">section
206 foreign context. See <a class="sec" href="qsaveforeign.html">section
248207 12.2</a> for details.
249208
250209 <p>
251210 <li>If the program uses directives (<code>:- goal.</code> lines) that
252211 perform other actions than setting predicate attributes (dynamic,
253212 volatile, etc.) or loading files (consult, etc.), the directive may need
254 to be prefixed with <a id="idx:initialization1:2117"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.
213 to be prefixed with <a name="idx:initialization1:2116"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>.
255214
256215 <p>
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>,
216 <li>Database references as returned by <a name="idx:clause3:2117"></a><a class="pred" href="examineprog.html#clause/3">clause/3</a>, <a name="idx:recorded3:2118"></a><a class="pred" href="db.html#recorded/3">recorded/3</a>,
258217 etc., are not preserved and may thus not be part of the database when
259218 saved.
260219 </ul>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.28</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="prolog_xref.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="random.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:quasiquotations"><a id="sec:A.28"><span class="sec-nr">A.28</span> <span class="sec-title">library(quasi_quotations):
194 <h2 id="sec:quasiquotations"><a name="sec:A.28"><span class="sec-nr">A.28</span> <span class="sec-title">library(quasi_quotations):
236195 Define Quasi Quotation syntax</span></a></h2>
237196
238 <p><a id="sec:quasiquotations"></a>
197 <p><a name="sec:quasiquotations"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">author</dt>
245204 </dd>
246205 <dt class="tag">See also</dt>
247206 <dd>
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>
207 http://www.cs.tufts.edu/comp/150FP/archive/geoff-mainland/quasiquoting.pdfWhy
208 it's nice to be quoted: quasiquoting for haskell
250209 </dd>
251210 </dl>
252211
253212 <p>Inspired by
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.
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.
260219
261220 <p>The basic form of a quasi quotation is defined below. Here, <var>Syntax</var>
262221 is an arbitrary Prolog term that must parse into a <i>callable</i> (atom
325284 the, suprisingly simple, quasi quotation parser for HTML.
326285
327286 <dl class="latex">
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,
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,
329288 -Stream, :Goal</var>)</a></dt>
330289 <dd class="defbody">
331290 Process the quasi-quoted <var>Content</var> using <var>Stream</var>
341300 <li>It will be closed after <var>Goal</var> completes.
342301 </ul>
343302 <table class="arglist">
344 <tr><td><var>Goal</var> </td><td>is executed as <code>once(Goal)</code>. <var>Goal</var>
303 <tr valign="top"><td><var>Goal</var> </td><td>is executed as <code>once(Goal)</code>. <var>Goal</var>
345304 must succeed. Failure or exceptions from <var>Goal</var> are interpreted
346305 as syntax errors. </td></tr>
347306 </table>
355314 </dl>
356315
357316 </dd>
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,
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,
359318 +Content</var>)</a></dt>
360319 <dd class="defbody">
361320 Process the quasi quotation using the DCG <var>Grammar</var>. Failure of
370329 </dl>
371330
372331 </dd>
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>
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>
374333 <dd class="defbody">
375334 Declare the predicate <var>SyntaxName</var>/4 to implement the the quasi
376335 quote syntax <var>SyntaxName</var>. Normally used as a directive.</dd>
377 <dt class="pubdef"><a id="quasi_quotation_syntax_error/1"><strong>quasi_quotation_syntax_error</strong>(<var>+Error</var>)</a></dt>
336 <dt class="pubdef"><a name="quasi_quotation_syntax_error/1"><strong>quasi_quotation_syntax_error</strong>(<var>+Error</var>)</a></dt>
378337 <dd class="defbody">
379338 Report <code>syntax_error(Error)</code> using the current location in
380339 the quasi quoted input parser.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="overview.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="initfile.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:quickstart"><a id="sec:2.1"><span class="sec-nr">2.1</span> <span class="sec-title">Getting
194 <h2 id="sec:quickstart"><a name="sec:2.1"><span class="sec-nr">2.1</span> <span class="sec-title">Getting
236195 started quickly</span></a></h2>
237196
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
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
241200 SWI-Prolog</span></a></h3>
242201
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
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
246205 SWI-Prolog on Unix</span></a></h4>
247206
248 <a id="sec:startunix"></a>
207 <a name="sec:startunix"></a>
249208
250209 <p>By default, SWI-Prolog is installed as `swipl'. The command line
251210 arguments of SWI-Prolog itself and its utility programs are documented
261220 </pre>
262221
263222 <p>After starting Prolog, one normally loads a program into it using
264 <a id="idx:consult1:6"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
223 <a name="idx:consult1:6"></a><a class="pred" href="consulting.html#consult/1">consult/1</a>,
265224 which may be abbreviated by putting the name of the program file between
266225 square brackets. The following goal loads the file
267 <a class="url" href="https://raw.githubusercontent.com/SWI-Prolog/swipl-devel/master/demo/likes.pl">likes.pl</a>
226 https://raw.githubusercontent.com/SWI-Prolog/swipl-devel/master/demo/likes.pllikes.pl
268227 containing clauses for the predicates likes/2 :
269228
270229 <pre class="code">
286245 </pre>
287246
288247 <p>After this point, Unix and Windows users unite, so if you are using
289 Unix please continue at <a class="sec" href="quickstart.html#sec:2.1.3">section
290 2.1.3</a>.
291
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
248 Unix please continue at <a class="sec" href="quickstart.html">section
249 2.1.2</a>.
250
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
293252 SWI-Prolog on Windows</span></a></h4>
294253
295 <a id="sec:startwin"></a>
254 <a name="sec:startwin"></a>
296255
297256 <p>After SWI-Prolog has been installed on a Windows system, the
298257 following important new things are available to the user:
313272 </ul>
314273
315274 <p>The normal way to start the <code>likes.pl</code> file mentioned in
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
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
320279 rules from the console</span></a></h3>
321280
322 <a id="sec:consultuser"></a>
281 <a name="sec:consultuser"></a>
323282
324283 <p>Although we strongly advice to put your program in a file, optionally
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
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
330288 <code>user</code>. The input is ended using the system end-of-file
331289 character.
332290
341299 true.
342300 </pre>
343301
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>
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>
346304 are alternatives to add and remove rules and facts.
347305
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
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
349307 a query</span></a></h3>
350308
351 <a id="sec:execquery"></a>
309 <a name="sec:execquery"></a>
352310
353311 <p>After loading a program, one can ask Prolog queries about the
354312 program. The query below asks Prolog what food `sam' likes. The system
381339 differs in several ways from traditional Prolog top level. The current
382340 top level was designed in cooperation with Ulrich Neumerkel.</span></sup>
383341
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
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
385343 and modifying your program</span></a></h3>
386344
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>
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>
390348 starts the built-in or user configured editor on the argument. The
391349 argument can be anything that can be linked to a location: a file name,
392350 predicate name, module name, etc. If the argument resolves to only one
395353
396354 <p>If a graphical user interface is available, the editor normally
397355 creates a new window and the system prompts for the next command. The
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>
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>
399357 to update any modified source file. If the editor cannot be opened in 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>
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>
401359 to reload any source files that have been modified.
402360
403361 <pre class="code">
411369 ...
412370 </pre>
413371
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>
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>
416374 is just a predicate name, a predicate
417375 <em>indicator</em> of the form <var>Name/Arity</var>, e.g., <code>?-
418 listing(<a id="idx:mild1:15"></a><span class="pred-ext">mild/1</span>).</code>
376 listing(<a name="idx:mild1:15"></a><span class="pred-ext">mild/1</span>).</code>
419377 or a <em>head</em>, e.g., <code>?- listing(likes(sam, _).</code>,
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>,
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>,
421379 i.e., without arguments lists the entire program.<sup class="fn">8<span class="fn-text">This
422380 lists several <em>hook</em> predicates that are defined by default and
423381 is typically not very informative.</span></sup>
431389 true.
432390 </pre>
433391
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
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
435393 Prolog</span></a></h3>
436394
437 <a id="sec:halt"></a>
395 <a name="sec:halt"></a>
438396
439397 <p>The interactive toplevel can be stopped in two ways: enter the system
440398 end-of-file character (typically <i>Control-D</i>) or by executing the
441 <a id="idx:halt0:17"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
399 <a name="idx:halt0:17"></a><a class="pred" href="toplevel.html#halt/0">halt/0</a>
442400 predicate:
443401
444402 <pre class="code">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.29</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="quasiquotations.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="readutil.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:random"><a id="sec:A.29"><span class="sec-nr">A.29</span> <span class="sec-title">library(random):
194 <h2 id="sec:random"><a name="sec:A.29"><span class="sec-nr">A.29</span> <span class="sec-title">library(random):
236195 Random numbers</span></a></h2>
237196
238 <p><a id="sec:random"></a>
197 <p><a name="sec:random"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">author</dt>
255214 are based on the GMP library.
256215
257216 <dl class="latex">
258 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random/1"><strong>random</strong>(<var>-R:float</var>)</a></dt>
217 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random/1"><strong>random</strong>(<var>-R:float</var>)</a></dt>
259218 <dd class="defbody">
260219 Binds <var>R</var> to a new random float in the <i>open</i> interval
261220 (0.0,1.0).
272231 </dl>
273232
274233 </dd>
275 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_between/3"><strong>random_between</strong>(<var>+L:int,
234 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_between/3"><strong>random_between</strong>(<var>+L:int,
276235 +U:int, -R:int</var>)</a></dt>
277236 <dd class="defbody">
278237 Binds <var>R</var> to a random integer in [<var>L</var>,<var>U</var>]
279238 (i.e., including both <var>L</var> and
280239 <var>U</var>). Fails silently if <var>U</var><var>&lt;</var><var>L</var>.</dd>
281 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random/3"><strong>random</strong>(<var>+L:int,
240 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random/3"><strong>random</strong>(<var>+L:int,
282241 +U:int, -R:int</var>)</a></dt>
283 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random/3"><strong>random</strong>(<var>+L:float,
242 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random/3"><strong>random</strong>(<var>+L:float,
284243 +U:float, -R:float</var>)</a></dt>
285244 <dd class="defbody">
286245 Generate a random integer or float in a range. If <var>L</var> and <var>U</var>
300259 </dl>
301260
302261 </dd>
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>
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>
305264 <dd class="defbody">
306265 Query/set the state of the random generator. This is intended for
307266 restarting the generator at a known state only. The predicate <a class="pred" href="random.html#setrand/1">setrand/1</a>
331290 </dl>
332291
333292 </dd>
334 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="maybe/0"><strong>maybe</strong></a></dt>
293 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="maybe/0"><strong>maybe</strong></a></dt>
335294 <dd class="defbody">
336295 Succeed/fail with equal probability (variant of <a class="pred" href="random.html#maybe/1">maybe/1</a>).</dd>
337 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="maybe/1"><strong>maybe</strong>(<var>+P</var>)</a></dt>
296 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="maybe/1"><strong>maybe</strong>(<var>+P</var>)</a></dt>
338297 <dd class="defbody">
339298 Succeed with probability <var>P</var>, fail with probability 1-<var>P</var></dd>
340 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="maybe/2"><strong>maybe</strong>(<var>+K,
299 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="maybe/2"><strong>maybe</strong>(<var>+K,
341300 +N</var>)</a></dt>
342301 <dd class="defbody">
343302 Succeed with probability <var>K</var>/<var>N</var> (variant of <a class="pred" href="random.html#maybe/1">maybe/1</a>)</dd>
344 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_perm2/4"><strong>random_perm2</strong>(<var>?A,
303 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_perm2/4"><strong>random_perm2</strong>(<var>?A,
345304 ?B, ?X, ?Y</var>)</a></dt>
346305 <dd class="defbody">
347306 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>
348307 with equal probability.</dd>
349 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_member/2"><strong>random_member</strong>(<var>-X,
308 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_member/2"><strong>random_member</strong>(<var>-X,
350309 +List:list</var>)</a></dt>
351310 <dd class="defbody">
352311 <var>X</var> is a random member of <var>List</var>. Equivalent to
362321 </dl>
363322
364323 </dd>
365 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="random_select/3"><strong>random_select</strong>(<var>-X,
324 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="random_select/3"><strong>random_select</strong>(<var>-X,
366325 +List, -Rest</var>)</a></dt>
367 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_select/3"><strong>random_select</strong>(<var>+X,
326 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_select/3"><strong>random_select</strong>(<var>+X,
368327 -List, +Rest</var>)</a></dt>
369328 <dd class="defbody">
370329 Randomly select or insert an element. Either <var>List</var> or <var>Rest</var>
378337 </dl>
379338
380339 </dd>
381 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="randset/3"><strong>randset</strong>(<var>+K:int,
340 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="randset/3"><strong>randset</strong>(<var>+K:int,
382341 +N:int, -S:list(int)</var>)</a></dt>
383342 <dd class="defbody">
384343 <var>S</var> is a sorted list of <var>K</var> unique random integers in
405364 </dl>
406365
407366 </dd>
408 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="randseq/3"><strong>randseq</strong>(<var>+K:int,
367 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="randseq/3"><strong>randseq</strong>(<var>+K:int,
409368 +N:int, -List:list(int)</var>)</a></dt>
410369 <dd class="defbody">
411370 S is a list of <var>K</var> unique random integers in the range 1..<var>N</var>.
425384 </dl>
426385
427386 </dd>
428 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_permutation/2"><strong>random_permutation</strong>(<var>+List,
387 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_permutation/2"><strong>random_permutation</strong>(<var>+List,
429388 -Permutation</var>)</a></dt>
430 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="random_permutation/2"><strong>random_permutation</strong>(<var>-List,
389 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="random_permutation/2"><strong>random_permutation</strong>(<var>-List,
431390 +Permutation</var>)</a></dt>
432391 <dd class="defbody">
433392 <var>Permutation</var> is a random permutation of <var>List</var>. This
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.30</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="random.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="record.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:readutil"><a id="sec:A.30"><span class="sec-nr">A.30</span> <span class="sec-title">library(readutil):
194 <h2 id="sec:readutil"><a name="sec:A.30"><span class="sec-nr">A.30</span> <span class="sec-title">library(readutil):
236195 Reading lines, streams and files</span></a></h2>
237196
238 <a id="sec:readutil"></a>
197 <a name="sec:readutil"></a>
239198
240199 <p>This library contains primitives to read lines, files, multiple
241200 terms, etc. The package <code>clib</code> provides a shared object (DLL)
246205 shared object if performance of these predicates is critical.
247206
248207 <dl class="latex">
249 <dt class="pubdef"><a id="read_line_to_codes/2"><strong>read_line_to_codes</strong>(<var>+Stream,
208 <dt class="pubdef"><a name="read_line_to_codes/2"><strong>read_line_to_codes</strong>(<var>+Stream,
250209 -Codes</var>)</a></dt>
251210 <dd class="defbody">
252211 Read the next line of input from <var>Stream</var> and unify the result
253212 with
254213 <var>Codes</var> <em>after</em> the line has been read. A line is ended
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>,
214 by a newline character or end-of-file. Unlike <a name="idx:readlinetocodes3:2157"></a><a class="pred" href="readutil.html#read_line_to_codes/3">read_line_to_codes/3</a>,
256215 this predicate removes a trailing newline character.
257216
258217 <p>On end-of-file the atom <code>end_of_file</code> is returned. See
259218 also
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,
219 <a name="idx:atendofstream01:2158"></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,
262221 -Codes, ?Tail</var>)</a></dt>
263222 <dd class="defbody">
264223 Difference-list version to read an input line to a list of character
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>,
224 codes. Reading stops at the newline or end-of-file character, but unlike <a name="idx:readlinetocodes2:2159"></a><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a>,
266225 the newline is retained in the output. This predicate is especially
267226 useful for reading a block of lines up to some delimiter. The following
268227 example reads an HTTP header ended by a blank line:
281240 </pre>
282241
283242 </dd>
284 <dt class="pubdef"><a id="read_stream_to_codes/2"><strong>read_stream_to_codes</strong>(<var>+Stream,
243 <dt class="pubdef"><a name="read_stream_to_codes/2"><strong>read_stream_to_codes</strong>(<var>+Stream,
285244 -Codes</var>)</a></dt>
286245 <dd class="defbody">
287246 Read all input until end-of-file and unify the result to <var>Codes</var>.</dd>
288 <dt class="pubdef"><a id="read_stream_to_codes/3"><strong>read_stream_to_codes</strong>(<var>+Stream,
247 <dt class="pubdef"><a name="read_stream_to_codes/3"><strong>read_stream_to_codes</strong>(<var>+Stream,
289248 -Codes, ?Tail</var>)</a></dt>
290249 <dd class="defbody">
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,
250 Difference-list version of <a name="idx:readstreamtocodes2:2160"></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,
293252 -Codes, +Options</var>)</a></dt>
294253 <dd class="defbody">
295254 Read a file to a list of character codes. <var>Spec</var> is a file
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>
255 specification for <a name="idx:absolutefilename3:2161"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>. <var>Codes</var>
297256 is the resulting code list. <var>Options</var> is a list of options for
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>.
257 <a name="idx:absolutefilename3:2162"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
258 and <a name="idx:open4:2163"></a><a class="pred" href="IO.html#open/4">open/4</a>.
300259 In addition, the option
301260 <code>tail(Tail)</code> is defined, forming a difference-list.</dd>
302 <dt class="pubdef"><a id="read_file_to_terms/3"><strong>read_file_to_terms</strong>(<var>+Spec,
261 <dt class="pubdef"><a name="read_file_to_terms/3"><strong>read_file_to_terms</strong>(<var>+Spec,
303262 -Terms, +Options</var>)</a></dt>
304263 <dd class="defbody">
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>
264 Read a file to a list of Prolog terms (see <a name="idx:read1:2164"></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:2165"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>. <var>Terms</var>
307266 is the resulting list of Prolog terms. <var>Options</var> is a list of
308267 options for
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>.
268 <a name="idx:absolutefilename3:2166"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>
269 and <a name="idx:open4:2167"></a><a class="pred" href="IO.html#open/4">open/4</a>.
311270 In addition, the option
312271 <code>tail(Tail)</code> is defined, forming a difference-list.
313272 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.31</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="readutil.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="registry.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:record"><a id="sec:A.31"><span class="sec-nr">A.31</span> <span class="sec-title">library(record):
194 <h2 id="sec:record"><a name="sec:A.31"><span class="sec-nr">A.31</span> <span class="sec-title">library(record):
236195 Access named fields in a term</span></a></h2>
237196
238 <a id="sec:record"></a>
239 <a id="sec:lib:record"></a>
197 <a name="sec:record"></a>
198 <a name="sec:lib:record"></a>
240199
241200 <p>The library <code>library(record)</code> provides named access to
242201 fields in a record represented as a compound term such as <code>point(X,
251210 predicates, an optimizing compiler can easily inline them for optimal
252211 preformance.
253212
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>.
213 <p>A record is defined using the directive <a name="idx:record1:2168"></a><a class="pred" href="record.html#record/1">record/1</a>.
255214 We introduce the library with a short example:
256215
257216 <pre class="code">
274233
275234 <p>In this definition, &lt;<var>name</var>&gt; is an atom defining the
276235 name of the argument,
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>
236 &lt;<var>type</var>&gt; is an optional type specification as defined by <a name="idx:mustbe2:2169"></a><a class="pred" href="error.html#must_be/2">must_be/2</a>
278237 from library <code>library(error)</code>, and &lt;<var>default</var>&gt;
279238 is the default initial value. The
280239 &lt;<var>type</var>&gt; defaults to <code>any</code>. If no default
310269 <p>
311270 <li><i>&lt;<var>constructor</var>&gt;_&lt;<var>name</var>&gt;(Record,
312271 Value)</i><br>
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
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
314273 this is not called `get_' as it performs unification and can perfectly
315274 well instantiate the argument.</span></sup>
316275
330289 !Record)</i><br>
331290 Destructively replace the argument &lt;<var>name</var>&gt; in <var>Record</var>
332291 by
333 <var>Value</var> based on <a id="idx:setarg3:2171"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>.
292 <var>Value</var> based on <a name="idx:setarg3:2170"></a><a class="pred" href="manipterm.html#setarg/3">setarg/3</a>.
334293 Use with care.
335294
336295 <p>
337296 <li><i>nb_set_&lt;<var>name</var>&gt;_of_&lt;<var>constructor</var>&gt;(+Value,
338297 !Record)</i><br>
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>.
298 As above, but using non-backtrackable assignment based on <a name="idx:nbsetarg3:2171"></a><a class="pred" href="manipterm.html#nb_setarg/3">nb_setarg/3</a>.
340299 Use with <em>extreme</em> care.
341300
342301 <p>
359318 </ul>
360319
361320 <dl class="latex">
362 <dt class="pubdef"><a id="record/1"><strong>record</strong>(<var>+Spec</var>)</a></dt>
321 <dt class="pubdef"><a name="record/1"><strong>record</strong>(<var>+Spec</var>)</a></dt>
363322 <dd class="defbody">
364323 The construct <code>:- record Spec, ...</code> is used to define access
365324 to named fields in a compound. It is subject to term-expansion (see
366 <a id="idx:expandterm2:2173"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>)
325 <a name="idx:expandterm2:2172"></a><a class="pred" href="consulting.html#expand_term/2">expand_term/2</a>)
367326 and cannot be called as a predicate. See
368 <a class="sec" href="record.html#sec:A.31">section A.31</a> for details.
327 <a class="sec" href="record.html">section A.31</a> for details.
369328 </dd>
370329 </dl>
371330
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="mtoplevel.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="moduleop.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:reexport"><a id="sec:6.7"><span class="sec-nr">6.7</span> <span class="sec-title">Composing
194 <h2 id="sec:reexport"><a name="sec:6.7"><span class="sec-nr">6.7</span> <span class="sec-title">Composing
236195 modules from other modules</span></a></h2>
237196
238 <a id="sec:reexport"></a>
197 <a name="sec:reexport"></a>
239198
240199 <p>The predicates in this section are intended to create new modules
241200 from the content of other modules. Below is an example to define a
242201 <em>composite</em> module. The example exports all public predicates of <code>module_1</code>, <code>module_2</code>
243 and <code>module_3</code>, <a id="idx:pred1:1714"></a><span class="pred-ext">pred/1</span>
202 and <code>module_3</code>, <a name="idx:pred1:1713"></a><span class="pred-ext">pred/1</span>
244203 from <code>module_4</code>, all predicates from <code>module_5</code>
245204 except
246 <a id="idx:donotuse1:1715"></a><span class="pred-ext">do_not_use/1</span>
205 <a name="idx:donotuse1:1714"></a><span class="pred-ext">do_not_use/1</span>
247206 and all predicates from <code>module_6</code> while renaming
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>.
207 <a name="idx:pred1:1715"></a><span class="pred-ext">pred/1</span> into <a name="idx:mypred1:1716"></a><span class="pred-ext">mypred/1</span>.
249208
250209 <pre class="code">
251210 :- module(my_composite, []).
259218 </pre>
260219
261220 <dl class="latex">
262 <dt class="pubdef"><a id="reexport/1"><strong>reexport</strong>(<var>+Files</var>)</a></dt>
221 <dt class="pubdef"><a name="reexport/1"><strong>reexport</strong>(<var>+Files</var>)</a></dt>
263222 <dd class="defbody">
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>
223 Load and import predicates as <a name="idx:usemodule1:1717"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>
265224 and re-export all imported predicates. The reexport declarations must
266225 immediately follow the module declaration.</dd>
267 <dt class="pubdef"><a id="reexport/2"><strong>reexport</strong>(<var>+File,
226 <dt class="pubdef"><a name="reexport/2"><strong>reexport</strong>(<var>+File,
268227 +Import</var>)</a></dt>
269228 <dd class="defbody">
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>
229 Import from <var>File</var> as <a name="idx:usemodule2:1718"></a><a class="pred" href="import.html#use_module/2">use_module/2</a>
271230 and re-export the imported predicates. The reexport declarations must
272231 immediately follow the module declaration.
273232 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.32</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="record.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="simplex.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:registry"><a id="sec:A.32"><span class="sec-nr">A.32</span> <span class="sec-title">library(registry):
194 <h2 id="sec:registry"><a name="sec:A.32"><span class="sec-nr">A.32</span> <span class="sec-title">library(registry):
236195 Manipulating the Windows registry</span></a></h2>
237196
238 <a id="sec:registry"></a>
197 <a name="sec:registry"></a>
239198
240199 <p>The <code>library(registry)</code> is only available on the
241200 MS-Windows version of SWI-Prolog. It loads the foreign extension <code>plregtry.dll</code>,
255214 <code>users</code>.
256215
257216 <dl class="latex">
258 <dt class="pubdef"><a id="registry_get_key/2"><strong>registry_get_key</strong>(<var>+Path,
217 <dt class="pubdef"><a name="registry_get_key/2"><strong>registry_get_key</strong>(<var>+Path,
259218 -Value</var>)</a></dt>
260219 <dd class="defbody">
261220 Get the principal (default) value associated to this key. Fails silently
262221 if the key does not exist.</dd>
263 <dt class="pubdef"><a id="registry_get_key/3"><strong>registry_get_key</strong>(<var>+Path,
222 <dt class="pubdef"><a name="registry_get_key/3"><strong>registry_get_key</strong>(<var>+Path,
264223 +Name, -Value</var>)</a></dt>
265224 <dd class="defbody">
266225 Get a named value associated to this key.</dd>
267 <dt class="pubdef"><a id="registry_set_key/2"><strong>registry_set_key</strong>(<var>+Path,
226 <dt class="pubdef"><a name="registry_set_key/2"><strong>registry_set_key</strong>(<var>+Path,
268227 +Value</var>)</a></dt>
269228 <dd class="defbody">
270229 Set the principal (default) value of this key. Creates (a path to) the
271230 key if it does not already exist.</dd>
272 <dt class="pubdef"><a id="registry_set_key/3"><strong>registry_set_key</strong>(<var>+Path,
231 <dt class="pubdef"><a name="registry_set_key/3"><strong>registry_set_key</strong>(<var>+Path,
273232 +Name, +Value</var>)</a></dt>
274233 <dd class="defbody">
275234 Associate a named value to this key. Creates (a path to) the key if it
276235 does not already exist.</dd>
277 <dt class="pubdef"><a id="registry_delete_key/1"><strong>registry_delete_key</strong>(<var>+Path</var>)</a></dt>
236 <dt class="pubdef"><a name="registry_delete_key/1"><strong>registry_delete_key</strong>(<var>+Path</var>)</a></dt>
278237 <dd class="defbody">
279238 Delete the indicated key.</dd>
280 <dt class="pubdef"><a id="shell_register_file_type/4"><strong>shell_register_file_type</strong>(<var>+Ext,
239 <dt class="pubdef"><a name="shell_register_file_type/4"><strong>shell_register_file_type</strong>(<var>+Ext,
281240 +Type, +Name, +OpenAction</var>)</a></dt>
282241 <dd class="defbody">
283242 Register a file-type. <var>Ext</var> is the extension to associate.
285244 <var>Name</var> is the name visible in the Windows file-type browser.
286245 Finally, <var>OpenAction</var> defines the action to execute when a file
287246 with this extension is opened in the Windows explorer.</dd>
288 <dt class="pubdef"><a id="shell_register_dde/6"><strong>shell_register_dde</strong>(<var>+Type,
247 <dt class="pubdef"><a name="shell_register_dde/6"><strong>shell_register_dde</strong>(<var>+Type,
289248 +Action, +Service, +Topic, +Command, +IfNotRunning</var>)</a></dt>
290249 <dd class="defbody">
291250 Associate DDE actions to a type. <var>Type</var> is the same type as
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>
251 used for the 2nd argument of <a name="idx:shellregisterfiletype4:2173"></a><a class="pred" href="registry.html#shell_register_file_type/4">shell_register_file_type/4</a>, <var>Action</var>
293252 is the action to perform, <var>Service</var> and <var>Topic</var>
294253 specify the DDE topic to address, and <var>Command</var> is the command
295254 to execute on this topic. Finally, <var>IfNotRunning</var> defines the
296255 command to execute if the required DDE server is not present.</dd>
297 <dt class="pubdef"><a id="shell_register_prolog/1"><strong>shell_register_prolog</strong>(<var>+Ext</var>)</a></dt>
256 <dt class="pubdef"><a name="shell_register_prolog/1"><strong>shell_register_prolog</strong>(<var>+Ext</var>)</a></dt>
298257 <dd class="defbody">
299258 Default registration of SWI-Prolog, which is invoked as part of the
300259 initialisation process on Windows systems. As the source also includes
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.10</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="importmodule.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="altmoduleapi.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:resmodules"><a id="sec:6.10"><span class="sec-nr">6.10</span> <span class="sec-title">Reserved
194 <h2 id="sec:resmodules"><a name="sec:6.10"><span class="sec-nr">6.10</span> <span class="sec-title">Reserved
236195 Modules and using the `user' module</span></a></h2>
237196
238 <a id="sec:resmodules"></a>
197 <a name="sec:resmodules"></a>
239198
240199 <p>As mentioned above, SWI-Prolog contains two special modules. The
241200 first one is the module <code>system</code>. This module contains all
249208 implies they can use all predicates imported into <code>user</code>
250209 without explicitly importing them. If an application loads all modules
251210 from the
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>,
211 <code>user</code> module using <a name="idx:usemodule1:1728"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,
253212 one achieves a scoping system similar to the C-language, where every
254213 module can access all exported predicates without any special
255214 precautions.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="foreignnotes.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="qsavelimits.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:runtime"><a id="sec:12"><span class="sec-nr">12</span> <span class="sec-title">Generating
194 <h1 id="sec:runtime"><a name="sec:12"><span class="sec-nr">12</span> <span class="sec-title">Generating
236195 Runtime Applications</span></a></h1>
237196
238 <a id="sec:runtime"></a>
197 <a name="sec:runtime"></a>
239198
240199 <p>This chapter describes the features of SWI-Prolog for delivering
241200 applications that can run without the development version of the system
245204 The first part is the <em>emulator</em>, which is machine-dependent. The
246205 second part is the <em>resource archive</em>, which contains the
247206 compiled program in a machine-independent format, startup options and
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>
207 possibly user-defined <em>resources</em>; see <a name="idx:resource3:2099"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>
249208 and
250 <a id="idx:openresource3:2101"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
209 <a name="idx:openresource3:2100"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
251210
252211 <p>These two parts can be connected in various ways. The most common way
253212 for distributed runtime applications is to <em>concatenate</em> the two
254213 parts. This can be achieved using external commands (Unix:
255214 <b>cat</b>, Windows: <b>copy</b>), or using the
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>.
215 <code>stand_alone</code> option to <a name="idx:qsaveprogram2:2101"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>.
257216 The second option is to attach a startup script in front of the resource
258217 that starts the emulator with the proper options. This is the default
259218 under Unix. Finally, an emulator can be told to use a specified resource
260219 file using the <strong>-x</strong> command line switch.
261220
262221 <dl class="latex">
263 <dt class="pubdef"><a id="qsave_program/2"><strong>qsave_program</strong>(<var>+File,
222 <dt class="pubdef"><a name="qsave_program/2"><strong>qsave_program</strong>(<var>+File,
264223 +Options</var>)</a></dt>
265224 <dd class="defbody">
266225 Saves the current state of the program to the file <var>File</var>. The
273232 <dl class="latex">
274233 <dt><strong>local</strong>(<var>+KBytes</var>)</dt>
275234 <dd class="defbody">
276 Limit for the local stack. See <a class="sec" href="cmdline.html#sec:2.4.3">section
235 Limit for the local stack. See <a class="sec" href="cmdline.html">section
277236 2.4.3</a>.
278237 </dd>
279238 <dt><strong>global</strong>(<var>+KBytes</var>)</dt>
280239 <dd class="defbody">
281 Limit for the global stack. See <a class="sec" href="cmdline.html#sec:2.4.3">section
240 Limit for the global stack. See <a class="sec" href="cmdline.html">section
282241 2.4.3</a>.
283242 </dd>
284243 <dt><strong>trail</strong>(<var>+KBytes</var>)</dt>
285244 <dd class="defbody">
286 Limit for the trail stack. See <a class="sec" href="cmdline.html#sec:2.4.3">section
245 Limit for the trail stack. See <a class="sec" href="cmdline.html">section
287246 2.4.3</a>.
288247 </dd>
289248 <dt><strong>goal</strong>(<var>:Callable</var>)</dt>
305264 If
306265 <code>kernel</code>, lock all predicates as system predicates. If
307266 <code>development</code>, save the predicates in their current state and
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>.
267 keep reading resources from their source (if present). See also <a name="idx:resource3:2102"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
309268 </dd>
310269 <dt><strong>autoload</strong>(<var>+Boolean</var>)</dt>
311270 <dd class="defbody">
312 If <code>true</code> (default), run <a id="idx:autoload0:2104"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
271 If <code>true</code> (default), run <a name="idx:autoload0:2103"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
313272 first.
314273 </dd>
315274 <dt><strong>map</strong>(<var>+File</var>)</dt>
329288 application has all libraries loaded, the resulting executable is
330289 completely independent of the runtime environment or location where it
331290 was built. See also
332 <a class="sec" href="compilation.html#sec:2.10.2.4">section 2.10.2.4</a>.
291 <a class="sec" href="compilation.html">section 2.10.2.4</a>.
333292 </dd>
334293 <dt><strong>emulator</strong>(<var>+File</var>)</dt>
335294 <dd class="defbody">
339298 <dd class="defbody">
340299 If <code>save</code>, include shared objects (DLLs) into the saved
341300 state. See
342 <a id="idx:currentforeignlibrary2:2105"></a><a class="pred" href="foreignlink.html#current_foreign_library/2">current_foreign_library/2</a>.
301 <a name="idx:currentforeignlibrary2:2104"></a><a class="pred" href="foreignlink.html#current_foreign_library/2">current_foreign_library/2</a>.
343302 If the program <b>strip</b> is available, this is first used to reduce
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>
303 the size of the shared object. If a state is started, <a name="idx:useforeignlibrary1:2105"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
345304 first tries to locate the foreign resource in the executable. When found
346305 it copies the content of the resource to a temporary file and loads it.
347306 If possible (Unix), the temporary object is deleted immediately after
348 opening.<sup class="fn">181<span class="fn-text">This option is
307 opening.<sup class="fn">180<span class="fn-text">This option is
349308 experimental and currently disabled by default. It will become the
350309 default if it proves robust.</span></sup>
351310 </dd>
352311 </dl>
353312
354313 </dd>
355 <dt class="pubdef"><a id="qsave_program/1"><strong>qsave_program</strong>(<var>+File</var>)</a></dt>
314 <dt class="pubdef"><a name="qsave_program/1"><strong>qsave_program</strong>(<var>+File</var>)</a></dt>
356315 <dd class="defbody">
357316 Equivalent to <code>qsave_program(File, [])</code>.</dd>
358 <dt class="pubdef"><a id="autoload/0"><strong>autoload</strong></a></dt>
317 <dt class="pubdef"><a name="autoload/0"><strong>autoload</strong></a></dt>
359318 <dd class="defbody">
360319 Check the current Prolog program for predicates that are referred to,
361320 are undefined and have a definition in the Prolog library. Load the
362321 appropriate libraries.
363322
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>
323 <p>This predicate is used by <a name="idx:qsaveprogram12:2106"></a><a class="pred" href="runtime.html#qsave_program/1">qsave_program/[1,2]</a>
365324 to ensure the saved state does not depend on availability of the
366325 libraries. The predicate
367 <a id="idx:autoload0:2108"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
326 <a name="idx:autoload0:2107"></a><a class="pred" href="runtime.html#autoload/0">autoload/0</a>
368327 examines all clauses of the loaded program (obtained with
369 <a id="idx:clause2:2109"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>)
328 <a name="idx:clause2:2108"></a><a class="pred" href="examineprog.html#clause/2">clause/2</a>)
370329 and analyzes the body for referenced goals. Such an analysis cannot be
371330 complete in Prolog, which allows for the creation of arbitrary terms at
372331 runtime and the use of them as a goal. The current analysis is limited
376335 <ul class="latex">
377336 <li>Direct goals appearing in the body
378337 <li>Arguments of declared meta-predicates that are marked with an
379 integer (0..9). See <a id="idx:metapredicate1:2110"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>.
338 integer (0..9). See <a name="idx:metapredicate1:2109"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>.
380339 </ul>
381340
382341 <p>The analysis of meta-predicate arguments is limited to cases where
393352
394353 <p>But, the calls to prove_simple/1 and prove_complex/1 in the example
395354 below are <em>not</em> discovered by the analysis and therefore the
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.
355 modules that define these predicates must be loaded explicitly using <a name="idx:usemodule1:2110"></a><a class="pred" href="import.html#use_module/1">use_module/1</a>,2.
397356
398357 <pre class="code">
399358 ...,
404363 Goal)),
405364 </pre>
406365
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>
366 <p>It is good practice to use <a name="idx:gxref0:2111"></a><a class="pred" href="xref.html#gxref/0">gxref/0</a>
408367 to make sure that the program has sufficient declarations such that the
409368 analaysis tools can verify that all required predicates can be resolved
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>
369 and that all code is called. See <a name="idx:metapredicate1:2112"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>, <a name="idx:dynamic1:2113"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>, <a name="idx:public1:2114"></a><a class="pred" href="dynamic.html#public/1">public/1</a>
411370 and prolog:called_by/2.</dd>
412 <dt class="pubdef"><a id="volatile/1"><strong>volatile</strong> <var>+Name/Arity,
371 <dt class="pubdef"><a name="volatile/1"><strong>volatile</strong> <var>+Name/Arity,
413372 ...</var></a></dt>
414373 <dd class="defbody">
415374 Declare that the clauses of specified predicates should <strong>not</strong>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 8.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="examples.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="guidelines.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:sicstus-chr"><a id="sec:8.6"><span class="sec-nr">8.6</span> <span class="sec-title">Backwards
194 <h2 id="sec:sicstus-chr"><a name="sec:8.6"><span class="sec-nr">8.6</span> <span class="sec-title">Backwards
236195 Compatibility</span></a></h2>
237196
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
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
240199 Old SICStus CHR implemenation</span></a></h3>
241200
242 <a id="sec:chr-sicstus"></a>
201 <a name="sec:chr-sicstus"></a>
243202
244203 <p>There are small differences between the current K.U.Leuven CHR system
245204 in SWI-Prolog, older versions of the same system, and SICStus' CHR
257216 <ul class="latex">
258217 <li><i>The constraints/1 declaration</i><br>
259218 This declaration is deprecated. It has been replaced with the
260 <a id="idx:chrconstraint1:1827"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
219 <a name="idx:chrconstraint1:1826"></a><a class="pred" href="practical.html#chr_constraint/1">chr_constraint/1</a>
261220 declaration.
262221
263222 <p>
264223 <li><i>The option/2 declaration</i><br>
265224 This declaration is deprecated. It has been replaced with the
266 <a id="idx:chroption2:1828"></a><a class="pred" href="SyntaxAndSemantics.html#chr_option/2">chr_option/2</a>
225 <a name="idx:chroption2:1827"></a><a class="pred" href="SyntaxAndSemantics.html#chr_option/2">chr_option/2</a>
267226 declaration.
268227
269228 <p>
283242 <li><i>Guard bindings</i><br>
284243 The <code>check_guard_bindings</code> option only turns invalid calls to
285244 unification into failure. In SICStus this option does more: it
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>
245 intercepts instantiation errors from Prolog built-ins such as <a name="idx:is2:1828"></a><a class="pred" href="arith.html#is/2">is/2</a>
287246 and turns them into failure. In SWI-Prolog, we do not go this far, as we
288247 like to separate concerns more. The CHR compiler is aware of the CHR
289248 code, the Prolog system, and the programmer should be aware of the
291250 rules.
292251 </ul>
293252
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
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
295254 Old ECLiPSe CHR implemenation</span></a></h3>
296255
297 <a id="sec:chr-eclipse"></a>
256 <a name="sec:chr-eclipse"></a>
298257
299258 <p>The old ECLiPSe CHR implementation features a label_with/1 construct
300259 for labeling variables in CHR constraints. This feature has long since
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.12</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="exception.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="DCG.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:signal"><a id="sec:4.12"><span class="sec-nr">4.12</span> <span class="sec-title">Handling
194 <h2 id="sec:signal"><a name="sec:4.12"><span class="sec-nr">4.12</span> <span class="sec-title">Handling
236195 signals</span></a></h2>
237196
238 <a id="sec:signal"></a>
197 <a name="sec:signal"></a>
239198
240199 <p>As of version 3.1.0, SWI-Prolog is able to handle software interrupts
241 (signals) in Prolog as well as in foreign (C) code (see <a class="sec" href="foreigninclude.html#sec:11.4.13">section
200 (signals) in Prolog as well as in foreign (C) code (see <a class="sec" href="foreigninclude.html">section
242201 11.4.13</a>).
243202
244203 <p>Signals are used to handle internal errors (execution of a
253212 communication (Unix kill() function).
254213
255214 <dl class="latex">
256 <dt class="pubdef"><a id="on_signal/3"><strong>on_signal</strong>(<var>+Signal,
215 <dt class="pubdef"><a name="on_signal/3"><strong>on_signal</strong>(<var>+Signal,
257216 -Old, :New</var>)</a></dt>
258217 <dd class="defbody">
259218 Determines the reaction on <var>Signal</var>. <var>Old</var> is unified
262221 retrieved using <code>on_signal(Signal, Current, Current)</code>.
263222
264223 <p>The action description is an atom denoting the name of the predicate
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>
224 that will be called if <var>Signal</var> arrives. <a name="idx:onsignal3:775"></a><a class="pred" href="signal.html#on_signal/3">on_signal/3</a>
266225 is a meta-predicate, which implies that &lt;<var>Module</var>&gt;:&lt;<var>Name</var>&gt;
267226 refers to &lt;<var>Name</var>&gt;/1 in module &lt;<var>Module</var>&gt;.
268227 The handler is called with a single argument: the name of the signal as
270229
271230 <p>Two predicate names have special meaning. <code>throw</code> implies
272231 Prolog will map the signal onto a Prolog exception as described in
273 <a class="sec" href="exception.html#sec:4.11">section 4.11</a>. <code>default</code>
232 <a class="sec" href="exception.html">section 4.11</a>. <code>default</code>
274233 resets the handler to the settings active before SWI-Prolog manipulated
275234 the handler.
276235
284243
285244 <p>The signal names are defined by the POSIX standard as symbols of the
286245 form <code>SIG</code>&lt;SIGNAME&gt;. The Prolog name for a signal is
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>
246 the lowercase version of &lt;SIGNAME&gt;. The predicate <a name="idx:currentsignal3:776"></a><a class="pred" href="signal.html#current_signal/3">current_signal/3</a>
288247 may be used to map between names and signals.
289248
290249 <p>Initially, some signals are mapped to <code>throw</code>, while all
292251 exception:
293252 <code>fpe</code>, <code>alrm</code>, <code>xcpu</code>, <code>xfsz</code>
294253 and <code>vtalrm</code>.</dd>
295 <dt class="pubdef"><a id="current_signal/3"><strong>current_signal</strong>(<var>?Name,
254 <dt class="pubdef"><a name="current_signal/3"><strong>current_signal</strong>(<var>?Name,
296255 ?Id, ?Handler</var>)</a></dt>
297256 <dd class="defbody">
298257 Enumerate the currently defined signal handling. <var>Name</var> is the
299258 signal name, <var>Id</var> is the numerical identifier and <var>Handler</var>
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>).
259 is the currently defined handler (see <a name="idx:onsignal3:777"></a><a class="pred" href="signal.html#on_signal/3">on_signal/3</a>).</dd>
260 <dt class="pubdef"><a name="prolog_alert_signal/2"><strong>prolog_alert_signal</strong>(<var>?Old,
261 +New</var>)</a></dt>
262 <dd class="defbody">
263 Query or set the signal used to unblock blocking system calls on Unix
264 systems and process pending Prolog signals. The default is
265 <code>SIGUSR2</code>. See also <strong>--sigalert</strong>.
301266 </dd>
302267 </dl>
303268
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
269 <p><h3 id="sec:signalhandling"><a name="sec:4.12.1"><span class="sec-nr">4.12.1</span> <span class="sec-title">Notes
305270 on signal handling</span></a></h3>
306271
307 <a id="sec:signalhandling"></a>
272 <a name="sec:signalhandling"></a>
308273
309274 <p>Before deciding to deal with signals in your application, please
310275 consider the following:
315280 On MS-Windows, the signal interface is severely limited. Different Unix
316281 brands support different sets of signals, and the relation between
317282 signal name and number may vary. Currently, the system only supports
318 signals numbered 1 to 32<sup class="fn">70<span class="fn-text">TBD: the
283 signals numbered 1 to 32<sup class="fn">69<span class="fn-text">TBD: the
319284 system should support the Unix realtime signals</span></sup>. Installing
320285 a signal outside the limited set of supported signals in MS-Windows
321286 crashes the application.
326291 foreign functions called from a handler cannot safely use the SWI-Prolog
327292 API and cannot use C longjmp(). Handlers defined as <code>throw</code>
328293 are unsafe. Handlers defined to call a predicate are safe. Note that the
329 predicate can call <a id="idx:throw1:776"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
294 predicate can call <a name="idx:throw1:778"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
330295 but the delivery is delayed until Prolog is in a safe state.
331296
332 <p>The C-interface described in <a class="sec" href="foreigninclude.html#sec:11.4.13">section
297 <p>The C-interface described in <a class="sec" href="foreigninclude.html">section
333298 11.4.13</a> provides the option
334299 <code>PL_SIGSYNC</code> to select either safe synchronous or unsafe
335300 asynchronous delivery.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.33</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="registry.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="solutionsequences.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:simplex"><a id="sec:A.33"><span class="sec-nr">A.33</span> <span class="sec-title">library(simplex):
194 <h2 id="sec:simplex"><a name="sec:A.33"><span class="sec-nr">A.33</span> <span class="sec-title">library(simplex):
236195 Solve linear programming problems</span></a></h2>
237196
238 <a id="sec:simplex"></a>
239
240 <p><a id="sec:simplex"></a>
197 <a name="sec:simplex"></a>
198
199 <p><a name="sec:simplex"></a>
241200
242201 <dl class="tags">
243202 <dt class="tag">author</dt>
244203 <dd>
245 <a class="url" href="https://www.metalevel.at">Markus Triska</a>
204 https://www.metalevel.atMarkus Triska
246205 </dd>
247206 </dl>
248207
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>
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>
252211
253212 <p>A <b>linear programming problem</b> or simply <b>linear program</b>
254213 (LP) consists of:
294253 <p>The most frequently used predicates are thus:
295254
296255 <dl class="latex">
297 <dt class="pubdef"><a id="gen_state/1"><strong>gen_state</strong>(<var>-State</var>)</a></dt>
256 <dt class="pubdef"><a name="gen_state/1"><strong>gen_state</strong>(<var>-State</var>)</a></dt>
298257 <dd class="defbody">
299258 Generates an initial state corresponding to an empty linear program.</dd>
300 <dt class="pubdef"><a id="constraint/3"><strong>constraint</strong>(<var>+Constraint,
259 <dt class="pubdef"><a name="constraint/3"><strong>constraint</strong>(<var>+Constraint,
301260 +S0, -S</var>)</a></dt>
302261 <dd class="defbody">
303262 Adds a linear or integrality constraint to the linear program
309268 or <code>&gt;=</code>. The coefficient <code>1</code> can be omitted. An
310269 integrality constraint is of the form <code>integral(Variable)</code>
311270 and constrains Variable to an integral value.</dd>
312 <dt class="pubdef"><a id="maximize/3"><strong>maximize</strong>(<var>+Objective,
271 <dt class="pubdef"><a name="maximize/3"><strong>maximize</strong>(<var>+Objective,
313272 +S0, -S</var>)</a></dt>
314273 <dd class="defbody">
315274 Maximizes the objective function, stated as a list of
317276 elements, with respect to the linear program corresponding to state
318277 <var>S0</var>. <code>\</code>arg{<var>S</var>} is unified with an
319278 internal representation of the solved instance.</dd>
320 <dt class="pubdef"><a id="minimize/3"><strong>minimize</strong>(<var>+Objective,
279 <dt class="pubdef"><a name="minimize/3"><strong>minimize</strong>(<var>+Objective,
321280 +S0, -S</var>)</a></dt>
322281 <dd class="defbody">
323282 Analogous to <a class="pred" href="simplex.html#maximize/3">maximize/3</a>.</dd>
324 <dt class="pubdef"><a id="variable_value/3"><strong>variable_value</strong>(<var>+State,
283 <dt class="pubdef"><a name="variable_value/3"><strong>variable_value</strong>(<var>+State,
325284 +Variable, -Value</var>)</a></dt>
326285 <dd class="defbody">
327286 <var>Value</var> is unified with the value obtained for <var>Variable</var>. <var>State</var>
328287 must correspond to a solved instance.</dd>
329 <dt class="pubdef"><a id="objective/2"><strong>objective</strong>(<var>+State,
288 <dt class="pubdef"><a name="objective/2"><strong>objective</strong>(<var>+State,
330289 -Objective</var>)</a></dt>
331290 <dd class="defbody">
332291 Unifies <var>Objective</var> with the result of the objective function
341300 be <i>non-negative</i>. This may change in future versions, and
342301 non-negativity constraints should therefore be stated explicitly.
343302
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
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
345304 column generation</span></a></h3>
346305
347 <p><a id="sec:simplex-delayed-column"></a>
306 <p><a name="sec:simplex-delayed-column"></a>
348307
349308 <p><i>Delayed column generation</i> means that more constraint columns
350309 are added to an existing LP. The following predicates are frequently
351310 used when this method is applied:
352311
353312 <dl class="latex">
354 <dt class="pubdef"><a id="constraint/4"><strong>constraint</strong>(<var>+Name,
313 <dt class="pubdef"><a name="constraint/4"><strong>constraint</strong>(<var>+Name,
355314 +Constraint, +S0, -S</var>)</a></dt>
356315 <dd class="defbody">
357316 Like <a class="pred" href="simplex.html#constraint/3">constraint/3</a>,
358317 and attaches the name <var>Name</var> (an atom or compound term) to the
359318 new constraint.</dd>
360 <dt class="pubdef"><a id="shadow_price/3"><strong>shadow_price</strong>(<var>+State,
319 <dt class="pubdef"><a name="shadow_price/3"><strong>shadow_price</strong>(<var>+State,
361320 +Name, -Value</var>)</a></dt>
362321 <dd class="defbody">
363322 Unifies <var>Value</var> with the shadow price corresponding to the
364323 linear constraint whose name is <var>Name</var>. <var>State</var> must
365324 correspond to a solved instance.</dd>
366 <dt class="pubdef"><a id="constraint_add/4"><strong>constraint_add</strong>(<var>+Name,
325 <dt class="pubdef"><a name="constraint_add/4"><strong>constraint_add</strong>(<var>+Name,
367326 +Left, +S0, -S</var>)</a></dt>
368327 <dd class="defbody">
369328 <var>Left</var> is a list of <code>Coefficient*Variable</code> terms.
374333
375334 <p>An example application of <i>delayed column generation</i> to solve a <i>bin
376335 packing</i> task is available from:
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
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
380339 LPs with special structure</span></a></h3>
381340
382 <p><a id="sec:simplex-special-structure"></a>
341 <p><a name="sec:simplex-special-structure"></a>
383342
384343 <p>The following predicates allow you to solve specific kinds of LPs
385344 more efficiently:
386345
387346 <dl class="latex">
388 <dt class="pubdef"><a id="transportation/4"><strong>transportation</strong>(<var>+Supplies,
347 <dt class="pubdef"><a name="transportation/4"><strong>transportation</strong>(<var>+Supplies,
389348 +Demands, +Costs, -Transport</var>)</a></dt>
390349 <dd class="defbody">
391350 Solves a transportation problem. <var>Supplies</var> and <var>Demands</var>
397356 the form of a list of lists that represents the transportation matrix,
398357 where element (<i>i</i>,<i>j</i>) denotes how many units to ship from <i>i</i>
399358 to <i>j</i>.</dd>
400 <dt class="pubdef"><a id="assignment/2"><strong>assignment</strong>(<var>+Cost,
359 <dt class="pubdef"><a name="assignment/2"><strong>assignment</strong>(<var>+Cost,
401360 -Assignment</var>)</a></dt>
402361 <dd class="defbody">
403362 Solves a linear assignment problem. <var>Cost</var> is a list of lists
409368 </dd>
410369 </dl>
411370
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>
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>
415374
416375 <p>We include a few examples for solving LPs with this library.
417376
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
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
419378 1</span></a></h4>
420379
421 <p><a id="sec:simplex-ex-1"></a>
380 <p><a name="sec:simplex-ex-1"></a>
422381
423382 <p>This is the "radiation therapy" example, taken from
424383 <i>Introduction to Operations Research</i> by Hillier and Lieberman.
425384
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:
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:
429387
430388 <pre class="code">
431389 :- use_module(library(simplex)).
452410 Val2 = 9 rdiv 2.
453411 </pre>
454412
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
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
456414 2</span></a></h4>
457415
458 <p><a id="sec:simplex-ex-2"></a>
416 <p><a name="sec:simplex-ex-2"></a>
459417
460418 <p>Here is an instance of the knapsack problem described above, where
461419 <code>C = 8</code>, and we have two types of items: One item with value
517475 does not necessarily yield an optimal solution in the presence of
518476 integrality constraints.
519477
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
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
521479 3</span></a></h4>
522480
523 <p><a id="sec:simplex-ex-3"></a>
481 <p><a name="sec:simplex-ex-3"></a>
524482
525483 <p>We are given:
526484
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section E.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="contrib.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="otherlicenses.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:softlicense"><a id="sec:E.2"><span class="sec-nr">E.2</span> <span class="sec-title">Software
194 <h2 id="sec:softlicense"><a name="sec:E.2"><span class="sec-nr">E.2</span> <span class="sec-title">Software
236195 support to keep track of license conditions</span></a></h2>
237196
238 <a id="sec:softlicense"></a>
197 <a name="sec:softlicense"></a>
239198
240199 <p>Given the above, it is possible that SWI-Prolog packages and
241200 extensions rely on the GPL, LGPL or other licenses. The predicates below
242201 allow for registering license requirements for Prolog files and foreign
243 modules. The predicate <a id="idx:license0:2344"></a><a class="pred" href="softlicense.html#license/0">license/0</a>
202 modules. The predicate <a name="idx:license0:2343"></a><a class="pred" href="softlicense.html#license/0">license/0</a>
244203 reports which components from the currently configured system are
245204 distributed under non-permissive open source licenses and therefore may
246205 need to be replaced to suit your requirements.
247206
248207 <dl class="latex">
249 <dt class="pubdef"><a id="license/0"><strong>license</strong></a></dt>
208 <dt class="pubdef"><a name="license/0"><strong>license</strong></a></dt>
250209 <dd class="defbody">
251210 Evaluate the license conditions of all loaded components. If the system
252211 contains one or more components that are licenced under GPL-like
253212 restrictions the system indicates this program may only be distributed
254213 under the <code>GPL</code> license as well as which components prohibit
255214 the use of other license conditions. Likewise for for LGPL components.</dd>
256 <dt class="pubdef"><a id="license/2"><strong>license</strong>(<var>+LicenseId,
215 <dt class="pubdef"><a name="license/2"><strong>license</strong>(<var>+LicenseId,
257216 +Component</var>)</a></dt>
258217 <dd class="defbody">
259218 Register the fact that <var>Component</var> is distributed under a
260219 license identified by <var>LicenseId</var>. Known license identifiers
261 can be listed using <a id="idx:knownlicenses0:2345"></a><a class="pred" href="softlicense.html#known_licenses/0">known_licenses/0</a>.
220 can be listed using <a name="idx:knownlicenses0:2344"></a><a class="pred" href="softlicense.html#known_licenses/0">known_licenses/0</a>.
262221 A new license can be registered as a known language using a declaration
263222 like below. The second argument defines the
264223 <em>category</em> if the license, which is one of <code>gpl</code>,
276235 </pre>
277236
278237 </dd>
279 <dt class="pubdef"><a id="license/1"><strong>license</strong>(<var>+LicenseId</var>)</a></dt>
238 <dt class="pubdef"><a name="license/1"><strong>license</strong>(<var>+LicenseId</var>)</a></dt>
280239 <dd class="defbody">
281240 Intended as a directive in Prolog source files. It takes the current
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
241 filename and calls <a name="idx:license2:2345"></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
284243 char *LicenseId, const char *Component</var>)</a></dt>
285244 <dd class="defbody">
286245 Intended for the install() procedure of foreign libraries. This call can
287246 be made <em>before</em> <a class="func" href="foreigninclude.html#PL_initialise()">PL_initialise()</a>.</dd>
288 <dt class="pubdef"><a id="known_licenses/0"><strong>known_licenses</strong></a></dt>
247 <dt class="pubdef"><a name="known_licenses/0"><strong>known_licenses</strong></a></dt>
289248 <dd class="defbody">
290249 List all licenses <em>known</em> to the system. This does not imply the
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>.
250 system contains code covered by the listed licenses. See <a name="idx:license2:2346"></a><a class="pred" href="softlicense.html#license/2">license/2</a>.
292251 </dd>
293252 </dl>
294253
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.34</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="simplex.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="tabling.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:solutionsequences"><a id="sec:A.34"><span class="sec-nr">A.34</span> <span class="sec-title">library(solution_sequences):
194 <h2 id="sec:solutionsequences"><a name="sec:A.34"><span class="sec-nr">A.34</span> <span class="sec-title">library(solution_sequences):
236195 Modify solution sequences</span></a></h2>
237196
238 <p><a id="sec:solutionsequences"></a>
197 <p><a name="sec:solutionsequences"></a>
239198
240199 <dl class="tags">
241200 <dt class="mtag">See also</dt>
252211 GROUP BY.
253212
254213 <p>These predicates were introduced in the context of the
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>
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>
258217 avoids duplicates in the result table and using
259218 <a class="pred" href="solutionsequences.html#order_by/2">order_by/2</a>
260219 produces a nicely ordered table.
301260 </dl>
302261
303262 <dl class="latex">
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,
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,
306265 :Goal</var>)</a></dt>
307266 <dd class="defbody">
308267 True if <var>Goal</var> is true and no previous solution of <var>Goal</var>
324283 </pre>
325284
326285 </dd>
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,
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,
329288 :Goal, +Options</var>)</a></dt>
330289 <dd class="defbody">
331290 Similar to <a class="pred" href="solutionsequences.html#distinct/1">distinct/1</a>,
349308 </dl>
350309
351310 </dd>
352 <dt class="pubdef"><a id="limit/2"><strong>limit</strong>(<var>+Count,
311 <dt class="pubdef"><a name="limit/2"><strong>limit</strong>(<var>+Count,
353312 :Goal</var>)</a></dt>
354313 <dd class="defbody">
355314 Limit the number of solutions. True if <var>Goal</var> is true,
356315 returning at most <var>Count</var> solutions. Solutions are returned as
357316 soon as they become available.</dd>
358 <dt class="pubdef"><a id="offset/2"><strong>offset</strong>(<var>+Count,
317 <dt class="pubdef"><a name="offset/2"><strong>offset</strong>(<var>+Count,
359318 :Goal</var>)</a></dt>
360319 <dd class="defbody">
361320 Ignore the first <var>Count</var> solutions. True if <var>Goal</var> is
362321 true and produces more than <var>Count</var> solutions. This predicate
363322 computes and ignores the first <var>Count</var> solutions.</dd>
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>
323 <dt class="pubdef"><a name="order_by/2"><strong>order_by</strong>(<var>Spec,
324 Goal</var>)</a></dt>
372325 <dd class="defbody">
373326 Order solutions according to <var>Spec</var>. <var>Spec</var> is a list
374327 of terms, where each element is one of. The ordering of solutions of <var>Goal</var>
387340 </dl>
388341
389342 </dd>
390 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="group_by/4"><strong>group_by</strong>(<var>+By,
343 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="group_by/4"><strong>group_by</strong>(<var>+By,
391344 +Template, :Goal, -Bag</var>)</a></dt>
392345 <dd class="defbody">
393346 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.7.4 Reference Manual: Section 1.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="swiorother.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="implhistory.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:sponsor"><a id="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Support
194 <h2 id="sec:sponsor"><a name="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Support
236195 the SWI-Prolog project</span></a></h2>
237196
238 <a id="sec:sponsor"></a>
197 <a name="sec:sponsor"></a>
239198
240199 <p>You can support the SWI-Prolog project in several ways. Academics are
241200 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.7.4 Reference Manual: Section 4.40</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="debugger.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="profile.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:statistics"><a id="sec:4.40"><span class="sec-nr">4.40</span> <span class="sec-title">Obtaining
194 <h2 id="sec:statistics"><a name="sec:4.40"><span class="sec-nr">4.40</span> <span class="sec-title">Obtaining
236195 Runtime Statistics</span></a></h2>
237196
238 <a id="sec:statistics"></a>
197 <a name="sec:statistics"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="statistics/2"><strong>statistics</strong>(<var>+Key,
200 <dt class="pubdef"><a name="statistics/2"><strong>statistics</strong>(<var>+Key,
242201 -Value</var>)</a></dt>
243202 <dd class="defbody">
244203 Unify system statistics determined by <var>Key</var> with <var>Value</var>.
247206 reasons. These keys are described in <a class="tab" href="statistics.html#tab:qpstatistics">table
248207 7</a>.
249208
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
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
253214 performed </td></tr>
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>
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>
264231 time since thread was started in seconds </td></tr>
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>
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>
295274 time since Prolog was started in seconds </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>
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>
303286 </table>
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>.
287 <div class="caption"><b>Table 6 : </b>Keys for <a name="idx:statistics2:1564"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>.
305288 Space is expressed in bytes. Time is expressed in seconds, represented
306289 as a floating point number.</div>
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
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
311294 milliseconds)</tr>
312 <tr class="hline"><td>runtime</td><td>[ CPU time, CPU time since last ]
295 <tbody>
296 <tr valign="top"><td>runtime</td><td>[ CPU time, CPU time since last ]
313297 (milliseconds, excluding time spent in garbage collection) </td></tr>
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,
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:1565"></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,
335317 time spent ] </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>
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>
339324 </table>
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>.
325 <div class="caption"><b>Table 7 : </b>Compatibility keys for <a name="idx:statistics2:1566"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>.
341326 Time is expressed in milliseconds.</div>
342 <a id="tab:qpstatistics"></a>
327 <a name="tab:qpstatistics"></a>
343328 </dd>
344 <dt class="pubdef"><a id="statistics/0"><strong>statistics</strong></a></dt>
329 <dt class="pubdef"><a name="statistics/0"><strong>statistics</strong></a></dt>
345330 <dd class="defbody">
346331 Display a table of system statistics on the stream <code>user_error</code>.</dd>
347 <dt class="pubdef"><a id="time/1"><strong>time</strong>(<var>:Goal</var>)</a></dt>
332 <dt class="pubdef"><a name="time/1"><strong>time</strong>(<var>:Goal</var>)</a></dt>
348333 <dd class="defbody">
349 Execute <var>Goal</var> just like <a id="idx:call1:1565"></a><a class="pred" href="metacall.html#call/1">call/1</a>
334 Execute <var>Goal</var> just like <a name="idx:call1:1567"></a><a class="pred" href="metacall.html#call/1">call/1</a>
350335 and print time used, number of logical inferences and the average number
351336 of <var>lips</var> (logical inferences per second). Note that SWI-Prolog
352337 counts the actual executed number of inferences rather than the number
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="swiprolog.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="swiorother.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:status"><a id="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Status
194 <h2 id="sec:status"><a name="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Status
236195 and releases</span></a></h2>
237196
238 <a id="sec:status"></a>
239
240 <p>This manual describes version 7.7.4 of SWI-Prolog. SWI-Prolog is
197 <a name="sec:status"></a>
198
199 <p>This manual describes version 7.6.4 of SWI-Prolog. SWI-Prolog is
241200 widely considered to be a robust and scalable implementation of the
242201 Prolog language. It is widely used in education and research. In
243202 addition, it is in use for <var>24 &times; 7</var> mission critical
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.18</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="IO.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="chario.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:streamstat"><a id="sec:4.18"><span class="sec-nr">4.18</span> <span class="sec-title">Status
194 <h2 id="sec:streamstat"><a name="sec:4.18"><span class="sec-nr">4.18</span> <span class="sec-title">Status
236195 of streams</span></a></h2>
237196
238 <a id="sec:streamstat"></a>
197 <a name="sec:streamstat"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="wait_for_input/3"><strong>wait_for_input</strong>(<var>+ListOfStreams,
200 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="wait_for_input/3"><strong>wait_for_input</strong>(<var>+ListOfStreams,
242201 -ReadyList, +TimeOut</var>)</a></dt>
243202 <dd class="defbody">
244203 Wait for input on one of the streams in <var>ListOfStreams</var> and
245204 return a list of streams on which input is available in <var>ReadyList</var>.
246 <a id="idx:waitforinput3:1066"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
205 <a name="idx:waitforinput3:1068"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
247206 waits for at most <var>TimeOut</var> seconds. <var>TimeOut</var> may be
248207 specified as a floating point number to specify fractions of a second.
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>
208 If <var>TimeOut</var> equals <code>infinite</code>, <a name="idx:waitforinput3:1069"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
250209 waits indefinitely. If <var>Timeout</var> is 0 or 0.0 this predicate
251 returns without waiting.<sup class="fn">91<span class="fn-text">Prior to
210 returns without waiting.<sup class="fn">90<span class="fn-text">Prior to
252211 7.3.23, the integer value `0' was the same as <code>infinite</code>.</span></sup>
253212
254213 <p>This predicate can be used to implement timeout while reading and to
268227 wait_for_input([user_input, P4], Inputs, 0).
269228 </pre>
270229
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
230 <p><a name="idx:select:1070"></a><a name="idx:poll:1071"></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
276236 <code>representation_error(timeout)</code> exception. If poll() is not
277237 supported by the OS, select() is used. The select() call can only handle
278238 file descriptors up to <code>FD_SETSIZE</code>. If the set contains a
279239 descriptor that exceeds this limit a
280240 <code>representation_error('FD_SETSIZE')</code> is raised.
281241
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>
242 <p>Note that <a name="idx:waitforinput3:1072"></a><a class="pred" href="streamstat.html#wait_for_input/3">wait_for_input/3</a>
283243 returns streams that have data waiting. This does not mean you can, for
284 example, call <a id="idx:read2:1071"></a><a class="pred" href="termrw.html#read/2">read/2</a>
244 example, call <a name="idx:read2:1073"></a><a class="pred" href="termrw.html#read/2">read/2</a>
285245 on the stream without blocking as the stream might hold an incomplete
286246 term. The predicate
287 <a id="idx:setstream2:1072"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
247 <a name="idx:setstream2:1074"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>
288248 using the option <code>timeout(Seconds)</code> can be used to make the
289249 stream generate an exception if no new data arrives within the timeout
290250 period. Suppose two processes communicate by exchanging Prolog terms.
301261 </pre>
302262
303263 </dd>
304 <dt class="pubdef"><a id="byte_count/2"><strong>byte_count</strong>(<var>+Stream,
264 <dt class="pubdef"><a name="byte_count/2"><strong>byte_count</strong>(<var>+Stream,
305265 -Count</var>)</a></dt>
306266 <dd class="defbody">
307267 Byte position in <var>Stream</var>. For binary streams this is the same
308 as <a id="idx:charactercount2:1073"></a><a class="pred" href="streamstat.html#character_count/2">character_count/2</a>.
268 as <a name="idx:charactercount2:1075"></a><a class="pred" href="streamstat.html#character_count/2">character_count/2</a>.
309269 For text files the number may be different due to multi-byte encodings
310270 or additional record separators (such as Control-M in Windows).</dd>
311 <dt class="pubdef"><a id="character_count/2"><strong>character_count</strong>(<var>+Stream,
271 <dt class="pubdef"><a name="character_count/2"><strong>character_count</strong>(<var>+Stream,
312272 -Count</var>)</a></dt>
313273 <dd class="defbody">
314274 Unify <var>Count</var> with the current character index. For input
315275 streams this is the number of characters read since the open; for output
316276 streams this is the number of characters written. Counting starts at 0.</dd>
317 <dt class="pubdef"><a id="line_count/2"><strong>line_count</strong>(<var>+Stream,
277 <dt class="pubdef"><a name="line_count/2"><strong>line_count</strong>(<var>+Stream,
318278 -Count</var>)</a></dt>
319279 <dd class="defbody">
320280 Unify <var>Count</var> with the number of lines read or written.
321281 Counting starts at 1.</dd>
322 <dt class="pubdef"><a id="line_position/2"><strong>line_position</strong>(<var>+Stream,
282 <dt class="pubdef"><a name="line_position/2"><strong>line_position</strong>(<var>+Stream,
323283 -Count</var>)</a></dt>
324284 <dd class="defbody">
325285 Unify <var>Count</var> with the position on the current line. Note that
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 5.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ext-lists.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ext-syntax.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:strings"><a id="sec:5.2"><span class="sec-nr">5.2</span> <span class="sec-title">The
194 <h2 id="sec:strings"><a name="sec:5.2"><span class="sec-nr">5.2</span> <span class="sec-title">The
236195 string type and its double quoted syntax</span></a></h2>
237196
238 <a id="sec:strings"></a>
197 <a name="sec:strings"></a>
239198
240199 <p>As of SWI-Prolog version&nbsp;7, text enclosed in double quotes
241200 (e.g.,
244203 on the global (term) stack. Strings represent sequences of Unicode
245204 characters including the character code 0 (zero). The length strings is
246205 limited by the available space on the global (term) stack (see
247 <a id="idx:setprologstack2:1594"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>).
206 <a name="idx:setprologstack2:1597"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>).
248207 Strings are distinct from lists, which makes it possible to detect them
249208 at runtime and print them using the string syntax, as illustrated below:
250209
265224 Prolog flag and does not define the term that is produced by back quoted
266225 text.
267226
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>
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>
272232 </table>
273233 <div class="caption"><b>Table 8 : </b>Mapping of double and back quoted
274234 text in the two modes.</div>
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
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
282241 that operate on strings</span></a></h3>
283242
284 <a id="sec:string-predicates"></a>
243 <a name="sec:string-predicates"></a>
285244
286245 <p>Strings may be manipulated by a set of predicates that is similar to
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
246 the manipulation of atoms. In addition to the list below, <a name="idx:string1:1598"></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
289248 4.6</a>.
290249
291250 <p>SWI-Prolog's string primitives are being synchronized with
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.
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.
302260
303261 <dl class="latex">
304 <dt class="pubdef"><a id="atom_string/2"><strong>atom_string</strong>(<var>?Atom,
262 <dt class="pubdef"><a name="atom_string/2"><strong>atom_string</strong>(<var>?Atom,
305263 ?String</var>)</a></dt>
306264 <dd class="defbody">
307265 Bi-directional conversion between an atom and a string. At least one of
308266 the two arguments must be instantiated. <var>Atom</var> can also be an
309267 integer or floating point number.</dd>
310 <dt class="pubdef"><a id="number_string/2"><strong>number_string</strong>(<var>?Number,
268 <dt class="pubdef"><a name="number_string/2"><strong>number_string</strong>(<var>?Number,
311269 ?String</var>)</a></dt>
312270 <dd class="defbody">
313271 Bi-directional conversion between a number and a string. At least one of
328286 before exponent, i.e., <code>"1e10"</code> is a valid number.
329287 </ul>
330288 </dd>
331 <dt class="pubdef"><a id="term_string/2"><strong>term_string</strong>(<var>?Term,
289 <dt class="pubdef"><a name="term_string/2"><strong>term_string</strong>(<var>?Term,
332290 ?String</var>)</a></dt>
333291 <dd class="defbody">
334292 Bi-directional conversion between a term and a string. If <var>String</var>
335293 is instantiated, it is parsed and the result is unified with <var>Term</var>.
336294 Otherwise <var>Term</var> is `written' using the option <code>quoted(true)</code>
337295 and the result is converted to <var>String</var>.</dd>
338 <dt class="pubdef"><a id="term_string/3"><strong>term_string</strong>(<var>?Term,
296 <dt class="pubdef"><a name="term_string/3"><strong>term_string</strong>(<var>?Term,
339297 ?String, +Options</var>)</a></dt>
340298 <dd class="defbody">
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>.
299 As <a name="idx:termstring2:1599"></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:1600"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
301 or <a name="idx:writeterm2:1601"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>.
344302 For example:
345303
346304 <pre class="code">
350308 </pre>
351309
352310 </dd>
353 <dt class="pubdef"><a id="string_chars/2"><strong>string_chars</strong>(<var>?String,
311 <dt class="pubdef"><a name="string_chars/2"><strong>string_chars</strong>(<var>?String,
354312 ?Chars</var>)</a></dt>
355313 <dd class="defbody">
356314 Bi-directional conversion between a string and a list of characters
357315 (one-character atoms). At least one of the two arguments must be
358316 instantiated.</dd>
359 <dt class="pubdef"><a id="string_codes/2"><strong>string_codes</strong>(<var>?String,
317 <dt class="pubdef"><a name="string_codes/2"><strong>string_codes</strong>(<var>?String,
360318 ?Codes</var>)</a></dt>
361319 <dd class="defbody">
362320 Bi-directional conversion between a string and a list of character
363321 codes. At least one of the two arguments must be instantiated.</dd>
364 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="text_to_string/2"><strong>text_to_string</strong>(<var>+Text,
322 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="text_to_string/2"><strong>text_to_string</strong>(<var>+Text,
365323 -String</var>)</a></dt>
366324 <dd class="defbody">
367325 Converts <var>Text</var> to a string. <var>Text</var> is an atom, string
368326 or list of characters (codes or chars). When running in
369327 <strong>--traditional</strong> mode, <code>'[]'</code> is ambiguous and
370328 interpreted as an empty string.</dd>
371 <dt class="pubdef"><a id="string_length/2"><strong>string_length</strong>(<var>+String,
329 <dt class="pubdef"><a name="string_length/2"><strong>string_length</strong>(<var>+String,
372330 -Length</var>)</a></dt>
373331 <dd class="defbody">
374332 Unify <var>Length</var> with the number of characters in <var>String</var>.
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>
333 This predicate is functionally equivalent to <a name="idx:atomlength2:1602"></a><a class="pred" href="manipatom.html#atom_length/2">atom_length/2</a>
376334 and also accepts atoms, integers and floats as its first argument.</dd>
377 <dt class="pubdef"><a id="string_code/3"><strong>string_code</strong>(<var>?Index,
335 <dt class="pubdef"><a name="string_code/3"><strong>string_code</strong>(<var>?Index,
378336 +String, ?Code</var>)</a></dt>
379337 <dd class="defbody">
380338 True when <var>Code</var> represents the character at the 1-based <var>Index</var>
385343 <var>String</var>. The mode <code>string_code(-,+,+)</code> is
386344 deterministic if the searched-for <var>Code</var> appears only once in <var>String</var>.
387345 See also
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,
346 <a name="idx:substring5:1603"></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,
390348 +String, -Code</var>)</a></dt>
391349 <dd class="defbody">
392 Semi-deterministic version of <a id="idx:stringcode3:1601"></a><a class="pred" href="strings.html#string_code/3">string_code/3</a>.
350 Semi-deterministic version of <a name="idx:stringcode3:1604"></a><a class="pred" href="strings.html#string_code/3">string_code/3</a>.
393351 In addition, this version provides strict range checking, throwing a
394352 domain error if <var>Index</var> is less than 1 or greater than the
395353 length of <var>String</var>. ECLiPSe provides this to support <code>String[Index]</code>
396354 notation.</dd>
397 <dt class="pubdef"><a id="string_concat/3"><strong>string_concat</strong>(<var>?String1,
355 <dt class="pubdef"><a name="string_concat/3"><strong>string_concat</strong>(<var>?String1,
398356 ?String2, ?String3</var>)</a></dt>
399357 <dd class="defbody">
400 Similar to <a id="idx:atomconcat3:1602"></a><a class="pred" href="manipatom.html#atom_concat/3">atom_concat/3</a>,
358 Similar to <a name="idx:atomconcat3:1605"></a><a class="pred" href="manipatom.html#atom_concat/3">atom_concat/3</a>,
401359 but the unbound argument will be unified with a string object rather
402360 than an atom. Also, if both <var>String1</var> and
403361 <var>String2</var> are unbound and <var>String3</var> is bound to text,
408366 particularly fast on long strings, as for each redo the system has to
409367 create two entirely new strings, while the list equivalent only creates
410368 a single new list-cell and moves some pointers around.</dd>
411 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="split_string/4"><strong>split_string</strong>(<var>+String,
369 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="split_string/4"><strong>split_string</strong>(<var>+String,
412370 +SepChars, +PadChars, -SubStrings</var>)</a></dt>
413371 <dd class="defbody">
414372 Break <var>String</var> into <var>SubStrings</var>. The <var>SepChars</var>
443401 <var>PadChars</var> or is equivalent to handle multiple adjacent
444402 separators as a single (often white space). The behaviour with partially
445403 overlapping sets of padding and separators should be considered
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,
404 undefined. See also <a name="idx:readstring5:1606"></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,
448406 ?Before, ?Length, ?After, ?SubString</var>)</a></dt>
449407 <dd class="defbody">
450408 <var>SubString</var> is a substring of <var>String</var>. There are <var>Before</var>
452410 contains <var>Length</var> character and is followed by <var>After</var>
453411 characters in <var>String</var>. If not enough information is provided
454412 to compute the start of the match, <var>String</var> is scanned
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>,
413 left-to-right. This predicate is functionally equivalent to <a name="idx:subatom5:1607"></a><a class="pred" href="manipatom.html#sub_atom/5">sub_atom/5</a>,
456414 but operates on strings. The following example splits a string of the
457415 form
458416 &lt;<var>name</var>&gt;=&lt;<var>value</var>&gt; into the name part (an
467425 </pre>
468426
469427 </dd>
470 <dt class="pubdef"><a id="atomics_to_string/2"><strong>atomics_to_string</strong>(<var>+List,
428 <dt class="pubdef"><a name="atomics_to_string/2"><strong>atomics_to_string</strong>(<var>+List,
471429 -String</var>)</a></dt>
472430 <dd class="defbody">
473431 <var>List</var> is a list of strings, atoms, integers or floating point
474432 numbers. Succeeds if <var>String</var> can be unified with the
475433 concatenated elements of <var>List</var>. Equivalent to <code>atomics_to_string(List,
476434 '', String)</code>.</dd>
477 <dt class="pubdef"><a id="atomics_to_string/3"><strong>atomics_to_string</strong>(<var>+List,
435 <dt class="pubdef"><a name="atomics_to_string/3"><strong>atomics_to_string</strong>(<var>+List,
478436 +Separator, -String</var>)</a></dt>
479437 <dd class="defbody">
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>,
438 Creates a string just like <a name="idx:atomicstostring2:1608"></a><a class="pred" href="strings.html#atomics_to_string/2">atomics_to_string/2</a>,
481439 but inserts
482440 <var>Separator</var> between each pair of inputs. For example:
483441
488446 </pre>
489447
490448 </dd>
491 <dt class="pubdef"><a id="string_upper/2"><strong>string_upper</strong>(<var>+String,
449 <dt class="pubdef"><a name="string_upper/2"><strong>string_upper</strong>(<var>+String,
492450 -UpperCase</var>)</a></dt>
493451 <dd class="defbody">
494452 Convert <var>String</var> to upper case and unify the result with
495453 <var>UpperCase</var>.</dd>
496 <dt class="pubdef"><a id="string_lower/2"><strong>string_lower</strong>(<var>+String,
454 <dt class="pubdef"><a name="string_lower/2"><strong>string_lower</strong>(<var>+String,
497455 LowerCase</var>)</a></dt>
498456 <dd class="defbody">
499457 Convert <var>String</var> to lower case and unify the result with
500458 <var>LowerCase</var>.</dd>
501 <dt class="pubdef"><a id="read_string/3"><strong>read_string</strong>(<var>+Stream,
459 <dt class="pubdef"><a name="read_string/3"><strong>read_string</strong>(<var>+Stream,
502460 ?Length, -String</var>)</a></dt>
503461 <dd class="defbody">
504462 Read at most <var>Length</var> characters from <var>Stream</var> and
505463 return them in the string <var>String</var>. If <var>Length</var> is
506464 unbound, <var>Stream</var> is read to the end and <var>Length</var> is
507465 unified with the number of characters read.</dd>
508 <dt class="pubdef"><a id="read_string/5"><strong>read_string</strong>(<var>+Stream,
466 <dt class="pubdef"><a name="read_string/5"><strong>read_string</strong>(<var>+Stream,
509467 +SepChars, +PadChars, -Sep, -String</var>)</a></dt>
510468 <dd class="defbody">
511469 Read a string from <var>Stream</var>, providing functionality similar to
512 <a id="idx:splitstring4:1606"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>.
470 <a name="idx:splitstring4:1609"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>.
513471 The predicate performs the following steps:
514472
515473 <p>
524482 terminated by the end of the input, <var>Sep</var> is unified with -1.
525483 </ol>
526484
527 <p>The predicate <a id="idx:readstring5:1607"></a><a class="pred" href="strings.html#read_string/5">read_string/5</a>
485 <p>The predicate <a name="idx:readstring5:1610"></a><a class="pred" href="strings.html#read_string/5">read_string/5</a>
528486 called repeatedly on an input until
529487 <var>Sep</var> is -1 (end of file) is equivalent to reading the entire
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>,
488 file into a string and calling <a name="idx:splitstring4:1611"></a><a class="pred" href="strings.html#split_string/4">split_string/4</a>,
531489 provided that <var>SepChars</var> and <var>PadChars</var> are not <em>partially
532490 overlapping</em>.<sup class="fn">144<span class="fn-text">Behaviour that
533491 is fully compatible would requite unlimited look-ahead.</span></sup>
543501 </pre>
544502
545503 </dd>
546 <dt class="pubdef"><a id="open_string/2"><strong>open_string</strong>(<var>+String,
504 <dt class="pubdef"><a name="open_string/2"><strong>open_string</strong>(<var>+String,
547505 -Stream</var>)</a></dt>
548506 <dd class="defbody">
549507 True when <var>Stream</var> is an input stream that accesses the content
553511 </dd>
554512 </dl>
555513
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
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
557515 text: strings, atoms and code lists</span></a></h3>
558516
559 <a id="sec:text-representation"></a>
517 <a name="sec:text-representation"></a>
560518
561519 <p>With the introduction of strings as a Prolog data type, there are
562520 three main ways to represent text: using strings, atoms or code lists.
569527 <dt><b>Lists of character codes</b></dt>
570528 <dd>
571529 is what you need if you want to <em>parse</em> text using Prolog grammar
572 rules (DCGs, see <a id="idx:phrase3:1609"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>).
530 rules (DCGs, see <a name="idx:phrase3:1612"></a><a class="pred" href="DCG.html#phrase/3">phrase/3</a>).
573531 Most of the text reading predicates (e.g.,
574 <a id="idx:readlinetocodes2:1610"></a><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a>)
532 <a name="idx:readlinetocodes2:1613"></a><a class="pred" href="readutil.html#read_line_to_codes/2">read_line_to_codes/2</a>)
575533 return a list of character codes because most applications need to parse
576534 these lines before the data can be processed.</dd>
577535 <dt><b>Atoms</b></dt>
589547 <dd>
590548 typically represents text that is processed as a unit most of the time,
591549 but which is not an identifier for something. Format specifications for
592 <a id="idx:format3:1611"></a><a class="pred" href="format.html#format/3">format/3</a>
550 <a name="idx:format3:1614"></a><a class="pred" href="format.html#format/3">format/3</a>
593551 is a good example. Another example is a descriptive text provided in an
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>.
552 application. Strings may be composed and decomposed using e.g., <a name="idx:stringconcat3:1615"></a><a class="pred" href="strings.html#string_concat/3">string_concat/3</a>
553 and <a name="idx:substring5:1616"></a><a class="pred" href="strings.html#sub_string/5">sub_string/5</a>
554 or converted for parsing using <a name="idx:stringcodes2:1617"></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:1618"></a><a class="pred" href="strings.html#string_codes/2">string_codes/2</a>.
598556 </dd>
599557 </dl>
600558
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
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
602560 code for double quoted strings</span></a></h3>
603561
604 <a id="sec:ext-dquotes-port"></a>
562 <a name="sec:ext-dquotes-port"></a>
605563
606564 <p>The predicates in this section can help adapting your program to the
607565 new convention for handling double quoted strings. We have adapted a
608566 huge code base with which we were not familiar in about half a day.
609567
610568 <dl class="latex">
611 <dt class="pubdef"><a id="list_strings/0"><strong>list_strings</strong></a></dt>
569 <dt class="pubdef"><a name="list_strings/0"><strong>list_strings</strong></a></dt>
612570 <dd class="defbody">
613571 This predicate may be used to assess compatibility issues due to the
614572 representation of double quoted text as string objects. See
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>.
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:1619"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
617575 The predicate lists source locations of string objects encountered in
618576 the program that are not considered safe. Such string need to be
619577 examined manually, after which one of the actions below may be
637595 command line option and code exploiting this mapping is also not
638596 portable to ISO compliant systems.
639597 <li>If the strings appear in facts and usage is safe, add a clause to
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>
598 the multifile predicate check:string_predicate/1 to silence <a name="idx:liststrings0:1620"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
641599 on all clauses of that predicate.
642600 <li>If the strings appear as an argument to a predicate that can handle
643601 string objects, add a clause to the multifile predicate
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>.
602 check:valid_string_goal/1 to silence <a name="idx:liststrings0:1621"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>.
645603 </ul>
646604 </dd>
647 <dt class="pubdef"><a id="check:string_predicate/1"><strong>check:string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
605 <dt class="pubdef"><a name="check:string_predicate/1"><strong>check:string_predicate</strong>(<var>:PredicateIndicator</var>)</a></dt>
648606 <dd class="defbody">
649607 Declare that <var>PredicateIndicator</var> has clauses that contain
650608 strings, but that this is safe. For example, if there is a predicate
651609 help_info/2 , where the second argument contains a double quoted string
652610 that is handled properly by the predicates of the applications' help
653611 system, add the following declaration to stop
654 <a id="idx:liststrings0:1619"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
612 <a name="idx:liststrings0:1622"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
655613 from complaining:
656614
657615 <pre class="code">
661619 </pre>
662620
663621 </dd>
664 <dt class="pubdef"><a id="check:valid_string_goal/1"><strong>check:valid_string_goal</strong>(<var>:Goal</var>)</a></dt>
622 <dt class="pubdef"><a name="check:valid_string_goal/1"><strong>check:valid_string_goal</strong>(<var>:Goal</var>)</a></dt>
665623 <dd class="defbody">
666624 Declare that calls to <var>Goal</var> are safe. The module qualification
667625 is the actual module in which <var>Goal</var> is defined. For example, a
668 call to <a id="idx:format3:1620"></a><a class="pred" href="format.html#format/3">format/3</a>
626 call to <a name="idx:format3:1623"></a><a class="pred" href="format.html#format/3">format/3</a>
669627 is resolved by the predicate system:format/3. and the code below
670628 specifies that the second argument may be a string (system predicates
671629 that accept strings are defined in the library).
679637 <p></dd>
680638 </dl>
681639
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
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
683641 has the representation of double quoted text changed?</span></a></h3>
684642
685 <a id="sec:ext-dquotes-motivation"></a>
643 <a name="sec:ext-dquotes-motivation"></a>
686644
687645 <p>Prolog defines two forms of quoted text. Traditionally, single quoted
688646 text is mapped to atoms while double quoted text is mapped to a list of
723681
724682 <p>Lacking runtime information, debuggers and the toplevel can only use
725683 heuristics to decide whether to print a list of integers as such or as a
726 string (see <a id="idx:portraytext1:1621"></a><span class="pred-ext">portray_text/1</span>).
684 string (see <a name="idx:portraytext1:1624"></a><span class="pred-ext">portray_text/1</span>).
727685
728686 <p>While experienced Prolog programmers have learned to cope with this,
729687 we still consider this an unfortunate situation.
791749 my_class(_).
792750 </pre>
793751
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>
752 <p>Finally, the predicate <a name="idx:stringcode3:1625"></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:1626"></a><a class="pred" href="builtinlist.html#memberchk/2">memberchk/2</a>
796754 on a list of codes. Although the string is still pushed onto the stack,
797755 it is more compact and only a single entity.
798756 </dd>
799757 </dl>
800758
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>
759 <p>We offer the predicate <a name="idx:liststrings0:1627"></a><a class="pred" href="strings.html#list_strings/0">list_strings/0</a>
802760 to help porting your program.
803761
804762 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="otherlicenses.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="predsummary.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>
240199 <hr>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="status.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="sponsor.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:swiorother"><a id="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Should
194 <h2 id="sec:swiorother"><a name="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Should
236195 I be using SWI-Prolog?</span></a></h2>
237196
238 <a id="sec:swiorother"></a>
197 <a name="sec:swiorother"></a>
239198
240199 <p>There are a number of reasons why it might be better to choose a
241200 commercial, or another free, Prolog system:
279238 SWI-Prolog provides a good command line environment, including `Do What
280239 I Mean', autocompletion, history and a tracer that operates on single
281240 key strokes. The system automatically recompiles modified parts of the
282 source code using the <a id="idx:make0:1"></a><a class="pred" href="consulting.html#make/0">make/0</a>
241 source code using the <a name="idx:make0:1"></a><a class="pred" href="consulting.html#make/0">make/0</a>
283242 command. The system can be instructed to open an arbitrary editor on the
284243 right file and line based on its source database. It ships with various
285244 graphical tools and can be combined with the SWI-Prolog editor, PDT
288247 <p>
289248 <li><i>Fast compiler</i><br>
290249 Even very large applications can be loaded in seconds on most machines.
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>.
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>.
293252
294253 <p>
295254 <li><i>Transparent compiled code</i><br>
316275 <p>
317276 <li><i>Flexibility</i><br>
318277 SWI-Prolog can easily be integrated with C, supporting non-determinism
319 in Prolog calling C as well as C calling Prolog (see <a class="sec" href="foreign.html#sec:11">section
278 in Prolog calling C as well as C calling Prolog (see <a class="sec" href="foreign.html">section
320279 11</a>). It can also be <em>embedded</em> in external programs (see
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.
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.
324282
325283 <p>
326284 <li><i>Threads</i><br>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 1.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="intro.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="status.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:swiprolog"><a id="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Positioning
194 <h2 id="sec:swiprolog"><a name="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Positioning
236195 SWI-Prolog</span></a></h2>
237196
238 <a id="sec:swiprolog"></a>
197 <a name="sec:swiprolog"></a>
239198
240199 <p>Most implementations of the Prolog language are designed to serve a
241200 limited set of use cases. SWI-Prolog is no exception to this rule.
278237 <cite><a class="cite" href="Bibliography.html#Demoen:CW350">Demoen, 2002</a></cite>.
279238 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>
280239 system. Together with YAP we developed a portability framework (see
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
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
284243 5</a>). The
285244 <em>string</em> data type and its supporting set of built-in predicates
286245 is compatibility with ECLiPSe.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.16</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="gc.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="cyclic.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:syntax"><a id="sec:2.16"><span class="sec-nr">2.16</span> <span class="sec-title">The
194 <h2 id="sec:syntax"><a name="sec:2.16"><span class="sec-nr">2.16</span> <span class="sec-title">The
236195 SWI-Prolog syntax</span></a></h2>
237196
238 <a id="sec:syntax"></a>
197 <a name="sec:syntax"></a>
239198
240199 <p>SWI-Prolog syntax is close to ISO-Prolog standard syntax, which is
241200 based on the Edinburgh Prolog syntax. A formal description can be found
242201 in the ISO standard document. For an informal introduction we refer to
243 Prolog text books (see <a class="sec" href="intro.html#sec:1">section 1</a>)
202 Prolog text books (see <a class="sec" href="intro.html">section 1</a>)
244203 and
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
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
249207 5</a> for more information.
250208
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
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
252210 Syntax Support</span></a></h3>
253211
254 <a id="sec:isosyntax"></a>
212 <a name="sec:isosyntax"></a>
255213
256214 <p>This section lists various extensions w.r.t. the ISO Prolog syntax.
257215
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
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
259217 Character Set</span></a></h4>
260218
261 <a id="sec:processorcharset"></a>
262
263 <p><a id="idx:ISOLatin1:212"></a><a id="idx:characterset:213"></a>The
219 <a name="sec:processorcharset"></a>
220
221 <p><a name="idx:ISOLatin1:214"></a><a name="idx:characterset:215"></a>The
264222 processor character set specifies the class of each character used for
265223 parsing Prolog source text. Character classification is fixed to
266 <a class="url" href="http://www.unicode.org/">Unicode</a>. See also <a class="sec" href="widechars.html#sec:2.19">section
224 http://www.unicode.org/Unicode. See also <a class="sec" href="widechars.html">section
267225 2.19</a>.
268226
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
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
270228 comments</span></a></h4>
271229
272 <a id="sec:nestedcomments"></a>
230 <a name="sec:nestedcomments"></a>
273231
274232 <p>SWI-Prolog allows for nesting <code>/* ... */</code> comments. Where
275233 the ISO standard accepts <code>/* ... /* ... */</code> as a comment,
293251
294252 </pre>
295253
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
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
297255 Escape Syntax</span></a></h4>
298256
299 <a id="sec:charescapes"></a>
257 <a name="sec:charescapes"></a>
300258
301259 <p>Within quoted atoms (using single quotes: <code>'&lt;atom&gt;'</code>)
302260 special characters are represented using escape sequences. An escape
442400
443401 <p>Character escaping is only available if
444402 <code>current_prolog_flag(character_escapes, true)</code> is active
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>
403 (default). See <a name="idx:currentprologflag2:216"></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:217"></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:218"></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:219"></a><a class="pred" href="format.html#writef/2">writef/2</a>
449407 sequence
450408 <code>\l</code> is illegal. It is advised to use the more widely
451409 supported
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>,
410 <a name="idx:format23:220"></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:221"></a><a class="pred" href="format.html#writef/2">writef/2</a>,
454412 either switch <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
455413 to <code>false</code>, or use double <code>\\</code>, as in <code>writef('\\l')</code>.
456414
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
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
458416 for non-decimal numbers</span></a></h4>
459417
460 <a id="sec:nondecsyntax"></a>
418 <a name="sec:nondecsyntax"></a>
461419
462420 <p>SWI-Prolog implements both Edinburgh and ISO representations for
463421 non-decimal numbers. According to Edinburgh syntax, such numbers are
467425 <code>0<em>[bxo]</em>&lt;<var>number</var>&gt;</code>. For example: <code>A is 0b100 \/ 0xf00</code>
468426 is a valid expression. Such numbers are always unsigned.
469427
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
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
471429 digit groups in large integers</span></a></h4>
472430
473 <a id="sec:digitgroupsyntax"></a>
431 <a name="sec:digitgroupsyntax"></a>
474432
475433 <p>SWI-Prolog supports splitting long integers into <em>digit groups</em>.
476434 Digit groups can be separated with the sequence &lt;<var>underscore</var>&gt;,
484442 1_000_/*more*/000
485443 </pre>
486444
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>,
445 <p>Integers can be printed using this notation with <a name="idx:format2:222"></a><a class="pred" href="format.html#format/2">format/2</a>,
488446 using the
489447 <code>~I</code> format specifier. For example:
490448
496454 <p>The current syntax has been proposed by Ulrich Neumerkel on the
497455 SWI-Prolog mailinglist.
498456
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
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
500458 and Infinity floats and their syntax</span></a></h4>
501459
502 <a id="sec:floatsyntax"></a>
460 <a name="sec:floatsyntax"></a>
503461
504462 <p>SWI-Prolog supports reading an printing `special' floating point
505463 values according to
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,
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,
509467
510468 <p>
511469 <ul class="latex">
531489
532490 <p>Note that, compliant with the ISO standard, SWI-Prolog arithmetic
533491 (see
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.,
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.,
537494
538495 <pre class="code">
539496 ?- A is 1/0.
547504 exchange data with languages that can represent the full range of IEEE
548505 doubles.
549506
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
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
551508 only underscore to introduce a variable</span></a></h4>
552509
553 <a id="sec:varprefix"></a>
510 <a name="sec:varprefix"></a>
554511
555512 <p>According to the ISO standard and most Prolog systems, identifiers
556513 that start with an uppercase letter or an underscore are variables. In
573530 uppercase letter is another category were the readability of the code
574531 improves using this option.
575532
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
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
577534 Prolog source</span></a></h4>
578535
579 <a id="sec:unicodesyntax"></a>
536 <a name="sec:unicodesyntax"></a>
580537
581538 <p>The ISO standard specifies the Prolog syntax in ASCII characters. As
582539 SWI-Prolog supports Unicode in source files we must extend the syntax.
583540 This section describes the implication for the source files, while
584 writing international source files is described in <a class="sec" href="projectfiles.html#sec:3.1.3">section
541 writing international source files is described in <a class="sec" href="projectfiles.html">section
585542 3.1.3</a>.
586543
587544 <p>The SWI-Prolog Unicode character classification is based on version
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>
545 6.0.0 of the Unicode standard. Please note that <a name="idx:chartype2:223"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a>
589546 and friends, intended to be used with all text except Prolog source
590547 code, is based on the C library locale-based classification routines.
591548
594551 <li><i>Quoted atoms and strings</i><br>
595552 Any character of any script can be used in quoted atoms and strings. The
596553 escape sequences <code>\uXXXX</code> and <code>\UXXXXXXXX</code> (see
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.
554 <a class="sec" href="syntax.html">section 2.16.1.3</a>) were introduced
555 to specify Unicode code points in ASCII files.
599556
600557 <p>
601558 <li><i>Atoms and Variables</i><br>
631588 character of other type</i>) are currently handled as `solo'.
632589 </ul>
633590
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
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
635592 variable checking</span></a></h4>
636593
637 <a id="sec:singleton"></a>
638
639 <p><a id="idx:singletonvariable:222"></a><a id="idx:anonymousvariable:223"></a>A <em>singleton
594 <a name="sec:singleton"></a>
595
596 <p><a name="idx:singletonvariable:224"></a><a name="idx:anonymousvariable:225"></a>A <em>singleton
640597 variable</em> is a variable that appears only one time in a clause. It
641598 can always be replaced by <code>_</code>, the
642599 <em>anonymous</em> variable. In some cases, however, people prefer to
643600 give the variable a name. As mistyping a variable is a common mistake,
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>)
601 Prolog systems generally give a warning (controlled by <a name="idx:stylecheck1:226"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>)
645602 if a variable is used only once. The system can be informed that a
646603 variable is meant to appear once by <em>starting</em> it with an
647604 underscore, e.g.,
673630 <p>Any normal variable appearing exactly once in the clause <em>and</em>
674631 any named singleton variables appearing more than once are reported.
675632 Below are some examples with warnings in the right column. Singleton
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>
633 messages can be suppressed using the <a name="idx:stylecheck1:227"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>
677634 directive.
678635
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>
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>
693650 </table>
694651
695652 <p><b>Semantic singletons</b>
696653
697654 <p>Starting with version 6.5.1, SWI-Prolog has <em>syntactic singletons</em>
698655 and <em>semantic singletons</em>. The first are checked by
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>
656 <a name="idx:readclause3:228"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a>
657 (and <a name="idx:readterm3:229"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
701658 using the option
702659 <code>singletons(warning)</code>). The latter are generated by the
703660 compiler for variables that appear alone in a <em>branch</em>. For
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.35</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="tty.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="files.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:system"><a id="sec:4.35"><span class="sec-nr">4.35</span> <span class="sec-title">Operating
194 <h2 id="sec:system"><a name="sec:4.35"><span class="sec-nr">4.35</span> <span class="sec-title">Operating
236195 System Interaction</span></a></h2>
237196
238 <a id="sec:system"></a>
197 <a name="sec:system"></a>
239198
240199 <p>The predicates in this section provide basic access to the operating
241200 system that has been part of the Prolog legacy tradition. Note that more
244203 <code>library(socket)</code>, <code>library(unix)</code> and <code>library(filesex)</code>.
245204
246205 <dl class="latex">
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>
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:1442"></a><a class="pred" href="system.html#shell/2">shell/2</a>
250209 for details.</dd>
251 <dt class="pubdef"><a id="shell/2"><strong>shell</strong>(<var>+Command,
210 <dt class="pubdef"><a name="shell/2"><strong>shell</strong>(<var>+Command,
252211 -Status</var>)</a></dt>
253212 <dd class="defbody">
254213 Execute <var>Command</var> on the operating system. <var>Command</var>
255214 is given to the Bourne shell (/bin/sh). <var>Status</var> is unified
256215 with the exit status of the command.
257216
258 <p>On Windows, <a id="idx:shell12:1441"></a><a class="pred" href="system.html#shell/1">shell/[1,2]</a>
217 <p>On Windows, <a name="idx:shell12:1443"></a><a class="pred" href="system.html#shell/1">shell/[1,2]</a>
259218 executes the command using the CreateProcess() API and waits for the
260219 command to terminate. If the command ends with a
261220 <code>&amp;</code> sign, the command is handed to the WinExec() API,
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>
221 which does not wait for the new task to terminate. See also <a name="idx:winexec2:1444"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
263222 and
264 <a id="idx:winshell2:1443"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>.
223 <a name="idx:winshell2:1445"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>.
265224 Please note that the CreateProcess() API does <b>not</b> imply the
266225 Windows command interpreter (<b>cmd.exe</b> and therefore commands that
267226 are built in the command interpreter can only be activated using the
274233
275234 <p>Note that many of the operations that can be achieved using the shell
276235 built-in commands can easily be achieved using Prolog primitives. See
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>,
236 <a name="idx:makedirectory1:1446"></a><a class="pred" href="files.html#make_directory/1">make_directory/1</a>, <a name="idx:deletefile1:1447"></a><a class="pred" href="files.html#delete_file/1">delete_file/1</a>, <a name="idx:renamefile2:1448"></a><a class="pred" href="files.html#rename_file/2">rename_file/2</a>,
278237 etc. The clib package provides <code>library(filesex)</code>,
279 implementing various high level file operations such as <a id="idx:copyfile2:1447"></a><span class="pred-ext">copy_file/2</span>.
238 implementing various high level file operations such as <a name="idx:copyfile2:1449"></a><span class="pred-ext">copy_file/2</span>.
280239 Using Prolog primitives instead of shell commands improves the
281240 portability of your program.
282241
283 <p>The library <code>library(process)</code> provides <a id="idx:processcreate3:1448"></a><span class="pred-ext">process_create/3</span>
242 <p>The library <code>library(process)</code> provides <a name="idx:processcreate3:1450"></a><span class="pred-ext">process_create/3</span>
284243 and several related primitives that support more fine-grained
285244 interaction with processes, including I/O redirection and management of
286245 asynchronous processes.</dd>
287 <dt class="pubdef"><a id="getenv/2"><strong>getenv</strong>(<var>+Name,
246 <dt class="pubdef"><a name="getenv/2"><strong>getenv</strong>(<var>+Name,
288247 -Value</var>)</a></dt>
289248 <dd class="defbody">
290249 Get environment variable. Fails silently if the variable does not exist.
291250 Please note that environment variable names are case-sensitive on Unix
292251 systems and case-insensitive on Windows.</dd>
293 <dt class="pubdef"><a id="setenv/2"><strong>setenv</strong>(<var>+Name,
252 <dt class="pubdef"><a name="setenv/2"><strong>setenv</strong>(<var>+Name,
294253 +Value</var>)</a></dt>
295254 <dd class="defbody">
296255 Set an environment variable. <var>Name</var> and <var>Value</var> must
297256 be instantiated to atoms or integers. The environment variable will be
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>.
257 passed to <a name="idx:shell02:1451"></a><a class="pred" href="system.html#shell/1">shell/[0-2]</a>
258 and can be requested using <a name="idx:getenv2:1452"></a><a class="pred" href="system.html#getenv/2">getenv/2</a>.
259 They also influence <a name="idx:expandfilename2:1453"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.
301260 Environment variables are shared between threads. Depending on the
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>
261 underlying C library, <a name="idx:setenv2:1454"></a><a class="pred" href="system.html#setenv/2">setenv/2</a>
262 and <a name="idx:unsetenv1:1455"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
304263 may not be thread-safe and may cause memory leaks. Only changing the
305264 environment once and before starting threads is safe in all versions of
306265 SWI-Prolog.</dd>
307 <dt class="pubdef"><a id="unsetenv/1"><strong>unsetenv</strong>(<var>+Name</var>)</a></dt>
266 <dt class="pubdef"><a name="unsetenv/1"><strong>unsetenv</strong>(<var>+Name</var>)</a></dt>
308267 <dd class="defbody">
309268 Remove an environment variable from the environment. Some systems lack
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>
269 the underlying unsetenv() library function. On these systems <a name="idx:unsetenv1:1456"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
311270 sets the variable to the empty string.</dd>
312 <dt class="pubdef"><a id="setlocale/3"><strong>setlocale</strong>(<var>+Category,
271 <dt class="pubdef"><a name="setlocale/3"><strong>setlocale</strong>(<var>+Category,
313272 -Old, +New</var>)</a></dt>
314273 <dd class="defbody">
315274 Set/Query the <em>locale</em> setting which tells the C library how to
316275 interpret text files, write numbers, dates, etc. Category is one of
317276 <code>all</code>, <code>collate</code>, <code>ctype</code>, <code>messages</code>,
318277 <code>monetary</code>, <code>numeric</code> or <code>time</code>. For
319 details, please consult the C library locale documentation. See also <a class="sec" href="widechars.html#sec:2.19.1">section
278 details, please consult the C library locale documentation. See also <a class="sec" href="widechars.html">section
320279 2.19.1</a>. Please note that the locale is shared between all threads
321 and thread-safe usage of <a id="idx:setlocale3:1455"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>
280 and thread-safe usage of <a name="idx:setlocale3:1457"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>
322281 is in general not possible. Do locale operations before starting threads
323282 or thoroughly study threading aspects of locale support in your
324283 environment before using in multithreaded environments. Locale settings
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>
284 are used by <a name="idx:formattime3:1458"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>, <a name="idx:collationkey2:1459"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
285 and <a name="idx:localesort2:1460"></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>
328287 <dd class="defbody">
329288 This predicate comes from the Quintus compatibility library and provides
330289 a partial implementation thereof. It provides access to some operating
334293 <dl class="latex">
335294 <dt><strong>system</strong>(<var>+Command</var>)</dt>
336295 <dd class="defbody">
337 Equivalent to calling <a id="idx:shell1:1459"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
296 Equivalent to calling <a name="idx:shell1:1461"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
338297 Use for compatibility only.</dd>
339298 <dt><strong>shell</strong>(<var>+Command</var>)</dt>
340299 <dd class="defbody">
341 Equivalent to calling <a id="idx:shell1:1460"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
300 Equivalent to calling <a name="idx:shell1:1462"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
342301 Use for compatibility only.</dd>
343302 <dt><strong>shell</strong></dt>
344303 <dd class="defbody">
345 Equivalent to calling <a id="idx:shell0:1461"></a><span class="pred-ext">shell/0</span>.
304 Equivalent to calling <a name="idx:shell0:1463"></a><span class="pred-ext">shell/0</span>.
346305 Use for compatibility only.</dd>
347306 <dt><strong>cd</strong></dt>
348307 <dd class="defbody">
349 Equivalent to calling <a id="idx:workingdirectory2:1462"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>
308 Equivalent to calling <a name="idx:workingdirectory2:1464"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>
350309 to the expansion (see
351 <a id="idx:expandfilename2:1463"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>)
310 <a name="idx:expandfilename2:1465"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>)
352311 of <code><code>~</code></code>. For compatibility only.</dd>
353312 <dt><strong>cd</strong>(<var>+Directory</var>)</dt>
354313 <dd class="defbody">
355 Equivalent to calling <a id="idx:workingdirectory2:1464"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
314 Equivalent to calling <a name="idx:workingdirectory2:1466"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
356315 Use for compatibility only.</dd>
357316 <dt><strong>argv</strong>(<var>-Argv</var>)</dt>
358317 <dd class="defbody">
370329 </dd>
371330 </dl>
372331
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
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
374333 Operating System Interaction</span></a></h3>
375334
376 <a id="sec:winsystem"></a>
335 <a name="sec:winsystem"></a>
377336
378337 <p>The predicates in this section are only available on the Windows
379338 version of SWI-Prolog. Their use is discouraged if there are portably
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>
339 alternatives. For example, <a name="idx:winexec2:1467"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
340 and <a name="idx:winshell2:1468"></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:1469"></a><a class="pred" href="system.html#shell/2">shell/2</a>
383342 or the more powerful
384 <a id="idx:processcreate3:1468"></a><span class="pred-ext">process_create/3</span>.
343 <a name="idx:processcreate3:1470"></a><span class="pred-ext">process_create/3</span>.
385344
386345 <dl class="latex">
387 <dt class="pubdef"><a id="win_exec/2"><strong>win_exec</strong>(<var>+Command,
346 <dt class="pubdef"><a name="win_exec/2"><strong>win_exec</strong>(<var>+Command,
388347 +Show</var>)</a></dt>
389348 <dd class="defbody">
390349 Windows only. Spawns a Windows task without waiting for its completion. <var>Show</var>
404363 <code>shownormal</code>. In addition, <code>iconic</code> is a synonym
405364 for <code>minimize</code> and
406365 <code>normal</code> for <code>shownormal</code>.</dd>
407 <dt class="pubdef"><a id="win_shell/3"><strong>win_shell</strong>(<var>+Operation,
366 <dt class="pubdef"><a name="win_shell/3"><strong>win_shell</strong>(<var>+Operation,
408367 +File, +Show</var>)</a></dt>
409368 <dd class="defbody">
410369 Windows only. Opens the document <var>File</var> using the Windows shell
411370 rules for doing so. <var>Operation</var> is one of <code>open</code>,
412371 <code>print</code> or <code>explore</code> or another operation
413372 registered with the shell for the given document type. On modern systems
414 it is also possible to pass a <a id="idx:URL:1469"></a>URL as <var>File</var>,
373 it is also possible to pass a <a name="idx:URL:1471"></a>URL as <var>File</var>,
415374 opening the URL in Windows default browser. This call interfaces to the
416375 Win32 API ShellExecute(). The <var>Show</var> argument determines the
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>
376 initial state of the opened window (if any). See <a name="idx:winexec2:1472"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
418377 for defined values.</dd>
419 <dt class="pubdef"><a id="win_shell/2"><strong>win_shell</strong>(<var>+Operation,
378 <dt class="pubdef"><a name="win_shell/2"><strong>win_shell</strong>(<var>+Operation,
420379 +File</var>)</a></dt>
421380 <dd class="defbody">
422381 Same as <code>win_shell(Operation, File, normal)</code></dd>
423 <dt class="pubdef"><a id="win_registry_get_value/3"><strong>win_registry_get_value</strong>(<var>+Key,
382 <dt class="pubdef"><a name="win_registry_get_value/3"><strong>win_registry_get_value</strong>(<var>+Key,
424383 +Name, -Value</var>)</a></dt>
425384 <dd class="defbody">
426385 Windows only. Fetches the value of a Windows registry key. <var>Key</var>
446405 </pre>
447406
448407 </dd>
449 <dt class="pubdef"><a id="win_folder/2"><strong>win_folder</strong>(<var>?Name,
408 <dt class="pubdef"><a name="win_folder/2"><strong>win_folder</strong>(<var>?Name,
450409 -Directory</var>)</a></dt>
451410 <dd class="defbody">
452411 True if <var>Name</var> is the Windows `CSIDL' of <var>Directory</var>.
465424 </pre>
466425
467426 </dd>
468 <dt class="pubdef"><a id="win_add_dll_directory/1"><strong>win_add_dll_directory</strong>(<var>+AbsDir</var>)</a></dt>
427 <dt class="pubdef"><a name="win_add_dll_directory/1"><strong>win_add_dll_directory</strong>(<var>+AbsDir</var>)</a></dt>
469428 <dd class="defbody">
470429 This predicate adds a directory to the search path for dependent DLL
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>.
430 files. If possible, this is achieved with <a name="idx:winadddlldirectory2:1473"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
472431 Otherwise, <code>%PATH%</code> is extended with the provided directory.
473432 <var>AbsDir</var> may be specified in the Prolog canonical syntax. See
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>
433 <a name="idx:prologtoosfilename2:1474"></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:1475"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
476435 passes an absolute path to the DLL if the destination DLL can be located
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,
436 from the specification using <a name="idx:absolutefilename3:1476"></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,
479438 -Cookie</var>)</a></dt>
480439 <dd class="defbody">
481440 This predicate adds a directory to the search path for dependent DLL
482441 files. If the call is successful it unifies <var>Cookie</var> with 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>
442 handle that must be passed to <a name="idx:winremovedlldirectory1:1477"></a><a class="pred" href="system.html#win_remove_dll_directory/1">win_remove_dll_directory/1</a>
484443 to remove the directory from the search path. Error conditions:
485444
486445 <p>
494453 or the underlying Windows API returns an error.
495454 </ul>
496455
497 <p>If <a id="idx:opensharedobject2:1476"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
456 <p>If <a name="idx:opensharedobject2:1478"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
498457 is passed an <em>absolute</em> path to a DLL on a Windows installation
499 that supports AddDllDirectory() and friends,<sup class="fn">130<span class="fn-text">Windows&nbsp;7
458 that supports AddDllDirectory() and friends,<sup class="fn">129<span class="fn-text">Windows&nbsp;7
500459 with up-to-date patches or Windows&nbsp;8.</span></sup> SWI-Prolog uses
501460 LoadLibraryEx() with the flags
502461 <code>LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR</code> and
503462 <code>LOAD_LIBRARY_SEARCH_DEFAULT_DIRS</code>. In this scenario,
504463 directories from <code>%PATH%</code> and <em>not</em> searched.
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>.
464 Additional directories can be added using <a name="idx:winadddlldirectory2:1479"></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:1480"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
509468 </dd>
510469 </dl>
511470
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
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
513472 with time and date</span></a></h3>
514473
515 <a id="sec:timedate"></a>
474 <a name="sec:timedate"></a>
516475
517476 <p>Representing time in a computer system is surprisingly complicated.
518477 There are a large number of time representations in use, and the correct
540499 opinion, using a floating point number is a more natural choice as we
541500 can use a natural unit and the interface does not need to be changed if
542501 a higher resolution is required in the future. Our unit of choice is the
543 second as it is the scientific unit.<sup class="fn">131<span class="fn-text">Using
502 second as it is the scientific unit.<sup class="fn">130<span class="fn-text">Using
544503 Julian days is a choice made by the Eclipse team. As conversion to dates
545504 is needed for a human readable notation of time and Julian days cannot
546505 deal naturally with leap seconds, we decided for the second as our unit.</span></sup>
550509
551510 <p>Where older versions of SWI-Prolog relied on the POSIX conversion
552511 functions, the current implementation uses
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
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
558516 and date data structures</span></a></h4>
559517
560 <a id="sec:dattimedata"></a>
518 <a name="sec:dattimedata"></a>
561519
562520 <p>We use the following time representations
563521
573531 and minute (0..59). The <var>S</var> field holds the seconds as a
574532 floating point number between 0.0 and 60.0. <var>Off</var> is an integer
575533 representing the offset relative to UTC in seconds, where positive
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>),
534 values are west of Greenwich. If converted from local time (see <a name="idx:stampdatetime3:1481"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>),
577535 <var>TZ</var> holds the name of the local timezone. If the timezone is
578536 not known, <var>TZ</var> is the atom <code><code>-</code></code>. <var>DST</var>
579537 is <code>true</code> if daylight saving time applies to the current
583541 <dt><strong>date</strong>(<var>Y,M,D</var>)</dt>
584542 <dd class="defbody">
585543 Date using the same values as described above. Extracted using
586 <a id="idx:datetimevalue3:1480"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.</dd>
544 <a name="idx:datetimevalue3:1482"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.</dd>
587545 <dt><strong>time</strong>(<var>H,Mn,S</var>)</dt>
588546 <dd class="defbody">
589547 Time using the same values as described above. Extracted using
590 <a id="idx:datetimevalue3:1481"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.
548 <a name="idx:datetimevalue3:1483"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.
591549 </dd>
592550 </dl>
593551
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
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
595553 and date predicates</span></a></h4>
596554
597 <a id="sec:datimepreds"></a>
555 <a name="sec:datimepreds"></a>
598556
599557 <dl class="latex">
600 <dt class="pubdef"><a id="get_time/1"><strong>get_time</strong>(<var>-TimeStamp</var>)</a></dt>
558 <dt class="pubdef"><a name="get_time/1"><strong>get_time</strong>(<var>-TimeStamp</var>)</a></dt>
601559 <dd class="defbody">
602560 Return the current time as a <var>TimeStamp</var>. The granularity is
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,
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,
606563 -DateTime, +TimeZone</var>)</a></dt>
607564 <dd class="defbody">
608565 Convert a <var>TimeStamp</var> to a <var>DateTime</var> in the given
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,
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,
615572 -TimeStamp</var>)</a></dt>
616573 <dd class="defbody">
617574 Compute the timestamp from a date/9 term. Values for month, day, hour,
618575 minute or second need not be normalized. This flexibility allows for
619576 easy computation of the time at any given number of these units from 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>.
577 given timestamp. Normalization can be achieved following this call with <a name="idx:stampdatetime3:1484"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>.
621578 This example computes the date 200 days after 2006-7-14:
622579
623580 <pre class="code">
660617 <p>Note that DST and offset calculation are based on the POSIX function
661618 mktime(). If mktime() returns an error, a representation_error
662619 <code>dst</code> is generated.</dd>
663 <dt class="pubdef"><a id="date_time_value/3"><strong>date_time_value</strong>(<var>?Key,
620 <dt class="pubdef"><a name="date_time_value/3"><strong>date_time_value</strong>(<var>?Key,
664621 +DateTime, ?Value</var>)</a></dt>
665622 <dd class="defbody">
666623 Extract values from a date/9 term. Provided keys are:
667624
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
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
671629 integer </td></tr>
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)
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)
682645 if dst is in effect </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>
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>
685648 </table>
686649 </dd>
687 <dt class="pubdef"><a id="format_time/3"><strong>format_time</strong>(<var>+Out,
650 <dt class="pubdef"><a name="format_time/3"><strong>format_time</strong>(<var>+Out,
688651 +Format, +StampOrDateTime</var>)</a></dt>
689652 <dd class="defbody">
690653 Modelled after POSIX strftime(), using GNU extensions. <var>Out</var> is
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>
654 a destination as specified with <a name="idx:withoutputto2:1485"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>. <var>Format</var>
692655 is an atom or string with the following conversions. Conversions start
693 with a percent (%) character.<sup class="fn">132<span class="fn-text">Descriptions
656 with a percent (%) character.<sup class="fn">131<span class="fn-text">Descriptions
694657 taken from Linux Programmer's Manual</span></sup>
695658 <var>StampOrDateTime</var> is either a numeric time-stamp, a term
696659 <code>date(Y,M,D,H,M,S,O,TZ,DST)</code> or a term <code>date(Y,M,D)</code>.
699662 <ul class="latex">
700663 <li><code>a</code><br>
701664 The abbreviated weekday name according to the current locale. Use
702 <a id="idx:formattime4:1484"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
665 <a name="idx:formattime4:1486"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
703666 for POSIX locale.
704667 <li><code>A</code><br>
705668 The full weekday name according to the current locale. Use
706 <a id="idx:formattime4:1485"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
669 <a name="idx:formattime4:1487"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
707670 for POSIX locale.
708671 <li><code>b</code><br>
709672 The abbreviated month name according to the current locale. Use
710 <a id="idx:formattime4:1486"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
673 <a name="idx:formattime4:1488"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
711674 for POSIX locale.
712675 <li><code>B</code><br>
713676 The full month name according to the current locale. Use
714 <a id="idx:formattime4:1487"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
677 <a name="idx:formattime4:1489"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
715678 for POSIX locale.
716679 <li><code>c</code><br>
717680 The preferred date and time representation for the current locale.
773736 <li><code>p</code><br>
774737 Either `AM' or `PM' according to the given time value, or the
775738 corresponding strings for the current locale. Noon is treated as `pm'
776 and midnight as `am'.<sup class="fn">133<span class="fn-text">Despite
739 and midnight as `am'.<sup class="fn">132<span class="fn-text">Despite
777740 the above clain, some locales yield <code>am</code> or <code>pm</code>
778741 in lower case.</span></sup>
779742 <li><code>P</code><br>
834797
835798 <p>The table below gives some format strings for popular time
836799 representations. RFC1123 is used by HTTP. The full implementation of
837 <a id="idx:httptimestamp2:1488"></a><span class="pred-ext">http_timestamp/2</span>
800 <a name="idx:httptimestamp2:1490"></a><span class="pred-ext">http_timestamp/2</span>
838801 as available from <code>library(http/http_header)</code> is here.
839802
840803 <pre class="code">
845808 Date, posix).
846809 </pre>
847810
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>
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>
854818 </table>
855819 </dd>
856 <dt class="pubdef"><a id="format_time/4"><strong>format_time</strong>(<var>+Out,
820 <dt class="pubdef"><a name="format_time/4"><strong>format_time</strong>(<var>+Out,
857821 +Format, +StampOrDateTime, +Locale</var>)</a></dt>
858822 <dd class="defbody">
859823 Format time given a specified <var>Locale</var>. This predicate is a
864828 and <code>B</code> format specifiers. The predicate is used to be able
865829 to emit POSIX locale week and month names for emitting standardised
866830 time-stamps such as RFC1123.</dd>
867 <dt class="pubdef"><a id="parse_time/2"><strong>parse_time</strong>(<var>+Text,
831 <dt class="pubdef"><a name="parse_time/2"><strong>parse_time</strong>(<var>+Text,
868832 -Stamp</var>)</a></dt>
869833 <dd class="defbody">
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,
834 Same as <code>parse_time(Text, _Format, Stamp)</code>. See <a name="idx:parsetime3:1491"></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,
872836 ?Format, -Stamp</var>)</a></dt>
873837 <dd class="defbody">
874838 Parse a textual time representation, producing a time-stamp. Supported
877841 Otherwise,
878842 <var>Format</var> is unified with the format encountered.
879843
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
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
883848 GMT </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>
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>
893859 </table>
894860 </dd>
895 <dt class="pubdef"><a id="day_of_the_week/2"><strong>day_of_the_week</strong>(<var>+Date,-DayOfTheWeek</var>)</a></dt>
861 <dt class="pubdef"><a name="day_of_the_week/2"><strong>day_of_the_week</strong>(<var>+Date,-DayOfTheWeek</var>)</a></dt>
896862 <dd class="defbody">
897863 Computes the day of the week for a given date.
898864 <code><var>Date</var> = date(<var>Year</var>,<var>Month</var>,<var>Day</var>)</code>.
901867 </dd>
902868 </dl>
903869
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
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
905871 the <b>swipl-win.exe</b> console window</span></a></h3>
906872
907 <a id="sec:plwin"></a>
873 <a name="sec:plwin"></a>
908874
909875 <p>The Windows executable <b>swipl-win.exe</b> console has a number of
910876 predicates to control the appearance of the console. Being totally
913879 predicates for reference here.
914880
915881 <dl class="latex">
916 <dt class="pubdef"><a id="window_title/2"><strong>window_title</strong>(<var>-Old,
882 <dt class="pubdef"><a name="window_title/2"><strong>window_title</strong>(<var>-Old,
917883 +New</var>)</a></dt>
918884 <dd class="defbody">
919885 Unify <var>Old</var> with the title displayed in the console and change
920886 the title to <var>New</var>.<sup class="fn">bug<span class="fn-text">This
921887 predicate should have been called <code>win_window_title</code> for
922888 consistent naming.</span></sup></dd>
923 <dt class="pubdef"><a id="win_window_pos/1"><strong>win_window_pos</strong>(<var>+ListOfOptions</var>)</a></dt>
889 <dt class="pubdef"><a name="win_window_pos/1"><strong>win_window_pos</strong>(<var>+ListOfOptions</var>)</a></dt>
924890 <dd class="defbody">
925891 Interface to the MS-Windows SetWindowPos() function, controlling size,
926892 position and stacking order of the window. <var>ListOfOptions</var> is a
955921 </dl>
956922
957923 </dd>
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>
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:1492"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>
927 and <a name="idx:wininsertmenuitem4:1493"></a><a class="pred" href="system.html#win_insert_menu_item/4">win_insert_menu_item/4</a>
962928 are present.</dd>
963 <dt class="pubdef"><a id="win_insert_menu/2"><strong>win_insert_menu</strong>(<var>+Label,
929 <dt class="pubdef"><a name="win_insert_menu/2"><strong>win_insert_menu</strong>(<var>+Label,
964930 +Before</var>)</a></dt>
965931 <dd class="defbody">
966932 Insert a new entry (pulldown) in the menu. If the menu already contains
976942 </pre>
977943
978944 </dd>
979 <dt class="pubdef"><a id="win_insert_menu_item/4"><strong>win_insert_menu_item</strong>(<var>+Pulldown,
945 <dt class="pubdef"><a name="win_insert_menu_item/4"><strong>win_insert_menu_item</strong>(<var>+Pulldown,
980946 +Label, +Before, :Goal</var>)</a></dt>
981947 <dd class="defbody">
982948 Add an item to the named <var>Pulldown</var> menu. <var>Label</var> and
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>,
949 <var>Before</var> are handled as in <a name="idx:wininsertmenu2:1494"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>,
984950 but the label <code><code>-</code></code> inserts a <em>separator</em>. <var>Goal</var>
985951 is called if the user selects the item.
986952 </dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.35</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="solutionsequences.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="threadpool.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:tabling"><a id="sec:A.35"><span class="sec-nr">A.35</span> <span class="sec-title">library(tabling):
194 <h2 id="sec:tabling"><a name="sec:A.35"><span class="sec-nr">A.35</span> <span class="sec-title">library(tabling):
236195 Tabled execution (SLG)</span></a></h2>
237196
238 <a id="sec:tabling"></a>
239
240 <p><a id="idx:SLGresolution:2175"></a>The library <code>library(tabling)</code>
197 <a name="sec:tabling"></a>
198
199 <p><a name="idx:SLGresolution:2174"></a>The library <code>library(tabling)</code>
241200 provides support for <em>Tabled execution</em> of one or more Prolog
242201 predicates, also called <em>SLG resolution</em>. Tabling a predicate
243202 provides two properties:
247206 <li>Re-evaluation of a tabled predicate is avoided by
248207 <em>memoizing</em> the answers. This can realise huge performance
249208 enhancements as illustrated in
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).
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).
255213
256214 <p>
257215 <li><em>Left recursion</em>, a goal calling a <em>variant</em> of itself
258216 recursively and thus <i>looping</i> under the normal Prolog SLD
259217 resolution is avoided by suspending the variant call and resuming it
260 with answers from the table. This is illustrated in <a class="sec" href="tabling.html#sec:A.35.2">section
218 with answers from the table. This is illustrated in <a class="sec" href="tabling.html">section
261219 A.35.2</a>.
262220 </ol>
263221
269227 evaluation, i.e., applying rules on the axioms and derived facts until a
270228 fixed point is reached. However, bottom-up evaluation typically derives
271229 many facts that are never used. Tabling provides a <em>goal oriented</em>
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>
230 resolution strategy for such problems and is enabled simply by adding a <a name="idx:table1:2175"></a><a class="pred" href="tabling.html#table/1">table/1</a>
273231 directive to the program.
274232
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
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
276234 1: using tabling for memoizing</span></a></h4>
277235
278 <a id="sec:tabling-memoize"></a>
236 <a name="sec:tabling-memoize"></a>
279237
280238 <p>As a first classical example we use tabling for <em>memoizing</em>
281239 intermediate results. We use Fibonacci numbers to illustrate the
360318 fib(F1, F2, I2, N, F).
361319 </pre>
362320
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
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
364322 2: avoiding non-termination</span></a></h4>
365323
366 <a id="sec:tabling-non-termination"></a>
324 <a name="sec:tabling-non-termination"></a>
367325
368326 <p>SLD resolution easily results in an infinite loop due to <em>left
369327 recursion</em>, a goal that (indirectly) calls a variant of itself or
412370 X = 'Leiden'.
413371 </pre>
414372
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>
373 <p>Again, the fact that a simple <a name="idx:table1:2176"></a><a class="pred" href="tabling.html#table/1">table/1</a>
416374 directive turns the pure logical specification into a fairly efficient
417375 algorithm is a clear advantage. Without tabling the program needs to be <em>stratified</em>,
418376 introducing a base layer with the raw connections, a second layer that
428386 and does not need to deal with maintaining consistency between the
429387 tables and ground facts.
430388
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
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
432390 directed tabling</span></a></h4>
433391
434 <a id="sec:tabling-mode-directed"></a>
435
436 <p><a id="idx:answersubsumptiontabling:2178"></a>Tabling as defined
392 <a name="sec:tabling-mode-directed"></a>
393
394 <p><a name="idx:answersubsumptiontabling:2177"></a>Tabling as defined
437395 above has a serious limitation. Although the definition of connection/2
438396 from section
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
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
444402 algorithm to search for more routes, eventually running out of memory.
445403
446404 <p>The solution to this problem is called <em>mode directed tabling</em>
447405 or
448 <em>answer subsumption</em>.<sup class="fn">184<span class="fn-text">The
406 <em>answer subsumption</em>.<sup class="fn">183<span class="fn-text">The
449407 term <em>answer subsumption</em> is used by XSB and <em>mode directed
450408 tabling</em> by YAP and B-Prolog. The idea is that some arguments are
451409 considered `outputs', where multiple values for the same `input' are
453411 name.</span></sup> In this execution model one or more arguments are <em>not</em>
454412 added to the table. Instead, we remember a single <em>aggregated</em>
455413 value for these arguments. The example below is derived from
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
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
460418 mode is compatible to XSB Prolog.</span></sup> This causes the tabling
461419 engine each time that it finds an new path to call shortest/3 and keep
462420 the shortest route.
535493 </dd>
536494 </dl>
537495
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
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
539497 predicate reference</span></a></h3>
540498
541499 <dl class="latex">
542 <dt class="pubdef"><a id="table/1"><strong>table</strong> <var>+PredicateIndicators</var></a></dt>
500 <dt class="pubdef"><a name="table/1"><strong>table</strong> <var>+PredicateIndicators</var></a></dt>
543501 <dd class="defbody">
544502 Prepare the given <var>PredicateIndicators</var> for tabling. Can only
545503 be used as a directive. The example below prepares the predicate
546 <span class="pred-ext">edge/2</span> and the non-terminal <span class="pred-ext">statement//1</span>
504 <span class="pred-ext">edge/2</span> and the non-terminal <span class="pred-ext">statement/3</span>
547505 for tabled execution.
548506
549507 <pre class="code">
560518
561519 <p><i>Mode directed tabling</i> is discussed in the general introduction
562520 section about tabling.</dd>
563 <dt class="pubdef"><a id="abolish_all_tables/0"><strong>abolish_all_tables</strong></a></dt>
521 <dt class="pubdef"><a name="abolish_all_tables/0"><strong>abolish_all_tables</strong></a></dt>
564522 <dd class="defbody">
565523 Remove all tables. This is normally used to free up the space or
566524 recompute the result after predicates on which the result for some
575533 </dl>
576534
577535 </dd>
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>
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>
579537 <dd class="defbody">
580538 Abolish all tables that unify with SubGoal.
581539 </dd>
582540 </dl>
583541
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
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
585543 the tabling implementation</span></a></h4>
586544
587 <a id="sec:tabling-about"></a>
545 <a name="sec:tabling-about"></a>
588546
589547 <p>The SWI-Prolog implementation uses <em>Delimited continuations</em>
590548 (see
591 <a class="sec" href="delcont.html#sec:4.10">section 4.10</a> to realise
549 <a class="sec" href="delcont.html">section 4.10</a> to realise
592550 suspension of variant calls. The initial version was written by Benoit
593551 Desouter and described in
594552 <cite><a class="cite" href="Bibliography.html#DBLP:journals/tplp/DesouterDS15">Desouter <em>et
595553 al.</em>, 2015</a></cite>. We moved the main data structures required
596554 for tabling, the <em>answer tables</em> (see
597 <a class="sec" href="db.html#sec:4.14.4">section 4.14.4</a>) and the <em>worklist</em>
555 <a class="sec" href="db.html">section 4.14.4</a>) and the <em>worklist</em>
598556 to SWI-Prolog's C&nbsp;core.
599 <em>Mode directed tabling</em> (<a class="sec" href="tabling.html#sec:A.35.3">section
557 <em>Mode directed tabling</em> (<a class="sec" href="tabling.html">section
600558 A.35.3</a>) is based on a prototype implementation by Fabrizio Riguzzi.
601559
602 <p>The <a id="idx:table1:2179"></a><a class="pred" href="tabling.html#table/1">table/1</a>
560 <p>The <a name="idx:table1:2178"></a><a class="pred" href="tabling.html#table/1">table/1</a>
603561 directive causes the creation of a wrapper calling the renamed original
604562 predicate. For example, the program in
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.
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.
610568
611569 <pre class="code">
612570 connection(A, B) :-
625583 'connection tabled'('Haarlem', 'Leiden').
626584 </pre>
627585
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
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
629587 of tabling</span></a></h4>
630588
631 <a id="sec:tabling-status"></a>
589 <a name="sec:tabling-status"></a>
632590
633591 <p>The current implementation is merely a first prototype. It needs
634592 several enhancements before we can consider it a serious competitor to
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.20</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="chario.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="manipterm.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:termrw"><a id="sec:4.20"><span class="sec-nr">4.20</span> <span class="sec-title">Term
194 <h2 id="sec:termrw"><a name="sec:4.20"><span class="sec-nr">4.20</span> <span class="sec-title">Term
236195 reading and writing</span></a></h2>
237196
238 <a id="sec:termrw"></a>
197 <a name="sec:termrw"></a>
239198
240199 <p>This section describes the basic term reading and writing predicates.
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>
200 The predicates <a name="idx:format12:1116"></a><a class="pred" href="format.html#format/1">format/[1,2]</a>
201 and <a name="idx:writef2:1117"></a><a class="pred" href="format.html#writef/2">writef/2</a>
243202 provide formatted output. Writing to Prolog data structures such as
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>.
203 atoms or code-lists is supported by <a name="idx:withoutputto2:1118"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>
204 and <a name="idx:format3:1119"></a><a class="pred" href="format.html#format/3">format/3</a>.
246205
247206 <p>Reading is sensitive to the Prolog flag <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>,
248207 which controls the interpretation of the <code><code>\</code></code>
249208 character in quoted atoms and strings.
250209
251210 <dl class="latex">
252 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_term/2"><strong>write_term</strong>(<var>+Term,
211 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_term/2"><strong>write_term</strong>(<var>+Term,
253212 +Options</var>)</a></dt>
254213 <dd class="defbody">
255 The predicate <a id="idx:writeterm2:1118"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
214 The predicate <a name="idx:writeterm2:1120"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
256215 is the generic form of all Prolog term-write predicates. Valid options
257216 are:
258217
259218 <dl class="latex">
260219 <dt><strong>attributes</strong>(<var>Atom</var>)</dt>
261220 <dd class="defbody">
262 Define how attributed variables (see <a class="sec" href="attvar.html#sec:7.1">section
221 Define how attributed variables (see <a class="sec" href="attvar.html">section
263222 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>.
264223 Defined values are <code>ignore</code> (ignore the attribute), <code>dots</code>
265224 (write the attributes as <code>{...}</code>), <code>write</code> (simply
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>
225 hand the attributes recursively to <a name="idx:writeterm2:1121"></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:1122"></a><a class="pred" href="attvar.html#attr_portray_hook/2">attr_portray_hook/2</a>).</dd>
268227 <dt><strong>back_quotes</strong>(<var>Atom</var>)</dt>
269228 <dd class="defbody">
270229 Fulfills the same role as the <a class="flag" href="flags.html#flag:back_quotes">back_quotes</a>
281240 <dd class="defbody">
282241 Define how non-text blobs are handled. By default, this is left to the
283242 write handler specified with the blob type. Using <code>portray</code>,
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
243 <a name="idx:portray1:1123"></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
286245 11.4.7</a>.</dd>
287246 <dt><strong>character_escapes</strong>(<var>Bool</var>)</dt>
288247 <dd class="defbody">
295254 <code>@(Template, Substitutions)</code>, where <var>Substitutions</var>
296255 is a list
297256 <var>Var</var> = <var>Value</var>. If <code>cycles</code> is <code>false</code>,
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>
299 raises a <code>domain_error</code>.<sup class="fn">92<span class="fn-text">The
257 <code>max_depth</code> is not given, and <var>Term</var> is cyclic, <a name="idx:writeterm2:1124"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
258 raises a <code>domain_error</code>.<sup class="fn">91<span class="fn-text">The
300259 cycles option and the cyclic term representation using the @-term are
301260 copied from SICStus Prolog. However, the default in SICStus is set to <code>false</code>
302261 and SICStus writes an infinite term if not protected by, e.g., the <code>depth_limit</code>
303262 option.</span></sup> See also the <code>cycles</code> option in
304 <a id="idx:readterm2:1123"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.</dd>
263 <a name="idx:readterm2:1125"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>.</dd>
305264 <dt><strong>dotlists</strong>(<var>Bool</var>)</dt>
306265 <dd class="defbody">
307266 If <code>true</code> (default <code>false</code>), write lists using the
308 dotted term notation rather than the list notation.<sup class="fn">93<span class="fn-text">Copied
267 dotted term notation rather than the list notation.<sup class="fn">92<span class="fn-text">Copied
309268 from ECLiPSe.</span></sup> Note that as of version&nbsp;7, the list
310269 constructor is
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>
270 <code>'[|]'</code>. Using <code>dotlists(true)</code>, <a name="idx:writeterm2:1126"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
312271 writes a list using `.' as constructor. This is intended for
313272 communication with programs such as other Prolog systems, that rely on
314273 this notation.</dd>
317276 If <code>true</code> (default <code>false</code>), add a fullstop token
318277 to the output. The dot is preceeded by a space if needed and followed by
319278 a space (default) or newline if the <code>nl(true)</code> option is also
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>
279 given.<sup class="fn">93<span class="fn-text">Compatible with http://eclipseclp.org/doc/bips/kernel/ioterm/write_term-3.htmlECLiPSe</span></sup></dd>
321280 <dt><strong>ignore_ops</strong>(<var>Bool</var>)</dt>
322281 <dd class="defbody">
323282 If <code>true</code>, the generic term representation (&lt;<var>functor</var>&gt;(&lt;<var>args</var>&gt;
324283 ... )) will be used for all terms. Otherwise (default), operators will
325 be used where appropriate.<sup class="fn">95<span class="fn-text">In
284 be used where appropriate.<sup class="fn">94<span class="fn-text">In
326285 traditional systems this flag also stops the syntactic sugar notation
327286 for lists and brace terms. In SWI-Prolog, these are controlled by the
328287 separate options <code>dotlists</code> and <code>brace_terms</code></span></sup>.</dd>
348307 <dd class="defbody">
349308 Define the reference module (default <code>user</code>). This defines
350309 the default value for the <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
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>
310 option as well as the operator definitions to use. See also <a name="idx:op3:1127"></a><a class="pred" href="operators.html#op/3">op/3</a>.</dd>
352311 <dt><strong>nl</strong>(<var>Bool</var>)</dt>
353312 <dd class="defbody">
354313 Add a newline to the output. See also the <code>fullstop</code> option.</dd>
358317 is a non-negative integer, will be written as a variable name. If <var>N</var>
359318 is an atom it is written without quotes. This extension allows for
360319 writing variables with user-provided names. The default is <code>false</code>.
361 See also <a id="idx:numbervars3:1126"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
320 See also <a name="idx:numbervars3:1128"></a><a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>
362321 and the option <code>variable_names</code>.</dd>
363322 <dt><strong>partial</strong>(<var>Bool</var>)</dt>
364323 <dd class="defbody">
367326 is intended to solve the problems with the code below. Calling <code>write_value(<code>.</code>)</code>
368327 writes <code>..</code>, which cannot be read. By adding <code>partial(true)</code>
369328 to the option list, it correctly emits <code>. .</code>. Similar
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>.
329 problems appear when emitting operators using multiple calls to <a name="idx:writeterm3:1129"></a><a class="pred" href="termrw.html#write_term/3">write_term/3</a>.
371330
372331 <pre class="code">
373332 write_value(Value) :-
382341 <dt><strong>portray_goal</strong>(<var>:Goal</var>)</dt>
383342 <dd class="defbody">
384343 Implies <code>portray(true)</code>, but calls <var>Goal</var> rather
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>,
344 than the predefined hook <a name="idx:portray1:1130"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>. <var>Goal</var>
345 is called through <a name="idx:call3:1131"></a><span class="pred-ext">call/3</span>,
387346 where the first argument is <var>Goal</var>, the second is the term to
388347 be printed and the 3rd argument is the current write option list. The
389348 write option list is copied from the write_term call, but the list is
391350 current priority.</dd>
392351 <dt><strong>portrayed</strong>(<var>Bool</var>)</dt>
393352 <dd class="defbody">
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>.
353 If <code>true</code>, the hook <a name="idx:portray1:1132"></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:1133"></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:1134"></a><a class="pred" href="termrw.html#print/1">print/1</a>.
397356 The default is <code>false</code>. This option is an extension to the
398357 ISO write_term options.</dd>
399358 <dt><strong>priority</strong>(<var>Integer</var>)</dt>
416375 <dd class="defbody">
417376 Determines whether and where extra white space is added to enhance
418377 readability. The default is <code>standard</code>, adding only space
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>.
378 where needed for proper tokenization by <a name="idx:readterm3:1135"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
420379 Currently, the only other value is <code>next_argument</code>, adding a
421380 space after a comma used to separate arguments in a term or list.</dd>
422381 <dt><strong>variable_names</strong>(<var>+List</var>)</dt>
432391 <var>Name</var> does not represent a valid Prolog variable name.
433392
434393 <p>The implementation binds the variables from <var>List</var> to a term
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>,
394 <code>'$VAR'</code>(<var>Name</var>). Like <a name="idx:writecanonical1:1136"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>,
436395 terms that where already bound to <code>'$VAR'</code>(<var>X</var>)
437 before <a id="idx:writeterm2:1135"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
396 before <a name="idx:writeterm2:1137"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
438397 are printed normally, unless the option <code>numbervars(true)</code> is
439398 also provided. If the option <code>numbervars(true)</code> is used, the
440399 user is responsible for avoiding collisions between assigned names and
441400 numbered names. See also the <code>variable_names</code> option of
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>
401 <a name="idx:readterm2:1138"></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:1139"></a><a class="pred" href="attvar.html#copy_term/3">copy_term/3</a>
446405 to obtain a copy that is free of attributed variables and handle the
447406 associated constraints as appropriate for the use-case.
448407 </dd>
449408 </dl>
450409
451410 </dd>
452 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_term/3"><strong>write_term</strong>(<var>+Stream,
411 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_term/3"><strong>write_term</strong>(<var>+Stream,
453412 +Term, +Options</var>)</a></dt>
454413 <dd class="defbody">
455 As <a id="idx:writeterm2:1138"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
414 As <a name="idx:writeterm2:1140"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
456415 but output is sent to <var>Stream</var> rather than the current output.</dd>
457 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="write_length/3"><strong>write_length</strong>(<var>+Term,
416 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="write_length/3"><strong>write_length</strong>(<var>+Term,
458417 -Length, +Options</var>)</a></dt>
459418 <dd class="defbody">
460419 True when <var>Length</var> is the number of characters emitted for
461420 <var>write_term</var>Term, Options . In addition to valid options for
462 <a id="idx:writeterm2:1139"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
421 <a name="idx:writeterm2:1141"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>,
463422 it processes the option:
464423
465424 <dl class="latex">
472431 </dl>
473432
474433 </dd>
475 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_canonical/1"><strong>write_canonical</strong>(<var>+Term</var>)</a></dt>
434 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_canonical/1"><strong>write_canonical</strong>(<var>+Term</var>)</a></dt>
476435 <dd class="defbody">
477436 Write <var>Term</var> on the current output stream using standard
478437 parenthesised prefix notation (i.e., ignoring operator declarations).
479438 Atoms that need quotes are quoted. Terms written with this predicate can
480439 always be read back, regardless of current operator declarations.
481 Equivalent to <a id="idx:writeterm2:1140"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
440 Equivalent to <a name="idx:writeterm2:1142"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
482441 using the options <code>ignore_ops</code>,
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>
442 <code>quoted</code> and <code>numbervars</code> after <a name="idx:numbervars4:1143"></a><a class="pred" href="manipterm.html#numbervars/4">numbervars/4</a>
484443 using the
485444 <code>singletons</code> option.
486445
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>
446 <p>Note that due to the use of <a name="idx:numbervars4:1144"></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:1145"></a><a class="pred" href="termrw.html#write_canonical/1">write_canonical/1</a>
489448 call. This used to be the case anyhow, as garbage collection between
490449 multiple calls to one of the write predicates can change the <code>_G</code>&lt;NNN&gt;
491450 identity of the variables.</dd>
492 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write_canonical/2"><strong>write_canonical</strong>(<var>+Stream,
451 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write_canonical/2"><strong>write_canonical</strong>(<var>+Stream,
493452 +Term</var>)</a></dt>
494453 <dd class="defbody">
495454 Write <var>Term</var> in canonical form on <var>Stream</var>.</dd>
496 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write/1"><strong>write</strong>(<var>+Term</var>)</a></dt>
455 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write/1"><strong>write</strong>(<var>+Term</var>)</a></dt>
497456 <dd class="defbody">
498457 Write <var>Term</var> to the current output, using brackets and
499458 operators where appropriate.</dd>
500 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="write/2"><strong>write</strong>(<var>+Stream,
459 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="write/2"><strong>write</strong>(<var>+Stream,
501460 +Term</var>)</a></dt>
502461 <dd class="defbody">
503462 Write <var>Term</var> to <var>Stream</var>.</dd>
504 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="writeq/1"><strong>writeq</strong>(<var>+Term</var>)</a></dt>
463 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="writeq/1"><strong>writeq</strong>(<var>+Term</var>)</a></dt>
505464 <dd class="defbody">
506465 Write <var>Term</var> to the current output, using brackets and
507466 operators where appropriate. Atoms that need quotes are quoted. Terms
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>
467 written with this predicate can be read back with <a name="idx:read1:1146"></a><a class="pred" href="termrw.html#read/1">read/1</a>
509468 provided the currently active operator declarations are identical.</dd>
510 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="writeq/2"><strong>writeq</strong>(<var>+Stream,
469 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="writeq/2"><strong>writeq</strong>(<var>+Stream,
511470 +Term</var>)</a></dt>
512471 <dd class="defbody">
513472 Write <var>Term</var> to <var>Stream</var>, inserting quotes.</dd>
514 <dt class="pubdef"><a id="writeln/1"><strong>writeln</strong>(<var>+Term</var>)</a></dt>
473 <dt class="pubdef"><a name="writeln/1"><strong>writeln</strong>(<var>+Term</var>)</a></dt>
515474 <dd class="defbody">
516475 Equivalent to <code>write(Term), nl.</code>. The output stream is
517476 locked, which implies no output from other threads can appear between
518477 the term and newline.</dd>
519 <dt class="pubdef"><a id="writeln/2"><strong>writeln</strong>(<var>+Stream,
478 <dt class="pubdef"><a name="writeln/2"><strong>writeln</strong>(<var>+Stream,
520479 +Term</var>)</a></dt>
521480 <dd class="defbody">
522481 Equivalent to <code>write(Stream, Term), nl(Stream).</code>. The output
523482 stream is locked, which implies no output from other threads can appear
524483 between the term and newline.</dd>
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>
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:1147"></a><a class="pred" href="termrw.html#print/1">print/1</a>
528487 acts as if defined as below.
529488
530489 <pre class="code">
538497 ]).
539498 </pre>
540499
541 <p>The <a id="idx:print1:1146"></a><a class="pred" href="termrw.html#print/1">print/1</a>
500 <p>The <a name="idx:print1:1148"></a><a class="pred" href="termrw.html#print/1">print/1</a>
542501 predicate is used primarily through the <code>~p</code> escape sequence
543 of <a id="idx:format2:1147"></a><a class="pred" href="format.html#format/2">format/2</a>,
502 of <a name="idx:format2:1149"></a><a class="pred" href="format.html#format/2">format/2</a>,
544503 which is commonly used in the recipies used by
545 <a id="idx:printmessage2:1148"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
504 <a name="idx:printmessage2:1150"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
546505 to emit messages.
547506
548507 <p>The classical definition of this predicate is equivalent to the ISO
549 predicate <a id="idx:writeterm2:1149"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
508 predicate <a name="idx:writeterm2:1151"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
550509 using the options <code>portray(true)</code> and
551510 <code>numbervars(true)</code>. The <code>portray(true)</code> option
552511 allows the user to implement application-specific printing of terms
553512 printed during debugging to facilitate easy understanding of the output.
554513 See also
555 <a id="idx:portray1:1150"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
514 <a name="idx:portray1:1152"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
556515 and <code>library(portray_text)</code>. SWI-Prolog adds <code>quoted(true)</code>
557516 to (1) facilitate the copying/pasting of terms that are not affected by
558 <a id="idx:portray1:1151"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
517 <a name="idx:portray1:1153"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
559518 and to (2) allow numbers, atoms and strings to be more easily
560519 distinguished, e.g., <code>42</code>, <code>'42'</code> and <code>"42"</code>.</dd>
561 <dt class="pubdef"><a id="print/2"><strong>print</strong>(<var>+Stream,
520 <dt class="pubdef"><a name="print/2"><strong>print</strong>(<var>+Stream,
562521 +Term</var>)</a></dt>
563522 <dd class="defbody">
564523 Print <var>Term</var> to <var>Stream</var>.</dd>
565 <dt class="pubdef"><a id="portray/1"><strong>portray</strong>(<var>+Term</var>)</a></dt>
524 <dt class="pubdef"><a name="portray/1"><strong>portray</strong>(<var>+Term</var>)</a></dt>
566525 <dd class="defbody">
567526 A dynamic predicate, which can be defined by the user to change the
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>
527 behaviour of <a name="idx:print1:1154"></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:1155"></a><a class="pred" href="termrw.html#print/1">print/1</a>
529 first calls <a name="idx:portray1:1156"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
571530 using the term as argument. For lists, only the list as a whole is given
572 to <a id="idx:portray1:1155"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>.
531 to <a name="idx:portray1:1157"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>.
573532 If
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>
533 <a name="idx:portray1:1158"></a><a class="pred" href="termrw.html#portray/1">portray/1</a>
534 succeeds <a name="idx:print1:1159"></a><a class="pred" href="termrw.html#print/1">print/1</a>
576535 assumes the term has been written.</dd>
577 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="read/1"><strong>read</strong>(<var>-Term</var>)</a></dt>
536 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="read/1"><strong>read</strong>(<var>-Term</var>)</a></dt>
578537 <dd class="defbody">
579538 Read the next Prolog term from the current input stream and unify it
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>
539 with <var>Term</var>. On a syntax error <a name="idx:read1:1160"></a><a class="pred" href="termrw.html#read/1">read/1</a>
581540 displays an error message, attempts to skip the erroneous term and
582541 fails. On reaching end-of-file
583542 <var>Term</var> is unified with the atom <code>end_of_file</code>.</dd>
584 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="read/2"><strong>read</strong>(<var>+Stream,
543 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="read/2"><strong>read</strong>(<var>+Stream,
585544 -Term</var>)</a></dt>
586545 <dd class="defbody">
587546 Read <var>Term</var> from <var>Stream</var>.</dd>
588 <dt class="pubdef"><a id="read_clause/3"><strong>read_clause</strong>(<var>+Stream,
547 <dt class="pubdef"><a name="read_clause/3"><strong>read_clause</strong>(<var>+Stream,
589548 -Term, +Options</var>)</a></dt>
590549 <dd class="defbody">
591 Equivalent to <a id="idx:readterm3:1159"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
550 Equivalent to <a name="idx:readterm3:1161"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
592551 but sets options according to the current compilation context and
593552 optionally processes comments. Defined options:
594553
595554 <dl class="latex">
596555 <dt><strong>syntax_errors</strong>(<var>+Atom</var>)</dt>
597556 <dd class="defbody">
598 See <a id="idx:readterm3:1160"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
557 See <a name="idx:readterm3:1162"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>,
599558 but the default is <code>dec10</code> (report and restart).</dd>
600559 <dt><strong>term_position</strong>(<var>-TermPos</var>)</dt>
601560 <dd class="defbody">
602 Same as for <a id="idx:readterm3:1161"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
561 Same as for <a name="idx:readterm3:1163"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
603562 <dt><strong>subterm_positions</strong>(<var>-TermPos</var>)</dt>
604563 <dd class="defbody">
605 Same as for <a id="idx:readterm3:1162"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
564 Same as for <a name="idx:readterm3:1164"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
606565 <dt><strong>variable_names</strong>(<var>-Bindings</var>)</dt>
607566 <dd class="defbody">
608 Same as for <a id="idx:readterm3:1163"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
567 Same as for <a name="idx:readterm3:1165"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.</dd>
609568 <dt><strong>process_comment</strong>(<var>+Boolean</var>)</dt>
610569 <dd class="defbody">
611570 If <code>true</code> (default), call
620579 </dd>
621580 </dl>
622581
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>
582 <p>The <code>singletons</code> option of <a name="idx:readterm3:1166"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
624583 is initialised from the active style-checking mode. The <code>module</code>
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,
584 option is initialised to the current compilation module (see <a name="idx:prologloadcontext2:1167"></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,
627586 +Options</var>)</a></dt>
628587 <dd class="defbody">
629588 Read a term from the current input stream and unify the term with
630589 <var>Term</var>. The reading is controlled by options from the list of
631590 <var>Options</var>. If this list is empty, the behaviour is the same as
632591 for
633 <a id="idx:read1:1166"></a><a class="pred" href="termrw.html#read/1">read/1</a>.
592 <a name="idx:read1:1168"></a><a class="pred" href="termrw.html#read/1">read/1</a>.
634593 The options are upward compatible with Quintus Prolog. The argument
635594 order is according to the ISO standard. Syntax errors are always
636 reported using exception-handling (see <a id="idx:catch3:1167"></a><a class="pred" href="exception.html#catch/3">catch/3</a>).
595 reported using exception-handling (see <a name="idx:catch3:1169"></a><a class="pred" href="exception.html#catch/3">catch/3</a>).
637596 Options:
638597
639598 <dl class="latex">
641600 <dd class="defbody">
642601 If <code>true</code>, read <code>`</code>...<code>`</code> to a string
643602 object (see
644 <a class="sec" href="strings.html#sec:5.2">section 5.2</a>). The default
645 depends on the Prolog flag
603 <a class="sec" href="strings.html">section 5.2</a>). The default depends
604 on the Prolog flag
646605 <a class="flag" href="flags.html#flag:back_quotes">back_quotes</a>.</dd>
647606 <dt><strong>character_escapes</strong>(<var>Bool</var>)</dt>
648607 <dd class="defbody">
649608 Defines how to read <code>\</code> escape sequences in quoted atoms. See
650609 the Prolog flag <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
651 in <a id="idx:currentprologflag2:1168"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.
610 in <a name="idx:currentprologflag2:1170"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>.
652611 (SWI-Prolog).</dd>
653612 <dt><strong>comments</strong>(<var>-Comments</var>)</dt>
654613 <dd class="defbody">
655614 Unify <var>Comments</var> with a list of <var>Position</var>-<var>Comment</var>,
656615 where
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>)
616 <var>Position</var> is a stream position object (see <a name="idx:streampositiondata3:1171"></a><a class="pred" href="IO.html#stream_position_data/3">stream_position_data/3</a>)
658617 indicating the start of a comment and <var>Comment</var> is a string
659618 object containing the text including delimiters of a comment. It returns
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>
619 all comments from where the <a name="idx:readterm2:1172"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
661620 call started up to the end of the term read.</dd>
662621 <dt><strong>cycles</strong>(<var>Bool</var>)</dt>
663622 <dd class="defbody">
664623 If <code>true</code> (default <code>false</code>), re-instantiate
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>
624 templates as produced by the corresponding <a name="idx:writeterm2:1173"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
666625 option. Note that the default is <code>false</code> to avoid
667626 misinterpretation of <code>@(Template, Substutions)</code>, while the
668 default of <a id="idx:writeterm2:1172"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
627 default of <a name="idx:writeterm2:1174"></a><a class="pred" href="termrw.html#write_term/2">write_term/2</a>
669628 is <code>true</code> because emitting cyclic terms without using the
670629 template construct produces an infinitely large term (read: it will
671630 generate an error after producing a huge amount of output).</dd>
673632 <dd class="defbody">
674633 If <code>true</code> (default <code>false</code>), read <code>.(a,[])</code>
675634 as a list, even if lists are internally nor constructed using the dot as
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
635 functor. This is primarily intended to read the output from <a name="idx:writecanonical1:1175"></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
678637 5.1</a>.</dd>
679638 <dt><strong>double_quotes</strong>(<var>Atom</var>)</dt>
680639 <dd class="defbody">
685644 <dd class="defbody">
686645 Specify <var>Module</var> for operators, <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a>
687646 flag and <a class="flag" href="flags.html#flag:double_quotes">double_quotes</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>
647 flag. The value of the latter two is overruled if the corresponding <a name="idx:readterm3:1176"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
689648 option is provided. If no module is specified, the current `source
690649 module' is used. (SWI-Prolog).</dd>
691650 <dt><strong>quasi_quotations</strong>(<var>-List</var>)</dt>
692651 <dd class="defbody">
693652 If present, unify <var>List</var> with the quasi quotations (see
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,
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,
696655 +Quotation, +VarDict, -Result)</code>, where <var>Syntax</var> is the
697656 term in
698657 <code>{|Syntax||..|}</code>, <var>Quotation</var> is a list of character
707666 underscore (`<code>_</code>') are not included in this list. (ISO). If <var>Vars</var>
708667 is the constant <code>warning</code>, singleton variables are reported
709668 using
710 <a id="idx:printmessage2:1175"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
669 <a name="idx:printmessage2:1177"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
711670 The variables appear in the order they have been read.</dd>
712671 <dt><strong>syntax_errors</strong>(<var>Atom</var>)</dt>
713672 <dd class="defbody">
714673 If <code>error</code> (default), throw an exception on a syntax error.
715674 Other values are <code>fail</code>, which causes a message to be printed
716675 using
717 <a id="idx:printmessage2:1176"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>,
676 <a name="idx:printmessage2:1178"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>,
718677 after which the predicate fails, <code>quiet</code> which causes the
719678 predicate to fail silently, and <code>dec10</code> which causes syntax
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>
679 errors to be printed, after which <a name="idx:readterm23:1179"></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:1180"></a><a class="pred" href="termrw.html#read_term/2">read_term/[2,3]</a>
722681 never fails. (Quintus, SICStus).</dd>
723682 <dt><strong>subterm_positions</strong>(<var>TermPos</var>)</dt>
724683 <dd class="defbody">
752711 corresponding subterm.</dd>
753712 <dt><strong>dict_position</strong>(<var><var>From</var>, <var>To</var>, <var>TagFrom</var>, <var>TagTo</var>, <var>KeyValuePosList</var></var>)</dt>
754713 <dd class="defbody">
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>,
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>,
757716 which is a list of
758717 <code>key_value_position/7</code> terms. The <code>key_value_position/7</code>
759718 terms appear in the order of the input. Because maps to not preserve
760719 ordering, the key is provided in the position description.</dd>
761720 <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>
762721 <dd class="defbody">
763 Used for key-value pairs in a map (see <a class="sec" href="dicts.html#sec:5.4">section
722 Used for key-value pairs in a map (see <a class="sec" href="dicts.html">section
764723 5.4</a>). It is similar to the <code>term_position/5</code> that would
765724 be created, except that the key and value positions do not need an
766725 intermediate list and the key is provided in <var>Key</var> to enable
780739 <dt><strong>term_position</strong>(<var>Pos</var>)</dt>
781740 <dd class="defbody">
782741 Unifies <var>Pos</var> with the starting position of the term read. <var>Pos</var>
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>
742 is of the same format as used by <a name="idx:streamproperty2:1181"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.</dd>
784743 <dt><strong>var_prefix</strong>(<var>Bool</var>)</dt>
785744 <dd class="defbody">
786745 If <code>true</code>, demand variables to start with an underscore. See
787 <a class="sec" href="syntax.html#sec:2.16.1.7">section 2.16.1.7</a>.</dd>
746 <a class="sec" href="syntax.html">section 2.16.1.7</a>.</dd>
788747 <dt><strong>variables</strong>(<var>Vars</var>)</dt>
789748 <dd class="defbody">
790749 Unify <var>Vars</var> with a list of variables in the term. The
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>.
750 variables appear in the order they have been read. See also <a name="idx:termvariables2:1182"></a><a class="pred" href="manipterm.html#term_variables/2">term_variables/2</a>.
792751 (ISO).</dd>
793752 <dt><strong>variable_names</strong>(<var>Vars</var>)</dt>
794753 <dd class="defbody">
801760 </dl>
802761
803762 </dd>
804 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="read_term/3"><strong>read_term</strong>(<var>+Stream,
763 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="read_term/3"><strong>read_term</strong>(<var>+Stream,
805764 -Term, +Options</var>)</a></dt>
806765 <dd class="defbody">
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,
766 Read term with options from <var>Stream</var>. See <a name="idx:readterm2:1183"></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,
809768 -Term, +Options</var>)</a></dt>
810769 <dd class="defbody">
811 Use <a id="idx:readterm3:1182"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
770 Use <a name="idx:readterm3:1184"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>
812771 to read the next term from <var>Atom</var>. <var>Atom</var> is either an
813 atom or a string object (see <a class="sec" href="strings.html#sec:5.2">section
772 atom or a string object (see <a class="sec" href="strings.html">section
814773 5.2</a>). It is not required for <var>Atom</var> to end with a
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,
774 full-stop. This predicate supersedes <a name="idx:atomtoterm3:1185"></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,
817776 +Help, +Special, +Prompt, -Term, -Bindings</var>)</a></dt>
818777 <dd class="defbody">
819 Similar to <a id="idx:readterm2:1184"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
778 Similar to <a name="idx:readterm2:1186"></a><a class="pred" href="termrw.html#read_term/2">read_term/2</a>
820779 using the option <code>variable_names</code>, but allows for history
821 substitutions. <a id="idx:readhistory6:1185"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
780 substitutions. <a name="idx:readhistory6:1187"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
822781 is used by the top level to read the user's actions. <var>Show</var> is
823782 the command the user should type to show the saved events. <var>Help</var>
824783 is the command to get an overview of the capabilities. <var>Special</var>
825784 is a list of commands that are not saved in the history. <var>Prompt</var>
826785 is the first prompt given. Continuation prompts for more lines are
827 determined by <a id="idx:prompt2:1186"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
786 determined by <a name="idx:prompt2:1188"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
828787 A
829788 <code>%w</code> in the prompt is substituted by the event number. See
830 <a class="sec" href="history.html#sec:2.7">section 2.7</a> for available
789 <a class="sec" href="history.html">section 2.7</a> for available
831790 substitutions.
832791
833 <p>SWI-Prolog calls <a id="idx:readhistory6:1187"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
792 <p>SWI-Prolog calls <a name="idx:readhistory6:1189"></a><a class="pred" href="termrw.html#read_history/6">read_history/6</a>
834793 as follows:
835794
836795 <pre class="code">
838797 </pre>
839798
840799 </dd>
841 <dt class="pubdef"><a id="prompt/2"><strong>prompt</strong>(<var>-Old,
800 <dt class="pubdef"><a name="prompt/2"><strong>prompt</strong>(<var>-Old,
842801 +New</var>)</a></dt>
843802 <dd class="defbody">
844 Set prompt associated with <a id="idx:read1:1188"></a><a class="pred" href="termrw.html#read/1">read/1</a>
803 Set prompt associated with <a name="idx:read1:1190"></a><a class="pred" href="termrw.html#read/1">read/1</a>
845804 and its derivatives. <var>Old</var> is first unified with the current
846805 prompt. On success the prompt will be set to <var>New</var> if this is
847806 an atom. Otherwise an error message is displayed. A prompt is printed if
849808 margin. It is also printed whenever a newline is given and the term has
850809 not been terminated. Prompts are only printed when the current input
851810 stream is <var>user</var>.</dd>
852 <dt class="pubdef"><a id="prompt1/1"><strong>prompt1</strong>(<var>+Prompt</var>)</a></dt>
811 <dt class="pubdef"><a name="prompt1/1"><strong>prompt1</strong>(<var>+Prompt</var>)</a></dt>
853812 <dd class="defbody">
854813 Sets the prompt for the next line to be read. Continuation lines will be
855 read using the prompt defined by <a id="idx:prompt2:1189"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
814 read using the prompt defined by <a name="idx:prompt2:1191"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>.
856815 </dd>
857816 </dl>
858817
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="threadcreate.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="threadcom.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:thmonitor"><a id="sec:9.2"><span class="sec-nr">9.2</span> <span class="sec-title">Monitoring
194 <h2 id="sec:thmonitor"><a name="sec:9.2"><span class="sec-nr">9.2</span> <span class="sec-title">Monitoring
236195 threads</span></a></h2>
237196
238 <a id="sec:thmonitor"></a>
197 <a name="sec:thmonitor"></a>
239198
240199 <p>Normal multithreaded applications should not need the predicates from
241200 this section because almost any usage of these predicates is unsafe. For
242201 example checking the existence of a thread before signalling it is of no
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>
202 use as it may vanish between the two calls. Catching exceptions using <a name="idx:catch3:1875"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
244203 is the only safe way to deal with thread-existence errors.
245204
246205 <p>These predicates are provided for diagnosis and monitoring tasks. See
247 also <a class="sec" href="thutil.html#sec:9.5">section 9.5</a>,
248 describing more high-level primitives.
206 also <a class="sec" href="thutil.html">section 9.5</a>, describing more
207 high-level primitives.
249208
250209 <dl class="latex">
251 <dt class="pubdef"><a id="is_thread/1"><strong>is_thread</strong>(<var>@Term</var>)</a></dt>
210 <dt class="pubdef"><a name="is_thread/1"><strong>is_thread</strong>(<var>@Term</var>)</a></dt>
252211 <dd class="defbody">
253212 True if <var>Term</var> is a handle to an existing thread.</dd>
254 <dt class="pubdef"><a id="thread_property/2"><strong>thread_property</strong>(<var>?Id,
213 <dt class="pubdef"><a name="thread_property/2"><strong>thread_property</strong>(<var>?Id,
255214 ?Property</var>)</a></dt>
256215 <dd class="defbody">
257216 True if thread <var>Id</var> has <var>Property</var>. Either or both
258217 arguments may be unbound, enumerating all relations on backtracking.
259 Calling <a id="idx:threadproperty2:1877"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>
218 Calling <a name="idx:threadproperty2:1876"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>
260219 does not influence any thread. See also
261 <a id="idx:threadjoin2:1878"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
220 <a name="idx:threadjoin2:1877"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
262221 For threads that have an alias name, this name is returned in <var>Id</var>
263222 instead of the opaque thread identifier. Defined properties are:
264223
285244 note that threads waiting for something are considered running too.</dd>
286245 <dt><strong>suspended</strong></dt>
287246 <dd class="defbody">
288 Only if the thread is an engine (see <a class="sec" href="engines.html#sec:10">section
247 Only if the thread is an engine (see <a class="sec" href="engines.html">section
289248 10</a>). Indicates that the engine is currently not associated with an
290249 OS thread.</dd>
291250 <dt><strong>false</strong></dt>
296255 The <var>Goal</var> of the thread has been completed and succeeded.</dd>
297256 <dt><strong>exited</strong>(<var>Term</var>)</dt>
298257 <dd class="defbody">
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>
258 The <var>Goal</var> of the thread has been terminated using <a name="idx:threadexit1:1878"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
300259 with <var>Term</var> as argument. If the underlying native thread has
301260 exited (using pthread_exit()) <var>Term</var> is unbound.</dd>
302261 <dt><strong>exception</strong>(<var>Term</var>)</dt>
303262 <dd class="defbody">
304263 The <var>Goal</var> of the thread has been terminated due to an uncaught
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>).
264 exception (see <a name="idx:throw1:1879"></a><a class="pred" href="exception.html#throw/1">throw/1</a>
265 and <a name="idx:catch3:1880"></a><a class="pred" href="exception.html#catch/3">catch/3</a>).
307266 </dd>
308267 </dl>
309268
310269 </dd>
311270 <dt><strong>engine</strong>(<var>Boolean</var>)</dt>
312271 <dd class="defbody">
313 If the thread is an engine (see <a class="sec" href="engines.html#sec:10">chapter
272 If the thread is an engine (see <a class="sec" href="engines.html">chapter
314273 10</a>), <var>Boolean</var> is
315274 <code>true</code>. Othwerwise the property is not present.</dd>
316275 <dt><strong>thread</strong>(<var>ThreadId</var>)</dt>
328287 </dd>
329288 </dl>
330289
331 <p>See also <a id="idx:threadstatistics3:1882"></a><a class="pred" href="thmonitor.html#thread_statistics/3">thread_statistics/3</a>
290 <p>See also <a name="idx:threadstatistics3:1881"></a><a class="pred" href="thmonitor.html#thread_statistics/3">thread_statistics/3</a>
332291 to obtain resource usage information and
333 <a id="idx:messagequeueproperty2:1883"></a><a class="pred" href="threadcom.html#message_queue_property/2">message_queue_property/2</a>
292 <a name="idx:messagequeueproperty2:1882"></a><a class="pred" href="threadcom.html#message_queue_property/2">message_queue_property/2</a>
334293 to get the number of queued messages for a thread.</dd>
335 <dt class="pubdef"><a id="thread_statistics/3"><strong>thread_statistics</strong>(<var>+Id,
294 <dt class="pubdef"><a name="thread_statistics/3"><strong>thread_statistics</strong>(<var>+Id,
336295 +Key, -Value</var>)</a></dt>
337296 <dd class="defbody">
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>,
297 Obtains statistical information on thread <var>Id</var> as <a name="idx:statistics2:1883"></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:1884"></a><a class="pred" href="statistics.html#statistics/2">statistics/2</a>,
340299 although only stack sizes, <code>cputime</code>,
341300 <code>inferences</code> and <code>epoch</code> yield different values
342 for each thread.<sup class="fn">160<span class="fn-text">There is no
301 for each thread.<sup class="fn">159<span class="fn-text">There is no
343302 portable interface to obtain thread-specific CPU time and some operating
344303 systems provide no access to this information at all. On such systems
345304 the total process CPU is returned. Thread CPU time is supported on
346305 MS-Windows, Linux and MacOSX.</span></sup></dd>
347 <dt class="pubdef"><a id="mutex_statistics/0"><strong>mutex_statistics</strong></a></dt>
306 <dt class="pubdef"><a name="mutex_statistics/0"><strong>mutex_statistics</strong></a></dt>
348307 <dd class="defbody">
349308 Print usage statistics on internal mutexes and mutexes associated with
350309 dynamic predicates. For each mutex two numbers are printed: the number
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="thmonitor.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="threadsync.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:threadcom"><a id="sec:9.3"><span class="sec-nr">9.3</span> <span class="sec-title">Thread
194 <h2 id="sec:threadcom"><a name="sec:9.3"><span class="sec-nr">9.3</span> <span class="sec-title">Thread
236195 communication</span></a></h2>
237196
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
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
241200 queues</span></a></h3>
242201
243 <a id="sec:msgqueue"></a>
202 <a name="sec:msgqueue"></a>
244203
245204 <p>Prolog threads can exchange data using dynamic predicates, database
246205 records, and other globally shared data. These provide no suitable means
249208 threads to wait for data or conditions without using the CPU.
250209
251210 <p>Each thread has a message queue attached to it that is identified by
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>.
211 the thread. Additional queues are created using <a name="idx:messagequeuecreate1:1885"></a><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a>.
253212 Explicitly created queues come in two flavours. When given an
254213 <em>alias</em>, they must be destroyed by the user. <em>Anonymous</em>
255 message queues are identified by a <em>blob</em> (see <a class="sec" href="foreigninclude.html#sec:11.4.7">section
214 message queues are identified by a <em>blob</em> (see <a class="sec" href="foreigninclude.html">section
256215 11.4.7</a>) and subject to garbage collection.
257216
258217 <dl class="latex">
259 <dt class="pubdef"><a id="thread_send_message/2"><strong>thread_send_message</strong>(<var>+QueueOrThreadId,
218 <dt class="pubdef"><a name="thread_send_message/2"><strong>thread_send_message</strong>(<var>+QueueOrThreadId,
260219 +Term</var>)</a></dt>
261220 <dd class="defbody">
262221 Place <var>Term</var> in the given queue or default queue of the
263222 indicated thread (which can even be the message queue of itself, see
264 <a id="idx:threadself1:1887"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>).
223 <a name="idx:threadself1:1886"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>).
265224 Any term can be placed in a message queue, but note that the term is
266225 copied to the receiving thread and variable bindings are thus lost. This
267226 call returns immediately.
274233 the same queue as all-but-the-winner perform a useless scan of the
275234 queue. If there is only one waiting thread or all waiting threads wait
276235 with an unbound variable, an arbitrary thread is restarted to scan the
277 queue.<sup class="fn">161<span class="fn-text">See the documentation for
236 queue.<sup class="fn">160<span class="fn-text">See the documentation for
278237 the POSIX thread functions pthread_cond_signal() v.s. pthread_cond_broadcast()
279238 for background information.</span></sup></dd>
280 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="thread_send_message/3"><strong>thread_send_message</strong>(<var>+Queue,
239 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="thread_send_message/3"><strong>thread_send_message</strong>(<var>+Queue,
281240 +Term, +Options</var>)</a></dt>
282241 <dd class="defbody">
283 As <a id="idx:threadsendmessage2:1888"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>,
242 As <a name="idx:threadsendmessage2:1887"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>,
284243 but providing additional <var>Options</var>. These are to deal with the
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>
244 case that the queue has a finite maximum size and is full: whereas <a name="idx:threadsendmessage2:1888"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
286245 will block until the queue has drained sufficiently to accept a new
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>.
246 message, <a name="idx:threadsendmessage3:1889"></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:1890"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>.
289248 The options are:
290249
291250 <dl class="latex">
292251 <dt><strong>deadline</strong>(<var>+AbsTime</var>)</dt>
293252 <dd class="defbody">
294253 The call fails (silently) if no space has become available before
295 <var>AbsTime</var>. See <a id="idx:gettime1:1892"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
254 <var>AbsTime</var>. See <a name="idx:gettime1:1891"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
296255 for the representation of absolute time. If <var>AbsTime</var> is
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>
256 earlier then the current time, <a name="idx:threadsendmessage3:1892"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
298257 fails immediately. Both resolution and maximum wait time is
299 platform-dependent.<sup class="fn">162<span class="fn-text">The
258 platform-dependent.<sup class="fn">161<span class="fn-text">The
300259 implementation uses MsgWaitForMultipleObjects() on MS-Windows and
301260 pthread_cond_timedwait() on other systems.</span></sup></dd>
302261 <dt><strong>timeout</strong>(<var>+Time</var>)</dt>
305264 wait in seconds. This is a relative-time version of the <code>deadline</code>
306265 option. If both options are provided, the earlier time is effective.
307266
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>
267 <p>If <var>Time</var> is 0 or 0.0, <a name="idx:threadsendmessage3:1893"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
309268 examines the queue and sends the message if space is availabel, but does
310269 not suspend if no space is available, failing immediately instead.
311270
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>
271 <p>If <var>Time</var> <var>&lt; 0</var>, <a name="idx:threadsendmessage3:1894"></a><a class="pred" href="threadcom.html#thread_send_message/3">thread_send_message/3</a>
313272 fails immediately without sending the message.
314273 </dd>
315274 </dl>
316275
317276 </dd>
318 <dt class="pubdef"><a id="thread_get_message/1"><strong>thread_get_message</strong>(<var>?Term</var>)</a></dt>
277 <dt class="pubdef"><a name="thread_get_message/1"><strong>thread_get_message</strong>(<var>?Term</var>)</a></dt>
319278 <dd class="defbody">
320279 Examines the thread message queue and if necessary blocks execution
321280 until a term that unifies to <var>Term</var> arrives in the queue. After
335294 thread_send_message(Thread_1, a(gnat)),
336295 </pre>
337296
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>
297 <p>See also <a name="idx:threadpeekmessage1:1895"></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>
340299 <dd class="defbody">
341300 Examines the thread message queue and compares the queued terms with <var>Term</var>
342301 until one unifies or the end of the queue has been reached. In the first
343302 case the call succeeds, possibly instantiating
344303 <var>Term</var>. If no term from the queue unifies, this call fails.
345304 I.e.,
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>
305 <a name="idx:threadpeekmessage1:1896"></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:1897"></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>
349308 <dd class="defbody">
350309 Equivalent to <code>message_queue_create(Queue,[])</code>. For
351310 compatibility, calling <code>message_queue_create(+Atom)</code> is
352311 equivalent to
353312 <code>message_queue_create(Queue, [alias(Atom)])</code>. New code should
354313 use
355 <a id="idx:messagequeuecreate2:1899"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>
314 <a name="idx:messagequeuecreate2:1898"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>
356315 to create a named queue.</dd>
357 <dt class="pubdef"><a id="message_queue_create/2"><strong>message_queue_create</strong>(<var>-Queue,
316 <dt class="pubdef"><a name="message_queue_create/2"><strong>message_queue_create</strong>(<var>-Queue,
358317 +Options</var>)</a></dt>
359318 <dd class="defbody">
360319 Create a message queue from <var>Options</var>. Defined options are:
365324 Create a message queue that is identified by the atom <var>Alias</var>.
366325 Message queues created this way must be explicitly destroyed by the
367326 user. If the alias option is omitted, an <em>Anonymous</em> queue is
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
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
370329 collecting anonymous message queues is not part of the ISO proposal and
371330 most likely not a widely implemented feature.</span></sup></dd>
372331 <dt><strong>max_size</strong>(<var>+Size</var>)</dt>
373332 <dd class="defbody">
374333 Maximum number of terms in the queue. If this number is reached,
375 <a id="idx:threadsendmessage2:1900"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
334 <a name="idx:threadsendmessage2:1899"></a><a class="pred" href="threadcom.html#thread_send_message/2">thread_send_message/2</a>
376335 will suspend until the queue is drained. The option can be used if the
377336 source, sending messages to the queue, is faster than the drain,
378337 consuming the messages.
380339 </dl>
381340
382341 </dd>
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>.
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:1900"></a><a class="pred" href="threadcom.html#message_queue_create/1">message_queue_create/1</a>.
386345 A permission error is raised if <var>Queue</var> refers to (the default
387346 queue of) a thread. Other threads that are waiting for <var>Queue</var>
388347 using
389 <a id="idx:threadgetmessage2:1902"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>
348 <a name="idx:threadgetmessage2:1901"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>
390349 receive an existence error.</dd>
391 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="thread_get_message/2"><strong>thread_get_message</strong>(<var>+Queue,
350 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="thread_get_message/2"><strong>thread_get_message</strong>(<var>+Queue,
392351 ?Term</var>)</a></dt>
393352 <dd class="defbody">
394 As <a id="idx:threadgetmessage1:1903"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>,
353 As <a name="idx:threadgetmessage1:1902"></a><a class="pred" href="threadcom.html#thread_get_message/1">thread_get_message/1</a>,
395354 operating on a given queue. It is allowed (but not advised) to get
396355 messages from the queue of other threads. This predicate raises an
397356 existence error exception if <var>Queue</var> doesn't exist or is
398 destroyed using <a id="idx:messagequeuedestroy1:1904"></a><a class="pred" href="threadcom.html#message_queue_destroy/1">message_queue_destroy/1</a>
357 destroyed using <a name="idx:messagequeuedestroy1:1903"></a><a class="pred" href="threadcom.html#message_queue_destroy/1">message_queue_destroy/1</a>
399358 while this predicate is waiting.</dd>
400 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="thread_get_message/3"><strong>thread_get_message</strong>(<var>+Queue,
359 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="thread_get_message/3"><strong>thread_get_message</strong>(<var>+Queue,
401360 ?Term, +Options</var>)</a></dt>
402361 <dd class="defbody">
403 As <a id="idx:threadgetmessage2:1905"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>,
362 As <a name="idx:threadgetmessage2:1904"></a><a class="pred" href="threadcom.html#thread_get_message/2">thread_get_message/2</a>,
404363 but providing additional <var>Options</var>:
405364
406365 <dl class="latex">
407366 <dt><strong>deadline</strong>(<var>+AbsTime</var>)</dt>
408367 <dd class="defbody">
409368 The call fails (silently) if no message has arrived before
410 <var>AbsTime</var>. See <a id="idx:gettime1:1906"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
369 <var>AbsTime</var>. See <a name="idx:gettime1:1905"></a><a class="pred" href="system.html#get_time/1">get_time/1</a>
411370 for the representation of absolute time. If <var>AbsTime</var> is
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>
371 earlier then the current time, <a name="idx:threadgetmessage3:1906"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
413372 fails immediately. Both resolution and maximum wait time is
414 platform-dependent.<sup class="fn">164<span class="fn-text">The
373 platform-dependent.<sup class="fn">163<span class="fn-text">The
415374 implementation uses MsgWaitForMultipleObjects() on MS-Windows and
416375 pthread_cond_timedwait() on other systems.</span></sup></dd>
417376 <dt><strong>timeout</strong>(<var>+Time</var>)</dt>
420379 wait in seconds. This is a relative-time version of the <code>deadline</code>
421380 option. If both options are provided, the earlier time is effective.
422381
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>
382 <p>If <var>Time</var> is 0 or 0.0, <a name="idx:threadgetmessage3:1907"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
424383 examines the queue but does not suspend if no matching term is
425384 available. Note that unlike
426 <a id="idx:threadpeekmessage2:1909"></a><a class="pred" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a>,
385 <a name="idx:threadpeekmessage2:1908"></a><a class="pred" href="threadcom.html#thread_peek_message/2">thread_peek_message/2</a>,
427386 a matching term is removed from the queue.
428387
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>
388 <p>If <var>Time</var> <var>&lt; 0</var>, <a name="idx:threadgetmessage3:1909"></a><a class="pred" href="threadcom.html#thread_get_message/3">thread_get_message/3</a>
430389 fails immediately without removing any message from the queue.
431390 </dd>
432391 </dl>
433392
434393 </dd>
435 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="thread_peek_message/2"><strong>thread_peek_message</strong>(<var>+Queue,
394 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="thread_peek_message/2"><strong>thread_peek_message</strong>(<var>+Queue,
436395 ?Term</var>)</a></dt>
437396 <dd class="defbody">
438 As <a id="idx:threadpeekmessage1:1911"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>,
397 As <a name="idx:threadpeekmessage1:1910"></a><a class="pred" href="threadcom.html#thread_peek_message/1">thread_peek_message/1</a>,
439398 operating on a given queue. It is allowed to peek into another thread's
440399 message queue, an operation that can be used to check whether a thread
441400 has swallowed a message sent to it.</dd>
442 <dt class="pubdef"><a id="message_queue_property/2"><strong>message_queue_property</strong>(<var>?Queue,
401 <dt class="pubdef"><a name="message_queue_property/2"><strong>message_queue_property</strong>(<var>?Queue,
443402 ?Property</var>)</a></dt>
444403 <dd class="defbody">
445404 True if <var>Property</var> is a property of <var>Queue</var>. Defined
453412 <dt><strong>max_size</strong>(<var>Size</var>)</dt>
454413 <dd class="defbody">
455414 Maximum number of terms that can be in the queue. See
456 <a id="idx:messagequeuecreate2:1912"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>.
415 <a name="idx:messagequeuecreate2:1911"></a><a class="pred" href="threadcom.html#message_queue_create/2">message_queue_create/2</a>.
457416 This property is not present if there is no limit (default).
458417 </dd>
459418 <dt><strong>size</strong>(<var>Size</var>)</dt>
509468 thread_send_message(Id, Goal).
510469 </pre>
511470
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
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
513472 threads</span></a></h3>
514473
515 <a id="sec:thread-signal"></a>
474 <a name="sec:thread-signal"></a>
516475
517476 <p>These predicates provide a mechanism to make another thread execute
518477 some goal as an <em>interrupt</em>. Signalling threads is safe as these
519478 interrupts are only checked at safe points in the virtual machine.
520479 Nevertheless, signalling in multithreaded environments should be handled
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>).
480 with care as the receiving thread may hold a <em>mutex</em> (see <a name="idx:withmutex2:1912"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>).
522481 Signalling probably only makes sense to start debugging threads and to
523 cancel no-longer-needed threads with <a id="idx:throw1:1914"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
482 cancel no-longer-needed threads with <a name="idx:throw1:1913"></a><a class="pred" href="exception.html#throw/1">throw/1</a>,
524483 where the receiving thread should be designed carefully to handle
525484 exceptions at any point.
526485
527486 <dl class="latex">
528 <dt class="pubdef"><a id="thread_signal/2"><strong>thread_signal</strong>(<var>+ThreadId,
487 <dt class="pubdef"><a name="thread_signal/2"><strong>thread_signal</strong>(<var>+ThreadId,
529488 :Goal</var>)</a></dt>
530489 <dd class="defbody">
531490 Make thread <var>ThreadId</var> execute <var>Goal</var> at the first
532491 opportunity. In the current implementation, this implies at the first
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>
492 pass through the <em>Call port</em>. The predicate <a name="idx:threadsignal2:1914"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>
534493 itself places <var>Goal</var> into the signalled thread's signal queue
535494 and returns immediately.
536495
539498 guaranteed easily. At the call port, the Prolog virtual machine holds no
540499 locks and therefore the asynchronous execution is safe.
541500
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>
501 <p><var>Goal</var> can be any valid Prolog goal, including <a name="idx:throw1:1915"></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:1916"></a><a class="pred" href="debugger.html#trace/0">trace/0</a>
544503 to start tracing the receiving thread.
545504
546505 <p>In the Windows version, the receiving thread immediately executes the
549508 </dd>
550509 </dl>
551510
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
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
553512 and dynamic predicates</span></a></h3>
554513
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>)
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:1917"></a><a class="pred" href="dynamic.html#dynamic/1">dynamic/1</a>)
562521 is shared by all threads. Each thread may assert, retract and run the
563522 dynamic predicate. Synchronisation inside Prolog guarantees the
564523 consistency of the predicate. Updates are
565524 <em>logical</em>: visible clauses are not affected by assert/retract
566525 after a query started on the predicate. In many cases primitives from
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.
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.
570528
571529 <p>Besides shared predicates, dynamic predicates can be declared with
572530 the
573 <a id="idx:threadlocal1:1919"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>
531 <a name="idx:threadlocal1:1918"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>
574532 directive. Such predicates share their attributes, but the clause list
575533 is different in each thread.
576534
577535 <dl class="latex">
578 <dt class="pubdef"><a id="thread_local/1"><strong>thread_local</strong> <var>+Functor/+Arity,
536 <dt class="pubdef"><a name="thread_local/1"><strong>thread_local</strong> <var>+Functor/+Arity,
579537 ...</var></a></dt>
580538 <dd class="defbody">
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>,
539 This directive is related to the <a name="idx:dynamic1:1919"></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:1920"></a><a class="pred" href="db.html#assert/1">assert/1</a>, <a name="idx:retract1:1921"></a><a class="pred" href="db.html#retract/1">retract/1</a>,
583541 etc., during execution of the program. Unlike normal shared dynamic
584542 data, however, each thread has its own clause list for the predicate. As
585543 a thread starts, this clause list is empty. If there are still clauses
586544 when the thread terminates, these are automatically reclaimed by the
587 system (see also <a id="idx:volatile1:1923"></a><a class="pred" href="runtime.html#volatile/1">volatile/1</a>).
545 system (see also <a name="idx:volatile1:1922"></a><a class="pred" href="runtime.html#volatile/1">volatile/1</a>).
588546 The thread_local property implies the properties <em>dynamic</em> and <em>volatile</em>.
589547
590548 <p>Thread-local dynamic predicates are intended for maintaining
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="threads.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="thmonitor.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:threadcreate"><a id="sec:9.1"><span class="sec-nr">9.1</span> <span class="sec-title">Creating
194 <h2 id="sec:threadcreate"><a name="sec:9.1"><span class="sec-nr">9.1</span> <span class="sec-title">Creating
236195 and destroying Prolog threads</span></a></h2>
237196
238 <a id="sec:threadcreate"></a>
197 <a name="sec:threadcreate"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="thread_create/2"><strong>thread_create</strong>(<var>:Goal,
200 <dt class="pubdef"><a name="thread_create/2"><strong>thread_create</strong>(<var>:Goal,
242201 -Id</var>)</a></dt>
243202 <dd class="defbody">
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,
203 Shorthand for <code>thread_create(Goal, Id, [])</code>. See <a name="idx:threadcreate3:1830"></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,
246205 -Id, +Options</var>)</a></dt>
247206 <dd class="defbody">
248207 Create a new Prolog thread (and underlying operating system thread) and
253212 is given. Otherwise it is a <em>blob</em> of type <code>thread</code>.
254213 The anonymous blobs are subject to atom garbage collection. If a thread
255214 handle is garbage collected and the thread is not <em>detached</em>, it
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
215 is <em>joined</em> if it has already terminated (see <a name="idx:threadjoin2:1831"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>)
216 and detached otherwise (see <a name="idx:threaddetach1:1832"></a><a class="pred" href="threadcreate.html#thread_detach/1">thread_detach/1</a>).<sup class="fn">156<span class="fn-text">Up
258217 to version 7.3.23, anonymous thread handles were integers. Using
259218 integers did not allow for safe checking of the thread's status as the
260219 thread may have died and the handle may have been reused and did not
263222 where <var>I</var> is the internal thread identifier and <var>Ptr</var>
264223 is the unique address of the identifier. The <var>I</var> is accepted as
265224 input argument for all thread APIs that accept a thread identifier for
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>.
225 convenient interaction from the toplevel. See also <a name="idx:threadproperty2:1833"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
267226
268227 <p><var>Options</var> is a list of options. The currently defined
269228 options are below. Stack size options can also take the value <code>inf</code>
276235 <dd class="defbody">
277236 Associate an `alias name' with the thread. This name may be used to
278237 refer to the thread and remains valid until the thread is joined (see
279 <a id="idx:threadjoin2:1835"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>).
238 <a name="idx:threadjoin2:1834"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>).
280239 If the OS supports it (e.g., Linux), the operating system thread is
281240 named as well.</dd>
282241 <dt><strong>at_exit</strong>(<var>:AtExit</var>)</dt>
283242 <dd class="defbody">
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>
243 Register <var>AtExit</var> as using <a name="idx:threadatexit1:1835"></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:1836"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
286245 as part of the normal
287246 <var>Goal</var>, this <em>ensures</em> the <var>AtExit</var> is called.
288247 Using
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>
248 <a name="idx:threadatexit1:1837"></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:1838"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
291250 is reached.</dd>
292251 <dt><strong>debug</strong>(<var>+Bool</var>)</dt>
293252 <dd class="defbody">
294253 Enable/disable debugging the new thread. If <code>false</code> (default
295254 <code>true</code>), the new thread is created with the property
296255 <code>debug(false)</code> and debugging is disabled before the new
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>
256 thread is started. The thread debugging predicates such as <a name="idx:tspy1:1839"></a><a class="pred" href="thutil.html#tspy/1">tspy/1</a>
257 and <a name="idx:tdebug0:1840"></a><a class="pred" href="thutil.html#tdebug/0">tdebug/0</a>
299258 do not signal threads with the debug property set to
300 <code>false</code>.<sup class="fn">158<span class="fn-text">Currently,
259 <code>false</code>.<sup class="fn">157<span class="fn-text">Currently,
301260 the flag is only used as a hint for the the various debugging
302261 primitives, i.e., the system does not really enforce that the target
303262 thread stays in <em>nodebug</em> mode.</span></sup></dd>
304263 <dt><strong>detached</strong>(<var>Bool</var>)</dt>
305264 <dd class="defbody">
306265 If <code>false</code> (default), the thread can be waited for using
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>
266 <a name="idx:threadjoin2:1841"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>. <a name="idx:threadjoin2:1842"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
308267 must be called on this thread to reclaim all resources associated with
309268 the thread. If <code>true</code>, the system will reclaim all associated
310269 resources automatically after the thread finishes. Please note that
311270 thread identifiers are freed for reuse after a detached thread finishes
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>.
271 or a normal thread has been joined. See also <a name="idx:threadjoin2:1843"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
272 and <a name="idx:threaddetach1:1844"></a><a class="pred" href="threadcreate.html#thread_detach/1">thread_detach/1</a>.
314273
315274 <p>If a detached thread dies due to failure or exception of the initial
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>.
275 goal, the thread prints a message using <a name="idx:printmessage2:1845"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>.
317276 If such termination is considered normal, the code must be wrapped using
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>
277 <a name="idx:ignore1:1846"></a><a class="pred" href="metacall.html#ignore/1">ignore/1</a>
278 and/or <a name="idx:catch3:1847"></a><a class="pred" href="exception.html#catch/3">catch/3</a>
320279 to ensure successful completion.</dd>
321280 <dt><strong>inherit_from</strong>(<var>+ThreadId</var>)</dt>
322281 <dd class="defbody">
323282 Inherit defaults from the given <var>ThreadId</var> instead of the
324283 calling thread. This option was added to ensure that the
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>),
284 <code>__thread_pool_manager</code> (see <a name="idx:threadcreateinpool4:1848"></a><a class="pred" href="threadpool.html#thread_create_in_pool/4">thread_create_in_pool/4</a>),
326285 which is created lazily, has a predictable state. The following
327286 properties are inherited:
328287
329288 <p>
330289 <ul class="latex">
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>)
290 <li>The prompt (see <a name="idx:prompt2:1849"></a><a class="pred" href="termrw.html#prompt/2">prompt/2</a>)
291 <li>The <em>typein</em> module (see <a name="idx:module1:1850"></a><a class="pred" href="mtoplevel.html#module/1">module/1</a>)
333292 <li>The standard streams (<code>user_input</code>, etc.)
334293 <li>The default encoding (see <a class="flag" href="flags.html#flag:encoding">encoding</a>)
335 <li>The default locale (see <a id="idx:setlocale1:1852"></a><span class="pred-ext">setlocale/1</span>)
294 <li>The default locale (see <a name="idx:setlocale1:1851"></a><span class="pred-ext">setlocale/1</span>)
336295 <li>All prolog flags
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>)
296 <li>The limits of Prolog stacks (see <a name="idx:setprologstack2:1852"></a><a class="pred" href="memory.html#set_prolog_stack/2">set_prolog_stack/2</a>)
338297 </ul>
339298 </dd>
340299 <dt><strong>global</strong>(<var>K-Bytes</var>)</dt>
350309 <dt><strong>c_stack</strong>(<var>K-Bytes</var>)</dt>
351310 <dd class="defbody">
352311 Set the limit to which the system stack of this thread may grow. The
353 default, minimum and maximum values are system-dependent.<sup class="fn">159<span class="fn-text">Older
312 default, minimum and maximum values are system-dependent.<sup class="fn">158<span class="fn-text">Older
354313 versions used <code>stack</code>. This is still accepted as a synonym.</span></sup></dd>
355314 <dt><strong>trail</strong>(<var>K-Bytes</var>)</dt>
356315 <dd class="defbody">
364323 engine. This implies that further instantiation of this term in either
365324 thread does not have consequences for the other thread: Prolog threads
366325 do not share data from their stacks.</dd>
367 <dt class="pubdef"><a id="thread_self/1"><strong>thread_self</strong>(<var>-Id</var>)</a></dt>
326 <dt class="pubdef"><a name="thread_self/1"><strong>thread_self</strong>(<var>-Id</var>)</a></dt>
368327 <dd class="defbody">
369328 Get the Prolog thread identifier of the running thread. If the thread
370329 has an alias, the alias name is returned.</dd>
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>
330 <dt class="pubdef"><a name="thread_join/1"><strong>thread_join</strong>(<var>+Id</var>)</a></dt>
331 <dd class="defbody">
332 Calls <a name="idx:threadjoin2:1853"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
374333 and succeeds if thread <var>Id</var> terminated with success. Otherwise
375334 the exception
376335 <code>error(<code>thread_error(Status)</code>, _)</code> is raised.</dd>
377 <dt class="pubdef"><a id="thread_join/2"><strong>thread_join</strong>(<var>+Id,
336 <dt class="pubdef"><a name="thread_join/2"><strong>thread_join</strong>(<var>+Id,
378337 -Status</var>)</a></dt>
379338 <dd class="defbody">
380339 Wait for the termination of the thread with the given <var>Id</var>.
381340 Then unify the result status of the thread with <var>Status</var>. After
382341 this call, <var>Id</var> becomes invalid and all resources associated
383342 with the thread are reclaimed. Note that threads with the attribute
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>
343 <code>detached(true)</code> cannot be joined. See also <a name="idx:threadproperty2:1854"></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:1855"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
387346 being called on it is partly reclaimed: the Prolog stacks are released
388347 and the C thread is destroyed. A small data structure representing the
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>
348 exit status of the thread is retained until <a name="idx:threadjoin2:1856"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
390349 is called on the thread. Defined values for <var>Status</var> are:
391350
392351 <dl class="latex">
398357 The goal has failed.</dd>
399358 <dt><strong>exception</strong>(<var>Term</var>)</dt>
400359 <dd class="defbody">
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>
360 The thread is terminated on an exception. See <a name="idx:printmessage2:1857"></a><a class="pred" href="exception.html#print_message/2">print_message/2</a>
402361 to turn system exceptions into readable messages.</dd>
403362 <dt><strong>exited</strong>(<var>Term</var>)</dt>
404363 <dd class="defbody">
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>
364 The thread is terminated on <a name="idx:threadexit1:1858"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
406365 using the argument <var>Term</var>.
407366 </dd>
408367 </dl>
409368
410369 </dd>
411 <dt class="pubdef"><a id="thread_detach/1"><strong>thread_detach</strong>(<var>+Id</var>)</a></dt>
370 <dt class="pubdef"><a name="thread_detach/1"><strong>thread_detach</strong>(<var>+Id</var>)</a></dt>
412371 <dd class="defbody">
413372 Switch thread into detached state (see <code>detached(Bool)</code>
414373 option at
415 <a id="idx:threadcreate3:1860"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>)
374 <a name="idx:threadcreate3:1859"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>)
416375 at runtime. <var>Id</var> is the identifier of the thread placed in
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>.
376 detached state. This may be the result of <a name="idx:threadself1:1860"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>.
418377
419378 <p>One of the possible applications is to simplify debugging. Threads
420379 that are created as <em>detached</em> leave no traces if they crash. For
421380 non-detached threads the status can be inspected using
422 <a id="idx:threadproperty2:1862"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
381 <a name="idx:threadproperty2:1861"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>.
423382 Threads nobody is waiting for may be created normally and detach
424383 themselves just before completion. This way they leave no traces on
425384 normal completion and their reason for failure can be inspected.</dd>
426 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="thread_exit/1"><strong>thread_exit</strong>(<var>+Term</var>)</a></dt>
385 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="thread_exit/1"><strong>thread_exit</strong>(<var>+Term</var>)</a></dt>
427386 <dd class="defbody">
428387 Terminates the thread immediately, leaving <code>exited(Term)</code> as
429 result state for <a id="idx:threadjoin2:1863"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
388 result state for <a name="idx:threadjoin2:1862"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>.
430389 If the thread has the attribute
431390 <code>detached(true)</code> it terminates, but its exit status cannot be
432 retrieved using <a id="idx:threadjoin2:1864"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>,
391 retrieved using <a name="idx:threadjoin2:1863"></a><a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>,
433392 making the value of <var>Term</var> irrelevant. The Prolog stacks and C
434393 thread are reclaimed.
435394
436395 <p>The current implementation does not guarantee proper releasing of all
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>)
396 mutexes and proper cleanup in <a name="idx:setupcallcleanup3:1864"></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:1865"></a><a class="pred" href="exception.html#throw/1">throw/1</a>)
439398 to abort execution using non-standard control.</dd>
440 <dt class="pubdef"><a id="thread_initialization/1"><strong>thread_initialization</strong>(<var>:Goal</var>)</a></dt>
399 <dt class="pubdef"><a name="thread_initialization/1"><strong>thread_initialization</strong>(<var>:Goal</var>)</a></dt>
441400 <dd class="defbody">
442401 Run <var>Goal</var> when thread is started. This predicate is similar to
443 <a id="idx:initialization1:1867"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
402 <a name="idx:initialization1:1866"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>,
444403 but is intended for initialization operations of the runtime stacks,
445404 such as setting global variables as described in
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>
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:1867"></a><a class="pred" href="consulting.html#initialization/1">initialization/1</a>
452411 hooks.</dd>
453 <dt class="pubdef"><a id="thread_at_exit/1"><strong>thread_at_exit</strong>(<var>:Goal</var>)</a></dt>
412 <dt class="pubdef"><a name="thread_at_exit/1"><strong>thread_at_exit</strong>(<var>:Goal</var>)</a></dt>
454413 <dd class="defbody">
455414 Run <var>Goal</var> just before releasing the thread resources. This is
456 to be compared to <a id="idx:athalt1:1869"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>,
415 to be compared to <a name="idx:athalt1:1868"></a><a class="pred" href="consulting.html#at_halt/1">at_halt/1</a>,
457416 but only for the current thread. These hooks are run regardless of why
458417 the execution of the thread has been completed. When these hooks are
459418 run, the return code is already available through
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>
419 <a name="idx:threadproperty2:1869"></a><a class="pred" href="thmonitor.html#thread_property/2">thread_property/2</a>
420 using the result of <a name="idx:threadself1:1870"></a><a class="pred" href="threadcreate.html#thread_self/1">thread_self/1</a>
462421 as thread identifier. Note that there are two scenarios for using exit
463 hooks. Using <a id="idx:threadatexit1:1872"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
422 hooks. Using <a name="idx:threadatexit1:1871"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
464423 is typically used if the thread creates a side-effect that must be
465424 reverted if the thread dies. Another scenario is where the creator of
466425 the thread wants to be informed when the thread ends. That cannot be
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>
426 guaranteed by means of <a name="idx:threadatexit1:1872"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
468427 because it is possible that the thread cannot be created or dies almost
469428 instantly due to a signal or resource error. The <code>at_exit(Goal)</code>
470429 option of
471 <a id="idx:threadcreate3:1874"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
430 <a name="idx:threadcreate3:1873"></a><a class="pred" href="threadcreate.html#thread_create/3">thread_create/3</a>
472431 is designed to deal with this scenario.</dd>
473 <dt class="pubdef"><a id="thread_setconcurrency/2"><strong>thread_setconcurrency</strong>(<var>-Old,
432 <dt class="pubdef"><a name="thread_setconcurrency/2"><strong>thread_setconcurrency</strong>(<var>-Old,
474433 +New</var>)</a></dt>
475434 <dd class="defbody">
476 <a id="idx:Solaris:1875"></a>Determine the concurrency of the process,
435 <a name="idx:Solaris:1874"></a>Determine the concurrency of the process,
477436 which is defined as the maximum number of concurrently active threads.
478437 `Active' here means they are using CPU time. This option is provided if
479438 the thread implementation provides pthread_setconcurrency(). Solaris is
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.36</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="tabling.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="ugraphs.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:threadpool"><a id="sec:A.36"><span class="sec-nr">A.36</span> <span class="sec-title">library(thread_pool):
194 <h2 id="sec:threadpool"><a name="sec:A.36"><span class="sec-nr">A.36</span> <span class="sec-title">library(thread_pool):
236195 Resource bounded thread management</span></a></h2>
237196
238 <p><a id="sec:threadpool"></a>
197 <p><a name="sec:threadpool"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">See also</dt>
278237 directive or otherwise during startup of the application.
279238
280239 <dl class="latex">
281 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="thread_pool_create/3"><strong>thread_pool_create</strong>(<var>+Pool,
240 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="thread_pool_create/3"><strong>thread_pool_create</strong>(<var>+Pool,
282241 +Size, +Options</var>)</a></dt>
283242 <dd class="defbody">
284243 Create a pool of threads. A pool of threads is a declaration for
305264 state of a thread. Threads can be created both <code>detached</code> and
306265 normal and must be joined using <a class="pred" href="threadcreate.html#thread_join/2">thread_join/2</a>
307266 if they are not detached.</dd>
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>
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>
309268 <dd class="defbody">
310269 Destroy the thread pool named <var>Name</var>.
311270
317276 </dl>
318277
319278 </dd>
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>
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>
321280 <dd class="defbody">
322281 True if <var>Name</var> refers to a defined thread pool.</dd>
323 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a id="thread_pool_property/2"><strong>thread_pool_property</strong>(<var>?Name,
282 <dt class="pubdef"><span class="pred-tag">[nondet]</span><a name="thread_pool_property/2"><strong>thread_pool_property</strong>(<var>?Name,
324283 ?Property</var>)</a></dt>
325284 <dd class="defbody">
326285 True if <var>Property</var> is a property of thread pool <var>Name</var>.
354313 </dl>
355314
356315 </dd>
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,
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,
358317 :Goal, -Id, +Options</var>)</a></dt>
359318 <dd class="defbody">
360319 Create a thread in <var>Pool</var>. <var>Options</var> overrule default
380339 </dl>
381340
382341 </dd>
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>
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>
384343 <dd class="defbody">
385344 Hook to create a thread pool lazily. The hook is called if
386345 <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.7.4 Reference Manual</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="errors.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="threadcreate.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h1 id="sec:threads"><a id="sec:9"><span class="sec-nr">9</span> <span class="sec-title">Multithreaded
194 <h1 id="sec:threads"><a name="sec:9"><span class="sec-nr">9</span> <span class="sec-title">Multithreaded
236195 applications</span></a></h1>
237196
238 <a id="sec:threads"></a>
197 <a name="sec:threads"></a>
239198
240199 <p>SWI-Prolog multithreading is based on standard C language
241200 multithreading support. It is not like <em>ParLog</em> or other parallel
251210 applications. Such applications often have need for communication
252211 between services and/or fast non-blocking service to multiple concurrent
253212 clients. The shared heap provides fast communication, and thread
254 creation is relatively cheap.<sup class="fn">155<span class="fn-text">On
213 creation is relatively cheap.<sup class="fn">154<span class="fn-text">On
255214 an Intel i7-2600K, running Ubuntu Linux 12.04, SWI-Prolog 6.2 creates
256215 and joins 32,000 threads per second elapsed time.</span></sup>
257216
261220 such computations are executed in a new thread, the main thread can
262221 process events and allow the user to cancel the ongoing computation.
263222 User interfaces can also use multiple threads, each thread dealing with
264 input from a distinct group of windows. See also <a class="sec" href="mt-xpce.html#sec:9.7">section
223 input from a distinct group of windows. See also <a class="sec" href="mt-xpce.html">section
265224 9.7</a>.
266225
267226 <p>
276235 <cite><a class="cite" href="Bibliography.html#Butenhof:1997:PPT">Butenhof,
277236 1997</a></cite> used on most popular systems except for MS-Windows. On
278237 Windows it uses the
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>.
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>.
285244 It appears to have dropped from the ISO WG17 agenda.</span></sup>
286245
287246 <p>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.4</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="threadcom.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="thutil.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:threadsync"><a id="sec:9.4"><span class="sec-nr">9.4</span> <span class="sec-title">Thread
194 <h2 id="sec:threadsync"><a name="sec:9.4"><span class="sec-nr">9.4</span> <span class="sec-title">Thread
236195 synchronisation</span></a></h2>
237196
238 <a id="sec:threadsync"></a>
197 <a name="sec:threadsync"></a>
239198
240199 <p>All internal Prolog operations are thread-safe. This implies that two
241200 Prolog threads can operate on the same dynamic predicate without
256215 assert/retract order.
257216
258217 <p>The code below provides a solution to this problem based on
259 <a id="idx:withmutex2:1924"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>.
218 <a name="idx:withmutex2:1923"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>.
260219 It also illustrates the problem of mutexes. The predicate
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>
220 <a name="idx:withmutex2:1924"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
221 behaves as <a name="idx:once1:1925"></a><a class="pred" href="metacall.html#once/1">once/1</a>
263222 with respect to the guarded goal. This means that our predicate
264223 address/2 is no longer a nice logical non-deterministic relation. This
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>,
224 could be solved by explicit locking and unlocking a mutex using <a name="idx:setupcallcleanup2:1926"></a><span class="pred-ext">setup_call_cleanup/2</span>,
266225 but at the risk of deadlocking the program if the choice point is left
267226 open by accident.
268227
278237 address_db(Id, Address)).
279238 </pre>
280239
281 <p>Message queues (see <a id="idx:messagequeuecreate3:1928"></a><span class="pred-ext">message_queue_create/3</span>)
240 <p>Message queues (see <a name="idx:messagequeuecreate3:1927"></a><span class="pred-ext">message_queue_create/3</span>)
282241 often provide simpler and more robust ways for threads to communicate.
283242 Still, mutexes can be a sensible solution and are therefore provided.
284243
285244 <dl class="latex">
286 <dt class="pubdef"><a id="mutex_create/1"><strong>mutex_create</strong>(<var>?MutexId</var>)</a></dt>
245 <dt class="pubdef"><a name="mutex_create/1"><strong>mutex_create</strong>(<var>?MutexId</var>)</a></dt>
287246 <dd class="defbody">
288247 Create a mutex. If <var>MutexId</var> is an atom, a <em>named</em> mutex
289248 is created. If it is a variable, an anonymous mutex reference is
290249 returned. Anonymous mutexes are subject to (atom) garbage collection.</dd>
291 <dt class="pubdef"><a id="mutex_create/2"><strong>mutex_create</strong>(<var>-MutexId,
250 <dt class="pubdef"><a name="mutex_create/2"><strong>mutex_create</strong>(<var>-MutexId,
292251 +Options</var>)</a></dt>
293252 <dd class="defbody">
294253 Create a mutex using options. Defined options are:
302261 </dl>
303262
304263 </dd>
305 <dt class="pubdef"><a id="mutex_destroy/1"><strong>mutex_destroy</strong>(<var>+MutexId</var>)</a></dt>
264 <dt class="pubdef"><a name="mutex_destroy/1"><strong>mutex_destroy</strong>(<var>+MutexId</var>)</a></dt>
306265 <dd class="defbody">
307266 Destroy a mutex. If the mutex is not locked, it is destroyed and further
308267 access yields an <code>existence_error</code> exception. As of version
309268 7.1.19, this behaviour is reliable. If the mutex is locked, the mutex is
310269 sheduled for <em>delayed destruction</em>: it will be destroyed when it
311270 becomes unlocked.</dd>
312 <dt class="pubdef"><a id="with_mutex/2"><strong>with_mutex</strong>(<var>+MutexId,
271 <dt class="pubdef"><a name="with_mutex/2"><strong>with_mutex</strong>(<var>+MutexId,
313272 :Goal</var>)</a></dt>
314273 <dd class="defbody">
315274 Execute <var>Goal</var> while holding <var>MutexId</var>. If <var>Goal</var>
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>).
275 leaves choice points, these are destroyed (as in <a name="idx:once1:1928"></a><a class="pred" href="metacall.html#once/1">once/1</a>).
317276 The mutex is unlocked regardless of whether <var>Goal</var> succeeds,
318277 fails or raises an exception. An exception thrown by <var>Goal</var> is
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>.
278 re-thrown after the mutex has been successfully unlocked. See also <a name="idx:mutexcreate1:1929"></a><a class="pred" href="threadsync.html#mutex_create/1">mutex_create/1</a>
279 and <a name="idx:setupcallcleanup3:1930"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>.
321280
322281 <p>Although described in the thread section, this predicate is also
323282 available in the single-threaded version, where it behaves simply as
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>
283 <a name="idx:once1:1931"></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>
326285 <dd class="defbody">
327286 Lock the mutex. Prolog mutexes are <em>recursive</em> mutexes: they can
328287 be locked multiple times by the same thread. Only after unlocking it as
331290 thread is suspended until the mutex is unlocked.
332291
333292 <p>If <var>MutexId</var> is an atom, and there is no current mutex with
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>.
293 that name, the mutex is created automatically using <a name="idx:mutexcreate1:1932"></a><a class="pred" href="threadsync.html#mutex_create/1">mutex_create/1</a>.
335294 This implies named mutexes need not be declared explicitly.
336295
337296 <p>Please note that locking and unlocking mutexes should be paired
338297 carefully. Especially make sure to unlock mutexes even if the protected
339298 code fails or raises an exception. For most common cases, use
340 <a id="idx:withmutex2:1934"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>,
299 <a name="idx:withmutex2:1933"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>,
341300 which provides a safer way for handling Prolog-level mutexes. The
342 predicate <a id="idx:setupcallcleanup3:1935"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
301 predicate <a name="idx:setupcallcleanup3:1934"></a><a class="pred" href="metacall.html#setup_call_cleanup/3">setup_call_cleanup/3</a>
343302 is another way to guarantee that the mutex is unlocked while retaining
344303 non-determinism.</dd>
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>,
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:1935"></a><a class="pred" href="threadsync.html#mutex_lock/1">mutex_lock/1</a>,
348307 but if the mutex is held by another thread, this predicates fails
349308 immediately.</dd>
350 <dt class="pubdef"><a id="mutex_unlock/1"><strong>mutex_unlock</strong>(<var>+MutexId</var>)</a></dt>
309 <dt class="pubdef"><a name="mutex_unlock/1"><strong>mutex_unlock</strong>(<var>+MutexId</var>)</a></dt>
351310 <dd class="defbody">
352311 Unlock the mutex. This can only be called if the mutex is held by the
353312 calling thread. If this is not the case, a <code>permission_error</code>
354313 exception is raised.</dd>
355 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a id="mutex_unlock_all/0"><strong>mutex_unlock_all</strong></a></dt>
314 <dt class="pubdef"><span class="pred-tag">[deprecated]</span><a name="mutex_unlock_all/0"><strong>mutex_unlock_all</strong></a></dt>
356315 <dd class="defbody">
357316 Unlock all mutexes held by the current thread. This predicate should not
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>
317 be needed if mutex unlocking is guaranteed with <a name="idx:withmutex2:1936"></a><a class="pred" href="threadsync.html#with_mutex/2">with_mutex/2</a>
359318 or
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>
319 <a name="idx:setupcallcleanup3:1937"></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:1938"></a><a class="pred" href="threadcreate.html#thread_exit/1">thread_exit/1</a>
362321 bypasses the automatic cleanup.</span></sup></dd>
363 <dt class="pubdef"><a id="mutex_property/2"><strong>mutex_property</strong>(<var>?MutexId,
322 <dt class="pubdef"><a name="mutex_property/2"><strong>mutex_property</strong>(<var>?MutexId,
364323 ?Property</var>)</a></dt>
365324 <dd class="defbody">
366325 True if <var>Property</var> is a property of <var>MutexId</var>. Defined
369328 <dl class="latex">
370329 <dt><strong>alias</strong>(<var>Alias</var>)</dt>
371330 <dd class="defbody">
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>
331 Mutex has the defined alias name. See <a name="idx:mutexcreate2:1939"></a><a class="pred" href="threadsync.html#mutex_create/2">mutex_create/2</a>
373332 using the `alias' option.</dd>
374333 <dt><strong>status</strong>(<var>Status</var>)</dt>
375334 <dd class="defbody">
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 9.5</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="threadsync.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="foreignthread.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:thutil"><a id="sec:9.5"><span class="sec-nr">9.5</span> <span class="sec-title">Thread
194 <h2 id="sec:thutil"><a name="sec:9.5"><span class="sec-nr">9.5</span> <span class="sec-title">Thread
236195 support library(threadutil)</span></a></h2>
237196
238 <a id="sec:thutil"></a>
197 <a name="sec:thutil"></a>
239198
240199 <p>This library defines a couple of useful predicates for demonstrating
241200 and debugging multithreaded applications. This library is certainly not
242201 complete.
243202
244203 <dl class="latex">
245 <dt class="pubdef"><a id="threads/0"><strong>threads</strong></a></dt>
204 <dt class="pubdef"><a name="threads/0"><strong>threads</strong></a></dt>
246205 <dd class="defbody">
247206 Lists all current threads and their status.</dd>
248 <dt class="pubdef"><a id="join_threads/0"><strong>join_threads</strong></a></dt>
207 <dt class="pubdef"><a name="join_threads/0"><strong>join_threads</strong></a></dt>
249208 <dd class="defbody">
250209 Join all terminated threads. For normal applications, dealing with
251210 terminated threads must be part of the application logic, either
252211 detaching the thread before termination or making sure it will be
253 joined. The predicate <a id="idx:jointhreads0:1941"></a><a class="pred" href="thutil.html#join_threads/0">join_threads/0</a>
212 joined. The predicate <a name="idx:jointhreads0:1940"></a><a class="pred" href="thutil.html#join_threads/0">join_threads/0</a>
254213 is intended for interactive sessions to reclaim resources from threads
255214 that died unexpectedly during development.</dd>
256 <dt class="pubdef"><a id="interactor/0"><strong>interactor</strong></a></dt>
215 <dt class="pubdef"><a name="interactor/0"><strong>interactor</strong></a></dt>
257216 <dd class="defbody">
258217 Create a new console and run the Prolog top level in this new console.
259 See also <a id="idx:attachconsole0:1942"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.
218 See also <a name="idx:attachconsole0:1941"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>.
260219 In the Windows version a new interactor can also be created from the <b>Run/New
261220 thread</b> menu.
262221 </dd>
263222 </dl>
264223
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
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
266225 threads</span></a></h3>
267226
268 <a id="sec:threaddebug"></a>
227 <a name="sec:threaddebug"></a>
269228
270229 <p>Support for debugging threads is still very limited. Debug and trace
271230 mode are flags that are local to each thread. Individual threads can be
272231 debugged either using the graphical debugger described in
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>
232 <a class="sec" href="guitracer.html">section 3.5</a> (see <a name="idx:tspy1:1942"></a><a class="pred" href="thutil.html#tspy/1">tspy/1</a>
274233 and friends) or by attaching a console to the thread and running the
275234 traditional command line debugger (see
276 <a id="idx:attachconsole0:1944"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>).
235 <a name="idx:attachconsole0:1943"></a><a class="pred" href="thutil.html#attach_console/0">attach_console/0</a>).
277236 When using the graphical debugger, the debugger must be <em>loaded</em>
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>
237 from the main thread (for example using guitracer) before <a name="idx:gtrace0:1944"></a><a class="pred" href="guitracer.html#gtrace/0">gtrace/0</a>
279238 can be called from a thread.
280239
281240 <dl class="latex">
282 <dt class="pubdef"><a id="attach_console/0"><strong>attach_console</strong></a></dt>
241 <dt class="pubdef"><a name="attach_console/0"><strong>attach_console</strong></a></dt>
283242 <dd class="defbody">
284243 If the current thread has no console attached yet, attach one and
285244 redirect the user streams (input, output, and error) to the new console
297256 </pre>
298257
299258 </dd>
300 <dt class="pubdef"><a id="tdebug/1"><strong>tdebug</strong>(<var>+ThreadId</var>)</a></dt>
259 <dt class="pubdef"><a name="tdebug/1"><strong>tdebug</strong>(<var>+ThreadId</var>)</a></dt>
301260 <dd class="defbody">
302261 Prepare <var>ThreadId</var> for debugging using the graphical tracer.
303262 This implies installing the tracer hooks in the thread and switching the
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>.
263 thread to debug mode using <a name="idx:debug0:1945"></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:1946"></a><a class="pred" href="threadcom.html#thread_signal/2">thread_signal/2</a>.
306265 We refer to the documentation of this predicate for asynchronous
307266 interaction with threads. New threads created inherit their debug mode
308267 from the thread that created them.</dd>
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>
268 <dt class="pubdef"><a name="tdebug/0"><strong>tdebug</strong></a></dt>
269 <dd class="defbody">
270 Call <a name="idx:tdebug1:1947"></a><a class="pred" href="thutil.html#tdebug/1">tdebug/1</a>
312271 in all running threads.</dd>
313 <dt class="pubdef"><a id="tnodebug/1"><strong>tnodebug</strong>(<var>+ThreadId</var>)</a></dt>
272 <dt class="pubdef"><a name="tnodebug/1"><strong>tnodebug</strong>(<var>+ThreadId</var>)</a></dt>
314273 <dd class="defbody">
315274 Disable debugging thread <var>ThreadId</var>.</dd>
316 <dt class="pubdef"><a id="tnodebug/0"><strong>tnodebug</strong></a></dt>
275 <dt class="pubdef"><a name="tnodebug/0"><strong>tnodebug</strong></a></dt>
317276 <dd class="defbody">
318277 Disable debugging in all threads.</dd>
319 <dt class="pubdef"><a id="tspy/2"><strong>tspy</strong>(<var>:Spec,
278 <dt class="pubdef"><a name="tspy/2"><strong>tspy</strong>(<var>:Spec,
320279 +ThreadId</var>)</a></dt>
321280 <dd class="defbody">
322 Set a spy point as <a id="idx:spy1:1949"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
281 Set a spy point as <a name="idx:spy1:1948"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
323282 and enable the thread for debugging using
324 <a id="idx:tdebug1:1950"></a><a class="pred" href="thutil.html#tdebug/1">tdebug/1</a>.
283 <a name="idx:tdebug1:1949"></a><a class="pred" href="thutil.html#tdebug/1">tdebug/1</a>.
325284 Note that a spy point is a global flag on a predicate that is visible
326285 from all threads. Spy points are honoured in all threads that are in
327286 debug mode and ignored in threads that are in nodebug mode.</dd>
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>
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:1950"></a><a class="pred" href="debugger.html#spy/1">spy/1</a>
331290 and enable debugging in all threads using
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>.
291 <a name="idx:tdebug0:1951"></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:1952"></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:1953"></a><a class="pred" href="thutil.html#tnodebug/1">tnodebug/1</a>.
335294 </dd>
336295 </dl>
337296
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
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
339298 threads</span></a></h3>
340299
341 <a id="sec:tprofile"></a>
300 <a name="sec:tprofile"></a>
342301
343302 <p>In the current implementation, at most one thread can be profiled at
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>
303 any moment. Any thread can call <a name="idx:profile1:1954"></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:1955"></a><a class="pred" href="thutil.html#tprofile/1">tprofile/1</a>
346305 allows for profiling the execution of another thread until the user
347306 stops collecting profile data.
348307
349308 <dl class="latex">
350 <dt class="pubdef"><a id="tprofile/1"><strong>tprofile</strong>(<var>+ThreadId</var>)</a></dt>
309 <dt class="pubdef"><a name="tprofile/1"><strong>tprofile</strong>(<var>+ThreadId</var>)</a></dt>
351310 <dd class="defbody">
352311 Start collecting profile data in <var>ThreadId</var> and ask the user to
353312 hit
354 &lt;<var>return</var>&gt; to stop the profiler. See <a class="sec" href="profile.html#sec:4.41">section
313 &lt;<var>return</var>&gt; to stop the profiler. See <a class="sec" href="profile.html">section
355314 4.41</a> for details on the execution profiler.
356315 </dd>
357316 </dl>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.37</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="files.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="protocol.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:toplevel"><a id="sec:4.37"><span class="sec-nr">4.37</span> <span class="sec-title">User
194 <h2 id="sec:toplevel"><a name="sec:4.37"><span class="sec-nr">4.37</span> <span class="sec-title">User
236195 Top-level Manipulation</span></a></h2>
237196
238 <a id="sec:toplevel"></a>
197 <a name="sec:toplevel"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="break/0"><strong>break</strong></a></dt>
200 <dt class="pubdef"><a name="break/0"><strong>break</strong></a></dt>
242201 <dd class="defbody">
243202 Recursively start a new Prolog top level. This Prolog top level shares
244203 everything from the environment it was started in. Debugging is switched
248207 <code>end_of_file.</code> can be entered to return from the break
249208 environment. If the <strong>-t</strong> <var>toplevel</var> command line
250209 option is given, this goal is started instead of entering the default
251 interactive top level (<a id="idx:prolog0:1525"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
210 interactive top level (<a name="idx:prolog0:1527"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
252211
253212 <p>Notably the gui based versions (<b>swipl-win</b> on Windows and
254213 MacOS) provide the menu <b>Run/New thread</b> that opens a new toplevel
255214 that runs concurrently with the initial toplevel. The concurrent
256215 toplevel can be used to examine the program, in particular global
257216 dynamic predicates. It can not access <em>global variables</em> or
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>)
217 thread-local dynamic predicates (see <a name="idx:threadlocal1:1528"></a><a class="pred" href="threadcom.html#thread_local/1">thread_local/1</a>)
259218 of the main thread.</dd>
260 <dt class="pubdef"><a id="abort/0"><strong>abort</strong></a></dt>
219 <dt class="pubdef"><a name="abort/0"><strong>abort</strong></a></dt>
261220 <dd class="defbody">
262221 Abort the Prolog execution and restart the top level. If the
263222 <strong>-t</strong> <var>toplevel</var> command line option is given,
265224 level.
266225
267226 <p>Aborting is implemented by throwing the reserved exception
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>,
227 <code>'$aborted'</code>. This exception can be caught using <a name="idx:catch3:1529"></a><a class="pred" href="exception.html#catch/3">catch/3</a>,
269228 but the recovery goal is wrapped with a predicate that prunes the choice
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>)
229 points of the recovery goal (i.e., as <a name="idx:once1:1530"></a><a class="pred" href="metacall.html#once/1">once/1</a>)
271230 and re-throws the exception. This is illustrated in the example below,
272 where we press control-C and `a'. See also <a class="sec" href="exception.html#sec:4.11.1">section
231 where we press control-C and `a'. See also <a class="sec" href="exception.html">section
273232 4.11.1</a>.
274233
275234 <pre class="code">
279238 </pre>
280239
281240 </dd>
282 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="halt/0"><strong>halt</strong></a></dt>
241 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="halt/0"><strong>halt</strong></a></dt>
283242 <dd class="defbody">
284243 Terminate Prolog execution. This is the same as <code>halt(0)</code>.
285244 See
286 <a id="idx:halt1:1529"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>
245 <a name="idx:halt1:1531"></a><a class="pred" href="toplevel.html#halt/1">halt/1</a>
287246 for details.</dd>
288 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="halt/1"><strong>halt</strong>(<var>+Status</var>)</a></dt>
247 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="halt/1"><strong>halt</strong>(<var>+Status</var>)</a></dt>
289248 <dd class="defbody">
290249 Terminate Prolog execution with <var>Status</var>. This predicate calls
291250 <a class="func" href="foreigninclude.html#PL_halt()">PL_halt()</a> which
297256 to <var>Status</var>.
298257
299258 <p>
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>,
259 <li>Call all hooks registered using <a name="idx:athalt1:1532"></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:1533"></a><a class="pred" href="consulting.html#cancel_halt/1">cancel_halt/1</a>,
302261 termination is cancelled.
303262
304263 <p>
311270
312271 <p>
313272 <ul class="latex">
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>
273 <li>Cancel all threads, calling <a name="idx:threadatexit1:1534"></a><a class="pred" href="threadcreate.html#thread_at_exit/1">thread_at_exit/1</a>
315274 registered termination hooks. Threads not responding within 1 second are
316275 cancelled forcefully.
317276 <li>Flush I/O and close all streams except for standard I/O.
324283 <li>Call exit(Status) to terminate the process
325284 </ol>
326285 </dd>
327 <dt class="pubdef"><a id="prolog/0"><strong>prolog</strong></a></dt>
286 <dt class="pubdef"><a name="prolog/0"><strong>prolog</strong></a></dt>
328287 <dd class="defbody">
329288 This goal starts the default interactive top level. Queries are read
330289 from the stream <code>user_input</code>. See also the Prolog flag
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>
290 <a class="flag" href="flags.html#flag:history">history</a>. The <a name="idx:prolog0:1535"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>
332291 predicate is terminated (succeeds) by typing the end-of-file character
333292 (typically control-D).
334293 </dd>
336295
337296 <p>The following two hooks allow for expanding queries and handling the
338297 result of a query. These hooks are used by the top level variable
339 expansion mechanism described in <a class="sec" href="topvars.html#sec:2.8">section
298 expansion mechanism described in <a class="sec" href="topvars.html">section
340299 2.8</a>.
341300
342301 <dl class="latex">
343 <dt class="pubdef"><a id="expand_query/4"><strong>expand_query</strong>(<var>+Query,
302 <dt class="pubdef"><a name="expand_query/4"><strong>expand_query</strong>(<var>+Query,
344303 -Expanded, +Bindings, -ExpandedBindings</var>)</a></dt>
345304 <dd class="defbody">
346305 Hook in module <code>user</code>, normally not defined. <var>Query</var>
347306 and
348307 <var>Bindings</var> represents the query read from the user and the
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>.
308 names of the free variables as obtained using <a name="idx:readterm3:1536"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a>.
350309 If this predicate succeeds, it should bind <var>Expanded</var> and <var>ExpandedBindings</var>
351310 to the query and bindings to be executed by the top level. This
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>
311 predicate is used by the top level (<a name="idx:prolog0:1537"></a><a class="pred" href="toplevel.html#prolog/0">prolog/0</a>).
312 See also <a name="idx:expandanswer2:1538"></a><a class="pred" href="toplevel.html#expand_answer/2">expand_answer/2</a>
354313 and
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,
314 <a name="idx:termexpansion2:1539"></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,
357316 -ExpandedBindings</var>)</a></dt>
358317 <dd class="defbody">
359318 Hook in module <code>user</code>, normally not defined. Expand the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.8</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="history.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="debugoverview.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:topvars"><a id="sec:2.8"><span class="sec-nr">2.8</span> <span class="sec-title">Reuse
194 <h2 id="sec:topvars"><a name="sec:2.8"><span class="sec-nr">2.8</span> <span class="sec-title">Reuse
236195 of top-level bindings</span></a></h2>
237196
238 <a id="sec:topvars"></a>
197 <a name="sec:topvars"></a>
239198
240199 <p>Bindings resulting from the successful execution of a top-level goal
241200 are asserted in a database <em>if they are not too large</em>. These
255214 </pre>
256215
257216 <div class="caption"><b>Figure 1 : </b>Reusing top-level bindings</div>
258 <a id="fig:topevelvars"></a>
217 <a name="fig:topevelvars"></a>
259218
260219 <p>Note that variables may be set by executing <a class="pred" href="compare.html#=/2">=/2</a>:
261220
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section B.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ancestral-cut.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="breakpoint.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:tracehook"><a id="sec:B.3"><span class="sec-nr">B.3</span> <span class="sec-title">Intercepting
194 <h2 id="sec:tracehook"><a name="sec:B.3"><span class="sec-nr">B.3</span> <span class="sec-title">Intercepting
236195 the Tracer</span></a></h2>
237196
238 <a id="sec:tracehook"></a>
197 <a name="sec:tracehook"></a>
239198
240199 <dl class="latex">
241 <dt class="pubdef"><a id="prolog_trace_interception/4"><strong>prolog_trace_interception</strong>(<var>+Port,
200 <dt class="pubdef"><a name="prolog_trace_interception/4"><strong>prolog_trace_interception</strong>(<var>+Port,
242201 +Frame, +Choice, -Action</var>)</a></dt>
243202 <dd class="defbody">
244203 Dynamic predicate, normally not defined. This predicate is called from
269228 <dd class="defbody">
270229 The unify port represents the <em>neck</em> instruction, signalling the
271230 end of the head-matching process. This port is normally invisible. See
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>
231 <a name="idx:leash1:2192"></a><a class="pred" href="debugger.html#leash/1">leash/1</a>
232 and <a name="idx:visible1:2193"></a><a class="pred" href="debugger.html#visible/1">visible/1</a>.</dd>
274233 <dt><strong>exit</strong></dt>
275234 <dd class="defbody">
276235 The exit port signals the goal is proved. It is possible for the goal to
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>
236 have alternatives. See <a name="idx:prologframeattribute3:2194"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>
278237 to examine the goal stack.</dd>
279238 <dt><strong>fail</strong></dt>
280239 <dd class="defbody">
301260 </dl>
302261
303262 <p><var>Frame</var> is a reference to the current local stack frame,
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>
263 which can be examined using <a name="idx:prologframeattribute3:2195"></a><a class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</a>. <var>Choice</var>
305264 is a reference to the last choice point and can be examined using
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>
265 <a name="idx:prologchoiceattribute3:2196"></a><a class="pred" href="manipstack.html#prolog_choice_attribute/3">prolog_choice_attribute/3</a>. <var>Action</var>
307266 must be unified with a term that specifies how execution must continue.
308267 The following actions are defined:
309268
310269 <dl class="latex">
311270 <dt><strong>abort</strong></dt>
312271 <dd class="defbody">
313 Abort execution. See <a id="idx:abort0:2198"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
272 Abort execution. See <a name="idx:abort0:2197"></a><a class="pred" href="toplevel.html#abort/0">abort/0</a>.
314273 </dd>
315274 <dt><strong>continue</strong></dt>
316275 <dd class="defbody">
326285 </dd>
327286 <dt><strong>nodebug</strong></dt>
328287 <dd class="defbody">
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>.
288 Continue execution in normal nodebugging mode. See <a name="idx:nodebug0:2198"></a><a class="pred" href="debugger.html#nodebug/0">nodebug/0</a>.
330289 </dd>
331290 <dt><strong>retry</strong></dt>
332291 <dd class="defbody">
348307 </dd>
349308 </dl>
350309
351 <p>Together with the predicates described in <a class="sec" href="debugger.html#sec:4.39">section
310 <p>Together with the predicates described in <a class="sec" href="debugger.html">section
352311 4.39</a> and the other predicates of this chapter, this predicate
353312 enables the Prolog user to define a complete new debugger in Prolog.
354313 Besides this, it enables the Prolog programmer to monitor the execution
370329 </pre>
371330
372331 </dd>
373 <dt class="pubdef"><a id="prolog_skip_frame/1"><strong>prolog_skip_frame</strong>(<var>-Frame</var>)</a></dt>
332 <dt class="pubdef"><a name="prolog_skip_frame/1"><strong>prolog_skip_frame</strong>(<var>-Frame</var>)</a></dt>
374333 <dd class="defbody">
375334 Indicate <var>Frame</var> as a skipped frame and set the `skip level'
376335 (see
377 <a id="idx:prologskiplevel2:2200"></a><a class="pred" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a>
336 <a name="idx:prologskiplevel2:2199"></a><a class="pred" href="tracehook.html#prolog_skip_level/2">prolog_skip_level/2</a>
378337 to the recursion depth of <var>Frame</var>. The effect of the skipped
379338 flag is that a redo on a child of this frame is handled differently.
380339 First, a <code>redo</code> trace is called for the child, where the skip
381340 level is set to <code>redo_in_skip</code>. Next, the skip level is set
382341 to skip level of the skipped frame.</dd>
383 <dt class="pubdef"><a id="prolog_skip_level/2"><strong>prolog_skip_level</strong>(<var>-Old,
342 <dt class="pubdef"><a name="prolog_skip_level/2"><strong>prolog_skip_level</strong>(<var>-Old,
384343 +New</var>)</a></dt>
385344 <dd class="defbody">
386345 Unify <var>Old</var> with the old value of `skip level' and then set
387346 this level according to <var>New</var>. <var>New</var> is an integer,
388347 the atom
389348 <code>very_deep</code> (meaning don't skip) or the atom <code>skip_in_redo</code>
390 (see <a id="idx:prologskipframe1:2201"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>).
349 (see <a name="idx:prologskipframe1:2200"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>).
391350 The `skip level' is a setting of each Prolog thread that disables the
392351 debugger on all recursion levels deeper than the level of the variable.
393 See also <a id="idx:prologskipframe1:2202"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>.
352 See also <a name="idx:prologskipframe1:2201"></a><a class="pred" href="tracehook.html#prolog_skip_frame/1">prolog_skip_frame/1</a>.
394353 </dd>
395354 </dl>
396355
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.34</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="gvar.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="system.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:tty"><a id="sec:4.34"><span class="sec-nr">4.34</span> <span class="sec-title">Terminal
194 <h2 id="sec:tty"><a name="sec:4.34"><span class="sec-nr">4.34</span> <span class="sec-title">Terminal
236195 Control</span></a></h2>
237196
238 <a id="sec:tty"></a>
197 <a name="sec:tty"></a>
239198
240199 <p>The following predicates form a simple access mechanism to the Unix
241200 termcap library to provide terminal-independent I/O for screen
243202 SWI-Prolog Windows console accepts the ANSI escape sequences.
244203
245204 <dl class="latex">
246 <dt class="pubdef"><a id="tty_get_capability/3"><strong>tty_get_capability</strong>(<var>+Name,
205 <dt class="pubdef"><a name="tty_get_capability/3"><strong>tty_get_capability</strong>(<var>+Name,
247206 +Type, -Result</var>)</a></dt>
248207 <dd class="defbody">
249208 Get the capability named <var>Name</var> from the termcap library. See
256215 are only computed once. Successive queries on the same capability are
257216 fast.
258217 </dd>
259 <dt class="pubdef"><a id="tty_goto/2"><strong>tty_goto</strong>(<var>+X,
218 <dt class="pubdef"><a name="tty_goto/2"><strong>tty_goto</strong>(<var>+X,
260219 +Y</var>)</a></dt>
261220 <dd class="defbody">
262221 Goto position (<var>X</var>, <var>Y</var>) on the screen. Note that the
263222 predicates
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>
223 <a name="idx:linecount2:1437"></a><a class="pred" href="streamstat.html#line_count/2">line_count/2</a>
224 and <a name="idx:lineposition2:1438"></a><a class="pred" href="streamstat.html#line_position/2">line_position/2</a>
266225 will not have a well-defined behaviour while using this predicate.
267226 </dd>
268 <dt class="pubdef"><a id="tty_put/2"><strong>tty_put</strong>(<var>+Atom,
227 <dt class="pubdef"><a name="tty_put/2"><strong>tty_put</strong>(<var>+Atom,
269228 +Lines</var>)</a></dt>
270229 <dd class="defbody">
271230 Put an atom via the termcap library function tputs(). This function
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>
231 decodes padding information in the strings returned by <a name="idx:ttygetcapability3:1439"></a><a class="pred" href="tty.html#tty_get_capability/3">tty_get_capability/3</a>
273232 and should be used to output these strings. <var>Lines</var> is the
274233 number of lines affected by the operation, or 1 if not applicable (as in
275234 almost all cases).
276235 </dd>
277 <dt class="pubdef"><a id="tty_size/2"><strong>tty_size</strong>(<var>-Rows,
236 <dt class="pubdef"><a name="tty_size/2"><strong>tty_size</strong>(<var>-Rows,
278237 -Columns</var>)</a></dt>
279238 <dd class="defbody">
280239 Determine the size of the terminal. Platforms:
282241 <dl class="latex">
283242 <dt><b>Unix</b></dt>
284243 <dd>
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>
244 If the system provides <em>ioctl</em> calls for this, these are used and <a name="idx:ttysize2:1440"></a><a class="pred" href="tty.html#tty_size/2">tty_size/2</a>
286245 properly reflects the actual size after a user resize of the window. The <em>ioctl</em>
287246 is issued on teh file descriptor associated with the <code>user_input</code>
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>
247 stream. As a fallback, the system uses <a name="idx:ttygetcapability3:1441"></a><a class="pred" href="tty.html#tty_get_capability/3">tty_get_capability/3</a>
289248 using <code>li</code> and <code>co</code> capabilities. In this case the
290249 reported size reflects the size at the first call and is not updated
291250 after a user-initiated resize of the terminal.</dd>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 4.6</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="listing.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="compare.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:typetest"><a id="sec:4.6"><span class="sec-nr">4.6</span> <span class="sec-title">Verify
194 <h2 id="sec:typetest"><a name="sec:4.6"><span class="sec-nr">4.6</span> <span class="sec-title">Verify
236195 Type of a Term</span></a></h2>
237196
238 <a id="sec:typetest"></a>
197 <a name="sec:typetest"></a>
239198
240199 <p>Type tests are semi-deterministic predicates that succeed if the
241200 argument satisfies the requested type. Type-test predicates have no
243202 <code>library(error)</code>.
244203
245204 <dl class="latex">
246 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="var/1"><strong>var</strong>(<var>@Term</var>)</a></dt>
205 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="var/1"><strong>var</strong>(<var>@Term</var>)</a></dt>
247206 <dd class="defbody">
248207 True if <var>Term</var> currently is a free variable.
249208 </dd>
250 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="nonvar/1"><strong>nonvar</strong>(<var>@Term</var>)</a></dt>
209 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="nonvar/1"><strong>nonvar</strong>(<var>@Term</var>)</a></dt>
251210 <dd class="defbody">
252211 True if <var>Term</var> currently is not a free variable.
253212 </dd>
254 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="integer/1"><strong>integer</strong>(<var>@Term</var>)</a></dt>
213 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="integer/1"><strong>integer</strong>(<var>@Term</var>)</a></dt>
255214 <dd class="defbody">
256215 True if <var>Term</var> is bound to an integer.
257216 </dd>
258 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="float/1"><strong>float</strong>(<var>@Term</var>)</a></dt>
217 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="float/1"><strong>float</strong>(<var>@Term</var>)</a></dt>
259218 <dd class="defbody">
260219 True if <var>Term</var> is bound to a floating point number.
261220 </dd>
262 <dt class="pubdef"><a id="rational/1"><strong>rational</strong>(<var>@Term</var>)</a></dt>
221 <dt class="pubdef"><a name="rational/1"><strong>rational</strong>(<var>@Term</var>)</a></dt>
263222 <dd class="defbody">
264223 True if <var>Term</var> is bound to a rational number. Rational numbers
265224 include integers.
266225 </dd>
267 <dt class="pubdef"><a id="rational/3"><strong>rational</strong>(<var>@Term,
226 <dt class="pubdef"><a name="rational/3"><strong>rational</strong>(<var>@Term,
268227 -Numerator, -Denominator</var>)</a></dt>
269228 <dd class="defbody">
270229 True if <var>Term</var> is a rational number with given <var>Numerator</var>
274233 integer and there are no common divisors between <var>Numerator</var>
275234 and <var>Denominator</var>.
276235 </dd>
277 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="number/1"><strong>number</strong>(<var>@Term</var>)</a></dt>
278 <dd class="defbody">
279 True if <var>Term</var> is bound to an integer or floating point number.<sup class="fn">55<span class="fn-text">As
236 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="number/1"><strong>number</strong>(<var>@Term</var>)</a></dt>
237 <dd class="defbody">
238 True if <var>Term</var> is bound to an integer or floating point number.<sup class="fn">54<span class="fn-text">As
280239 rational numbers are not atomic in the current implementation and we do
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>
240 not want to break the rule that <a name="idx:number1:603"></a><a class="pred" href="typetest.html#number/1">number/1</a>
241 implies <a name="idx:atomic1:604"></a><a class="pred" href="typetest.html#atomic/1">atomic/1</a>, <a name="idx:number1:605"></a><a class="pred" href="typetest.html#number/1">number/1</a>
283242 fails on rational numbers. This will change if rational numbers become
284243 atomic.</span></sup></dd>
285 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atom/1"><strong>atom</strong>(<var>@Term</var>)</a></dt>
244 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atom/1"><strong>atom</strong>(<var>@Term</var>)</a></dt>
286245 <dd class="defbody">
287246 True if <var>Term</var> is bound to an atom.</dd>
288 <dt class="pubdef"><a id="blob/2"><strong>blob</strong>(<var>@Term,
247 <dt class="pubdef"><a name="blob/2"><strong>blob</strong>(<var>@Term,
289248 ?Type</var>)</a></dt>
290249 <dd class="defbody">
291250 True if <var>Term</var> is a <em>blob</em> of type <var>Type</var>. See
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>
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>
294253 <dd class="defbody">
295254 True if <var>Term</var> is bound to a string. Note that string here
296 refers to the built-in atomic type string as described in <a class="sec" href="strings.html#sec:5.2">section
255 refers to the built-in atomic type string as described in <a class="sec" href="strings.html">section
297256 5.2</a>. Starting with version&nbsp;7, the syntax for a string object is
298 text between double quotes, such as <code>"hello"</code>.<sup class="fn">56<span class="fn-text">In
257 text between double quotes, such as <code>"hello"</code>.<sup class="fn">55<span class="fn-text">In
299258 traditional Prolog systems, double quoted text is often mapped to a list
300259 of <em>character codes</em>.</span></sup> See also the Prolog flag
301260 <a class="flag" href="flags.html#flag:double_quotes">double_quotes</a>.</dd>
302 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="atomic/1"><strong>atomic</strong>(<var>@Term</var>)</a></dt>
261 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="atomic/1"><strong>atomic</strong>(<var>@Term</var>)</a></dt>
303262 <dd class="defbody">
304263 True if <var>Term</var> is bound (i.e., not a variable) and is not
305264 compound. Thus, atomic acts as if defined by:
310269 \+ compound(Term).
311270 </pre>
312271
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>).
272 <p>SWI-Prolog defines the following atomic datatypes: atom (<a name="idx:atom1:606"></a><a class="pred" href="typetest.html#atom/1">atom/1</a>),
273 string (<a name="idx:string1:607"></a><a class="pred" href="typetest.html#string/1">string/1</a>),
274 integer (<a name="idx:integer1:608"></a><a class="pred" href="typetest.html#integer/1">integer/1</a>),
275 floating point number (<a name="idx:float1:609"></a><a class="pred" href="typetest.html#float/1">float/1</a>)
276 and blob (<a name="idx:blob2:610"></a><a class="pred" href="typetest.html#blob/2">blob/2</a>).
318277 In addition, the symbol <code>[]</code> (empty list) is atomic, but not
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>
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:611"></a><a class="pred" href="manipterm.html#functor/3">functor/3</a>
282 =../2, <a name="idx:compoundnamearity3:612"></a><a class="pred" href="manipterm.html#compound_name_arity/3">compound_name_arity/3</a>
283 and <a name="idx:compoundnamearguments3:613"></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>
326285 <dd class="defbody">
327286 True if <var>Term</var> is bound to an atom or a compound term. This was
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>..
287 intended as a type-test for arguments to <a name="idx:call1:614"></a><a class="pred" href="metacall.html#call/1">call/1</a>
288 and <a name="idx:call2:615"></a><a class="pred" href="metacall.html#call/2">call/2</a>..
330289 Note that callable only tests the <em>surface term</em>. Terms such as
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>)
290 (22,true) are considered callable, but cause <a name="idx:call1:616"></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:617"></a><a class="pred" href="metapred.html#meta_predicate/1">meta_predicate/1</a>)
333292 using
334293 <code><code>:</code>/2</code> causes callable to succeed on any
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>
294 meta-argument.<sup class="fn">56<span class="fn-text">We think that <a name="idx:callable1:618"></a><a class="pred" href="typetest.html#callable/1">callable/1</a>
336295 should be deprecated and there should be two new predicates, one
337296 performing a test for callable that is minimally module aware and
338 possibly consistent with type-checking in <a id="idx:call1:617"></a><a class="pred" href="metacall.html#call/1">call/1</a>
297 possibly consistent with type-checking in <a name="idx:call1:619"></a><a class="pred" href="metacall.html#call/1">call/1</a>
339298 and a second predicate that tests for atom or compound.</span></sup>
340299 Consider the program and query below:
341300
351310 </pre>
352311
353312 </dd>
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>
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:620"></a><a class="pred" href="manipterm.html#nonground/2">nonground/2</a>
316 and <a name="idx:termvariables2:621"></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>
359318 <dd class="defbody">
360319 True if <var>Term</var> contains cycles, i.e. is an infinite term. See
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>
320 also <a name="idx:acyclicterm1:622"></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">57<span class="fn-text">The
322 predicates <a name="idx:cyclicterm1:623"></a><a class="pred" href="typetest.html#cyclic_term/1">cyclic_term/1</a>
323 and <a name="idx:acyclicterm1:624"></a><a class="pred" href="typetest.html#acyclic_term/1">acyclic_term/1</a>
365324 are compatible with SICStus Prolog. Some Prolog systems supporting
366325 cyclic terms use is_cyclic/1 .</span></sup></dd>
367 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a id="acyclic_term/1"><strong>acyclic_term</strong>(<var>@Term</var>)</a></dt>
326 <dt class="pubdef"><span class="pred-tag">[ISO]</span><a name="acyclic_term/1"><strong>acyclic_term</strong>(<var>@Term</var>)</a></dt>
368327 <dd class="defbody">
369328 True if <var>Term</var> does not contain cycles, i.e. can be processed
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>.
329 recursively in finite time. See also <a name="idx:cyclicterm1:625"></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>.
372331 </dd>
373332 </dl>
374333
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.37</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="threadpool.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="url.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:ugraphs"><a id="sec:A.37"><span class="sec-nr">A.37</span> <span class="sec-title">library(ugraphs):
194 <h2 id="sec:ugraphs"><a name="sec:A.37"><span class="sec-nr">A.37</span> <span class="sec-title">library(ugraphs):
236195 Unweighted Graphs</span></a></h2>
237196
238 <a id="sec:ugraphs"></a>
239 <a id="sec:lib:ugraphs"></a> Authors: <em>Richard O'Keefe &amp; Vitor
197 <a name="sec:ugraphs"></a>
198 <a name="sec:lib:ugraphs"></a> Authors: <em>Richard O'Keefe &amp; Vitor
240199 Santos Costa</em>
241200 <blockquote><i>Implementation and documentation are copied from YAP
242201 5.0.1. The
267226 has no neighbors.
268227
269228 <dl class="latex">
270 <dt class="pubdef"><a id="vertices_edges_to_ugraph/3"><strong>vertices_edges_to_ugraph</strong>(<var>+Vertices,
229 <dt class="pubdef"><a name="vertices_edges_to_ugraph/3"><strong>vertices_edges_to_ugraph</strong>(<var>+Vertices,
271230 +Edges, -Graph</var>)</a></dt>
272231 <dd class="defbody">
273232 Given a graph with a set of <var>Vertices</var> and a set of <var>Edges</var>,
291250 </pre>
292251
293252 </dd>
294 <dt class="pubdef"><a id="vertices/2"><strong>vertices</strong>(<var>+Graph,
253 <dt class="pubdef"><a name="vertices/2"><strong>vertices</strong>(<var>+Graph,
295254 -Vertices</var>)</a></dt>
296255 <dd class="defbody">
297256 Unify <var>Vertices</var> with all vertices appearing in <var>Graph</var>.
303262 </pre>
304263
305264 </dd>
306 <dt class="pubdef"><a id="edges/2"><strong>edges</strong>(<var>+Graph,
265 <dt class="pubdef"><a name="edges/2"><strong>edges</strong>(<var>+Graph,
307266 -Edges</var>)</a></dt>
308267 <dd class="defbody">
309268 Unify <var>Edges</var> with all edges appearing in <var>Graph</var>.
315274 </pre>
316275
317276 </dd>
318 <dt class="pubdef"><a id="add_vertices/3"><strong>add_vertices</strong>(<var>+Graph,
277 <dt class="pubdef"><a name="add_vertices/3"><strong>add_vertices</strong>(<var>+Graph,
319278 +Vertices, -NewGraph</var>)</a></dt>
320279 <dd class="defbody">
321280 Unify <var>NewGraph</var> with a new graph obtained by adding the list
328287 </pre>
329288
330289 </dd>
331 <dt class="pubdef"><a id="del_vertices/3"><strong>del_vertices</strong>(<var>+Graph,
290 <dt class="pubdef"><a name="del_vertices/3"><strong>del_vertices</strong>(<var>+Graph,
332291 +Vertices, -NewGraph</var>)</a></dt>
333292 <dd class="defbody">
334293 Unify <var>NewGraph</var> with a new graph obtained by deleting the list
345304 </pre>
346305
347306 </dd>
348 <dt class="pubdef"><a id="add_edges/3"><strong>add_edges</strong>(<var>+Graph,
307 <dt class="pubdef"><a name="add_edges/3"><strong>add_edges</strong>(<var>+Graph,
349308 +Edges, -NewGraph</var>)</a></dt>
350309 <dd class="defbody">
351310 Unify <var>NewGraph</var> with a new graph obtained by adding the list
362321 </pre>
363322
364323 </dd>
365 <dt class="pubdef"><a id="del_edges/3"><strong>del_edges</strong>(<var>+Graph,
324 <dt class="pubdef"><a name="del_edges/3"><strong>del_edges</strong>(<var>+Graph,
366325 +Edges, -NewGraph</var>)</a></dt>
367326 <dd class="defbody">
368327 Unify <var>NewGraph</var> with a new graph obtained by removing the list
378337 </pre>
379338
380339 </dd>
381 <dt class="pubdef"><a id="transpose_ugraph/2"><strong>transpose_ugraph</strong>(<var>+Graph,
340 <dt class="pubdef"><a name="transpose_ugraph/2"><strong>transpose_ugraph</strong>(<var>+Graph,
382341 -NewGraph</var>)</a></dt>
383342 <dd class="defbody">
384343 Unify <var>NewGraph</var> with a new graph obtained from <var>Graph</var>
393352 </pre>
394353
395354 </dd>
396 <dt class="pubdef"><a id="neighbours/3"><strong>neighbours</strong>(<var>+Vertex,
355 <dt class="pubdef"><a name="neighbours/3"><strong>neighbours</strong>(<var>+Vertex,
397356 +Graph, -Vertices</var>)</a></dt>
398357 <dd class="defbody">
399358 Unify <var>Vertices</var> with the list of neighbours of vertex <var>Vertex</var>
406365 </pre>
407366
408367 </dd>
409 <dt class="pubdef"><a id="neighbors/3"><strong>neighbors</strong>(<var>+Vertex,
368 <dt class="pubdef"><a name="neighbors/3"><strong>neighbors</strong>(<var>+Vertex,
410369 +Graph, -Vertices</var>)</a></dt>
411370 <dd class="defbody">
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,
371 American version of <a name="idx:neighbours3:2179"></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,
414373 -NewGraph</var>)</a></dt>
415374 <dd class="defbody">
416375 Unify <var>NewGraph</var> with the graph complementary to <var>Graph</var>.
425384 </pre>
426385
427386 </dd>
428 <dt class="pubdef"><a id="compose/3"><strong>compose</strong>(<var>+LeftGraph,
387 <dt class="pubdef"><a name="compose/3"><strong>compose</strong>(<var>+LeftGraph,
429388 +RightGraph, -NewGraph</var>)</a></dt>
430389 <dd class="defbody">
431390 Compose <var>NewGraph</var> by connecting the <em>drains</em> of <var>LeftGraph</var>
437396 </pre>
438397
439398 </dd>
440 <dt class="pubdef"><a id="ugraph_union/3"><strong>ugraph_union</strong>(<var>+Graph1,
399 <dt class="pubdef"><a name="ugraph_union/3"><strong>ugraph_union</strong>(<var>+Graph1,
441400 +Graph2, -NewGraph</var>)</a></dt>
442401 <dd class="defbody">
443402 <var>NewGraph</var> is the union of <var>Graph1</var> and <var>Graph2</var>.
449408 </pre>
450409
451410 </dd>
452 <dt class="pubdef"><a id="top_sort/2"><strong>top_sort</strong>(<var>+Graph,
411 <dt class="pubdef"><a name="top_sort/2"><strong>top_sort</strong>(<var>+Graph,
453412 -Sort</var>)</a></dt>
454413 <dd class="defbody">
455414 Generate the set of nodes <var>Sort</var> as a topological sorting of
463422 </pre>
464423
465424 </dd>
466 <dt class="pubdef"><a id="top_sort/3"><strong>top_sort</strong>(<var>+Graph,
425 <dt class="pubdef"><a name="top_sort/3"><strong>top_sort</strong>(<var>+Graph,
467426 -Sort0, -Sort</var>)</a></dt>
468427 <dd class="defbody">
469428 Generate the difference list Sort-Sort0 as a topological sorting of
470429 <var>Graph</var>, if one is possible.</dd>
471 <dt class="pubdef"><a id="transitive_closure/2"><strong>transitive_closure</strong>(<var>+Graph,
430 <dt class="pubdef"><a name="transitive_closure/2"><strong>transitive_closure</strong>(<var>+Graph,
472431 -Closure</var>)</a></dt>
473432 <dd class="defbody">
474433 Generate the graph Closure as the transitive closure of
480439 </pre>
481440
482441 </dd>
483 <dt class="pubdef"><a id="reachable/3"><strong>reachable</strong>(<var>+Vertex,
442 <dt class="pubdef"><a name="reachable/3"><strong>reachable</strong>(<var>+Vertex,
484443 +Graph, -Vertices</var>)</a></dt>
485444 <dd class="defbody">
486445 Unify <var>Vertices</var> with the set of all vertices in <var>Graph</var>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.38</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="ugraphs.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="varnumbers.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:url"><a id="sec:A.38"><span class="sec-nr">A.38</span> <span class="sec-title">library(url):
194 <h2 id="sec:url"><a name="sec:A.38"><span class="sec-nr">A.38</span> <span class="sec-title">library(url):
236195 Analysing and constructing URL</span></a></h2>
237196
238 <p><a id="sec:url"></a>
197 <p><a name="sec:url"></a>
239198
240199 <dl class="tags">
241200 <dt class="mtag">author</dt>
262221 of the standard encountered in practical use.
263222
264223 <dl class="latex">
265 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="global_url/3"><strong>global_url</strong>(<var>+URL,
224 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="global_url/3"><strong>global_url</strong>(<var>+URL,
266225 +Base, -Global</var>)</a></dt>
267226 <dd class="defbody">
268227 Translate a possibly relative <var>URL</var> into an absolute one.
275234 </dl>
276235
277236 </dd>
278 <dt class="pubdef"><a id="is_absolute_url/1"><strong>is_absolute_url</strong>(<var>+URL</var>)</a></dt>
237 <dt class="pubdef"><a name="is_absolute_url/1"><strong>is_absolute_url</strong>(<var>+URL</var>)</a></dt>
279238 <dd class="defbody">
280239 True if <var>URL</var> is an absolute <var>URL</var>. That is, a <var>URL</var>
281240 that starts with a protocol identifier.</dd>
282 <dt class="pubdef"><a id="http_location/2"><strong>http_location</strong>(<var>?Parts,
241 <dt class="pubdef"><a name="http_location/2"><strong>http_location</strong>(<var>?Parts,
283242 ?Location</var>)</a></dt>
284243 <dd class="defbody">
285244 Construct or analyze an HTTP location. This is similar to
293252 </pre>
294253
295254 <table class="arglist">
296 <tr><td><var>Location</var> </td><td>Atom or list of character codes. </td></tr>
255 <tr valign="top"><td><var>Location</var> </td><td>Atom or list of
256 character codes. </td></tr>
297257 </table>
298258 </dd>
299 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="parse_url/2"><strong>parse_url</strong>(<var>?URL,
259 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="parse_url/2"><strong>parse_url</strong>(<var>?URL,
300260 ?Attributes</var>)</a></dt>
301261 <dd class="defbody">
302262 Construct or analyse a <var>URL</var>. <var>URL</var> is an atom holding
364324
365325 <p>By instantiating the parts-list this predicate can be used to create
366326 a <var>URL</var>.</dd>
367 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="parse_url/3"><strong>parse_url</strong>(<var>+URL,
327 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="parse_url/3"><strong>parse_url</strong>(<var>+URL,
368328 +BaseURL, -Attributes</var>)</a></dt>
369329 <dd class="defbody">
370330 Similar to <a class="pred" href="url.html#parse_url/2">parse_url/2</a>
371331 for relative URLs. If <var>URL</var> is relative, it is resolved using
372332 the absolute <var>URL</var> <var>BaseURL</var>.</dd>
373 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="www_form_encode/2"><strong>www_form_encode</strong>(<var>+Value,
333 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="www_form_encode/2"><strong>www_form_encode</strong>(<var>+Value,
374334 -XWWWFormEncoded</var>)</a></dt>
375 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="www_form_encode/2"><strong>www_form_encode</strong>(<var>-Value,
335 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="www_form_encode/2"><strong>www_form_encode</strong>(<var>-Value,
376336 +XWWWFormEncoded</var>)</a></dt>
377337 <dd class="defbody">
378338 En/decode to/from application/x-www-form-encoded. Encoding encodes all
393353 </dl>
394354
395355 </dd>
396 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="set_url_encoding/2"><strong>set_url_encoding</strong>(<var>?Old,
356 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="set_url_encoding/2"><strong>set_url_encoding</strong>(<var>?Old,
397357 +New</var>)</a></dt>
398358 <dd class="defbody">
399359 Query and set the encoding for URLs. The default is <code>utf8</code>.
408368 </dl>
409369
410370 </dd>
411 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="url_iri/2"><strong>url_iri</strong>(<var>+Encoded,
371 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="url_iri/2"><strong>url_iri</strong>(<var>+Encoded,
412372 -Decoded</var>)</a></dt>
413 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="url_iri/2"><strong>url_iri</strong>(<var>-Encoded,
373 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="url_iri/2"><strong>url_iri</strong>(<var>-Encoded,
414374 +Decoded</var>)</a></dt>
415375 <dd class="defbody">
416376 Convert between a URL, encoding in US-ASCII and an IRI. An IRI is a
417377 fully expanded Unicode string. Unicode strings are first encoded into
418378 UTF-8, after which %-encoding takes place.</dd>
419 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="parse_url_search/2"><strong>parse_url_search</strong>(<var>?Spec,
379 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="parse_url_search/2"><strong>parse_url_search</strong>(<var>?Spec,
420380 ?Fields:list(Name=Value)</var>)</a></dt>
421381 <dd class="defbody">
422382 Construct or analyze an HTTP search specification. This deals with form
423383 data using the MIME-type
424384 <code>application/x-www-form-urlencoded</code> as used in HTTP GET
425385 requests.</dd>
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,
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,
427387 -URL</var>)</a></dt>
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,
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,
429389 +URL</var>)</a></dt>
430390 <dd class="defbody">
431391 Translate between a filename and a file:<code>//</code> <var>URL</var>.
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 12.3</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="qsaveforeign.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="findappfile.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:useresource"><a id="sec:12.3"><span class="sec-nr">12.3</span> <span class="sec-title">Using
194 <h2 id="sec:useresource"><a name="sec:12.3"><span class="sec-nr">12.3</span> <span class="sec-title">Using
236195 program resources</span></a></h2>
237196
238 <a id="sec:useresource"></a>
197 <a name="sec:useresource"></a>
239198
240199 <p>A <em>resource</em> is very similar to a file. Resources, however,
241200 can be represented in two different formats: on files, as well as part
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>).
201 of the resource <em>archive</em> of a saved state (see <a name="idx:qsaveprogram2:2122"></a><a class="pred" href="runtime.html#qsave_program/2">qsave_program/2</a>).
243202
244203 <p>A resource has a <em>name</em> and a <em>class</em>. The <em>source</em>
245204 data of the resource is a file. Resources are declared by declaring the
246 predicate <a id="idx:resource3:2124"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
205 predicate <a name="idx:resource3:2123"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
247206 They are accessed using the predicate
248 <a id="idx:openresource3:2125"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
207 <a name="idx:openresource3:2124"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>.
249208
250209 <p>Before going into details, let us start with an example. Short texts
251210 can easily be expressed in Prolog source code, but long texts are
264223 close(In)).
265224 </pre>
266225
267 <p>The predicate <a id="idx:help0:2126"></a><a class="pred" href="help.html#help/0">help/0</a>
226 <p>The predicate <a name="idx:help0:2125"></a><a class="pred" href="help.html#help/0">help/0</a>
268227 opens the resource as a Prolog stream. If we are executing this from the
269228 development environment, this will actually return a stream to the file <code>help.txt</code>
270229 itself. When executed from the saved state, the stream will actually be
271230 a stream opened on the program resource file, taking care of the offset
272231 and length of the resource.
273232
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
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
275234 manipulation predicates</span></a></h3>
276235
277 <a id="sec:runtime-predicates"></a>
236 <a name="sec:runtime-predicates"></a>
278237
279238 <dl class="latex">
280 <dt class="pubdef"><a id="resource/3"><strong>resource</strong>(<var>+Name,
239 <dt class="pubdef"><a name="resource/3"><strong>resource</strong>(<var>+Name,
281240 +Class, +FileSpec</var>)</a></dt>
282241 <dd class="defbody">
283242 This predicate is defined as a dynamic predicate in the module
287246 :, which are reserved for internal usage by the resource library. <var>Class</var>
288247 describes the kind of object stored in the resource. In the current
289248 implementation, it is just an atom. <var>FileSpec</var> is a file
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>
249 specification that may exploit <a name="idx:filesearchpath2:2126"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
291250 (see
292 <a id="idx:absolutefilename2:2128"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
251 <a name="idx:absolutefilename2:2127"></a><a class="pred" href="files.html#absolute_file_name/2">absolute_file_name/2</a>).
293252
294253 <p>Normally, resources are defined as unit clauses (facts), but the
295254 definition of this predicate also allows for rules. For proper
299258
300259 <p>Dynamic rules are useful to turn all files in a certain directory
301260 into resources, without specifying a resource for each file. For
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>
261 example, assume the <a name="idx:filesearchpath2:2128"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a> <code>icons</code>
303262 refers to the resource directory containing icon files. The following
304263 definition makes all these images available as resources:
305264
316275 </pre>
317276
318277 </dd>
319 <dt class="pubdef"><a id="open_resource/3"><strong>open_resource</strong>(<var>+Name,
278 <dt class="pubdef"><a name="open_resource/3"><strong>open_resource</strong>(<var>+Name,
320279 ?Class, -Stream</var>)</a></dt>
321280 <dd class="defbody">
322281 Opens the resource specified by <var>Name</var> and <var>Class</var>. If
325284 <var>Stream</var> becomes a handle to a binary input stream, providing
326285 access to the content of the resource.
327286
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>.
287 <p>The predicate <a name="idx:openresource3:2129"></a><a class="pred" href="useresource.html#open_resource/3">open_resource/3</a>
288 first checks <a name="idx:resource3:2130"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>.
330289 When successful it will open the returned resource source file.
331290 Otherwise it will look in the program's resource database. When creating
332291 a saved state, the system normally saves the resource contents into the
333292 resource archive, but does not save the resource clauses.
334293
335294 <p>This way, the development environment uses the files (and
336 modifications) to the <a id="idx:resource3:2132"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>
295 modifications) to the <a name="idx:resource3:2131"></a><a class="pred" href="useresource.html#resource/3">resource/3</a>
337296 declarations and/or files containing resource info, thus immediately
338297 affecting the running environment, while the runtime system quickly
339298 accesses the system resources.
340299 </dd>
341300 </dl>
342301
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>
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>
344303 program</span></a></h3>
345304
346 <a id="sec:swiplrc"></a>
305 <a name="sec:swiplrc"></a>
347306
348307 <p>The utility program <b>swipl-rc</b> can be used to examine and
349308 manipulate the contents of a SWI-Prolog resource file. The options are
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.2</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="projectfiles.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="editreload.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:usingmodules"><a id="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Using
194 <h2 id="sec:usingmodules"><a name="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Using
236195 modules</span></a></h2>
237196
238 <a id="sec:usingmodules"></a>
197 <a name="sec:usingmodules"></a>
239198
240199 <p>Modules have been debated fiercely in the Prolog world. Despite all
241200 counter-arguments we feel they are extremely useful because:
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.39</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="url.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="yall.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:varnumbers"><a id="sec:A.39"><span class="sec-nr">A.39</span> <span class="sec-title">library(varnumbers):
194 <h2 id="sec:varnumbers"><a name="sec:A.39"><span class="sec-nr">A.39</span> <span class="sec-title">library(varnumbers):
236195 Utilities for numbered terms</span></a></h2>
237196
238 <p><a id="sec:varnumbers"></a>
197 <p><a name="sec:varnumbers"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">See also</dt>
267226 </pre>
268227
269228 <dl class="latex">
270 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="numbervars/1"><strong>numbervars</strong>(<var>+Term</var>)</a></dt>
229 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="numbervars/1"><strong>numbervars</strong>(<var>+Term</var>)</a></dt>
271230 <dd class="defbody">
272231 Number variables in <var>Term</var> using $VAR(N). Equivalent to
273232 <code>numbervars(Term, 0, _)</code>.
280239 </dl>
281240
282241 </dd>
283 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="varnumbers/2"><strong>varnumbers</strong>(<var>+Term,
242 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="varnumbers/2"><strong>varnumbers</strong>(<var>+Term,
284243 -Copy</var>)</a></dt>
285244 <dd class="defbody">
286245 Inverse of <a class="pred" href="varnumbers.html#numbervars/1">numbervars/1</a>.
287246 Equivalent to <code>varnumbers(Term, 0, Copy)</code>.</dd>
288 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="varnumbers/3"><strong>varnumbers</strong>(<var>+Term,
247 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="varnumbers/3"><strong>varnumbers</strong>(<var>+Term,
289248 +Start, -Copy</var>)</a></dt>
290249 <dd class="defbody">
291250 Inverse of <a class="pred" href="manipterm.html#numbervars/3">numbervars/3</a>.
307266 </dl>
308267
309268 </dd>
310 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="max_var_number/3"><strong>max_var_number</strong>(<var>+Term,
269 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="max_var_number/3"><strong>max_var_number</strong>(<var>+Term,
311270 +Start, -Max</var>)</a></dt>
312271 <dd class="defbody">
313272 True when <var>Max</var> is the max of <var>Start</var> and the highest
326285 </dl>
327286
328287 </dd>
329 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="varnumbers_names/3"><strong>varnumbers_names</strong>(<var>+Term,
288 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="varnumbers_names/3"><strong>varnumbers_names</strong>(<var>+Term,
330289 -Copy, -VariableNames</var>)</a></dt>
331290 <dd class="defbody">
332291 If <var>Term</var> is a term with numbered and named variables using the
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 6.1</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="modules.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="defmodule.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:whymodules"><a id="sec:6.1"><span class="sec-nr">6.1</span> <span class="sec-title">Why
194 <h2 id="sec:whymodules"><a name="sec:6.1"><span class="sec-nr">6.1</span> <span class="sec-title">Why
236195 Use Modules?</span></a></h2>
237196
238 <a id="sec:whymodules"></a>
197 <a name="sec:whymodules"></a>
239198
240199 <p>In classic Prolog systems, all predicates are organised in a single
241200 namespace and any predicate can call any predicate. Because each
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 2.19</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="jitindex.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="limits.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:widechars"><a id="sec:2.19"><span class="sec-nr">2.19</span> <span class="sec-title">Wide
194 <h2 id="sec:widechars"><a name="sec:2.19"><span class="sec-nr">2.19</span> <span class="sec-title">Wide
236195 character support</span></a></h2>
237196
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
197 <a name="sec:widechars"></a>
198
199 <p><a name="idx:UTF8:264"></a><a name="idx:Unicode:265"></a><a name="idx:UCS:266"></a><a name="idx:internationalization:267"></a>SWI-Prolog
241200 supports <em>wide characters</em>, characters with character codes above
242201 255 that cannot be represented in a single <em>byte</em>.
243202 <em>Universal Character Set</em> (UCS) is the ISO/IEC 10646 standard
249208 as case conversion are unambiguously defined.
250209
251210 <p>For this reason SWI-Prolog has two representations for atoms and
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
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
257216 11</a> sometimes need to be aware of these issues though.
258217
259218 <p>Character coding comes into view when characters of strings need to
262221 section we only deal with I/O through streams, which includes file I/O
263222 as well as I/O through network sockets.
264223
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
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
266225 character encodings on streams</span></a></h3>
267226
268 <a id="sec:encoding"></a>
227 <a name="sec:encoding"></a>
269228
270229 <p>Although characters are uniquely coded using the UCS standard
271230 internally, streams and files are byte (8-bit) oriented and there are a
278237 pairs of bytes, is also popular.
279238
280239 <p>Prolog I/O streams have a property called <em>encoding</em> which
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>
240 specifies the used encoding that influences <a name="idx:getcode2:268"></a><a class="pred" href="chario.html#get_code/2">get_code/2</a>
241 and <a name="idx:putcode2:269"></a><a class="pred" href="chario.html#put_code/2">put_code/2</a>
283242 as well as all the other text I/O predicates.
284243
285244 <p>The default encoding for files is derived from the Prolog flag
289248 and the translation is left to the wide-character functions of the C
290249 library.<sup class="fn">34<span class="fn-text">The Prolog native UTF-8
291250 mode is considerably faster than the generic mbrtowc() one.</span></sup>
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>
251 The encoding can be specified explicitly in <a name="idx:loadfiles2:270"></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:271"></a><a class="pred" href="IO.html#open/4">open/4</a>
253 when opening files or using <a name="idx:setstream2:272"></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:273"></a><a class="pred" href="consulting.html#encoding/1">encoding/1</a>
296255 directive that can be used to switch between encodings that are
297256 compatible with US-ASCII (<code>ascii</code>, <code>iso_latin_1</code>, <code>utf8</code>
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
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
300259 2.16.1.8</a> for syntax issues. For additional information and Unicode
301260 resources, please visit
302261 <a class="url" href="http://www.unicode.org/">http://www.unicode.org/</a>.
340299 <p>Note that not all encodings can represent all characters. This
341300 implies that writing text to a stream may cause errors because the
342301 stream cannot represent these characters. The behaviour of a stream on
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>.
302 these errors can be controlled using <a name="idx:setstream2:274"></a><a class="pred" href="IO.html#set_stream/2">set_stream/2</a>.
344303 Initially the terminal stream writes the characters using Prolog escape
345304 sequences while other streams generate an I/O exception.
346305
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:
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:
348307 Byte Order Mark</span></a></h4>
349308
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
309 <a name="sec:bom"></a>
310
311 <p><a name="idx:BOM:275"></a><a name="idx:ByteOrderMark:276"></a>From <a class="sec" href="widechars.html">section
353312 2.19.1</a>, you may have got the impression that text files are
354313 complicated. This section deals with a related topic, making life often
355314 easier for the user, but providing another worry to the programmer.
366325 additional information revealing the encoding, making the use of a BOM
367326 redundant or even illegal.
368327
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>
328 <p>The BOM is handled by SWI-Prolog <a name="idx:open4:277"></a><a class="pred" href="IO.html#open/4">open/4</a>
370329 predicate. By default, text files are probed for the BOM when opened for
371330 reading. If a BOM is found, the encoding is set accordingly and the
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>.
331 property <code>bom(true)</code> is available through <a name="idx:streamproperty2:278"></a><a class="pred" href="IO.html#stream_property/2">stream_property/2</a>.
373332 When opening a file for writing, writing a BOM can be requested using
374333 the option <code>bom(true)</code> with
375 <a id="idx:open4:277"></a><a class="pred" href="IO.html#open/4">open/4</a>.
334 <a name="idx:open4:279"></a><a class="pred" href="IO.html#open/4">open/4</a>.
376335
377336 <p></body></html>
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.18</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="nb_set.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="option.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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):
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):
236195 Activating your Web-browser</span></a></h2>
237196
238 <a id="sec:www_browser"></a>
197 <a name="sec:www_browser"></a>
239198
240199 <p>This library deals with the very system-dependent task of opening a
241200 web page in a browser. See also <code>library(url)</code> and the HTTP
242201 package.
243202
244203 <dl class="latex">
245 <dt class="pubdef"><a id="www_open_url/1"><strong>www_open_url</strong>(<var>+URL</var>)</a></dt>
204 <dt class="pubdef"><a name="www_open_url/1"><strong>www_open_url</strong>(<var>+URL</var>)</a></dt>
246205 <dd class="defbody">
247206 Open <var>URL</var> in an external web browser. The reason to place this
248207 in the library is to centralise the maintenance on this highly platform-
251210 <p>
252211 <ul class="latex">
253212 <li><i>MS-Windows</i><br>
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>
213 If it detects MS-Windows it uses <a name="idx:winshell2:2151"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>
255214 to open the <var>URL</var>. The behaviour and browser started depends on
256215 the version of Windows and Windows-shell configuration, but in general
257216 it should be the behaviour expected by the user.
258217
259218 <p>
260219 <li><i>Other platforms</i><br>
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>)
220 On other platforms it tests the environment variable (see <a name="idx:getenv2:2152"></a><a class="pred" href="system.html#getenv/2">getenv/2</a>)
262221 named <code>BROWSER</code> or uses <b>netscape</b> if this variable is
263222 not set. If the browser is either <code>mozilla</code> or <code>netscape</code>,
264 <a id="idx:wwwopenurl1:2154"></a><a class="pred" href="www_browser.html#www_open_url/1">www_open_url/1</a>
223 <a name="idx:wwwopenurl1:2153"></a><a class="pred" href="www_browser.html#www_open_url/1">www_open_url/1</a>
265224 first tries to open a new window on a running browser using the <code>-remote</code>
266225 option of Netscape. If this fails or the browser is not <code>mozilla</code>
267226 or <code>netscape</code> the system simply passes the URL as first
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section 3.7</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="navigator.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="idepreds.html"><img src="next.gif" alt="Next"></a>
234193 </div>
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>
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>
238197
239198 <p>A cross-referencer is a tool that examines the caller-callee relation
240199 between predicates, and, using this information to explicate dependency
242201 and predicates for which no callers can be found. Cross-referencing is
243202 useful during program development, reorganisation, clean-up, porting and
244203 other program maintenance tasks. The dynamic nature of Prolog makes the
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>
204 task non-trivial. Goals can be created dynamically using <a name="idx:call1:324"></a><a class="pred" href="metacall.html#call/1">call/1</a>
246205 after construction of a goal term. Abstract interpretation can find some
247206 of these calls, but they can also come from external communication,
248207 making it impossible to predict the callee. In other words, the
252211
253212 <p>SWI-Prolog's cross-referencer is split into two parts. The standard
254213 Prolog library <code>library(prolog_xref)</code> is an extensible
255 library for information gathering described in <a class="sec" href="prolog_xref.html#sec:A.27">section
214 library for information gathering described in <a class="sec" href="prolog_xref.html">section
256215 A.27</a>, and the XPCE library <code>library(pce_xref)</code> provides a
257216 graphical front-end for the cross-referencer described here. We
258217 demonstrate the tool on CHAT80, a natural language question and answer
259218 system by Fernando C.N. Pereira and David H.D. Warren.
260219
261220 <dl class="latex">
262 <dt class="pubdef"><a id="gxref/0"><strong>gxref</strong></a></dt>
221 <dt class="pubdef"><a name="gxref/0"><strong>gxref</strong></a></dt>
263222 <dd class="defbody">
264223 Run cross-referencer on all currently loaded files and present a
265224 graphical overview of the result. As the predicate operates on the
268227 </dd>
269228 </dl>
270229
271 <p><a id="fig:xrefchatfile"></a><div style="text-align:center"><img src="xrefchatfile.gif"></div>
230 <p><a name="fig:xrefchatfile"></a><div style="text-align:center"><img src="xrefchatfile.gif"></div>
272231 <div class="caption"><b>Figure 3 : </b>File info for <code>chattop.pl</code>,
273232 part of CHAT80</div>
274233
276235 3</a>) provides browsers for loaded files and predicates. To avoid long
277236 file paths, the file hierarchy has three main branches. The first is the
278237 current directory holding the sources. The second is marked <code>alias</code>,
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>
238 and below it are the file-search-path aliases (see <a name="idx:filesearchpath2:325"></a><a class="pred" href="consulting.html#file_search_path/2">file_search_path/2</a>
280239 and
281 <a id="idx:absolutefilename3:324"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>).
240 <a name="idx:absolutefilename3:326"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>).
282241 Here you find files loaded from the system as well as modules of the
283242 program loaded from other locations using the file search path. All
284243 loaded files that fall outside these categories are below the last
303262 file. Left-clicking opens a menu to open the definition or select one of
304263 the callers.
305264
306 <p><a id="fig:xrefchatdep"></a><div style="text-align:center"><img src="xrefchatdep.gif"></div>
265 <p><a name="fig:xrefchatdep"></a><div style="text-align:center"><img src="xrefchatdep.gif"></div>
307266 <div class="caption"><b>Figure 4 : </b>Dependencies between source files
308267 of CHAT80</div>
309268
11
22 <html>
33 <head>
4 <title>SWI-Prolog 7.7.4 Reference Manual: Section A.40</title><link rel="home" href="index.html">
4 <title>SWI-Prolog 7.6.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, 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; }
20 dt.pubdef
21 { background-color: #c5e1ff;
22 }
23
24 dt.multidef
25 { background-color: #c8ffc7;
26 }
3127
3228 .bib dd
3329 { margin-bottom: 1em;
121117 padding-top: 0.2em;
122118 font-size: 80%;
123119 font-style: italic;
124 color: #fff;
120 color: #202020;
125121 }
126122
127123 div.caption
131127 }
132128
133129 /* Footnotes */
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;
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;
155141 }
156142
157143 /* Lists */
195181 font-size: +1;
196182 margin-top: 1ex;
197183 }
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
225184 </style>
226185 </head>
227186 <body style="background:white">
232191 <a class="nav" href="varnumbers.html"><img src="prev.gif" alt="Previous"></a>
233192 <a class="nav" href="hack.html"><img src="next.gif" alt="Next"></a>
234193 </div>
235 <h2 id="sec:yall"><a id="sec:A.40"><span class="sec-nr">A.40</span> <span class="sec-title">library(yall):
194 <h2 id="sec:yall"><a name="sec:A.40"><span class="sec-nr">A.40</span> <span class="sec-title">library(yall):
236195 Lambda expressions</span></a></h2>
237196
238 <p><a id="sec:yall"></a>
197 <p><a name="sec:yall"></a>
239198
240199 <dl class="tags">
241200 <dt class="tag">author</dt>
323282 development of this module was sponsored by Kyndi, Inc.
324283
325284 <dl class="latex">
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,
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,
328287 +Lambda, ?A1</var>)</a></dt>
329 <dt class="pubdef"><a id=">>/4"><strong>&gt;&gt;</strong>(<var>+Parameters,
288 <dt class="pubdef"><a name=">>/4"><strong>&gt;&gt;</strong>(<var>+Parameters,
330289 +Lambda, ?A1, ?A2</var>)</a></dt>
331 <dt class="pubdef"><a id=">>/5"><strong>&gt;&gt;</strong>(<var>+Parameters,
290 <dt class="pubdef"><a name=">>/5"><strong>&gt;&gt;</strong>(<var>+Parameters,
332291 +Lambda, ?A1, ?A2, ?A3</var>)</a></dt>
333 <dt class="pubdef"><a id=">>/6"><strong>&gt;&gt;</strong>(<var>+Parameters,
292 <dt class="pubdef"><a name=">>/6"><strong>&gt;&gt;</strong>(<var>+Parameters,
334293 +Lambda, ?A1, ?A2, ?A3, ?A4</var>)</a></dt>
335 <dt class="pubdef"><a id=">>/7"><strong>&gt;&gt;</strong>(<var>+Parameters,
294 <dt class="pubdef"><a name=">>/7"><strong>&gt;&gt;</strong>(<var>+Parameters,
336295 +Lambda, ?A1, ?A2, ?A3, ?A4, ?A5</var>)</a></dt>
337 <dt class="pubdef"><a id=">>/8"><strong>&gt;&gt;</strong>(<var>+Parameters,
296 <dt class="pubdef"><a name=">>/8"><strong>&gt;&gt;</strong>(<var>+Parameters,
338297 +Lambda, ?A1, ?A2, ?A3, ?A4, ?A5, ?A6</var>)</a></dt>
339 <dt class="pubdef"><a id=">>/9"><strong>&gt;&gt;</strong>(<var>+Parameters,
298 <dt class="pubdef"><a name=">>/9"><strong>&gt;&gt;</strong>(<var>+Parameters,
340299 +Lambda, ?A1, ?A2, ?A3, ?A4, ?A5, ?A6, ?A7</var>)</a></dt>
341300 <dd class="defbody">
342301 Calls a copy of <var>Lambda</var>. This is similar to <code>call(Lambda,A1,...)</code>,
350309 <li>Possible excess arguments are passed by position.
351310 </ul>
352311 <table class="arglist">
353 <tr><td><var>Parameters</var> </td><td>is either a plain list of
354 parameters or a term
312 <tr valign="top"><td><var>Parameters</var> </td><td>is either a plain
313 list of parameters or a term
355314 <code>{Free}/List</code>. <var>Free</var> represents variables that are
356315 shared between the context and the <var>Lambda</var> term. This is
357316 needed for compiling <var>Lambda</var> expressions. </td></tr>
358317 </table>
359318 </dd>
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,
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,
362321 ?A1</var>)</a></dt>
363 <dt class="pubdef"><a id="//4"><strong>/</strong>(<var>+Free, :Lambda,
322 <dt class="pubdef"><a name="//4"><strong>/</strong>(<var>+Free, :Lambda,
364323 ?A1, ?A2</var>)</a></dt>
365 <dt class="pubdef"><a id="//5"><strong>/</strong>(<var>+Free, :Lambda,
324 <dt class="pubdef"><a name="//5"><strong>/</strong>(<var>+Free, :Lambda,
366325 ?A1, ?A2, ?A3</var>)</a></dt>
367 <dt class="pubdef"><a id="//6"><strong>/</strong>(<var>+Free, :Lambda,
326 <dt class="pubdef"><a name="//6"><strong>/</strong>(<var>+Free, :Lambda,
368327 ?A1, ?A2, ?A3, ?A4</var>)</a></dt>
369 <dt class="pubdef"><a id="//7"><strong>/</strong>(<var>+Free, :Lambda,
328 <dt class="pubdef"><a name="//7"><strong>/</strong>(<var>+Free, :Lambda,
370329 ?A1, ?A2, ?A3, ?A4, ?A5</var>)</a></dt>
371 <dt class="pubdef"><a id="//8"><strong>/</strong>(<var>+Free, :Lambda,
330 <dt class="pubdef"><a name="//8"><strong>/</strong>(<var>+Free, :Lambda,
372331 ?A1, ?A2, ?A3, ?A4, ?A5, ?A6</var>)</a></dt>
373 <dt class="pubdef"><a id="//9"><strong>/</strong>(<var>+Free, :Lambda,
332 <dt class="pubdef"><a name="//9"><strong>/</strong>(<var>+Free, :Lambda,
374333 ?A1, ?A2, ?A3, ?A4, ?A5, ?A6, ?A7</var>)</a></dt>
375334 <dd class="defbody">
376335 Shorthand for <code>Free/[]&gt;&gt;Lambda</code>. This is the same as
398357 </pre>
399358
400359 </dd>
401 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a id="is_lambda/1"><strong>is_lambda</strong>(<var>@Term</var>)</a></dt>
360 <dt class="pubdef"><span class="pred-tag">[semidet]</span><a name="is_lambda/1"><strong>is_lambda</strong>(<var>@Term</var>)</a></dt>
402361 <dd class="defbody">
403362 True if <var>Term</var> is a valid Lambda expression.</dd>
404 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="lambda_calls/2"><strong>lambda_calls</strong>(<var>+LambdaExpression,
363 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="lambda_calls/2"><strong>lambda_calls</strong>(<var>+LambdaExpression,
405364 -Goal</var>)</a></dt>
406 <dt class="pubdef"><span class="pred-tag">[det]</span><a id="lambda_calls/3"><strong>lambda_calls</strong>(<var>+LambdaExpression,
365 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="lambda_calls/3"><strong>lambda_calls</strong>(<var>+LambdaExpression,
407366 +ExtraArgs, -Goal</var>)</a></dt>
408367 <dd class="defbody">
409368 <var>Goal</var> is the goal called if call/N is applied to
11961196 an \jargon{atomic} update from the old file content to the
11971197 new.\footnote{This feature was implemented by Keri Harris.}
11981198
1199 \begin{description}
1200 \predicate{garbage_collect_clauses}{0}{}
1201 Reclaim retracted clauses. During normal operation, retracting a clause
1202 implies setting the \jargon{erased generation} to the current
1203 \jargon{generation} of the database and increment the generation.
1204 Keeping the clause around is both needed to realise the \jargon{logical
1205 update view} and deal with the fact that other threads may be executing
1206 the clause. Both static and dynamic code is processed this
1207 way.\footnote{Up to version 7.3.11, dynamic code was handled using
1208 \jargon{reference counts}.}.
1209
1210 The clause garbage collector (CGC) scans the environment stacks of all
1211 threads for referenced dirty predicates and at which generation this
1212 reference accesses the predicate. It then removes the references for
1213 clauses that have been retracted before the oldest access generation
1214 from the clause list as well as the secondary clauses indexes of the
1215 predicate. If the clause list is not being scanned, the clause
1216 references and ultimately the clause itself is reclaimed.
1217
1218 The clause garbage collector is called under three conditions, (1) after
1219 \jargon{reloading} a source file, (2) if the memory occupied by
1220 retracted but not yet reclaimed clauses exceeds 12.5\% of the program
1221 store, or (3) if skipping dead clauses in the clause lists becomes too
1222 costly. The cost of clause garbage collection is proportional with the
1223 total size of the local stack of all threads (the scanning phase) and
1224 the number of clauses in all `dirty' predicates (the reclaiming phase).
1225 \end{description}
1226
1227
12281199 \subsubsection{Compilation of mutually dependent code} \label{sec:depload}
12291200
12301201 Large programs are generally split into multiple files. If file $A$
27802751 Enumerate the currently defined signal handling. \arg{Name} is the
27812752 signal name, \arg{Id} is the numerical identifier and \arg{Handler}
27822753 is the currently defined handler (see on_signal/3).
2754
2755 \predicate{prolog_alert_signal}{2}{?Old, +New}
2756 Query or set the signal used to unblock blocking system calls on Unix
2757 systems and process pending Prolog signals. The default is
2758 \const{SIGUSR2}. See also \cmdlineoption{--sigalert}.
27832759 \end{description}
27842760
27852761
94179393 immediately. Note that there is no guarantee it will \emph{ever}
94189394 happen, as there may always be threads performing garbage collection.
94199395
9396 \predicate{garbage_collect_clauses}{0}{}
9397 Reclaim retracted clauses. During normal operation, retracting a clause
9398 implies setting the \jargon{erased generation} to the current
9399 \jargon{generation} of the database and increment the generation.
9400 Keeping the clause around is both needed to realise the \jargon{logical
9401 update view} and deal with the fact that other threads may be executing
9402 the clause. Both static and dynamic code is processed this
9403 way.\footnote{Up to version 7.3.11, dynamic code was handled using
9404 \jargon{reference counts}.}.
9405
9406 The clause garbage collector (CGC) scans the environment stacks of all
9407 threads for referenced dirty predicates and at which generation this
9408 reference accesses the predicate. It then removes the references for
9409 clauses that have been retracted before the oldest access generation
9410 from the clause list as well as the secondary clauses indexes of the
9411 predicate. If the clause list is not being scanned, the clause
9412 references and ultimately the clause itself is reclaimed.
9413
9414 The clause garbage collector is called under three conditions, (1) after
9415 \jargon{reloading} a source file, (2) if the memory occupied by
9416 retracted but not yet reclaimed clauses exceeds 12.5\% of the program
9417 store, or (3) if skipping dead clauses in the clause lists becomes too
9418 costly. The cost of clause garbage collection is proportional with the
9419 total size of the local stack of all threads (the scanning phase) and
9420 the number of clauses in all `dirty' predicates (the reclaiming phase).
9421
9422 \predicate{set_prolog_gc_thread}{+Status}
9423 Control whether or not atom and clause garbage collection are executed
9424 in a dedicated thread. The default is \const{true}. Values for
9425 \arg{Status} are \const{true}, \const{false} and \const{stop}. The
9426 latter stops the \const{gc} thread but allows is to be recreated lazily.
9427 This is use by e.g., fork/1 to avoid forking a multi-threaded
9428 application. See also \prologflag{gc_thread}.
9429
94209430 \predicate{trim_stacks}{0}{}
94219431 Release stack memory resources that are not in use at this moment,
94229432 returning them to the operating system. It can be used to release memory
94629472 amount is reported and specified in `cells'. A cell is 4 bytes in the
94639473 32-bit version and 8 bytes on the 64-bit version. See
94649474 \prologflag{address_bits}. See also trim_stacks/0 and debug/0.
9475
9476 \termitem{low}{+Cells}
9477 \nodescription
9478 \termitem{factor}{+Number}
9479 These two figures determine whether, if the stacks are low, a stack
9480 \jargon{shift} (expansion) or garbage collection is performed. This
9481 depends on these two parameters, the current stack usage and the amount
9482 of stack used after the last garbage collection. A garbage collection
9483 is started if $used > factor \times lastused + low$.
94659484
94669485 \termitem{spare}{+Cells}
94679486 All stacks trigger overflow before actually reaching the limit, so the
384384 ==
385385
386386 In this concrete case, the constraint solver is strong enough to find
387 the unique solution without any search.
387 the unique solution without any search. For the general case, see
388 [search](<#clpfd-search>).
388389
389390
390391 ## Residual goals {#clpfd-residual-goals}
444445 Using CLP(FD) constraints to solve combinatorial tasks typically
445446 consists of two phases:
446447
447 1. First, all relevant constraints are stated.
448 2. Second, if the domain of each involved variable is _finite_,
449 then _enumeration predicates_ can be used to search for
450 concrete solutions.
448 1. **Modeling**. In this phase, all relevant constraints are stated.
449 2. **Search**. In this phase, _enumeration predicates_ are used
450 to search for concrete solutions.
451451
452452 It is good practice to keep the modeling part, via a dedicated
453453 predicate called the *core relation*, separate from the actual
5858
5959 \newcommand{\vmajor}{7}
6060 \newcommand{\vminor}{6}
61 \newcommand{\vpatch}{3}
61 \newcommand{\vpatch}{4}
6262 \newcommand{\vtag}{}
63 \newcommand{\vmonth}{November}
64 \newcommand{\vyear}{2017}
63 \newcommand{\vmonth}{January}
64 \newcommand{\vyear}{2018}
6565
6666 #ifdef BOOK
6767 \newcommand{\versionshort}{\vmajor}
4242 \end{code}
4343
4444 After this point, Unix and Windows users unite, so if you are using
45 Unix please continue at \secref{execquery}.
45 Unix please continue at \secref{consultuser}.
4646
4747 \subsubsection{Starting SWI-Prolog on Windows}
4848 \label{sec:startwin}
378378 \prologflag{signals} to \const{false}. See \secref{sigembedded} for
379379 details. Note that the handler to unblock system calls is still
380380 installed. This can be prevented using \exam{--sigalert=0} additionally.
381 See \cmdlineoption{--sigalert}. This flag also sets
382 \prologflag{gc_thread} to \const{false} as synchronization with the
383 garbage collect thread is based on signals.
381 See \cmdlineoption{--sigalert}.
384382
385383 \cmdlineoptionitem{--pldoc}{[=port]}
386384 Start the PlDoc documentation system on a free network port and launch
394392 immediately when the target thread is blocked on an interruptable
395393 system call (e.g., sleep/1, read/write to most devices). The default is
396394 to use \const{SIGUSR2}. If \arg{NUM} is 0 (zero), this handler is not
397 installed.
395 installed. See prolog_alert_signal/2 to query or modify this value at
396 runtime.
398397
399398 \cmdlineoptionitem{-tty}{}
400399 Unix only. Switches controlling the terminal for allowing
14781477 garbage collection, nor stack shifts will take place, even not on
14791478 explicit request. May be changed.
14801479
1481 \prologflagitem{rc_thread}{bool}{rw}
1480 \prologflagitem{gc_thread}{bool}{r}
14821481 If \const{true} (default if threading is enabled), atom and
14831482 clause garbage collection are executed in a seperate thread with the
14841483 \jargon{alias} \const{gc}. Otherwise the thread the detect sufficient
14851484 garbage executes the garbage collector. As running these global
14861485 collectors may take relatively using a seperate thread improves
1487 real time behaviour.
1486 real time behaviour. The \const{gc} thread can be controlled using
1487 set_prolog_gc_thread/1.
14881488
14891489 \prologflagitem{generate_debug_info}{bool}{rw}
14901490 If \const{true} (default) generate code that can be debugged using
489489 \predicatesummary{profile_count}{3}{Obtain profile results on a predicate}
490490 \predicatesummary{profiler}{2}{Obtain/change status of the profiler}
491491 \predicatesummary{prolog}{0}{Run interactive top level}
492 \predicatesummary{prolog_alert_signal}{2}{Query/set unblock signal}
492493 \predicatesummary{prolog_choice_attribute}{3}{Examine the choice point stack}
493494 \predicatesummary{prolog_current_choice}{1}{Reference to most recent choice point}
494495 \predicatesummary{prolog_current_frame}{1}{Reference to goal's environment stack}
588589 \predicatesummary{set_output}{1}{Set current output stream from a stream}
589590 \predicatesummary{set_prolog_IO}{3}{Prepare streams for interactive session}
590591 \predicatesummary{set_prolog_flag}{2}{Define a system feature}
592 \predicatesummary{set_prolog_gc_thread}{1}{Control the gc thread}
591593 \predicatesummary{set_prolog_stack}{2}{Modify stack characteristics}
592594 \predicatesummary{set_random}{1}{Control random number generation}
593595 \predicatesummary{set_stream}{2}{Set stream attribute}
161161 Get the Prolog thread identifier of the running thread. If the thread
162162 has an alias, the alias name is returned.
163163
164 \predicate{thread_join}{2}{+Id}
164 \predicate{thread_join}{1}{+Id}
165165 Calls thread_join/2 and succeeds if thread \arg{Id} terminated with
166166 success. Otherwise the exception
167167 \term{error}{\term{thread_error}{Status}, _} is raised.
22 DOCTEX=$(TEXMF)/tex/latex/doc
33
44 install: install-fonts install-tex rehash
5
5
66 install-tex:
77 if [ ! -d $(DOCTEX) ]; then mkdir $(DOCTEX); fi
88 cp txt.sty rfc.sty i-d.sty $(DOCTEX)
1414 (cd $(DOCFONT) && ln doc.tfm docul.tfm)
1515
1616 rehash:
17 texconfig rehash
17 texhash
1111 { margin-bottom: 1em;
1212 }
1313
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; }
14 dt.pubdef
15 { background-color: #c5e1ff;
16 }
17
18 dt.multidef
19 { background-color: #c8ffc7;
20 }
2521
2622 .bib dd
2723 { margin-bottom: 1em;
115111 padding-top: 0.2em;
116112 font-size: 80%;
117113 font-style: italic;
118 color: #fff;
114 color: #202020;
119115 }
120116
121117 div.caption
125121 }
126122
127123 /* Footnotes */
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;
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;
149135 }
150136
151137 /* Lists */
189175 font-size: +1;
190176 margin-top: 1ex;
191177 }
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
219178 </style>
220179 </head>
221180 <body style="background:white">
230189 started using SWI-Prolog on MS-Windows. It also describes the components
231190 and issues that are specific to MS-Windows. It is by no means a manual
232191 or Prolog tutorial. The reference manual is available online or can be
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.
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.
236195 </div>
237196
238 <h1><a id="document-contents">Table of Contents</a></h1>
197 <h1><a name="document-contents">Table of Contents</a></h1>
239198
240199 <div class="toc">
241200 <div class="toc-h2"><a class="sec" href="#sec:1"><span class="sec-nr">1</span> <span class="sec-title">Using
280239 SWI-Prolog</span></a></div>
281240 </div>
282241
283 <h2><a id="sec:1"><span class="sec-nr">1</span> <span class="sec-title">Using
242 <h2><a name="sec:1"><span class="sec-nr">1</span> <span class="sec-title">Using
284243 SWI-Prolog</span></a></h2>
285244
286245 <p>
287246
288 <h3><a id="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Starting
247 <h3><a name="sec:1.1"><span class="sec-nr">1.1</span> <span class="sec-title">Starting
289248 Prolog and loading a program</span></a></h3>
290249
291250 <p>The SWI-Prolog executable <b>swipl-win.exe</b> can be started from
311270 <code>MyDocuments\Prolog</code>. This folder is created if it does not
312271 exist.
313272
314 <p><h3 id="sec:execquery"><a id="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Executing
273 <p><h3 id="sec:execquery"><a name="sec:1.2"><span class="sec-nr">1.2</span> <span class="sec-title">Executing
315274 a query</span></a></h3>
316275
317 <a id="sec:execquery"></a>
276 <a name="sec:execquery"></a>
318277
319278 <p>After loading a program, one can ask Prolog queries about the
320279 program. The query below asks Prolog what food `sam' likes. The system
343302 that, when executed, produces the same set of answers as the original
344303 program.
345304
346 <p><h3 id="sec:menu"><a id="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Menu
305 <p><h3 id="sec:menu"><a name="sec:1.3"><span class="sec-nr">1.3</span> <span class="sec-title">Menu
347306 commands</span></a></h3>
348307
349 <a id="sec:menu"></a>
308 <a name="sec:menu"></a>
350309
351310 <p>The SWI-Prolog console provided by <b>swipl-win.exe</b> has a menu
352311 for accessing the most commonly used commands. We assume not all menu
356315 <dt><b>File/Reload modified files</b></dt>
357316 <dd class="defbody">
358317 This menu reloads all loaded source files that have been modified using
359 the <a id="idx:make0:1"></a><a class="pred" href="#make/0">make/0</a>
318 the <a name="idx:make0:1"></a><a class="pred" href="#make/0">make/0</a>
360319 command described in <a class="sec" href="#sec:1.5">section 1.5</a>.</dd>
361320 <dt><b>File/Navigator ...</b></dt>
362321 <dd class="defbody">
408367 </dd>
409368 </dl>
410369
411 <p><h3 id="sec:edit"><a id="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Editing
370 <p><h3 id="sec:edit"><a name="sec:1.4"><span class="sec-nr">1.4</span> <span class="sec-title">Editing
412371 Prolog programs</span></a></h3>
413372
414 <a id="sec:edit"></a>
373 <a name="sec:edit"></a>
415374
416375 <p>There are three options for editing. One is to run an editor of
417 choice in a separate window and use the <a id="idx:make0:2"></a><a class="pred" href="#make/0">make/0</a>
376 choice in a separate window and use the <a name="idx:make0:2"></a><a class="pred" href="#make/0">make/0</a>
418377 command described below to reload modified files. In addition to this
419378 option Prolog can be used to locate predicates, modules and loaded files
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>
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>
421380 command, described below. This is achieved by editing the
422381 personalisation file (see <a class="sec" href="#sec:1.3">section 1.3</a>)
423382 and following the instructions in the comments.
431390 <a class="url" href="http://www.swi-prolog.org/IDE.html">http://www.swi-prolog.org/IDE.html</a>
432391 for an up-to-date overview.
433392
434 <p><h3 id="sec:commands"><a id="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Some
393 <p><h3 id="sec:commands"><a name="sec:1.5"><span class="sec-nr">1.5</span> <span class="sec-title">Some
435394 useful commands</span></a></h3>
436395
437 <a id="sec:commands"></a>
396 <a name="sec:commands"></a>
438397
439398 <p>This section provides a very brief overview of important or commonly
440399 used SWI-Prolog predicates to control the environment.
441400
442401 <dl class="latex">
443 <dt class="pubdef"><a id="consult/1"><strong>consult</strong>(<var>:File</var>)</a></dt>
402 <dt class="pubdef"><a name="consult/1"><strong>consult</strong>(<var>:File</var>)</a></dt>
444403 <dd class="defbody">
445404 Load a source file. On Windows, folders may be specified with the
446405 DOS/Windows <code><code>\</code></code>, which must be escaped, or by
451410 as well as the selected alternative) can be omitted. Here are some
452411 examples:
453412
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>
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>
458417 using absolute path. </td></tr>
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
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
460419 using Windows-style path name </td></tr>
461420 </table>
462421 </dd>
463 <dt class="pubdef"><a id="pwd/0"><strong>pwd</strong></a></dt>
422 <dt class="pubdef"><a name="pwd/0"><strong>pwd</strong></a></dt>
464423 <dd class="defbody">
465424 Print working directory (folder).</dd>
466 <dt class="pubdef"><a id="ls/0"><strong>ls</strong></a></dt>
425 <dt class="pubdef"><a name="ls/0"><strong>ls</strong></a></dt>
467426 <dd class="defbody">
468427 List files in current directory.</dd>
469 <dt class="pubdef"><a id="edit/0"><strong>edit</strong></a></dt>
428 <dt class="pubdef"><a name="edit/0"><strong>edit</strong></a></dt>
470429 <dd class="defbody">
471430 If Prolog is started by opening a <code>.pl</code> file in the explorer,
472431 edit this file. Also available from the menu.</dd>
473 <dt class="pubdef"><a id="edit/1"><strong>edit</strong>(<var>+Spec</var>)</a></dt>
432 <dt class="pubdef"><a name="edit/1"><strong>edit</strong>(<var>+Spec</var>)</a></dt>
474433 <dd class="defbody">
475434 Edit file, predicate, module, etc., with the given name. If multiple
476435 items are named <var>Spec</var> it prompts for the desired alternative.</dd>
477 <dt class="pubdef"><a id="make/0"><strong>make</strong></a></dt>
436 <dt class="pubdef"><a name="make/0"><strong>make</strong></a></dt>
478437 <dd class="defbody">
479438 Reload all files that have been changed since they were last loaded.
480439 Normally used after editing one or more files.</dd>
481 <dt class="pubdef"><a id="gtrace/0"><strong>gtrace</strong></a></dt>
440 <dt class="pubdef"><a name="gtrace/0"><strong>gtrace</strong></a></dt>
482441 <dd class="defbody">
483442 Start the graphical debugger. There are three ways to use this. Entered
484443 as a single goal at the top level, the next query will be traced.
494453 </pre>
495454
496455 </dd>
497 <dt class="pubdef"><a id="trace/0"><strong>trace</strong></a></dt>
456 <dt class="pubdef"><a name="trace/0"><strong>trace</strong></a></dt>
498457 <dd class="defbody">
499458 Same as gtrace, but text-based on the console.</dd>
500 <dt class="pubdef"><a id="apropos/1"><strong>apropos</strong>(<var>+Keyword</var>)</a></dt>
459 <dt class="pubdef"><a name="apropos/1"><strong>apropos</strong>(<var>+Keyword</var>)</a></dt>
501460 <dd class="defbody">
502461 Search for all predicates that contain <var>Keyword</var> in their name
503462 or short description. If a GUI environment is available the results are
504 hyperlinks. Otherwise use <a id="idx:help1:5"></a><a class="pred" href="#help/1">help/1</a>
463 hyperlinks. Otherwise use <a name="idx:help1:5"></a><a class="pred" href="#help/1">help/1</a>
505464 to get details on selected hits.</dd>
506 <dt class="pubdef"><a id="help/1"><strong>help</strong>(<var>+Spec</var>)</a></dt>
465 <dt class="pubdef"><a name="help/1"><strong>help</strong>(<var>+Spec</var>)</a></dt>
507466 <dd class="defbody">
508467 Give help on <var>Spec</var>, which is normally the name of a predicate
509468 or C interface function.
512471
513472 <p>
514473
515 <h2><a id="sec:2"><span class="sec-nr">2</span> <span class="sec-title">Using
474 <h2><a name="sec:2"><span class="sec-nr">2</span> <span class="sec-title">Using
516475 SWI-Prolog with C/C++</span></a></h2>
517476
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.
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.
522481
523482 <p>Details on how to interact with Prolog are in 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
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
528486 <code>SWI-cpp.h</code> C++ include file is available from the
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
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
536493 MSVC</span></a></h3>
537494
538495 <blockquote> Because the current versions of SWI-Prolog are compiled and
572529
573530 <p>To create an executable that does not rely on Prolog one must create
574531 a saved state of the required Prolog code and attach this to the
575 executable. Creating saved states is described with <a id="idx:qsaveprogram2:6"></a><span class="pred-ext">qsave_program/2</span>
532 executable. Creating saved states is described with <a name="idx:qsaveprogram2:6"></a><span class="pred-ext">qsave_program/2</span>
576533 in the reference manual. This can be attached to a state using the DOS
577534 command below to create <code>final.exe</code> from the executable
578535 produced by MSVC and the generated saved state.
583540
584541 <p>
585542
586 <h3><a id="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">Using
543 <h3><a name="sec:2.2"><span class="sec-nr">2.2</span> <span class="sec-title">Using
587544 swipl-ld.exe</span></a></h3>
588545
589546 <p>The <b>swipl-ld.exe</b> automates most of the above complications and
607564
608565 <p>
609566
610 <h2><a id="sec:3"><span class="sec-nr">3</span> <span class="sec-title">The
567 <h2><a name="sec:3"><span class="sec-nr">3</span> <span class="sec-title">The
611568 installation</span></a></h2>
612569
613 <p><h3 id="sec:winver"><a id="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">Supported
570 <p><h3 id="sec:winver"><a name="sec:3.1"><span class="sec-nr">3.1</span> <span class="sec-title">Supported
614571 Windows versions</span></a></h3>
615572
616 <a id="sec:winver"></a>
573 <a name="sec:winver"></a>
617574
618575 <p>SWI-Prolog requiring Windows XP or later (XP, Vista, Windows-7). The
619576 download site of SWI-Prolog contains older binaries that run on older
620577 versions of Windows. We provide both 32-bit and 64-bit installers.
621578
622 <p><h3 id="sec:ext"><a id="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Choosing
579 <p><h3 id="sec:ext"><a name="sec:3.2"><span class="sec-nr">3.2</span> <span class="sec-title">Choosing
623580 the file extension</span></a></h3>
624581
625 <a id="sec:ext"></a>
582 <a name="sec:ext"></a>
626583
627584 <p>By default, Prolog uses the <code>.pl</code> extension to indicate
628585 Prolog source files. Unfortunately this extension conflicts with the
637594
638595 <p>
639596
640 <h3><a id="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">Installed
597 <h3><a name="sec:3.3"><span class="sec-nr">3.3</span> <span class="sec-title">Installed
641598 programs</span></a></h3>
642599
643600 <p>The table below lists the installed components. Some components are
646603 of required libraries using different naming conventions. This will
647604 probably be synchronised in the future.
648605
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
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
652610 Windows application for interactive use. </td></tr>
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
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
657617 front-end to make single-file mixed Prolog/C/C++ executables. </td></tr>
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
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
670634 files</tr>
671 <tr class="hline"><td><code>boot32.prc</code> </td><td>Initial Prolog
635 <tbody>
636 <tr valign="top"><td><code>boot32.prc</code> </td><td>Initial Prolog
672637 state (32-bits) </td></tr>
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
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
650 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
656 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
669 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
677679 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
680 and POST arguments </td></tr>
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
687 interface </td></tr>
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
705 interface </td></tr>
680 <tr valign="top"><td><code>\bin\zlib4pl.dll</code> </td><td>Compression
681 library interface </td></tr>
706682 </table>
707683
708684 <p>
709685
710 <h3><a id="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Installed
686 <h3><a name="sec:3.4"><span class="sec-nr">3.4</span> <span class="sec-title">Installed
711687 Registry keys and menus</span></a></h3>
712688
713689 <p>The filetype <code>.pl</code> or chosen alternative (see <a class="sec" href="#sec:3.2">section
720696 <code>.pl</code> file can be associated with one of the installed Prolog
721697 versions only.
722698
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
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
726703 for Prolog files </td></tr>
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
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
733712 character units </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>
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>
739721 </table>
740722
741723 <p>
742724
743 <h3><a id="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">Execution
725 <h3><a name="sec:3.5"><span class="sec-nr">3.5</span> <span class="sec-title">Execution
744726 level</span></a></h3>
745727
746728 <p>The installer asks for the <code>admin</code> execution level (Vista
748730
749731 <p>
750732
751 <h3><a id="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">Creating
733 <h3><a name="sec:3.6"><span class="sec-nr">3.6</span> <span class="sec-title">Creating
752734 a desktop menu item</span></a></h3>
753735
754736 <p>If you want a desktop entry for SWI-Prolog, right-drag
758740
759741 <p>
760742
761 <h2><a id="sec:4"><span class="sec-nr">4</span> <span class="sec-title">The
743 <h2><a name="sec:4"><span class="sec-nr">4</span> <span class="sec-title">The
762744 SWI-Prolog community and foundation</span></a></h2>
763745
764746 <p>
765747
766 <h3><a id="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Website
748 <h3><a name="sec:4.1"><span class="sec-nr">4.1</span> <span class="sec-title">Website
767749 and mailing lists</span></a></h3>
768750
769751 <p>The SWI-Prolog website is located at <a class="url" href="http://www.swi-prolog.org/">http://www.swi-prolog.org/</a>.
770752
771753 <p>
772754
773 <h3><a id="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">About
755 <h3><a name="sec:4.2"><span class="sec-nr">4.2</span> <span class="sec-title">About
774756 license conditions</span></a></h3>
775757
776758 <p>The SWI-Prolog license allows it to be used in a wide variety of
796778
797779 <p>
798780
799 <h3><a id="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Supporting
781 <h3><a name="sec:4.3"><span class="sec-nr">4.3</span> <span class="sec-title">Supporting
800782 SWI-Prolog</span></a></h3>
801783
802784 <p>There are several ways to support SWI-Prolog:
821803 programmers.
822804 </ul>
823805
824 <h1><a id="document-index">Index</a></h1>
806 <h1><a name="document-index">Index</a></h1>
825807
826808 <dl>
827809 <dt class="index-sep">?</dt>
Binary diff not shown
270270 </pre>
271271
272272 <dl class="latex">
273 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="archive_open/3"><strong>archive_open</strong>(<var>+Data,
274 -Archive, +Options</var>)</a></dt>
275 <dd class="defbody">
276 Wrapper around <a class="pred" href="#archive_open/4">archive_open/4</a>
277 that opens the archive in read mode.</dd>
273278 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="archive_open/4"><strong>archive_open</strong>(<var>+Data,
274279 +Mode, -Archive, +Options</var>)</a></dt>
275280 <dd class="defbody">
546551 </dl>
547552
548553 <p>Non-archive files are handled as pseudo-archives that hold a single
549 stream. This is implemented by using <span class="pred-ext">archive_open/3</span>
554 stream. This is implemented by using <a class="pred" href="#archive_open/3">archive_open/3</a>
550555 with the options <code>[format(all),format(raw)]</code>.</dd>
551556 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="archive_create/3"><strong>archive_create</strong>(<var>+OutputFile,
552557 +InputFiles, +Options</var>)</a></dt>
598603 <dt><a class="idx" href="#archive_extract/3">archive_extract/3</a></dt>
599604 <dt><a class="idx" href="#archive_header_property/2">archive_header_property/2</a></dt>
600605 <dt><a class="idx" href="#archive_next_header/2">archive_next_header/2</a></dt>
606 <dt><a class="idx" href="#archive_open/3">archive_open/3</a></dt>
601607 <dt><a class="idx" href="#archive_open/4">archive_open/4</a></dt>
602608 <dt><a class="idx" href="#archive_open_entry/2">archive_open_entry/2</a></dt>
603609 <dt><a class="idx" href="#archive_property/2">archive_property/2</a></dt>
7171 */
7272
7373 :- use_foreign_library(foreign(archive4pl)).
74
75 %! archive_open(+Data, -Archive, +Options) is det.
76 %
77 % Wrapper around archive_open/4 that opens the archive in read mode.
7478
7579 archive_open(Stream, Archive, Options) :-
7680 archive_open(Stream, read, Archive, Options).
Binary diff not shown
525525 contain data.
526526
527527 \predicate{size_memory_file}{3}{+Handle, -Size, +Encoding}
528 Return the content-length of the memory-file it characters in the given
528 Return the content-length of the memory-file in characters in the given
529529 \arg{Encoding}. The file should be closed and contain data.
530530
531531 \predicate{atom_to_memory_file}{2}{+Atom, -Handle}
24522452 <dt class="pubdef"><a name="size_memory_file/3"><strong>size_memory_file</strong>(<var>+Handle,
24532453 -Size, +Encoding</var>)</a></dt>
24542454 <dd class="defbody">
2455 Return the content-length of the memory-file it characters in the given
2455 Return the content-length of the memory-file in characters in the given
24562456 <var>Encoding</var>. The file should be closed and contain data.</dd>
24572457 <dt class="pubdef"><a name="atom_to_memory_file/2"><strong>atom_to_memory_file</strong>(<var>+Atom,
24582458 -Handle</var>)</a></dt>
Binary diff not shown
269269 !PL_get_integer_ex(mode, &imode) )
270270 return FALSE;
271271
272 #ifdef __WINDOWS__
273 if ( _wchmod(name, imode) != 0 )
274 #else
272275 if ( chmod(name, imode) != 0 )
276 #endif
273277 return pl_error(NULL, 0, NULL, ERR_ERRNO, errno, "chmod", "file", mode);
274278
275279 return TRUE;
23242324 }
23252325 return -1;
23262326 }
2327 if ( n < len )
2328 { if ( PL_handle_signals() < 0 )
2329 { errno = EPLEXCEPTION;
2330 return -1;
2331 }
2332 }
23272333
23282334 len -= n;
23292335 str += n;
24652471 nbio_sendto(nbio_sock_t socket, void *buf, size_t bufSize, int flags,
24662472 const struct sockaddr *to, socklen_t tolen)
24672473 { plsocket *s;
2468 #ifdef __WINDOWS__
24692474 ssize_t n;
2470 #endif
24712475
24722476 if ( !(s = nbio_to_plsocket(socket)) )
24732477 return -1;
25092513
25102514 #else /*__WINDOWS__*/
25112515
2512 return sendto(s->socket, buf, bufSize, flags, to, tolen);
2516 for(;;)
2517 { n = sendto(s->socket, buf, bufSize, flags, to, tolen);
2518
2519 if ( n < 0 )
2520 { if ( need_retry(GET_ERRNO) )
2521 { if ( PL_handle_signals() < 0 )
2522 { errno = EPLEXCEPTION;
2523 return -1;
2524 }
2525 continue;
2526 }
2527 nbio_error(GET_ERRNO, TCP_ERRNO);
2528 return -1;
2529 }
2530 break;
2531 }
2532
2533 return n;
2534
25132535 #endif /*__WINDOWS__*/
25142536 }
6767 #include <malloc.h>
6868 #endif
6969
70 #ifdef __WINDOWS__
71 #define GET_ERRNO WSAGetLastError()
72 #define GET_H_ERRNO WSAGetLastError()
73 #else
74 #define GET_ERRNO errno
75 #define GET_H_ERRNO h_errno
76 #endif
77
7078 static atom_t ATOM_reuseaddr; /* "reuseaddr" */
7179 static atom_t ATOM_bindtodevice; /* "bindtodevice" */
7280 static atom_t ATOM_broadcast; /* "broadcast" */
154162
155163 return rc;
156164 } else
157 { return nbio_error(h_errno, TCP_HERRNO);
165 { return nbio_error(GET_H_ERRNO, TCP_HERRNO);
158166 }
159167 } else if ( nbio_get_ip(Ip, &ip) )
160168 { struct hostent *host;
162170 if ( (host = gethostbyaddr((char *)&ip, sizeof(ip), AF_INET)) )
163171 return PL_unify_atom_chars(Host, host->h_name);
164172 else
165 return nbio_error(h_errno, TCP_HERRNO);
173 return nbio_error(GET_H_ERRNO, TCP_HERRNO);
166174 }
167175
168176 return FALSE;
343351
344352 if ( (n=nbio_recvfrom(socket, buf, bufsize, flags,
345353 (struct sockaddr*)&sockaddr, &alen)) == -1 )
346 { rc = nbio_error(errno, TCP_ERRNO);
354 { rc = nbio_error(GET_ERRNO, TCP_ERRNO);;
347355 goto out;
348356 }
349357
384392 (int)dlen,
385393 flags,
386394 (struct sockaddr*)&sockaddr, alen)) == -1 )
387 return nbio_error(errno, TCP_ERRNO);
395 return nbio_error(GET_ERRNO, TCP_ERRNO);;
388396
389397 return TRUE;
390398 }
459467 #endif
460468
461469 if ( getsockname(fd, (struct sockaddr *) &addr, &len) )
462 return nbio_error(errno, TCP_ERRNO);
470 return nbio_error(GET_ERRNO, TCP_ERRNO);
463471 return PL_unify_integer(varport, ntohs(addr.sin_port));
464472 }
465473
509517 hname = PL_new_atom(buf);
510518
511519 } else
512 { return nbio_error(h_errno, TCP_HERRNO);
520 { return nbio_error(GET_H_ERRNO, TCP_HERRNO);
513521 }
514522 }
515523
658666
659667 switch(ret)
660668 { case -1:
661 return pl_error("tcp_select", 3, NULL, ERR_ERRNO, errno,
669 return pl_error("tcp_select", 3, NULL, ERR_ERRNO, GET_ERRNO,
662670 "select", "streams", Streams);
663671
664672 case 0: /* Timeout */
5858 close(In),
5959 atom_codes(Text, Codes).
6060
61 has_exe(Name) :-
62 process:exe_options(Options),
63 absolute_file_name(path(Name), _, [file_errors(fail)|Options]).
64
6165 :- begin_tests(process_create, [sto(rational_trees)]).
6266
63 test(echo, true) :-
67 test(echo, [condition(has_exe(true))]) :-
6468 process_create(path(true), [], []).
65 test(null_input, Codes == []) :-
69 test(null_input, [condition(has_exe(cat)), Codes == []]) :-
6670 process_create(path(cat), [], [stdin(null), stdout(pipe(Out))]),
6771 read_stream_to_codes(Out, Codes),
6872 close(Out).
69 test(null_output, true) :-
73 test(null_output, [condition(has_exe(sh))]) :-
7074 process_create(path(sh),
7175 ['-c', 'echo THIS IS AN ERROR'],
7276 [stdout(null)]).
73 test(null_error, true) :-
77 test(null_error, [condition(has_exe(sh))]) :-
7478 process_create(path(sh),
7579 ['-c', 'echo "THIS IS AN ERROR" 1>&2'],
7680 [stderr(null)]).
77 test(read_error, X == 'error\n') :-
81 test(read_error, [condition(has_exe(sh)),X == 'error\n']) :-
7882 process_create(path(sh),
7983 ['-c', 'echo "error" 1>&2'],
8084 [stderr(pipe(Out))]),
8185 read_process(Out, X).
82 test(echo, X == 'hello\n') :-
86 test(echo, [condition(has_exe(sh)), X == 'hello\n']) :-
8387 process_create(path(sh),
8488 ['-c', 'echo hello'],
8589 [ stdout(pipe(Out))
8690 ]),
8791 read_process(Out, X).
88 test(lwr, X == 'HELLO') :-
92 test(lwr, [condition(has_exe(tr)), X == 'HELLO']) :-
8993 process_create(path(tr), [hello, 'HELLO'], % a-z A-Z is non-portable
9094 [ stdin(pipe(In)),
9195 stdout(pipe(Out))
123127
124128 :- begin_tests(process_wait, [sto(rational_trees)]).
125129
126 test(wait_ok, X == exit(0)) :-
130 test(wait_ok, [condition(has_exe(sh)), X == exit(0)]) :-
127131 process_create(path(sh), ['-c', 'exit 0'], [process(PID)]),
128132 process_wait(PID, X).
129 test(wait_ok, X == exit(42)) :-
133 test(wait_ok, [condition(has_exe(sh)), X == exit(42)]) :-
130134 process_create(path(sh), ['-c', 'exit 42'], [process(PID)]),
131135 process_wait(PID, X).
132136 test(kill_ok, [ X == killed(9),
135139 process_kill(PID, 9),
136140 process_wait(PID, X).
137141 test(kill_ok, [ X = exit(_),
138 condition(current_prolog_flag(windows, true))]) :-
142 condition((current_prolog_flag(windows, true),
143 has_exe(sleep)))
144 ]) :-
139145 process_create(path(sleep), [2], [process(PID)]),
140146 process_kill(PID, 9),
141147 process_wait(PID, X).
146152 process_wait(PID, X),
147153 assertion(X == killed(15)),
148154 process_kill(PID).
149 test(wait_timeout, [ X = timeout ]) :-
155 test(wait_timeout, [ condition(has_exe(sleep)), X = timeout ]) :-
150156 process_create(path(sleep), [2], [process(PID)]),
151157 ( current_prolog_flag(windows, true)
152158 -> TMO = 0.1
188194
189195 /* See create_pipes() in process.c */
190196
191 test(concurr, true) :-
197 test(concurr, [condition(has_exe(cat))]) :-
192198 forall(between(1, 50, _),
193199 create_and_wait_once).
194200
9393 % See whether we are the only thread. If not, we cannot fork
9494
9595 fork_warn_threads :-
96 set_prolog_gc_thread(stop),
9697 findall(T, other_thread(T), Others),
9798 ( Others == []
9899 -> true
99 ; Others == [gc]
100 -> thread_signal(gc, abort),
101 thread_join(gc, _)
102100 ; throw(error(permission_error(fork, process, main),
103101 context(_, running_threads(Others))))
104102 ).
103
104 :- if(\+current_predicate(set_prolog_gc_thread/1)).
105 set_prolog_gc_thread(stop) :-
106 ( catch(thread_signal(gc, abort),
107 error(existence_error(thread, _), _),
108 fail)
109 -> thread_join(gc)
110 ; true
111 ).
112 :- endif.
105113
106114 other_thread(T) :-
107115 thread_self(Me),
1010 PL=@PL@
1111 PLBASE=@PLBASE@
1212 PKGDOC=$(PLBASE)/doc/packages
13 PCEHOME=../xpce
1413
15 DOCTOTEX=$(PCEHOME)/bin/doc2tex
16 PLTOTEX=$(PCEHOME)/bin/pl2tex
14 DOCTOTEX=../../man/doc2tex
1715 DOC=pl2cpp
1816 TEX=$(DOC).tex
1917 DVI=$(DOC).dvi
331331 </dd>
332332 <dt><a name="class:PlTermv"><strong>PlTermv</strong></a></dt>
333333 <dd class="defbody">
334 Vector of Prolog terms. See PL_new_term_refs(). the <code>[]</code>
334 Vector of Prolog terms. See <b>PL_new_term_refs()</b>. the <code>[]</code>
335335 operator is overloaded to access elements in this vector. <a class="" href="#class:PlTermv">PlTermv</a>
336336 is used to build complex terms and provide argument-lists to Prolog
337337 goals.
388388 </dd>
389389 <dt><a name="class:PlRegister"><strong>PlRegister</strong></a></dt>
390390 <dd class="defbody">
391 The encapsulation of PL_register_foreign() is defined to be able to use
392 C++ global constructors for registering foreign predicates.
391 The encapsulation of <b>PL_register_foreign()</b> is defined to be able
392 to use C++ global constructors for registering foreign predicates.
393393 </dd>
394394 </dl>
395395
419419 </pre>
420420
421421 <p>The arguments to PREDICATE() are the name and arity of the predicate.
422 The macros A&lt;<var>n</var>&gt; provide access to the predicate
423 arguments by position and are of the type <a class="" href="#class:PlTerm">PlTerm</a>.
422 The macros A&lt;n&gt; provide access to the predicate arguments by
423 position and are of the type <a class="" href="#class:PlTerm">PlTerm</a>.
424424 Casting a <a class="" href="#class:PlTerm">PlTerm</a> to a
425425 <code>char *</code> or <code>wchar_t *</code> provides the natural
426426 type-conversion for most Prolog data-types, using the output of <a name="idx:write1:3"></a><span class="pred-ext">write/1</span>
453453 </pre>
454454
455455 <p>Casting a <a class="" href="#class:PlTerm">PlTerm</a> to a <code>long</code>
456 performs a PL_get_long() and throws a C++ exception if the Prolog
456 performs a <b>PL_get_long()</b> and throws a C++ exception if the Prolog
457457 argument is not a Prolog integer or float that can be converted without
458458 loss to a <code>long</code>. The
459 <code>=</code> operator of <a class="" href="#class:PlTerm">PlTerm</a>
459 <code><code>=</code></code> operator of <a class="" href="#class:PlTerm">PlTerm</a>
460460 is defined to perform unification and returns <code>TRUE</code> or <code>FALSE</code>
461461 depending on the result.
462462
605605 <dt><strong>PlTerm ::operator wchar_t *</strong>(<var>void</var>)</dt>
606606 <dt><strong>PlTerm ::operator char *</strong>(<var>void</var>)</dt>
607607 <dd class="defbody">
608 Converts the Prolog argument using PL_get_chars() using the flags
608 Converts the Prolog argument using <b>PL_get_chars()</b> using the flags
609609 <code>CVT_ALL|CVT_WRITE|BUF_RING</code>, which implies Prolog atoms and
610610 strings are converted to the represented text. All other data is handed
611611 to <a name="idx:write1:6"></a><span class="pred-ext">write/1</span>. If
628628 <dt class="pubdef"><a name="PlTerm::operator=()"><var>int</var> <strong>PlTerm::operator
629629 =</strong>(<var>Type</var>)</a></dt>
630630 <dd class="defbody">
631 The operator <code>=</code> is defined for the <var>Types</var> <a class="" href="#class:PlTerm">PlTerm</a>,
631 The operator <code><code>=</code></code> is defined for the <var>Types</var> <a class="" href="#class:PlTerm">PlTerm</a>,
632632 <code>long</code>, <code>double</code>, <code>char *</code>, <code>wchar_t*</code>
633633 and
634634 <a class="" href="#class:PlAtom">PlAtom</a>. It performs Prolog
778778 <dl class="latex">
779779 <dt class="pubdef"><a name="PlTerm::type()"><var>int</var> <strong>PlTerm::type</strong>(<var></var>)</a></dt>
780780 <dd class="defbody">
781 Yields the actual type of the term as PL_term_type(). Return values are
781 Yields the actual type of the term as <b>PL_term_type()</b>. Return
782 values are
782783 <code>PL_VARIABLE</code>, <code>PL_FLOAT</code>, <code>PL_INTEGER</code>,
783784 <code>PL_ATOM</code>, <code>PL_STRING</code> or <code>PL_TERM</code>
784785 </dd>
859860 the <var>text</var>. If the <var>text</var> is not valid Prolog syntax,
860861 a <code>syntax_error</code> exception is raised. Otherwise a new
861862 term-reference holding the parsed text is created.</dd>
863 <dt><strong>PlCompound :: PlCompound</strong>(<var>const wchar_t *name,
864 size_t arity</var>)</dt>
865 <dt><strong>PlCompound :: PlCompound</strong>(<var>const char *name,
866 size_t arity</var>)</dt>
867 <dd class="defbody">
868 Create a term with the given name and arity and unbound (variable)
869 arguments. If <var>arity</var> equals 0 (zero), a compound with arity 0
870 is created, e.g., <code>a()</code>.</dd>
862871 <dt><strong>PlCompound :: PlCompound</strong>(<var>const wchar_t
863872 *functor, PlTermv args</var>)</dt>
864873 <dt><strong>PlCompound :: PlCompound</strong>(<var>const char *functor,
11261135
11271136 <a name="sec:cpp-plregister"></a>
11281137
1129 <p>This class encapsulates PL_register_foreign(). It is defined as a
1130 class rather then a function to exploit the C++ <em>global constructor</em>
1131 feature. This class provides a constructor to deal with the PREDICATE()
1132 way of defining foreign predicates as well as constructors to deal with
1133 more conventional foreign predicate definitions.
1138 <p>This class encapsulates <b>PL_register_foreign()</b>. It is defined
1139 as a class rather then a function to exploit the C++ <em>global
1140 constructor</em> feature. This class provides a constructor to deal with
1141 the PREDICATE() way of defining foreign predicates as well as
1142 constructors to deal with more conventional foreign predicate
1143 definitions.
11341144
11351145 <dl class="latex">
11361146 <dt><strong>PlRegister :: PlRegister</strong>(<var>const char *module,
11411151 &lt;<var>name</var>&gt;/&lt;<var>arity</var>&gt;. This interface uses
11421152 the <code>PL_FA_VARARGS</code> calling convention, where the argument
11431153 list of the predicate is passed using an array of <code>term_t</code>
1144 objects as returned by PL_new_term_refs(). This interface poses no
1145 limits on the arity of the predicate and is faster, especially for a
1154 objects as returned by <b>PL_new_term_refs()</b>. This interface poses
1155 no limits on the arity of the predicate and is faster, especially for a
11461156 large number of arguments.
11471157 </dd>
11481158 <dt><strong>PlRegister :: PlRegister</strong>(<var>const char *module,
14701480 </dd>
14711481 <dt class="pubdef"><a name="plThrow()"><var>int</var> <strong>plThrow</strong>(<var></var>)</a></dt>
14721482 <dd class="defbody">
1473 Used in the PREDICATE() wrapper to pass the exception to Prolog. See
1474 PL_raise_exeption().
1483 Used in the PREDICATE() wrapper to pass the exception to Prolog. See
1484 <b>PL_raise_exeption()</b>.
14751485 </dd>
14761486 <dt class="pubdef"><a name="cppThrow()"><var>int</var> <strong>cppThrow</strong>(<var></var>)</a></dt>
14771487 <dd class="defbody">
15701580 <dd class="defbody">
15711581 Initialises the Prolog engine. The application should make sure to pass <code>argv[0]</code>
15721582 from its main function, which is needed in the Unix version to find the
1573 running executable. See PL_initialise() for details.
1583 running executable. See <b>PL_initialise()</b> for details.
15741584 </dd>
15751585 <dt><strong>PlEngine :: PlEngine</strong>(<var>char *argv0</var>)</dt>
15761586 <dd class="defbody">
15791589 </dd>
15801590 <dt><strong>~ PlEngine</strong>(<var></var>)</dt>
15811591 <dd class="defbody">
1582 Calls PL_cleanup() to destroy all data created by the Prolog engine.
1592 Calls <b>PL_cleanup()</b> to destroy all data created by the Prolog
1593 engine.
15831594 </dd>
15841595 </dl>
15851596
Binary diff not shown
Binary diff not shown
373373 Succeeds if value is an atom of more than $N$ characters.
374374
375375 \definition{length $>= N$}
376 Succeeds if value is an atom of more or than equal to $N$ characters.
376 Succeeds if value is an atom of more than or equal to $N$ characters.
377377
378378 \definition{length $< N$}
379379 Succeeds if value is an atom of less than $N$ characters.
380380
381381 \definition{length $=< N$}
382 Succeeds if value is an atom of length than or equal to $N$ characters.
382 Succeeds if value is an atom of length less than or equal to $N$ characters.
383383
384384 \termitem{atom}{}
385385 No-op. Allowed for consistency.
29442944 Succeeds if value is an atom of more than <var>N</var> characters.</dd>
29452945 <dt><b>length <var>&gt;= N</var></b></dt>
29462946 <dd class="defbody">
2947 Succeeds if value is an atom of more or than equal to <var>N</var>
2947 Succeeds if value is an atom of more than or equal to <var>N</var>
29482948 characters.</dd>
29492949 <dt><b>length <var>&lt; N</var></b></dt>
29502950 <dd class="defbody">
29512951 Succeeds if value is an atom of less than <var>N</var> characters.</dd>
29522952 <dt><b>length <var>=&lt; N</var></b></dt>
29532953 <dd class="defbody">
2954 Succeeds if value is an atom of length than or equal to <var>N</var>
2954 Succeeds if value is an atom of length less than or equal to <var>N</var>
29552955 characters.</dd>
29562956 <dt><strong>atom</strong></dt>
29572957 <dd class="defbody">
Binary diff not shown
5757 { IOSTREAM *stream; /* Original stream */
5858 IOSTREAM *chunked_stream; /* Stream I'm handle of */
5959 int close_parent; /* close parent on close */
60 int eof_seen; /* We saw end-of-file */
6061 IOENC parent_encoding; /* Saved encoding of parent */
6162 size_t avail; /* data available */
6263 } chunked_context;
9293 static ssize_t /* decode */
9394 chunked_read(void *handle, char *buf, size_t size)
9495 { chunked_context *ctx = handle;
96
97 if ( ctx->eof_seen )
98 return 0;
9599
96100 for(;;)
97101 { if ( ctx->avail > 0 ) /* data waiting */
136140 { s = Sfgets(hdr, sizeof(hdr), ctx->stream);
137141 } while ( s && strcmp(s, "\r\n") != 0 );
138142 if ( s )
143 { ctx->eof_seen = TRUE;
139144 return 0;
145 }
140146 Sseterr(ctx->chunked_stream, 0, "Bad end-of-stream");
141147 return -1;
142148 }
119119 http_parameters(Request, Params, Options) :-
120120 must_be(list, Params),
121121 meta_options(is_meta, Options, QOptions),
122 option(attribute_declarations(DeclGoal), QOptions, -),
122 option(attribute_declarations(DeclGoal), QOptions, no_decl_goal),
123123 http_parms(Request, Params, DeclGoal, Form),
124124 ( memberchk(form_data(RForm), QOptions)
125125 -> RForm = Form
178178 %! fill_parameters(+ParamDecls, +FormData, +DeclGoal)
179179 %
180180 % Fill values from the parameter list
181
182 :- meta_predicate fill_parameters(+, +, 2).
181183
182184 fill_parameters([], _, _).
183185 fill_parameters([H|T], FormData, DeclGoal) :-
248250 % ==
249251
250252 http_convert_parameters(Data, ParamDecls) :-
251 fill_parameters(ParamDecls, Data, -).
253 fill_parameters(ParamDecls, Data, no_decl_goal).
252254 http_convert_parameters(Data, ParamDecls, DeclGoal) :-
253255 fill_parameters(ParamDecls, Data, DeclGoal).
256
257 no_decl_goal(_,_) :- fail.
254258
255259 %! http_convert_parameter(+Options, +FieldName, +ValueIn, -ValueOut) is det.
256260 %
852852
853853 pengine_property(Id, Prop) :-
854854 nonvar(Id), nonvar(Prop),
855 current_module(Id),
856855 pengine_property2(Id, Prop),
857856 !.
858857 pengine_property(Id, Prop) :-
12041203 State = count(Chunk),
12051204 statistics(cputime, Epoch),
12061205 Time = time(Epoch),
1207 ( call_cleanup(catch(findnsols_no_empty(State, Template, Goal, Result),
1206 nb_current('$variable_names', Bindings),
1207 ( call_cleanup(catch(findnsols_no_empty(State, Template,
1208 set_projection(Goal, Bindings),
1209 Result),
12081210 Error, true),
12091211 Det = true),
12101212 arg(1, Time, T0),
12331235 destroy_or_continue(failure(ID, CPUTime))
12341236 ).
12351237 solve(_, _, _, _). % leave a choice point
1238
1239 %! set_projection(:Goal, +Bindings)
1240 %
1241 % findnsols/4 copies its goal and template to avoid instantiation
1242 % thereof when it stops after finding N solutions. Using this helper
1243 % we can a renamed version of Bindings that we can set.
1244
1245 set_projection(Goal, Bindings) :-
1246 b_setval('$variable_names', Bindings),
1247 call(Goal).
12361248
12371249 projection(Projection) :-
12381250 nb_current('$variable_names', Bindings),
26292641 add_error_details(ErrorTerm, Error0, Error),
26302642 message_to_string(ErrorTerm, Message).
26312643 event_term_to_json_data(failure(ID, Time),
2632 json{event:failure, id:ID, time:Time}, _).
2644 json{event:failure, id:ID, time:Time}, _) :-
2645 !.
26332646 event_term_to_json_data(EventTerm, json{event:F, id:ID}, _) :-
26342647 functor(EventTerm, F, 1),
26352648 !,
Binary diff not shown
Binary diff not shown
995995 % Converted to true^^xsd:boolean
996996 % - false
997997 % Converted to false^^xsd:boolean
998 % - date(Y,M,D)
999 % Converted to date(Y,M,D)^^xsd:date
1000 % - date_time(Y,M,D,HH,MM,SS)
1001 % Converted to date_time(Y,M,D,HH,MM,SS)^^xsd:dateTime
1002 % - date_time(Y,M,D,HH,MM,SS,TZ)
1003 % Converted to date_time(Y,M,D,HH,MM,SS,TZ)^^xsd:dateTime
1004 % - month_day(M,D)
1005 % Converted to month_day(M,D)^^xsd:gMonthDay
1006 % - year_month(Y,M)
1007 % Converted to year_month(Y,M)^^xsd:gYearMonth
1008 % - time(HH,MM,SS)
1009 % Converted to time(HH,MM,SS)^^xsd:time
9981010 % - Text@Lang
9991011 % Converted to Text@Lang. Uses canonical (lowercase) lang.
10001012 % Text is converted into an atom.
10111023 :- rdf_meta
10121024 pre_ground_object(+, o).
10131025
1026 % Interpret Prolog integer as xsd:integer.
10141027 pre_ground_object(Int, Object) :-
10151028 integer(Int),
10161029 !,
10171030 rdf_equal(Object, literal(type(xsd:integer, Atom))),
10181031 atom_number(Atom, Int).
1032 % Interpret Prolog floating-point value as xsd:double.
10191033 pre_ground_object(Float, Object) :-
10201034 float(Float),
10211035 !,
10221036 rdf_equal(Object, literal(type(xsd:double, Atom))),
10231037 xsd_number_string(Float, String),
10241038 atom_string(Atom, String).
1039 % Interpret SWI string as xsd:string.
10251040 pre_ground_object(String, Object) :-
10261041 string(String),
10271042 !,
10281043 rdf_equal(Object, literal(type(xsd:string, Atom))),
10291044 atom_string(Atom, String).
1045 % Interpret `false' and `true' as the Boolean values.
10301046 pre_ground_object(false, literal(type(xsd:boolean, false))) :- !.
10311047 pre_ground_object(true, literal(type(xsd:boolean, true))) :- !.
1048 % Interpret date(Y,M,D) as xsd:date,
1049 % date_time(Y,M,D,HH,MM,SS) as xsd:dateTime,
1050 % date_time(Y,M,D,HH,MM,SS,TZ) as xsd:dateTime,
1051 % month_day(M,D) as xsd:gMonthDay,
1052 % year_month(Y,M) as xsd:gYearMonth, and
1053 % time(HH,MM,SS) as xsd:time.
1054 pre_ground_object(Term, literal(type(Type, Atom))) :-
1055 xsd_date_time_term(Term),
1056 !,
1057 xsd_time_string(Term, Type, Atom).
10321058 pre_ground_object(Val@Lang, literal(lang(Lang0, Val0))) :-
10331059 !,
10341060 downcase_atom(Lang, Lang0),
10481074 !.
10491075 pre_ground_object(Value, _) :-
10501076 type_error(rdf_object, Value).
1077
1078 xsd_date_time_term(date(_,_,_)).
1079 xsd_date_time_term(date_time(_,_,_,_,_,_)).
1080 xsd_date_time_term(date_time(_,_,_,_,_,_,_)).
1081 xsd_date_time_term(month_day(_,_)).
1082 xsd_date_time_term(year_month(_,_)).
1083 xsd_date_time_term(time(_,_,_)).
10511084
10521085 old_literal(Lit0, Lit) :-
10531086 old_literal(Lit0),
266266
267267 %! rdfs_member0(?Container, ?N, ?Elem) is nondet.
268268 %
269 % What is the most efficient way to enumerate
270 % `rdfs_member(-,-)`?
271 %
272 % 1. If we enumerate over all container membership properties (=
273 % the current implementation) then it takes N steps before we
274 % get to triple `〈Container, rdf:_N, Elem〉`, for arbitrary
275 % N.
276 %
277 % 2. The alternative is to enumerate over all triples and check
269 % What is the most efficient way to enumerate rdfs_member(-,-)?
270 %
271 % 1. If we enumerate over all container membership properties (= the
272 % current implementation) then it takes N steps before we get to
273 % triple `<Container, rdf:_N, Elem>`, for arbitrary N.
274 %
275 % 2. The alternative is to enumerate over all triples and check
278276 % whether the predicate term is a container membership property.
279277 %
280 % 3. The choice between (1) and (2) depends on whether the
281 % number of currently loaded triples in larger/smaller than the
282 % largest number that appears in a container membership
283 % property. This means enumerating over all predicate terms
284 % using rdf_predicate/1.
278 % 3. The choice between (1) and (2) depends on whether the number of
279 % currently loaded triples in larger/smaller than the largest number
280 % that appears in a container membership property. This means
281 % enumerating over all predicate terms using rdf_predicate/1.
285282
286283 rdfs_member0(Container, N, Elem) :-
287284 (nonvar(Container) ; nonvar(Elem)),
27512751
27522752 rdf_do_save(Out, Options0) :-
27532753 rdf_save_header(Out, Options0, Options),
2754 graph(Options, DB),
27542755 ( option(sorted(true), Options, false)
2755 -> setof(Subject, rdf_subject(Subject, Options), Subjects),
2756 -> ( var(DB)
2757 -> setof(Subject, rdf_subject(Subject), Subjects)
2758 ; findall(Subject, rdf(Subject, _, _, DB:_), SubjectList),
2759 sort(SubjectList, Subjects)
2760 ),
27562761 forall(member(Subject, Subjects),
27572762 rdf_save_non_anon_subject(Out, Subject, Options))
2758 ; forall(rdf_subject(Subject, Options),
2763 ; forall(rdf_subject_in_graph(Subject, DB),
27592764 rdf_save_non_anon_subject(Out, Subject, Options))
27602765 ),
27612766 rdf_save_footer(Out),
2762 !. % dubious cut; without the
2767 !. % dubious cut; without the
27632768 % cleanup handlers isn't called!?
27642769
2765 rdf_subject(Subject, Options) :-
2766 graph(Options, DB),
2770 %! rdf_subject_in_graph(-Subject, ?DB) is nondet.
2771 %
2772 % True when Subject is a subject in the graph DB. If DB is unbound,
2773 % all subjects are enumerated. Otherwise we have two options:
2774 % enumerate all subjects and filter by graph or collect all triples of
2775 % the graph and get the unique subjects. The first is attractive if
2776 % the graph is big compared to the DB, also because it does not
2777 % require memory, the second if the graph is small compared to the DB.
2778
2779 rdf_subject_in_graph(Subject, DB) :-
27672780 var(DB),
27682781 !,
27692782 rdf_subject(Subject).
2770 rdf_subject(Subject, Options) :-
2771 graph(Options, DB),
2772 rdf_subject(Subject),
2783 rdf_subject_in_graph(Subject, DB) :-
2784 rdf_statistics(triples(AllTriples)),
2785 rdf_graph_property(DB, triples(DBTriples)),
2786 DBTriples > AllTriples // 10,
2787 !,
2788 rdf_resource(Subject),
27732789 ( rdf(Subject, _, _, DB:_)
27742790 -> true
27752791 ).
2792 rdf_subject_in_graph(Subject, DB) :-
2793 findall(Subject, rdf(Subject, _, _, DB:_), SubjectList),
2794 list_to_set(SubjectList, Subjects),
2795 member(Subject, Subjects).
2796
27762797
27772798 graph(Options0, DB) :-
27782799 strip_module(Options0, _, Options),
27802801 -> DB = DB0
27812802 ; memberchk(db(DB0), Options)
27822803 -> DB = DB0
2783 ; true % leave unbound
2804 ; true % leave unbound
27842805 ).
27852806
27862807
150150 :- meta_predicate
151151 rdf_save_turtle(+, :),
152152 rdf_save_canonical_turtle(+, :),
153 rdf_save_canonical_trig(+, :),
153154 rdf_save_trig(+, :).
154155
155156 %! rdf_save_turtle(+Out, :Options) is det.
37113711 +Stream, :Options</var>)</a></dt>
37123712 <dd class="defbody">
37133713 (Turtle clauses)</dd>
3714 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="rdf_save_turtle/2"><strong>rdf_save_turtle</strong>(<var>+Out,
3715 :Options</var>)</a></dt>
3716 <dd class="defbody">
3717 Save an RDF graph as Turtle. <var>Options</var> processed are:
3718
3719 <dl class="latex">
3720 <dt><strong>a</strong>(<var>+Boolean</var>)</dt>
3721 <dd class="defbody">
3722 If <code>true</code> (default), use <code>a</code> for the predicate <code>rdf:type</code>.
3723 Otherwise use the full resource.
3724 </dd>
3725 <dt><strong>align_prefixes</strong>(<var>+Boolean</var>)</dt>
3726 <dd class="defbody">
3727 Nicely align the @prefix declarations
3728 </dd>
3729 <dt><strong>base</strong>(<var>+Base</var>)</dt>
3730 <dd class="defbody">
3731 Save relative to the given <var>Base</var>
3732 </dd>
3733 <dt><strong>canonize_numbers</strong>(<var>+Boolean</var>)</dt>
3734 <dd class="defbody">
3735 If <code>true</code> (default <code>false</code>), emit numeric
3736 datatypes using Prolog's write to achieve canonical output.
3737 </dd>
3738 <dt><strong>comment</strong>(<var>+Boolean</var>)</dt>
3739 <dd class="defbody">
3740 It <code>true</code> (default), write some informative comments between
3741 the output segments
3742 </dd>
3743 <dt><strong>encoding</strong>(<var>+Encoding</var>)</dt>
3744 <dd class="defbody">
3745 <var>Encoding</var> used for the output stream. Default is UTF-8.
3746 </dd>
3747 <dt><strong>expand</strong>(<var>:Goal</var>)</dt>
3748 <dd class="defbody">
3749 Query an alternative graph-representation. See below.
3750 </dd>
3751 <dt><strong>indent</strong>(<var>+Column</var>)</dt>
3752 <dd class="defbody">
3753 Indentation for ; -lists. `0' does not indent, but writes on the same
3754 line. Default is 8.
3755 </dd>
3756 <dt><strong>graph</strong>(<var>+Graph</var>)</dt>
3757 <dd class="defbody">
3758 Save only the named graph
3759 </dd>
3760 <dt><strong>group</strong>(<var>+Boolean</var>)</dt>
3761 <dd class="defbody">
3762 If <code>true</code> (default), using P-O and O-grouping.
3763 </dd>
3764 <dt><strong>inline_bnodes</strong>(<var>+Boolean</var>)</dt>
3765 <dd class="defbody">
3766 if <code>true</code> (default), inline bnodes that are used once.
3767 </dd>
3768 <dt><strong>abbreviate_literals</strong>(<var>+Boolean</var>)</dt>
3769 <dd class="defbody">
3770 if <code>true</code> (default), omit the type if allowed by turtle.
3771 </dd>
3772 <dt><strong>only_known_prefixes</strong>(<var>+Boolean</var>)</dt>
3773 <dd class="defbody">
3774 Only use prefix notation for known prefixes. Without, some documents
3775 produce <i>huge</i> amounts of prefixes.
3776 </dd>
3777 <dt><strong>prefixes</strong>(<var>+List</var>)</dt>
3778 <dd class="defbody">
3779 If provided, uses exactly these prefixes. <var>List</var> is a list of
3780 prefix specifications, where each specification is either a term <i>Prefix_-_URI</i>
3781 or a prefix that is known to
3782 <a class="pred" href="#rdf_current_prefix/2">rdf_current_prefix/2</a>.
3783 </dd>
3784 <dt><strong>silent</strong>(<var>+Boolean</var>)</dt>
3785 <dd class="defbody">
3786 If <code>true</code> (default <code>false</code>), do not print the
3787 final informational message.
3788 </dd>
3789 <dt><strong>single_line_bnodes</strong>(<var>+Bool</var>)</dt>
3790 <dd class="defbody">
3791 If <code>true</code> (default <code>false</code>), write [...] and (...)
3792 on a single line.
3793 </dd>
3794 <dt><strong>subject_white_lines</strong>(<var>+Count</var>)</dt>
3795 <dd class="defbody">
3796 Extra white lines to insert between statements about a different
3797 subject. Default is 1.
3798 </dd>
3799 <dt><strong>tab_distance</strong>(<var>+Tab</var>)</dt>
3800 <dd class="defbody">
3801 Distance between tab-stops. `0' forces the library to use only spaces
3802 for layout. Default is 8.
3803 </dd>
3804 <dt><strong>user_prefixes</strong>(<var>+Boolean</var>)</dt>
3805 <dd class="defbody">
3806 If <code>true</code> (default), use prefixes from <a class="pred" href="#rdf_current_prefix/2">rdf_current_prefix/2</a>.
3807 </dd>
3808 </dl>
3809
3810 <p>The option <code>expand</code> allows for serializing alternative
3811 graph representations. It is called through <span class="pred-ext">call/5</span>,
3812 where the first argument is the expand-option, followed by S,P,O,G. G is
3813 the graph-option (which is by default a variable). This notably allows
3814 for writing RDF graphs represented as <code>rdf(S,P,O)</code> using the
3815 following code fragment:
3816
3817 <pre class="code">
3818 triple_in(RDF, S,P,O,_G) :-
3819 member(rdf(S,P,O), RDF).
3820
3821 ...,
3822 rdf_save_turtle(Out, [ expand(triple_in(RDF)) ]),
3823 </pre>
3824
3825 <table class="arglist">
3826 <tr valign="top"><td><var>Out</var> </td><td>is one of <code>stream(Stream)</code>,
3827 a stream handle, a file-URL or an atom that denotes a filename. </td></tr>
3828 </table>
3829 </dd>
3830 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="rdf_save_ntriples/2"><strong>rdf_save_ntriples</strong>(<var>+Spec,
3831 :Options</var>)</a></dt>
3832 <dd class="defbody">
3833 Save RDF using ntriples format. The ntriples format is a subset of
3834 Turtle, writing each triple fully qualified on its own line.</dd>
3835 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="rdf_save_canonical_trig/2"><strong>rdf_save_canonical_trig</strong>(<var>+Spec,
3836 :Options</var>)</a></dt>
3837 <dd class="defbody">
3838 Save triples in a canonical format. See
3839 <a class="pred" href="#rdf_save_canonical_turtle/2">rdf_save_canonical_turtle/2</a>
3840 foir details.</dd>
38413714 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="rdf_save_trig/2"><strong>rdf_save_trig</strong>(<var>+Spec,
38423715 :Options</var>)</a></dt>
38433716 <dd class="defbody">
38833756 </dd>
38843757 </dl>
38853758
3759 </dd>
3760 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="rdf_save_turtle/2"><strong>rdf_save_turtle</strong>(<var>+Out,
3761 :Options</var>)</a></dt>
3762 <dd class="defbody">
3763 Save an RDF graph as Turtle. <var>Options</var> processed are:
3764
3765 <dl class="latex">
3766 <dt><strong>a</strong>(<var>+Boolean</var>)</dt>
3767 <dd class="defbody">
3768 If <code>true</code> (default), use <code>a</code> for the predicate <code>rdf:type</code>.
3769 Otherwise use the full resource.
3770 </dd>
3771 <dt><strong>align_prefixes</strong>(<var>+Boolean</var>)</dt>
3772 <dd class="defbody">
3773 Nicely align the @prefix declarations
3774 </dd>
3775 <dt><strong>base</strong>(<var>+Base</var>)</dt>
3776 <dd class="defbody">
3777 Save relative to the given <var>Base</var>
3778 </dd>
3779 <dt><strong>canonize_numbers</strong>(<var>+Boolean</var>)</dt>
3780 <dd class="defbody">
3781 If <code>true</code> (default <code>false</code>), emit numeric
3782 datatypes using Prolog's write to achieve canonical output.
3783 </dd>
3784 <dt><strong>comment</strong>(<var>+Boolean</var>)</dt>
3785 <dd class="defbody">
3786 It <code>true</code> (default), write some informative comments between
3787 the output segments
3788 </dd>
3789 <dt><strong>encoding</strong>(<var>+Encoding</var>)</dt>
3790 <dd class="defbody">
3791 <var>Encoding</var> used for the output stream. Default is UTF-8.
3792 </dd>
3793 <dt><strong>expand</strong>(<var>:Goal</var>)</dt>
3794 <dd class="defbody">
3795 Query an alternative graph-representation. See below.
3796 </dd>
3797 <dt><strong>indent</strong>(<var>+Column</var>)</dt>
3798 <dd class="defbody">
3799 Indentation for ; -lists. `0' does not indent, but writes on the same
3800 line. Default is 8.
3801 </dd>
3802 <dt><strong>graph</strong>(<var>+Graph</var>)</dt>
3803 <dd class="defbody">
3804 Save only the named graph
3805 </dd>
3806 <dt><strong>group</strong>(<var>+Boolean</var>)</dt>
3807 <dd class="defbody">
3808 If <code>true</code> (default), using P-O and O-grouping.
3809 </dd>
3810 <dt><strong>inline_bnodes</strong>(<var>+Boolean</var>)</dt>
3811 <dd class="defbody">
3812 if <code>true</code> (default), inline bnodes that are used once.
3813 </dd>
3814 <dt><strong>abbreviate_literals</strong>(<var>+Boolean</var>)</dt>
3815 <dd class="defbody">
3816 if <code>true</code> (default), omit the type if allowed by turtle.
3817 </dd>
3818 <dt><strong>only_known_prefixes</strong>(<var>+Boolean</var>)</dt>
3819 <dd class="defbody">
3820 Only use prefix notation for known prefixes. Without, some documents
3821 produce <i>huge</i> amounts of prefixes.
3822 </dd>
3823 <dt><strong>prefixes</strong>(<var>+List</var>)</dt>
3824 <dd class="defbody">
3825 If provided, uses exactly these prefixes. <var>List</var> is a list of
3826 prefix specifications, where each specification is either a term <i>Prefix_-_URI</i>
3827 or a prefix that is known to
3828 <a class="pred" href="#rdf_current_prefix/2">rdf_current_prefix/2</a>.
3829 </dd>
3830 <dt><strong>silent</strong>(<var>+Boolean</var>)</dt>
3831 <dd class="defbody">
3832 If <code>true</code> (default <code>false</code>), do not print the
3833 final informational message.
3834 </dd>
3835 <dt><strong>single_line_bnodes</strong>(<var>+Bool</var>)</dt>
3836 <dd class="defbody">
3837 If <code>true</code> (default <code>false</code>), write [...] and (...)
3838 on a single line.
3839 </dd>
3840 <dt><strong>subject_white_lines</strong>(<var>+Count</var>)</dt>
3841 <dd class="defbody">
3842 Extra white lines to insert between statements about a different
3843 subject. Default is 1.
3844 </dd>
3845 <dt><strong>tab_distance</strong>(<var>+Tab</var>)</dt>
3846 <dd class="defbody">
3847 Distance between tab-stops. `0' forces the library to use only spaces
3848 for layout. Default is 8.
3849 </dd>
3850 <dt><strong>user_prefixes</strong>(<var>+Boolean</var>)</dt>
3851 <dd class="defbody">
3852 If <code>true</code> (default), use prefixes from <a class="pred" href="#rdf_current_prefix/2">rdf_current_prefix/2</a>.
3853 </dd>
3854 </dl>
3855
3856 <p>The option <code>expand</code> allows for serializing alternative
3857 graph representations. It is called through <span class="pred-ext">call/5</span>,
3858 where the first argument is the expand-option, followed by S,P,O,G. G is
3859 the graph-option (which is by default a variable). This notably allows
3860 for writing RDF graphs represented as <code>rdf(S,P,O)</code> using the
3861 following code fragment:
3862
3863 <pre class="code">
3864 triple_in(RDF, S,P,O,_G) :-
3865 member(rdf(S,P,O), RDF).
3866
3867 ...,
3868 rdf_save_turtle(Out, [ expand(triple_in(RDF)) ]),
3869 </pre>
3870
3871 <table class="arglist">
3872 <tr valign="top"><td><var>Out</var> </td><td>is one of <code>stream(Stream)</code>,
3873 a stream handle, a file-URL or an atom that denotes a filename. </td></tr>
3874 </table>
3875 </dd>
3876 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="rdf_save_ntriples/2"><strong>rdf_save_ntriples</strong>(<var>+Spec,
3877 :Options</var>)</a></dt>
3878 <dd class="defbody">
3879 Save RDF using ntriples format. The ntriples format is a subset of
3880 Turtle, writing each triple fully qualified on its own line.</dd>
3881 <dt class="pubdef"><span class="pred-tag">[det]</span><a name="rdf_save_canonical_trig/2"><strong>rdf_save_canonical_trig</strong>(<var>+Spec,
3882 :Options</var>)</a></dt>
3883 <dd class="defbody">
3884 Save triples in a canonical format. See
3885 <a class="pred" href="#rdf_save_canonical_turtle/2">rdf_save_canonical_turtle/2</a>
3886 foir details.
38863887 </dd>
38873888 </dl>
38883889
Binary diff not shown
11381138 * PARSER OBJECT *
11391139 *******************************/
11401140
1141 static void clear_turtle_parser(turtle_state *ts);
1141 static int clear_turtle_parser(turtle_state *ts);
11421142 static int init_base_uri(turtle_state *ts);
11431143 static int read_predicate_object_list(turtle_state *ts, const char *end);
11441144 static int read_object(turtle_state *ts);
11691169 }
11701170
11711171
1172 static void
1172 static int
11731173 clear_turtle_parser(turtle_state *ts)
1174 { if ( ts->base_uri ) free(ts->base_uri);
1174 { int rc;
1175
1176 if ( ts->base_uri ) free(ts->base_uri);
11751177 if ( ts->empty_prefix ) free(ts->empty_prefix);
11761178 if ( ts->bnode.buffer ) free(ts->bnode.buffer);
11771179
1178 if ( ts->input ) PL_release_stream(ts->input);
1180 if ( ts->input )
1181 rc = PL_release_stream(ts->input);
1182 else
1183 rc = TRUE;
11791184
11801185 set_subject(ts, NULL, NULL);
11811186 set_predicate(ts, NULL, NULL);
11881193 clear_hash_table(&ts->blank_node_map);
11891194
11901195 memset(ts, 0, sizeof(*ts)); /* second call does nothing */
1196
1197 return rc;
11911198 }
11921199
11931200
23922399 free_resource(ts, r);
23932400 return rc;
23942401 }
2402 return FALSE;
23952403 }
23962404 case '[':
23972405 { resource *r;
31883196 { turtle_state *ts;
31893197
31903198 if ( get_turtle_parser(parser, &ts) )
3191 { clear_turtle_parser(ts);
3192
3193 return TRUE;
3194 }
3199 return clear_turtle_parser(ts);
31953200
31963201 return FALSE;
31973202 }
Binary diff not shown
32803280 goto out;
32813281 }
32823282
3283 assert(instance->sread = sorg_in);
3284 assert(instance->swrite = sorg_out);
3285
32863283 if ( !(i=Snew(instance, SIO_INPUT|SIO_RECORDPOS|SIO_FBUF, &ssl_funcs)) )
32873284 { rc = PL_resource_error("memory");
32883285 goto out;
Binary diff not shown
00 #!/usr/bin/env perl
11
22 sub printTeX
3 { s/`([@\w]+)\s*<->(\w+)/\\index{\l\1,\\both{\2}}`\\classboth{\1}{\2}/g;
4 s/`([@\w]+)\s*<-(\w+)/\\index{\l\1,\\get{\2}}`\\classget{\1}{\2}/g;
5 s/`([@\w]+)\s*->(\w+)/\\index{\l\1,\\send{\2}}`\\classsend{\1}{\2}/g;
6 s/<->(\w+)/\\both{\1}/g;
7 s/<-(\w+)/\\get{\1}/g;
8 s/->(\w+)/\\send{\1}/g;
9 s/(\s+|^)([a-z]\w+)\/((\d+|\[\d+(-|,)\d+\]))/\1\\index{\2\/\3}\\predref{\2}{\3}/g;
3 { s/`([@\w]+)\s*<->([a-z]\w*)/\\index\{\l\1,\\both\{\2\}\}`\\classboth\{\1\}\{\2\}/g;
4 s/`([@\w]+)\s*<-([a-z]\w*)/\\index\{\l\1,\\get\{\2\}\}`\\classget\{\1\}\{\2\}/g;
5 s/`([@\w]+)\s*->([a-z]\w*)/\\index\{\l\1,\\send\{\2\}\}`\\classsend\{\1\}\{\2\}/g;
6 s/<->([a-z]\w*)/\\both\{\1\}/g;
7 s/<-([a-z]\w*)/\\get\{\1\}/g;
8 s/->([a-z]\w*)/\\send\{\1\}/g;
9 s/(^|\s|\()([a-z]\w+)\/((\d+|\[\d+(-|,)\d+\]))/\1\\index\{\2\/\3\}\\predref\{\2\}\{\3\}/g;
10 s/(\s+|^)([a-z]\w+)\/\/((\d+|\[\d+(-|,)\d+\]))/\1\\index\{\2\/\/\3\}\\dcgref\{\2\}\{\3\}/g;
1011 s/(\w\.\w)\.(\s+[a-z])/\1.\\\2/g;
11 s/(^|[^\w}\\])@(\w+)/\1\\index{@\2}\\objectname{\2}/g;
12 s/<(\w[-~\w]*)>/\\bnfmeta{\1}/g;
13 s/\\class{([<\\=>]*)}/\\verb!\1!/g;
12 s/(^|[^'"\$])<(\w[-~a-z]*\w)>/\1\\bnfmeta\{\2\}/g;
13 s/\\class\{([<\\=>]*)\}/\\verb!\1!/g;
1414 s/==>/\$\\longrightarrow\$/g;
15 s/^((\\index{[^}]+})+) *$/\1%/;
16 s/(\\index{[^}]*)\\index{[^}]*}([^}]*})/\1\2/g;
17 s/(\\class(get|send|both){)\\index{[^}]*}/\1/g;
15 s/^((\\index\{[^\}]+\})+) *$/\1%/;
16 s/(\\index\{[^\}]*)\\index\{[^\}]*\}([^\}]*\})/\1\2/g;
17 s/(\\class(get|send|both)\{)\\index\{[^\}]*\}/\1/g;
18 s/(PL_[a-z_0-9]*)\(([^\)]*)\)/\\cfuncref\{\1\}\{\2\}/g;
19
20 # Prolog special arguments ...
21 # TBD: pick these up automatically from pl.sty
22
23 s/\\file\{([^\}]*\\bnfmeta[^\}]*)\}/\\metafile\{\1\}/g;
24 s/\\file\{([^\}]*\\arg[^\}]*)\}/\\metafile\{\1\}/g;
25 s/\\file\{([^\}]+)\}/\\file@\1@/g;
26 s/\\htmloutput\{([^\}]+)\}/\\htmloutput@\1@/g;
27
28 s/\{#!\}/\{\\Sexe\}/g;
29 s/\{#>\}/\{\\Scgt\}/g;
30 s/\{#>=\}/\{\\Scge\}/g;
31 s/\{#<\}/\{\\Sclt\}/g;
32 s/\{#=<\}/\{\\Scle\}/g;
33 s/\{#=\}/\{\\Sceq\}/g;
34 s/\{#\\=\}/\{\\Scne\}/g;
35 s/\{#\\\}/\{\\Snot\}/g;
36 s/\{#\\\/\}/\{\\Sor\}/g;
37 s/\{#\/\\\}/\{\\Sand\}/g;
38 s/\{#<=>\}/\{\\Sequiv\}/g;
39 s/\{#<=\}/\{\\Slimpl\}/g;
40 s/\{#=>\}/\{\\Srimpl\}/g;
41 s/\{#<==\}/\{\\Slimplies\}/g;
42 s/\{#==>\}/\{\\Srimplies\}/g;
43 s/\{#<==>\}/\{\\Scequal\}/g;
44 s/\{#=\\=\}/\{\\Scine\}/g;
45 s/\{#=:=\}/\{\\Scieq\}/g;
46 s/\{#\}/\{\\Shash\}/g;
47 s/\{!\}/\{\\Scut\}/g;
48 s/\{,\}/\{\\Scomma\}/g;
49 s/\{->\}/\{\\Sifthen\}/g;
50 s/\{\*->\}/\{\\Ssoftcut\}/g;
51 s/\{\.\}/\{\\Sdot\}/g;
52 s/\{;\}/\{\\Ssemicolon\}/g;
53 s/\{<\}/\{\\Slt\}/g;
54 s/\{><\}/\{\\Sxor\}/g;
55 s/\{=\}/\{\\Seq\}/g;
56 s/\{=\.\.\}/\{\\Suniv\}/g;
57 s/\{=:=\}/\{\\Saeq\}/g;
58 s/\{=<\}/\{\\Sle\}/g;
59 s/\{<=\}/\{\\Sel\}/g;
60 s/\{==\}/\{\\Sequal\}/g;
61 s/\{=@=\}/\{\\Sstructeq\}/g;
62 s/\{\\=@=\}/\{\\Sstructneq\}/g;
63 s/\{=\\=\}/\{\\Sane\}/g;
64 s/\{>\}/\{\\Sgt\}/g;
65 s/\{>=\}/\{\\Sge\}/g;
66 s/\{>=<\}/\{\\Seqbowtie\}/g;
67 s/\{>:<\}/\{\\Smappunify\}/g;
68 s/\{:<\}/\{\\Smapselect\}/g;
69 s/\{@<\}/\{\\Stlt\}/g;
70 s/\{@=<\}/\{\\Stle\}/g;
71 s/\{@>\}/\{\\Stgt\}/g;
72 s/\{@>=\}/\{\\Stge\}/g;
73 s/\{\\\+\}/\{\\Snot\}/g;
74 s/\{\\=\}/\{\\Sne\}/g;
75 s/\{\\==\}/\{\\Snequal\}/g;
76 s/\{\^\}/\{\\Shat\}/g;
77 s/\{\|\}/\{\\Sbar\}/g;
78 s/\{\*\}/\{\\Stimes\}/g;
79 s/\{\*\*\}/\{\\Spow\}/g;
80 s/\{\+\}/\{\\Splus\}/g;
81 s/\{-\}/\{\\Sminus\}/g;
82 s/\{\/\}/\{\\Sdiv\}/g;
83 s/\{\/\/\}/\{\\Sidiv\}/g;
84 s/\{\/\\\}/\{\\Sand\}/g;
85 s/\{<<\}/\{\\Slshift\}/g;
86 s/\{>>\}/\{\\Srshift\}/g;
87 s/\{\\\}/\{\\Sneg\}/g;
88 s/\{\\\/\}/\{\\Sor\}/g;
89 s/\{\$\}/\{\\Sdollar\}/g;
90 s/\{\?\}/\{\\Squest\}/g;
91 s/\{:\}/\{\\Smodule\}/g;
92 s/\{:-\}/\{\\Sneck\}/g;
93 s/\{\?-\}/\{\\Sdirective\}/g;
94 s/\{-->\}/\{\\Sdcg\}/g;
95 s/\{~\}/\{\\Stilde\}/g;
96 s/\{%\}/\{\\Spercent\}/g;
97 s/\{\{\}\}/\{\\Scurl\}/g;
98 s/\{\[\|\]\}/\{\\Scons\}/g;
99 s/\{xXX..\\\}/\{\\SxXX\}/g;
100
101 s/\\file@([^@]+)@/\\file\{\1\}/g;
102 s/\\htmloutput@([^@]+)@/\\htmloutput\{\1\}/g;
18103
19104 print;
20105 }
43128 while (<ARGV> )
44129 { &expandTabs;
45130 print;
46 if ( /\\end{(code|verbatim)}/ )
131 if ( /\\end\{(code|verbatim)\}/ )
47132 { return;
48133 }
49134 }
56141 while (<ARGV> )
57142 { $line++;
58143 &expandTabs;
59 if ( /\\end{pcecode}/ )
144 if ( /\\end\{pcecode\}/ )
60145 { print;
61146 return;
62147 }
83168 # MAIN PROGRAM
84169
85170 while (<>)
86 { while ( /\\begin{pcecode}/ )
171 { while ( /\\begin\{pcecode\}/ )
87172 { &printPceCode;
88173 print "\n\\noindent\n";
89174 &skiptonext;
90 }
91 while ( /\\begin{(code|verbatim)}/ )
175 }
176 while ( /\\begin\{(code|verbatim)\}/ )
92177 { &printCode;
93178 print "\n\\noindent\n";
94179 &skiptonext;
344344 ),
345345 ignore(send(@emacs_server, listen)).
346346
347 chrome_server(_Emacs) :->
348 "Start HTTP server on 9292 for Edit With Emacs"::
349 use_module(library(emacs/emacs_chrome_server)),
350 emacs_chrome_server.
351
347352 :- pce_group(customise).
348353
349354
0 /* Part of SWI-Prolog
1
2 Author: Jan Wielemaker
3 E-mail: J.Wielemaker@vu.nl
4 WWW: http://www.swi-prolog.org
5 Copyright (c) 2017, CWI Amsterdam
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions
10 are met:
11
12 1. Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14
15 2. Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in
17 the documentation and/or other materials provided with the
18 distribution.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 :- module(emacs_chrome_server,
35 [ emacs_chrome_server/0
36 ]).
37 :- use_module(library(http/thread_httpd)).
38 :- use_module(library(http/http_dispatch)).
39 :- use_module(library(http/http_client)).
40 :- use_module(library(pce)).
41
42 /** <module> Emacs Chrome Server
43
44 @see https://github.com/stsquad/emacs_chrome/tree/master/servers
45 */
46
47 %! emacs_chrome_server
48 %
49 % Start a PceEmacs server for the _Edit With Emacs_ Chrome/Firefox
50 % extension.
51
52 emacs_chrome_server :-
53 start_emacs,
54 http_server(http_dispatch,
55 [ port(localhost:9292)
56 ]).
57
58
59 :- http_handler(root(edit), edit, [method(post), spawn]).
60 :- http_handler(root(status), status, [method(get)]).
61
62 edit(Request) :-
63 http_read_data(Request, Data, [to(string)]),
64 edit_text(Data, NewData),
65 format('Content-type: text/plain~n~n'),
66 format('~s', [NewData]).
67
68 status(_Request) :-
69 format('Content-type: text/plain~n~n'),
70 format('Ready~n').
71
72 edit_text(From, To) :-
73 tmp_file_stream(utf8, FileName, Stream),
74 format(Stream, '~s', [From]),
75 close(Stream),
76 edit_file(FileName),
77 setup_call_cleanup(
78 open(FileName, read, In),
79 read_string(In, _, To),
80 close(In)),
81 delete_file(FileName).
82
83 :- pce_global(@emacs_chrome_server_method,
84 new(chain(send_method(unlink_to, new(vector),
85 and(message(@receiver?from, free),
86 message(@receiver, free))),
87 send_method(unlink_from, new(vector),
88 and(message(@receiver?to, free),
89 message(@receiver, free)))))).
90
91 :- pce_begin_class(emacs_chrome_proxy, object,
92 "Track emacs").
93
94 variable(client, int, get, "Client thread").
95
96 initialise(P, Client:int) :->
97 "Create from thread id"::
98 send_super(P, initialise),
99 send(P, slot, client, Client).
100
101 unlink(P) :->
102 get(P, client, Id),
103 thread_send_message(Id, emacs_chrome_server_done),
104 send_super(P, unlink).
105
106 :- pce_end_class(emacs_chrome_proxy).
107
108
109 %! edit_file(+File)
110 %
111 % Edit a file using PceEmacs, waiting for the user to close the
112 % editor.
113
114 edit_file(File) :-
115 thread_self(Me),
116 thread_property(Me, id(MeID)),
117 in_pce_thread(create_editor(File, MeID)),
118 thread_get_message(emacs_chrome_server_done).
119
120 create_editor(File, MeID) :-
121 new(Proxy, emacs_chrome_proxy(MeID)),
122 new(B, emacs_buffer(File)),
123 get(B, open, tab, Frame),
124 send(Frame, expose),
125 get(Frame, editor, Editor),
126 new(H, hyper(Proxy, Editor, editor, server)),
127 send(H, send_method, @emacs_chrome_server_method).
737737 send(Ispell, label, string('Ispell Emacs buffer %s', TB?name)),
738738 send(Ispell, open),
739739 send(Ispell, spell).
740
741 /*******************************
742 * EDIT WITH EMACS *
743 *******************************/
744
745 chrome_server(_) :->
746 "Start HTTP server on 9292 for Edit With Emacs"::
747 send(@emacs, chrome_server).
740748
741749
742750 /*******************************
307307 A functors "functors"
308308 A fx "fx"
309309 A fy "fy"
310 A garbage_collect_atoms "garbage_collect_atoms"
311 A garbage_collect_clauses "garbage_collect_clauses"
310312 A garbage_collected "<garbage_collected>"
311313 A garbage_collection "garbage_collection"
312314 A gc "gc"
6767 /* PLVERSION_TAG: a string, normally "", but for example "rc1" */
6868
6969 #ifndef PLVERSION
70 #define PLVERSION 70603
70 #define PLVERSION 70604
7171 #endif
7272 #ifndef PLVERSION_TAG
7373 #define PLVERSION_TAG ""
720720 * QUINTUS/SICSTUS WRAPPER *
721721 *******************************/
722722
723 PL_EXPORT(int) PL_cvt_i_char(term_t p, char *c);
724 PL_EXPORT(int) PL_cvt_i_uchar(term_t p, unsigned char *c);
725 PL_EXPORT(int) PL_cvt_i_short(term_t p, short *s);
726 PL_EXPORT(int) PL_cvt_i_ushort(term_t p, unsigned short *s);
723727 PL_EXPORT(int) PL_cvt_i_int(term_t p, int *c);
728 PL_EXPORT(int) PL_cvt_i_uint(term_t p, unsigned int *c);
724729 PL_EXPORT(int) PL_cvt_i_long(term_t p, long *c);
730 PL_EXPORT(int) PL_cvt_i_ulong(term_t p, unsigned long *c);
731 PL_EXPORT(int) PL_cvt_i_int64(term_t p, int64_t *c);
732 PL_EXPORT(int) PL_cvt_i_uint64(term_t p, uint64_t *c);
725733 PL_EXPORT(int) PL_cvt_i_size_t(term_t p, size_t *c);
726734 PL_EXPORT(int) PL_cvt_i_float(term_t p, double *c);
727735 PL_EXPORT(int) PL_cvt_i_single(term_t p, float *c);
10791087 #define PL_THREAD_NO_DEBUG 0x01 /* Start thread in nodebug mode */
10801088 #define PL_THREAD_NOT_DETACHED 0x02 /* Allow Prolog to join */
10811089
1090 typedef enum
1091 { PL_THREAD_CANCEL_FAILED = FALSE, /* failed to cancel; try abort */
1092 PL_THREAD_CANCEL_JOINED = TRUE, /* cancelled and joined */
1093 PL_THREAD_CANCEL_MUST_JOIN /* cancelled, must join */
1094 } rc_cancel;
1095
10821096 typedef struct
10831097 { long local_size; /* Stack sizes (Kbytes) */
10841098 long global_size;
10851099 long trail_size;
10861100 long argument_size;
10871101 char * alias; /* alias name */
1088 int (*cancel)(int id); /* cancel function */
1102 rc_cancel (*cancel)(int id); /* cancel function */
10891103 intptr_t flags; /* PL_THREAD_* flags */
10901104 void * reserved[4]; /* reserved for extensions */
10911105 } PL_thread_attr_t;
22 Author: Jan Wielemaker
33 E-mail: J.Wielemaker@vu.nl
44 WWW: www.swi-prolog.org
5 Copyright (c) 2014, University of Amsterdam
5 Copyright (c) 2017, University of Amsterdam
66 VU University Amsterdam
77 All rights reserved.
88
7575 !
7676 ),
7777 Lists).
78 test(agc, Xs == [ aaaa100001,aaaa100002,aaaa100003,aaaa100004,
79 aaaa100005,aaaa100006,aaaa100007,aaaa100008,
80 aaaa100009,aaaa100010
81 ]) :-
82 offset(10 000, findnsols(10, X, gen_atom(X), Xs)),
83 !.
84
85 gen_atom(A) :-
86 between(1, infinite, X),
87 atom_concat(aaaa, X, A).
7888
7989 :- end_tests(bags).
4141 asserta(user:file_search_path(library, ClibDir)),
4242 asserta(user:file_search_path(foreign, ClibDir)).
4343
44 :- if(absolute_file_name(foreign(process), _,
45 [ file_type(executable),
46 file_errors(fail),
47 access(read)
48 ])).
44 has_foreign_lib(Lib) :-
45 absolute_file_name(foreign(Lib), _,
46 [ file_type(executable),
47 file_errors(fail),
48 access(read)
49 ]).
50
51 :- if(has_foreign_lib(process)).
4952
5053 :- use_module(library(plunit)).
5154 :- use_module(library(lists)).
5356 :- use_module(library(filesex)).
5457 :- use_module(library(readutil)).
5558 :- use_module(library(debug)).
56 :- if(exists_source(library(rlimit))).
59 :- if(has_foreign_lib(rlimit)).
5760 :- use_module(library(rlimit)).
5861 :- endif.
5962
7174 \+ enough_files, !,
7275 format(user_error,
7376 'Skipped saved state files because the system does\n\c
74 not offer us enough file open files~n', []).
77 not offer us enough open files~n', []).
7578 test_saved_states :-
7679 run_tests([ saved_state
7780 ]).
110113 debug(save(max_files), 'No info on max open files; assuming ok', []).
111114 :- endif.
112115
113 %% state_output(-FileName)
116 %% state_output(+Id, -FileName)
114117 %
115118 % Name of the file we use for temporary output of the state.
116119
117 state_output(State) :-
120 state_output(Id, State) :-
118121 working_directory(Dir, Dir),
119 directory_file_path(Dir, 'test_state.exe', State).
120
122 current_prolog_flag(pid, Pid),
123 format(atom(File), 'test_state_~w_~w.exe', [Id, Pid]),
124 directory_file_path(Dir, File, State).
125
126 me(Exe) :-
127 current_prolog_flag(executable, WinExeOS),
128 prolog_to_os_filename(WinExe, WinExeOS),
129 file_base_name(WinExe, WinFile),
130 downcase_atom(WinFile, 'swipl-win.exe'), !,
131 file_directory_name(WinExe, WinDir),
132 atomic_list_concat([WinDir, 'swipl.exe'], /, PlExe),
133 prolog_to_os_filename(PlExe, Exe).
121134 me(MeSH) :-
122135 absolute_file_name('swipl.sh', MeSH,
123136 [ access(execute),
125138 ]), !.
126139 me(Exe) :-
127140 current_prolog_flag(executable, Exe).
141
142 :- dynamic
143 win_path_set/0.
144
145 set_windows_path :-
146 \+ win_path_set,
147 current_prolog_flag(windows, true), !,
148 current_prolog_flag(executable, WinExeOS),
149 prolog_to_os_filename(WinExe, WinExeOS),
150 file_directory_name(WinExe, PlWinDir),
151 prolog_to_os_filename(PlWinDir, WinDir),
152 getenv('PATH', Path0),
153 atomic_list_concat([WinDir, Path0], ';', Path),
154 setenv('PATH', Path),
155 asserta(win_path_set).
156 set_windows_path.
128157
129158 create_state(File, Output, Args) :-
130159 me(Me),
142171
143172 run_state(Exe, Args, Result) :-
144173 debug(save, 'Running state ~q ~q', [Exe, Args]),
174 set_windows_path,
145175 process_create(Exe, Args,
146176 [ stdout(pipe(Out)),
147177 stderr(pipe(Err))
189219 :- begin_tests(saved_state, [sto(rational_trees)]).
190220
191221 test(true, Result == [true]) :-
192 state_output(Exe),
222 state_output(1, Exe),
193223 call_cleanup(
194224 ( create_state('input/plain.pl', Exe, ['-g', echo_true]),
195225 run_state(Exe, [], Result)
196226 ),
197227 remove_state(Exe)).
198228 test(argv, Result == [[aap,noot,mies]]) :-
199 state_output(Exe),
229 state_output(2, Exe),
200230 call_cleanup(
201231 ( create_state('input/plain.pl', Exe, ['-g', echo_argv]),
202232 run_state(Exe, [aap, noot, mies], Result)
203233 ),
204234 remove_state(Exe)).
205235 test(true, Result == [true]) :-
206 state_output(Exe),
236 state_output(3, Exe),
207237 call_cleanup(
208238 ( create_state('input/data.pl', Exe, ['-g', test]),
209239 run_state(Exe, [], Result)
8585 ( I == 1
8686 -> true
8787 ; format(user_error,
88 '~NRequired ~D retrys before all queues were GCed~n', [])
88 '~N~p: Required ~D retrys before all queues were GCed~n',
89 [G, I])
8990 ).
91 no_new_queues(G) :-
92 format(user_error,
93 '~NWARNING: ~p: Did not reclaim queues in 10 runs.~n\c
94 This can be bad luck and is thus not considered a \c
95 test failure.~n',
96 [G]).
9097
9198 create_and_destroy :-
9299 message_queue_create(Q),
4646 (run(4), put_char(user_error, .))).
4747
4848 run(N) :-
49 kill_gc,
49 set_prolog_gc_thread(stop),
5050 length(Threads, N),
5151 maplist(thread_create(agc), Threads),
5252 maplist(thread_join, Threads).
5858 forall(between(1, 10000, I),
5959 atom_concat(Prefix, I, _)).
6060
61 kill_gc :-
62 ( catch(thread_signal(gc, abort),
63 error(existence_error(thread, gc),_),
64 ( print_message(warning, test_gc_thread_startup(not_created)),
65 fail))
66 -> thread_join(gc, _)
67 ; true
68 ).
69
7061 :- multifile
7162 prolog:message//1.
7263
0 /* Part of SWI-Prolog
1
2 Author: Jan Wielemaker
3 E-mail: J.Wielemaker@vu.nl
4 WWW: http://www.swi-prolog.org
5 Copyright (c) 2008, University of Amsterdam
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions
10 are met:
11
12 1. Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14
15 2. Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in
17 the documentation and/or other materials provided with the
18 distribution.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 :- module(thread_agc,
35 [ thread_agc/0,
36 thread_agc/2 % +Threads, +Count
37 ]).
38 :- use_module(library(debug)).
39
40 %% thread_agc
41 %
42 % Similar to thread_agc_findall.pl, but without using findall.
43
44 thread_agc :-
45 protocol(x),
46 thread_agc(4, 10000).
47
48 thread_agc(Threads, Count) :-
49 current_prolog_flag(agc_margin, Old),
50 set_prolog_flag(agc_margin, 1000),
51 call_cleanup(test(Threads, Count),
52 set_prolog_flag(agc_margin, Old)).
53
54
55 test(Threads, Count) :-
56 numlist(1, Threads, Is),
57 maplist(create_test(Count), Is, Ids),
58 maplist(thread_join, Ids).
59
60 create_test(Count, I, Id) :-
61 prefix(I, Prefix),
62 thread_create(test_find(Prefix, Count), Id, []).
63
64 prefix(_N, Prefix) :-
65 flag(prefix, N, N+1),
66 A is 0'A+N,
67 atom_codes(Prefix, [A,A,A,A]).
68
69 test_find(Prefix, N) :-
70 gen_atoms(1, N, Prefix, Atoms),
71 check_atoms(Atoms, 1, N, Prefix).
72
73 gen_atoms(I, N, _Prefix, Atoms) :-
74 I > N,
75 !,
76 Atoms = [].
77 gen_atoms(I, N, Prefix, Atoms) :-
78 atom_concat(Prefix, I, H),
79 I2 is I + 1,
80 Atoms = [H|T],
81 gen_atoms(I2, N, Prefix, T).
82
83 check_atoms([], I, N, _Prefix) :-
84 assertion(I=:=N+1).
85 check_atoms([H|T], I, N, Prefix) :-
86 ( atom_concat(Prefix, Rest, H)
87 -> ( atom_number(Rest, Num)
88 -> assertion(I == Num),
89 I2 is I + 1,
90 check_atoms(T, I2, N, Prefix)
91 ; format(user_error, 'Oops, ~q: invalid (lookup ~w)~n', [H,I]),
92 fail
93 )
94 ; format(user_error,
95 'Oops, ~q has no prefix ~q (lookup ~w)~n', [H,Prefix,I]),
96 fail
97 ).
5555 test(Threads, Count) :-
5656 numlist(1, Threads, Is),
5757 maplist(create_test(Count), Is, Ids),
58 maplist(thread_join, Ids, States),
59 maplist(==(true), States).
58 maplist(thread_join, Ids).
6059
6160 create_test(Count, I, Id) :-
6261 prefix(I, Prefix),
6362 thread_create(test_find(Prefix, Count), Id, []).
6463
6564 prefix(N, Prefix) :-
66 A is 0'A+N,
65 A is 0'A+N//2,
6766 atom_codes(Prefix, [A,A,A]).
6867
6968 test_find(Prefix, N) :-
7776 check_atoms([], I, N, _Prefix) :-
7877 assertion(I=:=N+1).
7978 check_atoms([H|T], I, N, Prefix) :-
80 atom_concat(Prefix, Rest, H),
81 atom_number(Rest, Num),
82 assertion(I == Num),
83 I2 is I + 1,
84 check_atoms(T, I2, N, Prefix).
79 ( atom_concat(Prefix, Rest, H)
80 -> ( atom_number(Rest, Num)
81 -> assertion(I == Num),
82 I2 is I + 1,
83 check_atoms(T, I2, N, Prefix)
84 ; format(user_error, 'Oops, ~q: invalid~n', [H]),
85 fail
86 )
87 ; format(user_error, 'Oops, ~q has no prefix ~q~n', [H,Prefix]),
88 fail
89 ).
202202
203203 /* Define to 1 if you have the `isnan' function. */
204204 #undef HAVE_ISNAN
205
206 /* Define to 1 if you have the `kill' function. */
207 #undef HAVE_KILL
205208
206209 /* Define to 1 if you have the `curses' library (-lcurses). */
207210 #undef HAVE_LIBCURSES
81058105 fi
81068106 done
81078107
8108 for ac_func in strerror tgetent times unsetenv grantpt nanosleep waitpid
8108 for ac_func in strerror tgetent times unsetenv grantpt nanosleep waitpid kill
81098109 do :
81108110 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
81118111 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
10261026 AC_CHECK_FUNCS(signal sigset sigprocmask sleep usleep srand srandom stat)
10271027 AC_CHECK_FUNCS(memmove stricmp strlwr sigaction sigsetmask siggetmask sigblock)
10281028 AC_CHECK_FUNCS(rint aint floor ceil isnan isinf tcsetattr cfmakeraw getpid)
1029 AC_CHECK_FUNCS(strerror tgetent times unsetenv grantpt nanosleep waitpid)
1029 AC_CHECK_FUNCS(strerror tgetent times unsetenv grantpt nanosleep waitpid kill)
10301030 AC_CHECK_FUNCS(setlocale fpgetmask fpresetsticky mtrace localtime_r asctime_r)
10311031 AC_CHECK_FUNCS(ctime_r mmap confstr strcasecmp mbscoll mbscasecoll fpclass)
10321032 AC_CHECK_FUNCS(setenv posix_openpt wcsxfrm sysctlbyname mbsnrtowcs wcsdup)
471471 #define ctime_r(timep, buf) strcpy(buf, ctime(timep))
472472 #endif
473473
474 static void
475 crashHandler(int sig)
476 { int tid;
477 atom_t alias;
478 const pl_wchar_t *name = L"";
479 time_t now = time(NULL);
480 char tbuf[48];
481
482 signal(sig, SIG_DFL);
483 tid = PL_thread_self();
484 ctime_r(&now, tbuf);
485 tbuf[24] = '\0';
486
487 if ( PL_get_thread_alias(tid, &alias) )
488 name = PL_atom_wchars(alias, NULL);
489
490 Sdprintf("\nSWI-Prolog [thread %d (%Ws) at %s]: "
491 "received fatal signal %d (%s)\n",
492 PL_thread_self(), name, tbuf, sig, signal_name(sig));
493 print_c_backtrace("crash");
494 run_on_halt(&GD->os.exit_hooks, 4);
495
496 #if defined(HAVE_KILL) && defined(HAVE_GETPID)
497 kill(getpid(), sig);
498 #else
499 abort();
500 #endif
501 }
502
503474 void
504475 initBackTrace(void)
505476 {
506477 #ifdef SIGSEGV
507 PL_signal(SIGSEGV, crashHandler);
478 PL_signal(SIGSEGV, sigCrashHandler);
508479 #endif
509480 #ifdef SIGILL
510 PL_signal(SIGILL, crashHandler);
481 PL_signal(SIGILL, sigCrashHandler);
511482 #endif
512483 #if defined(SIGBUS) && SIGBUS != SIGSEGV
513 PL_signal(SIGBUS, crashHandler);
484 PL_signal(SIGBUS, sigCrashHandler);
514485 #endif
515486 #ifdef SIGFPE
516 PL_signal(SIGFPE, crashHandler);
487 PL_signal(SIGFPE, sigCrashHandler);
517488 #endif
518489 #ifdef SIGSYS
519 PL_signal(SIGSYS, crashHandler);
490 PL_signal(SIGSYS, sigCrashHandler);
520491 #endif
521492 }
522493
907878 btrace_destroy(bt);
908879 }
909880
881 void
882 sigCrashHandler(int sig)
883 { int tid;
884 atom_t alias;
885 const pl_wchar_t *name = L"";
886 time_t now = time(NULL);
887 char tbuf[48];
888
889 signal(sig, SIG_DFL);
890 tid = PL_thread_self();
891 ctime_r(&now, tbuf);
892 tbuf[24] = '\0';
893
894 if ( PL_get_thread_alias(tid, &alias) )
895 name = PL_atom_wchars(alias, NULL);
896
897 Sdprintf("\nSWI-Prolog [thread %d (%Ws) at %s]: "
898 "received fatal signal %d (%s)\n",
899 PL_thread_self(), name, tbuf, sig, signal_name(sig));
900 print_c_backtrace("crash");
901 Sdprintf("Running on_halt hooks with status %d\n", 128+sig);
902 run_on_halt(&GD->os.exit_hooks, 128+sig);
903
904 #ifdef HAVE_KILL
905 { int pid;
906 # ifdef O_PLMT
907 # ifdef HAVE_GETTID_SYSCALL
908 # ifdef HAVE_SYS_SYSCALL_H
909 # include <sys/syscall.h>
910 # endif
911 pid = syscall(__NR_gettid);
912 # elif defined(HAVE_GETTID_MACRO)
913 pid = gettid();
914 # else
915 pid = getpid();
916 # endif
917 # else /*O_PLMT*/
918 pid = getpid();
919 # endif
920 Sdprintf("Killing %d with default signal handlers\n", pid);
921 kill(pid, sig);
922 }
923 #else /*HAVE_KILL*/
924 Sdprintf("Aborting\n");
925 abort();
926 #endif
927 }
928
910929 #endif /*BTRACE_DONE*/
911930
912931
949968 {
950969 }
951970
971 void
972 sigCrashHandler(int sig)
973 { int tid;
974 atom_t alias;
975 const pl_wchar_t *name = L"";
976 time_t now = time(NULL);
977 char tbuf[48];
978
979 signal(sig, SIG_DFL);
980 tid = PL_thread_self();
981 ctime_r(&now, tbuf);
982 tbuf[24] = '\0';
983
984 if ( PL_get_thread_alias(tid, &alias) )
985 name = PL_atom_wchars(alias, NULL);
986
987 Sdprintf("\nSWI-Prolog [thread %d (%Ws) at %s]: "
988 "received fatal signal %d (%s)\n",
989 PL_thread_self(), name, tbuf, sig, signal_name(sig));
990 run_on_halt(&GD->os.exit_hooks, 4);
991
992 #if defined(HAVE_KILL) && defined(HAVE_GETPID)
993 kill(getpid(), sig);
994 #else
995 abort();
996 #endif
997 }
998
952999 #endif /*BTRACE_DONE*/
4040 COMMON(void) print_backtrace(int last); /* 1..SAVE_TRACES */
4141 COMMON(void) print_backtrace_named(const char *why);
4242 COMMON(void) initBackTrace(void);
43 COMMON(void) sigCrashHandler(int sig);
4344
4445 #endif /*PL_CSTACK_H_INCLUDED*/
7272 { FMT_ERROR("not enough arguments"); \
7373 } \
7474 }
75 #define FMT_ERROR(fmt) return (void)Sunlock(fd), \
76 PL_error(NULL, 0, NULL, ERR_FORMAT, fmt)
77 #define FMT_ARG(c, a) return (void)Sunlock(fd), \
78 PL_error(NULL, 0, NULL, \
79 ERR_FORMAT_ARG, c, a)
80 #define FMT_EXEPTION() return (void)Sunlock(fd), FALSE
75 #define FMT_ERROR(fmt) return PL_error(NULL, 0, NULL, ERR_FORMAT, fmt)
76 #define FMT_ARG(c, a) return PL_error(NULL, 0, NULL, ERR_FORMAT_ARG, c, a)
77 #define FMT_EXEPTION() return FALSE
8178
8279
8380 static PL_locale prolog_locale =
314311 PL_put_term(argv, args);
315312 }
316313
317 startCritical;
318314 switch(fmt.storage) /* format can do call-back! */
319315 { case PL_CHARS_RING:
320316 case PL_CHARS_STACK:
324320 break;
325321 }
326322
323 Slock(out);
327324 rval = do_format(out, &fmt, argc, argv, m);
325 Sunlock(out);
328326 PL_free_text(&fmt);
329 if ( !endCritical )
330 return FALSE;
331327
332328 return rval;
333329 }
386382 int tab_stop = 0; /* padded tab stop */
387383 unsigned int here = 0;
388384 int rc = TRUE;
389
390 Slock(fd); /* buffer locally */
391385
392386 state.out = fd;
393387 state.pending_rubber = 0;
609603 { term_t r = PL_new_term_ref();
610604
611605 PL_put_integer(r, arg);
612 Sunlock(fd);
613606 return PL_error(NULL, 0, NULL, ERR_DOMAIN,
614607 ATOM_radix, r);
615608 }
846839 default:
847840 { term_t ex = PL_new_term_ref();
848841
849 Sunlock(fd);
850842 PL_put_atom(ex, codeToAtom(c));
851843 return PL_error("format", 2, NULL, ERR_EXISTENCE,
852844 PL_new_atom("format_character"),
870862 emit_rubber(&state);
871863
872864 out:
873 Sunlock(fd);
874
875865 return rc;
876866 }
877867
21092109 #define valdigit(c) ((c) - '0')
21102110 #define A_LEFT 0 /* left-aligned field */
21112111 #define A_RIGHT 1 /* right-aligned field */
2112
2113 #ifdef __WINDOWS__
2114 /* This is a copy from src/pl-nt.c, copied here to avoid dependency
2115 of pl-stream.c on SWI-Prolog internals.
2116 */
2117
2118 static int
2119 ms_snprintf(char *buffer, size_t count, const char *fmt, ...)
2120 { va_list ap;
2121 int ret;
2122
2123 va_start(ap, fmt);
2124 ret = _vsnprintf(buffer, count-1, fmt, ap);
2125 va_end(ap);
2126
2127 if ( ret < 0 || ret == count )
2128 { ret = (int)count;
2129 buffer[count-1] = '\0';
2130 }
2131
2132 return ret;
2133 }
2134 #endif
21352112
21362113 #define SNPRINTF3(fm, a1) \
21372114 { size_t __r; \
200200 }
201201
202202 void
203 free_lingering(linger_list **list)
204 { linger_list *c, *n;
205
206 do
207 { if ( !(c = *list) )
208 return;
209 } while( !COMPARE_AND_SWAP(list, c, NULL) );
210
211 for(; c; c=n)
212 { n = c->next;
213 (*c->unalloc)(c->object);
214 freeHeap(c, sizeof(*c));
203 free_lingering(linger_list *list)
204 { linger_list *n;
205
206 for(; list; list=n)
207 { n = list->next;
208 (*list->unalloc)(list->object);
209 freeHeap(list, sizeof(*list));
215210 }
216211 }
217212
8080 } linger_list;
8181
8282 COMMON(void) linger(linger_list** list, void (*unalloc)(void *), void *object);
83 COMMON(void) free_lingering(linger_list **list);
83 COMMON(void) free_lingering(linger_list *list);
8484
8585
8686 /*******************************
197197
198198 static int rehashAtoms(void);
199199 static void considerAGC(void);
200 static unsigned int register_atom(volatile Atom p);
201 static unsigned int unregister_atom(volatile Atom p);
202 #ifdef O_DEBUG_ATOMGC
203 static int tracking(const Atom a);
204 IOSTREAM *atomLogFd = 0;
205 #endif
200206
201207 static inline int
202208 bump_atom_references(Atom a, unsigned int ref)
548554 !likely(bump_atom_references(a, ref)) )
549555 break; /* atom was just GCed. Re-create */
550556 #endif
557 #ifdef O_DEBUG_ATOMGC
558 if ( atomLogFd && tracking(a) )
559 Sfprintf(atomLogFd, "Lookup `%s' at (#%d)\n",
560 a->name, indexAtom(a->atom));
561 #endif
551562 *new = FALSE;
552563 release_atom_table();
553564 release_atom_bucket();
596607
597608 if ( true(type, PL_BLOB_UNIQUE) )
598609 { a->next = table[v];
599 if ( !( COMPARE_AND_SWAP(&table[v], head, a) &&
600 !GD->atoms.rehashing && /* See (**) above */
601 table == GD->atoms.table->table ) )
610 if ( !( !GD->atoms.rehashing && /* See (**) above */
611 COMPARE_AND_SWAP(&table[v], head, a) &&
612 table == GD->atoms.table->table ) )
602613 { if ( false(type, PL_BLOB_NOCOPY) )
603614 PL_free(a->name);
604615 a->type = ATOM_TYPE_INVALID;
613624 a->references = 1 | ATOM_VALID_REFERENCE | ATOM_RESERVED_REFERENCE;
614625 #endif
615626
627 #ifdef O_DEBUG_ATOMGC
628 if ( atomLogFd && tracking(a) )
629 Sfprintf(atomLogFd, "Created `%s' at (#%d)\n",
630 a->name, indexAtom(a->atom));
631 #endif
616632 *new = TRUE;
617633 if ( type->acquire )
618634 (*type->acquire)(a->atom);
642658 #ifdef O_ATOMGC
643659
644660 #ifdef O_DEBUG_ATOMGC
645 static char *tracking;
646 IOSTREAM *atomLogFd;
661 static char *t_tracking;
662
663 static int
664 tracking(const Atom a)
665 { return /*a->type == &text_atom && */
666 strprefix(a->name, t_tracking);
667 }
668
647669
648670 void
649671 _PL_debug_register_atom(atom_t a,
650672 const char *file, int line, const char *func)
651 { int i = indexAtom(a);
652 int mx = entriesBuffer(&atom_array, Atom);
653 Atom atom;
673 { size_t i = indexAtom(a);
674 size_t mx = GD->atoms.highest;
654675
655676 assert(i>=0 && i<mx);
656 atom = fetchBuffer(&atom_array, i, Atom);
657
658 atom->references++;
659 if ( atomLogFd && strprefix(atom->name, tracking) )
660 Sfprintf(atomLogFd, "%s:%d: %s(): ++ (%d) for `%s' (#%d)\n",
661 file, line, func, atom->references, atom->name, i);
677 if ( i >= GD->atoms.builtin )
678 { Atom atom = fetchAtomArray(i);
679 unsigned int refs;
680
681 refs = register_atom(atom);
682 if ( atomLogFd && tracking(atom) )
683 Sfprintf(atomLogFd, "%s:%d: %s(): ++ (%d) for `%s' (#%d)\n",
684 file, line, func, refs, atom->name, i);
685 }
662686 }
663687
664688
665689 void
666690 _PL_debug_unregister_atom(atom_t a,
667691 const char *file, int line, const char *func)
668 { int i = indexAtom(a);
669 int mx = entriesBuffer(&atom_array, Atom);
670 Atom atom;
692 { size_t i = indexAtom(a);
693 size_t mx = GD->atoms.highest;
671694
672695 assert(i>=0 && i<mx);
673 atom = fetchBuffer(&atom_array, i, Atom);
674
675 assert(atom->references >= 1);
676 atom->references--;
677 if ( atomLogFd && strprefix(atom->name, tracking) )
678 Sfprintf(atomLogFd, "%s:%d: %s(): -- (%d) for `%s' (#%d)\n",
679 file, line, func, atom->references, atom->name, i);
680 }
681
682
683 Atom
684 _PL_debug_atom_value(atom_t a)
685 { GET_LD
686 int i = indexAtom(a);
687 Atom atom = fetchBuffer(&atom_array, i, Atom);
688
689 if ( !atom )
690 { char buf[32];
691
692 Sdprintf("*** No atom at index (#%d) ***", i);
693 trap_gdb();
694
695 atom = allocHeapOrHalt(sizeof(*atom));
696 Ssprintf(buf, "***(#%d)***", i);
697 atom->name = store_string(buf);
698 atom->length = strlen(atom->name);
699 }
700
701 return atom;
696 if ( i >= GD->atoms.builtin )
697 { Atom atom = fetchAtomArray(i);
698 unsigned int refs;
699
700 refs = unregister_atom(atom);
701 if ( atomLogFd && tracking(atom) )
702 Sfprintf(atomLogFd, "%s:%d: %s(): -- (%d) for `%s' (#%d)\n",
703 file, line, func, refs, atom->name, i);
704 }
702705 }
703706
704707
706709 pl_track_atom(term_t which, term_t stream)
707710 { char *s;
708711
709 if ( tracking )
710 remove_string(tracking);
711 tracking = NULL;
712 if ( t_tracking )
713 remove_string(t_tracking);
714 t_tracking = NULL;
712715 atomLogFd = NULL;
713716
714717 if ( PL_get_nil(stream) )
715718 succeed;
716719
717 if ( !PL_get_chars(which, &s, CVT_LIST) )
718 return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_list, which);
719 if ( !PL_get_stream_handle(stream, &atomLogFd) )
720 fail;
721
722 tracking = store_string(s);
720 if ( !PL_get_chars(which, &s, CVT_LIST|CVT_STRING|CVT_EXCEPTION) ||
721 !PL_get_stream_handle(stream, &atomLogFd) )
722 return FALSE;
723
724 PL_release_stream(atomLogFd);
725
726 t_tracking = store_string(s);
723727
724728 succeed;
725729 }
757761 if ( ATOM_IS_VALID(ap->references) && !ATOM_IS_MARKED(ap->references) )
758762 {
759763 #ifdef O_DEBUG_ATOMGC
760 if ( atomLogFd )
764 if ( atomLogFd && tracking(ap) )
761765 Sfprintf(atomLogFd, "Marked `%s' at (#%d)\n", ap->name, i);
762766 #endif
763767 ATOMIC_OR(&ap->references, ATOM_MARKED_REFERENCE);
807811
808812
809813 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
810 destroyAtom() actually discards an atom. The code marked (*) is
811 sometimes inserted to debug atom-gc. The trick is to create xxxx<...>
812 atoms that should *not* be subject to AGC. If we find one collected we
813 know we trapped a bug.
814 destroyAtom() actually discards an atom.
814815 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
815816
816817 #define ATOM_NAME_MUST_FREE 0x1
843844 a->references = ATOM_DESTROY_REFERENCE;
844845
845846 #ifdef O_DEBUG_ATOMGC
846 if ( atomLogFd )
847 if ( atomLogFd && tracking(a) )
847848 Sfprintf(atomLogFd, "Invalidated `%s'\n", a->name);
848849 #endif
849850
905906 buckets++;
906907 }
907908
908 #if 0
909 if ( strncmp(a->name, "xxxx", 4) == 0 ) /* (*) see above */
910 { Sdprintf("Deleting %s\n", a->name);
911 assert(0);
912 }
913 #endif
914
915909 #ifdef O_DEBUG_ATOMGC
916 if ( atomLogFd )
910 /* tracking() always returns FALSE as the type is lost */
911 if ( atomLogFd && tracking(a) )
917912 Sfprintf(atomLogFd, "Deleted `%s'\n", a->name);
918913 #endif
919914
11051100 - When we unregister an atom, it must have at least one reference.
11061101 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
11071102
1108 static void
1103 static unsigned int
11091104 register_atom(volatile Atom p)
11101105 { for(;;)
11111106 { unsigned int ref = p->references;
11151110 { if ( COMPARE_AND_SWAP(&p->references, ref, nref) )
11161111 { if ( ATOM_REF_COUNT(nref) == 1 )
11171112 ATOMIC_DEC(&GD->atoms.unregistered);
1118 return;
1113 return nref;
11191114 }
11201115 } else
1121 { return;
1116 { return ref;
11221117 }
11231118 }
11241119 }
11901185 markAtomsOnStacks().
11911186 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
11921187
1188 static unsigned int
1189 unregister_atom(volatile Atom p)
1190 { unsigned int refs;
1191
1192 if ( !ATOM_IS_VALID(p->references) )
1193 { Sdprintf("OOPS: PL_unregister_atom('%s'): invalid atom\n", p->name);
1194 trap_gdb();
1195 }
1196
1197 if ( unlikely(ATOM_REF_COUNT(p->references+1) == 0) )
1198 return ATOM_REF_COUNT(~(unsigned int)0);
1199
1200 if ( GD->atoms.gc_active )
1201 { unsigned int oldref, newref;
1202
1203 do
1204 { oldref = p->references;
1205 newref = oldref - 1;
1206
1207 if ( ATOM_REF_COUNT(newref) == 0 )
1208 newref |= ATOM_MARKED_REFERENCE;
1209 } while( !COMPARE_AND_SWAP(&p->references, oldref, newref) );
1210 refs = ATOM_REF_COUNT(newref);
1211 #ifdef O_DEBUG_ATOMGC
1212 if ( refs == 0 && atomLogFd && tracking(p) )
1213 Sfprintf(atomLogFd, "Marked '%s' at (#%d) (unregistered)\n",
1214 p->name, indexAtom(p->atom));
1215 #endif
1216 } else
1217 { GET_LD
1218
1219 if ( HAS_LD )
1220 { LD->atoms.unregistering = p->atom;
1221 #ifdef O_DEBUG_ATOMGC
1222 if ( atomLogFd && tracking(p) )
1223 Sfprintf(atomLogFd, "Set atoms.unregistering for '%s' at (#%d)\n",
1224 p->name, indexAtom(p->atom));
1225 #endif
1226 }
1227 if ( (refs=ATOM_REF_COUNT(ATOMIC_DEC(&p->references))) == 0 )
1228 ATOMIC_INC(&GD->atoms.unregistered);
1229 }
1230
1231 if ( refs == ATOM_REF_COUNT((unsigned int)-1) )
1232 { char fmt[100];
1233 char *enc;
1234 char *buf = NULL;
1235
1236 strcpy(fmt, "OOPS: PL_unregister_atom('%Ls'): -1 references\n");
1237 enc = strchr(fmt, '%')+1;
1238
1239 Sdprintf(fmt, dbgAtomName(p, enc, &buf));
1240 if ( buf )
1241 PL_free(buf);
1242 trap_gdb();
1243 }
1244
1245 return refs;
1246 }
1247
1248
11931249 void
11941250 PL_unregister_atom(atom_t a)
11951251 {
11961252 #ifdef O_ATOMGC
11971253 size_t index = indexAtom(a);
1198 unsigned int refs;
11991254
12001255 if ( index >= GD->atoms.builtin )
12011256 { Atom p;
12021257
12031258 p = fetchAtomArray(index);
1204 if ( !ATOM_IS_VALID(p->references) )
1205 { Sdprintf("OOPS: PL_unregister_atom('%s'): invalid atom\n", p->name);
1206 trap_gdb();
1207 }
1208
1209 if ( unlikely(ATOM_REF_COUNT(p->references+1) == 0) )
1210 return;
1211
1212 if ( GD->atoms.gc_active )
1213 { unsigned int oldref, newref;
1214
1215 do
1216 { oldref = p->references;
1217 newref = oldref - 1;
1218
1219 if ( ATOM_REF_COUNT(newref) == 0 )
1220 newref |= ATOM_MARKED_REFERENCE;
1221 } while( !COMPARE_AND_SWAP(&p->references, oldref, newref) );
1222 refs = ATOM_REF_COUNT(newref);
1223 } else
1224 { GET_LD
1225
1226 if ( HAS_LD )
1227 LD->atoms.unregistering = a;
1228 if ( (refs=ATOM_REF_COUNT(ATOMIC_DEC(&p->references))) == 0 )
1229 ATOMIC_INC(&GD->atoms.unregistered);
1230 }
1231 if ( refs == ATOM_REF_COUNT((unsigned int)-1) )
1232 { char fmt[100];
1233 char *enc;
1234 char *buf = NULL;
1235
1236 strcpy(fmt, "OOPS: PL_unregister_atom('%Ls'): -1 references\n");
1237 enc = strchr(fmt, '%')+1;
1238
1239 Sdprintf(fmt, dbgAtomName(p, enc, &buf));
1240 if ( buf )
1241 PL_free(buf);
1242 trap_gdb();
1243 }
1259 unregister_atom(p);
12441260 }
12451261 #endif
12461262 }
16791695
16801696 if ( ATOM_IS_VALID(refs) && btype &&
16811697 (!type_name || type_name == btype->atom_name) &&
1698 atom->atom != ATOM_garbage_collected &&
16821699 bump_atom_references(atom, refs) )
16831700 { DEBUG(CHK_SECURE, /* avoid trap through linkVal__LD() check */
16841701 if ( atom->atom == ATOM_garbage_collected )
305305 switch( CTX_CNTRL )
306306 { case FRG_FIRST_CALL:
307307 bag = current_bag(PASS_LD1);
308 simpleMutexLock(&LD->bags.mutex);
308309 clear_mem_pool(&bag->records);
310 simpleMutexUnlock(&LD->bags.mutex);
309311 bag->suspended_solutions += bag->solutions;
310312 bag->solutions = 0;
311313 bag->gsize = 0;
55885588 return FALSE;
55895589
55905590 chp = NULL;
5591 pushPredicateAccess(def, generationFrame(environment_frame));
5591 setGenerationFrameVal(environment_frame, pushPredicateAccess(def));
55925592 break;
55935593 }
55945594 case FRG_REDO:
56875687 Definition def;
56885688 Cref cr;
56895689 #ifdef O_LOGICAL_UPDATE
5690 gen_t generation = generationFrame(environment_frame);
5690 gen_t generation;
56915691 #endif
56925692
56935693 if ( ForeignControl(h) == FRG_CUTTED )
57095709 fail; /* I do not belong to a predicate */
57105710
57115711 def = clause->predicate;
5712 generation = pushPredicateAccess(def);
57125713 acquire_def(def);
57135714 for( cref = def->impl.clauses.first_clause, i=1; cref; cref = cref->next)
57145715 { if ( cref->value.clause == clause )
57185719 );
57195720
57205721 release_def(def);
5722 popPredicateAccess(def);
57215723 return rc;
57225724 }
57235725 if ( visibleClauseCNT(cref->value.clause, generation) )
57245726 i++;
57255727 }
57265728 release_def(def);
5729 popPredicateAccess(def);
57275730 }
57285731
57295732 fail;
57375740 fail;
57385741
57395742 def = getProcDefinition(proc);
5743 generation = pushPredicateAccess(def);
57405744 acquire_def(def);
57415745 cref = def->impl.clauses.first_clause;
57425746 while ( cref && !visibleClauseCNT(cref->value.clause, generation) )
57445748 release_def(def);
57455749
57465750 if ( !cref )
5751 { popPredicateAccess(def);
57475752 return FALSE;
5753 }
57485754
57495755 if ( PL_get_integer(n, &i) ) /* proc and n specified */
57505756 { i--; /* 0-based */
57585764 i--;
57595765 }
57605766 release_def(def);
5767 popPredicateAccess(def);
57615768 if ( i == 0 && cref )
57625769 return PL_unify_clref(ref, cref->value.clause);
57635770 return FALSE;
57665773 cr = allocForeignState(sizeof(*cr));
57675774 cr->clause = cref;
57685775 cr->index = 1;
5769 pushPredicateAccess(def, generation);
5776 setGenerationFrameVal(environment_frame, generation);
57705777 } else
57715778 { cr = ForeignContextPtr(h);
57725779 def = cr->clause->value.clause->predicate;
5780 generation = generationFrame(environment_frame);
57735781 }
57745782
57755783 PL_unify_integer(n, cr->index);
467467 fr->programPointer = pcret;
468468 fr->parent = pfr;
469469 fr->clause = cref;
470 fr->predicate = cl->predicate;
470 setFramePredicate(fr, cl->predicate);
471471 fr->context = fr->predicate->module;
472472 setNextFrameFlags(fr, pfr);
473473 #ifdef O_PROFILE
474474 fr->prof_node = NULL;
475475 #endif
476 setGenerationFrame(fr, global_generation());
476 setGenerationFrame(fr);
477477 enterDefinition(fr->predicate);
478478 environment_frame = fr;
479479
10111011 }
10121012 return PL_error(NULL, 0, NULL, ERR_DOMAIN,
10131013 ATOM_not_less_than_zero, t);
1014 } if ( PL_get_number(t, &n) )
1014 }
1015
1016 if ( PL_get_number(t, &n) )
10151017 { switch(n.type)
10161018 { case V_INTEGER:
10171019 if ( n.value.i >= 0 )
10541056 }
10551057
10561058
1059 int
1060 PL_get_uint64_ex__LD(term_t t, uint64_t *i ARG_LD)
1061 { number n;
1062 Word p = valTermRef(t);
1063
1064 deRef(p);
1065 if ( isTaggedInt(*p) )
1066 { intptr_t v = valInt(*p);
1067
1068 if ( v >= 0 )
1069 { *i = v;
1070 return TRUE;
1071 }
1072 return PL_error(NULL, 0, NULL, ERR_DOMAIN,
1073 ATOM_not_less_than_zero, t);
1074 }
1075
1076 if ( PL_get_number(t, &n) )
1077 { switch(n.type)
1078 { case V_INTEGER:
1079 if ( n.value.i >= 0 )
1080 { *i = n.value.i;
1081 return TRUE;
1082 } else
1083 { return PL_error(NULL, 0, NULL, ERR_DOMAIN,
1084 ATOM_not_less_than_zero, t);
1085 }
1086 #if SIZEOF_VOIDP == 8 && defined(O_GMP)
1087 case V_MPZ:
1088 { uint64_t v;
1089
1090 switch(mpz_to_uint64(n.value.mpz, &v))
1091 { case 0:
1092 *i = v;
1093 return TRUE;
1094 case -1:
1095 return PL_error(NULL, 0, NULL, ERR_DOMAIN,
1096 ATOM_not_less_than_zero, t);
1097 case 1:
1098 return PL_representation_error("uint64_t");
1099 default:
1100 assert(0);
1101 return FALSE;
1102 }
1103 }
1104 #else
1105 return PL_representation_error("uint64_t");
1106 #endif
1107 default:
1108 break;
1109 }
1110 }
1111
1112 return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_integer, t);
1113 }
1114
1115
10571116 #undef PL_get_size_ex
10581117 int
10591118 PL_get_size_ex(term_t t, size_t *i)
9797 COMMON(int) printMessage(atom_t severity, ...) WUNUSED;
9898 #ifdef ARG_LD
9999 COMMON(int) PL_get_atom_ex__LD(term_t t, atom_t *a ARG_LD);
100 COMMON(int) PL_get_uint64_ex__LD(term_t t, uint64_t *i ARG_LD);
100101 #endif
101102 COMMON(int) PL_get_module_ex(term_t name, module_t *m);
102103 COMMON(int) PL_get_arg_ex(int n, term_t term, term_t arg);
9393 return raiseStackOverflow(GLOBAL_OVERFLOW); } while(0)
9494
9595 static int unify_int64_ex__LD(term_t t, int64_t i, int ex ARG_LD);
96 static int PL_get_uint__LD(term_t t, unsigned int *i ARG_LD);
9697
9798 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9899 Deduce the value to store a copy of the contents of p. This is a *very*
817818
818819 #define REP_SP (sp_encoding)
819820
821 #ifndef SCHAR_MIN
822 #define SCHAR_MIN -128
823 #define SCHAR_MAX 127
824 #endif
825 #ifndef UCHAR_MAX
826 #define UCHAR_MAX 255
827 #endif
828
829 #ifndef SHORT_MIN
830 #define SHORT_MIN -32768
831 #define SHORT_MAX 32767
832 #define USHORT_MAX (SHORT_MAX*2+1)
833 #endif
834
835 static bool
836 _PL_cvt_i_char(term_t p, char *c, int mn, int mx)
837 { GET_LD
838 int i;
839 PL_chars_t txt;
840
841 if ( PL_get_integer(p, &i) && i >= mn && i <= mx )
842 { *c = (char)i;
843 return TRUE;
844 } else if ( PL_get_text(p, &txt, CVT_ATOM|CVT_STRING|CVT_LIST) )
845 { if ( txt.length == 1 && txt.encoding == ENC_ISO_LATIN_1 )
846 { *c = txt.text.t[0];
847 return TRUE; /* can never be allocated */
848 }
849 PL_free_text(&txt);
850 }
851
852 if ( PL_is_integer(p) )
853 return PL_representation_error(mn < 0 ? "char" : "uchar");
854
855 return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_integer, p);
856 }
857
858
859 bool
860 PL_cvt_i_char(term_t p, char *c)
861 { return _PL_cvt_i_char(p, c, SCHAR_MIN, SCHAR_MAX);
862 }
863
864 bool
865 PL_cvt_i_uchar(term_t p, unsigned char *c)
866 { return _PL_cvt_i_char(p, (char *)c, 0, UCHAR_MAX);
867 }
868
869
870 static bool
871 _PL_cvt_i_short(term_t p, short *s, int mn, int mx)
872 { GET_LD
873 int i;
874
875 if ( PL_get_integer(p, &i) &&
876 i >= mn && i <= mx )
877 { *s = (short)i;
878 return TRUE;
879 }
880
881 if ( PL_is_integer(p) )
882 return PL_representation_error(mn < 0 ? "short" : "ushort");
883
884 return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_integer, p);
885 }
886
887 bool
888 PL_cvt_i_short(term_t p, short *s)
889 { return _PL_cvt_i_short(p, s, SHORT_MIN, SHORT_MAX);
890 }
891
892 bool
893 PL_cvt_i_ushort(term_t p, unsigned short *s)
894 { return _PL_cvt_i_short(p, (short *)s, 0, USHORT_MAX);
895 }
896
820897 bool
821898 PL_cvt_i_int(term_t p, int *c)
822899 { return PL_get_integer_ex(p, c);
823900 }
824901
902 bool
903 PL_cvt_i_uint(term_t t, unsigned int *c)
904 { GET_LD
905
906 if ( PL_get_uint__LD(t, c PASS_LD) )
907 return TRUE;
908
909 if ( PL_is_integer(t) )
910 return PL_representation_error("uint");
911
912 return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_integer, t);
913 }
825914
826915 bool
827916 PL_cvt_i_long(term_t p, long *c)
828917 { return PL_get_long_ex(p, c);
829918 }
830919
920 bool
921 PL_cvt_i_ulong(term_t p, unsigned long *c)
922 {
923 #if SIZEOF_LONG == 8
924 return PL_cvt_i_uint64(p, c);
925 #else
926 return PL_cvt_i_uint(p, (unsigned int*)c);
927 #endif
928 }
929
930 bool
931 PL_cvt_i_int64(term_t p, int64_t *c)
932 { return PL_get_int64_ex(p, c);
933 }
934
935 bool
936 PL_cvt_i_uint64(term_t p, uint64_t *c)
937 { GET_LD
938 return PL_get_uint64_ex__LD(p, c PASS_LD);
939 }
831940
832941 bool
833942 PL_cvt_i_size_t(term_t p, size_t *c)
14421551 *i = (int)val;
14431552 succeed;
14441553 }
1554 #if SIZEOF_VOIDP < 8
14451555 if ( isBignum(w) )
14461556 { int64_t val = valBignum(w);
14471557
14511561 *i = (int)val;
14521562 succeed;
14531563 }
1564 #endif
14541565 if ( isFloat(w) )
14551566 { double f = valFloat(w);
14561567 int l;
14771588 return PL_get_integer__LD(t, i PASS_LD);
14781589 }
14791590 #define PL_get_integer(t, i) PL_get_integer__LD(t, i PASS_LD)
1591
1592
1593 static int
1594 PL_get_uint__LD(term_t t, unsigned int *i ARG_LD)
1595 { word w = valHandle(t);
1596
1597 if ( isTaggedInt(w) )
1598 { intptr_t val = valInt(w);
1599
1600 if ( val < 0 || val > UINT_MAX )
1601 fail;
1602 *i = (unsigned int)val;
1603 succeed;
1604 }
1605 #if SIZEOF_VOIDP < 8
1606 if ( isBignum(w) )
1607 { int64_t val = valBignum(w);
1608
1609 if ( val < 0 || val > UINT_MAX )
1610 fail;
1611
1612 *i = (unsigned int)val;
1613 succeed;
1614 }
1615 #endif
1616 #ifndef O_GMP
1617 if ( isFloat(w) )
1618 { double f = valFloat(w);
1619 unsigned int l;
1620
1621 #ifdef DOUBLE_TO_LONG_CAST_RAISES_SIGFPE
1622 if ( f > (double)UINT_MAX || f < 0.0 )
1623 fail;
1624 #endif
1625
1626 l = (unsigned int)f;
1627 if ( (double)l == f )
1628 { *i = l;
1629 succeed;
1630 }
1631 }
1632 #endif
1633 fail;
1634 }
14801635
14811636
14821637 int
326326 COMMON(void) setLTopInBody(void);
327327 COMMON(word) check_foreign(void); /* DEBUG(CHK_SECURE...) stuff */
328328 COMMON(void) markAtomsOnStacks(PL_local_data_t *ld);
329 COMMON(void) set_min_generation(DirtyDefInfo ddi, gen_t gen);
329330 COMMON(void) markPredicatesInEnvironments(PL_local_data_t *ld);
330331 COMMON(QueryFrame) queryOfFrame(LocalFrame fr);
331332 COMMON(void) mark_active_environment(struct bit_vector *active,
501502 COMMON(void) freeClause(Clause c);
502503 COMMON(void) lingerClauseRef(ClauseRef c);
503504 COMMON(ClauseRef) newClauseRef(Clause cl, word key);
504 COMMON(void) gcClauseRefs(void);
505505 COMMON(size_t) removeClausesPredicate(Definition def,
506506 int sfindex, int fromfile);
507507 COMMON(void) reconsultFinalizePredicate(sf_reload *rl, Definition def,
516516
517517
518518 static inline size_t
519 offset_cell(Word p)
520 { word m = *p; /* was get_value(p) */
521 size_t offset;
519 offset_word(word m)
520 { size_t offset;
522521
523522 if ( unlikely(storage(m) == STG_LOCAL) )
524523 offset = wsizeofInd(m) + 1;
526525 offset = 0;
527526
528527 return offset;
528 }
529
530
531 static inline size_t
532 offset_cell(Word p)
533 { return offset_word(*p);
529534 }
530535
531536
51585163 to walk along all reachable data as well.
51595164 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
51605165
5161 #ifdef O_DEBUG_ATOMGC
5162 extern IOSTREAM * atomLogFd; /* for error messages */
5163
5164 static intptr_t
5165 loffset(void *p)
5166 { GET_LD
5167 if ( p == NULL )
5168 return 0;
5169
5170 assert((intptr_t)p % sizeof(word) == 0);
5171 return (Word)p-(Word)lBase;
5172 }
5173 #endif
5174
51755166 static void
51765167 markAtomsOnGlobalStack(PL_local_data_t *ld)
51775168 { Word gbase = ld->stacks.global.base;
51785169 Word gtop = ld->stacks.global.top;
51795170 Word current;
5180
5181 for(current = gbase; current < gtop; current += (offset_cell(current)+1) )
5182 { if ( isAtom(*current) )
5183 markAtom(*current);
5171 word w;
5172
5173 #ifdef O_DEBUG_ATOMGC
5174 if ( atomLogFd ) Sfprintf(atomLogFd, "Mark global %p..%p\n", gbase, gtop);
5175 #endif
5176
5177 for(current = gbase; current < gtop; current += (offset_word(w)+1) )
5178 { w = *current;
5179
5180 if ( isAtom(w) )
5181 markAtom(w);
51845182 }
51855183 }
51865184
51935191 Word current;
51945192
51955193 for(current = lbase; current < lend; current++ )
5196 { if ( isAtom(*current) )
5197 markAtom(*current);
5194 { word w = *current;
5195
5196 if ( isAtom(w) )
5197 markAtom(w);
51985198 }
51995199 }
52005200
52205220 #ifdef O_MAINTENANCE
52215221 save_backtrace("AGC");
52225222 #endif
5223 #ifdef O_DEBUG_ATOMGC
5224 if ( atomLogFd ) Sfprintf(atomLogFd, "Mark atoms.unregistering\n");
5225 #endif
52235226 markAtom(ld->atoms.unregistering); /* see PL_unregister_atom() */
5227 markAtomsOnLocalStack(ld);
52245228 markAtomsOnGlobalStack(ld);
5225 markAtomsOnLocalStack(ld);
52265229 markAtomsFindall(ld);
52275230 #ifdef O_PLMT
52285231 markAtomsThreadMessageQueue(ld);
52325235 #endif /*O_ATOMGC*/
52335236
52345237 #ifdef O_CLAUSEGC
5235 /* - - - q- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5238 void
5239 set_min_generation(DirtyDefInfo ddi, gen_t gen)
5240 {
5241 #ifdef O_PLMT
5242 #ifdef HAVE___SYNC_ADD_AND_FETCH_8
5243 for(;;)
5244 { gen_t old = ddi->oldest_generation;
5245
5246 if ( gen >= old ||
5247 COMPARE_AND_SWAP(&ddi->oldest_generation, old, gen) )
5248 return;
5249 }
5250 #else
5251 PL_LOCK(L_CGCGEN);
5252 if ( gen < ddi->oldest_generation )
5253 ddi->oldest_generation = gen;
5254 PL_UNLOCK(L_CGCGEN);
5255 #endif
5256 #else
5257 if ( gen < ddi->oldest_generation )
5258 ddi->oldest_generation = gen;
5259 #endif
5260 }
5261
5262 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52365263 Find the latest generation at which a predicate is being used.
52375264 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
52385265
52785305 { gen_t gen = generationFrame(fr);
52795306
52805307 if ( gen < ddi->oldest_generation )
5281 ddi->oldest_generation = gen;
5308 set_min_generation(ddi, gen);
52825309 }
52835310 }
52845311 }
339339 int highest_allocated; /* Highest with info struct */
340340 int thread_max; /* Size of threads array */
341341 PL_thread_info_t **threads; /* Pointers to thread-info */
342 struct
343 { pthread_mutex_t mutex;
344 pthread_cond_t cond;
345 unsigned int requests;
346 unsigned int initialized; /* mutex and condvar are initialized */
347 } gc;
342348 } thread;
343349 #endif /*O_PLMT*/
344350
984984
985985 #define generationFrame(f) \
986986 ((gen_t)(f)->generation.gen_u<<32 | (gen_t)(f)->generation.gen_l)
987 #define setGenerationFrame(f, gen) \
988 do { (f)->generation.gen_u = (uint32_t)(gen>>32); \
989 (f)->generation.gen_l = (uint32_t)(gen); \
987 #define setGenerationFrameVal(f, g) \
988 do { gen_t __gen = (g); \
989 (f)->generation.gen_u = (uint32_t)(__gen>>32); \
990 (f)->generation.gen_l = (uint32_t)(__gen); \
990991 } while(0)
991992 #else
992993 typedef uint64_t lgen_t;
993994 #define generationFrame(f) ((f)->generation)
994 #define setGenerationFrame(f, gen) \
995 #define setGenerationFrameVal(f, gen) \
995996 do { (f)->generation = (gen); } while(0)
996997 #endif
997998 #ifdef HAVE___SYNC_ADD_AND_FETCH_8
998 #define global_generation() (GD->_generation)
999 #define next_global_generation() ATOMIC_INC(&GD->_generation)
1000999 typedef uint64_t ggen_t;
10011000 #else
10021001 #define ATOMIC_GENERATION_HACK 1
10061005 } ggen_t;
10071006 #endif /*HAVE___SYNC_ADD_AND_FETCH_8*/
10081007 #else /*O_LOGICAL_UPDATE*/
1009 #define global_generation() (0)
1008 #define global_generation() (0)
10101009 #define next_global_generation() (0)
1011 #define generationFrame(f) (0)
1012 #define setGenerationFrame(f) (void)0
10131010 #endif /*O_LOGICAL_UPDATE*/
1011
1012 #define setGenerationFrame(fr) setGenerationFrame__LD((fr) PASS_LD)
10141013
10151014 #define FR_CLEAR_NEXT FR_SKIPPED|FR_WATCHED|FR_CATCHED|FR_HIDE_CHILDS|FR_CLEANUP
10161015 #define FR_CLEAR_FLAGS (FR_CLEAR_NEXT|FR_CONTEXT)
10191018 do \
10201019 { (next)->level = (fr)->level+1; \
10211020 (next)->flags = ((fr)->flags) & ~FR_CLEAR_FLAGS; \
1021 } while(0)
1022
1023 #define setFramePredicate(fr, def) \
1024 do \
1025 { (fr)->predicate = (def); \
10221026 } while(0)
10231027
10241028 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11531157 #define ATOM_TYPE_INVALID ((PL_blob_t*)0x007)
11541158
11551159 #ifdef O_DEBUG_ATOMGC
1160 extern IOSTREAM *atomLogFd;
11561161 #define PL_register_atom(a) \
11571162 _PL_debug_register_atom(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
11581163 #define PL_unregister_atom(a) \
11591164 _PL_debug_unregister_atom(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
1160 #undef atomValue
1161 #define atomValue(a) _PL_debug_atom_value(a)
1162 extern Atom _PL_debug_atom_value(atom_t a);
1163 #endif
1164 #else
1165 #endif
1166 #else /*!O_ATOMGC*/
11651167 #define PL_register_atom(a)
11661168 #define PL_unregister_atom(a)
11671169 #endif
14541456 };
14551457
14561458 #ifdef O_PLMT
1457 #define acquire_def(def) do { LD->thread.info->access.predicate = def; } while(0)
1458 #define release_def(def) do { LD->thread.info->access.predicate = NULL; } while(0)
1459 #define acquire_def(def) \
1460 do { DEBUG(CHK_SECURE, assert(!LD->thread.info->access.predicate)); \
1461 LD->thread.info->access.predicate = def; } while(0)
1462 #define release_def(def) \
1463 do { LD->thread.info->access.predicate = NULL; } while(0)
1464 #define acquire_def2(def, store) \
1465 do { store = LD->thread.info->access.predicate; \
1466 DEBUG(CHK_SECURE, assert(!store || store == def)); \
1467 LD->thread.info->access.predicate = def; } while(0)
1468 #define release_def2(def, store) \
1469 do { LD->thread.info->access.predicate = store; } while(0)
1470
14591471 #else
14601472 #define acquire_def(def) (void)0
14611473 #define release_def(def) (void)0
454454 } else
455455 { cref = nextClauseArg1(chp, generation PASS_LD);
456456 }
457 DEBUG(CHK_SECURE, assert(!cref || !chp->cref ||
458 visibleClause(chp->cref->value.clause,
459 generationFrame(fr))));
460457 release_def();
458
459 DEBUG(CHK_SECURE,
460 assert(!cref || !chp->cref ||
461 chp->cref->value.clause->generation.erased > generation));
461462
462463 return cref;
463464 }
13481349
13491350 ci = newClauseIndexTable(hints->args, hints);
13501351
1351 acquire_def(def);
1352 #ifdef O_PLMT
1353 assert(LD->thread.info->access.predicate == def);
1354 #endif
13521355 first = def->impl.clauses.first_clause;
13531356 last = def->impl.clauses.last_clause;
13541357
13561359 { if ( false(cref->value.clause, CL_ERASED) )
13571360 addClauseToIndex(ci, cref->value.clause, CL_END);
13581361 }
1359 release_def(def);
13601362
13611363 LOCKDEF(def);
13621364 if ( first == def->impl.clauses.first_clause &&
16351637 for(i=0,cb=ci->entries; i<ci->buckets; i++,cb++)
16361638 { ClauseRef cref;
16371639 unsigned int dirty = 0;
1638
1639 acquire_def(def);
1640 Definition old;
1641
1642 acquire_def2(def, old);
16401643 for(cref=cb->head; cref; cref=cref->next)
16411644 { if ( cref->d.key )
16421645 ci_size++;
16641667 dirty++;
16651668 }
16661669 }
1667 release_def(def);
1670 release_def2(def, old);
16681671
16691672 assert(cb->dirty == dirty);
16701673 if ( cb->dirty )
487487
488488 return (gen_t)u<<32|l;
489489 }
490
491 #else /*ATOMIC_GENERATION_HACK*/
492
493 static inline gen_t
494 global_generation(void)
495 { return GD->_generation;
496 }
497
498 static inline gen_t
499 next_global_generation(void)
500 { return ATOMIC_INC(&GD->_generation);
501 }
502
490503 #endif /*ATOMIC_GENERATION_HACK*/
504
505 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
506 We must ensure that cleanDefinition() does not remove clauses that are
507 valid for the generation in the frame. This means that
508 pl_garbage_collect_clauses() must either pick up the generation from
509 this frame using markPredicatesInEnvironments() or the start generation
510 of pl_garbage_collect_clauses() is older than what is stored in this
511 frame. This loop ensure that if CGC has been running between
512 global_generation() and storing the generation in our frame, our
513 generation is updated and thus no harm is done.
514 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
515
516 static inline void
517 setGenerationFrame__LD(LocalFrame fr ARG_LD)
518 {
519 #ifdef O_LOGICAL_UPDATE
520 gen_t gen;
521
522 do
523 { gen = global_generation();
524 setGenerationFrameVal(fr, gen);
525 if ( unlikely(GD->clauses.cgc_active) )
526 cgcActivatePredicate__LD(fr->predicate, gen PASS_LD);
527 } while(gen != global_generation());
528 #endif
529 }
491530
492531 static inline int WUNUSED
493532 callEventHook(pl_event_type ev, ...)
5858 #define popTermRef() popTermRef__LD(PASS_LD1)
5959 #define pushWordAsTermRef(p) pushWordAsTermRef__LD(p PASS_LD)
6060 #define lookupHTable(ht, n) lookupHTable__LD(ht, n PASS_LD)
61 #define pushPredicateAccess(def, gen) pushPredicateAccess__LD(def, gen PASS_LD)
61 #define pushPredicateAccess(def) pushPredicateAccess__LD(def PASS_LD)
6262 #define popPredicateAccess(def) popPredicateAccess__LD(def PASS_LD)
6363 #define popNPredicateAccess(cnt) popNPredicateAccess__LD(cnt PASS_LD)
6464 #define nextClause(chp, argv, fr, def) nextClause__LD(chp, argv, fr, def PASS_LD)
10231023 PRED_IMPL("win_registry_get_value", 3, win_registry_get_value, 0)
10241024 { GET_LD
10251025 DWORD type;
1026 BYTE data[MAXREGSTRLEN];
1026 union
1027 { BYTE bytes[MAXREGSTRLEN];
1028 wchar_t wchars[MAXREGSTRLEN/sizeof(wchar_t)];
1029 DWORD dword;
1030 } data;
10271031 DWORD len = sizeof(data);
10281032 size_t klen, namlen;
10291033 wchar_t *k, *name;
10401044 return PL_error(NULL, 0, NULL, ERR_EXISTENCE, PL_new_atom("key"), Key);
10411045
10421046 DEBUG(9, Sdprintf("key = %p, name = %s\n", key, name));
1043 if ( RegQueryValueExW(key, name, NULL, &type, data, &len) == ERROR_SUCCESS )
1047 if ( RegQueryValueExW(key, name, NULL, &type, data.bytes, &len)
1048 == ERROR_SUCCESS )
10441049 { RegCloseKey(key);
10451050
10461051 switch(type)
10471052 { case REG_SZ:
10481053 return PL_unify_wchars(Value, PL_ATOM,
1049 len/sizeof(wchar_t)-1, (wchar_t*)data);
1054 len/sizeof(wchar_t)-1, data.wchars);
10501055 case REG_DWORD:
1051 return PL_unify_integer(Value, *((DWORD *)data));
1056 return PL_unify_integer(Value, data.dword);
10521057 default:
10531058 warning("get_registry_value/2: Unknown registery-type: %d", type);
10541059 fail;
10801085 static void
10811086 setStacksFromKey(HKEY key)
10821087 { DWORD type;
1083 BYTE data[128];
1088 union
1089 { BYTE bytes[128];
1090 DWORD dword;
1091 } data;
10841092 DWORD len = sizeof(data);
10851093 const struct regdef *rd;
10861094
10871095 for(rd = regdefs; rd->name; rd++)
1088 { if ( RegQueryValueEx(key, rd->name, NULL, &type, data, &len) ==
1096 { if ( RegQueryValueEx(key, rd->name, NULL, &type, data.bytes, &len) ==
10891097 ERROR_SUCCESS &&
10901098 type == REG_DWORD )
1091 { DWORD v = *((DWORD *)data);
1099 { DWORD v = data.dword;
10921100
10931101 *rd->address = (int)v;
10941102 }
10871087
10881088 static int activePredicate(const Definition *defs, const Definition def);
10891089
1090 void
1090 static void
10911091 gcClauseRefs(void)
10921092 { ClauseRef cref;
10931093
13961396 unallocClause(Clause c)
13971397 { ATOMIC_SUB(&GD->statistics.codes, c->code_size);
13981398 ATOMIC_DEC(&GD->statistics.clauses);
1399
1400 #ifdef ALLOC_DEBUG
1401 #define ALLOC_FREE_MAGIC 0xFB
1402 size_t size = sizeofClause(c->code_size);
1403 memset(c, ALLOC_FREE_MAGIC, size);
1404 #endif
1405
13991406 PL_free(c);
14001407 }
14011408
1409
1410 #ifdef O_DEBUG_ATOMGC
1411 void
1412 unregister_atom_clause(atom_t a)
1413 { PL_unregister_atom(a);
1414 }
1415
1416 void
1417 register_atom_clause(atom_t a)
1418 { PL_register_atom(a);
1419 }
1420 #endif
14021421
14031422 void
14041423 freeClause(Clause c)
14051424 {
14061425 #ifdef O_ATOMGC
1426 #ifdef O_DEBUG_ATOMGC
1427 forAtomsInClause(c, unregister_atom_clause);
1428 #else
14071429 forAtomsInClause(c, PL_unregister_atom);
1430 #endif
14081431 #endif
14091432
14101433 if ( true(c, DBREF_CLAUSE) ) /* will be freed from symbol */
14331456 }
14341457
14351458
1459 static void
1460 freeLingeringDefinition(Definition def, DirtyDefInfo ddi)
1461 { linger_list *c;
1462
1463 do
1464 { if ( !(c=def->lingering) )
1465 return;
1466 if ( ddi->oldest_generation != GEN_MAX )
1467 return;
1468 } while( !COMPARE_AND_SWAP(&def->lingering, c, NULL) );
1469
1470 free_lingering(c);
1471 }
1472
1473
14361474 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14371475 cleanDefinition()
14381476 This function has two tasks. If the predicate needs to be rehashed,
14471485 may change due to an assert. Now that we are in the locked region we can
14481486 search for the real previous, using the one from cleanDefinition() as
14491487 the likely candidate.
1488
1489 The `ddi->oldest_generation` contains the latest marked generation that
1490 was found or GEN_MAX if the predicate is not active. The `start`
1491 generation contains the generation when pl_garbage_collect_clauses() was
1492 started.
14501493 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14511494
14521495 static int mustCleanDefinition(const Definition def);
14701513
14711514
14721515 static size_t
1473 cleanDefinition(Definition def, gen_t marked, gen_t start, int *rcp)
1516 cleanDefinition(Definition def, DirtyDefInfo ddi, gen_t start, int *rcp)
14741517 { GET_LD
14751518 size_t removed = 0;
1519 gen_t marked = ddi->oldest_generation;
14761520 gen_t active = start < marked ? start : marked;
14771521
14781522 DEBUG(CHK_SECURE, checkDefinition(def));
15191563 cleanClauseIndexes(def, active);
15201564 UNLOCKDEF(def);
15211565 }
1522 if ( marked == GEN_MAX && def->lingering )
1523 free_lingering(&def->lingering);
1566 freeLingeringDefinition(def, ddi);
15241567 release_def(def);
15251568
15261569 DEBUG(CHK_SECURE, checkDefinition(def));
20892132
20902133 if ( false(def, P_FOREIGN) &&
20912134 def->impl.clauses.erased_clauses > 0 )
2092 { size_t del = cleanDefinition(def,
2093 ddi->oldest_generation,
2094 start_gen, &rc);
2135 { size_t del = cleanDefinition(def, ddi, start_gen, &rc);
20952136
20962137 removed += del;
20972138 DEBUG(MSG_CGC_PRED,
24942535 fail; /* no clauses */
24952536 }
24962537
2497 startCritical;
24982538 enterDefinition(def); /* reference the predicate */
2499 pushPredicateAccess(def, generationFrame(environment_frame));
2539 setGenerationFrameVal(environment_frame, pushPredicateAccess(def));
25002540 cref = firstClause(argv, environment_frame, def, &ctxbuf.chp PASS_LD);
25012541 if ( !cref )
25022542 { popPredicateAccess(def);
25032543 leaveDefinition(def);
2504 if ( !endCritical )
2505 fail;
25062544 fail;
25072545 }
25082546
25122550 } else
25132551 { ctx = CTX_PTR;
25142552 cref = nextClause(&ctx->chp, argv, environment_frame, ctx->def);
2515 startCritical;
25162553 }
25172554
25182555 if ( !(fid = PL_open_foreign_frame()) )
25192556 { free_retract_context(ctx PASS_LD);
2520 endCritical;
25212557 return FALSE;
25222558 }
2523
2524 /* ctx->cref is the first candidate; next is the next one */
25252559
25262560 while( cref )
25272561 { if ( decompile(cref->value.clause, cl, 0) )
25282562 { if ( retractClauseDefinition(ctx->def, cref->value.clause) ||
25292563 CTX_CNTRL != FRG_FIRST_CALL )
2530 { if ( !endCritical )
2531 { free_retract_context(ctx PASS_LD);
2532 PL_close_foreign_frame(fid);
2533
2534 return FALSE;
2535 }
2536
2537 if ( !ctx->chp.cref ) /* deterministic last one */
2564 { if ( !ctx->chp.cref ) /* deterministic last one */
25382565 { free_retract_context(ctx PASS_LD);
25392566 PL_close_foreign_frame(fid);
25402567 return TRUE;
25462573 PL_close_foreign_frame(fid);
25472574 ForeignRedoPtr(ctx);
25482575 } else
2549 { setGenerationFrame(environment_frame, global_generation());
2576 { setGenerationFrame(environment_frame);
25502577 }
25512578 }
25522579
2580 if ( PL_exception(0) )
2581 break;
2582
25532583 PL_rewind_foreign_frame(fid);
2554
25552584 cref = nextClause(&ctx->chp, argv, environment_frame, ctx->def);
25562585 }
25572586
25582587 PL_close_foreign_frame(fid);
25592588 free_retract_context(ctx PASS_LD);
2560 endCritical;
25612589 return FALSE;
25622590 }
25632591 }
26272655
26282656 startCritical;
26292657 enterDefinition(def);
2630 pushPredicateAccess(def, generationFrame(environment_frame));
2658 setGenerationFrameVal(environment_frame, pushPredicateAccess(def));
26312659 fid = PL_open_foreign_frame();
26322660
26332661 DEBUG(CHK_SECURE, checkDefinition(def));
33053333 if ( def->module != copy_def->module )
33063334 remoduleClause(copy, def->module, copy_def->module);
33073335 #ifdef O_ATOMGC
3336 #ifdef O_DEBUG_ATOMGC
3337 forAtomsInClause(copy, register_atom_clause);
3338 #else
33083339 forAtomsInClause(copy, PL_register_atom);
3340 #endif
33093341 #endif
33103342 assertProcedure(to, copy, CL_END PASS_LD);
33113343 }
33593391 unsigned int nc, indexed = 0;
33603392 ClauseRef cref;
33613393 unsigned int erased = 0;
3394 Definition old;
33623395
33633396 /* check basic clause list */
3364 acquire_def(def);
3397 acquire_def2(def, old);
33653398 for(nc=0, cref = def->impl.clauses.first_clause; cref; cref=cref->next)
33663399 { Clause clause = cref->value.clause;
33673400
33733406 { erased++;
33743407 }
33753408 }
3376 release_def(def);
3409 release_def2(def, old);
33773410
33783411 assert(nc == def->impl.clauses.number_of_clauses);
33793412 assert(erased == def->impl.clauses.erased_clauses);
781781 }
782782 default:
783783 assert(0);
784 return FALSE;
784785 }
785786 }
786787
17481749 }
17491750
17501751
1752 #ifdef O_DEBUG_ATOMGC
1753 void
1754 unregister_atom_rec(atom_t a)
1755 { PL_unregister_atom(a);
1756 }
1757 #endif
1758
1759
17511760 bool
17521761 freeRecord(Record record)
17531762 { if ( true(record, R_DUPLICATE) && --record->references > 0 )
17611770
17621771 ci.base = ci.data = dataRecord(record);
17631772 ci.version_map = NULL;
1773 #ifdef O_DEBUG_ATOMGC
1774 scanAtomsRecord(&ci, unregister_atom_rec);
1775 #else
17641776 scanAtomsRecord(&ci, PL_unregister_atom);
1777 #endif
17651778 assert(ci.data == addPointer(record, record->size));
17661779 }
17671780 #endif
398398 #undef LD
399399 #define LD LOCAL_LD
400400
401 static int
402 is_fatal_signal(int sig)
403 { switch(sig)
404 {
405 #ifdef SIGFPE
406 case SIGFPE:
407 #endif
408 #ifdef SIGSEGV
409 case SIGSEGV:
410 #if defined(SIGBUS) && SIGBUS != SIGSEGV
411 case SIGBUS:
412 #endif
413 #endif
414 #ifdef SIGILL
415 case SIGILL:
416 #endif
417 #ifdef SIGSYS
418 case SIGSYS:
419 #endif
420 return TRUE;
421 }
422
423 return FALSE;
424 }
425
426
401427 void
402428 dispatch_signal(int sig, int sync)
403429 { GET_LD
416442 }
417443
418444 DEBUG(MSG_SIGNAL,
419 Sdprintf("Got signal %d in thread %d (=%d) %s\n",
420 sig, LD->thread.info->pl_tid,
421 pthread_self(),
422 sync ? " (sync)" : " (async)"));
445 { const pl_wchar_t *name = L"";
446 int tid = LD->thread.info->pl_tid;
447 atom_t alias;
448
449 if ( PL_get_thread_alias(tid, &alias) )
450 name = PL_atom_wchars(alias, NULL);
451 Sdprintf("Got signal %d in thread %d (%Ws) %s\n",
452 sig, tid, name,
453 sync ? " (sync)" : " (async)");
454 });
423455 #else
424456 DEBUG(MSG_SIGNAL,
425457 Sdprintf("Got signal %d %s\n",
435467 saved_current_signal = LD->signal.current;
436468 saved_sync = LD->signal.is_sync;
437469
438 switch(sig)
439 { case SIGFPE:
440 case SIGSEGV:
441 #if defined(SIGBUS) && SIGBUS != SIGSEGV
442 case SIGBUS:
443 #endif
444 if ( sig == LD->signal.current )
445 sysError("Recursively received fatal signal %d", sig);
446 }
470 if ( is_fatal_signal(sig) && sig == LD->signal.current )
471 sysError("Recursively received fatal signal %d", sig);
447472
448473 if ( gc_status.active && sig < SIG_PROLOG_OFFSET )
449474 { fatalError("Received signal %d (%s) while in %ld-th garbage collection",
450475 sig, signal_name(sig), gc_status.collections);
451476 }
452477
453 if ( LD->critical || (true(sh, PLSIG_SYNC) && !sync) )
478 if ( (LD->critical || (true(sh, PLSIG_SYNC) && !sync)) &&
479 !is_fatal_signal(sig) )
454480 { PL_raise(sig); /* wait for better times! */
455481 return;
456482 }
457483
458484 if ( !(fid = PL_open_signal_foreign_frame(sync)) )
459 { PL_raise(sig); /* no space; wait */
485 { if ( is_fatal_signal(sig) )
486 sigCrashHandler(sig); /* should not return */
487 PL_raise(sig); /* no space; wait */
460488 return;
461489 }
462490
532560
533561 if ( !sync )
534562 unblockGC(0 PASS_LD);
563
564 /* we cannot return. First try */
565 /* longjmp. If that fails, crash */
566 if ( is_fatal_signal(sig) )
567 { if ( exception_term )
568 { PL_rethrow();
569 sigCrashHandler(sig);
570 }
571 exit(4);
572 }
535573 }
536574
537575
10611099 }
10621100
10631101
1102 #ifdef SIG_ALERT
1103 static
1104 PRED_IMPL("prolog_alert_signal", 2, prolog_alert_signal, 0)
1105 { PRED_LD
1106 const char *sname = signal_name(GD->signals.sig_alert);
1107 int rc;
1108
1109 if ( strcmp(sname, "unknown") == 0 )
1110 rc = PL_unify_integer(A1, GD->signals.sig_alert);
1111 else
1112 rc = PL_unify_atom_chars(A1, sname);
1113
1114 if ( rc )
1115 { if ( PL_compare(A1,A2) == CMP_EQUAL )
1116 { return TRUE;
1117 } else
1118 { int new;
1119
1120 if ( (PL_get_integer(A2, &new) && new == 0) ||
1121 PL_get_signum_ex(A2, &new) )
1122 { if ( GD->signals.sig_alert )
1123 { unprepareSignal(GD->signals.sig_alert);
1124 GD->signals.sig_alert = 0;
1125 }
1126 if ( new )
1127 { GD->signals.sig_alert = new;
1128 PL_signal(GD->signals.sig_alert|PL_SIGNOFRAME, alert_handler);
1129 }
1130
1131 return TRUE;
1132 }
1133 }
1134 }
1135
1136 return FALSE;
1137 }
1138 #endif
1139
1140
10641141 int
10651142 endCritical__LD(ARG1_LD)
10661143 { if ( exception_term )
17561833 *******************************/
17571834
17581835 BeginPredDefs(setup)
1759 PRED_DEF("$set_prolog_stack", 4, set_prolog_stack, 0)
1760 PRED_DEF("$on_signal", 4, on_signal, 0)
1761 PRED_DEF("trim_stacks", 0, trim_stacks, 0)
1836 PRED_DEF("$set_prolog_stack", 4, set_prolog_stack, 0)
1837 PRED_DEF("$on_signal", 4, on_signal, 0)
1838 PRED_DEF("trim_stacks", 0, trim_stacks, 0)
1839 #ifdef SIG_ALERT
1840 PRED_DEF("prolog_alert_signal", 2, prolog_alert_signal, 0)
1841 #endif
17621842 EndPredDefs
895895 if ( true(def, P_THREAD_LOCAL|P_FOREIGN) )
896896 { set(reload, P_NO_CLAUSES);
897897 } else if ( isRedefinedProcedure(proc, global_generation()) )
898 { reload->generation = global_generation();
899 pushPredicateAccess(def, reload->generation);
898 { reload->generation = pushPredicateAccess(def);
900899 acquire_def(def);
901900 reload->current_clause = find_clause(def->impl.clauses.first_clause,
902901 reload->generation);
502502 if ( PL_unify_stream(A2, s) )
503503 return TRUE;
504504 Sclose(s);
505 }
506
507 PL_free_text(&text);
505 } else
506 { PL_free_text(&text);
507 }
508508 }
509509
510510 return FALSE;
3838 /* compile clean with glibc. Can */
3939 /* this do any harm? */
4040
41 #if defined(__MINGW32__)
41 #if __MINGW32__
4242 #define __try
4343 #define __except(_) if (0)
4444 #define __finally
45 #endif
46
47 #ifdef __MINGW32__
4845 #include <winsock2.h>
4946 #include <windows.h>
5047 #include <errno.h> /* must be before pl-incl.h */
5653 #include "pl-prof.h"
5754 #include <stdio.h>
5855 #include <math.h>
56
57 #if __MINGW32__ /* this is a stub. Should be detected */
58 #undef HAVE_PTHREAD_SETNAME_NP /* in configure.ac */
59 #endif
60
5961 #ifdef O_PLMT
6062
6163 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
293295 COUNT_MUTEX_INITIALIZER("L_LOCALE"),
294296 COUNT_MUTEX_INITIALIZER("L_SORTR"),
295297 COUNT_MUTEX_INITIALIZER("L_UMUTEX"),
296 COUNT_MUTEX_INITIALIZER("L_INIT_ATOMS")
298 COUNT_MUTEX_INITIALIZER("L_INIT_ATOMS"),
299 COUNT_MUTEX_INITIALIZER("L_CGCGEN")
297300 #ifdef __WINDOWS__
298301 , COUNT_MUTEX_INITIALIZER("L_DDE")
299302 , COUNT_MUTEX_INITIALIZER("L_CSTACK")
393396 lc = (cm == &_PL_mutexes[L_MUTEX] ? 1 : 0);
394397
395398 if ( cm->lock_count > lc )
396 Sdprintf(" LOCKS: %d\n", cm->count - lc);
399 Sdprintf(" LOCKS: %d\n", cm->lock_count - lc);
397400 else
398401 Sdprintf("\n");
399402 }
920923 { info->thread_data->exit_requested = TRUE;
921924
922925 if ( info->cancel )
923 { if ( (*info->cancel)(i) == TRUE )
924 break; /* done so */
926 { switch( (*info->cancel)(i) )
927 { case PL_THREAD_CANCEL_FAILED:
928 break;
929 case PL_THREAD_CANCEL_MUST_JOIN:
930 canceled++;
931 /*FALLTHROUGH*/
932 case PL_THREAD_CANCEL_JOINED:
933 continue;
934 }
925935 }
926936
927937 if ( PL_thread_raise(i, SIG_PLABORT) )
21272137
21282138
21292139 static int
2130 unify_thread_status(term_t status, PL_thread_info_t *info, int lock)
2140 unify_thread_status(term_t status, PL_thread_info_t *info,
2141 thread_status stat, int lock)
21312142 { GET_LD
21322143
2133 switch(info->status)
2144 switch(stat)
21342145 { case PL_THREAD_CREATED:
21352146 case PL_THREAD_RUNNING:
21362147 { int rc = FALSE;
23052316 void *r;
23062317 word rval;
23072318 int rc;
2319 thread_status status;
23082320
23092321 term_t thread = A1;
23102322 term_t retcode = A2;
23362348 ERR_SYSCALL, "pthread_join");
23372349 }
23382350
2339 rval = unify_thread_status(retcode, info, FALSE);
2340
2341 free_thread_info(info);
2351 status = info->status;
2352 if ( !THREAD_STATUS_INVALID(status) &&
2353 COMPARE_AND_SWAP(&info->status, status, PL_THREAD_JOINED) )
2354 { rval = unify_thread_status(retcode, info, status, FALSE);
2355
2356 free_thread_info(info);
2357 } else
2358 { rval = PL_error(NULL, 0, "already joined",
2359 ERR_EXISTENCE, ATOM_thread, thread);
2360 }
23422361
23432362 return rval;
23442363 }
24292448 thread_status_propery(PL_thread_info_t *info, term_t prop ARG_LD)
24302449 { IGNORE_LD
24312450
2432 return unify_thread_status(prop, info, TRUE);
2451 return unify_thread_status(prop, info, info->status, TRUE);
24332452 }
24342453
24352454 static int
53955414 static int GC_id = 0;
53965415 static int GC_starting = 0;
53975416
5417 static rc_cancel cancelGCThread(int tid);
5418
53985419 static void *
53995420 GCmain(void *closure)
54005421 { PL_thread_attr_t attrs = {0};
54205441 pred = PL_predicate("$gc", 0, "system");
54215442
54225443 GC_id = PL_thread_self();
5444 info->cancel = cancelGCThread;
54235445 rc = PL_call_predicate(NULL, PL_Q_PASS_EXCEPTION, pred, 0);
54245446 GC_id = 0;
54255447
54415463 pthread_t thr;
54425464 int rc;
54435465
5466 if ( !GD->thread.gc.initialized )
5467 { pthread_mutex_init(&GD->thread.gc.mutex, NULL);
5468 pthread_cond_init(&GD->thread.gc.cond, NULL);
5469 GD->thread.gc.initialized = TRUE;
5470 }
5471
54445472 pthread_attr_init(&attr);
54455473 rc = pthread_create(&thr, &attr, GCmain, NULL);
54465474 pthread_attr_destroy(&attr);
54535481 }
54545482
54555483
5484 static int
5485 gc_sig_request(int sig)
5486 { switch(sig)
5487 { case SIG_ATOM_GC:
5488 return GCREQUEST_AGC;
5489 case SIG_CLAUSE_GC:
5490 return GCREQUEST_CGC;
5491 case SIG_PLABORT:
5492 return GCREQUEST_ABORT;
5493 default:
5494 assert(0);
5495 return 0;
5496 }
5497 }
5498
5499
5500 static int
5501 signalGCThreadCond(int tid, int sig)
5502 { (void)tid;
5503
5504 pthread_mutex_lock(&GD->thread.gc.mutex);
5505 GD->thread.gc.requests |= gc_sig_request(sig);
5506 pthread_cond_signal(&GD->thread.gc.cond);
5507 pthread_mutex_unlock(&GD->thread.gc.mutex);
5508
5509 return TRUE;
5510 }
5511
5512
54565513 int
54575514 signalGCThread(int sig)
54585515 { GET_LD
54615518 if ( truePrologFlag(PLFLAG_GCTHREAD) &&
54625519 !GD->bootsession &&
54635520 (tid = GCthread()) > 0 &&
5464 PL_thread_raise(tid, sig) )
5521 signalGCThreadCond(tid, sig) )
54655522 return TRUE;
54665523
54675524 return raiseSignal(LD, sig);
5525 }
5526
5527
5528 static int
5529 gc_running(void)
5530 { int tid;
5531 PL_thread_info_t *info;
5532
5533 if ( (tid=GC_id) > 0 && (info = GD->thread.threads[tid]) &&
5534 info->status == PL_THREAD_RUNNING )
5535 return tid;
5536
5537 return 0;
54685538 }
54695539
54705540
54715541 int
54725542 isSignalledGCThread(int sig ARG_LD)
5543 { if ( gc_running() )
5544 { return (GD->thread.gc.requests & gc_sig_request(sig)) != 0;
5545 } else
5546 { return PL_pending(sig);
5547 }
5548 }
5549
5550
5551 static
5552 PRED_IMPL("$gc_wait", 1, gc_wait, 0)
5553 { PRED_LD
5554
5555 for(;;)
5556 { unsigned int req;
5557 atom_t action;
5558
5559 pthread_mutex_lock(&GD->thread.gc.mutex);
5560 req = GD->thread.gc.requests;
5561 if ( !req )
5562 pthread_cond_wait(&GD->thread.gc.cond, &GD->thread.gc.mutex);
5563 pthread_mutex_unlock(&GD->thread.gc.mutex);
5564
5565 if ( (req&GCREQUEST_ABORT) )
5566 action = ATOM_abort;
5567 else if ( (req&GCREQUEST_AGC) )
5568 action = ATOM_garbage_collect_atoms;
5569 else if ( (req&GCREQUEST_CGC) )
5570 action = ATOM_garbage_collect_clauses;
5571 else
5572 continue;
5573
5574 return PL_unify_atom(A1, action);
5575 }
5576 }
5577
5578
5579 static
5580 PRED_IMPL("$gc_clear", 1, gc_clear, 0)
5581 { PRED_LD
5582 atom_t action;
5583
5584 if ( PL_get_atom_ex(A1, &action) )
5585 { unsigned int mask;
5586
5587 if ( action == ATOM_garbage_collect_atoms )
5588 mask = GCREQUEST_AGC;
5589 else if ( action == ATOM_garbage_collect_clauses )
5590 mask = GCREQUEST_CGC;
5591 else
5592 return PL_domain_error("action", A1);
5593
5594 pthread_mutex_lock(&GD->thread.gc.mutex);
5595 GD->thread.gc.requests &= ~mask;
5596 pthread_mutex_unlock(&GD->thread.gc.mutex);
5597
5598 return TRUE;
5599 }
5600
5601 return FALSE;
5602 }
5603
5604
5605 static rc_cancel
5606 cancelGCThread(int tid)
5607 { signalGCThreadCond(tid, SIG_PLABORT);
5608 return PL_THREAD_CANCEL_MUST_JOIN;
5609 }
5610
5611 static
5612 PRED_IMPL("$gc_stop", 0, gc_stop, 0)
54735613 { int tid;
5474 PL_thread_info_t *info;
5475 int rc;
5476
5477 if ( (tid=GC_id) > 0 && (info = GD->thread.threads[tid]) &&
5478 info->status == PL_THREAD_RUNNING )
5479 { PL_local_data_t *ld = acquire_ldata(info);
5480
5481 rc = PL_pending__LD(sig, ld);
5482 release_ldata(ld);
5483 } else
5484 { rc = PL_pending(sig);
5485 }
5486
5487 return rc;
5614
5615 if ( (tid=gc_running()) )
5616 return cancelGCThread(tid) != PL_THREAD_CANCEL_FAILED;
5617
5618 return FALSE;
54885619 }
54895620
54905621
65216652 *******************************/
65226653
65236654 #ifdef O_PLMT
6655
65246656 static void
65256657 init_predicate_references(PL_local_data_t *ld)
65266658 { definition_refs *refs = &ld->predicate_references;
65506682 }
65516683 #endif /*O_PLMT*/
65526684
6553 int
6554 pushPredicateAccess__LD(Definition def, gen_t gen ARG_LD)
6685 void
6686 cgcActivatePredicate__LD(Definition def, gen_t gen ARG_LD)
6687 { DirtyDefInfo ddi;
6688
6689 if ( (ddi=lookupHTable(GD->procedures.dirty, def)) )
6690 { if ( gen < ddi->oldest_generation )
6691 set_min_generation(ddi, gen);
6692 }
6693 }
6694
6695
6696 gen_t
6697 pushPredicateAccess__LD(Definition def ARG_LD)
65556698 { definition_refs *refs = &LD->predicate_references;
65566699 definition_ref *dref;
65576700 size_t top = refs->top+1;
65686711 outOfCore();
65696712
65706713 memset(newblock, 0, bs*sizeof(definition_ref));
6571 refs->blocks[idx] = newblock-bs;
6714 if ( !COMPARE_AND_SWAP(&refs->blocks[idx], NULL, newblock-bs) )
6715 PL_free(newblock);
65726716 }
65736717
65746718 enterDefinition(def); /* probably not needed in the end */
65756719 dref = &refs->blocks[idx][top];
65766720 dref->predicate = def;
6577 dref->generation = gen;
6721 do
6722 { dref->generation = global_generation();
6723 if ( unlikely(GD->clauses.cgc_active) )
6724 cgcActivatePredicate__LD(def, dref->generation PASS_LD);
6725 } while ( dref->generation != global_generation() );
65786726
65796727 refs->top = top;
65806728
6581 return TRUE;
6729 return dref->generation;
65826730 }
65836731
65846732
66826830
66836831 for(i=1; i<=refs->top; i++)
66846832 { int idx = MSB(i);
6685 DirtyDefInfo ddi;
6686 definition_ref dref = refs->blocks[idx][i];
6687
6688 if ( is_pointer_like(dref.predicate) &&
6689 (ddi=lookupHTable(GD->procedures.dirty, dref.predicate)) )
6690 { if ( dref.generation < ddi->oldest_generation )
6691 ddi->oldest_generation = dref.generation;
6692 }
6833 volatile definition_ref *drefp = &refs->blocks[idx][i];
6834 definition_ref dref = *drefp; /* struct copy */
6835
6836 if ( is_pointer_like(dref.predicate) )
6837 cgcActivatePredicate__LD(dref.predicate, dref.generation PASS_LD);
66936838 }
66946839 }
66956840
67326877 PRED_DEF("mutex_statistics", 0, mutex_statistics, 0)
67336878
67346879 PRED_DEF("$thread_local_clause_count", 3, thread_local_clause_count, 0)
6880 PRED_DEF("$gc_wait", 1, gc_wait, 0)
6881 PRED_DEF("$gc_clear", 1, gc_clear, 0)
6882 PRED_DEF("$gc_stop", 0, gc_stop, 0)
67356883 #endif
67366884 EndPredDefs
4646 #define SIG_ALERT SIGUSR2
4747 #endif
4848
49 #define GCREQUEST_AGC 0x01 /* GD->thread.gc.requests */
50 #define GCREQUEST_CGC 0x02
51 #define GCREQUEST_ABORT 0x04
52
4953 typedef enum
5054 { LDATA_IDLE = 0,
5155 LDATA_SIGNALLED,
5357 LDATA_ANSWERED
5458 } ldata_status_t;
5559
56 #define THREAD_STATUS_INVALID(s) ((s) == PL_THREAD_UNUSED || \
57 (s) == PL_THREAD_RESERVED)
60 #define THREAD_STATUS_INVALID(s) ((int)(s) < (int)PL_THREAD_RUNNING)
5861
5962 typedef enum
6063 { PL_THREAD_UNUSED = 0, /* no thread on this slot */
64 PL_THREAD_RESERVED, /* allocated but not yet created */
65 PL_THREAD_JOINED, /* just joined */
66 /* normal states */
6167 PL_THREAD_RUNNING, /* a normally running one */
6268 PL_THREAD_EXITED, /* died with thread_exit/1 */
6369 PL_THREAD_SUCCEEDED, /* finished with Yes */
6470 PL_THREAD_FAILED, /* finished with No */
6571 PL_THREAD_EXCEPTION, /* finished with exception */
6672 PL_THREAD_NOMEM, /* couldn't start due no-memory */
67 PL_THREAD_RESERVED, /* allocated but not yet created */
6873 PL_THREAD_CREATED, /* just created */
6974 } thread_status;
7075
8792 size_t global_size;
8893 size_t trail_size;
8994 size_t stack_size; /* system (C-) stack */
90 int (*cancel)(int id); /* cancel function */
95 rc_cancel (*cancel)(int id); /* cancel function */
9196 unsigned short open_count; /* for PL_thread_detach_engine() */
9297 unsigned detached : 1; /* detached thread */
9398 unsigned debug : 1; /* thread can be debugged */
212217 #define L_SORTR 22
213218 #define L_UMUTEX 23
214219 #define L_INIT_ATOMS 24
220 #define L_CGCGEN 25
215221 #ifdef __WINDOWS__
216 #define L_DDE 25
217 #define L_CSTACK 26
222 #define L_DDE 26
223 #define L_CSTACK 27
218224 #endif
219225
220226 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
442448 COMMON(Definition*) predicates_in_use(void);
443449 COMMON(int) pl_functor_table_in_use(FunctorTable functor_table);
444450 COMMON(int) pl_kvs_in_use(KVS kvs);
445 COMMON(int) pushPredicateAccess__LD(Definition def, gen_t gen ARG_LD);
451 COMMON(void) cgcActivatePredicate__LD(Definition def, gen_t gen ARG_LD);
452 COMMON(gen_t) pushPredicateAccess__LD(Definition def ARG_LD);
446453 COMMON(void) popPredicateAccess__LD(Definition def ARG_LD);
447454 COMMON(size_t) popNPredicateAccess__LD(size_t n ARG_LD);
448455 COMMON(void) markAccessedPredicates(PL_local_data_t *ld);
8484
8585
8686 static inline bool
87 push_start_args(argPairs *a, Word left, Word right, int arity) /* plural */
88 { a->work.left = left;
89 a->work.right = right;
90 a->work.arg = 0;
91 a->work.arity = arity;
92
93 return TRUE;
94 }
95
96 static inline bool
8797 push_args(argPairs *a, Word left, Word right, int arity) /* plural */
8898 { if ( !pushSegStack(&a->stack, a->work, aWork) )
8999 return FALSE;
90100
91 a->work.left = left;
92 a->work.right = right;
93 a->work.arg = 0;
94 a->work.arity = arity;
95
96 return TRUE;
101 return push_start_args(a, left, right, arity);
97102 }
98103
99104 static inline bool
100105 next_arg(argPairs *a, Word *lp, Word *rp) /* singular (not plural !) */
101 { if ( emptySegStack(&a->stack) )
102 return FALSE;
106 { while( a->work.arg >= a->work.arity)
107 { if ( !popSegStack(&a->stack, &a->work, aWork) )
108 return FALSE;
109 }
103110
104111 *lp = a->work.left;
105112 *rp = a->work.right;
106113
107 a->work.arg++ ;
108 a->work.left++ ;
109 a->work.right++ ;
110
111 if ( a->work.arg >= a->work.arity )
112 { if ( !popSegStack(&a->stack, &a->work, aWork) )
113 return FALSE;
114 }
114 a->work.arg++;
115 a->work.left++;
116 a->work.right++;
115117
116118 return TRUE;
117119 }
470472 init_agenda(&agenda);
471473
472474 if ( (add_node_buffer(VARIANT_BUFFER, &new) >= 0) &&
473 (push_args(&agenda, p1, p2, 1) >=0) )
475 (push_start_args(&agenda, p1, p2, 1) >=0) )
474476 rval = variant(&agenda, VARIANT_BUFFER PASS_LD);
475477 else
476478 rval = MEMORY_OVERFLOW;
16491649 procedure and deallocate our temporary version if threading is not used.
16501650 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16511651 NFR->parent = FR;
1652 NFR->predicate = DEF; /* TBD */
1652 setFramePredicate(NFR, DEF); /* TBD */
16531653 NFR->programPointer = PC; /* save PC in child */
16541654 NFR->clause = NULL; /* for save atom-gc */
16551655 environment_frame = FR = NFR; /* open the frame */
16691669
16701670 depart_continue:
16711671 retry_continue:
1672 setGenerationFrame(FR, global_generation());
1672 setGenerationFrame(FR);
16731673 #ifdef O_PROFILE
16741674 FR->prof_node = NULL;
16751675 #endif
16931693 DEF = getProcDefinedDefinition(DEF PASS_LD); /* see (*) above */
16941694 LOAD_REGISTERS(qid);
16951695 if ( FR->predicate != DEF ) /* auto imported/loaded */
1696 { FR->predicate = DEF;
1697 setGenerationFrame(FR, global_generation());
1696 { setFramePredicate(FR, DEF);
1697 setGenerationFrame(FR);
16981698 }
16991699 SAVE_REGISTERS(qid);
17001700 handleSignals(PASS_LD1);
17521752 DEF = getProcDefinedDefinition(DEF PASS_LD);
17531753 LOAD_REGISTERS(qid);
17541754 if ( FR->predicate != DEF ) /* auto imported/loaded */
1755 { FR->predicate = DEF;
1755 { setFramePredicate(FR, DEF);
1756 setGenerationFrame(FR);
17561757 #ifdef O_PROFILE
17571758 if ( FR->prof_node )
17581759 profSetHandle(FR->prof_node, DEF);
18301831 if ( true(DEF, HIDE_CHILDS) )
18311832 set(FR, FR_HIDE_CHILDS);
18321833
1833 FR->predicate = DEF;
1834 setFramePredicate(FR, DEF);
18341835 copyFrameArguments(lTop, FR, DEF->functor->arity PASS_LD);
18351836
18361837 END_PROF();
27322733 DEF = getProcDefinedDefinition(DEF PASS_LD);
27332734 LOAD_REGISTERS(qid);
27342735
2735 FR->predicate = DEF;
2736 setFramePredicate(FR, DEF);
2737 setGenerationFrame(FR);
27362738 #ifdef O_PROFILE
27372739 if ( FR->prof_node )
27382740 profSetHandle(FR->prof_node, DEF);
27412743 #ifdef O_PLMT
27422744 } else if ( true(DEF, P_THREAD_LOCAL) )
27432745 { DEF = getProcDefinition__LD(DEF PASS_LD);
2744 FR->predicate = DEF;
2746 setFramePredicate(FR, DEF);
2747 setGenerationFrame(FR);
27452748 #endif
27462749 }
27472750
28852888 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
28862889
28872890 VMI(S_THREAD_LOCAL, 0, 0, ())
2888 { FR->predicate = DEF = getProcDefinition__LD(DEF PASS_LD);
2891 { DEF = getProcDefinition__LD(DEF PASS_LD);
2892 setFramePredicate(FR, DEF);
2893 setGenerationFrame(FR);
28892894
28902895 assert(DEF->codes);
28912896 PC = DEF->codes;
47914796 #ifdef O_LOGICAL_UPDATE
47924797 cl->generation.erased = ~(gen_t)0;
47934798 cl->generation.created = global_generation();
4794 setGenerationFrame(NFR, global_generation());
4799 setGenerationFrame(NFR);
47954800 #endif
47964801 PC = cl->codes;
47974802
49154920 if ( !DEF->impl.any && false(DEF, PROC_DEFINED) )
49164921 { term_t nref = consTermRef(NFR);
49174922 NFR->parent = FR;
4918 NFR->predicate = DEF; /* TBD */
4923 setFramePredicate(NFR, DEF); /* TBD */
4924 setGenerationFrame(NFR);
49194925 NFR->programPointer = PC; /* save PC in child */
49204926 NFR->clause = NULL;
49214927 #ifdef O_PROFILE
24272427 fr->prof_node = NULL; /* true? */
24282428 #endif
24292429 Mark(qf->choice.mark);
2430 setGenerationFrame(fr, global_generation());
2430 setGenerationFrame(fr);
24312431 /* context module */
24322432 if ( true(def, P_TRANSPARENT) )
24332433 { if ( ctx )
17301730 statistics(agc, AGC0),
17311731 statistics(agc_gained, Gained0),
17321732 forall(between(0, UpTo, X), atom_concat(foobar, X, _)),
1733 ( between(1, 6, X),
1733 ( between(1, 8, X),
17341734 ( statistics(agc, AGC1),
17351735 AGC is AGC1 - AGC0,
17361736 AGC > 5,
17431743 fail
17441744 )
17451745 -> true
1746 ; statistics(agc_gained, Gained1),
1747 Gained is Gained1 - Gained0,
1748 format(user_error,
1749 '~NWarning: gc(agc-2): reclaimed only ~D atoms~n',
1750 [Gained])
17461751 )
17471752 ; true % no atom-gc
17481753 ).
21402145 *******************************/
21412146
21422147 io(tell-1) :-
2143 tell(test_x),
2148 current_prolog_flag(pid, P),
2149 atom_concat(test_x_, P, TestX),
2150 atom_concat(test_y_, P, TestY),
2151 tell(TestX),
21442152 format('~q.~n', [a]),
2145 tell(test_y),
2153 tell(TestY),
21462154 format('~q.~n', [b]),
2147 tell(test_x),
2155 tell(TestX),
21482156 format('~q.~n', [c]),
21492157 told,
2150 tell(test_y),
2158 tell(TestY),
21512159 told,
2152 read_file_to_terms(test_x, [a,c], []),
2153 read_file_to_terms(test_y, [b], []),
2154 delete_file(test_x),
2155 delete_file(test_y),
2156 \+ stream_property(_, file_name(test_x)),
2157 \+ stream_property(_, file_name(test_y)).
2160 read_file_to_terms(TestX, [a,c], []),
2161 read_file_to_terms(TestY, [b], []),
2162 delete_file(TestX),
2163 delete_file(TestY),
2164 \+ stream_property(_, file_name(TestX)),
2165 \+ stream_property(_, file_name(TestY)).
21582166
21592167 io(tell-2) :-
2168 current_prolog_flag(pid, P),
2169 atom_concat(test_y_, P, TestY),
21602170 current_output(OrgOut),
21612171 open_null_stream(Out),
21622172 set_output(Out),
21632173 write(Out, x),
2164 telling(Old), tell(test_y),
2174 telling(Old), tell(TestY),
21652175 format('~q.~n', [b]),
21662176 told, tell(Old),
21672177 write(Out, y),
21692179 character_count(Out, 2),
21702180 close(Out),
21712181 set_output(OrgOut),
2172 read_file_to_terms(test_y, [b], []),
2173 delete_file(test_y).
2182 read_file_to_terms(TestY, [b], []),
2183 delete_file(TestY).
21742184
21752185
21762186 /*******************************
21902200 popen(cat-1) :-
21912201 ( current_prolog_flag(windows, true)
21922202 -> true % there is *no* cmd.exe command like cat!?
2193 ; File = 'pltest.txt',
2203 ; current_prolog_flag(pid, Pid),
2204 format(atom(File), 'pltest-~w.txt', [Pid]),
21942205 Text = 'Hello World',
21952206 Cmd = cat,
21962207 atomic_list_concat([Cmd, ' > ', File], Command),
23392350 exists_directory(CWD),
23402351 same_file(CWD, '.').
23412352 file(absfile-2) :- % canonicaliseDir() caching issues
2342 X = 'pl-test-x',
2343 Y = 'pl-test-y',
2353 current_prolog_flag(pid, Pid),
2354 atom_concat('pl-test-x-', Pid, X),
2355 atom_concat('pl-test-y-', Pid, Y),
23442356 atom_concat(X, '/file', XF),
23452357 atom_concat(Y, '/file', YF),
23462358 make_directory(X),
23702382 * UNICODE FILENAMES *
23712383 *******************************/
23722384
2385 unicode_file_name(Name) :-
2386 current_prolog_flag(pid, Pid),
2387 atom_codes(Name0, [1074, 1086, 1079, 1076, 1091, 1093, 1072]),
2388 atomic_list_concat([Name0, -, Pid], Name).
2389
23732390 unicode_file(mkdir-1) :- % create Cyrillic directory
2374 atom_codes(Dir, [1074, 1086, 1079, 1076, 1091, 1093, 1072]),
2391 unicode_file_name(Dir),
23752392 catch(delete_directory(Dir), _, true),
23762393 make_directory(Dir),
23772394 exists_directory(Dir),
23812398 same_file(O2, Dir),
23822399 delete_directory(Dir).
23832400 unicode_file(file-1) :- % create Cyrillic file
2384 atom_codes(File, [1074, 1086, 1079, 1076, 1091, 1093, 1072]),
2401 unicode_file_name(File),
23852402 Term = hello(world),
23862403 catch(delete_file(File), _, true),
23872404 open(File, write, Out),
23942411 Read =@= Term,
23952412 delete_file(File).
23962413 unicode_file(absfile-1) :-
2397 atom_codes(File, [1074, 1086, 1079, 1076, 1091, 1093, 1072]),
2414 unicode_file_name(File),
23982415 absolute_file_name(File, Path),
23992416 file_directory_name(Path, Dir),
24002417 same_file(Dir, '.'),
24742491 * CONSULT *
24752492 *******************************/
24762493
2477 mk_include :-
2478 open('test_included.pl', write, Out1),
2494 mk_include(Include, Included) :-
2495 current_prolog_flag(pid, Pid),
2496 format(atom(Included), 'test_included_~w.pl', [Pid]),
2497 format(atom(Include), 'test_include_~w.pl', [Pid]),
2498 file_name_extension(Base, pl, Included),
2499 open(Included, write, Out1),
24792500 format(Out1, ':- dynamic foo/1.\n', []),
24802501 close(Out1),
24812502
2482 open('test_include.pl', write, Out2),
2483 format(Out2, ':- include(test_included).\n', []),
2503 open(Include, write, Out2),
2504 format(Out2, ':- include(~w).\n', [Base]),
24842505 format(Out2, 'foo(a).\n', []),
24852506 close(Out2).
24862507
24872508 load_program(include-1) :-
2488 mk_include,
2509 mk_include(Include, Included),
24892510 abolish(foo, 1),
2490 load_files(test_include, [silent(true)]),
2511 load_files(Include, [silent(true)]),
24912512 assert(foo(b)),
24922513 findall(X, retract(foo(X)), [a,b]),
2493 delete_file('test_included.pl'),
2494 delete_file('test_include.pl').
2514 delete_file(Included),
2515 delete_file(Include).
24952516
24962517
24972518 /*******************************
10181018 /*******************************
10191019 * WINDOW PROCEDURE *
10201020 *******************************/
1021
1022 #undef MAKEPOINTS
1023
1024 static inline POINTS
1025 MAKEPOINTS(LPARAM lParam)
1026 { union
1027 { LPARAM p;
1028 POINTS pt;
1029 } u;
1030
1031 u.p = lParam;
1032 return u.pt;
1033 }
1034
10211035
10221036 static void
10231037 rlc_destroy(RlcData b)