Callwrapper

by Alathon
[Share] [Zip]
ID:109930
 
Callwrapper provides two objects:

The callObject object, for calling a specific function belonging to an object.

The callInterface object, for providing access to up to many different functions belonging to an object.

The objects make sure that the function exists, and the callInterface can automatically guess what functions should be callable, based on their name (Rather, it will not allow you to call functions that are considered private).

This library stems from the ideas discussed in the DevTalk article, Design in BYOND: Interfaces?. Demo code is available in demo.dm, the library can be run by itself to run the demo code.

There is currently no documentation other than the code shown in demo.dm - That will change in the Near Future(tm).
Despite the name, DevTalk doesn't appear to be a place for open discussion. I think the concept of this library is good but a little clumsy to use. This blog post describes how checking an object's interface would actually be used. If you've ever used JavaScript it should look familiar to check if an object has a member before using it.

I'm also not sure about the enforcement of public and private members. The naming convention is ok, but I think self-enforcement would work better. You can just search your code for ".__" to find places where you reference a private member from outside the object. Valid references don't need to specify src.__something, they can just be __something, invalid references would have to be of the form object.__something.