[Coldstuff] Some undocumented functions

Brad Roberts coldstuff@cold.org
Wed, 5 Jun 2002 23:55:03 -0700 (PDT)


I'll let Bruce, Brian, or Brandon correct any errors in this, so don't
take it as gospel until someone backs me up.

get_var('variable)
default_var('variable)
inherited_var('variable)

All three take a symbol that is the name of the variable to lookup.  All
three will throw ~varnf if the variable isn't declared on the parent that
contains the method being executed.  All three return the value of that
variable as contained in the child object, if it exists.  Where they
differ is in what they do if the child object doesn't have a value yet.

get_var returns 0.

default_var returns the value of the variable on the parent (it will
always have a value, though it might be 0 also).

inherited_var walks up the parent tree (in breadth first order) and
returns the value from the first parent to have a value.

So.. that's the short form of the docs for these three builtin functions.
The latter two rather break one of the fundamental tenet in cold's
object system, strong variable encapsulation.  That said, coldcore uses
default_var in 3 places, all of which could have easily been done without.

Later,
Brad

On Thu, 6 Jun 2002, Jon A. Lambert wrote:

> Date: Thu, 6 Jun 2002 01:36:22 -0400
> From: Jon A. Lambert <jlsysinc@ix.netcom.com>
> Reply-To: coldstuff@cold.org
> To: "Coldstuff@Cold. Org" <coldstuff@cold.org>
> Subject: [Coldstuff] Some undocumented functions
>
> I couldn't find any documentation on:
>
> default_var()
>
> and
>
> inherited_var()
>
> What are they and what can they do for me?
>
> Thanks!
>
> --
> --* Jon A. Lambert - TychoMUD        Email:jlsysinc@ix.netcom.com *--
> --* Mud Server Developer's Page <http://tychomud.home.netcom.com> *--
> --* If I had known it was harmless, I would have killed it myself.*--
>
> _______________________________________________
> Cold-Coldstuff mailing list
> Cold-Coldstuff@cold.org
> http://web.cold.org/mailman/listinfo/cold-coldstuff
>