Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56840 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78334 invoked from network); 7 Dec 2011 18:58:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2011 18:58:07 -0000 Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; 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: will.fitch@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:54136] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/00-12666-E37BFDE4 for ; Wed, 07 Dec 2011 13:58:06 -0500 Received: by qcsc21 with SMTP id c21so560309qcs.29 for ; Wed, 07 Dec 2011 10:58:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=rFmxDZF58bZ59yZTwTW7V2lK3n1J7mR5wftl7u7qG34=; b=aFPLBgovR8FXa44avOm4TNZwUY43XeOl3CpeN6zB7QMoEaLkR07xx0/Oxi3xZSDySz qeLe+Jw0gCazn2nBax1/qv8pVAZl3IdFxx4pTcvRmVv0NGAZXORfSF//lmJTuik/Eb7n wx0MDNZcOgFBcvYFBk5E7H74YqEDX9Hv8jcgE= Received: by 10.229.69.212 with SMTP id a20mr21184qcj.125.1323284283605; Wed, 07 Dec 2011 10:58:03 -0800 (PST) Received: from [192.168.1.68] ([68.64.144.221]) by mx.google.com with ESMTPS id gg6sm4927060qab.3.2011.12.07.10.58.00 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Dec 2011 10:58:02 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: Date: Wed, 7 Dec 2011 13:58:01 -0500 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <9570D903A3BECE4092E924C2985CE4853994C39F@MBX202.domain.local> <34B6F836-CC50-4470-AD5F-C6F8C471FC65@gmail.com> To: Rasmus Schultz X-Mailer: Apple Mail (2.1251.1) Subject: Re: [PHP-DEV] Patch: getters/setters syntax Implementation From: will.fitch@gmail.com (Will Fitch) I'm saying that when you define an accessor, the body of the get/set = functionality is contained within get {} and set {}, just like C#. I'm = referencing your suggestion to automatic backing fields. There's no = need for the backup. Reflection for accessors should be treated the same as the rest. Since = there is a definition for each get and set, = Reflection{Property/Accessor} should treat invocations of those = separately, so I agree with that, but Reflection hasn't failed us so = far. :) =20 On Dec 7, 2011, at 1:33 PM, Rasmus Schultz wrote: > I have no opinion about how it gets implemented under the hood - I = thought > we were just discussing the syntax. I most likely don't know enough = about > the innards of PHP it carry on that discussion. >=20 > But by userspace definitions, are you referring to the fact that = getters > and setters would compile down to actual methods? I have no strong = feelings > about that one way or the other - as long as the reflection API = reports > what was defined in the source code, rather than reflecting the = underlying > accessor-methods as actual methods. (something that doesn't seem to be = true > for traits...) >=20 > I don't know if that's meaningful or relevant to you, but I think = that's > all I can contribute to that discussion... >=20 > On Wed, Dec 7, 2011 at 1:11 PM, Will Fitch = wrote: >=20 >> The difference being *where* the functionality gets mapped. It's not >> about making something "look like something else", it's about = requiring >> more userspace definitions. Functionality within get {} and set {} = can >> (and should IMO) be implemented outside of userspace code. Whether = that >> means another union within op_array or a completely new structure = mapped to >> a property zval and bitmap added to the zend_uchar type identifying = it as >> an accessor.... I'm saying be creative - don't just implement = something >> halfway for the sake of getting it done. >>=20 >>=20 >> On Dec 7, 2011, at 12:50 PM, Rasmus Schultz wrote: >>=20 >>>> if we're attempting to get around __set/get, let's not replace them = with >>> more method implementations >>>=20 >>> I don't understand this argument. Accessors are methods - making = them >> look >>> like something else won't change that fact. >>>=20 >>> In C#, type-hinted properties with automatic getters/setters = actually >>> compile down to two method implementations, while implemented >>> getters/settings do the same, substituting "value" for whatever is >> required >>> to access the auto-implemented backing field. >>>=20 >>>=20 >>> On Tue, Dec 6, 2011 at 9:26 AM, Will Fitch = wrote: >>>=20 >>>>=20 >>>> On Dec 6, 2011, at 8:58 AM, Rasmus Schultz wrote: >>>>=20 >>>>> I agree with all of those points - the extra indentation looks = messy, >> and >>>>> yes, type hints are important. It does fit better with PHP in = general. >>>>>=20 >>>>> It would be nice to also have support for automatic backing fields = in >>>>> addition though - so something simple like this: >>>>>=20 >>>>> class BlogPost >>>>> { >>>>> private $_author; >>>>>=20 >>>>> public get author() >>>>> { >>>>> return $this->_author; >>>>> } >>>>>=20 >>>>> public set author(Person $value) >>>>> { >>>>> $this->_author =3D $value; >>>>> } >>>>> } >>>>=20 >>>> I don't like this approach. All efforts (which I'm currently part = of) >> to >>>> implement type hinting return values will be compromised. If you = want >> to >>>> implement accessors, keep them within a syntax that makes sense. >>>> Personally, I support the C# style as much as possible. Methods = are >>>> already overused for purposes they shouldn't be, so if we're = attempting >> to >>>> get around __set/get, let's not replace them with more method >>>> implementations. >>>>=20 >>>>=20 >>=20 >>=20