Damian Conway wrote:
> 
> I don't think the RFC shows that at all.

Well, I think the RFC is a little rough on some things, but that doesn't
necessarily invalidate some of the points.

> Or are you implying that packages and interfaces would dwell in separate
> namespaces? If so: YUCK!!!!!

No, c'mon. What am I over here, an idiot? :-}

That does bring up a good point, though, and perhaps is reason enough to
make :interface an attribute rather than its own keyword. Just like
:private and :public, actually... :-)

> On the other hand, if you can show me an example where there's a critical
> difference between C<use base 'Name'> and C<use interface 'Name'>, I'll
> happily retract my suggestion.

Well, I'm short on time - I'm flying out in a manner of hours. However,
I can point out one thing: If interfaces can only have sub prototype
definitions, then they cannot^Wshould not be the base for true
inheritance. Furthermore, if you conflate "use base" and "use
interface", then the following becomes impossible: using a base class
that does NOT use the interface, but then nonetheless using the
interface in your class.

By specifying "use interface" explicitly, you can make sure that your
class follows the interface spec. Otherwise, you rely on other classes
in the hierarchy above you doing so, and then you indirectly inheriting
from that interface. So "use interface" is really the only way you can
make sure somebody else didn't screw up. ;-) On large projects I think
this would be an essential safety check, just like "use strict".

-Nate

   package Pet : interface;

   sub isborn (@);
   sub scratches ($\@;@);
   sub annoys (\@);
   sub costsmoney ($$$$$$$$);
   sub poopsonfurniture ($);


   package Cat;

   use interface 'Pet';

   sub isborn {
       bless { @_ }, self;   # ;-)
   }
   sub scratches ($\@;@) {
       ...
   }
   sub annoys (\@) {
       ...
   }
   sub costsmoney ($$$$$$$$) {
       ...
   }
   sub poopsonfurniture ($) {
       ...
   }


   package Doggie;

   sub isborn {
       bless { @_ }, self;   # ;-)
   }
   sub scratches ($\@;@) {
       ...
   }


   package Doggie::Cute;

   use base 'Doggie';
   use interface 'Pet';

   # Our base class is 'Doggie', which does not use the 'Pet'
   # interface (perhaps unbeknownst to us!). Nonetheless, we use
   # the 'Pet' interface to make sure that our class is implemented
   # correctly.

   # code would follow...

Reply via email to