RE: [PHP-DEV] RFC: Traits for PHP
| From: | Larry Garfield | Date: | Thu, 21 Feb 2008 19:03:16 +0000 |
| Subject: | RE: [PHP-DEV] RFC: Traits for PHP | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-35700@lists.php.net to get a copy of this message | ||
Ah, I thought you were talking about both. Non-public makes more sense for properties, but I
thought you were talking about methods not having ppp either. No worries then.
</de-lurk>
--Larry Garfield
On Wed, 20 Feb 2008 23:19:23 -0800, "Andi Gutmans" <andi@zend.com> wrote:
> My email talked about properties not methods. Please re-read it :)
>
> Andi
>
>> -----Original Message-----
>> From: Larry Garfield [mailto:larry@garfieldtech.com]
>> Sent: Wednesday, February 20, 2008 10:51 PM
>> To: internals@lists.php.net
>> Subject: Re: [PHP-DEV] RFC: Traits for PHP
>>
>> I am unclear on how this:
>>
>> trait ParseThingie {
>> protected function parseThingie($thingie) {...}
>> }
>> trait ProcessThingie {
>> protected function parseThingie($thingie) {...}
>> }
>> class Thingies {
>> use ParseThingie;
>> use ProcessThingie;
>> }
>>
>> allows more opportunity for confusion and clashes than this:
>>
>> trait ParseThingie {
>> public function parseThingie($thingie) {...}
>> }
>> trait ProcessThingie {
>> public function parseThingie($thingie) {...}
>> }
>> class Thingies {
>> use ParseThingie;
>> use ProcessThingie;
>> }
>>
>> (Presumably an un-qualified method would be public for traits just
> like
>> for
>> classes.)
>>
>> OK the above example is a bit of a strawman, but I don't know a non-
>> strawman
>> example here. :-) That's the clarification I'm asking for.
>>
>> On Thursday 21 February 2008, Andi Gutmans wrote:
>> > Because then you get into similar problems as with multiple
>> inheritance
>> > when you have property clashes and other issues.
>> > The reason why private is beneficial and different because it will
>> allow
>> > you to develop self contained functionality which can be attached to
>> > random classes. This can be quite useful for Timers, Counters,
>> > Containers, etc...
>> >
>> > Andi
>> >
>> > > -----Original Message-----
>> > > From: Larry Garfield [mailto:larry@garfieldtech.com]
>> > > Sent: Wednesday, February 20, 2008 9:54 PM
>> > > To: internals@lists.php.net
>> > > Subject: Re: [PHP-DEV] RFC: Traits for PHP
>> > >
>> > > On Wednesday 20 February 2008, Andi Gutmans wrote:
>> > > > a)
>> > > > I think Traits should be able to act as a self-contained
> behavior
>> > >
>> > > which can
>> > >
>> > > > always be expected to work. For example if I want a Counter
>> behavior
>> > >
>> > > I
>> > >
>> > > > would like that not to depend on the properties in the
> containing
>> > >
>> > > class.
>> > >
>> > > > While I don't think we should enable public nor protected
>> properties
>> > >
>> > > in
>> > >
>> > > > Traits I think allowing for private properties in Traits would
>> come
>> > >
>> > > in very
>> > >
>> > > > handy. It also is no problem when it comes to mangling as we can
>> use
>> > >
>> > > the
>> > >
>> > > > Trait name.
>> > > >
>> > > > class Trait {
>> > > > private $counter = 0;
>> > > > function getNextSerialNumber() {
>> > > > return $this->counter++;
>> > > > }
>> > > > }
>> > > >
>> > > > I strongly recommend not to support protected/public and not to
>> even
>> > >
>> > > get
>> > >
>> > > > into the discussion of dealing with conflicts of such
> properties.
>> >
>> > But
>> >
>> > > I
>> > >
>> > > > think private is very useful.
>> > >
>> > > Hi Andi. Why no ppp on Traits? It seems useful to be able to
> pull
>> in
>> > > a
>> > > utility function or functions that can be leveraged from other
>> >
>> > methods,
>> >
>> > > like
>> > > domain-specific parsers, without exposing them to the outside
>> world.
>> > > Is it
>> > > an engine-level implementation issue, or a conceptual complexity
>> >
>> > issue?
>> >
>> > > I
>> > > don't really see a complexity issue on the developer level, at
>> least
>> > > for me.
>> > >
>> > > --
>> > > Larry Garfield AIM: LOLG42
>> > > larry@garfieldtech.com ICQ: 6817012
>> > >
>> > > "If nature has made any one thing less susceptible than all others
>> of
>> > > exclusive property, it is the action of the thinking power called
>> an
>> > > idea,
>> > > which an individual may exclusively possess as long as he keeps it
>> to
>> > > himself; but the moment it is divulged, it forces itself into the
>> > > possession
>> > > of every one, and the receiver cannot dispossess himself of it."
> -
>> -
>> > > Thomas
>> > > Jefferson
>> > >
>> > > --
>> > > PHP Internals - PHP Runtime Development Mailing List
>> > > To unsubscribe, visit:
>> > > http://www.php.net/unsub.php
>>
>>
>> --
>> Larry Garfield AIM: LOLG42
>> larry@garfieldtech.com ICQ: 6817012
>>
>> "If nature has made any one thing less susceptible than all others of
>> exclusive property, it is the action of the thinking power called an
>> idea,
>> which an individual may exclusively possess as long as he keeps it to
>> himself; but the moment it is divulged, it forces itself into the
>> possession
>> of every one, and the receiver cannot dispossess himself of it." --
>> Thomas
>> Jefferson
>>
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php