Why should variables within a module be read only? As far as I can tell, a module is just a class that is instantiated only one time. That alone doesn't seem reason enough to cause there to be any difference in behavior compared to an object that's been instantiated from a class.
Am I missing something?
Bill
On Sat, 6 Aug 2005, Martin[iso-8859-1] B�hr wrote:
hi,
while playing around with modules, i observed the following:
variables in modules are readonly, when accesses directly, and trying to change them from the outside gives an error.
however trying to change then from the inside is either silently ignored or succeeds:
int i=7; string s="foo"; mapping dict = ([ "foo":8 ]); array list = ({ 5 }); multiset mset = (< "foo" >);
void set(mixed var) { // ignored: i=(int)var; s[0]=((string)var)[0]; dict += ([ "baz":var ]); list +=({ var }); list[0] = (int)var;
// succeeds: dict->foo=var; dict->bar=var; mset[var] = 1; mset += (< var >); }
shouldn't all of them fail and produce an error?
greetings, martin.