On 15 January 2011 20:23, Thomas Müller <[email protected]> wrote:
>
> Apparently the c-version of Thing.set_property makes a call to
> g_return_if_fail, which prints the critical message as thing is null.
> Shouldn't a programming language, that offers exception handling, throw
> some kind of null pointer exception?

As a rule, exceptions in Vala (GErrors in GLib) are only used in
situations where you can't check what will happen before the fact.
With nulls, you can (almost) always do "if (x == null)", so triggering
a null pointer would be counted as a bug. Likewise, when in Java you
see comments like "@throws IllegalArgumentException when...", in C you
are more likely to see "Behaviour is undefined when..."

Whether that's a good thing is up to you. As Aleksander says, it's
less practical to handle this sort of error at runtime when you are
running native code with no VM, so Vala is a bit less forgiving than
some languages.

-- 
Phil Housley
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to