On Mon, Feb 02, 2004 at 10:05:01AM +0100, Mirar @ Pike developers forum wrote:
- If you inherit modules, you're probably doing something that you really didn't want to do, since modules are objects, not classes.
OK, then it leads to another question - if modules are objects, why I can't modify variables, defined in those modules (directly)? And what _exactly_ happening when I import or inherit the module (the docs are a bit short in this topic)?
Rename Parent.pmod to Parent.pike if you really want to inherit it. .pike files represent classes (programs).
OK, this works - thank you :)
But there is another question, then...
I've a module with "global" object, initialized to 0. When I try to compile some file, which imports this module, I get an error:
=> Global.pmod <= GlobalClass Global;
class GlobalClass { string method() { return "I am Global!"; } }
void Global_init() { Global = GlobalClass(); }
=> x.pike <= import Global;
int main() { Global_init(); write("Global's value: %O\n", Global->method()); } ============
So, attempt to compile & run: "pike -M. x.pike" gives:
x.pike:7:Indexing on illegal type. (This is Global->method()) Pike: Failed to compile script: Compilation failed.
Well... Frankly, I see no reason why it cannot be _compiled_... When Global is initialized in place (...Global = GlobalClass()), everything is OK.
Regards, /Al