--- Kurt Starsinic <[EMAIL PROTECTED]> wrote: > > 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?"
No. I did mean "which should not have been exported", but a thorough explanation of traits and what they do won't fit into this margin. > 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, This is actually very easy to do in capability based systems. For example, let's say I want the "clone" method from Clone.pm, but I want to call it as a function: package Foo; use Clone 'clone'; sub new { bless {}, shift } sub frobnicate { my $self = shift; my $args = clone([EMAIL PROTECTED]); # don't mess with their refs! ... } I've imported the clone function quite a few times but it's quite reasonable for someone to do this: my $foo = Foo->new; # later if ( $foo->can('clone') ) { # whoops Yes, they can just call the clone() method directly and watch things blow up but if they're testing an objects capabilities first, they get a bit of sanity. > 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. I agree that the name is ugly. I only used that after I saw Sean Burke's "strict::ModuleName". Namespace suggestions are quite welcome. Cheers, Ovid -- If this message is a response to a question on a mailing list, please send follow up questions to the list. Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/