1998Q4/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: DevMUD:  Inheritable modules -->
<!--X-From-R13: Xnzrf Ivyfba <wjvyfbaNebpurfgre.ee.pbz> -->
<!--X-Date: Sun, 22 Nov 1998 15:04:22 &#45;0800 -->
<!--X-Message-Id: 98103107413600.19398@d185d1e96 -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199810310335.UAA05407@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:  Inheritable modules</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="msg00851.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00853.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00633.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00853.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00852">Author</A>
&nbsp;|&nbsp;<A HREF="#00852">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00852">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: DevMUD:  Inheritable modules</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:  Inheritable modules</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>: Sat, 31 Oct 1998 06:42:51 -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 Fri, 30 Oct 1998, Chris Gray wrote:
&gt;[Joachim Pileborg/The Arrow:]
&gt;
&gt;[...description of mudule interfaces...]

[snip Chris's endorsement]

&gt; &gt;The function array is a NULL terminated array of pointers to
&gt; &gt;interface_function structures.  The interface_function struture contains
&gt; &gt;the following fields:
&gt; &gt;  o Funciton name
&gt; &gt;  o Pointer to the function
&gt; &gt;The function name is a predefined constant that is interface specific.
&gt; &gt;For example:  The Net basic module could have the following function
&gt; &gt;names:  MOD_NET_CONNECTTO, MOD_NET_WRITETO, and MOD_NET_READFROM.
&gt;
&gt;I'd like to add parameter and result type information. Even if this
&gt;stuff is statically predetermined, having it available at run-time is
&gt;useful if there is a MUD-internal language that can display it. Or
&gt;allow an on-line programmer to call a module exporting it!
&gt;
&gt; &gt;MUDs must have at least the following interfaces to be DevMUD compliant:
&gt; &gt;  o Module
&gt; &gt;      The Module interface contains functions to get info about the
&gt; &gt;      module and configuring the module.
&gt; &gt;  o Net
&gt; &gt;     The Net module is an abstract interface, containing just dummy net
&gt; &gt;     functions.  Modules inheriting this interface must provide real
&gt; &gt;     implementations for these functions.
&gt;
&gt;Are you really speaking of what a MUD must implement in order to be
&gt;compliant with DevMUD? Or are you speaking of what modules must
&gt;implement in order to be usable with a DevMUD core? In the latter case,
&gt;why must all modules implement the Net interface?

core vs non-core again. Clearly mud hackers will need to be able to run test
muds on non-networked machines. The question is, how do we support them?
If networking is just another module, they can drop out the tcp module and
replace it with the "read from stdin" dummy net-module (or something).
Unsupported functions like gethostbyname would then have to fail... 

&gt; &gt;If a module inherits an interface not in the interface database, the
&gt; &gt;module is unloaded and an error message should be logged on the console
&gt; &gt;and sent as a message to all loaded modules.
&gt;
&gt;Why? If a module is loaded, and it implements an interface that no-one else
&gt;has heard of, so what? Perhaps the very next module to be loaded needs
&gt;that interface, and the two are being loaded as a pair. Just add the
&gt;interface to the table of interfaces, and have it ready for use. I also
&gt;think that the only interfaces that the core need already know about are
&gt;those which it exports, or which it generically requires of all modules
&gt;(e.g. your Module interface).

yes, I agree with Chris, there is absolutely no reason why new interfaces
should not be added at runtime. I do have a niggling question, though: if
Module A uses Interface B, and Module C implements interface B, how
does A get ahold of the proper declarations for Interface B? That is, if B has
function "string foo (double)", and A wants to use it, does A have to declare a
function pointer 

string (*foo) (double);

and do the dynamic resolution when it's loaded? Then every module that uses
interface B needs to declare the prototype for foo, and at this point you might
think, "they should all include a header file". This might be the way to go.

I would do this using static constructors in C++, so it would all happen
magically at load-time without much work on the module writer's part. In
C, something like the following could work (I tested this with egcs-1.0.3, I
would assume it is legal...) I have neglected interfaces per se
and just looked at function pointers.

#include &lt;stdio.h&gt;

int _foo (int a, const char *b)
{
  /* let's pretend I'm really from another module */
  return a + atoi (b);
}

void *_lookup (const char *returns, const char *name, const char *args)
{
  /* let's pretend I'm part of the Module Connector */
  return _foo;
}

/* God bless those macros */
#define declare(ret,name,args) ret (*name) args
#define resolve(ret,name,args) name = _lookup (#ret, #name, #args)

#define foo_args (int, const char *)
declare (int, foo, foo_args);

int main (void)
{
  resolve (int, foo, foo_args);
  printf ("2 + 2 = %d\n", foo (2, "2"));
  return 0;
}

&gt;After thinking through this, and some earlier discussions, too, my
&gt;previous idea of having a header file containing prototypes for the
&gt;interfaces isn't needed at all. As Joachim says, each interface is
&gt;self describing, and the core simply matches up modules that export
&gt;such an interface with those that require it.

as I suggest above, headers might still come in handy if you have fifty modules
using interface B, and don't want to keep their prototypes in sync.

&gt;Just how the core matches up requirers with providers still needs some
&gt;discussion. This is a good start!

in Perl, I can "use Foo" and Foo's symbols then appear in my namespace. 
Let me propose the following:

1. All modules, no matter what their language, have some glue in C or C++ which
is responsible for hooking them into the core.
2. That glue should be fairly easy to write and understand. We can write
something like perl's xsubpp to automate its creation; different languages will
require different sorts of glue code, and we would need to write autogenerators
for each such language.
3. In order to import an interface, the glue code should #include a
header file containing the proper prototypes and typedefs
4. The glue code should include an _init (DLLMain on Win32) which resolves
all symbols from external modules and aborts the load if any symbols are
unresolved.
5. If the module has some initialization of its own, it can define some
specially named function (let's say "bootstrap") which the glue code will
look for and call if appropriate.

thoughts?

Jame



</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="00853" HREF="msg00853.html">[MUD-Dev] Re: DevMUD: Inheritable modules</A></strong>
<ul compact><li><em>From:</em> J C Lawrence &lt;claw#kanga,nu&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00614" HREF="msg00614.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</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="msg00851.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00853.html">[MUD-Dev] Re: DevMUD: Inheritable modules</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00633.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00853.html">[MUD-Dev] Re: DevMUD: Inheritable modules</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00852"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00852"><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: DevMUD:  Inheritable modules</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00576" HREF="msg00576.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Thu 29 Oct 1998, 02:45 GMT
</LI>
<LI><strong><A NAME="00613" HREF="msg00613.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sat 31 Oct 1998, 03:16 GMT
</LI>
<LI><strong><A NAME="00614" HREF="msg00614.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sat 31 Oct 1998, 03:37 GMT
<UL>
<LI><strong><A NAME="00633" HREF="msg00633.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
The Arrow <a href="mailto:arrow#trelleborg,mail.telia.com">arrow#trelleborg,mail.telia.com</a>, Sat 31 Oct 1998, 21:01 GMT
</LI>
<LI><strong><A NAME="00852" HREF="msg00852.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
James Wilson <a href="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</a>, Sun 22 Nov 1998, 23:04 GMT
<UL>
<LI><strong><A NAME="00853" HREF="msg00853.html">[MUD-Dev] Re: DevMUD: Inheritable modules</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Sun 22 Nov 1998, 23:08 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00621" HREF="msg00621.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Cynbe ru Taren <a href="mailto:cynbe#muq,org">cynbe#muq,org</a>, Sat 31 Oct 1998, 07:50 GMT
<UL>
<LI><strong><A NAME="00657" HREF="msg00657.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Sun 01 Nov 1998, 04:02 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00639" HREF="msg00639.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sat 31 Oct 1998, 21:22 GMT
</LI>
</ul>
</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>