Error getting tags :
error 404Error getting tags :
error 404 private | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Expander triangle

private (command|function) name parameterList

Desktop, Web and Server
Platform Support
Mac OS X,Windows,Linux
None required
The private keyword makes a function or command local to the script in which it is present

private command someLocalCommand pParameter1, pParameter2
-- do something
end someLocalCommand

private function someLocalFunction

- do something
nend someLocalFunction

Additional Comments
Expander triangle

Use the private keyword to declare a function or command as local to the object whose script it is in and stop it being directly called by any other objects.

Whenever an implicit handler call is made (ie calling the handler simply by its name as opposed to using send or call), Revolution 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.

Note: Attempting to compile a private handler containing a pass control structure will cause a compilation error because private handlers cannot be passed through the message path.

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.

Using private handlers when appropriate will also result in a performance gain as less messages are passed through the message path.

Note: Although it is also possible to use on 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 on control structure entry for more details.

User Comments
Expander triangle
User thumbnail
Martin Koob
Jan 30, 2011
Private does not work on the on-rev version of revserver.