Après une version 0.7.7 sans grande nouveauté, La nouvelle version du compilateur Vala, 0.7.8, vient d'être annoncée :
Support constructor chain up to GObject using Object (...)Citation:
Changes since 0.7.7
- Support constructor chain up to GObject using Object (...).
- Add syntax for string templates.
- Support (!) non-null casts.
- Many bug fixes and binding updates.
Il s'agit d'une nouvelle syntaxe pour modifier les propriétés d'un objet lors de sa construction.
Avant :
Code:
1
2
3
4
5
6
7
8
9
10
11
12 class MyWindow : Gtk.Window { public MyWindow () { this.type = Gtk.WindowType.POPUP; } construct { // ... } }
Maintenant :
Code:
1
2
3
4
5
6
7
8
9
10
11
12 class MyWindow : Gtk.Window { public MyWindow () { Object (type: Gtk.WindowType.POPUP); } construct { // ... } }
Add syntax for string templates
Il s'agit d'une nouvelle syntaxe pour facilité la substitution des variables dans une chaine de caractères :
Code:
1
2
3 string name = "Vala"; stdout.printf (@"Hello, $name!\n"); stdout.printf (@"2 + 3 = $(2 + 3)\n");
Support (!) non-null casts
Code:
1
2
3
4
5 void main () { string? a = "hello"; string b = a; }
Ce code ne compile pas avec la vérification strict ('--enable-experimental-non-null') :
Code:error: Assignment: Cannot convert from `string?' to `string'
Il est maintenant possible d'utiliser l'opérateur '(!)' pour forcer la conversion :
Code:
1
2
3
4
5 void main () { string? a = "hello"; string b = (!) a; }