Re: Functions | &ByRef • ByVal
Posted: 26 Apr 2018, 01:15
I can only repeat what I said before.
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=37&t=47684
No, not similarly. Byref also allows you to wipe out the external object reference by blanking the internal variable and then you have no object outside of the function. There is a world of difference in passing a variable holding a reference to an object by value vs passing it by reference. Object access is explicit, there's no "oops I didn't know I was accessing this object", variables being erasable outside of scope with no indication for it is not (duh).Helgef wrote: Similarily, passing an object to a function, byref or not, allows the function to modify the object, I do not see too much confusion about it
Code: Select all
obj:=["what", " when ", "where"]
msgbox(function(obj))
function(param) ; assume byref default everywhere
{
param:=Trim(param[2]) . " are you coming back?" ; external "obj" is gone
; some other code
; some other code
; some other code
return param
}
msgbox(isobject(obj)) ; nope
Code: Select all
Byref function(param1, param2........................................ param25)
Code: Select all
Byref function(param1, param2........................................ param25)
Not having & mean byref makes it consistent with pbrush.& on definition would be consistent with cpp for references.