[Vala] Understanding object creation (and other things)



Hi, I'm pretty excited about how vala is coming on, but there are some
things that I just don't follow.  It's quite possible that I would
understand a lot more if I knew more about glib/gobject, but I don't
sadly.  However, if vala is going to be adopted, it probably needs to
appeal more to people like me, right?

The specific problem I have is trying to work out how to do something
that's very simple in most languages.  I want a constructor to take a
parameter that is only of use in the constructor, and is never stored.
Normally I would just:

class SomeThing extends Thing {
public SomeThing(int x) {
 initialize_things(x);
}
}

But vala tells me that this constructor can't do anything except set
member values.  I'm sure this is a common thing to do, yet vala seems
to make it very tricky.  I don't want to store that "x" anywhere, just
use it and forget about it.

I guess overall I find the whole object construction thing very
confusing.  There seem to be 3 different ways to set the value of
properties, and yet none of them can easily take arguments.  This
might all make sense if I knew more about glib, but I've tried to
learn that and failed twice already.

The other language I'm watching at the moment is D, which feels a lot
more intuitive so far.  I'd much rather use vala though, as it fits so
nicely with everything else - gtk being a big selling point for me.

Thanks in advance.

--
Phil Housley



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]