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
Forth (programming language)
(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!
=== “Hello, World!” === <syntaxhighlight lang="forth"> : HELLO ( -- ) CR ." Hello, World!" ; </syntaxhighlight> HELLO <cr> Hello, World! The word <code>CR</code> (Carriage Return) causes the output following <code>CR</code> to be displayed on a new line. The parsing word <code>."</code> (dot-quote) reads a double-quote delimited string and appends code to the current definition so that the parsed string will be displayed upon execution. The space character separating the word <code>."</code> from the string <code>Hello, World!</code> is not included as part of the string. It is needed so that the parser recognizes <code>."</code> as a Forth word. A standard Forth system is also an interpreter, and the same output can be obtained by typing the following code fragment into the Forth console: <syntaxhighlight lang="forth"> CR .( Hello, World!) </syntaxhighlight> <code>.(</code> (dot-paren) is an immediate word that parses a parenthesis-delimited string and displays it. As with the word <code>."</code> the space character separating <code>.(</code> from <code>Hello, World!</code> is not part of the string. The word <code>CR</code> comes before the text to print. By convention, the Forth interpreter does not start output on a new line. Also by convention, the interpreter waits for input at the end of the previous line, after an <code>ok</code> prompt. There is no implied "flush-buffer" action in Forth's <code>CR</code>, as sometimes is in other programming languages.
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)