Stack name conflicts resolved?

Mark Waddingham mark at
Mon Nov 7 13:01:26 EST 2016

On 2016-11-05 19:28, Richard Gaskin wrote:
> I've grown weary of stack name conflict over the years, and this
> morning decided to take some time to assess where we're really at with
> that and see if perhaps there's a way to handle things more liberally
> than how the IDE does now.
> That is, once we modify the IDE to allow it.
> Is there something I've missed here?

The engine has always been 'okay' (I believe) with substacks of the same 
name when they are owned by *different* mainstacks - the only rule you 
must follow in your code is that if you are referencing a substack when 
the 'defaultStack' is not the main stack owning it, then you must use:

   stack ... of stack ...

Just as you would if you have two controls with the same name in two 
different groups.

There is still the general problem of having multiple mainstacks with 
the same name, or multiple substacks with the same name with the same 
owner. Unfortunately, I'm not sure there is a general solution to that 
(mainly because we use stack <name> as the reference for a specific 
stack in script, and when you start making cross-stack references, any 
search order is likely to cause 'surprising' results at unexpected 

I'd perhaps use the observation that you wouldn't expect to have two 
files in the same folder with the same name on disk... So why expect to 
be able to have two mainstacks with the same name in memory? (Or indeed, 
two substacks with the same name owned by the same stack).

I think it would be generally true to say that in one project, you don't 
want more than one (main) stack with the same name - as you would never 
know what stack you were referring to in script. I'd actually propose 
that the only use-case for multiple (main) stacks with the same name is 
for the purposes of editing (in the IDE) - e.g. so you can compare and 
contrast two revisions of the same stackfile. However, beyond opening 
two instances of the IDE, that isn't possible at present.

I do wonder if the engine was a little bit more hard-line about stack 
naming if some of the issues people find might go away. Also, it *might* 
be reasonable for the engine to actually rename a stack when loaded if 
there is already one with the same name in memory - so you can at least 
access it; although it might not work because its scripts might still be 
using 'stack <name>' to refer to itself (which, of course, would refer 
to the originally opened stack and not itself).

In regards to the IDE as it is now - it uses long ids to reference 
objects internally throughout - and because this means substacks are 
always references as stack X of stack Y, it now does not break if you 
have two substacks with the same name in memory. (However 'the finding 
the right stack' problem still exists if you have a substack anywhere 
with the same name as a mainstack).

Warmest Regards,


Mark Waddingham ~ mark at ~
LiveCode: Everyone can create apps

More information about the Use-livecode mailing list