Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61317 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22739 invoked from network); 16 Jul 2012 15:32:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 15:32:07 -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:64913] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/E2-09344-6F334005 for ; Mon, 16 Jul 2012 11:32:07 -0400 Received: by obfk16 with SMTP id k16so11389595obf.29 for ; Mon, 16 Jul 2012 08:32:04 -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=s0oKvbbaZ3w5IFvd4X5TDXC4G609r/WuH8M4qKZ/IDM=; b=JEF37aF2CllcbKqyWtG/OKsZeRCRSGBAFeyZVqc+xq8iPoepcipe+3EAYyRN1WtVcf FZUQgO8IqZatDIkxKZAIy3ZY4NsSu4R+lPktbQXpCeeZUkJG2+P2ug9GbuXV9Pg5tnt1 /Bkfk0hIc4dXKw4zTmAqR9jOrNB6pRixH/2W3ujn4IWX3lbS1AlALQBW/lOHDPMzPAYk w+VdegX3846fQSWNrjzuW5Jz61y/vb5CjqpEJpNZoxEzVq1IYtwfwbzGIZmACRTuqlOf X9SPIpDxsUZI1dEA47Yzz+5ySgMV1ciPZ9cVSsrPO/0aeSHCQqPj3SEg93SYYOxb4A4R ICCg== Received: by 10.182.231.6 with SMTP id tc6mr16237545obc.63.1342452724522; Mon, 16 Jul 2012 08:32:04 -0700 (PDT) MIME-Version: 1.0 Sender: amaury.bouchard@gmail.com Received: by 10.182.60.131 with HTTP; Mon, 16 Jul 2012 08:31:43 -0700 (PDT) In-Reply-To: References: Date: Mon, 16 Jul 2012 17:31:43 +0200 X-Google-Sender-Auth: fDzeUlnH2BPkxGvF_vO5brTBKJw Message-ID: To: Andrew Faulds Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d0446312cc5e06104c4f42161 Subject: Re: [PHP-DEV] RFC Proposal - Attributes read/write visibility From: amaury@amaury.net (Amaury Bouchard) --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. 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--