• What's the difference between a ::ROUTINE and a procedure?

    From Robert Bridges@21:1/5 to All on Sun May 31 13:06:12 2020
    So I wrote my first working ooRexx program (thanks offered to those who helped me over the first hump). Now I'm reading the programmer's guide in a more leisurely fashion, and I've paused to contemplate the ::ROUTINE directive:

    "You use the ::ROUTINE directive to create a named routine within a program. The ::ROUTINE directive starts the named routine and another directive (or the end of the program) ends the routine.

    "The ::ROUTINE directive is useful organizing functions that are not specific to a particular class type."

    Sounds like a procedure to me. What's the difference?

    /* Code example */
    call routine
    exit 0

    routine: procedure
    say 'Hi, there!'

    ::ROUTINE routine
    say 'Hi, there!'
    /* code ends */

    In this simplest form, is there any practical difference? (I do see from the definition in the Reference that ::ROUTINE can do other things as well, though I'm still absorbing exactly what those are.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rick McGuire@21:1/5 to All on Sun May 31 14:36:57 2020
    One other important difference with ::ROUTINE is scope. A procedure, since it depends on labels, is only visible within the code unit that declares the label. A ::ROUTINE can be accessed by any other code unit (such as within a ::METHOD).

    Rick

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rick McGuire@21:1/5 to Robert Bridges on Sun May 31 14:30:23 2020
    On Sunday, May 31, 2020 at 4:06:13 PM UTC-4, Robert Bridges wrote:
    So I wrote my first working ooRexx program (thanks offered to those who helped me over the first hump). Now I'm reading the programmer's guide in a more leisurely fashion, and I've paused to contemplate the ::ROUTINE directive:

    "You use the ::ROUTINE directive to create a named routine within a program. The ::ROUTINE directive starts the named routine and another directive (or the end of the program) ends the routine.

    "The ::ROUTINE directive is useful organizing functions that are not specific to a particular class type."

    Sounds like a procedure to me. What's the difference?

    /* Code example */
    call routine
    exit 0

    routine: procedure
    say 'Hi, there!'

    ::ROUTINE routine
    say 'Hi, there!'
    /* code ends */

    In this simplest form, is there any practical difference? (I do see from the definition in the Reference that ::ROUTINE can do other things as well, though I'm still absorbing exactly what those are.)

    A ::ROUTINE is invoked like an external call, so it gets a new variable set, does not inherit things like digits settings or signal traps. It also cannot see labels in the main program. Using PROCEDURE on an internal call just creates the new variable
    set, the other settings get inherited from the caller.

    One big advantage of using ::ROUTINE is that you can group a large number of functions in a single file and call them from other programs by using ::REQUIRES to access them.

    Rick

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)