Loyal Opposition to Const, Private, Freeze, Non-Configurable, Non-Writable...
David Bruant
bruant.d at gmail.com
Wed Nov 2 15:45:23 PDT 2011
Le 02/11/2011 22:56, Jake Verbaten a écrit :
>
>> 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.
What is the difference between a local variable and a private object
property?
Both reduce access to the data they store. Private properties are only
accessible from the body of a given number of functions, local variables
too. What is the difference?
I don't get why we would push 'let' to ES.next and not private properties.
> 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.
You're right, I didn't analyse the code enough. Sorry, my mistake.
But my point remains. Why make a "utility function"? What is "utility"?
Why isn't it public like everything else?
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111102/4db54bf8/attachment.html>
More information about the es-discuss
mailing list