View source with formatted 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)  1999-2019, University of Amsterdam
    7                              VU University Amsterdam
    8                              CWI, Amsterdam
    9    All rights reserved.
   10
   11    Redistribution and use in source and binary forms, with or without
   12    modification, are permitted provided that the following conditions
   13    are met:
   14
   15    1. Redistributions of source code must retain the above copyright
   16       notice, this list of conditions and the following disclaimer.
   17
   18    2. Redistributions in binary form must reproduce the above copyright
   19       notice, this list of conditions and the following disclaimer in
   20       the documentation and/or other materials provided with the
   21       distribution.
   22
   23    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   24    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   25    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   26    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   27    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   28    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   29    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   30    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   31    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   33    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   34    POSSIBILITY OF SUCH DAMAGE.
   35*/
   36
   37:- module(edinburgh,
   38          [ display/1,
   39            display/2,
   40            unknown/2,
   41            reconsult/1,
   42            debug/0,
   43            nodebug/0,
   44            fileerrors/2
   45          ]).   46
   47:- meta_predicate
   48    unknown(:, :),
   49    reconsult(:).   50
   51
   52/** <module> Some traditional Edinburgh predicates
   53
   54This module defines  predicates  from   `traditional  Edinburgh  Prolog'
   55(Dec10 and C-Prolog) whose functionality  has   been  replaced  by (ISO)
   56Standard Prolog.
   57*/
   58
   59                 /*******************************
   60                 *            TERM I/O          *
   61                 *******************************/
   62
   63%!  display(+Term) is det.
   64%!  display(+Stream, +Term) is det.
   65%
   66%   Write a term, ignoring operators and  special syntax constructs such
   67%   as _brace terms_ (`{a}`) and lists (`[a,b,c]`). Currently does print
   68%   dicts using the dict notation.
   69%
   70%   @see  write_canonical/2.  SWI-Prolog's  write_canonical/2,  however,
   71%   prints lists using list notation to   reduce  incompatibility due to
   72%   the modified list functor  (`'[|]'`  rather   than  `.`)  and reduce
   73%   memory usage while parsing lists.
   74
   75display(Term) :-
   76    display(current_output, Term).
   77display(Stream, Term) :-
   78    write_term(Stream, Term,
   79               [ quoted(true),
   80                 ignore_ops(true),
   81                 no_lists(true),
   82                 brace_terms(false)
   83               ]).
   84
   85%!  unknown(-Old, +New) is det.
   86%
   87%   Edinburgh Prolog predicate for dealing dealing with undefined
   88%   procedures
   89
   90unknown(M:Old, M:New) :-
   91    current_prolog_flag(M:unknown, O),
   92    map_unknown(O, Old),
   93    map_unknown(N, New),
   94    !,
   95    set_prolog_flag(M:unknown, N).
   96
   97map_unknown(error,   trace).
   98map_unknown(warning, trace).
   99map_unknown(fail,    fail).
  100
  101%!  reconsult(+FileOrList) is det.
  102%
  103%   Load source file(s), wiping the  old content first. SWI-Prolog's
  104%   consult/1 and related predicates always do this.
  105%
  106%   @deprecated The Edinburgh Prolog consult/reconsult distinction
  107%   is no longer used throughout most of the Prolog world.
  108
  109reconsult(File) :-
  110    consult(File).
  111
  112%!  debug is det.
  113%!  nodebug is det.
  114%
  115%   Switch on/off debug mode.  Note that nodebug/0 has been defined
  116%   such that is is not traced itself.
  117
  118debug   :- set_prolog_flag(debug, true).
  119nodebug :- notrace, set_prolog_flag(debug, false).
  120
  121:- '$hide'(nodebug/0).  122
  123%!  fileerrors(-Old, +New) is det.
  124%
  125%   Query and change the  fileerrors  flag.   Default  it  is set to
  126%   =true=, causing file operations to   raise an exception. Setting
  127%   it to =false=  activates  the  old   Edinburgh  mode  of  silent
  128%   failure.
  129%
  130%   @deprecated     New code should use catch/3 to handle file errors
  131%                   silently
  132
  133fileerrors(Old, New) :-
  134    current_prolog_flag(fileerrors, Old),
  135    (   Old == New
  136    ->  true
  137    ;   set_prolog_flag(fileerrors, New)
  138    )