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



On 3/15/07, Juerg Billeter <j bitron ch> wrote:
> On 3/14/07, Jürg Billeter <j bitron ch> wrote:
>> On Mit, 2007-03-14 at 18:10 -0300, Alexandre Moreira wrote:
>> > I'd love to have pointer support, this is basically "THE" thing I miss
>> > in Vala, not that I would use it that much... just that I like the
>> > Error support in GLib and wouldn't feel like using an exception
>> > handling mechanism ...
>>
>> Could you explain why you wouldn't like try, catch, throw syntax for
>> GError?
>
> Not anything wrong with try catch, but it all comes down to the kind
> of code it would generate. What I like with GError as it is in C Api
> is that not much (pretty much nothing, actually) happens under the
> hood. That way I can always rely on what is going on simply by reading
> the code.

We don't plan to generate very complicated C code when compiling Vala
exception handling statements. Note that we won't replace GError, we'll
just add syntax to easily use GError with simpler code than in C.

> I have to work daily with C#.Net and I really like the overall syntax
> of Vala, as I like C#. It is just that I am quite familiar with pure C
> also, and don't want to get too much abstraction between my Vala code
> and the related C code.
>
> *THE* nice thing I love about Vala is that it maps so beautifully to
> pure C code, so I am sure I can count on my C skills to easily debug
> generated code if I think something is not doing right. Unfortunately
> I expect try/catch to break a bit of this beauty of generated code.
> Thats all.

We really like to follow this principle in the future - and improve the
generated C code even more. Exception handling won't be different, it
should look pretty much the same as if you manually handle GErrors.

>> > If I'm allowed to ask: PLEASE, add pointer support :) It shouldn't be
>> > the preferred way to do things but I'd love to have it available to
>> > solve the problems one might face.
>>
>> Yes, it probably makes sense, at least to make it easier to bind some
>> non-GObject libraries. I can imagine that parsing the pointer syntax
>> will be a bit tedious but the rest shouldn't be that hard.
>
> I don't think we'd need too much stuff for pointer syntax here. I
> mean, since this is not the preferred way of working in Vala, it would
> be a simple matter of being able to declare a pointer, assign a
> reference to it (and I think that ref already works pretty well for
> that matter) and having an operator for dereferencing the pointer. No
> -> or stuff like that would be needed.
>
> It's great to see that this is being thought off... Think I'll get
> back to the paper and keep modeling the further iterations of my
> software, since the very first class I need to implement needs to use
> GError's... please let me know when we have a pointer syntax so I can
> start implementing it all :)

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...

Jürg





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