Bert, I'm with you on setenv/getenv being better. Maybe we can add those also, and those who value correctness will use them.
In the meantime, https://github.com/joyent/node/commit/e3074689f501eea413c29b99defac29659a2b615 fixes 90% of the weirdness. Having process.env behave like an object is indeed too damn convenient, but if we're going to do that, we should accept that it's worth giving up a slight amount of correctness in exchange for convenience. On Sun, Jun 24, 2012 at 3:26 PM, Bert Belder <[email protected]> wrote: > > > On Sunday, June 24, 2012 3:17:23 AM UTC+2, Mikeal Rogers wrote: >> >> You and Bert are technically correct but what you're correct about doesn't >> matter. >> >> Should node cause an exception on accessing this prototype which many >> people expect to be there? >> >> The answer is obviously "no" only because it's much easier to make it not >> a problem that anyone ever sees than it is to explain this to everyone who >> gets this error. >> >> If you reply with another email explaining to me how JavaScript works I'm >> seriously going to flip out. >> >> -Mikeal >> > > Let me elaborate on my reservations a little more: > > * Calling .hasOwnProperty() (or any other prototype method) on an object > that's used as a hash table and where the keys are defined outside of the > program's control is an anti pattern. People shouldn't do it. The question > is really whether node wants to get in the way of the user when he tries to > do it anyway. That's debatable - I could live with fixing the prototype. But > really, if I were to redo node, I would make all of these guys - > process.env, http headers, querystring args - prototype-less object. > > * process.env does not in any way behave like a normal object. For example > all values are coerced to string, and setting a value to "" (empty string) > might actually delete the key. Also, on Windows, keys are case insensitive; > changing that is going to break much more than it fixes. There's probably > more weirdness that I am not even aware of, which is all caused by the fact > that the environment *is* not a JS object. The "proper" way to do it would > probably be to remove `process.env` and expose the functions > `process.setenv()` and `process.getenv()`, but the way it works now is too > damn convenient to remove. People should just accept the fact that > process.env behaves a little different sometimes, and if you really need JS > object semantics, make a copy of it. > > - Bert > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
