________________________________________________________________________

This file is part of Logtalk <http://logtalk.org/>  

Logtalk is free software. You can redistribute it and/or modify it under
the terms of the FSF GNU General Public License 3  (plus some additional
terms per section 7).        Consult the `LICENSE.txt` file for details.
________________________________________________________________________


% start by loading the example:

| ?- logtalk_load(viewpoints(loader)).
...


% we can start by asking joe its age:

| ?- joe_person::age(Age).

Age = 30
yes


% the same question could be made via any of its viewpoints:

| ?- joe_sportsman::age(Age).

Age = 30
yes


% now let's tell joe to get older:

| ?- joe_person::grow_older.

yes


% we can verify the effect of the above message from any of the viewpoints:

| ?- joe_chess_player::age(Age).

Age = 31
yes


% because the growOld/0 and the age/1 predicates are implemented using 
% property sharing, we can send the grow_older/0 message to any viewpoint:

| ?- joe_employee::grow_older.

yes


% we can check this by asking joe its age:


| ?- joe_person::age(Age).

Age = 32
yes


% as you can see, although the modification message have been sent to a 
% descendant, its the predicate age/1 in the parent that got updated


% to illustrate value sharing we use a couple of predicates, score/1 and
% set_score/0, defined in joe_person:


| ?- joe_person::score(Score).

Score = 0
yes


% initially, score/1 is only defined for joe_person, so every descendant 
% or viewpoint will share its value/definition:

| ?- joe_employee::score(Score).

Score = 0
yes


% but if we decide to increment the counter by sending the set_score/0 message to a descendant
% (don't use message broadcasting syntax in order to workaround a XSB parser bug):

| ?- joe_chess_player::set_score(2200), joe_chess_player::score(Score).

Score = 2200
yes


% then the descendant will now have a local definition for counter/1,
% independent of the definition in its parent, joe_person:

| ?- joe_person::score(Score).

Score = 0
yes


% the other descendants/viewpoints will continue to share the definition 
% in joe_person:

| ?- joe_sportsman::score(Score).

Score = 0
yes
