msg00358.html

1999Q1/msg00358.html · 8.3 KB

From the archive 1999Q1.zip

Download the archive   « Back to the archive contents

<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: Question on c++ switch optimization, and parsers in general. -->
<!--X-From-R13: [nex Uevggre <znexNreqbf.Egnasbeq.SRG> -->
<!--X-Date: Mon, 8 Feb 1999 13:18:26 &#45;0800 -->
<!--X-Message-Id: 199902082117.NAA25807#erdos,Stanford.EDU -->
<!--X-Content-Type: text -->
<!--X-Reference: Pine.SGI.3.96.990208111536.930G&#45;100000#zazu,angel.com -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: Question on c++ switch optimization, and parsers</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:mark#erdos,Stanford.EDU">
</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="msg00357.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00359.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00357.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00359.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00358">Author</A>
&nbsp;|&nbsp;<A HREF="#00358">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00358">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</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: Question on c++ switch optimization, and parsers in general.</LI>
<LI><em>From</em>: Mark Gritter &lt;<A HREF="mailto:mark#erdos,Stanford.EDU">mark#erdos,Stanford.EDU</A>&gt;</LI>
<LI><em>Date</em>: Mon, 8 Feb 1999 13:17:57 -0800 (PST)</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>
Adam Wiggins writes:
&gt; 
&gt; I've always been fond of the simplicity of the "big array with everything
&gt; you need to know about a given command" method.  Apparently some folks in
&gt; the diku world are as well: I know that stock CircleMUD handles commands
&gt; this way.
&gt; 

One advantage of this approach is that it's easy to handle abbreviated
commands --- just change the strncmp() in Adam's code to be is_abbrev()
or whatever.  You can then choose the order of search so that, for 
example "n" finds "north" before "news", or "k" finds "kill" before
"kick".  I'm not convinced, however, that any order other than alphabetic 
is worth the confusion--- or that global support for abbreviated commands are!
(I generally find myself typing the whole command in, and individual-user
aliasing support seems more generally useful.)

What's also missing from this scheme, in my experience, is nice way of
dynamically changing what commands mean.  (In diku terminology, "spec_procs".)
In my mud (as in most Circles, I think) all commands go through three linear 
searches:
   -- list of aliases for the player (linear, exact search)
   -- call all spec_procs in the room, each of which generally uses a
      bunch of if...else if...else if... statements  (abbreviated search)
   -- list of global commands (linear, abbreviate search.)

Now... the profiler says this isn't a big part of our processor load, but
it still offends the perfectionist in me.  :)  I think it would be a big 
improvement to dump the abbreviation support (possibly adding the commonly
used ones to the global commands) and use three hash tables to do the
lookup.  (Or at least B-trees.)  But... it might be interesting to study
whether the cost of updating the data structure as mobs and objects move
around is greater than the benefit obtained in verb lookups.

What this reminds me of is method dispatch in Smalltalk or Objective-C,
where the object has to determine at runtime how to dispatch a method.
Unfortunately, I don't recall how this is implemented, but it seems like
the aliases-specials-globals hierarchy is similar to inheritance--- except
that it can change at runtime.

Mark Gritter
mark#erdos,stanford.edu


</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="00357" HREF="msg00357.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
<UL><LI><EM>From:</EM> Adam Wiggins &lt;adam#angel,com&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00357.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00359.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00357.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00359.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00358"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00358"><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: Question on c++ switch optimization, and parsers i</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00364" HREF="msg00364.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers i</A></strong>, 
Ben Greear <a href="mailto:greear#cyberhighway,net">greear#cyberhighway,net</a>, Tue 09 Feb 1999, 02:46 GMT
</LI>
</ul>
<LI><strong><A NAME="00356" HREF="msg00356.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Ola Fosheim Grøstad <a href="mailto:olag#ifi,uio.no">olag#ifi,uio.no</a>, Mon 08 Feb 1999, 16:53 GMT
<UL>
<LI><strong><A NAME="00365" HREF="msg00365.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in  general.</A></strong>, 
Ben Greear <a href="mailto:greear#cyberhighway,net">greear#cyberhighway,net</a>, Tue 09 Feb 1999, 02:54 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00357" HREF="msg00357.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Adam Wiggins <a href="mailto:adam#angel,com">adam#angel,com</a>, Mon 08 Feb 1999, 19:47 GMT
<UL>
<LI><strong><A NAME="00358" HREF="msg00358.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Mark Gritter <a href="mailto:mark#erdos,Stanford.EDU">mark#erdos,Stanford.EDU</a>, Mon 08 Feb 1999, 21:18 GMT
</LI>
<LI><strong><A NAME="00359" HREF="msg00359.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Oliver Jowett <a href="mailto:icecube#ihug,co.nz">icecube#ihug,co.nz</a>, Mon 08 Feb 1999, 21:23 GMT
<UL>
<LI><strong><A NAME="00360" HREF="msg00360.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Oliver Jowett <a href="mailto:icecube#ihug,co.nz">icecube#ihug,co.nz</a>, Mon 08 Feb 1999, 21:30 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00361" HREF="msg00361.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Ola Fosheim Grøstad <a href="mailto:olag#ifi,uio.no">olag#ifi,uio.no</a>, Tue 09 Feb 1999, 00:16 GMT
</LI>
<LI><strong><A NAME="00362" HREF="msg00362.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Richard Woolcock <a href="mailto:KaVir#dial,pipex.com">KaVir#dial,pipex.com</a>, Tue 09 Feb 1999, 01:12 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>

Site Stats

Snippets: 1791
Codebases: 571