Skip to content

Commit

Permalink
Clarify base.Method()
Browse files Browse the repository at this point in the history
  • Loading branch information
Lexikos committed Jan 15, 2015
1 parent ea2f11f commit f04a5ce
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions docs/Objects.htm
Expand Up @@ -302,11 +302,10 @@ <h4 id="Custom_Classes_method">Methods</h4>
}
</pre>

<p id="Custom_Classes_base">In addition to the hidden parameter <code>this</code>, method definitions can use the pseudo-keyword <code>base</code> to invoke the base class of the class which contains the method definition. For example, <code>base.Method()</code> in the method above would be equivalent to <code>BaseClassName.Method.(this)</code>. Note that this differs from <code>this.base.base.Method()</code> in two other ways:</p>
<p id="Custom_Classes_base">Inside a method, the pseudo-keyword <code>base</code> can be used to access the super-class versions of methods or properties which are overridden in a derived class. For example, <code>base.Method()</code> in the class defined above would call the version of <em>Method</em> which is defined by <em>BaseClassName</em>. <a href="#Meta_Functions">Meta-functions</a> are not called; otherwise, <code>base.Method()</code> behaves like <code>BaseClassName.Method.(this)</code>. That is,</p>
<ul>
<li>It always invokes the base of the current class, even if <code>this</code> is derived from a <i>sub-class</i> of the current class.</li>
<li>It passes <code>this</code> automatically, not <code>this.base.base</code>.</li>
<li>It never causes a <a href="#Meta_Functions">meta-function</a> to be called.</li>
<li><code>base.Method()</code> always invokes the base of the class where the current method was defined, even if <code>this</code> is derived from a <em>sub-class</em> of that class or some other class entirely.</li>
<li><code>base.Method()</code> implicitly passes <code>this</code> as the first (hidden) parameter.</li>
</ul>
<p><code>base</code> only has special meaning if followed by a dot <code>.</code> or brackets <code>[]</code>, so code like <code>obj := base, obj.Method()</code> will not work. Scripts can disable the special behaviour of <i>base</i> by assigning it a non-empty value; however, this is not recommended. Since the variable <i>base</i> must be empty, performance may be reduced if the script omits <a href="commands/_NoEnv.htm">#NoEnv</a>.</p>

Expand Down

0 comments on commit f04a5ce

Please sign in to comment.