[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Note: The following post cites an example from MOO, but outlines something I'd like to see given driver support in Cold.

On E_MOO, we've made some feature objects such as channels work a little more generically than a typical feature object.  The channel FO is the quintessential example here, in which channels are simply rooms with a special :announce() verb.  The channel FO simply changes your apparent location for the duration of the task and redirects all commands that result in calls to :announce() and $you:say_action() to the channel.  This gives us code re-use, because channel socials can be ordinary social features that use the effective location (the channel) instead of the real location (the room the player is in).

Except there, the only way this works is if every feature is explicitly passed a dict (an alist anyhow) that contains this data and extracts it from the dict.  This is obviously not ideal in terms of code-re-use.  Dynamic scoping would solve this nicely.  I present a sample syntax (and yes it's primitive, I don't know message frobs):

@program socials.grin_cmd
    dynamic loc;
    loc ?= user().location();
    loc.announce(user().name() + " grins.");