Changeset 4271
- Timestamp:
- 05/23/08 15:12:42 (5 months ago)
- Location:
- trunk
- Files:
-
- 7 modified
-
compiler/logtalk.pl (modified) (22 diffs)
-
manuals/refman/control/direct1.html (modified) (2 diffs)
-
manuals/refman/index.html (modified) (1 diff)
-
manuals/userman/index.html (modified) (1 diff)
-
manuals/userman/messages.html (modified) (1 diff)
-
RELEASE_NOTES.txt (modified) (1 diff)
-
UPGRADING.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/compiler/logtalk.pl
r4270 r4271 41 41 42 42 43 % category predicate directcall operator43 % imported/inherited predicate call operator 44 44 45 45 :- op(600, fy, :). … … 65 65 66 66 :- dynamic('$lgt_current_protocol_'/3). % '$lgt_current_protocol_'(Ptc, Prefix, Type) 67 :- dynamic('$lgt_current_category_'/ 4). % '$lgt_current_category_'(Ctg, Prefix, Type, Synchronized)67 :- dynamic('$lgt_current_category_'/5). % '$lgt_current_category_'(Ctg, Prefix, Def, Type, Synchronized) 68 68 :- dynamic('$lgt_current_object_'/8). % '$lgt_current_object_'(Obj, Prefix, Dcl, Def, Super, Type, Synchronized, Threaded) 69 69 … … 314 314 ; '$lgt_extends_protocol_'(_, CtgOrPtc, _), \+ '$lgt_current_protocol_'(CtgOrPtc, _, _) -> 315 315 throw(error(existence_error(protocol, CtgOrPtc), _, _)) 316 ; '$lgt_imports_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _ ) ->316 ; '$lgt_imports_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _, _) -> 317 317 throw(error(existence_error(category, CtgOrPtc), _, _)) 318 ; '$lgt_extends_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _ ) ->318 ; '$lgt_extends_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _, _) -> 319 319 throw(error(existence_error(category, CtgOrPtc), _, _)) 320 320 ). … … 408 408 409 409 current_category(Ctg) :- 410 '$lgt_current_category_'(Ctg, _, _, _ ).410 '$lgt_current_category_'(Ctg, _, _, _, _). 411 411 412 412 … … 452 452 453 453 category_property(Ctg, Prop) :- % static/dynamic property 454 '$lgt_current_category_'(Ctg, _, Prop, _).454 '$lgt_current_category_'(Ctg, _, _, Prop, _). 455 455 456 456 category_property(Ctg, synchronized) :- 457 '$lgt_current_category_'(Ctg, _, _, yes).457 '$lgt_current_category_'(Ctg, _, _, _, yes). 458 458 459 459 … … 491 491 492 492 create_object(Obj, Rels, Dirs, Clauses) :- 493 '$lgt_current_category_'(Obj, _, _, _ ),493 '$lgt_current_category_'(Obj, _, _, _, _), 494 494 throw(error(permission_error(modify, category, Obj), create_object(Obj, Rels, Dirs, Clauses))). 495 495 … … 537 537 538 538 create_category(Ctg, Rels, Dirs, Clauses) :- 539 '$lgt_current_category_'(Ctg, _, _, _ ),539 '$lgt_current_category_'(Ctg, _, _, _, _), 540 540 throw(error(permission_error(modify, category, Ctg), create_category(Ctg, Rels, Dirs, Clauses))). 541 541 … … 594 594 595 595 create_protocol(Ptc, Rels, Dirs) :- 596 '$lgt_current_category_'(Ptc, _, _, _ ),596 '$lgt_current_category_'(Ptc, _, _, _, _), 597 597 throw(error(permission_error(modify, category, Ptc), create_protocol(Ptc, Rels, Dirs))). 598 598 … … 670 670 671 671 abolish_category(Ctg) :- 672 ( '$lgt_current_category_'(Ctg, Prefix, Type, _) ->672 ( '$lgt_current_category_'(Ctg, Prefix, _, Type, _) -> 673 673 ( Type == (dynamic) -> 674 674 call_with_args(Prefix, Dcl, Def, Rnm), … … 679 679 abolish(Rnm/3), 680 680 abolish(Prefix/3), 681 retractall('$lgt_current_category_'(Ctg, _, _, _ )),681 retractall('$lgt_current_category_'(Ctg, _, _, _, _)), 682 682 retractall('$lgt_extends_category_'(Ctg, _, _)), 683 683 retractall('$lgt_implements_protocol_'(Ctg, _, _)), … … 1963 1963 '$lgt_alias_pred'(Ctg1, _, Alias, Pred, _) :- 1964 1964 '$lgt_extends_category_'(Ctg1, Ctg2, _), 1965 '$lgt_current_category_'(Ctg2, Prefix, _, _ ),1965 '$lgt_current_category_'(Ctg2, Prefix, _, _, _), 1966 1966 '$lgt_alias_pred'(Ctg2, Prefix, Alias, Pred, _). 1967 1967 1968 1968 '$lgt_alias_pred'(Obj, _, Alias, Pred, _) :- 1969 1969 '$lgt_imports_category_'(Obj, Ctg, _), 1970 '$lgt_current_category_'(Ctg, Prefix, _, _ ),1970 '$lgt_current_category_'(Ctg, Prefix, _, _, _), 1971 1971 '$lgt_alias_pred'(Ctg, Prefix, Alias, Pred, _). 1972 1972 … … 3154 3154 3155 3155 3156 % '$lgt_call_pred_from_this'(+atom, +object_identifier, +atom, +atom, +callable, +object_identifier, +object_identifier, +object_identifier) 3157 % '$lgt_call_pred_from_this'(+atom, +category_identifier, +atom, +atom, +callable, +object_identifier, +object_identifier, +object_identifier) 3158 % 3159 % calls a predicate from "this", without using the message sending mechanism 3160 % prevent loops by ensuring that we look for an inherited or imported definition 3161 3162 '$lgt_call_pred_from_this'(object, Obj, Dcl, Def, Pred, Sender, This, Self) :- 3156 % '$lgt_call_ctg_pred'(+atom, +callable, +object_identifier, +object_identifier, +object_identifier) 3157 % 3158 % calls a category predicate directly, without using the message sending mechanism 3159 3160 '$lgt_call_ctg_pred'(Dcl, Pred, Sender, This, Self) :- 3163 3161 ( call_with_args(Dcl, Pred, _, _, _, _, _, _, _) -> 3164 ( call_with_args(Def, Pred, Sender, This, Self, Call, Ctn), Obj \= Ctn -> 3165 call(Call) 3166 ) 3167 ; throw(error(existence_error(predicate_declaration, Pred), ':'(Pred), This)) 3168 ). 3169 3170 '$lgt_call_pred_from_this'(category, Ctg, Dcl, Def, Pred, Sender, This, Self) :- 3171 ( call_with_args(Dcl, Pred, _, _, _, _, _, _) -> 3172 ( call_with_args(Def, Pred, Sender, This, Self, Call, Ctn), Ctg \= Ctn -> 3162 ( '$lgt_imports_category_'(This, Ctg, _), 3163 '$lgt_current_category_'(Ctg, _, Def, _, _), 3164 call_with_args(Def, Pred, Sender, This, Self, Call, _) -> 3173 3165 call(Call) 3174 3166 ) … … 3331 3323 3332 3324 '$lgt_hidden_functor'(Functor) :- 3333 '$lgt_current_category_'(_, Prefix, _, _ ),3325 '$lgt_current_category_'(_, Prefix, _, _, _), 3334 3326 atom_concat(Prefix, _, Functor), 3335 3327 !. … … 4073 4065 4074 4066 '$lgt_redefined_entity'(Entity, category) :- 4075 '$lgt_current_category_'(Entity, _, _, _ ).4067 '$lgt_current_category_'(Entity, _, _, _, _). 4076 4068 4077 4069 … … 4929 4921 !. 4930 4922 4931 '$lgt_pp_rclause'('$lgt_current_category_'(Ctg, Prefix, Mode, Synchronized)) :-4932 '$lgt_pp_category_'(Ctg, Prefix, _, _, _, Mode),4923 '$lgt_pp_rclause'('$lgt_current_category_'(Ctg, Prefix, Def, Mode, Synchronized)) :- 4924 '$lgt_pp_category_'(Ctg, Prefix, _, Def, _, Mode), 4933 4925 ( '$lgt_pp_synchronized_' -> 4934 4926 Synchronized = yes … … 6933 6925 '$lgt_tr_body'(':'(Pred), _, _, _) :- 6934 6926 \+ '$lgt_pp_imported_category_'(_, _, _, _, _), 6935 \+ '$lgt_pp_extended_category_'(_, _, _, _, _),6936 \+ '$lgt_pp_extended_object_'(_, _, _, _, _, _, _, _, _, _),6937 \+ '$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _),6938 \+ '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _),6939 6927 throw(existence_error(procedure, Pred)). 6940 6928 6941 6929 '$lgt_tr_body'(':'(Alias), TPred, '$lgt_dbg_goal'(':'(Alias), TPred, DbgCtx), Ctx) :- 6942 '$lgt_pp_object_'(Obj, _, Dcl, Def, _, IDcl, IDef, _, _, _, _),6943 !,6944 6930 '$lgt_ctx_ctx'(Ctx, _, Sender, This, Self, _, _, _), 6945 6931 '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), … … 6952 6938 true 6953 6939 ; Pred = Alias, 6940 '$lgt_pp_object_'(_, _, Dcl, _, _, IDcl, _, _, _, _, _), 6954 6941 ( ('$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _); '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _)) -> 6955 TPred = '$lgt_call_ pred_from_this'(object, Obj, IDcl, IDef, Pred, Sender, This, Self)6956 ; TPred = '$lgt_call_ pred_from_this'(object, Obj, Dcl, Def, Pred, Sender, This, Self)6942 TPred = '$lgt_call_ctg_pred'(IDcl, Pred, Sender, This, Self) 6943 ; TPred = '$lgt_call_ctg_pred'(Dcl, Pred, Sender, This, Self) 6957 6944 ) 6958 ).6959 6960 '$lgt_tr_body'(':'(Alias), TPred, '$lgt_dbg_goal'(':'(Alias), TPred, DbgCtx), Ctx) :-6961 '$lgt_pp_category_'(Ctg, _, Dcl, Def, _, _),6962 '$lgt_ctx_ctx'(Ctx, _, Sender, This, Self, _, _, _),6963 '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx),6964 ( '$lgt_pp_extended_category_'(Ctg2, _, _, _, _),6965 ( '$lgt_pp_alias_'(Ctg2, Pred, Alias) ->6966 true6967 ; Pred = Alias6968 ),6969 '$lgt_ctg_static_binding_cache'(Ctg2, Pred, Sender, This, Self, TPred) ->6970 true6971 ; Pred = Alias,6972 TPred = '$lgt_call_pred_from_this'(category, Ctg, Dcl, Def, Pred, Sender, This, Self)6973 6945 ). 6974 6946 … … 8801 8773 '$lgt_unknown_category'(Ctg) :- 8802 8774 '$lgt_pp_referenced_category_'(Ctg), 8803 \+ '$lgt_current_category_'(Ctg, _, _, _ ),% not a currently loaded category8775 \+ '$lgt_current_category_'(Ctg, _, _, _, _), % not a currently loaded category 8804 8776 \+ '$lgt_pp_category_'(Ctg, _, _, _, _, _), % not the category being compiled (self references) 8805 8777 \+ '$lgt_pp_entity_init_'(category, Ctg, _). % not a category defined in the source file being compiled … … 10631 10603 retractall('$lgt_current_object_'(Entity, _, _, _, _, _, _, _)), 10632 10604 retractall('$lgt_current_protocol_'(Entity, _, _)), 10633 retractall('$lgt_current_category_'(Entity, _, _, _ )),10605 retractall('$lgt_current_category_'(Entity, _, _, _, _)), 10634 10606 retractall('$lgt_implements_protocol_'(Entity, _, _)), 10635 10607 retractall('$lgt_imports_category_'(Entity, _, _)), … … 10698 10670 '$lgt_construct_category_functors'(Ctg, Prefix, Dcl, Def, Rnm) :- 10699 10671 ( '$lgt_built_in_category'(Ctg) -> 10700 '$lgt_current_category_'(Ctg, Prefix, _, _ ),10672 '$lgt_current_category_'(Ctg, Prefix, _, _, _), 10701 10673 Call =.. [Prefix, Dcl, Def, Rnm], 10702 10674 once(Call) … … 10747 10719 ( '$lgt_current_object_'(Entity, Prefix, _, _, _, _, _, _), 10748 10720 Type = object 10749 ; '$lgt_current_category_'(Entity, Prefix, _, _ ),10721 ; '$lgt_current_category_'(Entity, Prefix, _, _, _), 10750 10722 Type = category 10751 10723 ), … … 13358 13330 true 13359 13331 ; '$lgt_static_binding_entity_'(Ctg), 13360 '$lgt_current_category_'(Ctg, Prefix, _, _ ),13332 '$lgt_current_category_'(Ctg, Prefix, _, _, _), 13361 13333 Clause =.. [Prefix, Dcl, Def, _], 13362 13334 call(Clause), -
trunk/manuals/refman/control/direct1.html
r4270 r4271 26 26 <pre>:Goal</pre> 27 27 <p> 28 Calls an inherited or imported predicate with the lookup for both the predicate declaration and the predicate definition beginning in <em>this</em> instead of <em>self</em>. As a consequence, any redeclaration or redefinition of the predicate in a descendant of the object containing the call will be ignored. The predicate is called with the same execution context (<em>sender</em>, <em>this</em>, and <em>self</em>) as the predicate whose body contains the call. When the predicate is defined in an imported category compiled using static binding, this control construct allows the predicate to be called with the same performance as a local object predicate.28 Calls an <strong>imported</strong> predicate with the lookup for the predicate declaration beginning in <em>this</em> instead of <em>self</em> and with the lookup for the predicate definition restricted to the imported categories. As a consequence, any redeclaration or redefinition of the predicate in a descendant of the object containing the call will be ignored. The predicate is called with the same execution context (<em>sender</em>, <em>this</em>, and <em>self</em>) as the predicate whose body contains the call. When the predicate is defined in an imported category compiled using static binding, this control construct allows the predicate to be called with the same performance as a local object predicate. 29 29 </p> 30 30 … … 40 40 <dt>Goal is neither a variable nor a callable term:</dt> 41 41 <dd><code>type_error(callable, Goal)</code></dd> 42 <dt>The entity containing the call does not import or inherit from any entity:</dt>42 <dt>The object containing the call does not import any category:</dt> 43 43 <dd><code>existence_error(procedure, Goal)</code></dd> 44 44 </dl> -
trunk/manuals/refman/index.html
r4270 r4271 311 311 </dl> 312 312 313 <h3>Direct calls of i nherited or imported predicates</h3>313 <h3>Direct calls of imported predicates</h3> 314 314 315 315 <dl class="toc-entries"> -
trunk/manuals/userman/index.html
r4270 r4271 79 79 <dt><a href="messages.html#messages_self">Sending a message to <em>self</em></a><span class="leader"></span><span class="page-ref"><span class="messages_self"></span></span></dt> 80 80 <dt><a href="messages.html#messages_super">Calling an overridden predicate definition</a><span class="leader"></span><span class="page-ref"><span class="messages_super"></span></span></dt> 81 <dt><a href="messages.html#messages_direct">Direct calls of imported and inheritedpredicates</a><span class="leader"></span><span class="page-ref"><span class="messages_direct"></span></span></dt>81 <dt><a href="messages.html#messages_direct">Direct calls of imported predicates</a><span class="leader"></span><span class="page-ref"><span class="messages_direct"></span></span></dt> 82 82 <dt><a href="messages.html#messages_events">Message sending and event generation</a><span class="leader"></span><span class="page-ref"><span class="messages_events"></span></span></dt> 83 83 <dt><a href="messages.html#messages_performance">Message sending performance</a><span class="leader"></span><span class="page-ref"><span class="messages_performance"></span></span></dt> -
trunk/manuals/userman/messages.html
r4270 r4271 121 121 ... . % do something more</pre> 122 122 123 <h2 id="messages_direct">Direct calls of imported and inheritedpredicates</h2>124 125 <p> 126 It is possible to call an imported or inherited predicate starting the lookups for the predicate declaration and definition from <em>this</em> instead of <em>self</em> by usingthe <a title="Consult reference manual" href="../refman/control/direct1.html"><code>:/1</code></a> control construct.123 <h2 id="messages_direct">Direct calls of imported predicates</h2> 124 125 <p> 126 It is possible to call an imported predicate without using the message sending mechanisms with the <a title="Consult reference manual" href="../refman/control/direct1.html"><code>:/1</code></a> control construct. 127 127 </p> 128 128 -
trunk/RELEASE_NOTES.txt
r4270 r4271 13 13 2.31.6 - May ??, 2008 14 14 15 Generalized the :/1 control construct to allow its use from within 16 categories that extend other categories. 15 Fixed a Logtalk runtime bug when using the :/1 control construct to 16 call a predicate defined in a category extended by a category that 17 is imported by the object making the call. 17 18 18 19 Fixed a Logtalk compiler bug when compiling a class that imports a -
trunk/UPGRADING.txt
r4233 r4271 193 193 encoding/1). Older config files are incompatible with this new Logtalk 194 194 version. 195 196 Logtalk version 2.31.6 changes representation of loaded categories in order 197 to correct a bug in the use of the :/1 control construct, therefore implying 198 recompilation of all categories.
