Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61980 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81587 invoked from network); 3 Aug 2012 00:07:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2012 00:07:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qc0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:65333] helo=mail-qc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/73-61111-9561B105 for ; Thu, 02 Aug 2012 20:07:54 -0400 Received: by qcmt36 with SMTP id t36so74778qcm.29 for ; Thu, 02 Aug 2012 17:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=27CQMbsv4BuZrY3Tk+QzIgXjDCyI3SAkE+irGx5B4C0=; b=dXXYPBHLfdzohYEq0rl0aQlihrqzBFWfo+vsFGQMZzjB9uEAifm/Ct3zV9ajPJR7YS JBl8/xp0uM3qYoMWFmoYHYm+iL1qX8J6Snj506LXGogUjoXrSTH1btmfsqAV+8sH+aCv bSY9PMsqzdtDzfZ2iTypb9Vm1SakzdTq5q8CWU5lLSVZzrMvjEF28eUW5daAEXrsa/vC JLV9ekM7GAIo8S05ttbIFe3Wkq1jr+k2ipfMiPNGVAL7XsNhF2xQs92lDluSD2jHCflM 9Q26XpG+gcB3UFg1F7vd+8XTsXHViHZtP8eB+6iq5rq0dqp7zJJc1TkT/dF0m4iDUfvB r7JQ== MIME-Version: 1.0 Received: by 10.224.0.202 with SMTP id 10mr136054qac.5.1343952470732; Thu, 02 Aug 2012 17:07:50 -0700 (PDT) Received: by 10.229.182.4 with HTTP; Thu, 2 Aug 2012 17:07:50 -0700 (PDT) In-Reply-To: References: Date: Thu, 2 Aug 2012 20:07:50 -0400 Message-ID: To: Yahav Gindi Bar Cc: Sara Golemon , Leigh , PHP internals Content-Type: multipart/alternative; boundary=20cf30667c0d9cef1d04c65151d2 Subject: Re: [PHP-DEV] Add runkit to PHP Runtime From: ircmaxell@gmail.com (Anthony Ferrara) --20cf30667c0d9cef1d04c65151d2 Content-Type: text/plain; charset=ISO-8859-1 Yahav, On Thu, Aug 2, 2012 at 7:26 PM, Yahav Gindi Bar wrote: > I do think that some of the runkit features should not be included in PHP > core but I wish to focus on extending classes with extension methods, > constants, traits and members. > > Just like all other complicated and powerful features in PHP, one should > use them with a good reason and when he/she knows exacly what he/she is > doing - but we should provide the tools and ability to do that - that's > what I think.. > > I see the main usage for extension methods within frameworks and other big > applications that allows third-party integration such as CMS, forums > software etc. - in such kind of applications, extension methods can be very > useful, and you can take for example the many usage of this in > ASP.NET applications > that uses this concept (even if we'll take Objective-C, you can find on the > net many implementation of features for UI controls that was added via > extension method since there's no OO based reason to create a child class - > for example, many added method for setting background image to UIView type > object as an extension method). > > I don't think that this features should remain in PECL package (that's the > reason I've created this discussion) since frameworks and software that > third-party users will use should not relay on PECL packages... many users > who use frameworks and CMS use shared hosting enviorment and don't have > permissions to install PECL packages - if we want to bring this feature and > give such scripts to use this features we shall deeply integrate it to the > core of PHP - just like I've suggested above, I think that a new keyword or > syntax should be introduced for this usage. I wholeheartedly disagree towards this line of thinking. The ability to add and rename functions/methods dynamically to already defined constructs is going to do nothing but cause problems. For example, let's say that you're working with a class, and using it in one area of your application. Then you want to go re-use it in another application. All of a sudden, it stops working for non-obvious reasons. As it turns out, it was because the class was modified in some corner of the code elsewhere on the page. And the only real way to find that out is to step through it in xdebug to see where the trace goes (or dig through reflection to try to take a stab in the dark)... Now, I know you brought up other languages. I'm glad you did. PHP is not other languages. Other languages have first-class meta-classes that let you directly do things like this to. But they also don't have support for contract based programming (interfaces) or things like autoloading (both which are problematic with this approach). So unless we wanted to drop interfaces (big -1 from my book) or implement a first-class meta-class structure for all classes (huge +1, if done right), then this is only going to hurt things. Besides, there are ways to solve this problem today. You can implement decorators and bridges to solve this problem in a reusable and easy to understand way. Sure, it makes it hard to do dirty things (like insert a function in a parent of an inherited object), but you shouldn't be doing those things anyway (if you find a need for something like that, you have a *major* architectural flaw). So I'm against adding functionality that makes implementing architectural flaws easier while doing nothing for good programming practices... Anthony --20cf30667c0d9cef1d04c65151d2--