Re: Someone just too smart for his or her own good?

2017-08-04 Thread Steve Beaver
Charles.   PL/1 and REXX are about the same   The break would be a goto 

Sent from my iPhone

Sorry for any grammar problems 

> On Aug 4, 2017, at 12:45, Charles Mills  wrote:
> 
> Why do I keep devoting thought to this?
> 
> If you desperately needed to optimize every last cycle out of the loop, and 
> you wanted to do this in a supported way, the trick would be two loops. 
> Something like
> 
> for i = 1 to whatever;
>  if a(i) >= 0 then do
>sum = sum + a(i);
>switch = 1;
>break? /* what is the PL/I to exit from a loop? */ ;
>  end;
> end;
> 
> for i = i to whatever;
>  if a(i) > 0 then sum = sum + a(i);
> end;
> 
> I'm not a PL/I coder so not sure if you need a test for i already == whatever 
> when it gets to the second loop or whether it has already been incremented, 
> etc. 
> 
> Probably faster than the original because avoids most of the a(i) == 0 cases.
> 
> Charles
> 
> 
> -Original Message-
> From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On 
> Behalf Of Robert Prins
> Sent: Friday, August 4, 2017 10:48 AM
> To: IBM-MAIN@LISTSERV.UA.EDU
> Subject: Re: Someone just too smart for his or her own good?
> 
>> On 2017-08-04 13:41, Charles Mills wrote:
>> OK, I get it. (Way too much time spent on this now.) The sum is also 
>> to be printed if there are any zero values in a[whatever].
>> 
>> Is this a real business problem or an exercise in whatever?
> 
> The original code actually fills a set of buckets with values (or nothing), I 
> just simplified the code to a loop over an array, changing the values in the 
> array to do some testing, after first figuring out what was going on.
> 
>> I don't know the PL/I compiler but on a modern processor Store on 
>> Condition potentially makes
>> 
>> if a(i) >= 0 then switch = 1;
> 
> It's more than likely that Enterprise PL/I V5.2 can already generate code 
> that utilizes new features of the z14 systems.
> 
> Robert
> --
> Robert AH Prins
> robert.ah.prins(a)gmail.com
> 
> --
> 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

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Charles Mills
Why do I keep devoting thought to this?

If you desperately needed to optimize every last cycle out of the loop, and you 
wanted to do this in a supported way, the trick would be two loops. Something 
like

for i = 1 to whatever;
  if a(i) >= 0 then do
sum = sum + a(i);
switch = 1;
break? /* what is the PL/I to exit from a loop? */ ;
  end;
end;

for i = i to whatever;
  if a(i) > 0 then sum = sum + a(i);
end;

I'm not a PL/I coder so not sure if you need a test for i already == whatever 
when it gets to the second loop or whether it has already been incremented, 
etc. 

Probably faster than the original because avoids most of the a(i) == 0 cases.

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Robert Prins
Sent: Friday, August 4, 2017 10:48 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Someone just too smart for his or her own good?

On 2017-08-04 13:41, Charles Mills wrote:
> OK, I get it. (Way too much time spent on this now.) The sum is also 
> to be printed if there are any zero values in a[whatever].
> 
> Is this a real business problem or an exercise in whatever?

The original code actually fills a set of buckets with values (or nothing), I 
just simplified the code to a loop over an array, changing the values in the 
array to do some testing, after first figuring out what was going on.

> I don't know the PL/I compiler but on a modern processor Store on 
> Condition potentially makes
> 
> if a(i) >= 0 then switch = 1;

It's more than likely that Enterprise PL/I V5.2 can already generate code that 
utilizes new features of the z14 systems.

Robert
--
Robert AH Prins
robert.ah.prins(a)gmail.com

--
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


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Steve Smith
It's not really a word where I live (OH, USA), but in the words of my
favorite /. sig: "Every now and then I like to masterbate a new word into
my vocabulary, even if I don't know what it means".  ;-)

