<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD-Dev] Re: I wanna do it OO -->
<!--X-From-R13: Quevf Uenl <ptNnzv-pt.UenlEntr.Sqzbagba.OP.QO> -->
<!--X-Date: Sat, 24 Oct 1998 20:53:56 -0700 -->
<!--X-Message-Id: 199810250347.VAA02432@ami-cg.GraySage.Edmonton.AB.CA -->
<!--X-Content-Type: text/plain -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: I wanna do it OO</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">
</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>
[ <a href="../">Other Periods</a>
| <a href="../../">Other mailing lists</a>
| <a href="/search.php3">Search</a>
]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->
Date:
[ <a href="msg00474.html">Previous</a>
| <a href="msg00476.html">Next</a>
]
Thread:
[ <a href="msg00483.html">Previous</a>
| <a href="msg00472.html">Next</a>
]
Index:
[ <A HREF="author.html#00475">Author</A>
| <A HREF="#00475">Date</A>
| <A HREF="thread.html#00475">Thread</A>
]
<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: I wanna do it OO</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: I wanna do it OO</LI>
<LI><em>From</em>: Chris Gray <<A HREF="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</A>></LI>
<LI><em>Date</em>: Sat, 24 Oct 1998 21:47:58 -0600</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>
[James Wilson:]
>For those who like bytecode as an internal representation, I would like
>to note that using 'interpreted objects' rather than bytecode can be quite
>speedy. By this I mean that, for instance, a while loop can be represented
>as
>
>struct while_exp : public expression
>{
> virtual rep eval (vector<rep> &stack)
> {
> while (_test->eval (stack))
> _action->eval (stack);
> return VOID_REP;
> }
>....
>private:
> expression *_test, *_action;
>};
>
>this sort of internal representation is also really easy to integrate
>hand-written (or automagically-generated) C/C++ code with, as opposed to
>bytecode which doesn't have such a straightforward binding.
Nod. You can also translate the above representation (which is really
just a parse tree for the program) into byte-code readily enough. This
is what I was talking about in a previous post, about being able to
'pretty-print' the parse tree into user-selectable MUD languages.
Other than having the stack be pointed to by file-static variables
instead of being passed around as in your example, this is almost
identical to the non-byte-code interpreter in my system. My struct,
from the header file:
typedef struct {
struct Exec *wh_condition;
struct Exec *wh_body;
} While_t;
and the code in the parse-tree interpreter for a 'while':
case ex_while: {
While_t *wh;
wh = ex->ex_v.ex_whilePtr;
while (B_TRUE) {
runExec(wh->wh_condition, &leftValue, pType);
if (leftValue.qv_integer == BOOLEAN_FALSE || Exiting) {
break;
}
runExec(wh->wh_body, pRes, pType);
if (Aborting) {
Aborting = B_FALSE;
runError("execution timeout or abort");
Exiting = B_TRUE;
}
}
*pType = TYPE_VOID;
break;
}
Basically the same, except with a few of the inevitable extra details.
(Plus, its not C++ O-O stuff :-))
So, I can attest that what James is suggesting works quite well!
I did get additional speedup with bytecodes, however. I think the main
reason for this is that the above method uses a lot of function calls,
whereas a byte-code interpreter just loops internally. Also, MUD-language
function calls are a lot more expensive in my parse-tree interpreter
than in my byte-code interpreter, partly because of the need to do
general stuff to build the execution environment (like a stack frame)
for the called function.
--
Chris Gray cg#ami-cg,GraySage.Edmonton.AB.CA
</PRE>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00474.html">[MUD-Dev] I wanna do it OO</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00476.html">[MUD-Dev] Re: PDMud, Gamora and Casbah</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00483.html">[MUD-Dev] Re: DevMUD - thoughts.1</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00472.html">[MUD-Dev] Re: DevMUD Event Language</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00475"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00475"><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>
<ul compact>
<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><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><Possible follow-up(s)><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
<UL>
<LI><strong><A NAME="00474" HREF="msg00474.html">[MUD-Dev] I wanna do it OO</A></strong>,
James Wilson <a href="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</a>, Sun 25 Oct 1998, 03:14 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>
</ul>
<hr>
<center>
[ <a href="../">Other Periods</a>
| <a href="../../">Other mailing lists</a>
| <a href="/search.php3">Search</a>
]
</center>
<hr>
</body>
</html>