Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
PL/I
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Storage classes=== PL/I provides several 'storage classes' to indicate how the lifetime of variables' storage is to be managed{{snd}} <code>STATIC</code>, <code>AUTOMATIC</code>, <code>CONTROLLED</code>, and <code>BASED</code>, and <code>AREA</code>. <code>STATIC</code> data is allocated and initialized at load-time, as is done in [[COBOL]] "working-storage" and early [[Fortran]]. This is the default for <code>EXTERNAL</code> variables (similar to C “extern” or Fortran “named common"), <code>AUTOMATIC</code> is PL/I's default storage class for <code>INTERNAL</code> variables, similar to that of other block-structured languages influenced by [[ALGOL]], like the "auto" storage class in the [[C (programming language)|C]] language, the default storage allocation in [[Pascal (programming language)|Pascal]], and "local-storage" in IBM COBOL. Storage for <code>AUTOMATIC</code> variables is allocated upon entry into the procedure, <code>BEGIN</code>-block, or <code>ON</code>-unit in which they are declared. The compiler and runtime system allocate memory for a [[stack frame]] to contain them and other housekeeping information. If a variable is declared with an <code>INITIAL</code>-attribute, code to set it to an initial value is executed at this time. Care is required to manage the use of initialization properly. Large amounts of code can be executed to initialize variables every time a scope is entered, especially if the variable is an array or structure. Storage for <code>AUTOMATIC</code> variables is freed at block exit. <code>STATIC</code>, <code>CONTROLLED</code>, or <code>BASED</code> variables are used to retain variables' contents between invocations of a procedure or block. <code>CONTROLLED</code> storage is managed using a stack, but the pushing and popping of allocations on the stack is managed by the programmer, using <code>ALLOCATE</code> and <code>FREE</code> statements. Storage for <code>BASED</code> variables is also managed using <code>ALLOCATE</code>/<code>FREE</code>, but instead of a stack these allocations have independent lifetimes and are addressed through <code>OFFSET</code> or <code>POINTER</code> variables. <code>BASED</code> variables can also be used to address arbitrary storage areas by setting the associated <code>POINTER</code> variable, for example following a [[linked list]]. The <code>AREA</code> attribute is used to declare programmer-defined [[heap (programming)|heaps]]. Data can be allocated and freed within a specific area, and the area can be deleted, read, and written as a unit.<ref name="IBMLR43">{{cite book |publisher=IBM |title=Enterprise PL/I for z/OS PL/I for AIX Rational Developer for System z PL/I for Windows: Language Reference |date=September 2012 |edition=Third |id=SC14-7285-02 |url=https://publibfp.dhe.ibm.com/epubs/pdf/ibm4lr02.pdf |access-date=July 9, 2023}}</ref>{{rp|pp.235– 274}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)