actionscript 3 - Packages name conflicting with getters and setters? -


People, I've come to this compilation error some time ago. As is an easy decision and I did not get relevant at that time, I finally let it go.

I remembered it and now I am thinking that is it really a part of the grammar of language (which I am very skeptical) or if it is a compiler bug I am purely curious about it I - it does not really affect the development, but it would be nice to see if any of you have seen it already.

  Package view {import flash} display.Sprite; Public class provides main sprites {Private var _view: Sprite = new Sprite (); Public work chief () {this.test (); } Private Function Testing (): Zero {trace (this.view.x, this.view.y); // 1178: Static Type View tried to use inaccessible property X through context: Main // 1178: Stable type view attempted to use inaccessible property y through context: main / / Note that I found this because of the package name. // If I change the name of the package or the guestster then it runs fine. See the public event (): Sprite {return._view; }}}}  

I would say that this is either a compiler bug or an incompatibility

Chapter 11.1 Excerpt from package namespace (I directly link, but uses Docs Frame):

Packages are present at compiled time only. The static entity of the package allows us to give some of the qualities that runtime can be tampered with. Specifically:

Package names can have embedded dots.

But because there is no runtime value for the package name, the package can not be moved or used otherwise. An expression that uses a runtime value.

When compiling a legitimate reference, the name of the package name is correct; No explanation is possible on the runtime.

For this reason, a package name always shrouts the locally defined names independently from the scope series, when that package is used in the left hand of the dot operator.

Now, from the top, I collect this line:

  trace (this.view.x, this.view.y); The   

should not be interpreted by the compiler in the context of the view package, because it starts refuting this point - I will call it A:

The packages can not be moved solely or can be used in an expression that uses runtime values ​​

Because it , unless I am wrong, is a runtime value.

Again, if you use this , then the ambiguity can be solved as your recipient, I think, but according to this paragraph - we have B), this will not happen:

For this reason, a package name always shades locally defined names different from the scope series, when the package name is the left hand of a dot The operator is used in

Therefore, if you do not use this , then it is clear that to interpret as view.x One reference to define in the x in view package should be.

If you explicitly call this , there is a contradiction between A) and B), as I see. According to A) no aliasing should be; But aliasing is happening, it seems, because a package name has been used on the left of the dot operator. So my guess is that the compiler is not parsing in the context of the package, just to talk, it just checks that a name on the left of the dot operator matches the name of the defined package.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -