[161] in Coldmud discussion meeting
Re: accessors for vars
daemon@ATHENA.MIT.EDU (Thu Mar 24 02:35:12 1994
)
Date: Thu, 24 Mar 1994 00:31:46 -0600 (MDT)
From: Lynxian Theologies <BRANDON@cc.usu.edu>
To: coldstuff@MIT.EDU
X-Vms-To: COLDSTUFF
> In C-- in general, and in the colddark db, haw does accessing
> an objects variables work? There are usually functions that
> return the variable if called, but rarely is there a function
> to set it. well, ok maybe rarely is an understatement, but in
> this case, where the variable is protected by encapsulation,
> i cant resort to the MOOcode equivalent of ;$obj.prop = val
> (or can i?)
> as a corralary/aside, it seems that each param should have an
> accessor for it which, if called with no args returns the value
> of the associated variable (which is the current case usually i believe),
> and if called with args, sets the variable (perms depending of course)
> and if it cant for some reason returns an error
> Just some ramblings as i endevor to comprehend this stuff.
Definitely a question we should have in the FAQ, when/if we get one (anybody
want to volunteer?).
You cannot directly access parameters, like in MOO. Instead you must have a
method on the defining parent to return the parameter. Eval can be used, if
you own the object or are an admin. Basically, you have:
$obj_A,A_defined_parameter = 0;
$obj_B,A_defined_parameter = 1;
In order to return the parameter you cannot create a method on $obj_B, you must
have a method on $obj_A, which has 'return A_defined_parameter;' somewhere in
it's code.
As an admin you can also use the command 'def * as * eval *':
definer $obj_A as $obj_B eval return A_defined_parameter; => 1;
--------------
Hope that makes sense...
-Brandon (aka Lynx)