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