I found a strange thing here.
First of all, there’s 2 main () here, and the program doesn’t compile because of that.
The second where class Foo? there are classes Maman.Bar Maman.Foo Maman.Ibaz, and Maman.Bar inherited from Foo.
And third, what does a class Declaration like int field(?)
public class int public_class_field = 23;
Like to be treated like a normal int, not a class.
The test runner script compiles the tests with --main main, which specifies main as the entry point.
This one surprised me a little bit, but it seems that:
class Foo.Bar : Object {}
is exactly equivalent to:
namespace Foo {
class Bar : Object {}
}
The Vala manual (see below), says “When declaring which class, if any, a new class subclasses, and which interfaces it implements, the names of those other classes or interfaces can be qualified relative to the class being declared.” I couldn’t find anything that covers how Foo is used in Maman.Bar.main though.
Thanks for the replies. Before you get too far, another small question is how to access the inherited class field. A guide to the Gnome said about the access functions inherited class through base keyword , but nothing is said about the fields.
This is what it looks like on D lang.
class A { int a; int a2;}
class B : A { int a; }
void foo(B b)
{
b.a = 3; // accesses field B.a
b.a2 = 4; // accesses field A.a2
b.A.a = 5; // accesses field A.a
}
class Alpha {
public int a;
public int a2;
}
class Beta : Alpha {
public new int a;
}
void main() {
var b = new Beta();
b.a = 3; // accesses field Beta.a
b.a2 = 4; // accesses field Alpha.a2
(b as Alpha).a = 5; // accesses field Alpha.a
}