Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35709 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30420 invoked by uid 1010); 21 Feb 2008 23:12:34 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 30404 invoked from network); 21 Feb 2008 23:12:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2008 23:12:34 -0000 X-Host-Fingerprint: 81.25.53.50 NAT-81-25-53-50.ultranet.ru Received: from [81.25.53.50] ([81.25.53.50:25052] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/B9-64513-1650EB74 for ; Thu, 21 Feb 2008 18:12:34 -0500 Message-ID: <4E.B9.64513.1650EB74@pb1.pair.com> To: internals@lists.php.net References: <47BD207C.2080905@chiaraquartet.net> <47BE014F.5020202@stefan-marr.de> Date: Fri, 22 Feb 2008 02:12:37 +0300 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response X-Posted-By: 81.25.53.50 Subject: Re: [PHP-DEV] Re: Trait aliasing syntax suggestions From: dmda@yandex.ru ("jvlad") "Stefan Marr" wrote in message news:47BE014F.5020202@stefan-marr.de... > Hi, > > jvlad schrieb: >> in other words, why to introduce such a new thing as trait instead of >> using classes and trait'ing them? > I've introduced it as a separate notion from classes to avoid > misconception and problems occurring from conflicting properties and > constant definitions. > > Your example demonstrates the week point of this approach very well in my > eyes. Instead of allow easy reuse, you will have to manage much more > conflicts. Think it is better to restrict the idea. Just allow to reuse > methods trying to avoid additional conflicts which must be handled each > time. > > Another point is, think there is no benefit in duplicating constants?. Why would this create any problems? Say, you have class B that extends class A and both do define one method and one property under the same names. Will this create a problem? No. It's because there are rules that clearly describe how it works (method and property will be overriden). Similar approach may be applied to trait'ing classes. Why not? For example if you have a property defined above trait'ing, it will be overriden by the trait if it comes up with its own property with the same name (same goes for the properties defined in the ancestor class). If trait defines a property, it can be overriden by class if it introduce it below trait'ing statement. On the other hand, if someone being a developer cares of potential "conflict" (unwanted override), he/she may simply not define properties and constants in the class that's intended to be trait'ed into another class. Best Regards j