Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DEFINE CONSTANT

45 views
Skip to first unread message

John Cowan

unread,
Sep 5, 2022, 4:03:16 PM9/5/22
to
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;

Robin Vowels

unread,
Sep 5, 2022, 4:53:26 PM9/5/22
to
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.

John Cowan

unread,
Sep 5, 2022, 6:35:36 PM9/5/22
to
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.

Peter Flass

unread,
Sep 5, 2022, 8:23:28 PM9/5/22
to
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

Robin Vowels

unread,
Sep 5, 2022, 9:24:09 PM9/5/22
to
.
There's no such statement in the current (2022) IBM LRM, nor in IBM PL/I for OS/2.

John Cowan

unread,
Sep 5, 2022, 10:05:32 PM9/5/22
to
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.

Robin Vowels

unread,
Sep 5, 2022, 10:54:32 PM9/5/22
to
On Tuesday, September 6, 2022 at 8:35:36 AM UTC+10, co...@ccil.org wrote:
.
DEFINE CONSTANT is not in either the Uniprise PL/I LRM, nor the Stratus VOS PL/I LRM.

Peter Flass

unread,
Sep 6, 2022, 2:31:41 PM9/6/22
to
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

John Cowan

unread,
Sep 6, 2022, 6:45:35 PM9/6/22
to
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.

Peter Flass

unread,
Sep 7, 2022, 10:01:03 AM9/7/22
to
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
0 new messages