<HEAD><TITLE>discuss@charon: [212] in "Coldmud discussion meeting"</TITLE>
<H1>[212] in Coldmud discussion meeting</H1></HEAD>
<A HREF="/"><IMG SRC="/i-d.gif" ALT="root"></A>
<A HREF="?212"><IMG SRC="/i-back.gif" ALT="meeting"></A>
<A HREF="/help.html"><IMG SRC="/i-help.gif" ALT="help"></A>
<A HREF="1"><IMG SRC="/i-first.gif" ALT="first"></A>
<A HREF="211"><IMG SRC="/i-fref.gif" ALT="first in chain"></A>
<A HREF="211"><IMG SRC="/i-pref.gif" ALT="previous in chain"></A>
<A HREF="211"><IMG SRC="/i-prev.gif" ALT="previous"></A>
<A HREF="213"><IMG SRC="/i-next.gif" ALT="next"></A>
<A HREF="213"><IMG SRC="/i-nref.gif" ALT="next in chain"></A>
<A HREF="215"><IMG SRC="/i-lref.gif" ALT="last in chain"></A>
<A HREF="1641"><IMG SRC="/i-last.gif" ALT="last"></A>
<HR><H2>Re: match_template() needs help with consistancy</H2>
<H3>daemon@ATHENA.MIT.EDU (Thu Apr 28 00:29:21 1994
)</H3>
<PRE>
To: the Lyncx &lt;BRANDON@cc.usu.edu&gt;
Cc: coldstuff@MIT.EDU
In-Reply-To: Your message of Wed, 27 Apr 94 21:17:18 -0600.
             &lt;01HBOMJG87W4BETA4J@cc.usu.edu&gt; 
Date: Thu, 28 Apr 94 00:26:34 EDT
From: Greg Hudson &lt;ghudson@MIT.EDU&gt;


&gt; match_template("f * d *", "f zz d foo")        =&gt; ["f", "zz", "d", "foo"]
&gt; match_template("f * d *", "f \"zz\" d foo")    =&gt; ["f", "zz", "d", "foo"]
&gt; match_template("f * d *", "f \"zz\" cc d foo") =&gt; 0
&gt; match_template("f * d *", "f zz d \"fo\"o")    =&gt; ["f", "zz", "d", "\"fo\"o"]

From the documentation on match_template:

	A simple wildcard is represented by an asterix (`*').  A
	simple wildcard matches any number of words in string.  If the
	wildcard is followed by a word-pattern in template, then it
	can also match a quoted wildcard match.

	A quoted wildcard match is just like a C-- string literal: it
	begins and ends with a double quote (`"'), and can include a
	literal double quote or backslash by preceding the character
	with abackslash (`\').  If the simple wildcard is followed by
	a word-pattern, and the words in string that the wildcard
	would match begin with a double quote, then the match must be
	a quoted wildcard match or the match fails, even if the match
	would have succeeded if the words were not treated as a quoted
	wildcard match.

My justification:

* If the user wants to match a wildcard with something that includes
text that would match the next word pattern, the user should simply
quote the entire argument as a C string literal, and leave it at that.

* The user generally doesn't want any processing to get in the way
when it's not necessary; therefore, no processing at all is done on
the last argument.

As far as I know, these rules are completely consistent with MOO's
verb-dobj-preposition-iobj parsing rules, assuming the pattern is of
the form "foo * bar *".

&gt; As I feel it should work (for consistancy reasons):

&gt; match_template("f * d *", "f zz d foo")        =&gt; ["f", "zz", "d", "foo"]
&gt; match_template("f * d *", "f \"zz\" d foo")    =&gt; ["f", "zz", "d", "foo"]
&gt; match_template("f * d *", "f \"zz\" cc d foo") =&gt; ["f", "zz", "cc", "d", "foo"]
&gt; match_template("f * d *", "f zz d \"fo\"o")    =&gt; ["f", "zz", "d", "fo", "o"]

According to these rules, a wildcard can (apparently) result in more
than one field.  This requires in-db checking every time you match a
template containing a wildcard, and worse, it is ambiguous: consider:

	match_template("f * a|b *",
		       "f \"b\" a \"a\"")	=&gt; ["f", "b", "a", "a"]
	match_template("f * a|b *",
		       "f b \"a\" a")		=&gt; ["f", "b", "a", "a"]

The later results sound like genuine bugs; perhaps someone should fix
them.

--GBH

</PRE>
