Re: [Vala] out, ref and GError parameters.
- From: Jürg Billeter <j bitron ch>
- To: Alexandre Moreira <alexandream gmail com>
- Cc: vala paldo org
- Subject: Re: [Vala] out, ref and GError parameters.
- Date: Wed, 14 Mar 2007 21:51:51 +0100
On Mit, 2007-03-14 at 10:12 -0300, Alexandre Moreira wrote:
I'd like to know what is the "ref" keyword supposed to do in
parameters, I thought it would make the said parameter a pointer to
the type, but it made no change, at least not with class types.
So, right now I'm using out for that matter. Unfortunately, I can't
seem to use the GError stuff with that because it always tries to
dereference the pointer... and it is very likely that users of the
code will once in a while pass null as a parameter.
Do you guys have any idea on how to make this kind of code work ? It
is the last thing preventing me from using Vala and I'd really like to
use it :)
The plan is to use try, catch, and throw statements to handle GErrors;
that hasn't been implemented yet, though.
ref parameters are not yet supported with reference types, using out is
correct for the moment but that's not the problem. It's not possible to
pass null to ref and out parameters in C#; Vala follows this rule. The
reason is that it always dereferences the pointer; you can't check
whether the pointer itself is null with the current syntax, as there is
nothing like error and *error in C.
It probably makes sense to add support for real pointers like in C or
unsafe C#, this would fix the problem in this case.
There is still one possibility how to work around this limitation with
the current version, you may use something like the following:
if (out error != null) {
// set error
}
Support for this syntax will be removed in future Vala versions but
we'll try to keep it as long as neither exceptions nor pointers are
supported.
HTH,
Jürg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]