3 ms·
How did namespaces in ES4 differ from namespaces in Java?
by mycall 6y ago
How did namespaces in ES4 differ from namespaces in Java?
- olliej 6y agoMy recollection was that there were modules, packages, and namespaces. Which was kind of a problem.
- zwetan 6y agoIn Java you would use packages to group together class definitions same as with C++, C# where you would use namespaces to do that aka define the scope of classes in AS3, the packages are used the same, group collection of definitions, not only classes and interfaces but also variables, constants. The namespaces in AS3 are used to define the visibility of definitions at the class level, a bit like being able to define your own "public" attribute. In ActionScript 3, by default the AS3 namespace is open, for example with a builtin like Array instead of using the push() method defined in the prototype, it uses the push() method defined in the AS3 namespace. See https://github.com/adobe/avmplus/blob/master/core/Array.as#L187 https://github.com/adobe/avmplus/blob/master/core/Array.as#L... But you also have mode to compile with -ES to not open that AS3 namespace by default. In ES4, namespaces could do more advanced stuff like namespace shadowing (only a proposal at the time), see https://web.archive.org/web/20070629024201/http://developer.mozilla.org/es4/spec/chapter_12_namespaces.html https://web.archive.org/web/20070629024201/http://developer.... For AS3, see 1.9 Namespaces / 12 Namespaces / etc. https://github.com/as3lang/ActionScript3/wiki/Specification https://github.com/as3lang/ActionScript3/wiki/Specification