local methods

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

local methods

Alexander Plötz
Hello List,
is it possible to have local methods? I have recently experimented a bit with the structure of global arrays, finding that one can do some things with them that are not strictly in the documentation. Since, in the plg file, methods and global arrays have a very similar structure (probably the same, on a systemic level, but I am a layman), I started thinking about whether it would be possible to manipulate actual code in a similar manner. For example, it is possible to trace any method itself, just as an array:
The most useful manipulation that I could see right now is to have encapsulated subroutines in a method, that can be called from within, but only from there. Something like this (which, obviously, does not work):
MethAsStr="(str) {Trace(str);}";


LocalMethod("Hello World!");

I also tried to build local arrays with code, but so far without success. I cannot say whether this is because it is not possible or because I have succumbed to occult syntax once more.
My main current rationale for this is to de-clutter the method list in an elaborate plug-in. There are a lot of smaller methods there which are only ever called in deep sub branches of the code structure and nowhere else. It would be very convenient to a) contain them to the method where they are needed and b) to be able to edit them right there, as to not always having to struggle with switching between several relevant method windows. Thus, the usual strategies, like calling a library plug-in or methods from a dictionary, are not helpful, since they still need the code to be within an actual method of its own. (I have, though, never used Dictionary so far, so maybe I am misunderstanding how it would work.)
I'm grateful for any input,

Plugin-dev mailing list
[hidden email]