Re: [Vala] Question about namespaces..



Shawn Ferris píše v St 06. 01. 2010 v 12:22 -0700:
On Wed, 2010-01-06 at 07:51 +0100, Jan Hudec wrote:

It already exists. It's called a class!


Of course I know what a class is, and I understand (mostly) what they're
capable of. The problem with a separate class to manage the plugins is
scope. (IMO)

I wanted to suggest you convert the namespace to class (you can have
inner classes just fine) or create new class, but now I see you can
just as easily abuse the class you already have. Just make the array
a static field of the MyApp.Plugin.Instance class and make the "current"
property a class property of the same (static will do if you only call
it after any plugin is registered).

To convert the namespace to a class would require every plugin to then
know where the manager metaspace is, just so that it could instantiate
itself. That sounds like a pain, if not a bad idea.


I don't really know what "metaspace" is, but can't you just use static
methods, the same as with your namespace?

Anyway, in Vala, namespace is just a name prefix. It is nothing more and
never will be. It is there just to logically group related stuff. If you
need more, use classes with static members. :)

Attachment: signature.asc
Description: Toto je digitálně podepsaná část zprávy



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