On 26.02.2008, at 04:19, Gregory Beaver wrote:

My only objection is that this introduces two new keywords, trait and
instead.  In addition, this can get very awkward if multiple traits
(more than 2) implement the same method name.  I would prefer a simple
recycling of the "=" sign for both use cases (I'd also accept = for
override, "as" for alias).

class Talker {
 use A, B, C, D {
   smallTalk = A::smallTalk; // this says that if B, C or D implement
smallTalk, it is ignored
   talk = A::bigTalk;
 }
}

Well this is not just a different syntax, but an entirely different approach. In Stefan's proposal one had to explicitly handle every conflict manually. in your proposal you do not have to do this. As trait's specifically wanted to get away from automatic conflict resolution when things overlap, I think that Stefan's proposal makes more sense.

BTW Stefan: Whats the syntax for when you want to override a trait method with one inside the class definition?

I guess one would use "self::" like so:

class Talker {
 use A, B {
    B::smallTalk instead A::smallTalk;
    self::bigTalk instead B::bigTalk, A::bigTalk;
    A::bigTalk as talk;
  }

  function smallTalk() {
  }
}

I also assume that we would mandate signature compatibility (which IMHO should only throw an E_STRICT and not a fatal like what we currently do for inheritance in PHP6)?

regards,
Lukas

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to