Re: [Vala] Behavior on null pointers
- From: Phil Housley <undeconstructed gmail com>
- To: Thomas Müller <muelletm googlemail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Behavior on null pointers
- Date: Mon, 17 Jan 2011 13:33:10 +0000
On 15 January 2011 20:23, Thomas Müller <muelletm googlemail com> 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]