On Tuesday, August 9, 2016 at 7:08:55 AM UTC-7, Anton Ertl wrote:
>
hughag...@gmail.com writes:
> >On Monday, August 8, 2016 at 2:05:38 AM UTC-7, Anton Ertl wrote:
> >> There is no provision in the standard for FIND giving an error on
> >> valid input.
> >
> >According to the ANS-Forth document in the entry for IF (section 6.1.1700):=
> > "Interpretation semantics for this word are undefined." The ANS-Forth docu=
> >ment has a section (4.1.2) with the ominous heading: "Ambiguous Conditions.=
> >" One of the many ambiguous conditions is: "attempting to obtain the execut=
> >ion token, (e.g., with 6.1.0070 ', 6.1.1550 FIND, etc.) of a definition wit=
> >h undefined interpretation semantics."
>
> Good catch. Interestingly, the definition of FIND does not mention
> that, and given the return values that FIND can produce, and the way
> that FIND is used, I don't think it makes sense.
Well, I'm glad that you are admitting that FIND in ANS-Forth is broken. I would use the term "sabotaged" because there is no point to making FIND not work except to prevent the programmer from writing an outer-interpreter.
It is disingenious to describe this as a "good catch" in the year 2016. You yourself pointed this problem out to me in 2009, and you provided the way to fix it. This was in this thread:
https://groups.google.com/forum/#!topic/comp.lang.forth/wP5nw1ClzsM%5B1-25%5D
On Thursday, November 26, 2009 at 3:24:06 AM UTC-7, Anton Ertl wrote:
> Hugh Aguilar <
hugoa...@rosycrew.com> writes:
> >I don't understand how a word can not have execution semantics.
>
> That's quite simple: By not defining execution semantics in the
> definition of the word in the standard document. Look up the
> definition of ";" in the standard, and you will see that there is no
> "Execution:" section there; and there are other labeled sections
> there, so the "omitted label" sentence of 3.4.3.1 does not apply.
>
> >For immediate words (IF, ;, etc.)
>
> IF and ";" are not immediate words in the standard. A system can
> implement them as immediate words, but a program cannot rely on their
> immediacy.
>
> >I looked up ['] in the ANS-Forth document and it says:
> >
> >"Place name's execution token xt on the stack."
>
> What's the execution token of a word that has no execution semantics.
>
> Hmm, since you think that ";" is immediate, I guess you want an
> execution token that, when executed, performs the compilation
> semantics. You can get that as follows. Before the rest of the
> program, define:
>
> : ; postpone ; ; immediate
>
> Now you have an immediate ";" with an execution semantics that's the
> same as the compilation semantics, and you can tick it.
>
> >What I am saying is that I didn't have any warning that what I was
> >doing in MACRO: was going to be a problem.
>
> A system that would tell us all non-standard usages would be nice, but
> we don't have that. For now the solution is to test on as many
> systems as possible.
What you have above above are what I now have in the novice-package and call "disambiguifiers." Here is one disambiguifier copied out of the novice-package:
: if state @ 0= abort" *** no interpretation semantics for: IF ***"
postpone if ; immediate
This is just a bug-fix for ANS-Forth. Straight Forth doesn't need disambiguifiers because it is just straight Forth without ambiguity.
Earlier, I provided a list of what is needed for a cross-compiler. Let me slightly upgrade that list:
1.) LITERAL is vectored so the built-in outer-interpreter can be used and when it encounters a number in a TARG colon word it compiles that number into the target memory rather than the host memory.
2.) QUIT is vectored so the user can write his own outer-interpreter if he wants, and if it aborts on an error then control will go back to his outer-interpreter rather than to the built-in outer-interpreter (because ABORT and ABORT" call QUIT internally).
3.) The ability to take an xt and determine the following attributes:
what vocabulary it is in
immediate or non-immediate
smudged or not smudged
smudge-ready or not smudge-ready
4.) The ability to take an xt and modify those attributes.
5.) CONTEXT and CURRENT have to work like they did in Forth-83.
6.) FIND has to work correctly. The words in the standard have to be defined as being immediate or non-immediate. Words that have traditionally been immediate (everything requiring a disambiguifier in ANS-Forth) will be defined as immediate.
My primary goal with Straight Forth is to allow Forth programmers to write cross-compilers using a standard Forth system. As it currently stands, ANS-Forth has been sabotaged to prevent cross-compilers from being written (because this would be competition against Forth Inc. and MPE). It is possible to write a cross-compiler in various Forth systems, but each system has to be disassembled and the cross-compiler writer will need to rely on carnal knowledge. I did this with UR/Forth when I wrote MFX, but not a lot of carnal knowledge was necessary as UR/Forth was already pretty good out of the box. Modern Forth systems, such as VFX are a lot bigger than UR/Forth and hence disassembling them to obtain the needed carnal knowledge is more time-consuming and difficult. We shouldn't have to disassemble Forth systems though, because this is a waste of time. Also, the cross-compilers are not portable but obviously become vendor-specific due to relying on carnal knowledge. The goal with Straight Forth is just that we have a Standard that supports cross-compilers and does so in a straightforward manner that is well documented. People can write cross-compilers and they can be ported to any Straight Forth system. The cross-compiler itself will not be standardized in Straight Forth because there are many valid ways to write a cross-compiler (the most important choice is to either use the built-in outer-interpreter or write your own outer-interpreter, but there are other choices as well). There is room for creativity in writing a cross-compiler and it is not my business to tell people how to write their cross-compilers. Straight Forth only serves as a common host for these cross-compilers, making them possible.
I don't understand why Straight Forth is controversial. Other than Leon Wagner and Stephen Pelc, who is opposed to common Forth programmers writing cross-compilers? I wrote MFX for the MiniForth processor in 1994/1995 --- everybody on comp.lang.forth treats me like a criminal for doing this --- they howl: "That is not the Forth Way!!!" WTF???
Straight Forth can be a pretty simple Forth Standard --- about 1/2 the size of ANS-Forth and 1/8 the size of Forth-200x --- I'm adding a few features, such as quotations, that aren't related to cross-compilation, but Straight Forth is still pretty simple and straightforward --- a super-simple Forth Standard seems like a good thing to me, because Forth was traditionally super-simple (only with ANS-Forth did Forth become complicated, ambiguous and difficult or impossible to understand).
Most Forth programmers, including myself, originally got interested in Forth (rather than C) because of these reasons:
1.) Forth is simple and easy to understand. There is no syntax. The outer-interpreter is a short and straightforward function. Forth is to C as Go is to Chess.
2.) Forth is extensible. For example, in Forth structs can start with any offset, whereas in C they have to start with zero. As another example, a Forth system can be extended to generate code for a different processor (cross-compilation) using the built-in outer-interpreter, whereas in C a new compiler has to be written from scratch with its own super-complicated outer-interpreter.
3.) Forth is interactive. We can debug individual functions from the command-line (a REPL to use the Lisp term), whereas in C an entire program has to be compiled into an executable and then single-stepped through with a debugger.
I see no reason why Forth-200x and Straight Forth can't coexist as incompatible Standards --- their goals are completely different so they can't be combined into one Standard --- the Forth community can just diverge into two groups each with their own Standard and each with their own take on what Forth is:
1.) Forth-200x --- mind-numbingly complicated and utterly useless and opposed to general-purpose data-structures
2.) Straight Forth --- super-simple and useful as the host for a cross-compiler and supportive of general-purpose data-structures