On 16 October 2010 03:59, Ricardo Signes <perl...@rjbs.manxome.org> wrote:
>
> Tonight I uploaded Test::Deep 0.108.  The changes made are very small, and
> should not affect anyone other than some edge cases in which it should be
> faster.
>
> Many of the open bugs relate to unfortunately named exports like "blessed" and
> "isa," and to behavior that should probably change but would break existing
> scripts.  I'd like to improve the way in which exports are organized and
> generated.
>
> "use Test::Deep" would be equivalent to "use Test::Deep -v0" which would be 
> the
> current set of exports.  The new set of catch-all behavior, mostly the same 
> but
> with "blessed" and "isa" renamed would be "-v1".  Other exports could be
> grouped in other ways to get things like "use Test::More -objects, 
> -containers"
> or something along those lines.  Using Sub::Exporter would make this very 
> easy,
> and would allow a lot of other tricks like getting all the exports with a
> prefix on the names.  ("td_bag" instead of "bag" for example.)  I'm not sure
> whether there will be general chafing at the new prereq, though.

One of the reasons I had no time for Test::Deep is that my day-job is
python. While I spend a fair bit of time cursing python, I do not miss
for one minute Perl's global namespace which drives the need for
exported symbols. In python modules are objects themselves and so you
place the module object in your namespace and access it's members. One
of the first things I did was port Test::Deep and I use it like this

import deep

deep.compare(foo, deep.Set([1,2 3,4]))

I tried to port this import statement to Perl but functions vs methods
makes a general implementation impossible unless you have knowledge of
the module being imported. However there's nothing stopping individual
modules adopting the convention. It's particularly useful if the
module exports a large and growing number of symbols. So I could
imagine the follwoing interface.

use Test::Deep2 qw($deep); # import the "module" as $deep

$deep->is_deeply($foo, $deep->set([1,2,3,4]));

So no namespace pollution but still access to all Test::Deep symbols
with little typing.

All implemented with a few lines of AUTOLOAD (excuse my almost
certainly broken code).

package Test::Deep2;

sub export {
  # poke "Test::Deep::Module" into the caller's namespace
}

package Test::Deep::Module;

sub AUTOLOAD {
  shift();
  goto &{"Test::Deep::".$AUTOLOAD};
}

Of course this could be done without a Test::Deep2, something like

use Test::Deep -module => '$deep';

with a bit more cleverness in export(),

F

> Another common complaint is the lack of clear docs about what is and isn't
> exported.  I'd like to get the export situation cleared up before documenting
> everything, so this is more or less tabled.
>
> Finally, there's a bug that cmp_deeply($have, $want) should compare both parts
> of a dualvar.  I think this is a mistake, and am likely to reject it with
> alternate ways to write that test.  I am open to argument now, but I think 
> it's
> pretty likely that I'll follow through with this plan.
>
> --
> rjbs
>

Reply via email to