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



On 3/16/07, Jürg Billeter <j bitron ch> wrote:
On Don, 2007-03-15 at 22:02 -0300, Alexandre Moreira wrote:
> On 3/15/07, Jürg Billeter <j bitron ch> wrote:
> > It should work as follows:
> >
> > Method definition
> >         public void test (out Error error) {...}
> >
> > Checking for null
> >         if (out error != null) {...}
> >
>
> The problem with that is that it generates the following code:
>
> if (&(*error) != NULL) { ... }
>
> and this means that error will be dereferenced and then turned back
> into an address... Oh well, wait. I just decided to take a look at a
> debugger before hitting send.
>
> The thing is, I read the generated code but never actually ran it. It
> looks like by some kind of black magic (either that or I really don't
> get the meaning of that statement) error never gets dereferenced, even
> with the dereference operator acting right in front of it.
>
> I don't know if this is compiler dependent though. Perhaps it is
> simply a matter of gcc being smart enough to identify the pointless
> mix of operations and ignoring both.

It's obviously not nice code but it's only temporary and I assume it
works with any compiler as dereferencing error in &(*error) wouldn't
make sense.

> Just to be sure, though: Is the pointer support anywhere in the "map
> of plans" ? If so, is it near or far from being implemented (based on
> your list of priorities).

Yes, we'll add pointer support. I'll try to add it in the next couple of
weeks if it won't require large changes.

thanks for the replies, Jürg. I have to say: this is one of the
friendliest mail lists for in development projects I've ever been
into. I truly believe Vala is on its way to be a great tool, better
than it already is.


Jürg





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