go ahead... be a heretic | |
PerlMonks |
Re: (tye)Re2: File::Find bummers on an NFS volume.by bikeNomad (Priest) |
on Aug 01, 2001 at 22:58 UTC ( [id://101480]=note: print w/replies, xml ) | Need Help?? |
I don't see much of a difference between these idioms in Perl: It's interesting you mention this. My Algorithm-Diff module uses callbacks, in part because the original module by Dominus did, and in part because that seemed like a good thing to do. There are, in fact, about 6 callbacks that could be specified. A couple are there to handle comparison and hashing of user-defined data types (since everything in Perl isn't an object). The rest of them are there so that user code can be run while traversing the input sequences. This turns out to be pretty useful. I'm re-doing this module in Ruby, and am re-considering the interface in the process.
I ended up with the various diff functions in a class; if someone wants to override comparison behavior, they just re-define a method or two (Ruby lets you do this on a per-object basis; for the equivalent in Perl you can use my Class::Prototyped module). I wonder if that would be a better interface in Perl. You'd just override the methods you cared about:
Do you think that this is a better idiom than explicit callbacks?
In Section
Seekers of Perl Wisdom
|
|