To compare, or not to compare? That is a question for you

Since I don't want to sleep yet, but don't have anything to do either, I thought I might as well start with the new, totally random single-topic approach to the Vala Journal.

A while ago (in the first attempt on this journal thingy to be precise), I noted a proposed feature of "complex conditionals". Since there hasn't been much response, it may be better to dedicate a post to it.

It all boils down to a single new added possibility - chain more relational operations in a single expression. Example: if you need to compare a variable to two values, you currently need to do this:

if (1 < a && a < 5) {}

Well, that doesn't look too bad, you're right. What about this?

if (0 < a && a < b && b < c && c < d && d < 255) {
    // do something
} else {
    error ("Invalid data");

I don't know about you, but I think this is just evil.
Now, with the complex conditionals thingy, this would be possible:

if (1 < a < 5) {}

if (0 < a < b < c < d < 255) {
    // do something
} else {
    error ("Invalid data");

Muuuuuch nicer. :)

However, Jürg suggested that there are more possible approaches to this problem. For example a range syntax:

if (a in [1..5]) {}

I don't find this possibility particularly bad, but it wouldn't allow any fancier chaining, like in my second example.

So, questions for you: What do you thing about it? Which one do you prefer? Do you have any other suggestions?

Ahh, forgot to link the bug report.


Issue #3

I apologize for being late with this one. The flu season has finally caught up with me, so I wasn't in a very good shape for writing long texts.

As I have found out recently, it's pointless to post a verbatim list of changes in git, since you can all see it at http://git.gnome.org/browse/vala/log. That means I'll just stick to stuff I find noteworthy, which will be a challenge since my memory sucks.

Alternatively, since I moved this to a blog, I can very well treat it as a blog and simply write about interesting things ad-hoc, instead of trying to summarize them once a week. That would be a lot better, I suppose. What do you think?

Anyway, there have been a lot of fixes again.
Among others, some threading-related functions have been added to the MainLoop bindings. Good for those of you who want to use async functions within threads. Also libpurple bindings have been added.

It is now possible to use the "in" operator with arrays, which is quite nice I think.
Somewhat related is that it's now possible to use a different iterator style, I quote: "If the iterator object has a .next_value() function that returns a nullable type then we iterate by calling this function until it returns null". This can be useful for containers that can't contain null value.

Some might also find interesting that "likely" and "unlikely" functions have been added to the GLib bindings, binding G_LIKELY and G_UNLIKELY macros. Along with that, "static_assert" was added for G_STATIC_ASSERT, which I find utterly useless in Vala as it would cause a GCC error.

Well, that's all for today. Have a good time hacking (in) Vala. ;)


Valadoc.org is back online

After an unplanned "extended downtime", our lovely documentation site is back to its former glory.

Well, almost. Since the wiki style that allowed us to improve documentation was making the site incredibly slow, all pages are now static.

The site is now fast and the database is to be uploaded to a git repository as XML files, so changes will still be possible. It will be possible to download it and use locally, which is very nice.

Issue #2; the week after

Ah, so it's a week already! The time sure flies by.


Vala 0.7.10 Released!

Well, I'm a little late with this, but I guess you all already know.


Issue #1; introduction, questions and whatever

This one was originally posted to the Vala mailing list on Sunday.

Let there be light

So, a few days back, I started with an idea of a periodic summary of what is going on around the Vala programming language, mainly for those subscribed to the mailing list who are not that much interested in bugzilla.