Order of Operation with VA PL1 for Windows 
Author Message
 Order of Operation with VA PL1 for Windows

I am in the process of converting from PL1 for VMS to VisualAge PL1 for
Windows NT and I have a problem.  In PL1 for VMS there are two bit
operators "&:" and "|:"  that are not available in VisualAge PL1.  These
operators force the order of evaluation.  "&:" is like "&" except that the
second operand is evaluated only if the first operand is true.  "|:" is
like "|" except that the second operand is evaluated only if the first
operand is false.

Based on the Language Reference, Page 58, it doesn't appear that I can do
this.  Does anyone know if there a way of doing this in VisualAge PL1.  I
realize that I could break my IF statements and DO WHILE statements into
individual statments to force the order of evaluation but would like to
avoid that if possible.

Here is a nested procedure that I have that has this problem.
ltr_tla_list is a pointer declared in the top level procedure and is used
as the initial pointer to a link list.
ltr_tla_node is a structure declared in the top level procedure

        checkfor_ltr_tla: procedure(tla) returns(fixed bin(31));
        dcl tla char(*);
        dcl cur_ltr_tla_node pointer;

           cur_ltr_tla_node = ltr_tla_list;
           do while ((cur_ltr_tla_node ^= null()) &:
                     (cur_ltr_tla_node->ltr_tla_node.ltr_tla ^= tla));
              cur_ltr_tla_node = cur_ltr_tla_node->ltr_tla_node.next_ltr_tla_node;
           end;
           if (cur_ltr_tla_node = null()) then do;
              put skip(2) list('ERROR - "LTR_' || tla || '" DOES NOT EXIST IN
HEADER FILES.');
              put skip list('        FOR RECORD: ', recordsread);
              return(2);
           end;
           return(0);
        end checkfor_ltr_tla;

If variable ltr_tla_list is equal to NULL() then the do while statement
could cause error:
"IBM0534I oncode=8094 A protection exception occurred"
if the second half of the expression is evaluated before the first half.

Thanks,
Randy Gress



Tue, 03 Oct 2000 03:00:00 GMT  
 Order of Operation with VA PL1 for Windows

In a message dated 04-17-98, Randy Gress said to All about Order Of
Operation With V

RG>I am in the process of converting from PL1 for VMS to VisualAge PL1 for
RG>Windows NT and I have a problem.  In PL1 for VMS there are two bit
RG>operators "&:" and "|:"  that are not available in VisualAge PL1.  These
RG>operators force the order of evaluation.  "&:" is like "&" except that
RG>the second operand is evaluated only if the first operand is true.  "|:"
RG>is like "|" except that the second operand is evaluated only if the first
RG>operand is false.

RG>Based on the Language Reference, Page 58, it doesn't appear that I can do
RG>this.  Does anyone know if there a way of doing this in VisualAge PL1.  I
RG>realize that I could break my IF statements and DO WHILE statements into
RG>individual statments to force the order of evaluation but would like to
RG>avoid that if possible.

[snip]

There was a long and, at times, heated thread on this very issue in the
IBMLANG forum of Compuserve (where PL/I is supported, still) a few months
ago. At its conclusion, Peter Elderon said he would alter the compiler to
perform "short circuit" evaluations in purely Boolean (i.e. BIT(1), not
BIT(*)) contexts, just using the basic & and | operators, without the colon.

This already occurs in IF statements, at least when OPT(2) is specified. You
might care to enable full optimization and see if that helps.

If it doesn't help, raise the matter with IBM.

Regards

Dave
<Team PL/I>
___
 * MR/2 2.25 #353 * The problem with troubleshooting is that trouble shoots
back.



Tue, 03 Oct 2000 03:00:00 GMT  
 Order of Operation with VA PL1 for Windows


Quote:


>> I am in the process of converting from PL1 for VMS to VisualAge PL1 for
>> Windows NT and I have a problem.  In PL1 for VMS there are two bit
>> operators "&:" and "|:"  that are not available in VisualAge PL1.  These
>> operators force the order of evaluation.  "&:" is like "&" except that the
>> second operand is evaluated only if the first operand is true.  "|:" is
>> like "|" except that the second operand is evaluated only if the first
>> operand is false.
>> [snippage]
>Hi,

>I don't know the status of VA PLI, we're using V2.3 on MVS, and the above
>construction is very familiar. It has never caused us problems as V2.3
>evaluates expressions left to right, at least we've never found otherwise.
>However, we had a similar problem with 8094's while debugging such loops, and
>solved it by using SYSNULL(), on MVS the first 1K of storage is readable,
>however, this may not work on NT
> [snippage]

The manuals for mainframe PL/I at least, have always stated that the order of
evaluation is undefined.

Note that NULL() ^= SYSNULL(); you should use NULL() in the test if you've
initialized a pointer to NULL(), and SYSNULL() where the pointer is truely
zero.

While many people seem to disparage the LEAVE statement, it is a useful tool
if used with some discipline. Not only can you use it to force the order of
evaluation, but it can also be used where multiple statements are required to
evaluate a condition. (It can also be clearer than the somewhat badly designed
UNTIL syntax in PL/I.)

For example:
        do while(TRUE);
            if some_condition then leave;
            if some_other_condition then leave;
            /* body of loop */
        end

Bernie

--

Ontario DX Association    ===> http://www.grove.net/~odxa
Tsuruoka Canadian Budokai ===> http://www.interlog.com/~brat/tcb
** Please remove the thumb from my address if replying to Usenet post!
--



Sat, 07 Oct 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. VA-Reston- Operations Manager - NOC - Fairfax, VA EC Startup ( 533117 )

2. Help with Pl1 Pre Processor Parser (Operation PPPP!)

3. filling PL1 structures in VA Smalltalk?

4. Question: VA OS/2 or VA for Windows?

5. APL+Win and Order of Operation error

6. Window Properties Order of operations

7. Order of Operations of Logic?

8. Order of logical operations

9. PL1 for Linux / PL1 for Win95?

10. wanted: PL1 to C xlator or PL1 BNF

11. Announcement: Online ordering of VA PL/I

12. VA 4.02 Windows within windows functionality

 

 
Powered by phpBB® Forum Software