Dave Rolsky wrote:
> One possibility is to simply return undef for
> methods that might cause
> infinite loops when we don't know for certain they
> won't.
>
> Calculating whether or not this can happen is
> probably possible in some
> cases (defined start & end), and in others we can
> offer a constructor flag.
There is an internal method called is_too_complex()
that could be included in the api.
if ( $set->max->is_infinite ||
$set->min->is_infinite ) {
return "set is not countable";
}
elsif ( $set->is_too_complex ) {
print "this will take a big while";
return $set->count;
}
else {
return $set->count;
}
With version 0.21 you can use $set->count on "too
complex" sets. Infinite sets still return undef.
- Flavio S. Glock