View source with raw comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  1985-2017, University of Amsterdam
    7                              VU University Amsterdam
    8    All rights reserved.
    9
   10    Redistribution and use in source and binary forms, with or without
   11    modification, are permitted provided that the following conditions
   12    are met:
   13
   14    1. Redistributions of source code must retain the above copyright
   15       notice, this list of conditions and the following disclaimer.
   16
   17    2. Redistributions in binary form must reproduce the above copyright
   18       notice, this list of conditions and the following disclaimer in
   19       the documentation and/or other materials provided with the
   20       distribution.
   21
   22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   23    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   24    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   25    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   26    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   27    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   28    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   29    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   30    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   32    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   33    POSSIBILITY OF SUCH DAMAGE.
   34*/
   35
   36:- module(backward_compatibility,
   37          [ '$arch'/2,
   38            '$version'/1,
   39            '$home'/1,
   40            '$argv'/1,
   41            '$set_prompt'/1,
   42            '$strip_module'/3,
   43            '$declare_module'/3,
   44            '$module'/2,
   45            at_initialization/1,        % :Goal
   46            displayq/1,
   47            displayq/2,
   48            sformat/2,                  % -String, +Fmt
   49            sformat/3,                  % -String, +Fmt, +Args
   50            concat/3,
   51            concat_atom/2,              % +List, -Atom
   52            concat_atom/3,              % +List, +Sep, -Atom
   53            '$apropos_match'/2,         % +Needle, +Hashstack
   54            read_clause/1,              % -Term
   55            read_clause/2,              % +Stream, -Term
   56            read_variables/2,           % -Term, -VariableNames
   57            read_variables/3,           % +Stream, -Term, -VariableNames
   58            read_pending_input/3,       % +Stream, -List, ?Tail
   59            feature/2,
   60            set_feature/2,
   61            substring/4,
   62            string_to_list/2,           % ?String, ?Codes
   63            string_to_atom/2,           % ?String, ?Atom
   64            flush/0,
   65            write_ln/1,                 % +Term
   66            proper_list/1,              % @Term
   67            free_variables/2,           % +Term, -Variables
   68            subsumes_chk/2,             % @Generic, @Specific
   69            subsumes/2,                 % @Generic, @Specific
   70            hash_term/2,                % +Term, -Hash
   71            checklist/2,                % :Goal, +List
   72            sublist/3,                  % :Goal, +List, -Sublist
   73            sumlist/2,                  % +List, -Sum
   74            convert_time/2,             % +Stamp, -String
   75            convert_time/8,             % +String, -YMDmhs.ms
   76            'C'/3,                      % +List, -Head, -Tail
   77            current_thread/2,           % ?Thread, ?Status
   78            current_mutex/3,            % ?Mutex, ?Owner, ?Count
   79            message_queue_size/2,       % +Queue, -TermsWaiting
   80            lock_predicate/2,           % +Name, +Arity
   81            unlock_predicate/2,         % +Name, +Arity
   82            current_module/2,           % ?Module, ?File
   83            export_list/2,              % +Module, -Exports
   84            setup_and_call_cleanup/3,   % :Setup, :Goal, :Cleanup
   85            setup_and_call_cleanup/4,   % :Setup, :Goal, ?Catcher, :Cleanup
   86            merge/3,                    % +List1, +List2, -Union
   87            merge_set/3,                % +Set1, +Set2, -Union
   88            (index)/1,                  % :Head
   89            hash/1,                     % :PI
   90            set_base_module/1,          % :Base
   91            eval_license/0,
   92            trie_insert_new/3,		% +Trie, +Term, -Node
   93            thread_at_exit/1            % :Goal
   94          ]).   95:- use_module(apply,  [maplist/2]).   96:- use_module(system, [lock_predicate/1, unlock_predicate/1]).   97:- use_module(lists,  [sum_list/2]).   98
   99:- meta_predicate
  100    at_initialization(0),
  101    setup_and_call_cleanup(0,0,0),
  102    setup_and_call_cleanup(0,0,?,0),
  103    checklist(1, +),
  104    sublist(1, +, ?),
  105    index(:),
  106    hash(:),
  107    set_base_module(:),
  108    thread_at_exit(0).

