in reply to OO Algorithm::Diff (finally) released

Looks like I will be able to simplify my VCS::Lite in future releases. Well done!

Any chance it could do diffs on things other than arrays? I've wondered if a version of diff could be passed two filehandles or two iterator callbacks.

--
I'm Not Just Another Perl Hacker

  • Comment on Re: OO Algorithm::Diff (finally) released

Replies are listed 'Best First'.
Re^2: OO Algorithm::Diff (finally) released (iterators)
by tye (Sage) on Sep 27, 2004 at 16:33 UTC

    Thanks!

    The nature of the algorithm requires that the data end up in arrays. So supporting iterators would just be bolted on to the front. So for the case of file handles, you might as well just use:

    my $diff = Algorithm::Diff->new( [<IN1>], [<IN2>] );

    as that will be as efficient as possible.

    For the case of other iterators, you might as well provide a general "iterate into a list" procedure that has nothing to do with Algorithm::Diff, for example:

    sub cvIterToList { my $cvIter = shift( @_ ); my @list; my $item; while( defined( $item= $cvIter->() ) ) { push @list, $item; } return \@list; }
    so:
    my $diff = Algorithm::Diff->new( cvIterToList($iter), [<IN>] );

    But I could certainly add such to A::Diff anyway. What other types of iterators should I support? Perhaps that is enough since other cases can be covered simply enough with something like:

    cvIterToList( sub { $obj->Next() } )

    - tye        

      The nature of the algorithm requires that the data end up in arrays. So supporting iterators would just be bolted on to the front.

      Do you really need to have entire list at once or does it operate on a window? Or does this change depending on the characterization of the differences?

      Maybe it might be worth a look whether Tie::File helps with files?

      Makeshifts last the longest.