Show
Ignore:
Timestamp:
12/14/07 09:51:08 (13 months ago)
Author:
pmoura
Message:

Minor improvements to the "complements" example.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/complements/complements.lgt

    r3954 r3965  
    1616    complements(employee)). 
    1717 
    18     :- initialization(define_events(before, employee, _, _, employee)). % implies that the category must be loaded *after* 
    19                                                                         % the object due to the define_events/5 goal 
     18    % add a simple logging functionality by defining a "before" event and  
     19    % the corresponding event handler (implies that the category must be  
     20    % loaded *after* the object due to the define_events/5 goal): 
     21 
     22    :- initialization(define_events(before, employee, _, _, employee)). 
     23 
    2024    before(_, Message, Sender) :- 
    2125        write('Received message '), writeq(Message), write(' from '), writeq(Sender), nl. 
    2226 
    23     :- public(predicates/0). 
     27    % add a new method to the object: 
    2428 
    25     predicates :-   % list only public predicates 
    26         this(This), 
    27         setof(Predicate, This::current_predicate(Predicate), Predicates), 
    28         write(Predicates), nl.  
     29    :- public(predicates/1). 
     30 
     31    predicates(Predicates) :- 
     32        setof(Predicate, ::current_predicate(Predicate), Predicates).  
    2933 
    3034:- end_category.