Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78288 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51843 invoked from network); 24 Oct 2014 05:10:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2014 05:10:04 -0000 Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.46 as permitted sender) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.213.46 mail-yh0-f46.google.com Received: from [209.85.213.46] ([209.85.213.46:38252] helo=mail-yh0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/E3-24679-92FD9445 for ; Fri, 24 Oct 2014 01:10:01 -0400 Received: by mail-yh0-f46.google.com with SMTP id f10so344287yha.19 for ; Thu, 23 Oct 2014 22:09:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=ETXePyVCp6Pv31pUNHHy7xwht87i4ECtNpjR7KPOtV4=; b=Wk2xe6+AUoUTu8yZLpxUOqHMx6383g2icrtNwkYB61wb4EPQsLtFTJIrSrDJ3GaNVL 1aWRLdqacQqo1ewIrcFyx+Hv//N+yoa748bqgAWorgV6QAO9FpS56aV/Xiy/jEeGhN66 RdAeYWgO66UVA+LA3YrLFgafsLvgwWv+AlrA6xDXieyJI4v4EZzSUkQuTDGtYYVyoHMI WpUI57Ve+/g/3YM0U1Kyuk3qPzt/Mu5QHufkmalSFVWDatBFOh4j0SDA+4+CpF1LneCO waiicKeAky5Wgk+l9HLxRoAiTit/ke+ebZd/ibuqutSa7FzQpxMaYMtMdLO8hlJhZacD VB8Q== X-Gm-Message-State: ALoCoQkLnztTNI/OcPpGNWsJC09OkIkLgB48J4JbWt4ntNTAT7dkJOUODo1eT5PJJirI80xeM5BbkDQP8lIU0dz7BtppJk3Am4Souc/i33r8C8ZfBc7HkppPaR5JgvG050lU0/51i0ik2C/W91dq9z8mHJF+G+a4VQ== X-Received: by 10.170.217.131 with SMTP id j125mr2673491ykf.128.1414127398668; Thu, 23 Oct 2014 22:09:58 -0700 (PDT) Received: from mail-yh0-f42.google.com (mail-yh0-f42.google.com. [209.85.213.42]) by mx.google.com with ESMTPSA id f37sm1697074yhq.38.2014.10.23.22.09.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 22:09:57 -0700 (PDT) Received: by mail-yh0-f42.google.com with SMTP id t59so2692549yho.15 for ; Thu, 23 Oct 2014 22:09:57 -0700 (PDT) X-Received: by 10.170.194.78 with SMTP id l75mr2700391yke.27.1414127397767; Thu, 23 Oct 2014 22:09:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.159.141 with HTTP; Thu, 23 Oct 2014 22:09:37 -0700 (PDT) In-Reply-To: References: <6E04B9BE-854E-4112-8C74-7D90BD8BFE95@ajf.me> Date: Fri, 24 Oct 2014 13:09:37 +0800 Message-ID: To: Kalle Sommer Nielsen Cc: Andrea Faulds , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Readonly Properties From: laruence@php.net (Xinchen Hui) On Fri, Oct 24, 2014 at 12:11 PM, Kalle Sommer Nielsen wrote: > Hi > > 2014-10-24 5:02 GMT+02:00 Xinchen Hui : >> Hey: >> >> -1 on this. >> >> Actually, your example for explaining usage.. >> >> I don't see why it is must, add a getSize() will also meet the >> needs, and more beatiful, as you can change $size to another name if >> you like later. > > I disagree on your disagreement, while it is not a must, it does not > make much sense that we are gonna call what essential is a function to > return a value that is not changed in anyway during that call. It does > not really perform a function, other than returning a value in 99% of > all cases, and therefore it makes perfect sense to allow readonly > properties in my mind. > > It does not really make the code beautiful to prefix it with 'get' and > suffix it with '()' when you want such a value, it makes it > consistent, yes, but else it is just bloat to my eyes. so you prefer to expose the name of the property anywhere? let's say you expose a readonly int value name iSize.. but later, the value also need to be a double, then you also prefer add another dval? (since you can not simple change ival name, since it was exposed) > > Internally it should also be a slightly be faster to not having to > call a method everytime as well, a program that does, lets say 50-100 > calls to 'getX()' that can skip INIT_METHOD_CALL + DO_FCALL_BY_NAME > and instead just a FETCH_OBJ_R which is what should be after the > fcall, micro optimization I know (been a while since I went into these > parts so I might be a bit off though). I knew this of course, but this is actually not related to this specific "readonly" RFC but if you are strict to this., then I'd like to say, this will slowdown all FETCH_OBJ_R a bit, since this will need introduce a condition to check whether a property is readonly.. only faster a narrow case... thanks > > I'm a huge +1 on this, good job Andrea! > > > -- > regards, > > Kalle Sommer Nielsen > kalle@php.net -- Xinchen Hui @Laruence http://www.laruence.com/