alb...@spenarnc.xs4all.nl (Albert van der Horst) writes:
>In article <
3b27d020-72d1-4a58...@googlegroups.com>,
>Brad Eckert <
hwf...@gmail.com> wrote:
>>Is there a portable way to do this:
>>
>>: U ( <number> -- n )
>> (U) STATE @ IF POSTPONE LITERAL THEN
>>; IMMEDIATE
>>
>>without "STATE @" ?
>>
>>U takes a specially formatted number from the input stream.
>
>Are numbers state smart?
>Yes, and that has always been an accepted practise.
How can you tell?
If we describe a number as we would describe a word, would we describe
it as:
|5 ( -- n )
|
|Place 5 on the stack
or as
|5 Compilation: Perform the execution semantics given below:
|
|5 Execution: ( -- n| )
|
|In intepret state, place 5 on the stack. In compile state, append the
|run-time semantics below. 5 is an immediate word.
|
|Run-time: ( -- n )
|
|Place 5 on the stack.
I would prefer the first description, because it's simpler and at
least as accurate. So, if I were to describe numbers like we decribe
words, I would describe them as normal words (default compilation
semantics), not as STATE-smart (which would be the second
description).
The typical use of STATE-smartness (as exemplified by Brad Eckert's U)
is to make parsing words behave mostly like normal (default
compilation semantics) words. This works as intended when the word is
text-interpreted, but it breaks down if the word is ticked or
postponed. Since numbers do not parse, there is no need to connect
them with STATE-smartness. And since they cannot be ticked or
POSTPONEd, there is no way to tell the difference.