3 ms·
When looking at scripting languages, there's a couple problems. What does "no encoding" mean, or "constant by convention"? Can I write gibberish UTF32 in PHP a
by cfv 10y ago
When looking at scripting languages, there's a couple problems.
What does "no encoding" mean, or "constant by convention"? Can I write gibberish UTF32 in PHP and it won't care? Can I modify one of this "by convention" constants without a parsing error?
- rajangdavis 10y agoCould be wrong, but constants are all UPPERCASE by convention in a few different languages, I think that's what that means. I don't think this would break anything, I think it's supposed to make the code easier to read/nicer for handing off code to another developer. I don't use Python, but I have seen it in PHP, Ruby, and Javascript and they don't break there. PHP handles encoding in a very naughty way. I don't know the origins behind this, I only know that it will produce text in the wrong format at times. I have had issues where I would try to get some JSON with Japanese text and it will produce some janky unicode that doesn't work. There are work arounds for specifying encoding, but it's contingent upon what version of PHP you are using (I am stuck on 5.3.2 for a legacy, closed sourced app with a custom PHP binary).
- actsasbuffoon 10y ago> Can I modify one of this "by convention" constants without a parsing error? Depends on the language. Python does not enforce constants, so you can modify them freely. JavaScript as of the ES5 spec did not enforce constants, but ES6 does. Ruby mostly enforces constants, but there are certain bits of metaprogramming that will allow you to overwrite a constant if you are determined enough.