Name syntax
David-Sarah Hopwood
david-sarah at jacaranda.org
Thu Dec 23 11:58:05 PST 2010
On 2010-12-23 16:36, thaddee yann tyl wrote:
> The private names proposal has a lot of good ideas, but their use is
> not obvious.
> The reasons I see for that are:
> The "private a;" declaration:
> * changes meaning of all obj.a in scope
> * looks like a scoped variable, not a private element of an object
> * is not generative-looking
> ... which makes it harder to understand, and use.
I agree with these criticisms.
> I find that David Herman's proposal fixes those issues:
>> But your idea suggests yet another alternative worth adding to our growing pantheon. We could allow for the scoping of private names, but always require them to be prefixed by the sigil. This way there's no possibility of mixing up public and private names. So to use an earlier example from this thread (originally suggested to me by Allen):
>>
>> function Point(x, y) {
>> private #x, #y;
>> this.#x = x;
>> this.#y = y;
>> }
>
> I understand that the number sign gets really heavy and annoying after
> some time. As a result, I suggest a simpler syntax, "private
> .secret;":
>
[...]
> private .a;
> k..a = o;
I find this less readable, and I think it would be easy to miss the
difference between . and .. in larger expressions. Also, the .. operator
is used in other languages for ranges.
In any case, let's not bikeshed about this yet. Either .# or @ is fine
for discussion. ('.#' is perhaps more suited to being viewed as a
variant of '.' with a private field selector, and '@' as an operator
distinct from '.')
--
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/20101223/0029209e/attachment.bin>
More information about the es-discuss
mailing list