Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Modula-3
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Syntax== {{Expand section|date=July 2011}}<!-- Still needs some fleshing out. --> A common example of a language's [[Syntax (programming languages)|syntax]] is the [["Hello, World!" program]]. <syntaxhighlight lang="modula2"> MODULE Main; IMPORT IO; BEGIN IO.Put("Hello World\n") END Main. </syntaxhighlight> All programs in Modula-3 have at least a module file, while most also include an interface file that is used by clients to access data from the [[Modular programming|module]]. As in some other languages, a Modula-3 program must export a Main module, which can either be a file named Main.m3, or a file can call <code>EXPORT</code> to export the Main module. <syntaxhighlight lang="modula2">MODULE Foo EXPORTS Main</syntaxhighlight> Module file names are advised to be the same as the name in source code. If they differ, the compiler only emits a warning. Other conventions in the syntax include naming the exported type of an interface <code>T</code>, since types are usually qualified by their full names, so a type <code>T</code> inside a module named Foo will be named <code>Foo.T</code>. This aids in readability. Another similar convention is naming a public object <code>Public</code> as in the OOP examples below.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)