On Tue, Feb 12, 2013 at 2:51 PM, Staffan Tylen <staffan.tylen@gmail.com> wrote:
I'm fiddling with the .Package class and have found that if I create a new package from an array of rexx code, the new package is immediately executed by the init method. Is this the way it is supposed to work? Example:

a=.array~new
a~append("say 'hi this is me'")
a~append("say 'bye'")
p=.package~new("package1",a)


I haven't played with the .Package class much, but it says this in the doc:

The files loaded by ::REQUIRES are also contained in Package class instances.

So, I think that p = .Package~new()

is going to behave like:

::requires 'p.txt'

and if p.txt is

say 'hi this is me'
say 'bye'

Then when you require p.txt those 2 lines of code are going to run.  Which is what happens in your test.  Change your test to this

a=.array~new
a~append("::routine speak public")
a~append("say 'hi this is me'")
a~append("say 'bye'")
a~append("return 0")
p=.package~new("package1",a)
r = speak()

and try it.

Although I just did and it didn't work as I expected.  But, it is more like what I think should work.

--
Mark Miesfeld