Re: The IMMEDIATE mess
- From: Albert van der Horst <albert@xxxxxxxxxxxxxxxxxx>
- Date: 29 Aug 2006 21:39:08 GMT
In article <12f81n5mc01btf2@xxxxxxxxxxxxxxxxxx>,
Andrew Haley <andrew29@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
<SNIP>
OK. It seems to me that IMMEDIATE does this job quite well already:
if you have a word that only makes sense in compile state (e.g. IF,
WHILE, etc) then what is wrong with IMMEDIATE ? IMMEDIATE has just
one job to do.
IF and other control words working in interpreted state results in
this beautiful one-screener:
------------------8<----------------------------------
( CRC-MORE CRC ) CF: ?32 \ AvdH
REQUIRE BOUNDS REQUIRE NEW-IF HEX
\ Well the polynomial
EDB8,8320 CONSTANT CRC32_POLYNOMIAL
\ Auxiliary table with values for single bytes.
CREATE CRCTable
100 0 DO I 8 0 DO
DUP >R 1 RSHIFT R> 1 AND IF CRC32_POLYNOMIAL XOR THEN
LOOP , LOOP
\ For initial CRC and BUFFER COUNT pair, leave the updated CRC
: CRC-MORE BOUNDS DO DUP I C@ XOR 0FF AND CELLS CRCTable + @
SWAP 8 RSHIFT XOR LOOP ;
\ For BUFFER COUNT pair, leave the CRC .
: CRC -1 ROT ROT CRC-MORE INVERT ;
DECIMAL
------------------8<----------------------------------
This does a full zip-compatible crc as per
S" monkey.frt" GET-FILE ( alias SLURP ) CRC HEX .
Languages like c have to run a special program to generate
tables, then include those huge tables in the actual
program.
Forth generates the table during compilation.
<SNIP>
I'm sorry, this is all too abstract for me. I guess I don't
understand what the problems are you're trying to eliminate; in the
absence of any examples I have no way to know. I know what I think
should go: STATE. At the time of ANS, Forth, Inc already had
well-established practice for a STATE-free Forth, but STATE went into
the standard anyway.
The following is not to say that I'm font of the word STATE per se.
I hate people talking about state-free Forth, and not realising
that numbers are state smart, indicating that you can't get rid
of some form of state altogether.
The only one to get it right (from the purist point of view,
at least) is Chuck Moore.
He attaches state to each instance of usage of a word, not to the
word itself.
He has different colors for numbers whether they must be compiled or
put on the stack and different colors for words when they are to be
executed, or compiled, or defined.
Andrew.
--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@xxxxxxxxxxxxxxxxxx http://home.hccnet.nl/a.w.m.van.der.horst
.
- Follow-Ups:
- Re: The IMMEDIATE mess
- From: Julian V. Noble
- Re: The IMMEDIATE mess
- From: Andrew Haley
- Re: The IMMEDIATE mess
- From: Mark W. Humphries
- 32-bit CRC table generation at compile time in C, was Re: The IMMEDIATE mess
- From: John Passaniti
- Re: The IMMEDIATE mess
- References:
- The IMMEDIATE mess
- From: J Thomas
- Re: The IMMEDIATE mess
- From: Andrew Haley
- Re: The IMMEDIATE mess
- From: J Thomas
- Re: The IMMEDIATE mess
- From: Andrew Haley
- The IMMEDIATE mess
- Prev by Date: Re: The IMMEDIATE mess
- Next by Date: Re: The IMMEDIATE mess
- Previous by thread: Re: The IMMEDIATE mess
- Next by thread: 32-bit CRC table generation at compile time in C, was Re: The IMMEDIATE mess
- Index(es):
Relevant Pages
|