Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61616 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1601 invoked from network); 21 Jul 2012 11:33:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jul 2012 11:33:23 -0000 Authentication-Results: pb1.pair.com header.from=amaury.bouchard@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=amaury.bouchard@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: amaury.bouchard@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:43862] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/A1-27309-0839A005 for ; Sat, 21 Jul 2012 07:33:20 -0400 Received: by obfk16 with SMTP id k16so7452363obf.29 for ; Sat, 21 Jul 2012 04:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=UGAzj06qoWortjo+SF/wfxM9HSyAZirZeeU/RsGHJj4=; b=PdKdeRhqMnMUlCcgQTVYnK0b8gLVtsf1X1kHwq4C33Y/sZCiJk6vmGJAgTPxyL5I8q 41IzS4AALwJd+7SvQOt/v24FVSOFfUarYxu8kbAYqcccVbLvtytHgwHGO6SpclDhyHqS 2QUyte3sNBtDw+wsv9uFqTRYiTksGpFFOl6SZd+fth8EvPxIYLMOjE5meQFvXXFIJVaa 68u13uSS7zDVtJZls6OlgEHRNXn2DvOomOL/8At6vJQc+tTKjUQUn7B1MOod+q44BjKW 7srevHmehCLmMXrpApfMWHcrAABSQb/F4sQ9ZLAdd/u7A/khYuCw8kpsy3ByFEWbVRpd LPpA== Received: by 10.60.12.37 with SMTP id v5mr11633875oeb.25.1342870397365; Sat, 21 Jul 2012 04:33:17 -0700 (PDT) MIME-Version: 1.0 Sender: amaury.bouchard@gmail.com Received: by 10.182.149.69 with HTTP; Sat, 21 Jul 2012 04:32:57 -0700 (PDT) In-Reply-To: <2F.31.18983.220E9005@pb1.pair.com> References: <2F.31.18983.220E9005@pb1.pair.com> Date: Sat, 21 Jul 2012 13:32:57 +0200 X-Google-Sender-Auth: oCiPeBYB8863tvc_32Lddu7L6_0 Message-ID: To: "Matthew Weier O'Phinney" Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=e89a8f83a73503ac9304c5556107 Subject: Re: [PHP-DEV] RFC Proposal - Attributes read/write visibility From: amaury@amaury.net (Amaury Bouchard) --e89a8f83a73503ac9304c5556107 Content-Type: text/plain; charset=ISO-8859-1 Thank you Matthew. I had the feeling that my proposal was dismissed a bit quickly by some people, while I think it's how object-oriented languages should handle attributes' visibility. I still think it's very simple and elegant, and more coherent in some situations (those situations targeted by the proposal). I would like everybody give 5 minutes to this idea [1] :-) [1] : http://37signals.com/svn/posts/3124-give-it-five-minutes 2012/7/21 Matthew Weier O'Phinney > On 2012-07-16, Amaury Bouchard wrote: > > --f46d0446312cc5e06104c4f42161 > > Content-Type: text/plain; charset=ISO-8859-1 > > > > My point is not to add two ways to do the same thing. > > What I'm humbly suggesting to do is to keep the core idea of the > > existing RFC (make things easier when you have to write > > getters/setters), and think about another syntax for managing reading > > and writing visibilities. > > My first impression, being familiar with the other proposal, was that > this looked like duplication. However, on looking at the examples, I > have to admit that I really like the approach -- in many cases, it > obviates the need for a getter entirely. It would help dry up a lot of > code, reduce the number of method calls overall, and still enforce > internal logic when setting the value in the first place. > > I like it; it feels elegant. > > > > 2012/7/16 Andrew Faulds > > > >> How much syntactic sugar do we really need? Why add two ways to do > >> something? > >> > >> On 16 July 2012 16:24, Amaury Bouchard wrote: > >> > 2012/7/16 Nikita Popov > >> > > >> >> I'm not sure I really understand what this adds over the existing > >> >> getter/setter proposal. read-only and write-only should cover the > most > >> >> common cases. If you do need visibility control, it is possible too: > >> >> > >> >> public $property { > >> >> get { ... } > >> >> protected set { ... } > >> >> } > >> >> > >> >> So what does this proposal add to it? > >> >> > >> >> > >> > Yes, but only if you have to write an accessor. > >> > If you just want an attribute that is: > >> > - readable from everywhere > >> > - writable from the current class only > >> > > >> > With my syntax: > >> > public:private $a; (read it aloud "public reading, private > writing") > >> > > >> > With the existing RFC: > >> > public $a { > >> > private set { $this->a = $value; } > >> > } > >> > > >> > Which one is better? Why should I write code for that? > >> > > >> > If you read the existing RFC, you'll see that all examples involve a > >> > specific case: when you have a "fake" attribute, which manipulates > date > >> > stored in other attributes. The given example is an $Hours attributes, > >> > which is calculated from the private $Seconds attribute. > >> > Again, it could be very useful. But it doesn't work all the time. > >> > >> > >> > >> -- > >> Andrew Faulds (AJF) > >> http://ajf.me/ > >> > > > > --f46d0446312cc5e06104c4f42161-- > > > -- > Matthew Weier O'Phinney > Project Lead | matthew@zend.com > Zend Framework | http://framework.zend.com/ > PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --e89a8f83a73503ac9304c5556107--