On 12/4/05, Ovid <[EMAIL PROTECTED]> wrote: > --- Kurt Starsinic <[EMAIL PROTECTED]> wrote: > > > package Foo; > > use Exporter; > > use strict::can; > > if (Foo->can('import')); # BOOM > > > I can provide other examples from my own code, but I > > think you get the point. > > The current version on my hard drive allows for "import". > > > The module is clever, but it's not clear to me that it's > > practically useful. Could you provide a real-world example > > where this > > would help to prevent or detect a programming error? > > Your world and my world can be considerably different. Using code very > similar to this solved a problem I had with Class::Trait whereby I was > exporting methods which should not have been exported.
Do you mean "calling methods which should not have been called?" It's not clear to me what, exactly, "exporting methods" means. > Also, if one is > routinely in the habit of checking class capabilities rather than class > types, this can be quite useful. It's clear that you're interested in addressing issues with checking class capabilities. What I'm not quite following is the basis of your premise, as I understand it: that imported functions are, in general, not meant to called as methods (with an undocumented exception made for "import"). What I'm asking for, if you're interested in feedback, is an example of a situation where youvre imported a function into a class, from other code you've called can() on said class before invoking a method call, it did The Wrong Thing, and you posit that all of the above doesn't reflect a bug in the class that did the importing. You *are* suggesting making this a pragma under the very well-known "strict" namespace and putting it on CPAN, so I'm expressing my personal concern that it may not be as generally useful and safe as the nomenclature might suggest. - Kurt