Hi again,
I've digged a bit further on my problem. Compiling the vala code to C
code, showed a temporary variable which was a float. Changing this
variable to a double fixes the problem of the 'random' value. I've
attached a minimal sample vala program, and diff to change the
resulting c code. (all with vala 0.7.5)
This still leaves me wondering why i need to box a double to use it as
a generic type, while an int can be used just like that.
Kind regards,
Thomas Meire
On Fri, Aug 7, 2009 at 8:53 PM, Thomas Meire<[email protected]> wrote:
> Hi all,
>
> I tried to store a double in a Gee.Map for some algorithms I'm
> writing, but the program failed to compile (with valac errors). After
> reading a bit in the tutorial[1] and the reference draft[2], I decided
> to try the example in the reference manual[3]. However, the program
> failed to compile with the same error I had in my algorithms:
>
> "error: `double' is not a supported generic type argument, use `?' to
> box value types"
>
> So I changed that line a bit to look like:
>
> var t = new Two < int, double? > ();
>
> With that line, it compiles (with some warnings), but the output is
> not correct. It outputs some 'random' value instead of 5.
> So what can i do to make the program compile and make it do what it's
> supposed to do?
>
> Thanks a lot,
> Thomas
>
> [1] http://live.gnome.org/Vala/Tutorial
> [2] http://www.vala-project.org/doc/vala-draft/
> [3] http://www.vala-project.org/doc/vala-draft/generics.html#genericsexamples
>
using GLib;
public class Two <U> : Object {
public U u;
}
public static void main(string[] args) {
var t = new Two <double?> ();
t.u = 5.0f;
stdout.printf("%f\n", t.u);
}
171c171
< float _tmp0_;
---
> double _tmp0_;
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list