That text uses an example of a :magic number", and the advice is sound. Any value that you or another programmer might have to change in the future belongs in a declaration. Note that it's not your father's PL/I; there are named constants.
-- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 ________________________________________ From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on behalf of Paul Gilmartin <0000000433f07816-dmarc-requ...@listserv.ua.edu> Sent: Friday, September 4, 2020 1:00 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Constant Identifiers On Fri, 4 Sep 2020 10:55:19 -0500, Steve Smith wrote: >I'm not a PL/I novice, if not an expert. Whatever you read, it does not >mean what you think it means. > Enterprise PL/I for z/OS Language Reference Version 5 Release 1 IBM SC27-8940-00 Datatypes and attributes. . . 17 If the number 3.1416 is used in more than one place in the program, or if it requires specific data or precision attributes, you must declare it as a named constant. Thus, the above statement can be coded as follows: dcl Pi FIXED DECIMAL (5,4) VALUE(3.1416); area = (radius**2) * Pi; Perhaps then it doesn't mean what it says. I take "must" to indicate a rule, not a suggestion. I haven't seen the rule. I haven't looked very hard. Does it apply alike to 3.1416, 2.7183, and 2? >A constant (or variable) named TWO is an abomination in any language. > Yes. ----------------------------------------------- I see everything twice: On Fri, 4 Sep 2020 19:05:32 +0000, Robert Prins wrote: On Fri, 4 Sep 2020 19:06:49 +0000, Robert Prins wrote: > ... >And I don't think that anyone in their right mind would ever use anything like >your SQRT(X**TWO + Y**TWO). We once had a contractor who would use TRUE and >FALSE rather than just '1'b and '0'b, and did his compares as > >select(var_a = var_b); > when(true) ... > when(false) ... >end; > Shouldn't that just be IF ... THEN ... ELSE? >He didn't last very long! > I feel FALSE and TRUE should be compiler intrinsics even though they are rarely useful. But I'm a Pascal partisan. In Rexx I have sometimes, perhaps mischievously, replaced: IF (var_a = var_b) THEN THEN temp_var = some_string ELSE tenp_var = '' say string_a || temp_var || string_b with: say string_a || copies( some_string, (var_a = var_b) )string_b to save a few lines of code. -- gil ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN