In languages where the default is automatic (PL/I and C, for example), it is usual for variables in MAIN to be automatic. The compiler compiles MAIN the same way, with a special routine that does some setup before calling actual MAIN.
In the case of PL/I with multitasking, it is possible for MAIN to be reentrant. (I don't know all the details now, but pseudo-registers are used to keep track of data that is different for different tasks, and isn't on a stack or linked list.) To answer the question, in the case of multitasking you have to be careful with static variables in main. The usual implementation on OS/360 descendants is a linked list with dynamically allocated list entries as save areas, logically, but not physically, a stack. Static variables are generated using an appropriately named CSECT. Hope this helps. --glen -----Original Message----- From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf Of Frank Swarbrick Sent: Friday, August 7, 2015 2:26 PM To: [email protected] Subject: z/OS stack vs heap storage Don't want to work on a Friday afternoon, so a question for you all... I come from the VSE world where COBOL still does not have a LOCAL-STORAGE SECTION, so our code doesn't use that "new" feature (new within the last 20 years, I guess!). I know generally for a subroutine when you would want to use WORKING-STORAGE (heap/static) vs. LOCAL-STORAGE (automatic/stack). I am curious is there any reason you'd ever want to use LOCAL-STORAGE in a MAIN program. It looks like for PL/I the default is AUTOMATIC. I don't know if this "implies" anything with regard to COBOL storage types. Thanks, Frank ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
