moonbit-docs icon indicating copy to clipboard operation
moonbit-docs copied to clipboard

doc: the init and main functions should be further explained

Open chaijie2018 opened this issue 6 months ago • 0 comments

Program entrance

Why distinguish between the init and main functions? What are the benefits of doing this? Many MoonBit beginners have these questions, but it is not explained in the documentation.

System-level initialization includes tasks such as the operating system loading the executable file, initializing processes, allocating resources, and preparing the runtime environment.

User code-level initialization includes static initializers, static fields, struct loaders, and so on.

Does the init function only include user-defined code initialization? Can the init function include system-level initialization? These points are also not clearly explained in the documentation. It would be helpful to improve this part of the documentation.

chaijie2018 avatar Apr 22 '25 05:04 chaijie2018