Re: Class Notes for a PL/I Course.

"Giuseppe Vitillaro giuseppe-yuD/ahkh7LvrZ44/[email protected] [H390-MVS]" <[email protected]> Thu, 3 Oct 2019 12:42:33 +0200 (CEST)
Newsgroups gmane.comp.emulators.hercules390.mvs
Message-ID <[email protected]>
On Thu, 3 Oct 2019, Bernd Oppolzer berndoppolzer-/[email protected] [H390-MVS] wrote:

> Hi Peppe,
>
> in traditional PL/1, there is NOTHING outside the outermost procedure,
> so the only way to have global variables is to define them in the outermost 
> procedure;
> then they are known to all inner procedures, as long as there are no 
> duplicate names
> (normal block scope rules).
>
> Remember: while in C a module consists of several functions, which are all at 
> the top
> level (no function nesting allowed), a PL/1 module consists of only one 
> procedure
> (the top level procedure), and all others are inner procedures to this top 
> procedure.
> They may be nested over and over again. Same with Pascal
> (http://bernd-oppolzer.de/job9.htm)
> the static nesting level may be limited (nine levels in case of my Pascal 
> compiler,
> which is not much).
>
> Of course, you can have external definitions, but that means static linkage 
> of
> seperately compiled modules. Does not work, if you have some sort of
> dynamic linking (like with DLLs). This is possible in PL/1, too, using the
> EXTERNAL attribute. But I guess, this is not what you were referring too.
>
> Static definitions, like in C, which are outside every function and are known
> to every function (global definitions, but know only to the current source)
> are in fact not possible in PL/1. They must be defined in the outermost 
> function.
> Then they are known to every function, too (and: they may be static or
> automatic, regarding storage class - see the STATIC or AUTO attribute;
> AUTO should be the default, but this can easily be changed on a
> per module base, using the DEFAULT RANGE(*) ... statement).
>
> HTH,
> feel free to ask more questions
>
> Kind regards
>

I guess declaring this way a variable in the main program:

DECLARE ZAZA CHARACTER(10) STATIC EXTERNAL INITIAL ( 'GIGIO' );

and using it in an external procedure in this way:

  ZZ: PROCEDURE;
     DECLARE ZAZA CHARACTER(10) EXTERNAL;
     PUT FILE(SYSPRINT) SKIP EDIT ('ZAZA=', ZAZA ) (2(A));
     RETURN;
  END ZZ;

it is the best which can be done in PL/I(F) to get something
which looks like a global C variable?

Another thing I'm looking for is something like
the C typedef syntax.

The "LIKE" syntax looks to do something similar,
but for an already "allocated" variable, if
the variable is not actually a pointer.

Anything better can be done with PL/I (F)?

Peppe.