Is private really private?

Mark S. Miller erights at google.com
Tue Jan 3 12:08:37 PST 2012


On Tue, Jan 3, 2012 at 8:45 AM, Herby Vojčík <herby at mailbox.sk> wrote:

> Hello,
>
> "*Only* if that code appears appears within the text of the class
> ClassWithPrivateFoo" means "only inside class {...} block that defines
> ClassWithPrivateFoo"? So ES.next private could be seen as sugar for
> "lexical private in scope of class block"?
>

Yes, exactly. Thanks for the clear summary.



>
> Herby
>
> -----Pôvodná správa----- From: Mark S. Miller
> Sent: Tuesday, January 03, 2012 5:31 PM
> To: Herby Vojčík
> Cc: es-discuss at mozilla.org
> Subject: Re: Is private really private?
>
>
> *Only* if that code appears appears within the text of the class of which
> objectWithPrivateFoo is an instance. "foo" is what we call a "class private
> instance variable", which is essentially the same degree of encapsulation
> as Java's "private" fields -- instances of the class can see into other
> instances of the same class.
>
> If this code appears outside any class, it would be a syntax error. If it
> appears within a class other that the class of objectWithPrivateFoo, then
> private(this) returns undefined and private(this).foo thereby throws a
> TypeError.
>
> In the presence of inheritance, again the right analogy is Java's
> "private". If objectWithPrivateFoo is an instance of C which inherits from
> B which inherits from A, and if all of them contribute a private member
> named "foo" to the instance's state, and if your code appears within the
> text of B, then your expression will evaluate to the "foo" that B
> contributed to the state of objectWithPrivateFoo.
>
>
>
> On Tue, Jan 3, 2012 at 4:49 AM, Herby Vojčík <herby at mailbox.sk> wrote:
> Hello,
>
> form what I understood in the class proposal, I can write a code like this:
>
> (function () { return private(this).foo; }).apply(objectWithPrivateFoo)**;
>
> and it will work.
> Is it so? Isn't  then the notion of "per-object private" impossible having
> dynamic language with first-class function and apply/call?
>
> Herby
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
>
>
>
>
> --
>   Cheers,
>   --MarkM
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120103/41da5c00/attachment.html>


More information about the es-discuss mailing list