sas

p.s. seems I don't even know how to spell that word.  Yay for me. :-)

On Fri, Aug 4, 2017 at 10:44 AM, David Crayford  wrote:

> On 4/08/2017 10:03 PM, Steve Smith wrote:
>
>> Using UNSPEC to test the sign is absolutely ridiculous.  Sure, that's "too
>> clever", but it really shows that the writer was a wanker.  Nevertheless,
>> you have no case for an RFE.  Any feature can be abused or misused.
>>
> I'm not sure what wanker means where you live but it probably has a
> different connotation where I do ;) Classic Friday quote.
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>



-- 
sas

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Robert Prins

On 2017-08-04 13:41, Charles Mills wrote:

OK, I get it. (Way too much time spent on this now.) The sum is also to be
printed if there are any zero values in a[whatever].

Is this a real business problem or an exercise in whatever?


The original code actually fills a set of buckets with values (or nothing), I 
just simplified the code to a loop over an array, changing the values in the 
array to do some testing, after first figuring out what was going on.



I don't know the PL/I compiler but on a modern processor Store on Condition
potentially makes

if a(i) >= 0 then switch = 1;


It's more than likely that Enterprise PL/I V5.2 can already generate code that 
utilizes new features of the z14 systems.


Robert
--
Robert AH Prins
robert.ah.prins(a)gmail.com

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Bernd Oppolzer

Am 04.08.2017 um 16:03 schrieb Steve Smith:

In PL/I "FIXED" means neither packed nor binary; it can be either.  The
relevant attribute is "DEC" or "BIN" (short forms), and the default is
"DEC".

Using UNSPEC to test the sign is absolutely ridiculous.  Sure, that's "too
clever", but it really shows that the writer was a wanker.  Nevertheless,
you have no case for an RFE.  Any feature can be abused or misused.


IMO, the case for the RFE could be
that programs that rely on the initialization of

DCL SUM DEC FIXED (7) INIT (-0.1);

with negative zero (X'000d')
should be flagged; this is bad practice, and I would like
such initializations to be flagged as ERROR (not only warning)
and to be told by the error message, that the initialization will be
POSITIVE zero from now on. (Losing decimal digits to the right of
the decimal point should only be a warning, IMO).

BTW, it's not the UNSPEC per se and not the content of the loop,
which is subject of the discussion, IMO. The UNSPEC is needed
if you want to test for negative zero, after all (the UNSPEC is ok,
but the usage in this case is questionable).

See more discussions on this topic on the PL/1 mailing list
(pl...@listserv.dartmouth.edu), if you are interested.

Kind regards

Bernd Oppolzer




Anyway, it's been really difficult to make out what this post is about.
What's with all the discussion about what's in the loop, "negative zero",
etc. if the UNSPEC is the issue?

sas




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread David Crayford

On 4/08/2017 10:03 PM, Steve Smith wrote:

Using UNSPEC to test the sign is absolutely ridiculous.  Sure, that's "too
clever", but it really shows that the writer was a wanker.  Nevertheless,
you have no case for an RFE.  Any feature can be abused or misused.
I'm not sure what wanker means where you live but it probably has a 
different connotation where I do ;) Classic Friday quote.


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Steve Smith
In PL/I "FIXED" means neither packed nor binary; it can be either.  The
relevant attribute is "DEC" or "BIN" (short forms), and the default is
"DEC".

Using UNSPEC to test the sign is absolutely ridiculous.  Sure, that's "too
clever", but it really shows that the writer was a wanker.  Nevertheless,
you have no case for an RFE.  Any feature can be abused or misused.

Anyway, it's been really difficult to make out what this post is about.
What's with all the discussion about what's in the loop, "negative zero",
etc. if the UNSPEC is the issue?

sas

On Fri, Aug 4, 2017 at 9:42 AM, Charles Mills  wrote:

