Loyal Opposition to Const, Private, Freeze, Non-Configurable, Non-Writable...

Kam Kasravi kamkasravi at yahoo.com
Wed Nov 2 15:40:31 PDT 2011

Declaring vars in a function, private vars in a class or not using export in a module often have similar objectives and ultimately is the decision of the author. For serializable data structures that are reified in various places, private is overkill and would complicate JSON.{stringify,parse}. Perhaps an author wants to keep a definition 'open' and sees no reason for private. The language should enable but not require a variety of use cases which I think is the main point here.

On Nov 2, 2011, at 2:56 PM, Jake Verbaten <raynos2 at gmail.com> wrote:

>> I don't think I've ever heard an active JavaScript developer, who has been programming in JavaScript longer than 6 months, ask for private class or instance variables.
> Your own code:
> https://github.com/mikeal/npmjs.org/commit/c0d9cc77e79504b9a7c23b4fac735dde97444054#L3R10
> Line 35, you define the function stopBuffering (keeping only relevant parts):
> ----
> function File (options) {
>   var stopBuffering = function () {
>     // ...
>   }
> }
> ----
> Why didn't you do this.stopBuffering = function(){}?
> Maybe you used the keyword "var", but you effectively created a private method of your "File" class. With a class syntax, you would have used the "private" keyword to achieve the same thing.
> Maybe you don't call it this way, but you use (and de facto ask for) privacy.
> I think making such broad statements as "every local variable is actually a 'private' variable" is just plain silly.
> To me that looks like a utility method for code organisation points.
> "private" means its a private method/data that's used in other methods of an object. That particular function is not used in any method.
> And no, with class syntax it would not be private, it would still be a utility function inside the constructor.
> I personally second that we don't need private or instance variables.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111102/1d029682/attachment.html>

More information about the es-discuss mailing list