« Return to Thread: Classes as Sugar -- old threads revisited

Re: Classes as Sugar -- old threads revisited

by Mark S. Miller-2 :: Rate this Message:

Reply to Author | View in Thread



On Tue, May 26, 2009 at 3:08 PM, P T Withington <ptw@...> wrote:
These two are reversed, aren't they?  The const should have the getter rather than the value?


On 2009-03-30, at 22:41EDT, Mark S. Miller wrote:

      pubInstVar: {get: Object.freeze(function{return pubInstVar;}),
                   enumerable: true},
      pubInstConst: {value: pubInstConst,
                     enumerable: true}


No, it's correct as is. With an initialized const variable, its value can't change, so we can just present the value directly as the value of a frozen data property. A let variable, on the other hand, can continue to change. Thus, in order for the property to continue to present the variable's current value we need a getter.



--
   Cheers,
   --MarkM

_______________________________________________
es-discuss mailing list
es-discuss@...
https://mail.mozilla.org/listinfo/es-discuss

 « Return to Thread: Classes as Sugar -- old threads revisited