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
