Sorry, I have been too brief and too simplistic in the ROT example.
You have been right to point out that a stack annotation evaluation is
not an overdifficult task - not much more difficult than implementing
local variables.
But my main point was an inferencing and pattern matching
(unification) loop in the hilevel compiler. When I consider a threaded
or tokenized Forth dictionary not only as code segments, but also as
an internal Prolog-like database of lists containing xts, I could also
work with these lists.
Traditional Forth compilers use only the list head by
compiling/executing the header/xt. Thus the programmer himself has to
struggle with those damned stacks and each and every Forth word
becomes an optimization task. But what are computers for? Leave the
optimisations to a more clever compiler! Tail optimisations or finding
out the shortest/fastest sequence of stack reorderings or decisions
between calls or macros et cetera would be done by the compiler.
More interesting for applications perhaps would be the ease to
implement databases or associative structures.
But after that we wouldn't call it Forth any more, but ForLog or so
;-)
On 1 Apr 1998 06:46:00 GMT, wtanksle at sdcc10.ucsd.edu (William
Tanksley) wrote:
>In article <35209173.1533183 at news> kochenbu at khe.scn.de (Andreas Kochenburger) writes:
>>If I can still remember correctly (coming into "the years" meanwhile)
>>Prolog was once belonging to the Fifth Generation Language Project.
>>Prolog's main fantastic thing was its simple inference machine
>>combined with pattern matching or unification.
>>>F.ex. with unification in Forth we could define
>>: ROT (S a b c -- b c a ) ;
>>and be ready, because the compiler did evaluate the stack diagram by
>>matching variables of the same name.
>>I'm not sure I'd call that unification.
>>>IMO this - and a standardized OOF mechanism - on top of Forth would be
>>worth to be called a successor of Forth - perhaps 5th?
>>Perhaps. I'd rather call it Forth With Unification. :)
>>>Andreas
>>>P.S. Did anybody in the past try to power up the Forth compiler by
>>adding unification capabilities or evaluating stack annotations?
>>Yes. It (stack annotation) is suprisingly easy; I made Pygmy Forth do it
>in one night of programming (okay, I spent two debugging and repenting of
>my desire for features). My syntax went like this:
>>STACK: DUP a--aa
>STACK: 3REV abc--cba
>>There was also a version which was going to work anonymously right in the
>middle of a word; I never really got going on that one, simply because I
>was being SUCH a performance freak. Specifically, I was simply assembling
>pushes and pops in the appropriate order.
>>-Billy