On Sat, Jun 30, 2012 at 01:20:12PM -0700, Evan Nemerson wrote: > On Sat, 2012-06-30 at 12:39 -0700, Charles Hixson wrote: > > My first take is that the answer is no, and I'm enough of a neophyte that > > > > words.vala:53.29-53.33: error: `Entry' is not a supported generic type > > argument, use `?' to box value types > > > > ... > > > > HashMap<int32, Entry> ids; > > HashMap<int32, Entry?> ids; > > > currently I'm avoiding the problem by converting the struct to a class, > > and at least in this case that's a reasonable approach, (or, of course, > > I could probably store a pointer to the struct, but in my eyes one of > > the advantages of Vala is that it minimizes the number of times I need > > to explicitly deal with pointers). > > It's generally best to void structs unless you are concerned about > performance, and even then you have to be careful. structs are > allocated on the stack and aren't reference counted or registered with > the GObject type system, so they can be much faster when used properly. > However, they are harder to use and easy to misuse. It is easy to > accidentally copy them, which can easily counteract their performance > benefits. > > > -Evan > > _______________________________________________ > vala-list mailing list > [email protected] > https://mail.gnome.org/mailman/listinfo/vala-list
But if you don't need reference counting and just need data holding like in his example wouldn't a struct be much better then a class? Stefan _______________________________________________ vala-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/vala-list
