On Mar 20, 2006, at 9:01 PM, Mark Smith wrote:

I think the point is that when a variable is passed to a function/ handler 'normally', the data in it is duplicated, and if the data is big, this is not as efficient as passing it by reference - obviously, if you need to change the data in the called function/ handler, this may have unwanted side-effects, in which case passing it normally is going to be better.

The problem you raise here is handled in more traditional languages by declaring the reference to be constant. It strikes me that it would not be a big change to expand the use of the "constant" keyword. Then in situations such as Sarah was talking about the handler/function would be declared as not changing the referred to variable, something like

on myHandler constant @pByReferenceParameter
  -- following then should cause compiler error
  add 1 to @pByReferenceParameter
end myHandler

There is, of course, another use for references besides the efficiency of not having to copy large data structures: returning more than one value. This use doesn't suffer from the concern Sarah raises about having external effects as, when used this way, the parameter passed in should be empty. There isn't, of course, any guarantee of this other than the caller being careful and writer of the called function being careful to document that the parameter is used for output only.

Spence

James P. Spencer
Rochester, MN

[EMAIL PROTECTED]

"Badges??  We don't need no stinkin badges!"

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to