Namespaces
On 12/12/07 11:13 AM, Michael O'Brien wrote:
I've got a question about how user defined namespaces should resolve inside of packages. This is really an ES4 implementation question and not a usage question.
Consider:
package one { public namespace blue = "blue" }
package one { use namespace blue blue var x :int }
package two { public namespace blue = "blue" }
package two { use default namespace blue blue var x : string }
This fails to compile as the two "blue var x" declarations have different fixture types. So this implies that variable declarations inside packages that have namespaces with identical URI => are not defined with any package qualification. ie. the namespace is the only qualification. This is what I expected, but just wanted to confirm this.
That is correct. A namespace attribute in a package body overrides the default package qualifier. AS3 allowed only public and internal at this level, but we have agreed that we would allow such use of namespaces inside of packages and interfaces. #335 just opened to clarify.
Also, I noticed in the RI that you can't have namespace (and other) declarations outside of a "package {" block. ie.
namespace blue package { }
will fail to compile, but put the namespace declaration inside of "package {" and it works. Surely, these declarations should be allowed outside an explict package declaration due to the fact that there is an implicit "package {" around global declarations?
The error probably has to do with the fact that the current grammar requires packages to be defined at the top of a compilation unit. It is our intention to change this letting package definitions to be interspersed with other definitions and statements.
An HTML attachment was scrubbed... URL: esdiscuss/attachments/20071212/b5a40883/attachment-0002
I've got a question about how user defined namespaces should resolve inside of packages. This is really an ES4 implementation question and not a usage question.
Consider:
package one { public namespace blue = "blue" }
package one { use namespace blue blue var x :int }
package two { public namespace blue = "blue" }
package two { use default namespace blue blue var x : string }
This fails to compile as the two "blue var x" declarations have different fixture types. So this implies that variable declarations inside packages that have namespaces with identical URI => are not
defined with any package qualification. ie. the namespace is the only qualification. This is what I expected, but just wanted to confirm this.
Also, I noticed in the RI that you can't have namespace (and other) declarations outside of a "package {" block. ie.
namespace blue package { }
will fail to compile, but put the namespace declaration inside of "package {" and it works. Surely, these declarations should be allowed outside an explict package declaration due to the fact that there is an implicit "package {" around global declarations?
Michael O'Brien