From: beeman@cats.ucsc.edu (nameeB madA)
Newsgroups: rec.games.mud.lp
Subject: Re: Accessing attributes (was: Re: Virtual Rooms and Objects)
Date: 5 Sep 1992 21:01:18 GMT
Organization: University of California, Santa Cruz
Distribution: world
NNTP-Posting-Host: mingong-ws-4.ucsc.edu

In article <13963@chalmers.se>, d8andjo@dtek.chalmers.se (Johan Andersson) writes:
|> 
|> [ On the difference between variables accessed by functions and properties
|>   stored in a mapping. ]
|> 
|> I dont think one solution only can be correct. Replacing all variable
|> access functions (set/query) with 'properties' stored in a mapping is IMHO
|> a bad idea, because as someone stated, some times you need to do something
|> more then just setting or querying the variable.
|> 

For this reason, in the system I have, it's easy to overload things.
But, it means there's a wasted -> every time you use query("foo") because
it will look for a query_foo() that would override it.  And, if you want 
query_foo() to be able to access query("foo")'s value, then you just, use
_query("foo"), since _query() can't be overloaded.

|> 
|> By having set/query pairs you offer simple selectivity to the wizards.
|> 
|> If you have looked at CDlib you would know we use both functionalities, I
|> dont know if our compromise is very good.

Mine probably sucks.  Hard to say.

|> 
|> In article <37660@sdcc12.ucsd.edu> djohnson@cs.ucsd.edu (Darin Johnson) writes:
|> 
|> >   It should be done from the driver anyway, since it is really
|> >   a language feature.
|> >
|> I think I agree. 

Agreemsg.
I've produced a nice thing, functionally, but the overhead in LPC is too high.
I feel a little bit embarrassed that my new standard object is 8k and inherits
a 5k file of permissions stuff.  However, I guess most of this is comments and
fairly well-optimized code (IMHO) that seems to run pretty well.

But there's no doubt, at this level it needs driver support.  Everyone wants to 
read this standard object before they use it, and it doesn't help that it's an
insane maze of permissions, mappings, switch statements, bitmasked permissions
codes, etc.  (Actually, it reads fine to me, since I wrote it, but if you don't
know how mappings work then I guess it must look pretty bad.)  Putting this level
of stuff in the driver will make things seem transparent and magic again, and 
speed it up as well.

|> 
|> What we are talking here is an extension to the '->' operator to allow access
|> to variables.
|> 
|> >
|> >   The variables should define their own access.  (you wouldn't want
|> >   an external object defining if a variable is private or not,
|> >   so why do that for another variable attribute?)
|> >
|> Right, we could use 'public' to denote a read/write variable and 'protected'
|> to denote 'readonly', totally in conflict with C++ semantics :-)
|>

This has been talked about a bit, and in fact it's been done by Whiplash, the
guy who wrote MudOS's initial implementation of mappings in an hour... 
unfortunately there was some other stuff in his diffs that weren't finished
and not all his code was kept... the diffs may be laying around somewhere, though.
 
|> We should probably allow 'wrapper' functions optionally, thereby allowing
|> an object to trap sets and queries of its variables. The syntax for
|> declaring such wrapper functions are left to the amusement of the reader.
|> 

hm, my way of doing it basically wastes a -> to get it...

nomask mixed query(string what) {
        mixed foo;
        foo = call_other(this_object(), "query_" + what);
        return !undefinedp(foo) ? foo : _query(what);
}

Sorry this is just a wee bit obfuscated by the ? : operator, basically if there's
a function called "query_" + whatever you're querying, then you can over-ride
query()... this means valid_shadow() needs to do a function_exists() test on some
things, but it would be like this anyhow, wouldn't it?

I'd like to hear more on this thread.


|> /Johan
|> --
|> Johan Andersson           | "You don`t have conversations with microprocessors
|> Chalmers, Sweden          | you tell them what to do, and then you helplessly
|> Email:                    | watch the disaster when they take you literally."
|> d8andjo@dtek.chalmers.se  |	Sah`ot in David Brins "Startide Rising"


/Adam
-- 
#include <std/disclaimer.h>
#define NAME	"Adam Beeman"
#define EMAIL	"beeman@{cats, ucscb}.ucsc.edu"
inherit SIGNATURE; // enhanced .sig virus
Newsgroups: rec.games.mud.lp