Names strawman ready for discussion

Sam Tobin-Hochstadt samth at ccs.neu.edu
Thu Sep 9 10:49:31 PDT 2010


On Tue, Sep 7, 2010 at 11:02 PM, Mark S. Miller <erights at google.com> wrote:
> Syntax aside, these are both semantic differences with ExplicitSoftFields.

Yes, that's correct.  It's certainly not our contention that Names
provide an alternative to every use of WeakMaps.  WeakMaps are a very
useful language feature, not least because it's possible to write
library functions like ExplicitSoftFields using them.  However, Names
serve primarily a different use case - when you want the
information-hiding guarantees that lexical scope provides while still
programming in a traditional JS style.  Names allow economical
expression of common OO encapsulation techniques, while maintaing the
ES programming model.

ExplicitSoftFields intentionally stores data away from the object;
Names stores the data with the object.  The latter is often much more
convenient and easier to reason about.  I know that when I've been
able to shift programs I've written from using soft fields to using
real fields, the gains in code comprehensibility were noticeable.
-- 
sam th
samth at ccs.neu.edu


More information about the es-discuss mailing list