Page 2 of 2

Re: Standalone compile never leaves closing open stacks

Posted: Wed Nov 18, 2020 10:33 pm
by jacque
It was an intentional change so there's no reason to send a report to LC. There was a discussion on the mailing list about it, here is what I saved:
The standalone builder has always needed to close the stacks it builds for reasons pretty deeply ingrained in the code. However this causes a few problems, for example:
values in script locals become empty
behaviors are broken when the parent script is on / in a stack which closes

As an attempt to improve this situation, the code that locks messages when closing and opening stacks for standalone builds has been removed. This means that where previously mainstacks would not receive openStack and closeStack messages during standalone build, they now do.

If this causes problems for your stack, you can exit from the handler if standalone building is in progress:

on closeStack
if the environment is "development" AND there is a stack
"revStandaloneProgress" AND the mode of stack
"revStandaloneProgress" > 0 then
exit closeStack
end if
...
...
end closeStack

All stack-related messages need to use this: preOpen*, open*, close*, etc.
So you could write a function:

function isBuildingStandalone
return the environment is "development" AND \
there is a stack "revStandaloneProgress" AND \
the mode of stack "revStandaloneProgress" > 0
end isBuildingStandalone

and then in e.g. the openstack handler:

on openstack
if isBuildingStandalone() then
exit openstack
end if
..
..
end openstack

Similar in all other (pre)open*/close* messages.

Kind regards,
Panos

Re: Standalone compile never leaves closing open stacks

Posted: Thu Nov 19, 2020 2:13 am
by stam
That's really interesting and good to know - thanks Jacque
Don't think i've seen that in the documentation or as a lesson but it should be!

Re: Standalone compile never leaves closing open stacks

Posted: Thu Nov 19, 2020 8:25 pm
by dr_mumps
Fantastic!!! This solved all of the compile problems I was having ... I'm very happy about now being able to use the latest version of LC. However... one question remains...

If this code is REQUIRED in those sorts of handlers... why leave it to the developer to REMEMBER to specify it when the Standalone compiler SHOULD do automatically. IMHO... one of the characteristics that define a good programmer is that they want to be EXTREMELY lazy ... in that if they can avoid extra steps, that makes their output more efficient. So, naturally, we want the tool to do as much of the grunt work as possible.

Just my 5 cents (inflation) worth ... Thanks everyone for their contributions to this issue. What a great group!

Now if we can get the forum search functionality improved, I'll be in heaven.

Re: Standalone compile never leaves closing open stacks

Posted: Fri Nov 20, 2020 7:54 pm
by jacque
If this code is REQUIRED in those sorts of handlers... why leave it to the developer to REMEMBER to specify it when the Standalone compiler SHOULD do automatically
I'm not sure how they could do it any other way. When messages were locked there was no problem, but when unlocking messages to fix the problems they listed, the standalone builder no longer has any control. Messages are sent through the message path normally after the SB passes them.

I've built several standalones since the change was made and never needed to employ the fix, so it does depend on what the handlers do.

Re: Standalone compile never leaves closing open stacks

Posted: Fri Nov 20, 2020 8:03 pm
by Klaus
Maybe the mothership could add another "messageless" application which will create the standalone?

Re: Standalone compile never leaves closing open stacks

Posted: Fri Nov 20, 2020 8:31 pm
by FourthWorld
Klaus wrote:
Fri Nov 20, 2020 8:03 pm
Maybe the mothership could add another "messageless" application which will create the standalone?
^ this

In MC building a standalone was not a disruptive process. It shouldn't be in LC either, and certainly shouldn't require modifying code just to build.