Changeset 4270

Show
Ignore:
Timestamp:
05/23/08 09:49:25 (4 months ago)
Author:
pmoura
Message:

Generalized the :/1 control construct to allow its use from within categories that extend other categories.

Location:
trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4269 r4270  
    31543154 
    31553155 
    3156 % '$lgt_call_ctg_pred'(+atom, +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, Def, Pred, Sender, This, Self) :- 
     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) :- 
    31613163    (   call_with_args(Dcl, Pred, _, _, _, _, _, _, _) -> 
    3162         (   '$lgt_imports_category_'(This, Ctg, _), 
    3163             call_with_args(Def, Pred, Sender, This, Self, Call, Ctg) -> 
     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 -> 
    31643173            call(Call) 
    31653174        ) 
     
    69246933'$lgt_tr_body'(':'(Pred), _, _, _) :- 
    69256934    \+ '$lgt_pp_imported_category_'(_, _, _, _, _), 
     6935    \+ '$lgt_pp_extended_category_'(_, _, _, _, _), 
     6936    \+ '$lgt_pp_extended_object_'(_, _, _, _, _, _, _, _, _, _), 
     6937    \+ '$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _), 
     6938    \+ '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _), 
    69266939    throw(existence_error(procedure, Pred)). 
    69276940 
    69286941'$lgt_tr_body'(':'(Alias), TPred, '$lgt_dbg_goal'(':'(Alias), TPred, DbgCtx), Ctx) :- 
     6942    '$lgt_pp_object_'(Obj, _, Dcl, Def, _, IDcl, IDef, _, _, _, _), 
    69296943    !, 
    69306944    '$lgt_ctx_ctx'(Ctx, _, Sender, This, Self, _, _, _), 
     
    69386952        true 
    69396953    ;   Pred = Alias, 
    6940         '$lgt_pp_object_'(_, _, Dcl, Def, _, IDcl, _, _, _, _, _), 
    69416954        (   ('$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _); '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _)) -> 
    6942             TPred = '$lgt_call_ctg_pred'(IDcl, Def, Pred, Sender, This, Self) 
    6943         ;   TPred = '$lgt_call_ctg_pred'(Dcl, Def, Pred, Sender, This, Self) 
     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) 
    69446957        ) 
     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            true 
     6967        ;   Pred = Alias 
     6968        ), 
     6969        '$lgt_ctg_static_binding_cache'(Ctg2, Pred, Sender, This, Self, TPred) -> 
     6970        true 
     6971    ;   Pred = Alias, 
     6972        TPred = '$lgt_call_pred_from_this'(category, Ctg, Dcl, Def, Pred, Sender, This, Self) 
    69456973    ). 
    69466974 
  • trunk/manuals/index.html

    r4233 r4270  
    3232    <div class="copyright"> 
    3333        <span>Copyright &copy; <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> &mdash; <a href="http://logtalk.org">Logtalk.org</a></span><br/>  
    34         <span>Last updated on: April 21, 2008</span> 
     34        <span>Last updated on: May 23, 2008</span> 
    3535    </div> 
    3636    <div class="navbottom"> 
  • trunk/manuals/refman/control/direct1.html

    r3826 r4270  
    2626<pre>:Goal</pre> 
    2727<p> 
    28 Calls an imported category predicate without using the message sending mechanisms. The category 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. The lookup for both the predicate declaration and the predicate definition begins in <em>this</em> instead of <em>self</em>. Furthermore, the lookup of the predicate definition is 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. 
     28Calls 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. 
    2929</p> 
    3030 
     
    4040    <dt>Goal is neither a variable nor a callable term:</dt> 
    4141        <dd><code>type_error(callable, Goal)</code></dd> 
    42     <dt>The object containing the call does not import any category:</dt> 
     42    <dt>The entity containing the call does not import or inherit from any entity:</dt> 
    4343        <dd><code>existence_error(procedure, Goal)</code></dd> 
    4444</dl> 
     
    5959    <div class="copyright"> 
    6060        <span>Copyright &copy; <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> &mdash; <a href="http://logtalk.org">Logtalk.org</a></span><br/>  
    61         <span>Last updated on: August 27, 2007</span> 
     61        <span>Last updated on: May 23, 2008</span> 
    6262    </div> 
    6363    <div class="navbottom"> 
  • trunk/manuals/refman/control/to_super1.html

    r3560 r4270  
    2626<pre>^^Predicate</pre> 
    2727<p> 
    28 Calls a redefined/inherited definition for a message. Normally only used in the body of a predicate definition for the message. Predicate should match a public or protected predicate of <a class="glossary" title="Go to glossary definition" href="../../glossary.html#self">self</a> or be within the scope of <a class="glossary" title="Go to glossary definition" href="../../glossary.html#this">this</a>. 
     28Calls a redefined/inherited definition for a message. Normally only used in the body of a predicate definition for the message. Predicate should match a public or protected predicate of <a class="glossary" title="Go to glossary definition" href="../../glossary.html#self"><em>self</em></a> or be within the scope of <a class="glossary" title="Go to glossary definition" href="../../glossary.html#this"><em>this</em></a>. 
    2929</p> 
    3030 
  • trunk/manuals/refman/index.html

    r4209 r4270  
    311311</dl> 
    312312 
    313 <h3>Direct calls of category predicates</h3> 
     313<h3>Direct calls of inherited or imported predicates</h3> 
    314314 
    315315<dl class="toc-entries"> 
     
    320320    <div class="copyright"> 
    321321        <span>Copyright &copy; <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> &mdash; <a href="http://logtalk.org">Logtalk.org</a></span><br/>  
    322         <span>Last updated on: April 18, 2008</span> 
     322        <span>Last updated on: May 23, 2008</span> 
    323323    </div> 
    324324    <div class="navbottom"> 
  • trunk/manuals/userman/index.html

    r4213 r4270  
    7979    <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> 
    8080    <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 inherited predicates</a><span class="leader"></span><span class="page-ref"><span class="messages_direct"></span></span></dt> 
    8182    <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> 
    8283    <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> 
     
    302303    <div class="copyright"> 
    303304        <span>Copyright &copy; <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> &mdash; <a href="http://logtalk.org">Logtalk.org</a></span><br/> 
    304         <span>Last updated on: April 21, 2008</span> 
     305        <span>Last updated on: May 23, 2008</span> 
    305306    </div> 
    306307    <div class="navbottom"> 
  • trunk/manuals/userman/messages.html

    r3854 r4270  
    120120    ^^Predicate,    % call inherited definition 
    121121    ... .           % do something more</pre> 
     122 
     123<h2 id="messages_direct">Direct calls of imported and inherited predicates</h2> 
     124 
     125<p> 
     126It 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 using the <a title="Consult reference manual" href="../refman/control/direct1.html"><code>:/1</code></a> control construct. 
     127</p> 
    122128 
    123129<h2 id="messages_events">Message sending and event generation</h2> 
     
    236242    <div class="copyright"> 
    237243        <span>Copyright &copy; <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> &mdash; <a href="http://logtalk.org">Logtalk.org</a></span><br/>  
    238         <span>Last updated on: September 15, 2007</span> 
     244        <span>Last updated on: May 23, 2008</span> 
    239245    </div> 
    240246    <div class="navbottom"> 
  • trunk/manuals/userman/objects.html

    r3960 r4270  
    304304<pre>:- synchronized.</pre> 
    305305<p> 
    306 This directive results in using internally the same mutex for synchronizing the execution of all defined object predicates. 
     306This directive results in using internally the same mutex for synchronizing the execution of all defined object predicates. For fine-grained predicate synchronization, the <a title="Consult reference manual" href="../refman/directives/synchronized1.html"><code>synchronized/1</code></a> directive may be used instead. 
    307307</p> 
    308308 
     
    439439    <div class="copyright"> 
    440440        <span>Copyright &copy; <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> &mdash; <a href="http://logtalk.org">Logtalk.org</a></span><br/>  
    441         <span>Last updated on: December 9, 2007</span> 
     441        <span>Last updated on: May 21, 2008</span> 
    442442    </div> 
    443443    <div class="navbottom"> 
  • trunk/RELEASE_NOTES.txt

    r4269 r4270  
    1111 
    1212 
    13 2.31.6 - May 26, 2008 
     132.31.6 - May ??, 2008 
     14 
     15    Generalized the :/1 control construct to allow its use from within  
     16    categories that extend other categories. 
    1417 
    1518    Fixed a Logtalk compiler bug when compiling a class that imports a