Re: [Vala] out, ref and GError parameters.



On Don, 2007-03-15 at 14:57 -0300, Alexandre Moreira wrote:
On 3/15/07, Juerg Billeter <j bitron ch> wrote:
As mentioned before, you can already start implementing by using the
out
syntax, you just will have to port the code someday but that shouldn't be
difficult.


I can't see how use the GError stuff with out syntax. Unless I
generate a lot of Error variables to use with my code, I can't simply
pass on the error handle the user gave me to the functions I call,
because the user might have passed it as null, and whenever I try to
pass this to the next function, it will dereference it :(

I can't check for null, and I can't use it in any way without
dereferencing it...

It should work as follows:

Method definition
        public void test (out Error error) {...}

Checking for null
        if (out error != null) {...}

Passing to next function
        foo (out error);

In short, as long as you use `out error` instead of just `error`, it
shouldn't get dereferenced. I haven't used this workaround for real
error handling, though, so I might have overlooked something. Please
report if there are still problems with that scheme.

Jürg





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]