BUFFER was renamed into (BUFFER) in ciforth from FIGForth.
It is worthy of the round brackets, because it is an internal word.
--------------------
() Return the address addr of a buffer assigned to identification n ,
probably a block number. Block numbers are positive, so a negative
value can be used for a buffer that is used for some other purpose.
The buffer layout is as follows: a cell with n, a cell with the
status, and the content of length B/BUF . The status is negative for
locked. The l.s.b. gives zero for free and one for valid data. The
block is not read from the disc. The buffer is either one that was
already assigned, or else a free buffer. If there is none free, some
non-locked buffer is freed. The contents of that buffer is written to
the disc, if it was marked as updated. In ciforth this will never
happen, because updated blocks are written immediately. In ciforth
blocks can be locked, and locked buffers are never freed by (BUFFER) .
An update flag would somehow be multiplexed with the lock count, but
it is not needed in this ciforth. If all buffers were locked, (BUFFER)
throws exception 48.
-------------
The description suggest that you don't need the word unless you want
to mess with the internals of FORTH.
\ Copy block one to block two.
: C-S SWAP BLOCK SWAP BLOCK B/BUF CMOVE UPDATE ;
This requires that you have at least two block buffers.
Any content made before to other blocks, is at risk of
being lost, unless you do UPDATE diligently.
You must understand that BLOCK is a cache for a disk or a
file. So after any change to a block in memory you should
say UPDATE to notify that it is to be written to disk in
at a convenient time.
You have a wrong understanding of BLOCK if you ask that the address or
content has changed. You have only control over blocks via the UPDATE.
You can only change a block immediately after obtaining the address of
the block. In other words you have no business worrying about address
or content of blocks!
Using blocks is inherently more difficult than files, and any
newbies are strongly advised against using blocks, if files are
available.
I use blocks in lina (and am chastized for it!) but actually I
use it as a read only library, never changing blocks, never using
blocks for application source code, inserting blocks using external
tools, and never using block numbers, not even if symbolically
defined.
Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -