Deutsch   English   Français   Italiano  
<v8b04c$137lg$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!2.eu.feeder.erje.net!feeder.erje.net!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Stephen Pelc <stephen@vfxforth.com>
Newsgroups: comp.lang.forth
Subject: Re: Operator overloading?
Date: Tue, 30 Jul 2024 15:16:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <v8b04c$137lg$1@dont-email.me>
References: <a1aab44ee3b1b56c2f54f2606e98d040@www.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 30 Jul 2024 17:16:28 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d156e83f38ca0bbf57136bc03458ff1c";
	logging-data="1154736"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+/tgPJJvtcSts8P/ec/Io/"
User-Agent: Usenapp for MacOS
Cancel-Lock: sha1:0GptHNIaDNcank3WvBD0TRpDFho=
X-Usenapp: v1.27.4/l - Full License
Bytes: 2548

On 25 Jul 2024 at 08:30:58 BST, "minforth" <minforth> wrote:

> Forth has a lot of ‘redundant’ operators for e.g. arithmetic or
> stack operations, depending on the data type.
> 
> There was once an interesting approach for a type-bound layer
> on top of standard Forth:
> https://comp.lang.forth.narkive.com/rexLEBd0/strongforth-implemented-in-ans-forth
> 
> Unfortunately, the website for downloading strongforth.f
> is no longer available.
> 
> Or has anyone found another way to bundle/overload Forth operators?

The standard suggests/specifies that operators such as TO behave as if
they parse. Ignore that for the moment and define

variable operator

: to  1 operator !  ;  immediate

A child of VALUE is probably an immediate word that inspects OPERATOR
and compiles the fetch action if 0 or the store action if 1. This scheme can
be extended to support a wide range of operators, such as +TO INCR DECR
and so on. MPE has used this scheme for several decades with no tech
support issues. If you really want to to be fussy and avoid the use of the
"as if" rule for parsing, you can do something like (untested) the below
for TO. But why bother?

: to
  1 operator !  ' execute 
;  immediate

Stephen

-- 
Stephen Pelc, stephen@vfxforth.com
MicroProcessor Engineering, Ltd. - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)78 0390 3612,  +34 649 662 974
http://www.mpeforth.com
   MPE website
http://www.vfxforth.com/downloads/VfxCommunity/
   downloads