Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41862 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18935 invoked from network); 12 Nov 2008 03:17:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Nov 2008 03:17:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:53175] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/E7-07308-2DA4A194 for ; Tue, 11 Nov 2008 22:17:38 -0500 Received: from [83.228.56.37] (port=3039 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1L06EZ-0003fv-Vz for internals@lists.php.net; Tue, 11 Nov 2008 21:17:36 -0600 Message-ID: To: References: <47C21C19-D460-4945-AB88-2BEA2CD1D544@mac.com> Date: Wed, 12 Nov 2008 05:17:27 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] Request for Comments: Horizontal Reuse for PHP From: sv_forums@fmethod.com ("Stan Vassilev | FM") > class Helloworld > { > public function sayHello() { print "HELLO"; } > } > > category HelloworldExtras on Helloworld > { > public function sayWorld() { print "World"; } > } > > $h = new Helloworld; > $h->sayWorld(); // print "WORLD" > > This is extremely beneficial for lightweight "extension" of classes > without subclassing. This feature is identical to the C# .NET "Extension" methods. The best use of it is for selectively extending the primitive type classes on the fly with methods you need (string, int, array, etc.). The irony in this is, in PHP the primitive types are not OOP capable, so with this in mind I wonder how much this functionality would serve to make the life of people easier, and how much of it will be just the rope they need to hang themselves. The concept of categories and extensions is not as popular to the average developer as say classes and interfaces. Also we can't overload "use" for this as "use" specifically only imports symbol names, not actual code, into the environment. It doesn't have the knowledge of whether something is a namespace, or a class, or a category, so to know how to trigger autoload. Regards, Stan Vassilev