[ ECLiPSe Module built-in.|Group Index| Full Index]

export +SpecList

Exports all procedures specified by SpecList. These are then visible to modules that import them.

+SpecList
Sequence of expressions of the form Atom/Integer.

Description

There are three visibility levels which impose different restrictions on accessing a procedure.

local visible only in its home module.

exported visible in all modules that explicitly import it.

global visible in all modules that explicitly import it and in all modules where there is no procedure with the same name imported, declared or defined.

When looking for a procedure, the system looks first for a procedure defined or declared in the caller module then for an imported one and if none exists, for a global one defined in another module.

export +SpecList declares the procedure(s) specified by SpecList exported and therefore only visible to modules that import them (using the predicate import_from/2 or import/1).

A procedure can be declared as exported before it is actually defined.

If a procedure with the same name was already imported from another module, an error is raised. Import links must be cut explicitely using abolish/1.

Declaring a procedure as exported will make it visible to other modules. This may produce exceptions it there is a type conflict (e.g. when declaring a tool as exported when it is already imported from a module where a call has already been compiled to it as a non tool). Such type conflicts can be prevented using the declaration predicates (tool/1, external/1 or b_external/1).

Note If the procedure to be exported was global, it will not be global any longer and hence it will be visible only in modules where it has been imported.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
SpecList is not instantiated.
(5) Type error
SpecList is instantiated, but not a sequence of expressions of the form Atom/Integer.
(62)
making SpecList exported would create a type conflict
(88)
SpecList is already exported.
(94)
SpecList is already imported.

Examples


Success:

  [eclipse]: [user].
   p :- q.
   :- import q/0 from m.
   user   compiled 32 bytes in 0.05 seconds
  yes.
  [eclipse]: p.
  calling an undefined procedure q in module eclipse
  [eclipse]: module(m).
  [m]: [user].
   :- export q/0.
   q :- writeln(hello).
   user   compiled 60 bytes in 0.00 seconds
  yes.
  [m]: module(eclipse).
  [eclipse]: p.
  hello
  yes.

Error:

  export Q.                         (Error 4).
  export p/a.                       (Error 5).

  [eclipse]: [user].
    :- import t/0 from m.
  % :- tool(t/0) here would prevent error 62 in export(t/0) below
   p :- t.
  user   compiled 32 bytes in 0.07 seconds
  yes.
  [eclipse]: module(m).
  [m]: [user].
   :- tool(t/0, writeln/1).
   :- export(t/0).                  (Error 62).

  export(p/0), export(p/0).         (Error 88). (warning)
  (import p/0 from m), export p/0.  (Error 94).


See Also

abolish / 1, global / 1, import / 1, import_from / 2, local / 1