Import required?

Jeff Dyer jodyer at
Mon Apr 9 10:48:40 PDT 2007

'import' is not required to access a package property with a fully
qualified reference. However, the package qualifier must be statically
known to be a package name so that the reference can be properly
resolved ahead of time.

Here are two cases to illustrate this point (program 2 gets loaded after
program 1):


// program 1
package p.q { public var x = 10 }

// program 2
print(p.q.x)   // error: unresolved reference to 'p'


// program 1
package p.q { public var x = 10 }

// program 2
package p.q {} // could also be an import of any member of 'p.q'
print(p.q.x)   // prints 10

There is no loading implied by 'import'. It is simply the way to open a
package namespace. Implementations can add loading semantics to import
pragmas and package qualified references if they want to. FlexBuilder
does this by searching a "class path" to find references to definitions
outside of the current program.


> -----Original Message-----
> From: es4-discuss-bounces at [mailto:es4-discuss-
> bounces at] On Behalf Of Harri Porten
> Sent: Sunday, April 08, 2007 9:05 AM
> To: es4-discuss at
> Subject: Import required?
> Hello,
> reading the description of the "import" directive
>    "An ImportDirective causes the simple and fully qualified names of
>     or more public definitions of the specified package to be
>     into the current package."
> I am wondering whether "import" is required to access definitions
inside a
> package. After all, the symbols can otherwise be accessed directly as
> shown by the cited in the Package section:
>    package P {
>       function f() {}
>    }
>    P.f()
> If "import" is required I suggest to make this "loading" aspect a bit
> clearer in the text. Actually, I am wondering whether there is a way
> just just load a package without polluting the current namespace. A
> like "use" vs. "require" in Perl.
> Harri.
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at

More information about the Es4-discuss mailing list