Changeset 4508 for trunk/examples

Show
Ignore:
Timestamp:
10/15/08 17:36:18 (3 months ago)
Author:
pmoura
Message:

Improved the documentation of the "complements" and "hooks" examples.

Location:
trunk/examples
Files:
4 modified

Legend:

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

    r4274 r4508  
    11 
     2% setup the object employee as a monitor for any message sent to itself: 
    23:- initialization(define_events(before, employee, _, _, employee)). 
    34 
     
    1516 
    1617:- category(logging, 
    17     implements(monitoring), 
    18     complements(employee)). 
     18    implements(monitoring),     % built-in protocol for event handler methods 
     19    complements(employee)).     % add the category predicates to the employee object 
    1920 
     21    % define a "before" event handler for the complemented object: 
    2022    before(_, Message, Sender) :- 
    2123        write('Received message '), writeq(Message), write(' from '), writeq(Sender), nl. 
    2224 
    23     % add a new method to the object: 
    24  
     25    % add a new method to the complemented object: 
    2526    :- public(predicates/1). 
    2627 
  • trunk/examples/complements/SCRIPT.txt

    r4507 r4508  
    2121Category = logging, 
    2222Object = employee. 
    23  
    2423yes  
    2524 
     
    3130 
    3231Name = john 
    33  
    3432yes 
    3533 
     
    4139 
    4240Predicates = [after/3, age/1, before/3, name/1, predicates/1, salary/1] 
    43  
    4441yes 
    4542 
     
    5047Property = declared_in(logging) ; 
    5148Property = defined_in(logging) 
    52  
    5349yes 
  • trunk/examples/hooks/hooks.lgt

    r3967 r4508  
    11 
    22:- object(hook, 
    3     implements(expanding)). 
     3    implements(expanding)).     % built-in protocol for term and goal expansion methods 
    44 
    55    :- info([ 
     
    99        comment is 'Example of an object defining compiler hook predicates.']). 
    1010 
     11    % the term_expansion/2 predicate is called for every term in the source file: 
    1112    term_expansion((:- info(Original)), [(:- info(New))]) :- 
    1213        expand_author(Original, New). 
    1314 
    14     goal_expansion(write(Term), (numbervars(Term, 0, _), write_term(Term, [quoted(true), numbervars(true)]))). 
     15    % the goal_expansion/2 predicate is called for every goal in predicate clause 
     16    % bodies in the source file: 
     17    goal_expansion( 
     18        write(Term), 
     19        (numbervars(Term, 0, _), write_term(Term, [quoted(true), numbervars(true)]))). 
    1520 
    1621    expand_author([], []). 
  • trunk/examples/hooks/SCRIPT.txt

    r4507 r4508  
    1616 
    1717% check the XML documenting file generated for "object" 
    18 % for the results of term_expansion/2 calls 
     18% for the results of the term_expansion/2 calls 
    1919 
    2020