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 #.id syntax also allows private names to be treated as
first-class values, so the proposals are equivalent in this respect.
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 #.id 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
> <http://www.erights.org/elib/capability/ode/ode-capabilities.html#simple-money>,
> 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
> <http://www.eros-os.org/pipermail/cap-talk/2007-June/007885.html>
> uses WeakMaps to do this, and could just as well use soft fields
or private names
> if transliterated to ECMAScript.
--
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20101221/dcd6332a/attachment.bin>
On 2010-12-21 08:27, David-Sarah Hopwood wrote:
Correction: the #.id syntax also allows private names to be treated as first-class values, so the proposals are equivalent in this respect.
or private names