Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63501 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27853 invoked from network); 17 Oct 2012 11:46:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2012 11:46:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:38636] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E7/A9-64689-FAA9E705 for ; Wed, 17 Oct 2012 07:46:55 -0400 Received: by mail-lb0-f170.google.com with SMTP id gm13so5132808lbb.29 for ; Wed, 17 Oct 2012 04:46:52 -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=xpi5bQWDs6X5jaWw0ehyBUSqBpOp4//fptpQ8q1duPA=; b=gYYUH+JnIO/RXTAGcYruPmc2N5ovWEsmJe2Es/9vSZcRGSfEl8VU/3gSpRG+8VdJP0 Mfa3Rh1RREZZolyXVf9d6DQUuvxUsqnwbSxuyYL9Wuaxat0WDWMJqVfWAgEqUBgUB7Sl Q0wcUXDpfOXepOJXcqd9GcTx6w3nJsJ1RQA8q1tRJy5oAt+heirSumYPmgkyOtLZ22OZ XDq17tqxQe4gPSH1V+bdVj4Rc8JbrYr4NFZkAmYURrQ4bkchBObNEvqi2WmfNtMpUVD7 5335hixvQv6ufiRH2VSXpEPZS1clTuSE2MLHcmfYrB03WyrG5IG6MaWwAQT79jx19zCF k/aw== MIME-Version: 1.0 Received: by 10.112.102.42 with SMTP id fl10mr1836064lbb.5.1350474412543; Wed, 17 Oct 2012 04:46:52 -0700 (PDT) Received: by 10.112.83.100 with HTTP; Wed, 17 Oct 2012 04:46:50 -0700 (PDT) In-Reply-To: <507E9550.8070602@sugarcrm.com> References: <9570D903A3BECE4092E924C2985CE485612B53E4@MBX202.domain.local> <507D24E0.9070203@sugarcrm.com> <9570D903A3BECE4092E924C2985CE485612B6DC9@MBX202.domain.local> <507D5199.3090203@sugarcrm.com> <9570D903A3BECE4092E924C2985CE485612B6F1D@MBX202.domain.local> <507D6675.3080206@sugarcrm.com> <9570D903A3BECE4092E924C2985CE485612B7805@MBX202.domain.local> <507E846A.2030805@sugarcrm.com> <507E9550.8070602@sugarcrm.com> Date: Wed, 17 Oct 2012 13:46:50 +0200 Message-ID: To: Stas Malyshev Cc: Clint Priest , PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [PHP-DEV [RFC] Property Accessors v1.2 From: nikita.ppv@gmail.com (Nikita Popov) On Wed, Oct 17, 2012 at 1:24 PM, Stas Malyshev wrote: > Hi! > >> You have already written seven mails all saying how much complexity >> this would introduce. Could you maybe elaborate a bit on that? How >> would it make anything more complex? I mean, the only really > > Any code that deals with methods would now have to consider - is this > regular method or special "uncallable" method? Can I call it? Can I list > it in the list of class methods? I think we are still not on the same page here. The exact point is to *not* put accessors into the method table. As such the accessors aren't special, half-hidden methods (like they are with the current implementation), rather they are *just* accessors and nothing else. As this seems hard to understand, consider the following code: class Foo { public $foo = [ 'get' => function() { return $something; }, 'set' => function($value) { $something = $value; }, ]; } Rather than: class Foo { public $foo = [ 'get' => [$this, '__getFoo'], 'set' => [$this, '__setFoo'], ]; public function __getFoo() { return $something; } public function __setFoo($value) { $something = $value; } } The above obviously isn't working PHP code, but I hope that it makes the difference a bit clearer. It's all about making accessors accessors, rather than making them references to automagically generated methods representing the accessors. > And all inheritance functions will have to consider them > separately from all other methods, etc. Accessors need to be considered separately anyway, otherwise you end up with the problems that we currently have, where you can't override a property with an accessor in an extending class or the other way around. Having those pseudo-methods makes this even more complicated, because now you could have these inherited pseudo-methods still around in your class, even though you don't have the accessor anymore. And stuff like that. > And interface implementation has to be changed to account for existence of not-quite-methods. Again, this has to be done anyway and is already done. Accessors need different implementation checks than methods. See the interfaces thread. > Even conceptually, you need to be aware that there are methods of class > and then there are non-methods which look exactly like methods in almost > every aspect but aren't. I think it's the other way around. As I already said above, the accessors won't be methods. So you don't have to consider anything. *Right now* you need to consider on the other hand. Right now there methods and then there are autogenerated accessor methods, and they will show up everywhere you are analyzing classes with reflection (or maybe during debugging or whatever). Now you either have to explicitly consider them in your code, for they are not actual methods, or the PHP implementation has to try to hide them. And then you end up with the issues you mentioned above. Not having them as methods in the first place does not cause any of those issues, at least not as far as I can see. Etc