I wouldn't say that's an extra worthless test.
I think what it is telling us is that CASE 1 does not mean "otherwise" in a 
traditional sense.
It really does mean "IF @TRUE" or "IF 1=1"

Which is a bit suprising that the compiler would have been written that way, 
but it does make a kind of sense.



-----Original Message-----
From: Charles Stevenson <stevenson.c...@gmail.com>
To: U2 Users List <u2-users@listserver.u2ug.org>
Sent: Fri, Apr 20, 2012 6:28 am
Subject: Re: [U2] Case Statement with only two cases


A respectful correction, Brian.
On 4/20/2012 4:50 AM, Brian Leach wrote:
 it's all the same to the compiler.
 -----Original Message-----
     BEGIN CASE
        CASE A = "TEST"; GOSUB DO.SOMETHING
        CASE 1; GOSUB DO.SOMETHING.ELSE
     END CASE
 versus this
     IF A = "TEST" THEN GOSUB DO.SOMETHING ELSE GOSUB DO.SOMETHING.ELSE
----
Since we seem to be finding every nit in the bottom of this empty 
arrel, here's one more.
here are 2 compiler difference as shown by VLIST (UV10.2):
00001: BEGIN CASE
00002:    CASE A = "TEST"; GOSUB DO.SOMETHING
0002 00000 : 06E eq             A "TEST"  => $R0
0002 00008 : 2DE testfw         $R0 00020:
0002 00010 : 0A4 gosub          00060:

0003:    CASE 1; GOSUB DO.SOMETHING.ELSE
0003 00018 : 0C2 jump           00038:
0003 00020 : 2DE testfw         1 00038: <-------------- Extra 
orthless test
0003 00028 : 0A4 gosub          00062:
00004: END CASE
0004 00030 : 0C2 jump           00038: <-------------- Extra worthless 
ump (to next line)
                                                                          
Source lineup is goofy.  This jump is really part
                                                                        
   of source line 3.   RAID is confusing, too.
                                                                           A 
iscussion for a different thread.)
00005: IF A = "TEST" THEN GOSUB DO.SOMETHING ELSE GOSUB DO.SOMETHING.ELSE
0005 00038 : 06E eq             A "TEST"  => $R0
0005 00040 : 2DE testfw         $R0 00058:
0005 00048 : 0A4 gosub          00060:
0005 00050 : 0C2 jump           00060:
0005 00058 : 0A4 gosub          00062:
00006: STOP
0006 00060 : 190 stop

ith the speed of today's machines it would be hard to find a place 
here that performance makes a difference.
Rocket could theoretically clean up both (or either independently) if 
he compiler was smart enough:
1. to know that a logical test outcome was predestined at compile time 
It already does that sort of thing in other situations.).  Then it 
ould  compile only 1 of the 2 paths the testfw takes.  (e.g. 0020x).  
ame for IF,  WHILE, or UNTIL constructs.
2. To recognize the final CASE before the END CASE never needs to jump 
e.g., 0030x).
I wonder if we've already wasted more electrical & biological energy by 
e writing this email, dispersing it around the globe, and you reading 
t, than all the machine cycles wasted executing the 2 worthless tests 
n all the object scattered around the universe that Rocket could 
heoretically optimize.
cds

______________________________________________
2-Users mailing list
2-us...@listserver.u2ug.org
ttp://listserver.u2ug.org/mailman/listinfo/u2-users

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to