I've been stewing on this some more, and I realized something potentially
very interesting. If we use weakmaps in the manner specified by Kevin (with
Mark's help), I think we've very nearly added nominal typing to classes.
Assuming this privacy behavior was tied to classes, and assuming only
members of the class could be added to the weakmap, and assuming that *all*
members of the class belonged to the weakmap, the weakmap would quite
literally be the set of all members of that class (type). If there was an
easy way of asking the weakmap if an object belonged to the it, it would
the same as asking if the object was an instance of that class in a very
strong, nominal way. I guess I think this could be a plus, because it
allows for nominal types to be tied to classes, and yet do it in a very
javascripty feeling way.

Thoughts?

- Russ

On Fri, Jan 18, 2013 at 4:25 AM, Brendan Eich <bren...@mozilla.com> wrote:

> Domenic Denicola wrote:
>
>>
>> If we’re making up new syntax, I think this would be much nicer if
>> “private.x” were spelled “this.@x” and “private(x)” were spelled “x.@”
>>
>>
> +1 and this is not a minor point.
>
>
>  Also, I don’t see why constructors need to use the “private.x” syntax
>> whereas other methods get to use the free variable?
>>
>>
> +2 -- Same here, only moreso!
>
> This thread goes over ground well-trod in 2011:
>
> https://mail.mozilla.org/**pipermail/es-discuss/2011-**July/015787.html<https://mail.mozilla.org/pipermail/es-discuss/2011-July/015787.html>
>
> and others -- search for "private data record" 2011 es-discuss site:
> mail.mozilla.org.
>
>
>  With these in mind I give the following fork: https://gist.github.com/**
>> 4562796 <https://gist.github.com/4562796>
>>
>>
> Kevin, could you do an alterna-gist as Domenic proposes? Of course there's
> much more at stake than syntax, but it would help.
>
> /be
>
>>
>> *From:*es-discuss-bounces@**mozilla.org 
>> <es-discuss-boun...@mozilla.org>[mailto:
>> es-discuss-bounces@**mozilla.org <es-discuss-boun...@mozilla.org>] *On
>> Behalf Of *Kevin Smith
>> *Sent:* Thursday, January 17, 2013 21:40
>> *To:* Mark S. Miller
>> *Cc:* Brendan Eich; es-discuss
>> *Subject:* Re: Security Demands Simplicity (was: Private Slots)
>>
>>
>> It seems as if this approach to private class members also allows us to
>> describe private methods in a convenient way.  Private methods can be
>> attached to the _prototype_ of the private field object, thus avoiding
>> per-instance allocation.  Of course, the correct "this" value has to be
>> used in the expansion when calling the private method, but this approach
>> appears to be compatible with mixins (whereas private symbols are not).
>>
>> https://gist.github.com/**4561871 <https://gist.github.com/4561871>
>>
>> Thoughts?
>>
>> { Kevin }
>>
>>  ______________________________**_________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to