Allow states in modules
Status: Inactive
Brought to you by:
robgreayer
Pretty self-explanatory; some large and complex scripts can benefit greatly from the use of states, either in code-organisation, or efficiency by removing an event rather than filtering it, or avoiding unwieldy if-trees.
So, would be nice to be able to use states in modules at some point please ^^
I'm changing it to a feature request, although the description doesn't completely make sense to me -> large and complex scripts can be organized using states, but that doesn't argue for allowing states in modules, which provide for code sharing between scripts. The only thing you can't do is share an identical state definition between scripts -- i.e. two scripts have various different states, but one of the states is identical between them... not sure how that's useful.
While modules are great for code-sharing between scripts, they're also a great way to break-down a complex script. I've broken one massive script of mine (a parser) into four modules so-far for settings, functions, states, and communications (so another script can send parser requests easier), but the states have a lot in them so it'd be nice to be able to break them down-further.
Modules are therefore very good for reducing a large-script into smaller less-complex pieces, so I don't think sharing is a requirement personally.
If I were developing the same thing in an object-oriented language it's pretty much what I would have done; having a "controller" class, which then delegates to smaller "handler" classes as required. Since that's not possible in LSL I'm using states as the delegates, but it becomes quite unwieldy in a single file.
I suppose now I understand what pragma inline actually does, I could probably just put an inline function into each state and do it all that-way, and probably will for now, but I'd prefer not to =)