But as Jeff Fox explains:
"Forth is about words. Words have names. The choice of the names of the words
in Forth is certainly one of the most important things. And given that humans have limited minds there should be a focus on what words are important. That's
why it was considered important in the design of Forth to put emphasis on not having to name every temporary storage location. It has a name. It is a called
a stack. The point being here that you don't have to name items on a stack. If you think you want to name the temporary items on the stack you are missing
the most important design features of the language."
I don't see how the last sentence follows from the stuff he wrote
before.
And Chuck Moore and others who do not use locals do not practice what
Jeff Fox preached. They just use VARIABLEs instead of locals.
- anton
It is not a good to duplicate VARIABLE's with LOCAL's
DVARIABLE's with DLOCAL's FVARIABLE's with DLOCAL's etc.
Parsing with TO is an abuse of the powers of Forth.
none wrote:<SNIP>
[ BTW, it's not just classical re-entrancy. If a word isThey are local variables, so they don't need duplicates.
used from more than one location in a bigger program,
its variables have to be duplicated. Where do you
put the copies? ]
-marcel--
DVARIABLE's with DLOCAL's FVARIABLE's with DLOCAL's etc.
Parsing with TO is an abuse of the powers of Forth.
If I use VARIABLEs as locals it is admission I was beaten. I try to keep that to a minimum :)
On 16/12/2023 6:45 pm, Anton Ertl wrote:
...
And Chuck Moore and others who do not use locals do not practice what
Jeff Fox preached. They just use VARIABLEs instead of locals.
Moore has said:
"Don't use local variables [...] It's bad. It's wrong."
<https://www.ultratechnology.com/1xforth.htm>
If he's merely using VARIABLEs where locals would otherwise be used that's >worth investigating. Unfortunately I'm not aware of any substantive code
by Moore in the public domain to test the proposition.
As one of the "others who do not use locals" I offer the following sample. >Readers may decide whether such use of VARIABLEs and VALUEs amounts to locals >in the usual meaning of the word. ISTM the more factored the code, the more >difficult it is to apply the term 'local'.
variable #DIGIT \ #digits entered
: /FIELD ( n -- 0 )
drop #digit @ begin dup while
<bs> emit space <bs> emit 1-
repeat decimal #digit off ;
: .VIS ( c -- )
dup visible? if emit 1 #digit +! end drop ;
: ?$ ( n c -- n' c' )
[char] $ of /field hex [char] $ .vis key then ;
: +DIGIT ( u c -- u' err )
base @ >digit if swap base @ * + dup 255 u> end
drop true ;
: BUILD# ( c -- n c2 ) \ CR or BL exits
decimal #digit off
0 swap begin dup bl <> over <cr> <> and while
?$ upcase dup .vis +digit if beep /field then key
repeat decimal ;
: GET# ( -- n ) key build# drop ;
variable LEN 0 value MAXCHR
: ROOM? ( -- f ) len @ maxchr < ;
: +CHR ( c -- ) ibuf len @ + c! 1 len +! ;
: DO-NUM ( c -- ) \ CR or BL BL exits
begin room? while
build# swap #digit @ if +chr else drop then
<cr> = if end space key bl of <cr> then
repeat drop ;
: DO-ASC ( c -- )
begin dup <cr> - room? and while
dup .chr +chr key
repeat drop ;
: DIGIT? ( c -- f )
dup [char] $ = swap [char] 0 [char] 9 between or ;
: GET$ ( maxlen -- adr len )
to maxchr len off
key dup digit? if do-num else do-asc then
ibuf len @ ;
On 16/12/2023 6:45 pm, Anton Ertl wrote:
... And Chuck Moore and others who do not use locals do not
practice what Jeff Fox preached. They just use VARIABLEs instead
of locals.
Moore
has said:
"Don't use local variables [...] It's bad. It's wrong."
<https://www.ultratechnology.com/1xforth.htm>
If he's merely using VARIABLEs where locals would otherwise be used
that's worth investigating. Unfortunately I'm not aware of any
substantive code by Moore in the public domain to test the
proposition.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (3 / 13) |
Uptime: | 45:03:11 |
Calls: | 6,710 |
Calls today: | 3 |
Files: | 12,243 |
Messages: | 5,354,231 |