1998Q4/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: DevMUD &#45; thoughts.1 -->
<!--X-From-R13: Xnzrf Ivyfba <wjvyfbaNebpurfgre.ee.pbz> -->
<!--X-Date: Sun, 25 Oct 1998 12:45:36 &#45;0800 -->
<!--X-Message-Id: 98102515343906.22929@d185d1e96 -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199810251722.KAA02850@ami&#45;cg.GraySage.Edmonton.AB.CA -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: DevMUD - thoughts.1</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:jwilson#rochester,rr.com">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00496.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00498.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00491.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00500.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00497">Author</A>
&nbsp;|&nbsp;<A HREF="#00497">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00497">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: DevMUD - thoughts.1</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: [MUD-Dev] Re: DevMUD - thoughts.1</LI>
<LI><em>From</em>: James Wilson &lt;<A HREF="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</A>&gt;</LI>
<LI><em>Date</em>: Sun, 25 Oct 1998 14:22:17 -0500</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>

On Sun, 25 Oct 1998, Chris Gray wrote:

&gt;Adding things at run-time (new properties ("class members"), new
&gt;actions ("class methods")) is not incompatible with a strongly typed
&gt;language. You just have to have the right view of things, and not
&gt;be glued to the conventions that C++ and Java use. My MUD language
&gt;is strongly typed, but I can do this at run time (in wizard mode):
&gt;(Warning: 'private' does not mean what it does in C++ - it just says
&gt;who can see the newly defined *symbol*.)

yes, that's the other meaning of 'dynamic typing' that I was advocating.

&gt;I don't disagree. In my system, the very nature of the parser requires
&gt;going from compiled code to interpreted code to compiled code to
&gt;intepreted code (and possibly more) to handle nearly any input. What I'm
&gt;trying to avoid is requiring extra overhead for native =&gt; native calls
&gt;across module boundaries.

okay. that makes sense.

&gt; &gt;I'm trying to understand, so let me ask if this example is something along
&gt; &gt;your lines:
&gt; &gt;
&gt; &gt;Module 'web_support' is set up to work using an external resource 
&gt; &gt;'g_net' which is some subclass of interface 'net_manager'. When 'web_support'
&gt; &gt;is loaded, it needs to find 'g_net' (i.e. resolve its external reference).
&gt; &gt;It asks some broker to give it 'g_net'. (There can be multiple specialized
&gt; &gt;brokers, or one huge one.) The broker determines if 'g_net' is currently 
&gt; &gt;available, and if not tries to find a module which claims to provide it. 
&gt; &gt;Assuming said module is found, it is loaded and the symbol is provided to
&gt; &gt;'web_support'.
&gt;
&gt;That's a sort-of valid example, I think. I hadn't thought about the idea
&gt;of somehow automatically loading modules to resolve undefined references. I
&gt;was more concentrating on how explictly loaded modules would be tied
&gt;together. If we use 'dlopen' for loading, would a load module needed
&gt;by another be automatically loaded by dlopen? How would *our* loader know
&gt;that a given module exports a 'g_net' before someone has loaded that
&gt;module?

modules would need to register their functionality with the dynamic loader,
so they could be loaded when such functionality is requested. cf. kerneld,
which requires you to run depmod first.

&gt;I had thought that we wanted the various modules to be compiled completely
&gt;independently of one-another. The only header file I had envisioned for
&gt;inter-module stuff was one that defined constants for all of the currently
&gt;existing interface kinds, and provides prototypes for that kind.

see the end of the message for more on this.

&gt; &gt;Using a
&gt; &gt;straight function call doesn't allow someone to write a handler which 
&gt; &gt;has its own individual state, e.g.
&gt; &gt;
&gt; &gt;static string s_magic;
&gt; &gt;
&gt; &gt;void inputHandler (/* rep */)
&gt; &gt;{
&gt; &gt;	// manipulate s_magic in a non-reentrant way
&gt; &gt;}
&gt; &gt;
&gt; &gt;is BAD in a multi-threaded environment (and inflexible in any case). The
&gt; &gt;alternative is quite appealing:
&gt; &gt;
&gt; &gt;struct input_handler
&gt; &gt;{
&gt; &gt;	virtual void handle (/* rep */) = 0;
&gt; &gt;};
&gt; &gt;
&gt; &gt;can be specialized to be thread-safe and have any state it likes:
&gt; &gt;
&gt; &gt;struct my_input_handler
&gt; &gt;{
&gt; &gt;	virtual void handle (/* rep */) 
&gt; &gt;	{ /* magic */ }
&gt; &gt;private:
&gt; &gt;	string _magic;
&gt; &gt;	mutex _lock;
&gt; &gt;};
&gt;
&gt;I understand the C++ syntax you have written (except for "/* rep */" - is
&gt;that just meant to copy the prototype?), but I'm completely failing to
&gt;see what you are getting at. Sorry.

