Sujet : Re: Operator overloading?
De : minforth (at) *nospam* gmx.net (minforth)
Groupes : comp.lang.forthDate : 29. Jul 2024, 08:22:18
Autres entêtes
Organisation : novaBBS
Message-ID : <8e3520e45725c306aa0bf8fe9390e5ba@www.novabbs.com>
References : 1 2 3 4 5
User-Agent : Rocksolid Light
On Sat, 27 Jul 2024 20:55:48 +0000,
albert@spenarnc.xs4all.nl wrote:
Personnaly I hate TO and +TO, but if you decide to use them, you
could as well go all the way.
I know what you mean. For global values I follow you.
For locals it becomes annoying IMO to readjust operators in the
code body to changed data types. Contrived dumb example
\ for single item
: TT { f: dat -- res } <- local type: f:
pi dat f* ; <- suitable operator: f*
\ for vector/matrix
: TT { m: dat -- res } <- local type: m:
pi dat m.* ; <- suitable operator: m.*
With TO
: TT { <type>: dat -- res } <- replace <type> with suitable type id
pi *to dat dat ; <- no adjustment required, no errors
While this example may look dumb, things look different when you
have many non-trivial words.