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





On 4/29/2013 1:54 PM, Alan Campin wrote:
As I have said many times, VALUE means the compiler says I guarantee that
variable in the calling program will not be changed and it does that by
making a copy and pass a pointer to it.

Passing by VALUE does not involve passing a pointer to it. It simply copies the data from the caller's variable to another variable that's local to the procedure. It does not pass a pointer.

By contrast, CONST, if the variable size/type does not match does exactly what you're attributing to VALUE -- it makes a copy and then passes a pointer.



CONST means I will try to keep you from changing it but there are plenty of
ways to change the variable inside the procedure and have the calling
variable to be changed. These include passing as a parameter to a program
inside the procedure, getting a pointer to it, putting in a data structure.
The compiler may try to prevent you from changing but it is easy enough to
change which could result in some really nasty bugs.


Complaining that CONST is bad because a variable can still by changed though another non-CONST interface is like complaining that the locks on the front door of your house is bad because burglars can still steal your TV by entering through the back door.

The fault isn't with CONST, it's with the fact that you have two different methods to access the same variable.

Or, that you are lying to the compiler... using a prototype that doesn't match it's corresponding procedure interface.


That is why I always use a VALUE unless I passing something really big and
lately I have using Option(*String) to pass long variable strings.

VALUE is okay for short things, such as numeric values, but some environments (SQL comes to mind) don't allow VALUE. Then you end up with wrappers, et al.

Really, it's nearly impossible to "accidentally" change a CONST parameter. You pretty much have to be trying to do so. Don't throw away the baby with the bath water!

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.