home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / plbin.zip / pl / library / system.pl < prev    next >
Text File  |  1992-05-26  |  2KB  |  58 lines

  1. /*  system.pl,v 1.1.1.1 1992/05/26 11:51:38 jan Exp
  2.  
  3.     Copyright (c) 1990 Jan Wielemaker. All rights reserved.
  4.     jan@swi.psy.uva.nl
  5.  
  6.     Purpose: Manipulate system predicates and system mode
  7. */
  8.  
  9. :- module(system,
  10.     [ lock_predicate/2
  11.     , unlock_predicate/2
  12.     , system_mode/1
  13.     , system_module/0
  14.     ]).
  15.  
  16. :- style_check(+dollar).
  17.  
  18. %    system_mode(+OnOff)
  19. %    Switch the system into system or user mode.  When in system mode,
  20. %    system predicates loose most of their special properties, so it
  21. %    becomes possible to trace and even redefine them.  Use the latter
  22. %    with care as the system predicates call one another.  This should
  23. %    once be fixed by defining all of them in a module ($system), so
  24. %    the user can savely remove them from module user.
  25.  
  26. system_mode(on) :-
  27.     style_check(+dollar).
  28. system_mode(off) :-
  29.     style_check(-dollar).
  30.  
  31. %    system_module
  32. %    Any predicate defined after this declaraction uptill the end of
  33. %    the file will become a system predicate. Normally invoked by a
  34. %    directive immediately following the module declaration.
  35.  
  36. system_module :-
  37.     system_mode(on).
  38.  
  39. :- module_transparent
  40.     lock_predicate/2,
  41.     unlock_predicate/2.
  42.  
  43. %    lock_predicate(+Name, Arity)
  44. %    Transform a predicate into a system predicate. 
  45.  
  46. lock_predicate(Spec, Arity) :-
  47.     $strip_module(Spec, Module, Name),
  48.     functor(Head, Name, Arity ),
  49.     $predicate_attribute(Module:Head, system, 1).
  50.  
  51. %    unlock_predicate(+Name, Arity)
  52. %    Transform a system predicate into a normal system predicate.
  53.  
  54. unlock_predicate(Spec, Arity) :-
  55.     $strip_module(Spec, Module, Name),
  56.     functor(Head, Name, Arity ),
  57.     $predicate_attribute(Module:Head, system, 0).
  58.