Entry Points Section
The Entries
keyword begins the entry points section. The contents of this section are zero or more string literals separated by commas ,
(U+002C)
. Each string literal corresponds to an entry point, i.e., a message that should be exported for use at an external call site. For example:
In this example, Hello World
is a module that defines a single entry point, "Greet"
. This method may be invoked at an external call site. An external call site is a call site that occurs outside of a module, such as the input field of the Avail workbench.
An entry point is therefore analogous to the main()
of C or Java, since it provides a mechanism for an end user or external program to run an Avail program.
An entry point is not automatically available for use by downstream modules. To make an entry point available for downstream modules, simply include the name in the appropriate section:
- If the entry point is introduced by this module, then it should be included in the introduced names section.
- If the entry point is introduced by an upstream module, then it should be included (implicitly or explicitly) in the extended imports section.
In the example given above, there is only one entry point. The entry points section may contain arbitrarily many entry points, however:
This example, excerpted from the Availuator
, exports three entry points: "`!_"
, "Run_"
, and "time_"
. Any of these messages can be sent at an external call site. A send of an entry point at an external call site is called a command.
Unlike the entry points of traditional programming languages, the parameters of entry points are not constrained to be strings. They may be given any types whatsoever. The compiler is responsible for parsing and executing commands, so arbitrarily complex expressions may be parsed. The names available at argument positions of an entry point are limited to those exported by the module that defined the entry point.
‹ Introduced Names Section | | | Return to Modules | | | Active Versions Section › |