On 2010.10.16 3:29 PM, Fergal Daly wrote:
> 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.

I'm +1 to using this sort of solution for all the fiddly little special
comparison functions, but not the entire interface.

Exporting test functions is fine, they're unlikely to clash and they get used
plenty.  Exporting ninety bazillion little helper functions with names that
are likely to clash and only get rarely used... not so much.  Huffman encoding.

Exporting a $Deep which the user can use for $Deep->re or $Deep->superhashof
sounds like a good compromise.


-- 
Defender of Lexical Encapsulation

Reply via email to