Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site harvard.ARPA
Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!dcdwest!ittvax!decvax!genrad!panda!talcott!harvard!breuel
From: breuel@harvard.ARPA (Thomas M. Breuel)
Newsgroups: net.lang.forth
Subject: Re: redefine "+" ??
Message-ID: <375@harvard.ARPA>
Date: Sat, 9-Feb-85 14:10:02 EST
Article-I.D.: harvard.375
Posted: Sat Feb  9 14:10:02 1985
Date-Received: Mon, 11-Feb-85 04:47:15 EST
References: <2480@tekig.UUCP>
Organization: Harvard University
Lines: 21

> Do any of you FORTH experts out there know the answer to this:
> How do you redefine the "+" function (or any other operator) such that
> entering  "2 + 2" yields "4" instead of typing "2 2 +". Is this 
> impossible in FORTH ?
> thanks

To make it work interpreted, you have to build some kind of interpreter
for BASIC like expressions. I don't think that that's worth it.

To make it work compiled, you have to write a parser which translates
infix to postfix notation. The easiest way of doing that would probably
be to have a compiler word, say 'let', and have it do the parsing, e.g.

: ComputeIt let x = a * 9 + 3 ; ;

I believe, though, that this is hardly useful and very confusing. In
particular, if you don't have a mechanism for accessing local variables
by name, then computations involving data on the stack are very hard
to do.

							Thomas.