processor-dependent. Gforth’s alignment words perform natural alignment
(e.g., an address aligned for a datum of size 8 is divisible by
8). Unaligned accesses usually result in a -23 THROW
.
EMIT
and non-graphic characters: ¶The character is output using the C library function (actually, macro)
putc
.
ACCEPT
and EXPECT
: ¶This is modeled on the GNU readline library (see Command Line Editing in The GNU Readline Library) with Emacs-like key bindings. Tab deviates a little by producing a full word completion every time you type it (instead of producing the common prefix of all completions). See Command-line editing.
The character set of your computer and display device. Gforth is 8-bit-clean (but some other component in your system may make trouble).
installation-dependent. Currently a character is represented by a C
unsigned char
; in the future we might switch to wchar_t
(Comments on that requested).
Any character except the ASCII NUL character can be used in a
name. Matching is case-insensitive (except in TABLE
s). The
matching is performed using the C library function strncasecmp
, whose
function is probably influenced by the locale. E.g., the C
locale
does not know about accents and umlauts, so they are matched
case-sensitively in that locale. For portability reasons it is best to
write programs such that they work in the C
locale. Then one can
use libraries written by a Polish programmer (who might use words
containing ISO Latin-2 encoded characters) and by a French programmer
(ISO Latin-1) in the same program (of course, WORDS
will produce
funny results for some of the words (which ones, depends on the font you
are using)). Also, the locale you prefer may not be available in other
operating systems. Hopefully, Unicode will solve these problems one day.
If word
is called with the space character as a delimiter, all
white-space characters (as identified by the C macro isspace()
)
are delimiters. Parse
, on the other hand, treats space like other
delimiters. Parse-name
, which is used by the outer
interpreter (aka text interpreter) by default, treats all white-space
characters as delimiters.
The data stack is used as control-flow stack. The size of a control-flow
stack item in cells is given by the constant cs-item-size
. At the
time of this writing, an item consists of a (pointer to a) locals list
(third), an address in the code (second), and a tag for identifying the
item (TOS). The following tags are used: defstart
,
live-orig
, dead-orig
, dest
, do-dest
,
scopestart
.
The characters [\]^_'
are the digits with the decimal value
36−41. There is no way to input many of the larger digits.
ACCEPT
and EXPECT
: ¶The cursor is moved to the end of the entered string. If the input is terminated using the Return key, a space is typed.
ABORT"
: ¶The error string is stored into the variable abort-string
and a
-2 throw
is performed.
For interactive input, C-m (CR) and C-j (LF) terminate lines. One of these characters is typically produced when you type the Enter or Return key.
s" /counted-string" environment? drop .
. Currently 255 characters
on all platforms, but this may change.
Given by the constant /line
. Currently 255 characters.
MAXU/8
ENVIRONMENT?
, in characters: ¶MAXU/8
The user input device is the standard input. There is currently no way to change it from within Gforth. However, the input can typically be redirected in the command line that starts Gforth.
EMIT
and TYPE
output to the file-id stored in the value
outfile-id
(stdout
by default). Gforth uses unbuffered
output when the user output device is a terminal, otherwise the output
is buffered.
What are we expected to document here?
s" address-units-bits" environment? drop .
. 8 in all current
platforms.
Processor-dependent. Binary two’s complement on all current platforms.
Installation-dependent. Make environmental queries for MAX-N
,
MAX-U
, MAX-D
and MAX-UD
. The lower bounds for
unsigned (and positive) types is 0. The lower bound for signed types on
two’s complement and one’s complement machines machines can be computed
by adding 1 to the upper bound.
The whole Forth data space is writable.
WORD
: ¶PAD HERE - .
. 104 characters on 32-bit machines. The buffer is
shared with the pictured numeric output string. If overwriting
PAD
is acceptable, it is as large as the remaining dictionary
space, although only as much can be sensibly used as fits in a counted
string.
1 cells .
.
1 chars .
. 1 on all current platforms.
Varies. You can determine the size at a specific time using lp@
tib - .
. It is shared with the locals stack and TIBs of files that
include the current file. You can change the amount of space for TIBs
and locals stack at Gforth startup with the command line option
-l
.
PAD HERE - .
. 104 characters on 32-bit machines. The buffer is
shared with WORD
.
PAD
: ¶The remainder of dictionary space. unused pad here - - .
.
Dictionary searches are case-insensitive (except in
TABLE
s). However, as explained above under character-set
extensions, the matching for non-ASCII characters is determined by the
locale you are using. In the default C
locale all non-ASCII
characters are matched case-sensitively.
ok
in interpret state, compiled
in compile state.
The ordinary division words / mod /mod */ */mod
perform floored
division (with the default installation of Gforth). You can check
this with s" floored" environment? drop .
. If you write
programs that need a specific division rounding, best use
fm/mod
or sm/rem
for portability.
STATE
when true: ¶-1.
On two’s complement machines, arithmetic is performed modulo
2**bits-per-cell for single arithmetic and 4**bits-per-cell for double
arithmetic (with appropriate mapping for signed types). Division by
zero typically results in a -55 throw
(Floating-point
unidentified fault) or -10 throw
(divide by zero). Integer
division overflow can result in these throws, or in -11 throw
;
in gforth-fast
division overflow and divide by zero may also
result in returning bogus results without producing an exception.
DOES>
: ¶No.