<doc>
  <legacy_id>3032</legacy_id>
  <name>private</name>
  <type>keyword</type>
  <syntax>
    <example>private (command|function) <i>name</i> <i>parameterList</i></example>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>Writing LiveCode</category>
  </classification>
  <references>
    <control_st tag="function">function Control Structure</control_st>
    <control_st tag="on">on Control Structure</control_st>
  </references>
  <history>
    <introduced version="2.8.1">Added.</introduced>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
    <ios/>
    <android/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
    <mobile/>
  </classes>
  <security>
  </security>
  <summary>The <b>private</b> keyword makes a function or command local to the script in which it is present</summary>
  <examples>
    <example>private command someLocalCommand pParameter1, pParameter2</p><p>   -- do something</p><p>end someLocalCommand</example>
    <example>private function someLocalFunction</p><p>   -- do something</p><p> end someLocalFunction</example>
  </examples>
  <description>
    <p>Use the <b>private</b> keyword to declare a <control_st tag="function">function</control_st> or <control_st tag="on">command</control_st> as local to the object whose script it is in and stop it being directly called by any other objects.</p><p/><p>Whenever an implicit handler call is made (ie calling the handler simply by its name as opposed to using send or call), LiveCode will check the current script for a private handler before allowing the call to pass through the message path. If a private handler is found in the curent script, it will be directly called.</p><p/><p><b>Note:</b> Attempting to compile a private handler containing a <control_st tag="pass">pass control structure</control_st> will cause a compilation error because private handlers cannot be passed through the message path.</p><p/><p>The use of private handlers for functionality local to a particular object is recommended as it encourages better encapsulation and helps avoid problems with namespace pollution caused by multiple handlers in the message path with the same name.</p><p/><p>Using private handlers when appropriate will also result in a performance gain as less messages are passed through the message path.</p><p/><p><b>Note:</b> Although it is also possible to use <b>on</b> when declaring a private handler this is not recommended as it implies that the handler is a message sent when some event occurs. As private handlers are not passed through the message path, this is incorrect and can make the code harder to understand. Please see the <control_st tag="on">on control structure</control_st> entry for more details.</p>
  </description>
</doc>