Hi, no, you did not understand: I'm not trying to create object from an interface. I'm having class Foo, that is _NOT_ inheriting Object, but it's still a typed class, and it's implementing interface IFoo. This is (or used to be) legal. I'm creating instances of that class, but the reference is of interface-type:
// ------- test.vala ------- namespace Test { public interface IFoo { public abstract bool run(); } public class Foo : IFoo { public virtual bool run() { return true; } } public static void main() { IFoo ifoo = new Foo(); ifoo.run(); return; } } // ----- end test.vala ----- In my opinion it SHOULD be legal. I don't see a point why it's not legal now, and I don't understand the error message: error: missing class prerequisite for interface `Test.IFoo', add GLib.Object to interface declaration if unsure IFoo ifoo = new Foo(); ^^^^ As I'd understand this message, it means that an interface MUST have a prerequisite of a classed type. It's an absurd, why is it so? Can't I have an interface not having any prerequisites? Manual suggests so, the prerequisites list is optional. best regards, AW. >As far as I know, you cannot create objects from interfaces, so the line >below is wrong: > >I rewrote your code in this way and it worked correctly: > >namespace Test >{ > public interface IFoo : Object > { > public abstract bool run(); > } > > public class Foo : Object, IFoo > { > public virtual bool run() > { > print("fuck\n"); > return true; > } > } > > public static void main() > { > IFoo ifoo = new Foo(); > ifoo.run(); > return; > } >} > >If you like to learn how to use polymorphisms in you apps you can see >my tutorias >on launchpad <https://launchpad.net/vala-totrials>. >I wish it can help you... -- Mój klucz publiczny o identyfikatorze 1024D/E12C5A4C znajduje się na serwerze hkp://keys.gnupg.net My public key with signature 1024D/E12C5A4C is on the server hkp://keys.gnupg.net
signature.asc
Description: PGP signature
_______________________________________________ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list