Base Classes and the file load order

This is a question and if there’s no answer, a suggestion.

I understand that the order that files are loaded in is based on sorting them by name.

I’ve got classes StackMember, Bean and Pod. Bean and Pod have StackMember as their super class, so scattered over files I’ve got:

In tab “StackMember”
StackMember = class()

In tab “Bean”
Bean = class(StackMember)

In tab “Pod”
Pod = class(StackMember)

But my code doesn’t work, and I’m pretty sure the reason is when “Bean” and “Pod” are run “StackMember” hasn’t been run yet, so ’ = class(StackMember)’ is actually just ’ = class(nil)’ or simply ‘= class()’ – they’re not getting a base class.

I can fix this by putting the code for StackMember in to “AStackMember”, but that kind of sucks.

I’d like a way for “Bean” and “Pod” to request that “StackMember” is “loaded” before them, similar to the “require” method that’s available in Lua, really. Lets call it “need(fileName)”.

Codea could still use the file name order collect, but as it’s collecting files, if it gets a call to “need(fileName)”, and if fileName hasn’t already been loaded, then it loads fileName now, then continues as it was. It’s possible to cause a loop with this, but it’s easy to detect that and report an error.

Okay, I’m wrong :slight_smile: The tab load order is in the order of tabs, which makes it a lot nicer. Maybe that means this feature isn’t needed at all?

Hi @benjohn, yes the tabs used to be stuck in place and loaded in alphabetical order, but now we can drag them about.