Re: RFC: Traits for PHP

From: Date: Tue, 19 Feb 2008 13:12:11 +0000
Subject: Re: RFC: Traits for PHP
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-35592@lists.php.net to get a copy of this message
Larry Garfield wrote: > On Monday 18 February 2008, Richard Lynch wrote: >> Why not just allow 'include' here instead? >> > Because include requires the code in question to live in another file, which I > don't always want. I'm with Richard Lynch here: Simply allow inclusion. No new language concept, instead an existing one is made more orthogonal which is A Desirable Thing(tm) IMHO. About having it in the same file: You then need to also have the two classes using the Trait to live in the same file (or include_once that file) which is something I'm trying to avoid. I've gotten fond of one class per file for the sake of an autoloader anyway so I don't think separating the common code into a separate file is a big disadvantage. The part about being able to do partial Trait use seems hackish and somewhat complicated to me so I'd rather not have it in the language. It feels a little bit like being able to partially implement an Interface: I think a class should either have a Trait or not. If we're using include to emulate Traits then the same could be accomplished by separating the parts into files (if *really* desired). -1 for Traits as proposed +1 for allowing include in class definitions - Chris

« previous php.internals (#35592) next »