Re: [Vala] Help me find the right Vala idiom
- From: "Mark Delany" <v2h xray emu st>
- To: vala-list gnome org
- Subject: Re: [Vala] Help me find the right Vala idiom
- Date: 5 Mar 2012 20:41:28 +0000
On 05Mar12, Chris Elston allegedly wrote:
Hello list,
I have a pattern I commonly use in C which I've so far failed to
translate to an equivalent Vala or indeed OO equivalent. I was hoping
that those more used to thinking in such terms would be able to point me
in the right direction.
I'm no vala pro, but there are a number of ways you could do
this. Generics is one and polymorphism is another. I've pasted a
sample of the latter at http://pastebin.com/QwqwERJp
Note that parseInt and parseString are derived from the base class and
have different signatures for the "value" method.
Other vala short cuts include using:
o the int.parse() method rather than strtoul()
o [:] array referencing to access data after the keyword
o the label: value constructor technique
o properties to set/get the parsed value
BTW. It's not clear to me that length+1 is safe if the parse string
only contains the token, but this is just a mimic your C code.
Mark.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]