Sujet : Re: Operator overloading?
De : stephen (at) *nospam* vfxforth.com (Stephen Pelc)
Groupes : comp.lang.forthDate : 30. Jul 2024, 16:16:28
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v8b04c$137lg$1@dont-email.me>
References : 1
User-Agent : Usenapp for MacOS
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.comMicroProcessor Engineering, Ltd. - More Real, Less Time133 Hill Lane, Southampton SO15 5AF, Englandtel: +44 (0)78 0390 3612, +34 649 662 974http://www.mpeforth.com MPE website
http://www.vfxforth.com/downloads/VfxCommunity/ downloads