Writing it as a straight function call makes it impossible to extend by
subclassing, whereas using an object makes it possible. Since we don't
necessarily know all the things we are going to want to do in two months, 
four months, a year, why limit ourselves by choosing the more inflexible
option?    


&gt;Why would a handler want state? It seems to me that in a
persistent
&gt;virtual world, all state should either be attached to the entity
&gt;(e.g. player character) doing the action, or be global state attached to
&gt;some other persistent entity in the virtual world.

*blink* why is that inconsistent with a handler having state? suppose I
wanted to write a persistent object that WAS an inputHandler? or do you 
mean REALLY global state?

&gt;In either case, the
 preserving and retrieval of that state have to go
&gt;through the system's database.

this would assume that there's a distinction between DB objects and in-memory
objects, no? that is an issue which AFAIK hasn't yet been raised or resolved.

&gt; There should be very little static state in
&gt;any modules, and that all has to be protected by mutex's or spinlocks. Or,
&gt;the module could use queuing to serialize accesses. An example of static
&gt;state would
 be the set of client sockets that a telnet input module would
&gt;maintain.

agreed, though I would again write that as fields in some object rather than
as static, so one could have multiple telnet servers running simultaneously.

&gt; &gt;IMO, interfaces should be up to the module programmers. Think of a module
&gt; &gt;as a shared library; to use that shared library, you write a program that
&gt; &gt;#includes the proper headers, and link it against libfoo.so. It's up to
&gt; &gt;you to use libfoo's api according to the headers, and up to the compiler
&gt; &gt;to check your errors. If you want to write a new module with some funky
&gt; &gt;interface, and Bob wants to use said funky interface, that should be as
&gt; &gt;easy as #including your headers and linking against your library (or 
&gt; &gt;whatever analogue applies).
&gt;
&gt;If some modules wish to use shared libraries, that is up to them. 'dlopen'
&gt;can take care of that. It is outside our concern. What I think we need is

no no, the analogy is that modules ARE shared libraries.

&gt;ways whereby, e.g. modules that provide user input/output to the system
&gt;can be linked up to modules that provide parsing, scenario code, and
&gt;database operations. That linking up isn't done by name, it is done
&gt;based on the semantic nature of what is needed.

how is this semantic nature determined? 

&gt; Hmm. I suppose you could
&gt;use names to indicate that semantic nature. E.g. any module that exported
&gt;a parser would export a public symbol called 'parse', and the dlsym
&gt;facilities could be used to find that at run-time, and connect to it
&gt;from an input provider. However, that is just replacing the set of
&gt;constants in a header file with a set of strings, which would likely
&gt;also be in the header file beside the prototypes needed.

some unix systems will do this automatically (I believe Linux
does) while others require you to roll your own inter-module
linking. rolling your own is thus more portable, and also much 
more amenable to nice warning messages and graceful recovery 
from link errors. ("Unresolved symbol _Rxsv1_void_foo_1Qvoid", 
anyone?)

&gt;In this scheme of the header file containing the prototypes for the
&gt;interface kinds, it is quite easy to add new interface kinds. By
&gt;definition, no module is using or exporting an interface kind before
&gt;that interface kind is defined. OK, so someone needs a new one. They
&gt;add it to the big header file, along with the prototype they intend for
&gt;it. New modules can now be written that communicate using that new
&gt;interface kind. Old modules, which by definition do not use the new
&gt;kind, are not affected. Similar if someone wants old modules to use
&gt;the new kind - they must be modified to use it, and all is still well.
&gt;WOLOG (one of my math profs used that: WithOut Loss Of Generality).
&gt;
&gt;There is no particular reason that the "one big header file" couldn't
&gt;be split up into smaller pieces, if there are specialized interfaces
&gt;that only a couple of modules need. However, there does need to be
&gt;some mechanism (Perl scripts?) to check that no interface kind ID
&gt;(whether a number or a name) is used more than once. We don't want
&gt;a parser calling a database's 'fixup' interface when it is supposed
&gt;to be calling an output filter's 'fixup' interface.