Backward compatibility

This library defines predicates that used to exist in older version of SWI-Prolog, but are considered obsolete as there functionality is neatly covered by new features. Most often, these constructs are superceeded by ISO-standard compliant predicates.

Please also note the existence of quintus.pl and edinburgh.pl for more compatibility predicates.

See also
-
gxref/0 can be used to find files that import from library(backcomp) and thus reply on deprecated features. */
 $arch(-Architecture, -Version) is det
deprecated
- use current_prolog_flag(arch, Architecture)
  128'$arch'(Arch, unknown) :-
  129    current_prolog_flag(arch, Arch).
 $version(Version:integer) is det
deprecated
- use current_prolog_flag(version, Version)
  135'$version'(Version) :-
  136    current_prolog_flag(version, Version).
 $home(-SWIPrologDir) is det
See also
- file_search_path/2, absolute_file_name/3, The Prolog home directory is available through the alias swi.
deprecated
- use current_prolog_flag(home, SWIPrologDir)
  144'$home'(Home) :-
  145    current_prolog_flag(home, Home).
 $argv(-Argv:list) is det
deprecated
- use current_prolog_flag(os_argv, Argv) or current_prolog_flag(argv, Argv)
  152'$argv'(Argv) :-
  153    current_prolog_flag(os_argv, Argv).
 $set_prompt(+Prompt) is det
Set the prompt for the toplevel
deprecated
- use set_prolog_flag(toplevel_prompt, Prompt).
  161'$set_prompt'(Prompt) :-
  162    (   is_list(Prompt)
  163    ->  Prompt0 = Prompt
  164    ;   atom_codes(Prompt, Prompt0)
  165    ),
  166    maplist(percent_to_tilde, Prompt0, Prompt1),
  167    atom_codes(Atom, Prompt1),
  168    set_prolog_flag(toplevel_prompt, Atom).
  169
  170percent_to_tilde(0'%, 0'~) :- !.
  171percent_to_tilde(X, X).
 displayq(@Term) is det
 displayq(+Stream, @Term) is det
Write term ignoring operators and quote atoms.
deprecated
- Use write_term/3 or write_canonical/2.
  181displayq(Term) :-
  182    write_term(Term, [ignore_ops(true),quoted(true)]).
  183displayq(Stream, Term) :-
  184    write_term(Stream, Term, [ignore_ops(true),quoted(true)]).
 sformat(-String, +Format, +Args) is det
 sformat(-String, +Format) is det
deprecated
- Use format/3 as format(string(String), ...)
  192:- module_transparent sformat/2, sformat/3.  193
  194sformat(String, Format) :-
  195    format(string(String), Format, []).
  196sformat(String, Format, Arguments) :-
  197    format(string(String), Format, Arguments).
 concat(+Atom1, +Atom2, -Atom) is det
deprecated
- Use ISO atom_concat/3
  203concat(A, B, C) :-
  204    atom_concat(A, B, C).
 concat_atom(+List, -Atom) is det
Concatenate a list of atomic values to an atom.
deprecated
- Use atomic_list_concat/2 as proposed by the prolog commons initiative.
  213concat_atom([A, B], C) :-
  214    !,
  215    atom_concat(A, B, C).
  216concat_atom(L, Atom) :-
  217    atomic_list_concat(L, Atom).
 concat_atom(+List, +Seperator, -Atom) is det
Concatenate a list of atomic values to an atom, inserting Seperator between each consecutive elements.
deprecated
- Use atomic_list_concat/3 as proposed by the prolog commons initiative.
  228concat_atom(L, Sep, Atom) :-
  229    atomic_list_concat(L, Sep, Atom).
 $apropos_match(+Needle, +Haystack) is semidet
True if Needle is a sub atom of Haystack. Ignores the case of Haystack.
  236'$apropos_match'(Needle, Haystack) :-
  237    sub_atom_icasechk(Haystack, _, Needle).
 read_clause(-Term) is det
deprecated
- Use read_clause/3 or read_term/3.
  243read_clause(Term) :-
  244    read_clause(current_input, Term).
 read_clause(+Stream, -Term) is det
