On 01.03.2023 12:46, Josep Maria Blasco wrote:

    (snip)

    Besides, this is also *_undocumented_*: rexxref 3.3 says "If you specify 
the PUBLIC option,
    the class is visible beyond its containing Rexx program to any other 
program that references
    this program with a ::REQUIRES directive". There's nothing about CALL in 
the description of
    ::CLASS, only about ::REQUIRES (or in the description of ::ROUTINE, for 
that matter).



 Well I must say that his has surprised me. I am a believer: I believe in what manuals say. That's not the result of a special predisposition to belief, but because I think --rationally-- that I will spend less energy believing the manuals than testing everything by myself ;-)

I went to check my copy of OS/2, and Object Rexx ("OBJREXX 6.00 18 May 1999") behaves in the same way (but of course there is no .context runtime object, etc.). In that time, there were only four directives: ::CLASS, ::METHOD, ::REQUIRES and ::ROUTINE. The manual (REXX.INF) is, in that aspect, identical to rexxref: "If you specify the PUBLIC option, the class is visible beyond its containing REXX program to any other program that references this program with a ::REQUIRES directive. If you do not specify the PUBLIC option, the class is visible only within its containing REXX program. All classes defined within a program are used before PUBLIC classes created with the same name".

We seem to have inherited a longtime documentation bug. Maybe we should amend rexxref and finally recognize the rôle of call, i.e., change "to any other program that references this program with a ::REQUIRES directive" by "to any other program that references this program with a ::REQUIRES directive of a CALL instruction", and similarly for "::ROUTINE"?

What do you think? I can prepare the doc patch myself, when I find time.
Just finished with a little variation of your test programs and was surprised (like yesterday, hence wanting to come up with this variation, short of time it took until now) that .context~package~importedPackages is empty when "program.rex" (slightly amended, see below) gets called (test2.rex below) instead of getting required (test.rex below). It looks like a bug to me.

Here "program.rex" used by both client programs:

   Say "Program called." pp(.context~name)

   *::Class ClassPublic Public*
   ::Method MethodFromClassPublic
      Say "Method M called."

   *::routine pp public*
      return "["arg(1)"]"

   ::Class PrivateClass*Private*
   ::Method MethodFromPrivateClass
      Say "Method M called."

   ::routine privatePP*private*
      return "pPP["arg(1)"]PPp"

Here "test.rex", requiring "program.rex":

   pkg = .context~package     -- get access to our package (representing this 
program)
   say "this routine's name:" pp(pkg~name)
   say

   iPackages = pkg~importedPackages    -- get all imported packages
   say pp(iPackages~items) "imported package(s):"
   do counter c iPkg over iPackages
       say c":" pp(iPkg~name)
   end
   say "---"

   iClasses = pkg~importedClasses      -- get all imported classes
   say pp(iClasses~items) "imported public class(es):"
   do counter c clzName over iClasses
       clz = pkg~findPublicClass(clzName)
       say c":" pp(clzName) "from package" pp(clz~package~name)
   end
   say "---"

   iRoutines= pkg~importedRoutines     -- get all imported routines
   say pp(iRoutines~items) "imported public routine(s):"
   do counter c routineName over iRoutines
       routine = pkg~findPublicRoutine(routineName)
       say c":" pp(routineName) "from package" pp(routine~package~name)
   end
   say "---"
   say
   say "Seeking individual public classes and public routines:"
   say "findPublicClass('ClassPublic') :" pkg~findPublicClass('ClassPublic')
   say "findPublicClass('PrivateClass'):" pkg~findPublicClass('PrivateClass')
   say "findPublicRoutine('pp')        :" pkg~findPublicRoutine('pp')
   say "findPublicRoutine('privatePP') :" pkg~findPublicRoutine('privatePP')

   *::requires "program.rex"*

Here the output of running the above "test.rex" program:

   Program called. [G:\test\orx\require\program.rex]
   this routine's name: [G:\test\orx\require\test.rex]

   *[1] imported package(s):****1: [G:\test\orx\require\program.rex]*
   ---
   [1] imported public class(es):
   1: [CLASSPUBLIC] from package [G:\test\orx\require\program.rex]
   ---
   [1] imported public routine(s):
   1: [PP] from package [G:\test\orx\require\program.rex]
   ---

   Seeking individual public classes and public routines:
   findPublicClass('ClassPublic') : The CLASSPUBLIC class
   findPublicClass('PrivateClass'): The NIL object
   findPublicRoutine('pp')        : a Routine
   findPublicRoutine('privatePP') : The NIL object

Here "test2.rex", using "CALL program.rex" instead:

   pkg = .context~package     -- get access to our package (representing this 
program)
   *call "program.rex"*
   say "this routine's name:" pp(pkg~name)
   say

   iPackages = pkg~importedPackages    -- get all imported packages
   say pp(iPackages~items) "imported package(s):"
   do counter c iPkg over iPackages
       say c":" pp(iPkg~name)
   end
   say "---"

   iClasses = pkg~importedClasses      -- get all imported classes
   say pp(iClasses~items) "imported public class(es):"
   do counter c clzName over iClasses
       clz = pkg~findPublicClass(clzName)
       say c":" pp(clzName) "from package" pp(clz~package~name)
   end
   say "---"

   iRoutines= pkg~importedRoutines     -- get all imported routines
   say pp(iRoutines~items) "imported public routine(s):"
   do counter c routineName over iRoutines
       routine = pkg~findPublicRoutine(routineName)
       say c":" pp(routineName) "from package" pp(routine~package~name)
   end
   say "---"
   say
   say "Seeking individual public classes and public routines:"
   say "findPublicClass('ClassPublic') :" pkg~findPublicClass('ClassPublic')
   say "findPublicClass('PrivateClass'):" pkg~findPublicClass('PrivateClass')
   say "findPublicRoutine('pp')        :" pkg~findPublicRoutine('pp')
   say "findPublicRoutine('privatePP') :" pkg~findPublicRoutine('privatePP')

Here the output of running the above "test2.rex" program:

   Program called. [program.rex]
   this routine's name: [G:\test\orx\require\test2.rex]

   *[0] imported package(s):*
   ---
   [1] imported public class(es):
   1: [CLASSPUBLIC] from package [G:\test\orx\require\program.rex]
   ---
   [1] imported public routine(s):
   1: [PP] from package [G:\test\orx\require\program.rex]
   ---

   Seeking individual public classes and public routines:
   findPublicClass('ClassPublic') : The CLASSPUBLIC class
   findPublicClass('PrivateClass'): The NIL object
   findPublicRoutine('pp')        : a Routine
   findPublicRoutine('privatePP') : The NIL object

"test2.rex" should show "program.rex" as an imported package as do the methods importedClasses and importedRoutines.

Will file a bug for this.

---rony

_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to