--- chromatic <[EMAIL PROTECTED]> wrote: > On Thursday, July 24, 2003, at 11:17 AM, Austin Hastings wrote: > > >> No, I think Java interfaces are a kluge to get around copying a > >> broken type system and the lack of multiple inheritance. > > > > Multiple Inheritance != Protocols | Interfaces > > I quite agree, but I've done enough Java to know that if they could > have "solved" it with MI, they would have. > > > Protocols/Interfaces is a way of saying "My structure is none of > your > > damn business, but I comply with the rules you've set." > > Yes, exactly. > > > I disagree, and I hope you've simply swapped terms around. > > > > I think you want to declare "I comply with ruleset X" at the callee > > object level. That enables the compiler to (1) check that you're > not > > lying; and (2) optimize based on (1). > > At least one of us is using "caller/callee" in the X11 sense. What I > mean and what I think you mean is: > > method foo ( Thingie $t ) { ... } > > $object->foo( $behaves_like_thingie ); > > foo() says, "Give me something that I can treat like a Thingie. I > don't care HOW it does it, I just want it to do something sane."
To me, $object.Class is the callee (includes "method foo"). The code that contains C<$object->foo($behaves_like_thingie);> is the caller. > If we're just confused over a bit of terminology, we're in violent > agreement on the idea, which is much more important. Yeah. So what do we get? # Multiple Inheritance: class Combo is all(SuperClass1, SuperClass2, ...) {...} class Comb2 is Super1 is Super2 {...} # Protocol: # More than just an interface, because Perl6 is okay with # loose encapsulation protocol TCPIP { has $.variable; # Protocol requires this variable has $.var2 is Array of Int; # Ditto method Int m1(Int, Str) {...} # Method required } Going one step farther, there's a function called "protocol" and maybe one called "class" that handle this sort of thing. Also, C<is> means C<implements> when given a protocol, and C<implements> extracts a default protocol when given a class. class Scalar implements Str implements Int implements Ref {...} # All you need to know. class MyArray is class(Array) # Convert PCL to Class Perverse behavior: # Converts protocol "TCPIP", above, to anon class, inherits. class Perv is class(TCPIP) {...} # Converts Super2 to Protocol, implements it. class Perv2 is Super1 implements Super2 {...} class Perv2 is Super1 is protocol(Super2) {...} # Alternatively, select any of: # {private, protected, public}_methods (or "methods" => public) # {private, protected, public}_data ("data" => public) # inheritance class Perv2 is Super1 implements Super2, qw(methods inheritance) {...} class Perv2 is Super1 is protocol(Super2, qw(methods inheritance)) {...} =Austin