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 05:47:41 &#45;0800 -->
<!--X-Message-Id: 98102508364500.22929@d185d1e96 -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199810250458.WAA02465@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="msg00482.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00484.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00549.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00475.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00483">Author</A>
&nbsp;|&nbsp;<A HREF="#00483">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00483">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 07:15:01 -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;- it has been suggested that it would be nice if modules could be either
&gt;    native code (C, C++, whatever) or MUD-language code, and that the
&gt;    two ways of writing them would be interchangeable. That could be a
&gt;    problem. There would almost certainly have to be some glue code
&gt;    to convert between the two. The previously suggested method, was,
&gt;    I believe, to have the linkage convention defined to be the one
&gt;    that the MUD-language uses, and require that native code convert
&gt;    as needed. That works for me.
&gt;
&gt;    Note, however, that both C and C++ are essentially strongly typed
&gt;    languages. If a function is written to accept a character pointer
&gt;    argument, then you had better not pass it an arbitrary integer!
&gt;    I take this as an argument that the MUD-language be strongly typed,
&gt;    or at least be able to export strongly typed function declarations.
&gt;    There are ways around this, but are there any non-ugly ones?

the way it is done in Guile and Perl makes good sense - there is a
struct which stands for 'a dynamically-typed object', which can be passed
to C or C++, has some methods, etc. so the internal representation CAN
be dynamically-typed even when expressed in C/C++.

Though I'm usually a big strong-typing partisan (I've been burned enough 
times at work by subtle Perl and Scheme bugs that would have been caught
with strong typing) I'd like to see a _truly_ dynamic type system, in
which an object's type can change dynamically over time. Then adding a 
new capability to an object (such as a new magical power) can be done at
runtime. This could be implemented on top of a strongly-typed system
in exactly the same way Scheme is implemented in C.

I liked JC's suggestion to build it like a unix system, with the core 
as the kernel, the db as the filesystem, and executables as native code 
or shell scripts or perl scripts or... there could be an analogue to
inetd which maps incoming connections to servers, where the servers obey
telnet protocol or some exotic mud protocol or what have you.


&gt;    Alternatively, we could drop the requirement that modules be allowed
&gt;    to be native or MUD-language, interchangeably? That would at least
&gt;    allow native modules to communicate by direct function calls, which
&gt;    is the most efficient.

I think this is an important feature which should be retained if at all
possible. It would allow a builder to try out some code in the interpreter,
do some rapid development, and, once things are working, have the 
interpreted stuff compiled to native code. Moreover, if one is doing funky
graphics or what have you, the extra performance could be a necessity.

&gt;    I'm flexible on this - to me it makes sense that all server stuff be
&gt;    written in the native language, and only scenario (world definition)
&gt;    stuff needs to be in the MUD-language. Thus, the expense of using
&gt;    the MUD-language interface would only be needed for scenario-level
&gt;    stuff, and that would only need to be native code if it was *very*
&gt;    expensive, and that expense would hide the cost of using the
&gt;    MUD-language interface.

*shrug* clearly the mudlang must be able to hook to native code, and
I would argue that the reverse is also essential. Thus the only question
is whether the mudlang can be translated to C/C++. If that is something
people see as desirable, the interpreter would have to be designed from 
the start to make that mapping feasible. (Not hard if you know it from the 
first.)

&gt;- there was some talk about matching up the interfaces of the modules
&gt;    based on function type and parameters. I think instead we need to
&gt;    define a set (which can grow as needed) of interface kinds, which
&gt;    give a purpose to a given exported definition or reference. Those
&gt;    kinds implicitly include the required function prototype. This
&gt;    will hopefully be clearer in some examples.

I'm trying to understand, so let me ask if this example is something along
your lines:

Module 'web_support' is set up to work using an external resource 
'g_net' which is some subclass of interface 'net_manager'. When 'web_support'
is loaded, it needs to find 'g_net' (i.e. resolve its external reference).
It asks some broker to give it 'g_net'. (There can be multiple specialized
brokers, or one huge one.) The broker determines if 'g_net' is currently 
available, and if not tries to find a module which claims to provide it. 
Assuming said module is found, it is loaded and the symbol is provided to
'web_support'.

