Would it be better to support an optional #vapi preprocessor?
Sorry if it is not the first time this issue is raised, but would it be better to support an optional #vapi (or #pkg, or #package, or something) preprocessor in Vala? This preprocessor, with the syntax
#vapi <vapi_name>
could be used to indicate the packages used in source files, and thus automatically introduce the corresponding --pkg options to valac when compiling. With this preprocessor, Vala language servers should be able to detect the dependency in a vala source file without meson files, which is an overkilling for small projects.
The first point is that, for example, considering a GTK "hello world" in Vala, with this preprocessor, the code (helloworld.vala) can be written as
#vapi gtk+-3.0
int main(string[] args)
{
Gtk.init (ref args);
Gtk.Window window = new Gtk.Window();
window.show_all();
Gtk.main();
return 0;
}
and then it should be able to compile it with a neat command
valac helloworld.vala
In contrast, currently, we can only specify the GTK package in the compiling command
valac --pkg gtk+-3.0 helloworld.vala
The second point is that, as aforementioned, such an optional preprocessor would also be very useful for Vala language servers. Since currently there are no preprocessors such as import or #include for Vala, Vala language servers can only rely on meson files to detect the dependency. And what make things worse is, after you added source files in the meson file, you need to do first a meson build, and then a reload to make dependency detection work. With this optional preprocessor, Vala language servers should be able to automatically detect the dependencies.
The last point is that, this optional preprocessor would help us better denote the libraries used in each single Vala source file, which should increase the readability of source codes.
Thx for your consideration!