April 02
On 02-04-2019 17:48, Ron Tarrant wrote:
> On Tuesday, 2 April 2019 at 14:13:09 UTC, number wrote:
> 
>> Can somebody explain why getRgba() (apparently inherited from ColorChooser) does take an out parameter instead of returning an Gdk.RGBA?
> 
> My understanding is this:
> 
> Returning an object (as opposed to a single value) means returning a pointer rather than the entire object. And the object will cease to exist once the function returns because the scope no longer exists. So, it follows that an out variable passed in will preserve the object itself once program control returns to the caller.
> 

While that would be true for things that live on the stack, this is not the case for RGBA. The C version of getRgba uses the "out" parameter so you can pass in a existing GdkRgba, even tough that would make it more like ref.
This doesn't make sense for the d binding since you will always get a new RGBA passed through the out parameter.

-- 
Mike Wey
April 03
On Tuesday, 2 April 2019 at 18:27:10 UTC, Mike Wey wrote:

> While that would be true for things that live on the stack, this is not the case for RGBA. The C version of getRgba uses the "out" parameter so you can pass in a existing GdkRgba, even tough that would make it more like ref.
> This doesn't make sense for the d binding since you will always get a new RGBA passed through the out parameter.

Glad you're around to step in when I don't really understand what's going on, Mike. Thanks for clearing this up. :)
Next ›   Last »
1 2