[Vala] Set implementation and/or associative arrays



Hi all,

first of all a big thank you to Clement and Daniel for their links to
vala software sources. I am studyng them. :)

Now, to my problem: 95% of the software I write has to do with
databases, so the first one I am writing in Vala is using DBs. :)

I tried to implement an object "Row" that acts as an associative array,
so to have :

r = new DB.Row();
r["name"] = "My Name";
r.save();

I don't want to have to instantiate it like this:

r = new Row<string,string>();

So I tried to have them "implicit".
Looking through vala and gee sources I understood that I can do it
implementing Gee.Map interface, so I tried this:

using GLib;
using Gee;

public class Row: Object, Map<string,string>
{
        public string get(string key)
        {}
}

public class test: Object
{
        public void main(string[] args)
        {
                var r = new Row();
        }
}


But I get the following error (beside the "does not implement interface
method" ones):

error: Return type and/or parameters of overriding method `Row.get' do
not match overridden method `Gee.Map.get'.

I think it's because I should implement it as "public V get(K key)", but
this would lead me to declare "public class Row<K,V>: Object,Map<K,V>"
making the types explicit.

Is there a way to get what I want?

Could we have associative arrays embedded in the base language? ;)

And could we have "magic methods" without implementing interfaces
(__set(), __get(), __toString(), __call(), etc as in PHP/Pyhton/D)? :)

Thank you very much.

P.S.: I am using Vala 0.1.6, debian package.

-- 
Alessandro Pellizzari





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