Specifically I'd like to create a "method" declaration adjective, similar to "public" and "private" from JBR's tcloo.tcl. The adjective I'm thinking of is "linked" that will perform the function of the "procs" procedure in tcloo.tcl, and is called "link" in some other code (forgot where (PYK: probably in ooutil)). It links procs in an object's namespace to the class methods such that they can be called as commands.

The current implementations require the set of linked methods to be mentioned twice, once in their method declarations and once in the link/procs call in the class constructor. I'd like something like:

linked method name { args } { body }

The linked method would add the method name to the classes linked slot and then at constructor time (maybe automatically) the links would be made using the "linked" slot list. Is it possible to override or filter the class constructor to handle this automatic at constructor time part? Without subclassing??

PYK 2014-06-11: I put together a mixin class that tries to do what you've described. The purpose of string map here is to find a nice private location for the bookkeeping that is done to track the my methods. It's a little ugly, but hey, it works.

Using namespace unknown as the redirector was the only way I could find at the script level to get this job done.

Overloading the word my for this purpose leads to a heaping helping of my, but other ideas such as my! and nomy seemed even more forced. Better ideas are welcome, and anyone wants to improve this code, please just dig in!

PYK 2014-06-18: Neither my original code (since improved) nor JBR's followup was robust enough to handle subclasses. Here's a further evolution of JBR's code that has that ability. JBR (or anyone else), feel free to jump in and directly modiify in this code to taste: