Package (class)
public Package {inherits open-env, Component}
Package: CURL.LANGUAGE.COMPONENT
Direct Known Subclasses: OpenPackage

A container for Curl language code.

Description

Package objects serve as the containers for all code objects. Every code object, such as class and function definitions, exist within at least one Package object.

Although Package is a concrete class, objects of the exact type Package only result from importing a Curl package using import or import-package; such packages are already frozen and may not be modified. The only useful operation that may be performed on such objects is to examine their meta-data or lookup symbols.

The subclass OpenPackage is available for developers who wish to create modifiable package objects. All top-level applet code is evaluated in the context of an OpenPackage.

The Package object in which code is being currently compiled may be obtained using this-package. The Package object for the currently executing applet or script, may be obtained using get-current-package.

Properties
imported-packages:Return packages directly imported by this package.
accessor public final Package.imported-packages:{FastArray-of Package}
Properties inherited from Component: error-name, frozen?, id, meta-data, name, source-url, source-url-name, transitive-id
Methods
add:Adds a binding for a name in the package.
public {Package.add
    name:StringInterface,
    value:any,
    type:Type = {type-of value},
    access:BindingAccess = BindingAccess.public
}:void
get-member:Lookup package member by name.
public {Package.get-member
    name:String,
    check-imports?:bool = true
}:#PackageMember
get-members:Returns all public members accessible through this package.
public {Package.get-members
    check-imports?:bool = true
}:{FastArray-of PackageMember}
get-nonlocal-option:Lookup nonlocal option by name.
public {Package.get-nonlocal-option
    name:String,
    check-imports?:bool = true
}:#Option
get-nonlocal-options:Returns all options accessible through this package.
public {Package.get-nonlocal-options
    check-imports?:bool = true
}:{FastArray-of Option}
lookup:Looks up a name in the package.
public {Package.lookup
    name:StringInterface,
    check-imports?:bool = false,
    public-only?:bool = false
}:(value:any, found?:bool)
Methods inherited from Component: assert-not-frozen
Methods inherited from Object: object-describe, object-describe-for-debugging, object-serialize

Property Details
imported-packages (accessor)
accessor public final Package.imported-packages:{FastArray-of Package}

Return packages directly imported by this package.



Method Details
add (method)
public {Package.add
    name:StringInterface,
    value:any,
    type:Type = {type-of value},
    access:BindingAccess = BindingAccess.public
}:void

Adds a binding for a name in the package.

name: The name to be bound.
value: The value to be bound to name.
type: The compile-time type to be associated with the binding. This defaults to the type of the value. This type must be a supertype of the value's type.
access: The access level of the binding, which defaults to BindingAccess.public. Values that do not make sense for package bindings, such as BindingAccess.private and BindingAccess.protected, will result in an error.


get-member (method)
public {Package.get-member
    name:String,
    check-imports?:bool = true
}:#PackageMember

Lookup package member by name.

name: The name to be looked up.
check-imports?: If this flag is true, then any packages publicly imported by this package will also be searched. If the name is found in more than one imported package, a AmbiguousNameError will be thrown. If false, only members directly defined in this package will be returned.

Description

Returns PackageMember object representing public member of the package with the specified name.

Returns null if no matching public member is found.


get-members (method)
public {Package.get-members
    check-imports?:bool = true
}:{FastArray-of PackageMember}

Returns all public members accessible through this package.

check-imports?: If this flag is true, then any packages publicly imported by this package will also be searched. If false, only members directly defined in this package will be returned.

Description

Returns an array of PackageMember objects representing all of the public members accessible through this package.


get-nonlocal-option (method)
public {Package.get-nonlocal-option
    name:String,
    check-imports?:bool = true
}:#Option

Lookup nonlocal option by name.

name: The name to be looked up.
check-imports?: If this flag is true, then any packages imported by this package will also be searched.

Description

Returns Option object representing option with the specified name.

Returns null if no matching option is found.


get-nonlocal-options (method)
public {Package.get-nonlocal-options
    check-imports?:bool = true
}:{FastArray-of Option}

Returns all options accessible through this package.

check-imports?: If this flag is true, then any packages imported by this package will also be searched. If false, only options directly defined in this package will be returned.

Description

Returns an array of Option objects representing all of the options accessible through this package.


lookup (method)
public {Package.lookup
    name:StringInterface,
    check-imports?:bool = false,
    public-only?:bool = false
}:(value:any, found?:bool)

Looks up a name in the package.

name: The name to be looked up.
check-imports?: If this flag is true, then any packages imported by this package will also be searched. If the name is found in more than one imported package, a AmbiguousNameError will be thrown.
public-only?: If true, then only include public names. This is automatically set if the package is frozen.

Returns

If name is bound in the package then its value is returned as the first value with true as the second value. Otherwise null is returned as the first value and false as the second value.

Description

Note that only public names can be accessed in frozen packages even if public-only? is set to false.