>
> -Original Message-
> From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
> Behalf Of Charles Mills
> Sent: Friday, August 4, 2017 6:24 AM
> To: IBM-MAIN@LISTSERV.UA.EDU
> Subject: Re: Someone just too smart for his or her own good?
>
> Oh geez, well then I rest my case that this code is too clever to be
> maintainable. The next programmer might not be any smarter than I.
>
> (I'm not a PL/I expert -- I guess "fixed" means packed? I had guessed
> binary.)
>
> If i is fairly large and there are a good number of a(i) == 0 then my
> point is still valid -- this has to be an expensive way of doing this.
>
> What is the statement of the problem? What is the snippet supposed to
> accomplish? "For a table of packed values a[whatever], print the sum of all
> of the positive values, unless that sum is zero?" Do I have that right?
>
> I would be stunned if the code below performs better than -- and not worse
> than, assuming a fair number of zero values -- the most obvious logic
>
> for i = 1 to whatever;
> if a(i) > 0 then sum = sum + a(i);
> end;
> if sum > 0 then put data(sum);
>
> Charles

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Charles Mills
OK, I get it. (Way too much time spent on this now.) The sum is also to be 
printed if there are any zero values in a[whatever].

Is this a real business problem or an exercise in whatever?

I don't know the PL/I compiler but on a modern processor Store on Condition 
potentially makes 

if a(i) >= 0 then switch = 1;

pretty fast.

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Charles Mills
Sent: Friday, August 4, 2017 6:24 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Someone just too smart for his or her own good?

Oh geez, well then I rest my case that this code is too clever to be 
maintainable. The next programmer might not be any smarter than I.

