HaloO, David Green wrote:
The assignment happens only when foo() is invoked. However, the variable $*Main::inner is declared at compile-time. Similarly, an "our sub inner" inside foo() would declare the name, but you couldn't call inner() until after running foo() --or bar()-- since you can't call an undefined sub.
Do you mean there is an uninitialized variable &*Main::inner that is only bound when either foo or bar are executed? How is the body handled? If there are different bodies in foo and bar, is that a "re-definition of inner" error at compile time? If not, does the body bound to &*Main::inner depend on whether foo or bar was called first? Or does it even toggle?
I don't understand what a "sub doing Package" is supposed to do. I think you get the same thing from that last example whether foo and bar are classes or whether they're subs: either way, bar will raise a redefinition error, and "say inner.new.x" will throw a "no 'inner' in scope" error.
No, a class definitely does Package. So, my classes foo and bar get two separate classes foo::inner and bar::inner and there is *no* *Main::inner class at all. In particular there should be no re-definition error in bar. This is exactly the behavior I want for subs as well. Regards, TSa. -- "The unavoidable price of reliability is simplicity" -- C.A.R. Hoare "Simplicity does not precede complexity, but follows it." -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan