[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
On Sun, Jan 24, 1999 at 03:55:04PM -0500, scrytch wrote:
>
> @program socials.grin_cmd
>     dynamic loc;
>     loc ?= user().location();
>     loc.announce(user().name() + " grins.");
> .
> 
> 
> @program me.mygrin_cmd
>     .... get the social command package somehow ...
>     socials.grin_cmd();
> .
> 
> @program me.xgrin_cmd
>     dynamic loc;
>     ... get the social and the channel somehoe ...
>     loc = channel;
>     socials.grin_cmd();
> .
> In short, I'm looking for environment variables.  There are in-db ways
> to do this, using object variables on some global object, but they
> require looking up in some task id table, have to be garbage-collected,
> and overall such grossness lacks the clean syntax one gets from a
> simple declaration of dynamic scope.
 
In the past I have thought about creating a context or 'environment'. 
The problem is it does not follow the model of ColdC very well.  I'll
leave it up to Bruce to wrestle with this issue, however :)  Also, in
your example you are essentially wanting global variables--but globals
which are defined by limited scope methods.  The problem here is the
execution state becomes very contextual.  How is the method
.mygrin_cmd (using your example) supposed to know that 'loc' is
defined in .grin_cmd?  Should the interpreter just scan forward to the
next method, load it up and check to see if it defines any globals?
As you can see, this could get to be quite scary :)

Actually, it is just an issue of design.  I see what you are trying to
do, but I dont find it to be a good argument for environmental
settings :)  Since in your example you are already wrapping the
command, why not just add an extra option syntax that can be used
to specify alternate behaviour (i.e. the location/channel).  Infact,
just do it with optional arguments (oob_arg, as in out-of-bounds...
something that wouldn't normally come from the interpreter):

@program me.social_cmd
  arg cmdstr, cmd, str, @oob_args;
  var loc;

  oob_args = (| oob_args[1] |) || #[];
  if (oob_args.contains('location))
      loc = oob_args[loc];
  else
      loc = user().location();
  [...do the social...]
.

@program me.channel_social_cmd
  ...args
  ...figure out channel
  me.social_cmd("", args[1], args[2], #[['location, channel]]);
.

Then when .social_cmd() is called from the command interpreter
oob_args is simply [], but when called from .channel_social_cmd, it is
the dictionary defining the alternate location.

Enjoy,

  -Brandon Gillespie

PGP signature