Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

drhyde (1683)

  (email not shown publicly)

Journal of drhyde (1683)

Wednesday January 07, 2004
04:25 AM

Data::Compare 0.06 released

[ #16691 ]
Last night I released Data::Compare 0.06. It's functionally the same as the previous release, but the special-case support for comparing Scalar::Properties objects has been moved into a plugin.

Supporting plugins was Jim Cromie's idea. He was even good enough to send a nice big patch. I ended up not using his patch and writing my own version, for various reasons, but he deserves a great deal of credit for the idea.

The way I've done plugins is, I think, really nifty. We use File::Find::Rule to find any Data::Compare::Plugins::* module on the system, and require it. Because require returns the value from evaluating the code, we make use of that, and instead of just evaluating to 1 like most modules do, plugins must evaluate to a data structure which describes what the plugin can compare and how. That is squirreled away in a hash for easy access later.

Then, whenever we come to compare two structures, we first check to see if there is a hash entry for that pair of data types and if there is, do whatever the plugin says. If there isn't, we try to compare the underlying data structures.

Plugins are useful in two circumstances that I can see:

  1. when your data type has overloaded operators like stringify, numify, and comparison - you can now provide code so that Data::Compare can delve into their guts and *really* compare them;
  2. you want non-equal structures to compare equal. The plugin for Scalar::Properties is an excellent example. I decided that a true scalar and a Scalar::Properties should be treated as being the same if they stringify/numify the same, but that comparing two S::Ps should only succeed if both their values and all their properties match.

And then this morning, the first thing I did was spot a documentation bug in the new version. Oops.

[Update] I spotted another oopsie too, where it might try to load the same plugin twice, and hence spit out errors about redefined subroutines and stuff. Both fixed in 0.07 :-)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.