> >If you want really use such constructs, you can't put them in different > >compilation units, because they are basically one unit. > > So a BASIC IMCC program, with all of the builtin functions it needs, plus > the actual user program itself as one compilation unit? All for the sake > of a few needed globals? Sounds ghastly.
No. Global things shouldn't be in registers in the first place, because you're using up your computation resources for things that have a very long lifetime. > >Much better is to implement some kind of calling conventions. > > Except that these represent true global data structures that the entire > BASIC machine needs. They're not really things to be passed around from > place to place and the thought of having a Px register to hold the "state > of BASIC" and passing it (potentially) everywhere seems kinda silly for a > language that isn't really threaded in any incarnation and is ever only > going to need one state. If you use them often... then maybe one or two need a real register, but I'd still be weary of doing that. Use find_global and its friends. > I've *got* good, sound calling conventions now but there are things (sofar, > only half a dozen*) that exist in an outermost scope that need initialization. > > I could turn the whole thing upside-down (subs first, main last) except > that I'd need a token outer main() to call the initialization routine. And > from a quick test IMCC can tell that the execution path jumped down, and > optimizes those registers away anyway. Nevermind. > > Further suggestions, given better info? > > > * Examples of things that are really global in a BASIC machine: current > random number seed, cursor column position, console current character > attributes, last value picked up from a READ/DATA combo (line & position), > structure definition table, and a GOSUB call-stack lookback specifically > for "RETURN x". Yeah, most of those seem like they can be stored in the global name table instead of a register. Load them in when you need them. Except the latter, which seems like you should be using the call stack, if I'm not misunderstanding. Luke