deprecated
- Use read_clause/3 or read_term/3.
  250read_clause(Stream, Term) :-
  251    read_clause(Stream, Term, [process_comment(false)]).
 read_variables(-Term, -Bindings) is det
 read_variables(+In:stream, -Term, -Bindings) is det
deprecated
- Use ISO read_term/2 or read_term/3.
  258read_variables(Term, Vars) :-
  259    read_term(Term, [variable_names(Vars)]).
  260
  261read_variables(Stream, Term, Vars) :-
  262    read_term(Stream, Term, [variable_names(Vars)]).
 read_pending_input(+Stream, -Codes, ?Tail) is det
deprecated
- Use read_pending_codes/3.
  268read_pending_input(Stream, Codes, Tail) :-
  269    read_pending_codes(Stream, Codes, Tail).
 feature(?Key, ?Value) is nondet
 set_feature(+Key, @Term) is det
Control Prolog flags.
deprecated
- Use ISO current_prolog_flag/2 and set_prolog_flag/2.
  278feature(Key, Value) :-
  279    current_prolog_flag(Key, Value).
  280
  281set_feature(Key, Value) :-
  282    set_prolog_flag(Key, Value).
 substring(+String, +Offset, +Length, -Sub)
Predecessor of sub_string using 1-based Offset.
deprecated
- Use sub_string/5.
  290substring(String, Offset, Length, Sub) :-
  291    Offset0 is Offset - 1,
  292    sub_string(String, Offset0, Length, _After, Sub).
 string_to_list(?String, ?Codes) is det
Bi-directional conversion between a string and a list of character codes.
deprecated
- Use string_codes/2.
  301string_to_list(String, Codes) :-
  302    string_codes(String, Codes).
 string_to_atom(?String, ?Atom) is det
Bi-directional conversion between string and atom.
deprecated
- Use atom_string/2. Note that the order of the arguments is reversed.
  311string_to_atom(Atom, String) :-
  312    atom_string(String, Atom).
 flush is det
deprecated
- use ISO flush_output/0.
  318flush :-
  319    flush_output.
 write_ln(X) is det
deprecated
- Use writeln(X).
  325write_ln(X) :-
  326    writeln(X).
 proper_list(+List)
Old SWI-Prolog predicate to check for a list that really ends in a []. There is not much use for the quick is_list, as in most cases you want to process the list element-by-element anyway.
deprecated
- Use ISO is_list/1.
  336proper_list(List) :-
  337    is_list(List).
 free_variables(+Term, -Variables)
Return a list of unbound variables in Term. The name term_variables/2 is more widely used.
deprecated
- Use term_variables/2.
  346free_variables(Term, Variables) :-
  347    term_variables(Term, Variables).
 subsumes_chk(@Generic, @Specific)
True if Generic can be made equivalent to Specific without changing Specific.
deprecated
- Replace by subsumes_term/2.
  356subsumes_chk(Generic, Specific) :-
  357    subsumes_term(Generic, Specific).
 subsumes(+Generic, @Specific)
True if Generic is unified to Specific without changing Specific.
deprecated
- It turns out that calls to this predicate almost always should have used subsumes_term/2. Also the name is misleading. In case this is really needed, one is adviced to follow subsumes_term/2 with an explicit unification.
  369subsumes(Generic, Specific) :-
  370    subsumes_term(Generic, Specific),
  371    Generic = Specific.
 hash_term(+Term, -Hash) is det
If Term is ground, Hash is unified to an integer representing a hash for Term. Otherwise Hash is left unbound.
deprecated
- Use term_hash/2.
  380hash_term(Term, Hash) :-
  381    term_hash(Term, Hash).
 checklist(:Goal, +List)
deprecated
- Use maplist/2
  388checklist(Goal, List) :-
  389    maplist(Goal, List).
 sublist(:Goal, +List1, ?List2)
Succeeds if List2 unifies with a list holding those terms for wich call(Goal, Elem) succeeds.
deprecated
- Use include/3 from library(apply)
Compatibility
- DEC10 library
  399sublist(_, [], []) :- !.
  400sublist(Goal, [H|T], Sub) :-
  401    call(Goal, H),
  402    !,
  403    Sub = [H|R],
  404    sublist(Goal, T, R).
  405sublist(Goal, [_|T], R) :-
  406    sublist(Goal, T, R).
 sumlist(+List, -Sum) is det
