From: krishna.myneni@ccreweb.org   
      
   On 3/27/24 13:46, Anton Ertl wrote:   
   > Krishna Myneni writes:   
   >> I really think it is a bad idea to have UB in the spec of LSHIFT and   
   >> RSHIFT due to the arbitrariness of low level shift operations at the   
   >> hardware level. Here we have a chance to remove that UB and guarantee that   
   >>   
   >> 1 BITS_PER_CELL LSHIFT returns zero   
   >> and   
   >> 1 BITS_PER_CELL RSHIFT returns zero   
   >>   
   >> so that the expected result for a shift operation on the cell operand   
   >> does not have UB.   
   >   
   > I guess you mean the ambiguous condition in the specification of   
   > LSHIFT and RSHIFT, which is more like implementation-defined behaviour   
   > in some other languages (and the advocates of undefined behaviour make   
   > a lot of wind about the difference between implementation-defined and   
   > undefined).   
      
   I have to admit that the distinction between mapping "ambiguous   
   condition" to IB vs UB escapes me.   
      
   >   
   > Well, if you want to see this happen, you have to convince some Forth   
   > system implementors, so common practice moves in the direction you   
   > prefer, and once that is done, make a proposal.   
   >   
      
   Sure. I would start with modifying LSHIFT and RSHIFT in my own Forth   
   systems. The revisions would still be consistent with the standard.   
      
   > You could point out that the extra cost of the check is only incurred   
   > for shifts with non-constant shift amounts, and if you could provide   
   > data on the frequency of constant and non-constant shift amounts, this   
   > might help convince system implementors. Of course, for commercial   
   > implementors, you may get the usual answer that their customers have   
   > not complained to them, but if you don't try, you can't win.   
   >   
   >> Efficiency because of extra instructions needed to implement this   
   >> guarantee are not even worth bothering about -- we are not C.   
   >   
   > I am sure someone can produce some saying by Chuck Moore that   
   > contradicts this attitude. Sure, Forth is not C, but it's just as   
   > performance-conscious.   
   >   
      
   My meaning was that I expect the performance change to be negligible. Of   
   course, we have to implement and test to check this.   
      
   --   
   Krishna   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|