Strong vs weak encapsulation [correction]

David-Sarah Hopwood david-sarah at
Tue Dec 21 00:38:12 PST 2010

On 2010-12-21 08:27, David-Sarah Hopwood wrote:
> The private names and soft field proposals are similar in the
> visibility mechanisms they can simulate, but soft fields are slightly
> more general. In either proposal, visibility can be restricted to a
> particular lexical scope. In the soft fields proposal, because
> SoftFields are first-class values, it can also be restricted to any
> set of objects that can get access to a given SoftField.

Correction: the syntax also allows private names to be treated as
first-class values, so the proposals are equivalent in this respect.

> I don't
> claim this to be a critical benefit, but it is occasionally
> useful in object-capability programming. For example, in
> <>,
> a Purse of a given currency is supposed to be able to access a
> private field of other Purses of the same currency, but not other
> Purses of different currencies. The implementation at
> <>
> uses WeakMaps to do this, and could just as well use soft fields

or private names

> if transliterated to ECMAScript.

David-Sarah Hopwood  ⚥

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the es-discuss mailing list