The question is - why create() is called when module is inherited, not when it is instaniated?
1) If you inherit modules, you're probably doing something that you really didn't want to do, since modules are objects, not classes.
2) create *is* called when a module is instantiated. Create is called in every object that is instantiated, and modules are objects.
If there is Parent.pmod (with create() defined), and Child.pmod, which inherits Parent, then create() defined in Parent will be called when Child is _compiled_.
That is because you're inheriting an object. .pmod files will be instantiated. You probably don't want to inherit an object. Create is called because Parent.pmod is instantiated to the module object.
Rename Parent.pmod to Parent.pike if you really want to inherit it. .pike files represent classes (programs).
/ Mirar
Previous text:
2004-02-02 09:53: Subject: Pike module initialization at compile time
Hi,
I asked this once on general Pike list, nobody answered, so I'll try here :)
The question is - why create() is called when module is inherited, not when it is instaniated?
If there is Parent.pmod (with create() defined), and Child.pmod, which inherits Parent, then create() defined in Parent will be called when Child is _compiled_. Compilation of Parent won't call it's create() method.
In case if module is _imported_, such behavior is logical, but when inherited... What especially confuses me is the fact that regular parent class definition won't cause such effect...
Any ideas/explanations? :) Is this "behavior by design" or?
Regards, /Al
/ Brevbäraren