Byref and Objects

It is my understanding that when you call a method with an object as a parameter it is by default passed as a reference and you can see and modify object properties. I also understand that if you want to be able to replace the object and return it that you can pass it “byref” and do so.

With the above being stated, when I pass an object preceded with “byref” (a class variable for instance) in Xojo 2.3 I can only see the object as “nil” in the debugger even though the code works as expected. If the object is not passed as byref the object can be viewed in the debugger as expected.

One of the benefits of passing the object with “byref” is if it is truly nil, it can be instantiated in the method, changed and returned. If it is not passed by “byref”, if it is nil and instantiated, it will still be nil on return and cause a nil object exception.

What I don’t understand though is why the debugger will not show the contents of an object passed byref.

You’ve discovered a bug in the debugger :slight_smile: Using an older version the byref parameter does change to an instance when assigned to, but in Xojo 15r2.2 it stays nil. Note that if you select higher in the stack and view the variable that was passed in, it changes to an instance.

Looks like this is a reported bug that I can confirm on OS X. However the feedback has not been reviewed or verified.

(https://xojo.com/issue/40410)>]link text

Works up to Xojo 2014 (including last version of RB which I still use sometimes). Does not work anymore since Xojo 2015.1

William, your URL was bad, here’s the cleaned up URL:

<https://xojo.com/issue/40410>

Thanks, Michael.

FYI, inside Feedback.app, if you click the Gear icon and choose “Copy Sharing Link” you can then just paste that into the forum and it will do the magic.