Category:Forth: Difference between revisions

mention ANS standard forth; common extension words
(Copied language description.)
(mention ANS standard forth; common extension words)
Line 1:
[[Category:Solutions by Programming Language]]
'''Forth''', a procedural, stack-oriented and reflective programming language without type checking, Forth features both interactive execution of commands (making it suitable as a shell for systems that lack a more formal operating system) and the ability to compile sequences of commands for later execution. Some Forth versions (especially early ones) compile threaded code, but many implementations today generate optimized machine code like other language compilers.
 
Where not otherwise specified, examples conform to the 1994 ANSI Standard, also known as '''ANS Forth'''. Most Forth implementations now conform to this standard, often with system-specific extensions and convenience libraries. Some examples use words that are not in the standard, but which have become accepted as common practice since 1994:
 
1 cells constant cell
-1 cells constant -cell
: cell- -cell + ;
 
: -rot ( a b c -- c a b ) rot rot ;
 
: bounds ( addr len -- limit addr ) over + swap ; \ convert string/array to DO-LOOP limits
 
Alternate local variable syntax using curly braces, designed to look like a regular stack comment:
 
: muldiv { a b -- a*b a/b } \ all stuff after "--" is ignored
a b * a b / ;
 
==Citations==
* [http://en.wikipedia.org/wiki/Forth_%28programming_language%29 Wikipedia:Forth (programming language)]
* [http://www.forthfreak.net/dpans/dpansf.htm Index to the ANS Forth words]
Anonymous user