Re: Constants and Access Modifiers
| From: | Alice Wonder | Date: | Sun, 12 Nov 2017 09:50:23 +0000 |
| Subject: | Re: Constants and Access Modifiers | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101128@lists.php.net to get a copy of this message | ||
On 11/12/2017 01:38 AM, Tony Marston wrote:
wrote in message news:549c4634-ac38-41d3-ab43-f816a9f2b1e5@fleshgrinder.com...Plus plus on this. A constant does not change. If it changes it is a variable. I do not know anything about Dart but if they are changing the meaning of well-defined terms like constant, I worry that there will be programs with security holes simply because some developers will not understand what they mean by the terms they define.On 11/12/2017 12:44 AM, Stanislav Malyshev wrote:Just because some languages use a corrupt definition of "constant" is no reason for PHP to do the same. A constant has a value which, once defined, cannot be changed. It is not logical to define a constant name in one place and its value in another.Hi!I did not mean to say that we have to have everything exactly as Dart has it. I just wanted to show, that the meaning of const as we have is not universally the same. Abstract constants would also only be truly useful if we could define the type as well on them. Which is currently not possible. Also, I am not saying that the requested feature MUST be done with const. However, it should behave like one, which is impossible with methods.Yes, Dart has a different understanding of const, which is exactly why I posted it for you guys. In the hope that it helps to get more different views on the topic. Currently you are too concentrated on how it is implemented in PHP at this time, and argue that it is impossible to diverge from that path. Which is simply not true, we only have to ensure backwards compatibility.I am not arguing it's impossible, I am arguing it is not a good idea. We have the concept of constants in this language, and bolting on it a completely different concept from different language, which by coincidence was named with the same term, would only be a source of confusion. If we wanted immutable objects in language - which I am not convinced at all we do, but assuming for a minute we did - there's no reason to conflate them with constants as we have them now. These are different things.