Hi,

>Executing it results in:
>
>** (process:19834): CRITICAL **: thing_set_property: assertion `self !=
>NULL' failed
>
>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?

Two things:

1) AFAIK checking if self != NULL in the beginning of all member
functions is a common convention in GObject. Vala follows it.

2) There are no null pointer exceptions - checking every object every
time it's used would be too expensive in any sane binary; trapping
SIGSEGV could make more sense, and currently I'm developing a library
that enables possibility to do this. But it's not beyond
proof-of-concept yet, and for some usable shape it needs some time. I'm
lazy.

>Anyway, changing "int property {get;set;}" to "int property;" even
>results in a segmentation fault. It might be discouraged to use a public
>property without getters or setters, but valac should generate something
>saver than :
>
>        Thing* thing;
>        thing = NULL;
>        thing->property = 42;
>
>in this case, shouldn't it? My valac version is 0.11.3.

Well, if you have a _property_, it's a setter & getter functions that
take object instance as a first argument (self). Following GObject
conventions, we just check if self != NULL. But changing it to a
_field_ will make a direct access - so it's perfectly sane to segfault
here, just as in any other C program where you have a structure pointer
== NULL, and try to write to the structure's members.

You may be interested in checking how --enable-experimental-non-null -
Vala will enforce to never assign null or possibly null value to any
reference that's not marked as nullable.

best regards,

>I am sorry, if this is the hundredth time someone mentions this here,
>please point me to the according discussion, if this is the case.
>
>best regards,
>Thomas
>
>
>
>
>
>_______________________________________________
>vala-list mailing list
>[email protected]
>http://mail.gnome.org/mailman/listinfo/vala-list


-- 
Mój klucz publiczny o identyfikatorze 1024D/E12C5A4C znajduje się na
serwerze hkp://keys.gnupg.net

My public key with signature 1024D/E12C5A4C is on the server
hkp://keys.gnupg.net

Attachment: signature.asc
Description: PGP signature

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

Reply via email to