note
chromatic
<p>I suppose "I don't like modules that use string eval" is a fine objection if you want it to be, but I was under the impression that your meditation here was an attempt to argue that blindly applying conventional wisdom as prohibitions without understanding why it's conventional wisdom and why the real world can be more nuanced than it is is a bad thing.</p>
<p>So color me somewhat confused.</p>
<blockquote><em>The bit between big black lines looks an aweful lot like a string eval to me?</em></blockquote>
<p>Yep, and that's one way to do it. My Perl 6 reimplementation doesn't use string eval at all, for example. It's unnecessary in Perl 6. I believe my original Perl 5 T::B code dispatched to very small subroutine references. As it turns out, string [eval] happens to be faster and clearer in Perl 5 than maintaining a comprehensive dispatch table of all of the possible comparison operations. If there's a simpler, faster, and clearer way to do this, I'm sure Schwern would take a patch.</p>
<p>Similarly, I believe that <c>like()</c> uses string eval so that the code will work on truly ancient versions of Perl 5 that don't have <c>qr//</c>. I don't support versions of Perl older than 5.6.2, but Schwern's willing to do so here. If you have another solution that meets his goals, I'm sure he'd take that patch too.</p>
<p>However you said "String eval is the underlying basis of what the Test::* modules do." The code you quoted is not proof of that. How can it be? <code>cmp_ok</code> is <em>not</em> the underlying basis of what the Test::* modules do. It's not the underlying basis of Test::More. It's not the underlying basis of Test::Builder. Thus it's not the underlying basis of any Test::* module.</p>
<p>(What's the underlying basis of T::B? <c>ok()</c> and, to a lesser extent, <c>diag()</c>.)</p>
<blockquote><em>Reimplementing a small subset of perl's native functionality--string/numeric comparisons and regex--, using a large, slow, verbose and complex hierarchy of OO code modules, in order to compare scalar variables against constants, when at the final step you are just going to use string eval and let Perl do those comparisons anyway, just so that you can convert the boolean results into a stream of 'ok's and 'not ok's.</em></blockquote>
<p>My goodness, you're right. It's almost as if we wanted to test Perl code with Perl code. It's almost as if the code in T::B exists to report the locations of failures correctly, handle overloading properly, manage threading appropriately, and provide a uniform interface available from Perl 5.004 or earlier to the latest bleadperl, while allowing hundreds of testing modules to interoperate smoothly in the same process without having to know the internals of even those modules not yet written and without requiring everyone who wants to write tests in Perl to reinvent all of that badly and discover and, hopefully, fix the same weird bugs that everyone who writes testing modules in Perl would have had to fix eventually.</p>
<p>The horror.</p>
<blockquote><em>fascile</em></blockquote>
<p>I assume you meant facile, which means "easy", "unconstrained", and "pleasant". Thank you. That's why we wrote those modules.</p>
<p>(If you meant "superficial", I'd love to see the code you have which solves the same problems. Denying that many people have these problems and have solved them very satisfyingly is not the same thing.)</p>
<p>As always, you may have the last word in this discussion.</p>
670478
670779