Does private(expr) create a private storage block?
Mark S. Miller
erights at google.com
Thu Jan 19 14:38:56 PST 2012
On Thu, Jan 19, 2012 at 1:00 PM, Herby Vojčík <herby at mailbox.sk> wrote:
> Mark S. Miller wrote:
>> ... I don't have strong feelings about this for non-const
>> classes. For const classes, I think privates should always be declared
>> in the constructor. I would like to be able to always allocate instances
>> of const classes of fixed "shape", i.e., non-configurable /
>> non-extensible, so that users don't have to worry about whether they've
>> enabled the resulting optimizations or whether they have uncaught
>> spelling errors.
> It is written in class proposal:
> - An efficient implementation. The private state should be allocated with
> the instance as part of a single allocation, and with no undue burden on
> the garbage collector.
> - The ability to have private mutable state on publicly frozen objects.
> Now it is the question, what does it say about "fixed shape". Does "fixed
> shape" mean no private can be added / deleted, but private properties
> themselves can be mutated? Or is it the weaker "the private space must be
> created and is not removable (in frozen object), but it is itself
> extensible and private properties are configurable and writable"?
> For consistency, perhaps we should make similar requirements for
>> privates of non-const classes, but this isn't clear. If you have some
>> arguments one way or another, please post. Thanks.
> I have more thoughts on this, even the proposal how to make it work
> dynamically for non-const classes and "fixed" in const classes, but the
> answer to previous question seems important.
> I presume the answer is "the latter", since "with no undue burden on the
> garbage collector" could be read as "if possible, blended in single
> object". But I would like to hear from you.
For const classes specifically, my intention is that the "private state"
object is "sealed", i.e., it is non-extensible and all its properties are
non-configurable, but generally writable unless declared otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss