Tuesday 15 July 2014

packages - How does dart implement library privacy under the hood? -


When a library is prefixed with the name '_' then its library is private for Dart VM How does privacy implement? Internally, VM suffers variable names with a string, it is unique to the library, Therefore _foo may be _foo @ 1238fa12 . @ ensures that it can not collide with a user variable because @ is not valid in a common identifier. After attaching the string, VM can fully treat the variable as the normal variable, and because there is no other library which may possibly be in the context of the variable, it is effectively private library (although Perhaps in some corner cases, it should be more clever about private names.)

This is not the only possible implementation strategy, but private variables can be introduced to this strategy. Nane was designed for.


No comments:

Post a Comment