Oppolzer - Informatik / Blog


Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie

IBM-MAIN - Speicherklassen static und auto in C, PL/1, COBOL, ASSEMBLER ...

Subject:

Re: abend S602-0 when in AMODE 64

From:

Bernd Oppolzer <bernd.oppolzer@T-ONLINE.DE>

Reply-To:

IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU>

Date:

2015.01.17 11:16:00


all languages:

static vs. auto: different allocation technique and time, as already explained;
static: allocated once, lifetime of the variable is the whole process
auto: allocated on every call of the proc or function, removed at the end

in C: keyword static to denote static variables, no keyword for auto, but:
see below

in PL/1: keywords STATIC and AUTO, defaults set by DEFAULT RANGE
(normally AUTO)

in COBOL: WORKING STORAGE, LOCAL STORAGE (I'm no COBOL wizard)

Now there are some peculiarities:

most "old" compilers put the static variables in STATIC CSECT in the load module,
which is OK, but makes the module not reentrant (because it is changed at runtime,
if the static variables are not constant ... you see the difference between static
and constant)

now some new compilers (inspired by C++, where this is common or even necessary)
allow to put the static variables in a special dynamic area called WSA (writable static area)
allocated at process start (for every process once), so the modules stay reentrant,
although they change their static variables. Option RENT with PL/1 and C,
don't know for COBOL.

Furthermore, there is one thing, which makes headaches with C:

the keyword "static" is also used to denote functions and variables in the source code, that are
not external, that is, are not known to the linkage editor. This is gaga in my opinion;
this keyword should have been "local", but the designers of C chose to reuse
"static" here, because they wanted to save keywords, and external functions
and variables are static (in the sense above), anyway.

and the last thing:

static NEVER means constant ... there are other keywords in all the languages
to denote constant values (more or less effective).

Kind regards

Bernd



Am 17.01.2015 um 09:42 schrieb P.H.:
> I'd say that it is C that confused static with constant.
>
>
>> Humans would think of static data as being constant (at least constant once loaded).
>> "Writeable static" is, to me, an oxymoron.
>
>
> "Static" is just one of the terms used with computing that is being used with
> different meanings. When I started to work on IBM mainframes in 83, the first language
> I go taught was PL/I. PL/I distinguishes between "static" and "dynamic" storage for variables.
>
> Storage for static variables, i.e. variables declared with the STATIC keyword,
> is "allocated" in the so called static CSECT that becomes part of the object module.
> Note that this *is* read/write storage, so in PL/I STATIC does not mean constant.
>
> Storage for dynamic variables will be allocated at run time.
>
> PL/I did not have constants until the advent of Enterprise PL/I. You define a constant
> by defining its value via VALUE() keyword instead of the usual INITIAL() keyword.
>
> Also new with Enterprise PL/I is the ASSIGNABLE/NONASSIGNABLE attribute for variables.
> So, STATIC as well as dynamic variables can be writable or not (i.e. constant after
> being initialized).
>
> --
> P.H.
>

Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie