On Sun, Dec 12, 2010 at 7:25 AM, Jonathan Bond-Caron <jbo...@openmv.com>wrote:
> On Sat Dec 11 10:25 AM, Stefan Marr wrote: > > > > http://wiki.php.net/rfc/horizontalreuse#requiring_composing_class_to_impleme > nt_interface > > > > > > Are there any objections to implementing this? > > > > It's not a bad idea, though I haven't found a strong need for it in the way > I plan to use traits. > Do you intend to use traits as reusable implementations of interfaces? If not, I could see why this feature isn't of interest to you :) > It also turns a trait into something more complex 'copy & paste' code with > requirements/dependencies. > I think copy & paste is a good way to conceptualize traits, but feel, practically, they're a bit more complex than that w/ conflict resolution, traits composed of traits, and the issue w/ attributes Stefan has brought up. Essentially, there are already rules being added around the copy & paste concept. Also, this feature is mostly an extension of the abstract keyword concept in traits, which they already support. > -1 on using 'require' (T_REQUIRE token), an option could be 'within' > > trait IteratorUser within Iterator { > function foo() { > $next = $this->next(); > ... > } > } > > class MyIterator implements Iterator { > with IteratorUser; > } > > So the 'with/within' tokens would apply to traits. > I feel 'expect', 'need', 'require' etc sound better, matter of opinion really, but it sounds like from an internals perspective it's preferred to reuse existing keywords if possible. Overall I feel -1, more use cases around "Trait expresses a requirement for > the composing class" would help, it seems like useful theory... not > convinced it's worth the trouble. If you see the value in the abstract keyword in abstract classes or moreover interfaces in general, I'd consider the value of this feature equal. Of course not everyone uses abstract classes or interfaces :D -nathan