× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Steve Richter wrote:
Carlos,

Thanks for pointing this out.  Hans's response primarily addresses the use
of global variables.  What I am saying is that const can cause problems
whenever the calling proc uses the same variable on more than one parm of a
proc:
   Calc_New_Qty( qty1: qty1 ) ;

 d Calc_New_Qty   pi
 d OutQty                  7p 2
 d InQty                   7p 2  const
  /free
       OutQty    = 0 ;  // this can affect any other pass by
                        // reference parm.  const or no const!
       ...
  /end-free

I think passing any numeric or small char variable by const reference is a
bug waiting to happen.  passing by value is safer and performs just the
same.

In this example, you'd also have problems even if INQTY were a normal reference parameter, and so the problem isn't limited to CONST parms. As I discussed earlier, any time you can access some piece of storage from two (or more) different names (AKA aliasing), you run the risk of having some "fun" debugging sessions. Aliasing bugs crop up in a lot of places, especially if you're using pointers and dynamically allocated storage.


Cheers! Hans



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.