The main Function

Gamma: Version 4.0
Prev | Chapter 7. Functions and Program Structure | Next

# 7.5. The `main` Function

In Gamma there is no requirement for a function named `main` as there is in C. As a program file is loaded, a call to a function at the outermost scope will in fact cause that function to be run at that point. In the same way, variable definitions and assignments at the outermost scope level are executed, effectively becoming globals. In most cases, the application is initiated by calling the user's "top level mainline" function at the end of the file, or by entering a loop, such as an infinite event loop.

If a function is defined with the name `main`, then Gamma will automatically start to execute that function after the load is complete. This is equivalent to placing `main` as the last statement in the file. Note that `main`'s function definition must contain the keyword `function` , just like any other function definition. Since `argv` is available as a global variable, `main` does not require any arguments.

Prev | Home | Next
Loading files | Up | Executable Programs

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.