RE: [PHP-DEV] RFC: Traits for PHP
| From: | Andi Gutmans | Date: | Thu, 21 Feb 2008 18:55:44 +0000 |
| Subject: | RE: [PHP-DEV] RFC: Traits for PHP | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-35699@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Lukas Kahwe Smith [mailto:mls@pooteeweet.org]
> Sent: Thursday, February 21, 2008 10:32 AM
> To: Andi Gutmans
> Cc: php@stefan-marr.de; internals@lists.php.net; Marcus Börger;
> Johannes Schlüter; Sebastian Bergmann; Alexandre Bergel; Falko Menge;
> Sara Golemon; derick@php.net
> Subject: Re: [PHP-DEV] RFC: Traits for PHP
>
>
> On 21.02.2008, at 19:09, Andi Gutmans wrote:
>
> > I don't think so. I think the value here is not copy&paste but to be
> > able to encapsulate some functionality which a class can be
> > decorated with. Giving a basic storage mechanism to that would be
> > very beneficial in a large amount of uses. Again, I am proposing
> > private storage only which would be for internal use-only by the
> > decorating methods.
>
> if someone desperately needs that they could just write a method with
> a static variable.
Not really because if you want a container shared across the methods it wouldn't be very
feasible. I'm sure there are some hacks you can do but I just think it'd be a pretty
common use case.
Stefan, you have done a lot of research in this area and I assume have also looked at the most
common
use-cases where this functionality is used in other languages. What is your sense?
> again i prefer to keep the feature as simple as possible without
> crippeling it the point of not being useful.
This suggestion is actually geared towards the opposite of crippling (private property is actually
an addition). I actually think this is something which would be a very common use case for our
users.
Btw, the 2nd part where I recommend brainstorming about a slightly stronger contract would actually
also drive more towards simplicity.
In any case, I think we all agree this is a good thing to have in PHP. I am not advocating the
opposite but I would like to explore some of these use-cases and options for a slightly stricter
contact.
Andi