This is a new word introduced by MPE. It avoids some of the complications when
using #> to return the current contents of the PNO buffer. The definition is:
HELD ( -- caddr len )
Return the address and length of the string held in the pictured numeric output
buffer.
HELD is a factor of #> allowing the latter to be defined:
: #> 2DROP HELD ;
So if you've found yourself writing 0 0 #> or <# 2DUP HOLDS #> to avoid the
2DROP built into #> then HELD may be a neater solution.
(F.) is an example of where I used HELD two or three times. Some others:[..]
\ Return string right-aligned as a2 u2. Uses HOLD buffer
: RJUST ( a u +n c -- a2 u2 )
>r >r <# shold held r> over - 0 max r> nhold #> ;
HOLDS (200x) recognizes that the numeric conversion buffer can and is used for
string processing. In that situation HELD is often more appropriate than #> .
;
On 25/04/2024 10:05 pm, dxf wrote:[..]
On 25/04/2024 8:51 pm, mhx wrote:
dxf wrote:
Regarding redirection I'd say apps intended for disk output are written that way which implies functions have string output. If OTOH apps are written
for console output, then usually the OS has a mechanism for redirection in which case the app writer need not concern himself.
How does the programmer differentiate bona-fide
console output from disk output?
On 8/05/2024 7:18 pm, mhx wrote:
dxf wrote:different streams.
On 25/04/2024 10:05 pm, dxf wrote:[..]
On 25/04/2024 8:51 pm, mhx wrote:
dxf wrote:
Regarding redirection I'd say apps intended for disk output are written that
way which implies functions have string output. If OTOH apps are written >>> for console output, then usually the OS has a mechanism for redirection in >>> which case the app writer need not concern himself.
Typically text output is meant to be read by humans, while file output is mainly meant to be read by computers (further processing).
For debugging it is prudent to make sure the files are (somewhat) human readable though.
I think redirection is difficult (or at least inconvenient) from *within* a program, as is switching back and forth between
Indeed, for trivial and conventional programs, that do not use the
Forth interpreter as an essential component, the standard OS tools
may be sufficient.
Text may have originally been intended for humans but it became so massive that
now we use computers to process it and disks to store it. Redirecting text data
intended for disk to the console might be useful in certain circumstances and >when amounts are small. But the idea of sending data to disk using console output
statements seems confusing. How does the programmer differentiate bona-fide >console output from disk output? I don't like it at all.
But the idea of sending data to disk using console output
statements seems confusing.
How does the programmer differentiate bona-fide
console output from disk output?
The typical case is that error messages should go to the console while regular output is directed to disk. For that purpose Unix has two
file descriptors: 1 (stdout as C FILE *), and 2 (stderr as C FILE *).
If you want to print an error or warning message, you print to stderr, otherwise to stdout.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 502 |
Nodes: | 16 (2 / 14) |
Uptime: | 216:44:17 |
Calls: | 9,878 |
Calls today: | 6 |
Files: | 13,791 |
Messages: | 6,205,703 |