Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63572 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83331 invoked from network); 20 Oct 2012 19:58:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Oct 2012 19:58:57 -0000 Authentication-Results: pb1.pair.com header.from=tularis@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tularis@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.42 as permitted sender) X-PHP-List-Original-Sender: tularis@gmail.com X-Host-Fingerprint: 74.125.83.42 mail-ee0-f42.google.com Received: from [74.125.83.42] ([74.125.83.42:59739] helo=mail-ee0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/76-22055-18203805 for ; Sat, 20 Oct 2012 15:58:57 -0400 Received: by mail-ee0-f42.google.com with SMTP id l10so630466eei.29 for ; Sat, 20 Oct 2012 12:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=fVuWC4vbRcurEiNBs6zcKvaX8IRXwVlCnZp5yTwRxvc=; b=QN/bevZKOTfWFEWsWCPy28ylrytidv0bqXPh7JHLv+qiTfxcPRqTVq7Q/fhJYNFqlc CV3aWSeQFk0kdpPmqY0TJJh50EjsK74KTufbQU6YYyCAC8Fi93oF85QHiH2w+mpF3lZ1 2dt93zkMTyj4GpFKeQQIZncyCdO8oj4M8GeWfqoyG9nZKWTAE73hv+xCR7gIv6WjVNRd 3/K2Zq668qfqNumrRWWRRlZF4QnDNSmavgnU0weUSndT/Flj7ufLp9P+5D7MbVOEMR23 1wtMyHFM1C4u26QK7A5mxQIX+9PKH5ZQ43tyC2TEBrYalbLfhr561edOzgmqLa2PwJlD lUVw== Received: by 10.14.193.129 with SMTP id k1mr6514419een.13.1350763133654; Sat, 20 Oct 2012 12:58:53 -0700 (PDT) Received: from [127.0.0.1] ([192.87.225.65]) by mx.google.com with ESMTPS id v3sm8439786een.1.2012.10.20.12.58.51 (version=SSLv3 cipher=OTHER); Sat, 20 Oct 2012 12:58:52 -0700 (PDT) Sender: Maciek Sokolewicz Message-ID: <50830276.7030307@php.net> Date: Sat, 20 Oct 2012 21:58:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: Clint Priest CC: "internals@lists.php.net" References: <9570D903A3BECE4092E924C2985CE485612C2595@MBX214.domain.local> In-Reply-To: <9570D903A3BECE4092E924C2985CE485612C2595@MBX214.domain.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Accessors : read-only / write-only keywords From: maciek.sokolewicz@gmail.com (Maciek Sokolewicz) On 20-10-2012 19:20, Clint Priest wrote:> Hey Rasmus, please try and keep these replies in the appropriate thread... > > I am in favor of eliminating the read-only/write-only keywords and implementing no "special code" to make what was read-only/write-only language enforced. I think the alternatives with final are just fine and good enough and will let userland programming enforce it if they so desire. > > Example of user-land enforced 'read-only' code: > > class A { > public $b { > get() { ... } > private final set($x) { throw new Exception("cannot set $b"); } > } > } > > This solution introduces no magic on the engine side and lets those who need a read-only / write-only type scenario to "work." > > Does this sound like an effective solution for everyone? > Ok, time to put it in the correct thread again, with actual working threading. For the last few days I've been wondering why the hell anyone would really need a write-only keyword; and the only answer to this that I could think of was that "it would be nice" since you could catch such problems automatically, instead of actually having to write additional custom code which prevents access to the set-accessor. Apart from that, there is also the thing that using this additional keyword you can (if implemented at all) show that such a method does NOT exist in interfaces / reflection. Anyway, the 'solution' of not adding a lot of confusing keywords to say something that can be said simply using code inside the function... seems very good to me. I must admit I'm surprised noone has brought it up till yesterday. - Tul (casual internals reader)