Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51243 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38115 invoked from network); 8 Jan 2011 11:40:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2011 11:40:21 -0000 Authentication-Results: pb1.pair.com header.from=mail_ben_schmidt@yahoo.com.au; sender-id=unknown; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=mail_ben_schmidt@yahoo.com.au; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain yahoo.com.au from 98.139.91.100 cause and error) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: mail_ben_schmidt@yahoo.com.au X-Host-Fingerprint: 98.139.91.100 nm30.bullet.mail.sp2.yahoo.com Received: from [98.139.91.100] ([98.139.91.100:41636] helo=nm30.bullet.mail.sp2.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/50-36205-32D482D4 for ; Sat, 08 Jan 2011 06:40:20 -0500 Received: from [98.139.91.63] by nm30.bullet.mail.sp2.yahoo.com with NNFMP; 08 Jan 2011 11:40:17 -0000 Received: from [98.139.91.56] by tm3.bullet.mail.sp2.yahoo.com with NNFMP; 08 Jan 2011 11:40:17 -0000 Received: from [127.0.0.1] by omp1056.mail.sp2.yahoo.com with NNFMP; 08 Jan 2011 11:40:17 -0000 X-Yahoo-Newman-Id: 502864.47249.bm@omp1056.mail.sp2.yahoo.com Received: (qmail 74679 invoked from network); 8 Jan 2011 11:40:16 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=VH35PDIGJragTyzggrarCDMa171K4Yft0b1OU2GQ+tPcbqsMQom6YuDPy0du1BC5RTCykPr10Zk01t/Ik3jFlhV815BDjINgU6+FHpJvSkCyL9Mux29hIDwUhV220sC2/6oHDVMkidI8+c6XQylX1+DdaFL0WzupimAL2CWoILI= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.au; s=s1024; t=1294486816; bh=LKL8pZTBKQlA/Jjj4NJgja3G/gGsmG4mhcS8s0HKcRw=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=ykvu+tSELKnC+c1Eu5iGbUTapcjNoslss7lTom628YU99Ae/rPPh9isqWdIpNACwH7ZhS7aioJIliac7KHNlFxmo3OngxUeU0Zv3uPY176DclFThELQGkTJGMUEuaICpLGzKMCPxUYvaVOeQS/5YwOOa210ZKkeNbpi7FwZXK4A= Received: from thought.local (mail_ben_schmidt@124.149.85.149 with plain) by smtp131.mail.mud.yahoo.com with SMTP; 08 Jan 2011 03:40:16 -0800 PST X-Yahoo-SMTP: enFMnPSswBAexaHyzgobwuUTrYOhZdJ0KRA2SjA- X-YMail-OSG: .ruBCFQVM1kdniWpGzFUjoR7VeY4HyiJm_P0qCDBkm_.MHE KAttSLAsr_Ec.Ph5.kQSj5wrY4B3k.3f1kyNQDUEW82NRC2hlYJeXsONmXro Q3yFvKvdzSPOyklTh1zIydiwpq0Rzrs0ZBsr2kBx94V5MxTD9FRYu5hP1IEO UIqoUmTXGFvkRGtfoEvattDzcwkTMmbD7uy7tm1SFJxJBVvL2kQDJ2rQahoi M2Qmk.he8st9E4ivQ1gzorZHX9s3dtXPsBTTc6A5Sg4yTT3xBNzZZcW7gQNy kYrSLglmRqC4B5aYDn.NWcFc9jveI9Ubux1ugG4mRnuT1CQGsZKXKyJ96bUv U2T0R5P.7kcm1Jh_e2McDCZQ4UQ-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <4D284D1D.6080101@yahoo.com.au> Date: Sat, 08 Jan 2011 22:40:13 +1100 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 ThunderBrowse/3.3.4 MIME-Version: 1.0 To: Stefan Marr CC: internals@lists.php.net References: <4D206CA4.6060004@yahoo.com.au> <767E5516-E475-46E8-AE5C-9406D90881D7@stefan-marr.de> In-Reply-To: <767E5516-E475-46E8-AE5C-9406D90881D7@stefan-marr.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Extensions to traits From: mail_ben_schmidt@yahoo.com.au (Ben Schmidt) Hi, Stefan, Thanks for considering my ideas so carefully and for your detailed replies. > The reason to go with insteadof is that the assignment syntax hides > changes that might cause problems. > > Thus, when you change any of the traits participating in a composition > in a way that a conflict would be introduced, the assignment syntax is > hiding this. With the insteadof syntax you are actually forced to > reevaluate whether your code still makes sense and include the > offending change explicitly. OK. That makes sense. I'll rework any surviving parts of my proposal to be based on the insteadof syntax. > This does not only have the mentioned benefit of making problematic > changes in the traits hierarchy explicit, but the second reason to go > with this design was the wish to have a 'exclude' operator without > actually having a full-exclude operator. Thus, there is no way that > you can leave out arbitrary methods from a trait. This seems wrong to me. Doesn't it go against the stated principle that the class author should have full control of traits? How is it full control if you can't exclude a method? What is the reasoning behind this wish not to have a full exclude operator? > Hm, don't understand you here either. I needed to look up what > impoverished actually means, you are not insulting me here, right? > Just kidding ;) Sorry. I forget that a lot of you people aren't native English speakers and sometimes funny words like that slip in! I think all you people who communicate so fluently in additional languages are amazing. >> No error or warning will be >> generated, but the class will not work as intended; probably it will >> infinitely recurse; a nasty problem to track down. >> Furthermore, even if the incorrect method call didn't occur, there would >> be data-sharing problems, as both the ErrorReporting trait and the >> class' print() function make use of the $output data member, >> unintentially sharing data. > > Well, short answer: it is compiler-assisted copy-and-past, why isn't > that trait just providing the glue that gets your class the necessary > functionality to use a proper ErrorReporting class? > > Sorry, I know not a really helpful answer, but I hope that examples > shows how I see traits. > > They are for reusing code in situations where the other concepts just > break down. Not meant to replace those. I agree. I did say it was a poor example. I think the kinds of behavioural problems it demonstrates, though, could be found in situations where traits *are* truly appropriate. No need to argue over examples, though. Plenty of other things to argue about. :-) >> Warnings >> - - - - >> >> To avoid silent unintended shadowing, I suggest issuing a warning when a >> conflict between trait and class methods occurs. So this would trigger >> a warning: >> >> trait SaySomething { >> public function sayIt() { >> echo "Something\n"; >> } >> } >> class Sayer { >> use SaySomething; >> public function sayIt() { >> echo "Hello world!\n"; >> } >> } > > Ok, well, we could see the actual class body as another trait, and > require it to follow the same composition rules, and that way make > require the programmer to use insteadof in such a case. > > In return that would mean, that traits are not part of the inheritance > chain at all anymore. > > Thus, first is the inheritance chain used to build up the > implementation of a class, and afterwards all the traits are composed, > while the original class is seen as another trait. > > That idea has certainly something to it. Yes, I think that would be good. Having read your other emails, as well as having allowed my proposal itself to clarify in my mind, I'm beginning to think it might be clearest and cleverest to avoid inheritance altogether with traits. Of course, this is in contrast to my original proposal, which was to increase traits' participation in inheritance. In this case, parent:: will always do what you expect then, and there's no need for prev::. Now to the other emails! Ben.