True when Sum is the list of all numbers in List.
deprecated
- Use sum_list/2
  414sumlist(List, Sum) :-
  415    sum_list(List, Sum).
 $strip_module(+Term, -Module, -Plain)
This used to be an internal predicate. It was added to the XPCE compatibility library without $ and since then used at many places. From 5.4.1 onwards strip_module/3 is built-in and the $ variation is added here for compatibility.
deprecated
- Use strip_module/3.
  426:- module_transparent
  427    '$strip_module'/3.  428
  429'$strip_module'(Term, Module, Plain) :-
  430    strip_module(Term, Module, Plain).
 $module(-OldTypeIn, +NewTypeIn)
  434'$module'(OldTypeIn, NewTypeIn) :-
  435    '$current_typein_module'(OldTypeIn),
  436    '$set_typein_module'(NewTypeIn).
 $declare_module(Module, File, Line)
Used in triple20 particle library. Should use a public interface
  442'$declare_module'(Module, File, Line) :-
  443    '$declare_module'(Module, user, user, File, Line, false).
 at_initialization(:Goal) is det
Register goal only to be run if a saved state is restored.
deprecated
- Use initialization(Goal, restore)
  452at_initialization(Goal) :-
  453    initialization(Goal, restore).
 convert_time(+Stamp, -String)
Convert a time-stamp as obtained though get_time/1 into a textual representation using the C-library function ctime(). The value is returned as a SWI-Prolog string object (see section 4.23). See also convert_time/8.
deprecated
- Use format_time/3.
  465convert_time(Stamp, String) :-
  466    format_time(string(String), '%+', Stamp).
 convert_time(+Stamp, -Y, -Mon, -Day, -Hour, -Min, -Sec, -MilliSec)
Convert a time stamp, provided by get_time/1, time_file/2, etc. Year is unified with the year, Month with the month number (January is 1), Day with the day of the month (starting with 1), Hour with the hour of the day (0--23), Minute with the minute (0--59). Second with the second (0--59) and MilliSecond with the milliseconds (0--999). Note that the latter might not be accurate or might always be 0, depending on the timing capabilities of the system. See also convert_time/2.
deprecated
- Use stamp_date_time/3.
  481convert_time(Stamp, Y, Mon, Day, Hour, Min, Sec, MilliSec) :-
  482    stamp_date_time(Stamp,
  483                    date(Y, Mon, Day,
  484                         Hour, Min, FSec,
  485                         _, _, _),
  486                    local),
  487    Sec is integer(float_integer_part(FSec)),
  488    MilliSec is integer(float_fractional_part(FSec)*1000).
 C(?List, ?Head, ?Tail) is det
Used to be generated by DCG. Some people appear to be using in in normal code too.
deprecated
- Do not use in normal code; DCG no longer generates it.
  497'C'([H|T], H, T).
 current_thread(?Thread, ?Status) is nondet
deprecated
- Replaced by thread_property/2
  504current_thread(Thread, Status) :-
  505    nonvar(Thread),
  506    !,
  507    catch(thread_property(Thread, status(Status)),
  508          error(existence_error(thread, _), _),
  509          fail).
  510current_thread(Thread, Status) :-
  511    thread_property(Thread, status(Status)).
 current_mutex(?Mutex, ?Owner, ?Count) is nondet
deprecated
- Replaced by mutex_property/2
  517current_mutex(Mutex, Owner, Count) :-
  518    nonvar(Mutex),
  519    !,
  520    catch(mutex_property(Mutex, status(Status)),
  521          error(existence_error(mutex, _), _),
  522          fail),
  523    map_mutex_status(Status, Owner, Count).
  524current_mutex(Mutex, Owner, Count) :-
  525    mutex_property(Mutex, status(Status)),
  526    map_mutex_status(Status, Owner, Count).
  527
  528map_mutex_status(unlocked, [], 0).
  529map_mutex_status(locked(Owner, Count), Owner, Count).
 message_queue_size(+Queue, -Size) is det
