Chapter 8. Subroutines, Functions, and Modularity
Overview
Rexx fully supports structured programming. It encourages modularity — breaking up large, complex programs into a set of small, simple, interacting components or pieces. These components feature well-defined interfaces that render their interaction clear. Modularity underlies good program structure. Modularity means more easily understood and maintained programs than ill-designed "spaghetti" code, which can quickly become unmaintainable on large programming projects. Structured programming practices and modularity together reduce error rates and produce more reliable code.
Rexx provides the full range of techniques to invoke other programs and to create subroutines and functions. The basic concept is that there should be ways to link together any code you create, buy, or reuse. This is one of the fundamental advantages to using a "glue" language like Rexx.
With Rexx, you can develop large, modular programs that invoke routines written in Rexx or other languages, which issue operating system commands and utilize functions packaged in external function libraries. This chapter describes the basic ways in which one writes modular Rexx programs.
This chapter investigates how to write internal subroutines and functions, and how to call them from within the main program. Passing arguments or values into subroutines is an important issue, as is the ability to pass changed values back to the calling program. Variable scoping refers to ...
Get Rexx Programmer's Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.