Packages

Package is a separate name space in which variables and functions are defined.

package( ) or
(String packageName) or
(Package aPackage)

package() with one argument changes the current package to the specified package. package() with no argument returns the Package object of the current package.

package("foo")   ==> package "foo"
package()        ==> package "foo"
package("")      ==> package ""
package()        ==> package ""
use(String packageName)

This builtin function imports all functions from a module, pkgName. Imported functions can be called without specifying the package name.

package("foo")
function x() 100
y = 200

package("bar")
use("foo")
x ==> function x
y ==> error

package("")
x ==> error
y ==> error
aPackage . symbol
aPackage . symbol = value
foo = 100
package().foo     ==> 100
package().foo = 200
foo               ==> 200
package().bar     ==> null
aPackage .defined (String symbolName , Context context )

Package.defined method checks if the specified symbol name is defined in the target package.

getPackage("foo")
context = getContext()
findPackage("foo").defined("bar", context)   ==> false
foo::bar = 100
findPackage("foo").defined("bar", context)   ==> true
aPackage .clear (String symbolName, Context context )

Package.clear method removes the specified symbol in the target package.

context = getContext()
findPackage("foo").defined("bar", context)   ==> true
findPackage("foo").clear("bar", context)
findPackage("foo").defined("bar", context)   ==> false