| 1 | ================================================================ |
|---|
| 2 | Logtalk - Open source object-oriented logic programming language |
|---|
| 3 | Release 2.35.0 |
|---|
| 4 | |
|---|
| 5 | Copyright (c) 1998-2009 Paulo Moura. All Rights Reserved. |
|---|
| 6 | Logtalk is free software. You can redistribute it and/or modify |
|---|
| 7 | it under the terms of the "Artistic License 2.0" as published by |
|---|
| 8 | The Perl Foundation. Consult the "LICENSE.txt" file for details. |
|---|
| 9 | ================================================================ |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | % start by loading the example: |
|---|
| 13 | |
|---|
| 14 | | ?- logtalk_load(complements(loader)). |
|---|
| 15 | ... |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | % find categories that complement objects: |
|---|
| 19 | |
|---|
| 20 | | ?- complements_object(Category, Object). |
|---|
| 21 | Category = logging, |
|---|
| 22 | Object = employee. |
|---|
| 23 | yes |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | % turn event support on for messages sent at the command-line |
|---|
| 27 | % (i.e. for messages sent from the pseudo-object "user"): |
|---|
| 28 | |
|---|
| 29 | | ?- set_logtalk_flag(events, on). |
|---|
| 30 | |
|---|
| 31 | yes |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | % use the event handler defined in the "logging" category for the object "employee": |
|---|
| 35 | |
|---|
| 36 | | ?- employee::name(Name). |
|---|
| 37 | Received message name(_16) from user |
|---|
| 38 | |
|---|
| 39 | Name = john |
|---|
| 40 | yes |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | % check the protocol of the object "employee": |
|---|
| 44 | |
|---|
| 45 | | ?- employee::predicates(Predicates). |
|---|
| 46 | Received message predicates(_G180) from user |
|---|
| 47 | |
|---|
| 48 | Predicates = [after/3, age/1, before/3, name/1, predicates/1, salary/1] |
|---|
| 49 | yes |
|---|
| 50 | |
|---|
| 51 | | ?- employee::predicate_property(predicates(_), Property). |
|---|
| 52 | |
|---|
| 53 | Property = public ; |
|---|
| 54 | Property = static ; |
|---|
| 55 | Property = declared_in(logging) ; |
|---|
| 56 | Property = defined_in(logging) |
|---|
| 57 | yes |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | % turn event support off: |
|---|
| 61 | |
|---|
| 62 | | ?- set_logtalk_flag(events, off). |
|---|
| 63 | |
|---|
| 64 | yes |
|---|