(I'm not a PL/I expert -- I guess "fixed" means packed? I had guessed binary.)

If i is fairly large and there are a good number of a(i) == 0 then my point is 
still valid -- this has to be an expensive way of doing this.

What is the statement of the problem? What is the snippet supposed to 
accomplish? "For a table of packed values a[whatever], print the sum of all of 
the positive values, unless that sum is zero?" Do I have that right?

I would be stunned if the code below performs better than -- and not worse 
than, assuming a fair number of zero values -- the most obvious logic

for i = 1 to whatever;
if a(i) > 0 then sum = sum + a(i);
end;
if sum > 0 then put data(sum);

Charles

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Charles Mills
Oh geez, well then I rest my case that this code is too clever to be 
maintainable. The next programmer might not be any smarter than I.

(I'm not a PL/I expert -- I guess "fixed" means packed? I had guessed binary.)

If i is fairly large and there are a good number of a(i) == 0 then my point is 
still valid -- this has to be an expensive way of doing this.

What is the statement of the problem? What is the snippet supposed to 
accomplish? "For a table of packed values a[whatever], print the sum of all of 
the positive values, unless that sum is zero?" Do I have that right?

I would be stunned if the code below performs better than -- and not worse 
than, assuming a fair number of zero values -- the most obvious logic

for i = 1 to whatever;
if a(i) > 0 then sum = sum + a(i);
end;
if sum > 0 then put data(sum);

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Robert Prins
Sent: Friday, August 4, 2017 2:58 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Someone just too smart for his or her own good?

On 2017-08-04 00:31, Charles Mills wrote:
> Certainly if one is looking to save a cycle or two then
> 
>if a(i) >= 0 then
>  sum = sum + a(i);
> 
> should be
> 
>if a(i) > 0 then
>  sum = sum + a(i);
> 
> because adding a(i) to sum when a(i) == 0 is a waste of a cycle or two.

Yes, but in this case it *IS* significant, because the initialization of a PL/I 
"FIXED (7)" with -1.0 < init-value < 0 will set it to MINUS zero (zero with a
D-sign) and by adding zero to this will normalize the value to have a C-sign.

As I already write in the title, the gal or guy who wrote this code is just a 
trifle too smart for her or his own good, I've been using PL/I for nearly 32 
years, and until I used UNSPEC() on "sum", the code didn't make any sense to me.

FWIW, my original post contained a type,

if substr(unspec(sum), 25, 8) ^= '0d'bx then

should have been

if substr(unspec(sum), 29, 4) ^= 'd'bx then

or, like in the original code,

if substr(unspec(sum), 8*stg(sum)-3, 4) ^= 'd'bx then

Mea culpa, too much Intel assembler where hex constants must start with a 
zero...

Robert
> 
> -Original Message-
> From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] 
> On Behalf Of Robert Prins
> Sent: Thursday, August 3, 2017 12:11 PM
> To: IBM-MAIN@LISTSERV.UA.EDU
> Subject: Someone just too smart for his or her own good?
> 
> Just came across the following, and please don't come back with pedantic 
> remarks about undeclared variables, the code is just to show what's there:
> 
> dcl sum fixed (7) init (-0.1);
> 
> for i = 1 to whatever;
>if a(i) >= 0 then
>  sum = sum + a(i);
> end;
> 
> if substr(unspec(sum), 25, 8) ^= '0d'bx then
>put data(sum);
> 
> In other words if all a(i) are negative, nothing is printed. A comment in the 
> code suggests that this is faster code, on modern OoO z/OS systems, than the 
> more logical:
> 
> dcl sum fixed (7) init (-1);
> 
> for i = 1 to whatever;
>if a(i) >= 0 then
>  if sum ^= -1 then
>sum = sum + a(i);
>  else
>sum = a(i);
> end;
> 
> It probably is if the value of whatever is in the order of 42 gazillion, but 
> any other thoughts about this?
> 
> Robert
> --
> Robert AH Prins
> robert.ah.pr...@gmail.com
> Some programming  @ <https://prino.neocities.org/zOS/zOS%20Tools.html>
> 
> --
> 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
> 


--
Robert AH Prins
robert(a)prino(d)org

--
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


RFE submitted [WAS: Someone just too smart for his or her own good?]

2017-08-04 Thread Robert Prins

On 2017-08-04 07:56, Robert Prins wrote:

On 2017-08-04 00:31, Charles Mills wrote:

Certainly if one is looking to save a cycle or two then

   if a(i) >= 0 then
 sum = sum + a(i);

should be

   if a(i) > 0 then
 sum = sum + a(i);

because adding a(i) to sum when a(i) == 0 is a waste of a cycle or two.


Yes, but in this case it *IS* significant, because the initialization of a PL/I 
"FIXED (7)" with -1.0 < init-value < 0 will set it to MINUS zero (zero with a 
D-sign) and by adding zero to this will normalize the value to have a C-sign.


As I already write in the title, the gal or guy who wrote this code is just a 
trifle too smart for her or his own good, I've been using PL/I for nearly 32 
years, and until I used UNSPEC() on "sum", the code didn't make any sense to me.


FWIW, my original post contained a type,

if substr(unspec(sum), 25, 8) ^= '0d'bx then

should have been

if substr(unspec(sum), 29, 4) ^= 'd'bx then

or, like in the original code,

if substr(unspec(sum), 8*stg(sum)-3, 4) ^= 'd'bx then

Mea culpa, too much Intel assembler where hex constants must start with a 
zero...


Following myself, I've submitted this RFE requesting an I- or W-type message to 
flag this kind of (too) clever code, or a new RULES() option to outright ban it 
with an E-type message:


http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=108713

Robert
--
Robert AH Prins
robert.ah.prins(a)gmail.com
Some programming  @ 

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-04 Thread Robert Prins

On 2017-08-04 00:31, Charles Mills wrote:

Certainly if one is looking to save a cycle or two then

   if a(i) >= 0 then
 sum = sum + a(i);

should be

   if a(i) > 0 then
 sum = sum + a(i);

because adding a(i) to sum when a(i) == 0 is a waste of a cycle or two.


Yes, but in this case it *IS* significant, because the initialization of a PL/I 
"FIXED (7)" with -1.0 < init-value < 0 will set it to MINUS zero (zero with a 
D-sign) and by adding zero to this will normalize the value to have a C-sign.


As I already write in the title, the gal or guy who wrote this code is just a 
trifle too smart for her or his own good, I've been using PL/I for nearly 32 
years, and until I used UNSPEC() on "sum", the code didn't make any sense to me.


FWIW, my original post contained a type,

if substr(unspec(sum), 25, 8) ^= '0d'bx then

should have been

if substr(unspec(sum), 29, 4) ^= 'd'bx then

or, like in the original code,

if substr(unspec(sum), 8*stg(sum)-3, 4) ^= 'd'bx then

Mea culpa, too much Intel assembler where hex constants must start with a 
zero...

Robert


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Robert Prins
Sent: Thursday, August 3, 2017 12:11 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Someone just too smart for his or her own good?

Just came across the following, and please don't come back with pedantic 
remarks about undeclared variables, the code is just to show what's there:

dcl sum fixed (7) init (-0.1);

for i = 1 to whatever;
   if a(i) >= 0 then
 sum = sum + a(i);
end;

if substr(unspec(sum), 25, 8) ^= '0d'bx then
   put data(sum);

In other words if all a(i) are negative, nothing is printed. A comment in the 
code suggests that this is faster code, on modern OoO z/OS systems, than the 
more logical:

dcl sum fixed (7) init (-1);

for i = 1 to whatever;
   if a(i) >= 0 then
 if sum ^= -1 then
   sum = sum + a(i);
 else
   sum = a(i);
end;

It probably is if the value of whatever is in the order of 42 gazillion, but 
any other thoughts about this?

Robert
--
Robert AH Prins
robert.ah.pr...@gmail.com
Some programming  @ <https://prino.neocities.org/zOS/zOS%20Tools.html>

--
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




--
Robert AH Prins
robert(a)prino(d)org

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-03 Thread Kenneth J. Kripke
>dcl sum fixed (7) init (-0.1);/* Packed Decimal? */

 

>for i = 1 to whatever;

>  if a(i) >= 0 then

>sum = sum + a(i);

> 

And there, at least I'd do:

>  if a(i) >  0 then

>sum = sum + a(i);

> 

as long as testing, why bother to add 0?

 

>if substr(unspec(sum), 25, 8) ^= '0d'bx then/* test the sign of the
number? */

>  put data(sum);

> 

Unspec function returns a binary representation 

 

Sincerely;  

 

Kenneth J. Kripke

 

kennethkri...@gmail.com 

 


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-03 Thread CM Poncelet
>From memory, the PL/I compiler option 'LIST' should produce an assembler
listing and show 2 CLC's when using nested if's (else only 1 CLC). I
doubt that optimising the compiler could improve this, because the
generated machine code would(logically) stillhave to process the 2
nested if's.

On 04/08/2017 03:45, Edward Finnell wrote:
> It's been too long, would compiler OPT(2) make it better?
>  
>  
> In a message dated 8/3/2017 9:14:44 P.M. Central Daylight Time,  
> ponce...@bcs.org.uk writes:
>
> It is  the unnecessary nested'if' that would degrade  performance
>
> --
> 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


Re: Someone just too smart for his or her own good?

2017-08-03 Thread Edward Finnell
It's been too long, would compiler OPT(2) make it better?
 
 
In a message dated 8/3/2017 9:14:44 P.M. Central Daylight Time,  
ponce...@bcs.org.uk writes:

It is  the unnecessary nested'if' that would degrade  performance

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-03 Thread CM Poncelet
It is the unnecessary nested'if' that would degrade performance:

for i = 1 to whatever;
  if a(i) >= 0 then/* <-- if #1 */
if sum ^= -1 then  /* <-- if #2 */
  sum = sum + a(i);
else
  sum = a(i);
end;
if substr(unspec(sum), 25, 8) ^= '0d'bx then
  put data(sum);

 
It would be more efficient (less machine code) if coded as: 
 
for i = 1 to whatever;
  if a(i) > 0 then
sum = sum + a(i);
end; 
if substr(unspec(sum), 25, 8) ^= '0d'bx then
  put data(sum);
 
CP


On 04/08/2017 01:32, Charles Mills wrote:
> for i = 1 to whatever;
>   if a(i) >= 0 then
> if sum ^= -1 then
>   sum = sum + a(i);
> else
>   sum = a(i);


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-03 Thread Charles Mills
Certainly if one is looking to save a cycle or two then

  if a(i) >= 0 then
sum = sum + a(i);

should be 

  if a(i) > 0 then
sum = sum + a(i);

because adding a(i) to sum when a(i) == 0 is a waste of a cycle or two.

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Robert Prins
Sent: Thursday, August 3, 2017 12:11 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Someone just too smart for his or her own good?

Just came across the following, and please don't come back with pedantic 
remarks about undeclared variables, the code is just to show what's there:

dcl sum fixed (7) init (-0.1);

for i = 1 to whatever;
  if a(i) >= 0 then
sum = sum + a(i);
end;

if substr(unspec(sum), 25, 8) ^= '0d'bx then
  put data(sum);

In other words if all a(i) are negative, nothing is printed. A comment in the 
code suggests that this is faster code, on modern OoO z/OS systems, than the 
more logical:

dcl sum fixed (7) init (-1);

for i = 1 to whatever;
  if a(i) >= 0 then
if sum ^= -1 then
  sum = sum + a(i);
else
  sum = a(i);
end;

It probably is if the value of whatever is in the order of 42 gazillion, but 
any other thoughts about this?

Robert
--
Robert AH Prins
robert.ah.pr...@gmail.com
Some programming  @ <https://prino.neocities.org/zOS/zOS%20Tools.html>

--
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


Re: Someone just too smart for his or her own good?

2017-08-03 Thread Charles Mills
I think it is a fool's game guessing which bit of "tricky" source code will 
compile into faster executing machine code. Modern machines are plenty fast, 
but programmers are not getting any faster. Write maintainable code. Eschew 
obfuscation.

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Robert Prins
Sent: Thursday, August 3, 2017 9:11 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Someone just too smart for his or her own good?

Just came across the following, and please don't come back with pedantic 
remarks about undeclared variables, the code is just to show what's there:

dcl sum fixed (7) init (-0.1);

for i = 1 to whatever;
  if a(i) >= 0 then
sum = sum + a(i);
end;

if substr(unspec(sum), 25, 8) ^= '0d'bx then
  put data(sum);

In other words if all a(i) are negative, nothing is printed. A comment in the 
code suggests that this is faster code, on modern OoO z/OS systems, than the 
more logical:

dcl sum fixed (7) init (-1);

for i = 1 to whatever;
  if a(i) >= 0 then
if sum ^= -1 then
  sum = sum + a(i);
else
  sum = a(i);
end;

It probably is if the value of whatever is in the order of 42 gazillion, but 
any other thoughts about this?

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Someone just too smart for his or her own good?

2017-08-03 Thread Steve Beaver
It as elements of PL/I because of the DCL statement

-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Paul Gilmartin
Sent: Thursday, August 3, 2017 3:35 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Someone just too smart for his or her own good?

On Thu, 3 Aug 2017 19:11:07 +, Robert Prins wrote:

>Just came across the following, and please don't come back with 
>pedantic remarks about undeclared variables, the code is just to show what's 
>there:
>
>dcl sum fixed (7) init (-0.1);
>
I don't know what language this is, and I'm probsbly not skilled in it.
Regardless, "fixed" and "-0.1" seem contradictory; meriting a syntax error.

>for i = 1 to whatever;
>  if a(i) >= 0 then
>sum = sum + a(i);
>
And there, at least I'd do:
>  if a(i) >  0 then
>sum = sum + a(i);
>
as long as testing, why bother to add 0?

>if substr(unspec(sum), 25, 8) ^= '0d'bx then
>  put data(sum);
>
What's this testing for; in what representation?  Is a single non-numeric 
comparison cheaper than a numeric comparison?

>In other words if all a(i) are negative, nothing is printed. A comment 
>in the code suggests that this is faster code, on modern OoO z/OS 
>systems, than the more logical:
>
>dcl sum fixed (7) init (-1);
>
>for i = 1 to whatever;
>  if a(i) >= 0 then
>if sum ^= -1 then
>  sum = sum + a(i);
>else
>  sum = a(i);
>end;
>
Unless the preponderance of the items are non-positive, the test probably costs 
more than it saves.

I like to structure my loops, so neither boundary, the first item nor tne last, 
requires special treatment.  This violates that.

And I studiously avoid the over-and-under read, such as:

read X  # Get first item.
if not eof then do
process X
read X  # Get next item.
if eof then break
done

>end;
>
>It probably is if the value of whatever is in the order of 42 
>gazillion, but any other thoughts about this?
>
None suitable for publication, although events of the past week have eroded 
that standard.

-- 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


Re: Someone just too smart for his or her own good?

2017-08-03 Thread Paul Gilmartin
On Thu, 3 Aug 2017 19:11:07 +, Robert Prins wrote:

>Just came across the following, and please don't come back with pedantic
>remarks about undeclared variables, the code is just to show what's there:
>
>dcl sum fixed (7) init (-0.1);
>
I don't know what language this is, and I'm probsbly not skilled in it.
Regardless, "fixed" and "-0.1" seem contradictory; meriting a syntax
error.

>for i = 1 to whatever;
>  if a(i) >= 0 then
>sum = sum + a(i);
>
And there, at least I'd do:
>  if a(i) >  0 then
>sum = sum + a(i);
>
as long as testing, why bother to add 0?

>if substr(unspec(sum), 25, 8) ^= '0d'bx then
>  put data(sum);
>
What's this testing for; in what representation?  Is a single non-numeric
comparison cheaper than a numeric comparison?

>In other words if all a(i) are negative, nothing is printed. A comment in
>the code suggests that this is faster code, on modern OoO z/OS systems,
>than the more logical:
>
>dcl sum fixed (7) init (-1);
>
>for i = 1 to whatever;
>  if a(i) >= 0 then
>if sum ^= -1 then
>  sum = sum + a(i);
>else
>  sum = a(i);
>end;
>
Unless the preponderance of the items are non-positive, the test
probably costs more than it saves.

I like to structure my loops, so neither boundary, the first item nor tne last,
requires special treatment.  This violates that.

And I studiously avoid the over-and-under read, such as:

read X  # Get first item.
if not eof then do
process X
read X  # Get next item.
if eof then break
done

>end;
>
>It probably is if the value of whatever is in the order of 42 gazillion,
>but any other thoughts about this?
>
None suitable for publication, although events of the past week have eroded 
that standard.

-- gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Someone just too smart for his or her own good?

2017-08-03 Thread Robert Prins
Just came across the following, and please don't come back with pedantic
remarks about undeclared variables, the code is just to show what's there:

dcl sum fixed (7) init (-0.1);

for i = 1 to whatever;
  if a(i) >= 0 then
sum = sum + a(i);
end;

if substr(unspec(sum), 25, 8) ^= '0d'bx then
  put data(sum);

In other words if all a(i) are negative, nothing is printed. A comment in
the code suggests that this is faster code, on modern OoO z/OS systems,
than the more logical:

dcl sum fixed (7) init (-1);

for i = 1 to whatever;
  if a(i) >= 0 then
if sum ^= -1 then
  sum = sum + a(i);
else
  sum = a(i);
end;

It probably is if the value of whatever is in the order of 42 gazillion,
but any other thoughts about this?

Robert
-- 
Robert AH Prins
robert.ah.pr...@gmail.com
Some programming  @ 

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN