This isn’t quite correct.
Objects are reference types - but that does not mean they are passed byref.
What that means is what your passing is a reference / pointer / address and so you can still change the contents of the thing that is referenced.
But object REFERENCES can be passed byval (the default) and BYREF (explicitly) like any other type.
So in a simple case something like
sub foo(i as integer)
i = 6
end foo
Window1
Event Open()
dim i as integer = 9
foo(i)
break
end event
in the open event i gets initialized & set to 9
in foo it gets altered FOR THIS SCOPE to 6
but then control returns to the open event i is unchanged & is still 9
if you change this to BYREF
sub foo(byref i as integer)
i = 6
end foo
Window1
Event Open()
dim i as integer = 9
foo(i)
break
end event
in the open event i gets initialized & set to 9
in foo , the original item (as we now are byref so we refer to the original item), it gets altered to 6
when control returns to the open event i is changed & is still 6
Now with an object reference
sub foo(d as date)
i = new date
end foo
Window1
Event Open()
dim i as new date
foo(i)
break
end event
in the open event i gets initialized & set to a reference 0x018a0f78
in foo it gets altered FOR THIS SCOPE to a new reference 0x0515C4B8
but then control returns to the open event i is unchanged & is still 0x018a0f78
if you change this to BYREF
sub foo(byref d as date)
i = new date
end foo
Window1
Event Open()
dim i as new date
foo(i)
break
end event
in the open event i gets initialized & set to a reference 0x01537818
in foo it gets altered FOR THIS SCOPE to a new reference 0x00750078
but then control returns to the open event i is changed & is still 0x00750078
exactly the same effect as a byref on a intrinsic nonreference type
whats different is that with a reference type you can change what it refers TO
Lots of fun and useful as heck sometimes
Also see https://forum.xojo.com/conversation/post/133994