master.do:
outer.do:
inner.do:
Result:
I did not expect -program drop inner- to fail the second time.
I notice that -program dir- shows a program named outer.inner. My best guess is that -program drop inner- tries to drop program "inner", which fails because there is no program "inner" in memory. Then -program define inner- fails because it's actually trying to define program "outer.inner", which is already defined. The error message "program inner already defined" actually means "program outer.inner already defined". (This would require that that -program define- and -program drop- behave asymmetrically, but I don't have a better idea.)
I tried dropping outer.inner, but I get "subprograms not allowed".
I can work around the issue by moving -include inner.do- from outer.do to master.do, but this comes at the expense of managing outer.do's dependencies (i.e. inner.do) on its behalf, and I don't feel like I should be responsible for them. Am I missing a more elegant solution?
Code:
include outer.do outer outer
Code:
capture noisily program drop outer program outer include inner.do di "This is the outer program." inner end
Code:
capture noisily program drop inner program inner di "This is the inner program." end
Code:
. do master.do . include outer.do . capture noisily program drop outer program outer not found . program define outer 1. include inner.do 2. di "This is the outer program." 3. inner 4. end . . . outer . capture noisily program drop inner program inner not found . program define inner 1. di "This is the inner program." 2. end . This is the outer program. This is the inner program. . outer . capture noisily program drop inner program inner not found . program define inner program inner already defined r(110); r(110); end of do-file r(110);
I notice that -program dir- shows a program named outer.inner. My best guess is that -program drop inner- tries to drop program "inner", which fails because there is no program "inner" in memory. Then -program define inner- fails because it's actually trying to define program "outer.inner", which is already defined. The error message "program inner already defined" actually means "program outer.inner already defined". (This would require that that -program define- and -program drop- behave asymmetrically, but I don't have a better idea.)
I tried dropping outer.inner, but I get "subprograms not allowed".
I can work around the issue by moving -include inner.do- from outer.do to master.do, but this comes at the expense of managing outer.do's dependencies (i.e. inner.do) on its behalf, and I don't feel like I should be responsible for them. Am I missing a more elegant solution?
Comment