Note that this is exactly what Linux's kerneld does.

&gt;    Having said that, I don't have any good suggestions for a general
&gt;    method of deciding how threads should be used. One possibility is
&gt;    that each input is run in a thread (the thread can be re-used when
&gt;    it is done with that input). Then, it would be input-generating
&gt;    modules that did thread control. Other modules might choose to
&gt;    use threads internally - that would be their business. A prime
&gt;    example would be an event handler (which in some senses is just
&gt;    another input-generator).

the issue of 'what goes into a module' is quite different from 'what should
be a thread'. Module 'web_support' could simply provide a set of functions
and classes for other modules to use, if they want. There is no need for a
thread there (although the underlying network functionality might well be
threaded). On the other hand, one might conceivably want a weather module
to start up a weather daemon thread when it loads (or multiple threads).
Depending on the event model, this might not make sense. (i.e. perhaps
all these modules do is provide types of events and event contexts, and
the threading strategy is chosen by the engine.)

&gt;OK, now to get into a bit more detail for my thought experiment.
&gt;
&gt;- some module interface kinds that I think a MUD-type game needs:
&gt;
&gt;input - a source of input (typically from a user). This will come
&gt;    with an identification of where the input came from, so that output
&gt;    that needs to go back to the same place can be properly routed.
&gt;    In my system I've found it useful to have more than one kind of
&gt;    input, (e.g. text, keypad presses, mouse-clicks, etc.), so I suggest
&gt;    that the prototype for an input handler be something like:
&gt;
&gt;	void inputHandler(void *source, uint kind, void *data, ulong len)

right here is where the C++ goons come and break your kneecaps. Using a
straight function call doesn't allow someone to write a handler which 
has its own individual state, e.g.

static string s_magic;

void inputHandler (/* rep */)
{
	// manipulate s_magic in a non-reentrant way
}

is BAD in a multi-threaded environment (and inflexible in any case). The
alternative is quite appealing:

struct input_handler
{
	virtual void handle (/* rep */) = 0;
};

can be specialized to be thread-safe and have any state it likes:

struct my_input_handler
{
	virtual void handle (/* rep */) 
	{ /* magic */ }
private:
	string _magic;
	mutex _lock;
};

&gt;    Alternatively, we could make the kind of input be part of the
&gt;    interface kind, so that, potentially, different modules could
&gt;    handle different kinds of input. E.g.
&gt;
&gt;textInput - void textInputHandler(void *source, char *data, ulong len)

IMO, interfaces should be up to the module programmers. Think of a module
as a shared library; to use that shared library, you write a program that
#includes the proper headers, and link it against libfoo.so. It's up to
you to use libfoo's api according to the headers, and up to the compiler
to check your errors. If you want to write a new module with some funky
interface, and Bob wants to use said funky interface, that should be as
easy as #including your headers and linking against your library (or 
whatever analogue applies).

[more io interfaces snipped]

&gt;Parsing
&gt;
&gt;This is a tricky issue. There is a whole range of ways that parsing can
&gt;be done. For example, in LPC, a lot of parsing is done by the individual
&gt;objects in the world. How does that fit into the module scheme? I'll
&gt;let others suggest how other schemes might fit in - I don't know enough
&gt;about them to say anything reasonable.
&gt;
&gt;I *do* know what my system is, however, so I can talk about how it would
&gt;fit into this scheme. In my scheme, there are things call "grammars"
&gt;that describe how to handle text input. (Is a parser required for
&gt;non-text input?)

yes. although it might not properly be called a parser any more,
something still has to understand the non-text stuff.

[parser stuff snipped]

