Developing scene Luup code without constant reloads

Can I share this recent revelation without being shamed by my ignorance that this is, perhaps, common practice…?

I’ve always found it a complete pain to debug scene Luup code:

[ul][li]into the scene editor; [/li]
[li]make changes; [/li]
[li]save them; [/li]
[li]reload; [/li]
[li]wait; [/li]
[li]examine logs/variables; [/li]
[li]go round again… [/li][/ul]

…the biggest pain being the wait for reload - but what else to do?

The answer, of course, is to modify code on the fly without a reload.

Question: How to do that?
Answer: Put the code in a simple-to-access shared place.
Question: Where is that?
Answer: “[tt]Startup Lua[/tt]”.

So, for example, in my [tt]Startup Lua[/tt] I define:

akbooer = {}    -- (let's ignore the deeper philosophical possibilities of the statement)

In my [tt]scene Luup code[/tt], a simple one-liner:

akbooer.test()   --- possibly with some useful parameters from the local environment

Then, whenever I like, I can create any definition of [tt]akbooer.test[/tt] in [tt]Test Luup Code[/tt]:

function akbooer.test() -- do interesting things here end

and, magically, any subsequent activation of the scene with the call to this function runs the new definition (which, of course, can now be deleted here because the code is now pointed to by the global.) No reload, no waiting. I can change the function definition anytime I like.

In fact, rather than just using this method for debugging, I’m leaning towards using it as a standard approach for all scene Luup.

Now, the acid test - Am I:

[ol][li]rather behind the curve in realizing this?[/li]
[li]horribly mistaken, and there is a very good reason not to do this?[/li]
[li]completely missing some obvious alternative?[/li][/ol]

I await the judgement of those older and wiser (or, indeed, younger and less foolish) in the Vera / Luup / Lua school of hard knocks.

I see that I’m following a well-trodden path to having shared code in [tt]Startup Lua[/tt] along the lines of:
[url=http://forum.micasaverde.com/index.php/topic,6589.msg41024.html]http://forum.micasaverde.com/index.php/topic,6589.msg41024.html[/url]

There, @guessed suggested using [tt]require[/tt] to load a module, whereas I’ve been doing it the hard way, manually.

I’m really just extolling the virtues of being able to redefine global functions without having to reload all the time.

Actually your process is better … A second require of modified code will fail.
(But there are ways around that … but you are getting intimate with the run-time environment.)

A better approach is to test in a standalone LUA interpreter until the code is debugged.

That sounds very useful. Where is the UI for the stand-alone LUA interpreter that you speak of?

Several suggestions for development environments here:
[url=http://forum.micasaverde.com/index.php/topic,12530.msg106861.html#msg106861]http://forum.micasaverde.com/index.php/topic,12530.msg106861.html#msg106861[/url]