Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Forth (programming language)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Forth (programming language)
(section)
Add topic