Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>>>cmFORTH did use the wordlists for independent interpretation and
>>>>>compilation semantics, but indeed not for IF and DO. There were
>>>>>compiling versions of a bunch of things, like this:
>>>>>
>>>>>FORTH : BINARY ( n) CREATE , DOES R> @ ?CODE @ DUP
>>>>> ... lots ... ;
>>>>>
>>>>>COMPILER A840 BINARY + AA40 BINARY XOR A640 BINARY OR
>>>>> AC40 BINARY - A240 BINARY AND A440 BINARY SWAP-
>>>>>
>>>>>FORTH
>>>>>
>>>>>... much later ...
>>>>>
>>>>>: SWAP SWAP ; : OVER OVER ;
>>>>>: DUP DUP ; : DROP DROP ;
>>>>>: XOR XOR ; : AND AND ;
>>>>>: OR OR ;
>>>>>: + + ; : - - ;
>>>>
>>>> That's just an unusual implementation of default compilation
>>>> semantics, but it's not really independent interpretation and
>>>> compilation semantics.
>>>
>>>I don't understand what you mean.
>>
>> These are normal Forth words (words with default compilation
>> semantics).
>
>In what sense? The COMPILER versions lay down instructions, the FORTH
>versions call them. They are different words, with different
>semantics, i.e. they do different things.
Sure, the default compilation semantics of a normal Forth word are
different from the default interpretation semantics (the default
compilation semantics compiles the execution semantics, the default
interpretation semantics performs it; in a more conventional
implementation the default compilation semantics COMPILE,s the xt of
the word, whereas the default interpretation semantics EXECUTEs the
xt.
The point is that these words implement the default semantics. +
behaves like a normal Forth word; no immediacy, no other non-default
compilation semantics. This normality is also reflected in the
definition
: + + ;
He doesn't define compile-only words like IF or immediate words like (
like this, nor would that work for S" and TO.
>> With "independent interpretation and compilation semantics" I mean
>> things like S", where the interpretation semantics puts the string
>> in a buffer, and the compilation semantics compiles it as string
>> literal.
>
>How is the above different? I really don't understand what point
>you're making.
The definition of + etc. above is just an unusual *implementation* of
the default semantics. + behaves as specified in the standard (even
though cmForth does not aspire to being a standard system), and + in
the standard is a normal word (i.e., only default compilation and
interpretation semantics).
One difference is that
: S" S" ;
is not a valid implementation of the interpretation semantics of S".
If I still have not made myself clear: Implementation is not
semantics. Semantics is what is visible from the outside (black-box
view). Implementation is how it is done (white-box view). The same
semantics can (and often does) have several different implementations.
E.g.:
: 2* 2 * ;
: 2* 1 lshift ;
: 2* dup + ;
On a 2s-complement system all these definitions implement the same
semantics (those specified in the standard for 2*).
- anton
--
M. Anton Ertl
http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs:
http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard:
http://www.forth200x.org/forth200x.html
EuroForth 2012:
http://www.euroforth.org/ef12/