<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.developerdotstar.com/community" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>developer.* Blogs - A Microsoft Visual Studio C++ version of Brian Kernighan&amp;#039;s Beautiful (?) Code - Comments</title>
 <link>http://www.developerdotstar.com/community/node/777</link>
 <description>Comments for &quot;A Microsoft Visual Studio C++ version of Brian Kernighan&#039;s Beautiful (?) Code&quot;</description>
 <language>en</language>
<item>
 <title>A note on &quot;conforming strings&quot;</title>
 <link>http://www.developerdotstar.com/community/node/777#comment-9699</link>
 <description>&lt;p&gt;In wanting to return the start index and the length of the string that conforms I return counterintuitive results such as an index of 0 and a length of 1 for the regex CC* and the string CC, and, even worse, an index of 0 AND A LENGTH OF 0 for the regex C* and the string CC, using Pike&#039;s code, because Pike&#039;s code gets shortest string.&lt;/p&gt;
&lt;p&gt;Independent of programmer implementation, there is a mathematics of regular expressions (that is not necessarily the property of professional mathematicians, any more than a regex processor defines human reality).&lt;/p&gt;
&lt;p&gt;A programmer would observe that there isn&#039;t one and only one conforming substring, and that the conformant string is defined by the User, assuming you can find one (the &quot;user&quot; is an undefinable buzz word). A mathematician would say that the conformant strings are a plurality which can be thought of as a SET.&lt;/p&gt;
&lt;p&gt;Therefore, any real regular expression processor has to by default give the caller the start index and length of the longest conformant string, NOT the shorter: Pike&#039;s code is mislabeled.&lt;/p&gt;
&lt;p&gt;The longest conformant string can stand for the set since the set of conforming strings is just the set of substrings starting at the index i of the longest string, and then substring (i+1, maxlength-1), (i+2, maxlength-2) .. (i + maxlength - 1, 1). If the regex ends in an asterisk then the set also includes the null string.&lt;/p&gt;
&lt;p&gt;This model can be extended to carat and dollar (the characters representing start and end of string) by transforming the input string s to ^s$ in a meta-notation.&lt;/p&gt;
&lt;p&gt;Which means that a solid regex would return an object, a class, that allows retrieval of each conformant string from a set model. This class could implement laziness in a sweet fashion: if asked for the first and shortest conformant string, it could get only the conformants just-in-time by using an algorithm where the maximum length of conformant string, relative to the minimum, would be a parameter!&lt;/p&gt;
&lt;p&gt;Indeed, a solid regex would be a class with methods that would EXPLAIN regular expressions, producing outputs such as &quot;gets at least one C&quot; for CC*, allowing its use as a real tool as opposed to a rather misleading snippet.&lt;/p&gt;
&lt;p&gt;The ability to think in sets as opposed to bytes doesn&#039;t seem to transfer across the boundaries between languages, between languages that explicitly handle sets, and languages like C. In Beautiful Code, I don&#039;t see the beauty of ontology...making objects that correspond to thought.&lt;/p&gt;
</description>
 <pubDate>Sun, 30 Dec 2007 06:28:36 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 9699 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>A Microsoft Visual Studio C++ version of Brian Kernighan&#039;s Beautiful (?) Code</title>
 <link>http://www.developerdotstar.com/community/node/777</link>
 <description>&lt;p&gt;&lt;a href=&quot;http://www.developerdotstar.com/community/node/777&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.developerdotstar.com/community/node/777#comment</comments>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/20">Software Development</category>
 <pubDate>Sun, 30 Dec 2007 05:03:10 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">777 at http://www.developerdotstar.com/community</guid>
</item>
</channel>
</rss>