this is not an issue with C++ or suitably name-mangled C.

&gt;James, it seems to me you are thinking of building modules that are
&gt;aware of each other at compile time. I've been trying to avoid that,
&gt;so that only at run-time are they actually attached to one-another.
&gt;But then, I could be missing your point altogether. How about a
&gt;more detailed example?

I guess I don't see the alternative to having modules know about one
another at compile time. Either they refer to some external symbols
(which end up being function pointers or objects with virtual methods)
or ... what? No module refers to any external symbols? All function 
calls are done by (a stringified) name?

Here's what worked for me a couple of years ago.

module web_magic contains functions which use network functions such as
gethostbyname. These network functions live in another module, 'net_lib'.
When web_magic is written, something is put at the top which says "I 
depend on net_lib". The C++ code for web_magic contains module initialization
code (_init () in most dlopen implementations) which is responsible for
dynamically loading net_lib  and linking up the functions web_magic uses 
with their bodies in the net_lib module. So, this could look like

&lt;pseudocode&gt;

/* web_magic */

/* some definitions here of function pointers or polymorphic objects
 * which we need from other modules, e.g. */

static struct hostent *(*_gethostbyname) (string name);

extern "C" void _init (void)
{
	/* use the dynamic loader to pull in the external
	 * references we need. Perhaps we name netlib.so explicitly */
	void *net_lib = dlopen ("net_lib.so", RTLD_NOW);
	_gethostbyname = dlsym (net_lib, "gethostbyname");

	/* or maybe there's something like kerneld that will find the
	 * netlib module for us and give us the right reference: */
	_gethostbyname = dynaloader-&gt;resolve_function ("gethostbyname");

	/* or maybe there's even a type-safe loading mechanism */
	_gethostbyname = typesafe_dynaloader-&gt;resolve_function 
		("struct hostent *gethostbyname (string)");
}

&lt;/pseudocode&gt;

So, 'web_magic' is _aware_ of net_lib at compile time, but is only 
linked up with it at load-time.

This is all off the top of my head, BUT something like it did work.
Actually, it was wrapped up in some C++ static initializers so 
nobody'd ever have to care about the minutia of dynamic loading on
Win32 versus Irix versus Linux. 

&gt;Please, someone jump on me if I'm coming on too strong here. I'm not
&gt;trying to squelch anyone else's ideas and proposals. I'm just espousing
&gt;some thoughts I've had.

you're not coming on strong, at least in this message. and besides, what's
wrong with a little debate? we're not delicate little flowers.

James


</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00491" HREF="msg00491.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></STRONG>
<UL><LI><EM>From:</EM> Chris Gray &lt;cg#ami-cg,GraySage.Edmonton.AB.CA&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00496.html">[MUD-Dev] Re: OpenMUD: bus-based communications</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00498.html">[MUD-Dev] Re: PDMud thread summary</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00491.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00500.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00497"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00497"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>[MUD-Dev] Re: openmud or pdmud or devmud</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00530" HREF="msg00530.html">[MUD-Dev] Re: openmud or pdmud or devmud</A></strong>, 
Adam J. Thornton <a href="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</a>, Tue 27 Oct 1998, 02:24 GMT
</LI>
</ul>
</ul>
</LI>
<LI><strong><A NAME="00490" HREF="msg00490.html">[MUD-Dev] Re: MUD verb handling (Was: DevMUD - thoughts.1)</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 25 Oct 1998, 16:25 GMT
<LI><strong><A NAME="00489" HREF="msg00489.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 25 Oct 1998, 16:16 GMT
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00491" HREF="msg00491.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 25 Oct 1998, 17:24 GMT
<UL>
<LI><strong><A NAME="00497" HREF="msg00497.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></strong>, 
James Wilson <a href="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</a>, Sun 25 Oct 1998, 20:45 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00500" HREF="msg00500.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 25 Oct 1998, 22:38 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00488" HREF="msg00488.html">[MUD-Dev] Re: OpenMUD: bus-based communications</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 25 Oct 1998, 16:03 GMT
<UL>
<LI><strong><A NAME="00496" HREF="msg00496.html">[MUD-Dev] Re: OpenMUD: bus-based communications</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Sun 25 Oct 1998, 19:52 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00486" HREF="msg00486.html">[MUD-Dev] openmud: open issues</A></strong>, 
James Wilson <a href="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</a>, Sun 25 Oct 1998, 14:37 GMT
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>