<pclass="purpose">To enforce the domain of properties: for instance, that a door can be open or closed but that an animal cannot, or that a person can have a carrying capacity but that a door cannot.</p>
<pclass="commentary firstcommentary"><aid="SP1"class="paragraph-anchor"></a><b>§1. </b>Properties are pieces of data attached to their "owners", but they also
have a common identity wherever they turn up. For example, the property
"carrying capacity" is owned by any person and also by any container, but
it has a common meaning in each case, and in each case it's a number.
</p>
<pclass="commentary">Only values can own properties at run-time, but kinds can own properties
during compilation. Thus the Standard Rules declare that the kinds "person"
and "container" have a number called "carrying capacity", and we record
that as a single property which has two owners, both kinds. In the final
story file as compiled, each individual person and container then inherits
the property.
</p>
<pclass="commentary">And so each inference subject has a list of properties it can provide,
and each property a list of subjects it can be provided by. These are each
lists of <ahref="4-pp.html#SP1"class="internal">property_permission</a> objects.
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">struct</span><spanclass="plain-syntax"></span><spanclass="reserved-syntax">inference_subject</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">property_owner</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> to whom permission is granted</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">struct</span><spanclass="plain-syntax"></span><spanclass="reserved-syntax">property</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">property_granted</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> which property is permitted</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">struct</span><spanclass="plain-syntax"></span><spanclass="identifier-syntax">parse_node</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">where_granted</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> sentence granting the permission</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">struct</span><spanclass="plain-syntax"></span><spanclass="identifier-syntax">general_pointer</span><spanclass="plain-syntax"></span><spanclass="identifier-syntax">pp_storage_data</span><spanclass="plain-syntax">; </span><spanclass="comment-syntax"> how we'll compile this at run-time</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">void</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">plugin_pp</span><spanclass="plain-syntax">[</span><spanclass="identifier-syntax">MAX_PLUGINS</span><spanclass="plain-syntax">]; </span><spanclass="comment-syntax"> storage for plugins to attach, if they want to</span>
<ulclass="endnotetexts"><li>The structure property_permission is private to this section.</li></ul>
<pclass="commentary firstcommentary"><aid="SP2"class="paragraph-anchor"></a><b>§2. Seeking permission. </b>Note that an either/or property and its antonym (say, "open" and "closed")
are equivalent here: permission for one is always permission for the other.
</p>
<pclass="commentary">If these were long lists, or searched often, it would be faster to move each
found permission to the front, thus tending to move frequently-sought properties
to the start. Pofiling shows that this would save no significant time,
whereas the unpredictable order might make testing Inform more annoying.
<spanclass="reserved-syntax">property_permission</span><spanclass="plain-syntax"> *</span><spanclass="function-syntax">PropertyPermissions::find</span><buttonclass="popup"onclick="togglePopup('usagePopup1')"><spanclass="comment-syntax">?</span><spanclass="popuptext"id="usagePopup1">Usage of <spanclass="code-font"><spanclass="function-syntax">PropertyPermissions::find</span></span>:<br/><ahref="4-pp.html#SP3">§3</a><br/>Property Inferences - <ahref="5-pi.html#SP11">§11</a><br/>Indefinite Appearance - <ahref="5-ia.html#SP2">§2</a><br/>The Model World - <ahref="5-tmw.html#SP4_1">§4.1</a></span></button><spanclass="plain-syntax">(</span><spanclass="reserved-syntax">inference_subject</span><spanclass="plain-syntax"> *</span><spanclass="identifier-syntax">infs</span><spanclass="plain-syntax">,</span>
<pclass="commentary firstcommentary"><aid="SP3"class="paragraph-anchor"></a><b>§3. Granting permission. </b>This does nothing if permission already exists, simply returning the existing
permission structure; but note the use of <spanclass="extract"><spanclass="extract-syntax">allow_inheritance</span></span>. If this is
set to <spanclass="extract"><spanclass="extract-syntax">FALSE</span></span>, and we call for the "carrying capacity" property of the
player (say), then we may create a new permission even though the player's
kind ("person") already has one. This is intentional.<supid="fnref:1"><ahref="#fn:1"rel="footnote">1</a></sup>
</p>
<ulclass="footnotetexts"><liclass="footnote"id="fn:1"><pclass="inwebfootnote"><supid="fnref:1"><ahref="#fn:1"rel="footnote">1</a></sup> It means that plugins can specify different data about permissions when
applied to specific instances — see the example of the jar below.
<ahref="#fnref:1"title="return to text">↩</a></p></li></ul>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">PROPERTY_PROVISION</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"Allowing $j to provide $Y\n"</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">infs</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">prn</span><spanclass="plain-syntax">);</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-pp.html#SP3_1"class="named-paragraph-link"><spanclass="named-paragraph">Create the new permission structure</span><spanclass="named-paragraph-number">3.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-pp.html#SP3_2"class="named-paragraph-link"><spanclass="named-paragraph">Add the new permission to the owner's list</span><spanclass="named-paragraph-number">3.2</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-pp.html#SP3_3"class="named-paragraph-link"><spanclass="named-paragraph">Add the new permission to the property's list</span><spanclass="named-paragraph-number">3.3</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-pp.html#SP3_4"class="named-paragraph-link"><spanclass="named-paragraph">Notify plugins that a new permission has been issued</span><spanclass="named-paragraph-number">3.4</span></a></span><spanclass="plain-syntax">;</span>
<pclass="commentary firstcommentary"><aid="SP3_1"class="paragraph-anchor"></a><b>§3.1. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Create the new permission structure</span><spanclass="named-paragraph-number">3.1</span></span><spanclass="comment-syntax"> =</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-pp.html#SP3">§3</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2"class="paragraph-anchor"></a><b>§3.2. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Add the new permission to the owner's list</span><spanclass="named-paragraph-number">3.2</span></span><spanclass="comment-syntax"> =</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-pp.html#SP3">§3</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_3"class="paragraph-anchor"></a><b>§3.3. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Add the new permission to the property's list</span><spanclass="named-paragraph-number">3.3</span></span><spanclass="comment-syntax"> =</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-pp.html#SP3">§3</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_4"class="paragraph-anchor"></a><b>§3.4. </b>Complicating matters, plugins have the ability to attach data of their
own to a permission. For instance, the "parsing" plugin attaches the idea
of a property being visible — we might say that every thing has an
interior colour, but that it is invisible in the case of a dog and visible
in the case of a broken jar.
</p>
<pclass="commentary"><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Notify plugins that a new permission has been issued</span><spanclass="named-paragraph-number">3.4</span></span><spanclass="comment-syntax"> =</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-pp.html#SP3">§3</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP4"class="paragraph-anchor"></a><b>§4. </b>These two macros provide access to plugin-specific permission data: