Re: [Vala] [ANNOUNCE] Vala 0.5.2 - Compiler for the GObject type system
- From: Frederik <scumm_fredo gmx net>
- To: vala-list gnome org
- Subject: Re: [Vala] [ANNOUNCE] Vala 0.5.2 - Compiler for the GObject type system
- Date: Tue, 02 Dec 2008 18:46:42 +0100
Jürg Billeter wrote:
We are pleased to announce version 0.5.2 of Vala, a compiler for the
GObject type system.
Thank you! My favourite release so far, since some of my favourite bugs
are fixed.
* Do not require libgee for foreach statements.
Does that mean I can implement Iterables without libgee? If yes, how?
I can do this, but it requires libgee:
------------
using Gee;
private class RangeIterator : Object, Iterator<int> {
private Range range;
private int current;
public RangeIterator (Range range) {
this.range = range;
this.current = range.from;
}
public bool next () {
return this.current <= this.range.to;
}
public int get () {
return this.current++;
}
}
public class Range : Object, Iterable<int> {
public int from { get; private set; }
public int to { get; private set; }
public Range (int from, int to) {
assert (from < to);
this.from = from;
this.to = to;
}
public Type get_element_type () {
return typeof (int);
}
public Iterator<int> iterator () {
return new RangeIterator (this);
}
}
static int main (string[] args) {
foreach (int i in new Range (10, 20)) {
stdout.printf ("%d\n", i);
}
return 0;
}
------------
$ valac --pkg gee-1.0 iterable.vala
$ ./iterable
BTW, this produces a gcc warning, but it works:
iterable.c: In function 'range_iterator_gee_iterator_interface_init':
iterable.c:112: warning: assignment from incompatible pointer type
Regards,
Frederik
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]