Changeset 4508 for trunk/examples
- Timestamp:
- 10/15/08 17:36:18 (3 months ago)
- Location:
- trunk/examples
- Files:
-
- 4 modified
-
complements/complements.lgt (modified) (2 diffs)
-
complements/SCRIPT.txt (modified) (4 diffs)
-
hooks/hooks.lgt (modified) (2 diffs)
-
hooks/SCRIPT.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/complements/complements.lgt
r4274 r4508 1 1 2 % setup the object employee as a monitor for any message sent to itself: 2 3 :- initialization(define_events(before, employee, _, _, employee)). 3 4 … … 15 16 16 17 :- 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 19 20 21 % define a "before" event handler for the complemented object: 20 22 before(_, Message, Sender) :- 21 23 write('Received message '), writeq(Message), write(' from '), writeq(Sender), nl. 22 24 23 % add a new method to the object: 24 25 % add a new method to the complemented object: 25 26 :- public(predicates/1). 26 27 -
trunk/examples/complements/SCRIPT.txt
r4507 r4508 21 21 Category = logging, 22 22 Object = employee. 23 24 23 yes 25 24 … … 31 30 32 31 Name = john 33 34 32 yes 35 33 … … 41 39 42 40 Predicates = [after/3, age/1, before/3, name/1, predicates/1, salary/1] 43 44 41 yes 45 42 … … 50 47 Property = declared_in(logging) ; 51 48 Property = defined_in(logging) 52 53 49 yes -
trunk/examples/hooks/hooks.lgt
r3967 r4508 1 1 2 2 :- object(hook, 3 implements(expanding)). 3 implements(expanding)). % built-in protocol for term and goal expansion methods 4 4 5 5 :- info([ … … 9 9 comment is 'Example of an object defining compiler hook predicates.']). 10 10 11 % the term_expansion/2 predicate is called for every term in the source file: 11 12 term_expansion((:- info(Original)), [(:- info(New))]) :- 12 13 expand_author(Original, New). 13 14 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)]))). 15 20 16 21 expand_author([], []). -
trunk/examples/hooks/SCRIPT.txt
r4507 r4508 16 16 17 17 % check the XML documenting file generated for "object" 18 % for the results of t erm_expansion/2 calls18 % for the results of the term_expansion/2 calls 19 19 20 20
