Why does PHP not have the moral equivalent to the C++ const? I think that this is lacking in the PHP language. Is there a way to simulate the same properties as a const object or parameter?
Why does PHP not have the moral equivalent to the C++ const ? I
Share
C# doesn’t do the
constthing either, and it is a very general-purpose language.I’m a big
constfan, but understand why scripts in scripting languages tend to not use them: Scripting languages are great for “running naked through the woods” because it is “fun”, and very quick to add new functionality, because you are not enforcing serious type-correctness, includingconst.Perl and Python and Ruby use scalars for a reason, and pass/return arrays for a reason, because it is very easy to initially “grow” the system. Adding type correctness, including use of
const, can really slow down development iteration. Those languages were never intended to create “machined type-safe interfaces”, andconstis the first thing you would do after you first got type-safety.