• DEFINE CONSTANT

    From John Cowan@21:1/5 to All on Mon Sep 5 20:03:10 2022
    I'm having trouble understanding the DEFINE CONSTANT statement. I know
    that:

    1) It is a variant of the DECLARE statement.

    2) It declares constants rather than variables.

    3) It can only appear at the top of a package, procedure, or begin-block.

    What I'm unclear on is how you specify its value. The IBM, Kednos, and
    VOS manuals have nothing to say about DEFINE CONSTANT. The ANSI standard
    isn't very helpful either. Is the INITIAL attribute used, or is this
    where the VALUE attribute comes in (also undocumented)?



    --
    IF IF = THEN THEN THEN = ELSE ELSE ELSE = IF;

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robin Vowels@21:1/5 to co...@ccil.org on Mon Sep 5 13:53:25 2022
    On Tuesday, September 6, 2022 at 6:03:16 AM UTC+10, co...@ccil.org wrote:
    I'm having trouble understanding the DEFINE CONSTANT statement. I know
    that:

    1) It is a variant of the DECLARE statement.

    2) It declares constants rather than variables.

    3) It can only appear at the top of a package, procedure, or begin-block.

    What I'm unclear on is how you specify its value. The IBM, Kednos, and
    VOS manuals have nothing to say about DEFINE CONSTANT. The ANSI standard isn't very helpful either. Is the INITIAL attribute used, or is this
    where the VALUE attribute comes in (also undocumented)?

    I think you mean the DECLARE statement with the VALUE attribute.
    .
    e.g. DECLARE PI VALUE (3.1415928E0) FLOAT (10);
    .
    This is an example of a named constant.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Cowan@21:1/5 to Robin Vowels on Mon Sep 5 15:35:35 2022
    On Monday, September 5, 2022 at 4:53:26 PM UTC-4, Robin Vowels wrote:

    e.g. DECLARE PI VALUE (3.1415928E0) FLOAT (10);
    .
    This is an example of a named constant.

    Ah, thanks. But the DEFINE CONSTANT statement is part of ANSI X3.74-1987, the revised version of PL/I Subset G. So I assume it looks like:

    DEFINE CONSTANT PI VALUE(3.1415928E0) FLOAT(10);

    I'm working on a reference manual for Subset G based on the Kednos reference manual. I removed everything that's not in the ANSI standard, which is straightforward, and added everything that is not in Kednos but is in the ANSI standard, which requires
    understanding of those things. The VOS and IBM manuals provide most of what I need, but the truly new things like DEFINE CONSTANT and the enquiry functions require deciphering the ANSI standard. The concrete and abstract syntax are easy enough, but the
    semantics are defined by writing a PL/I interpreter in English prose, and that's not easy to understand.

    --
    IF IF = THEN THEN THEN = ELSE ELSE ELSE = IF;

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flass@21:1/5 to John Cowan on Mon Sep 5 17:23:27 2022
    John Cowan <cowan@ccil.org> wrote:
    On Monday, September 5, 2022 at 4:53:26 PM UTC-4, Robin Vowels wrote:

    e.g. DECLARE PI VALUE (3.1415928E0) FLOAT (10);
    .
    This is an example of a named constant.

    Ah, thanks. But the DEFINE CONSTANT statement is part of ANSI
    X3.74-1987, the revised version of PL/I Subset G. So I assume it looks like:

    DEFINE CONSTANT PI VALUE(3.1415928E0) FLOAT(10);

    I'm working on a reference manual for Subset G based on the Kednos
    reference manual. I removed everything that's not in the ANSI standard, which is straightforward, and added everything that is not in Kednos but
    is in the ANSI standard, which requires understanding of those things.
    The VOS and IBM manuals provide most of what I need, but the truly new
    things like DEFINE CONSTANT and the enquiry functions require deciphering
    the ANSI standard. The concrete and abstract syntax are easy enough, but
    the semantics are defined by writing a PL/I interpreter in English prose,
    and that's not easy to understand.


    Does Kednos use “OPTIONS(CONSTANT)”, like Multics? Some of the more “recent” PL/I features seem to use a mish-mash of syntax among different compilers. (Just for the record, Iron Spring PL/I uses DECLARE with the
    VALUE keyword, like some IBM versions).

    Your manual sounds like a worthwhile project.

    --
    Pete

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Cowan@21:1/5 to bearlyabus...@gmail.com on Mon Sep 5 19:05:31 2022
    On Monday, September 5, 2022 at 8:23:28 PM UTC-4, bearlyabus...@gmail.com wrote:

    Does Kednos use “OPTIONS(CONSTANT)”, like Multics?

    No, it doesn't.

    Your manual sounds like a worthwhile project.

    I'm glad to hear you think so.

    My next step, assuming I live so long, is to write a PL/I-to-GNU-C compiler. I've figured out a list of extensions to Subset G (complex numbers, C interoperability, FIXED BINARY numbers with nonzero scales, etc.) and a bunch of existing C packages that
    will help (DECIMAL FIXED and FLOAT, non-local GOTOs, ISAM files, etc.) Two packages that I'll need to write are for pictures and for formats, with help from sprintf().

    The compiler, at least its first version, will be written in Python and will use a PEG parser.



    --
    IF IF = THEN THEN THEN = ELSE ELSE ELSE = IF.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robin Vowels@21:1/5 to co...@ccil.org on Mon Sep 5 18:24:08 2022
    On Tuesday, September 6, 2022 at 8:35:36 AM UTC+10, co...@ccil.org wrote:
    On Monday, September 5, 2022 at 4:53:26 PM UTC-4, Robin Vowels wrote:

    e.g. DECLARE PI VALUE (3.1415928E0) FLOAT (10);
    .
    This is an example of a named constant.
    Ah, thanks. But the DEFINE CONSTANT statement is part of ANSI X3.74-1987, the revised version of PL/I Subset G. So I assume it looks like:

    DEFINE CONSTANT PI VALUE(3.1415928E0) FLOAT(10);

    I'm working on a reference manual for Subset G based on the Kednos reference manual. I removed everything that's not in the ANSI standard, which is straightforward, and added everything that is not in Kednos but is in the ANSI standard, which requires
    understanding of those things. The VOS and IBM manuals provide most of what I need, but the truly new things like DEFINE CONSTANT and the enquiry functions require deciphering the ANSI standard. The concrete and abstract syntax are easy enough, but the
    semantics are defined by writing a PL/I interpreter in English prose, and that's not easy to understand.
    .
    There's no such statement in the current (2022) IBM LRM, nor in IBM PL/I for OS/2.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robin Vowels@21:1/5 to co...@ccil.org on Mon Sep 5 19:54:31 2022
    On Tuesday, September 6, 2022 at 8:35:36 AM UTC+10, co...@ccil.org wrote:
    On Monday, September 5, 2022 at 4:53:26 PM UTC-4, Robin Vowels wrote:

    e.g. DECLARE PI VALUE (3.1415928E0) FLOAT (10);
    .
    This is an example of a named constant.
    Ah, thanks. But the DEFINE CONSTANT statement is part of ANSI X3.74-1987, the revised version of PL/I Subset G. So I assume it looks like:

    DEFINE CONSTANT PI VALUE(3.1415928E0) FLOAT(10);

    I'm working on a reference manual for Subset G based on the Kednos reference manual. I removed everything that's not in the ANSI standard, which is straightforward, and added everything that is not in Kednos but is in the ANSI standard, which requires
    understanding of those things. The VOS and IBM manuals provide most of what I need, but the truly new things like DEFINE CONSTANT and the enquiry functions require deciphering the ANSI standard. The concrete and abstract syntax are easy enough, but the
    semantics are defined by writing a PL/I interpreter in English prose, and that's not easy to understand.
    .
    DEFINE CONSTANT is not in either the Uniprise PL/I LRM, nor the Stratus VOS PL/I LRM.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flass@21:1/5 to John Cowan on Tue Sep 6 11:31:39 2022
    John Cowan <cowan@ccil.org> wrote:
    On Monday, September 5, 2022 at 8:23:28 PM UTC-4, bearlyabus...@gmail.com wrote:

    Does Kednos use “OPTIONS(CONSTANT)”, like Multics?

    No, it doesn't.

    Your manual sounds like a worthwhile project.

    I'm glad to hear you think so.

    My next step, assuming I live so long, is to write a PL/I-to-GNU-C
    compiler. I've figured out a list of extensions to Subset G (complex numbers, C interoperability, FIXED BINARY numbers with nonzero scales,
    etc.) and a bunch of existing C packages that will help (DECIMAL FIXED
    and FLOAT, non-local GOTOs, ISAM files, etc.) Two packages that I'll
    need to write are for pictures and for formats, with help from sprintf().

    The compiler, at least its first version, will be written in Python and
    will use a PEG parser.




    That would be great. There was a GNU PL/I project a while ago, but that
    seems to be dead. Have you thought about targeting the Gnu intermediate language, whatever it’s called, instead of C?

    --
    Pete

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Cowan@21:1/5 to bearlyabus...@gmail.com on Tue Sep 6 15:45:34 2022
    On Tuesday, September 6, 2022 at 2:31:41 PM UTC-4, bearlyabus...@gmail.com wrote:

    That would be great. There was a GNU PL/I project a while ago, but that seems to be dead. Have you thought about targeting the Gnu intermediate language, whatever it’s called, instead of C?

    Yes, for about five minutes. :-)

    PL/I's data model is really very close to C, so that it should be very easy to make the languages interoperate without much fuss. Each PL/I compilation unit foo.pli will produce both a foo.c and a foo.h file so that it will be possible to invoke PL/I
    procedures from C (modulo the main procedure will have to be in PL/I to set up the default condition processing, etc.)

    It would be very nice if something could be written to take a .h file and produce a PL/I equivalent, but the difficulty is that .h files are just random fragments of C that don't have to cohere: pretty much every language except C++ has this problem. I
    tried looking into SWIG, which is supposed to do this job, but it failed on most of the .h files I tried it on and its output is fiendishly complex. Most of the things labeled "alternatives to SWIG" are very specialized.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flass@21:1/5 to John Cowan on Wed Sep 7 07:01:02 2022
    John Cowan <cowan@ccil.org> wrote:
    On Tuesday, September 6, 2022 at 2:31:41 PM UTC-4, bearlyabus...@gmail.com wrote:

    That would be great. There was a GNU PL/I project a while ago, but that
    seems to be dead. Have you thought about targeting the Gnu intermediate
    language, whatever it’s called, instead of C?

    Yes, for about five minutes. :-)

    PL/I's data model is really very close to C, so that it should be very
    easy to make the languages interoperate without much fuss. Each PL/I compilation unit foo.pli will produce both a foo.c and a foo.h file so
    that it will be possible to invoke PL/I procedures from C (modulo the
    main procedure will have to be in PL/I to set up the default condition processing, etc.)

    It would be very nice if something could be written to take a .h file and produce a PL/I equivalent, but the difficulty is that .h files are just random fragments of C that don't have to cohere: pretty much every
    language except C++ has this problem. I tried looking into SWIG, which
    is supposed to do this job, but it failed on most of the .h files I tried
    it on and its output is fiendishly complex. Most of the things labeled "alternatives to SWIG" are very specialized.


    I think Robin has something to do this.

    A few years ago I played around with porting VAX SDL, which is a
    generalized version of this.It maintains a data dictionary and can emit
    headers in a number of languages. I think it can accept any of the
    supported languages as input. Unfortunately, like a lot of useful old stuff
    it has modules written in a number of languages, so it’s not just a straightforward port - so far I’ve seen MACRO-32, BLISS-32, and PL/I.

    --
    Pete

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)