True if Queue holds Size terms.
deprecated
- Please use message_queue_property(Queue, Size)
  538message_queue_size(Queue, Size) :-
  539    message_queue_property(Queue, size(Size)).
 lock_predicate(+Name, +Arity) is det
 unlock_predicate(+Name, +Arity) is det
deprecated
- see lock_predicate/1 and unlock_predicate/1.
  546:- module_transparent
  547    lock_predicate/2,
  548    unlock_predicate/2.  549
  550lock_predicate(Name, Arity) :-
  551    lock_predicate(Name/Arity).
  552
  553unlock_predicate(Name, Arity) :-
  554    unlock_predicate(Name/Arity).
 current_module(?Module, ?File) is nondet
True if Module is a module loaded from File.
deprecated
- Use module_property(Module, file(File))
  562current_module(Module, File) :-
  563    module_property(Module, file(File)).
 export_list(+Module, -List) is det
Module exports the predicates of List.
deprecated
- Use module_property(Module, exports(List))
  571export_list(Module, List) :-
  572    module_property(Module, exports(List)).
 setup_and_call_cleanup(:Setup, :Goal, :Cleanup)
Call Cleanup once after Goal is finished.
deprecated
- Use setup_call_cleanup/3.
  580setup_and_call_cleanup(Setup, Goal, Cleanup) :-
  581    setup_call_cleanup(Setup, Goal, Cleanup).
 setup_and_call_cleanup(:Setup, :Goal, Catcher, :Cleanup)
Call Cleanup once after Goal is finished, with Catcher unified to the reason
deprecated
- Use setup_call_cleanup/3.
  590setup_and_call_cleanup(Setup, Goal, Catcher, Cleanup) :-
  591    setup_call_catcher_cleanup(Setup, Goal, Catcher,Cleanup).
 merge_set(+Set1, +Set2, -Set3)
Merge the ordered sets Set1 and Set2 into a new ordered set without duplicates.
deprecated
- New code should use ord_union/3 from library(ordsets)
  601merge_set([], L, L) :- !.
  602merge_set(L, [], L) :- !.
  603merge_set([H1|T1], [H2|T2], [H1|R]) :- H1 @< H2, !, merge_set(T1, [H2|T2], R).
  604merge_set([H1|T1], [H2|T2], [H2|R]) :- H1 @> H2, !, merge_set([H1|T1], T2, R).
  605merge_set([H1|T1], [H2|T2], [H1|R]) :- H1 == H2,    merge_set(T1, T2, R).
 merge(+List1, +List2, -List3)
Merge the ordered sets List1 and List2 into a new ordered list. Duplicates are not removed and their order is maintained.
deprecated
- The name of this predicate is far too general for a rather specific function.
  616merge([], L, L) :- !.
  617merge(L, [], L) :- !.
  618merge([H1|T1], [H2|T2], [H|R]) :-
  619    (   H1 @=< H2
  620    ->  H = H1,
  621        merge(T1, [H2|T2], R)
  622    ;   H = H2,
  623        merge([H1|T1], T2, R)
  624    ).
 index(:Head) is det
Prepare the predicate indicated by Head for multi-argument indexing.
deprecated
- As of version 5.11.29, SWI-Prolog performs just-in-time indexing on all arguments.
  634index(Head) :-
  635    print_message(warning, decl_no_effect(index(Head))).
 hash(:PredInd) is det
Demands PredInd to be indexed using a hash-table. This is handled dynamically.
  642hash(PI) :-
  643    print_message(warning, decl_no_effect(hash(PI))).
 set_base_module(:Base) is det
Set the default module from whic we inherit.
deprecated
- Equivalent to set_module(base(Base)).
  651set_base_module(M:Base) :-
  652    set_module(M:base(Base)).
 eval_license is det
deprecated
- Equivalent to license/0
  658eval_license :-
  659    license.
 trie_insert_new(+Trie, +Term, -Handle) is semidet
deprecated
- use trie_insert/4.
  665trie_insert_new(Trie, Term, Handle) :-
  666    trie_insert(Trie, Term, [], Handle).
 thread_at_exit(:Goal) is det
Register Goal to be called when the calling thread exits. @deprecated use prolog_listen(this_thread_exit, Goal)
  673thread_at_exit(Goal) :-
  674    prolog_listen(this_thread_exit, Goal)