4 ms·
Can someone explain the benefits of the new lockdown features besides new opportunities for performance optimization?
by Hexstream 17y ago
Can someone explain the benefits of the new lockdown features besides new opportunities for performance optimization?
- axod 17y agoI think 'lockdown' type things can be really helpful when debugging code. Being able to lock something down, and be 100% sure that it can never be changed, by some weird eval(), by any 3rd party libs you're using, other developers code etc is very helpful. You could also use it to find where a property is being accessed from - just set it to writable:false - then see where an exception is thrown from. Also enforcing access - maybe you have a setTitle() function you want to be used instead of directly accessing the .title property. Now you can enforce that. Just as in Java, the keywords private and protected are a good mechanism for controlling access. These updates look really cool. Well thought out.
- mshafrir 17y agoLockdown would be like the final keyword in Java.
- mlLK 17y agoI think this is more of a permission feature for objects than a performance optimization. I think this `freezing/unfreezing` of objects only makes sense in an environment [or application] where objects and resources are being shared by more than one user or process. . .much like GNOME locks files in /tmp according to processes running on some other user's session.
- jeresig 17y agoIt's important to realize that once an object or property is "locked" (e.g. prevent extensibility on an object - most likely by being sealed or frozen) it cannot be "unlocked" - it's that way for as long as the object exists. This is done intentionally in order to prevent other code from unlocking it and then modifying it.