Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50267 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30089 invoked from network); 16 Nov 2010 20:21:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2010 20:21:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@stefan-marr.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@stefan-marr.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain stefan-marr.de from 85.88.12.247 cause and error) X-PHP-List-Original-Sender: php@stefan-marr.de X-Host-Fingerprint: 85.88.12.247 toolslave.net Received: from [85.88.12.247] ([85.88.12.247:47227] helo=uhweb12247.united-hoster.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AD/76-25421-8C7E2EC4 for ; Tue, 16 Nov 2010 15:21:29 -0500 Received: from cust194-138.dsl.as47377.net ([62.166.194.138] helo=[192.168.0.12]) by uhweb12247.united-hoster.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1PIS1p-00054M-78; Tue, 16 Nov 2010 21:21:25 +0100 Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii In-Reply-To: Date: Tue, 16 Nov 2010 21:21:14 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Simas Toleikis X-Mailer: Apple Mail (2.1081) Subject: Re: [PHP-DEV] Traits and static methods From: php@stefan-marr.de (Stefan Marr) Hi Simas: On 16 Nov 2010, at 18:46, Simas Toleikis wrote: > The first thing that comes to my mind is a Singleton > implementation - this is where I found myself literally "copying" most = of > the code in the past. As far as I know there is no way to implement = this > pattern properly in PHP without duplicate code (due to lack of = multiple > inheritance/templating). >=20 > Unfortunately, the same RFC document mentions this for trait methods: >=20 > The static modifier is not supported, because it would change the = methods >> semantics and references to $this would break. >>=20 >=20 > .. and that pretty much defeats Singleton-Trait implementation. Is = there any > particular technical/design reasons why traits can't handle $this = inside > static methods just like regular static methods do (with a fatal = error)? Hm, good question. I don't recall any implementation details. Haven't = touched the code for too long. =46rom the top of my head, I don't see why it should not work. If I would have elaborated a bit more what I was thinking when I wrote = that comment... Following the motto 'it is just compiler assisted copy and paste' I = think it should be implemented. Best regards Stefan --=20 Stefan Marr Software Languages Lab Vrije Universiteit Brussel Pleinlaan 2 / B-1050 Brussels / Belgium http://soft.vub.ac.be/~smarr Phone: +32 2 629 2974 Fax: +32 2 629 3525