Sujet : Re: Operator overloading?
De : mhx (at) *nospam* iae.nl (mhx)
Groupes : comp.lang.forthDate : 26. Jul 2024, 12:25:35
Autres entêtes
Organisation : novaBBS
Message-ID : <5a25c81bccd1ca3569a87dd2408e96b6@www.novabbs.com>
References : 1 2 3 4 5 6
User-Agent : Rocksolid Light
On Fri, 26 Jul 2024 8:33:41 +0000, minforth wrote:
On Thu, 25 Jul 2024 9:06:03 +0000, mhx wrote:
[..]
LET t0=6*ti1*2^DOUBLE[I]:
>
I gather the (integer) 6 is autoconverted. Why not I as well?
The problem is that I must be understood as an integer, not a
float, as it would be by default. It probably works fine without
double[] here. Functions with mixed types are a nuisance.
The '6' will become a float by default and that is just what is
needed.
[..]
If I understand correctly, the intelligence is within LET
which decides which operator matches the type of the operands.
LET is the XOPG entry word and converts standard formulas
to Forth with the asked for floating or integer numeric precision.
Can you use global VALUEs (or even VARIABLEs) within LET?
Or does it only work with local types?
It works with variables, values, and locals of any type. Arrays
of standard & iForth types are also supported.
That it can work with locals is actually the unique feature
here :--)
LET is not written in standard Forth. It is based on
Wil Baden's OPG (Operator Precedence Grammar), but there are
additions so that XOPG can be used as a SPICE expression
evaluator/compiler.
-marcel