Re: Packages
- Posted by Pete Lomax <petelomax at blueyonde?.co.u?> Aug 10, 2007
- 538 views
I wrote: > A couple of undecided points: > Whether dll.e and machine.e can also see r_DoStuff, or the new scope should > automatically suspend handling of an including package scope. To preserve author intent, only one package can be active at any given moment. Any notion of accessing the private details from two or more other packages is obviously as much of a plain no-no as accessing one externally. (Unless anyone can come up with an example that proves useful?) > Whether the scope name remains known/global after the <eof> It does, but only to the package statement handler. Eg:
-- counters.e package dllmach private dll_open_count = 0, allocate_count = 0, free_count = 0 <eof> -- dll.e package dllmach include counters.e global function dll_open() dll_open_count+=1 end function <eof> -- machine.e package dllmach include counters.e global function allocate() allocate_count+=1 end function global function free() free_count+=1 end function <eof> -- stats.e package dllmach include counters.e procedure show_stats() printf(1,"dll_open called %d times\n",dll_open_count) ... end procedure <eof>
Then you could include stats.e at the end of the main file and it wouldn't matter whether one, both, or neither dll.e nor machine.e had been included earlier, or if they had been included in completely separate sub-include branches. Naturally if two or more third party libs happen to use the same package name then clashes could arise, but that's just tough, imo. Regards, Pete