From: Huw Collingbourne Date: 2006-02-24T19:28:34+09:00 Subject: Re: Everything's an object, right? To the best of my knowledge everything (apart from integers) is passed by reference. However, 99% of the time this doesn't matter. In 'pure OOP' programming, 'messages' are sent to 'methods' and they respond with new data. If you only ever use return values you won't see inconsistent behaviour and you won't break encapsulation (which, in effect, using ByRef arguments to obtain new values does). To clarify. There are a few string methods which alter the original string object. This is also the case if you index into a string to change a char. However, when you evaluate an expression, this yields a new object so that in the following: x = x + 1 The expression on the right yields a value which is assigned to a new object, x, on the left. In other words, the x on the right is a different object from the x on the left. Since methods which alter data usually do so in the process of evaluation and assignment, most of the time any object (such as x) which "goes in" is assigned to a new object (with the same name) by the time the method ends. This explains why many people believe that arguments are sent 'by value' - because, in most cases, the value of any argument that goes into a method is not changed. Rather, a new object is created during the process of evaluation and assignment. If this is confusing, just stick to the 'pure OOP' way of doing things and always use return values; never try to use the values of ingoing arguments as 'ByRef' parameters. Life is much simpler that way ;-) best wishes Huw Collingbourne ================================ Bitwise Magazine www.bitwisemag.com Dark Neon Ltd. ================================