Michael G Schwern writes:

> "my $foo = $p || $q" is not boolean.  I'm not even sure you can call
> it "pseudo-boolean" without understanding the surrounding code.  How
> do you know that $q can never be false?

So we want some way of annotating the code which will let Devel::Cover
know that you're assuming that $p and $q won't both be false.
Devel::Cover wouldn't be the only beneficiary of having such an
assumption explicitly stated: other humans having to read the code might
appreciate it too.

I can see why having 'inline' directives specifically for Devel::Cover
could be seen as ugly, but if instead they are general-purpose
assumptions then it's obviously better to have them next to the code
that's relying on the assumption than in some other file.

A good way of putting assumptions into code is with (Michael's
excellent) Carp::Assert:

  assert $p || $q, 'Either $p or $q must be supplied' if DEBUG;

That improves your code, makes it easier for other people who have to
deal with it, and should be enough to keep Devel::Cover happy.

> The other examples in the ticket play out the same way:
> 
>       bless {}, ref $class || $class;
> 
> $class being false would be quite the error.

Ditto, so you could make the assumption explicit with an assertion.  Or
perhaps something like Params::Validate would be better.

Smylers
-- 
May God bless us with enough foolishness to believe that we can make a
difference in this world, so that we can do what others claim cannot be done.

Reply via email to