Top-Level Statements

Similar to Top-Level Statements introduced in C# 9.0 and similar to Swift, Mercury supports a simple syntax for defining the Entry Point for an executable without explicitly declaring a static class and a static Main method, by simply having a (single) .vb file that contains code statements at the top level.

Essentially this simplified code:

Imports System

writeLn("The magic happens here.")

is equivalent to:

Imports System

Module Program

  Sub Main(args as String())
    writeLn("The magic happens here.")
  End Sub

End Module

Access to command line arguments is still available via the implicitly named args variable, and the code can choose to Return either with an integer result, or without.

Requires Mercury build .2695 or later.

See Also