&gt;How do we handle ambiguity? Is a system of separate modules like this
&gt;going to limit the sophistication of the parsing, simply because of
&gt;the structure imposed by having these inter-module interphases? Can
&gt;there be multiple parser modules loaded? If so, perhaps each client
&gt;or robot connection that provides an input has a parser selection
&gt;associated with it, and it is that parser's input handler that is
&gt;used. That requires that the input generators explicitly know about the
&gt;existence of parsers. Perhaps that sort of thing could be done in an
&gt;input filter, which just maintained a mapping between input streams
&gt;and parsers, and the main parser input handler is never directly called
&gt;from an input generator, but only indirectly via that filter module.
&gt;How would that affect other filter modules - they would have to be
&gt;inserted *before* the parser-chooser filter, else they would never
&gt;see any data!

right. 

socket -&gt; filter out dirty words -&gt; fix all typos -&gt; lexer -&gt; parser
-&gt; actual function calls

works fine. By defining suitable interfaces, anything in the chain could
be replaced by its functional equivalent, e.g.

robot -&gt; lexer -&gt; parser

or

script file -&gt; lexer -&gt; parser

&gt;Where in all of this have we switched from native code to MUD-language
&gt;code? In my system, its done when going from the filtered input into
&gt;the parser, but, with loadable parsers, it could also be done at
&gt;the point of the callouts from the parser to other (scenario) modules.

as I have suggested, with a suitable design this distinction should not 
be an issue. 

&gt;Does it make any sense for there to be more than one database module
&gt;loaded? How would anything choose which one to use for something?

not unless they contain unrelated things. if one contains apples and
the other contains oranges, it's easy to choose which one to go to.
if they both contain apples, you might as well call them a single 
database and wrap them up so client modules don't have to know that 
there's really two (or three, etc).

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="00477" HREF="msg00477.html">[MUD-Dev] 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="msg00482.html">[MUD-Dev] Re: MUD verb handling (Was: DevMUD - thoughts.1)</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00484.html">[MUD-Dev] Re: PDMud thread summary</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00549.html">[MUD-Dev] Re: MUD verb handling (Was: DevMUD - thoughts.1)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00475.html">[MUD-Dev] Re: I wanna do it OO</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00483"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00483"><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: MUD verb handling (Was: DevMUD - thoughts.1)</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00482" HREF="msg00482.html">[MUD-Dev] Re: MUD verb handling (Was: DevMUD - thoughts.1)</A></strong>, 
The Arrow <a href="mailto:arrow#trelleborg,mail.telia.com">arrow#trelleborg,mail.telia.com</a>, Sun 25 Oct 1998, 11:57 GMT
<UL>
<LI><strong><A NAME="00487" HREF="msg00487.html">[MUD-Dev] Re: MUD verb handling (Was: DevMUD - thoughts.1)</A></strong>, 
Adam J. Thornton <a href="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</a>, Sun 25 Oct 1998, 15:11 GMT
</LI>
<LI><strong><A NAME="00543" HREF="msg00543.html">[MUD-Dev] Re: MUD verb handling (Was: DevMUD - thoughts.1)</A></strong>, 
Jon Leonard <a href="mailto:jleonard#divcom,slimy.com">jleonard#divcom,slimy.com</a>, Tue 27 Oct 1998, 06:57 GMT
<UL>
<LI><strong><A NAME="00549" HREF="msg00549.html">[MUD-Dev] Re: MUD verb handling (Was: DevMUD - thoughts.1)</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Tue 27 Oct 1998, 16:32 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00483" HREF="msg00483.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, 13:47 GMT
</LI>
</ul>
</LI>
<LI><strong><A NAME="00475" HREF="msg00475.html">[MUD-Dev] Re: I wanna do it OO</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, 03:53 GMT
<LI><strong><A NAME="00472" HREF="msg00472.html">[MUD-Dev] Re: DevMUD Event Language</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, 02:37 GMT
<LI><strong><A NAME="00465" HREF="msg00465.html">[MUD-Dev] Re: PDMud, Gamora and Casbah</A></strong>, 
ApplePiMan <a href="mailto:ApplePiMan#aol,com">ApplePiMan#aol,com</a>, Sat 24 Oct 1998, 23:35 GMT
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00471" HREF="msg00471.html">[MUD-Dev] Re: PDMud, Gamora and Casbah</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, 02:33 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>