Changeset 4470
- Timestamp:
- 09/22/08 08:18:55 (4 months ago)
- Location:
- trunk
- Files:
-
- 7 modified
-
compiler/logtalk.pl (modified) (1 diff)
-
examples/proxies/proxies.lgt (modified) (3 diffs)
-
examples/proxies/SCRIPT.txt (modified) (1 diff)
-
manuals/index.html (modified) (1 diff)
-
manuals/userman/index.html (modified) (1 diff)
-
manuals/userman/objects.html (modified) (2 diffs)
-
RELEASE_NOTES.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/compiler/logtalk.pl
r4468 r4470 7883 7883 7884 7884 7885 % convenient access to parametric object proxies 7886 7887 '$lgt_tr_msg'(Pred, {Proxy}, (call(Proxy), TPred), This) :- 7888 !, 7889 '$lgt_tr_msg'(Pred, Proxy, TPred, This). 7890 7891 7885 7892 % translation performed at runtime 7886 7893 -
trunk/examples/proxies/proxies.lgt
r3227 r4470 3 3 % object proxy arguments and to encapsulate relevant predicates: 4 4 5 :- object(circle(_ Radius, _Color)).5 :- object(circle(_Id, _Radius, _Color)). 6 6 7 7 :- public([ 8 radius/1, 9 color/1, 10 area/1, 11 perimeter/1, 12 print/0]). 8 id/1, radius/1, color/1, 9 area/1, perimeter/1, 10 print/0 11 ]). 12 13 id(Id) :- 14 parameter(1, Id). 13 15 14 16 radius(Radius) :- 15 parameter( 1, Radius).17 parameter(2, Radius). 16 18 17 19 color(Color) :- 18 parameter( 2, Color).20 parameter(3, Color). 19 21 20 22 area(Area) :- … … 27 29 28 30 print :- 29 area(Area), write('area: '), write(Area), 31 id(Id), write('id: '), write(Id), 32 area(Area), write(', area: '), write(Area), 30 33 perimeter(Perimeter), write(', perimeter: '), write(Perimeter), 31 34 color(Color), write(', color: '), write(Color), nl. … … 34 37 35 38 36 % parametric object proxies (with an extra argument to represent identity):39 % parametric object proxies: 37 40 38 41 circle('#1', 1.23, blue). -
trunk/examples/proxies/SCRIPT.txt
r4466 r4470 18 18 % print the area and the perimeter for all circle proxies: 19 19 20 | ?- forall(circle(Id, R, C), (write(Id), write(' '), circle(R, C)::print)).20 | ?- forall(circle(Id, R, C), circle(Id, R, C)::print). 21 21 22 #1 area: 4.75291, perimeter: 7.72831, color: blue 23 #2 area: 43.2412, perimeter: 23.3106, color: yellow 24 #3 area: 0.477836, perimeter: 2.45044, color: green 25 #4 area: 103.508, perimeter: 36.0655, color: black 26 #5 area: 217.468, perimeter: 52.2761, color: cyan 27 yes 22 id: #1, area: 4.75291, perimeter: 7.72831, color: blue 23 id: #2, area: 43.2412, perimeter: 23.3106, color: yellow 24 id: #3, area: 0.477836, perimeter: 2.45044, color: green 25 id: #4, area: 103.508, perimeter: 36.0655, color: black 26 id: #5, area: 217.468, perimeter: 52.2761, color: cyan 27 true. 28 29 30 % print the area and the perimeter for the circle #2: 31 32 | ?- {circle('#2', R, C)}::print. 33 34 id: #2, area: 43.2412, perimeter: 23.3106, color: yellow 35 R = 3.71, 36 C = yellow. -
trunk/manuals/index.html
r4466 r4470 32 32 <div class="copyright"> 33 33 <span>Copyright © <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> — <a href="http://logtalk.org">Logtalk.org</a></span><br/> 34 <span>Last updated on: August 25, 2008</span>34 <span>Last updated on: September 22, 2008</span> 35 35 </div> 36 36 <div class="navbottom"> -
trunk/manuals/userman/index.html
r4447 r4470 304 304 <div class="copyright"> 305 305 <span>Copyright © <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> — <a href="http://logtalk.org">Logtalk.org</a></span><br/> 306 <span>Last updated on: August 25, 2008</span>306 <span>Last updated on: September 22, 2008</span> 307 307 </div> 308 308 <div class="navbottom"> -
trunk/manuals/userman/objects.html
r4270 r4470 194 194 </p> 195 195 <p> 196 Compound terms with the same functor and (usually) the same number of arguments as a parametric object identifier may act as <em>proxies</em> to a parametric object. Proxies may be stored on the database as Prolog facts and be used to represent different instantiations of a parametric object identifier. 196 Compound terms with the same functor and (usually) the same number of arguments as a parametric object identifier may act as <em>proxies</em> to a parametric object. Proxies may be stored on the database as Prolog facts and be used to represent different instantiations of a parametric object identifier. Logtalk provides a convenient notation for accessing proxies represented as Prolog facts when sending a message: 197 </p> 198 <pre>{Proxy}::Message</pre> 199 <p> 200 In this context, the proxy argument is proved as a plain Prolog goal. If successful, the message is sent to the corresponding parametric object. Typically, the proof allows retrieving of parameter instantiations. This notation supports backtracking over the Prolog facts that unify with the proxy term. When this behavior is unwanted, is possible to commit to the first unifying fact by writing: 201 </p> 202 <pre>{Proxy}::(!, Message)</pre> 203 <p> 204 In most cases, however, the use of cuts is not necessary as this construct is usually used with a proxy argument that is partially instantiated in order to unify with a single Prolog fact. 197 205 </p> 198 206 … … 439 447 <div class="copyright"> 440 448 <span>Copyright © <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> — <a href="http://logtalk.org">Logtalk.org</a></span><br/> 441 <span>Last updated on: May 21, 2008</span>449 <span>Last updated on: September 22, 2008</span> 442 450 </div> 443 451 <div class="navbottom"> -
trunk/RELEASE_NOTES.txt
r4468 r4470 15 15 16 16 2.33.1 - October ??, 2008 17 18 Added a syntax construct for easy access to parametric object proxies 19 represented as Prolog facts when sending a message ({Proxy}::Message). 20 Updated the "proxies" example to illustrate this new functionality. 17 21 18 22 Corrected a bug in the Logtalk compiler that would result in failure to
