Sujet : Re: Back & Forth - Co-routines
De : melahi_ahmed (at) *nospam* yahoo.fr (ahmed)
Groupes : comp.lang.forthDate : 31. Jan 2025, 16:16:29
Autres entêtes
Organisation : novaBBS
Message-ID : <5170b8c9503530e924a5dc3619557093@www.novabbs.com>
References : 1 2 3
User-Agent : Rocksolid Light
On Fri, 31 Jan 2025 14:55:05 +0000, Hans Bezemer wrote:
On 31-01-2025 13:45, ahmed wrote:
Hi,
Thanks for this video and this implementation of locals.
You're welcome.
>
But what about the speed of execution?
>
Well, that will depend a lot. I mean - you're not very honest if you use
the built-in primitives of a Forth compiler. If you want to be honest,
use the reference implementation of Forth 200x. Because primitives
always win from high level code.
>
I measured a size penalty of 4 times and a performance penalty of 10
times when executing my example DIVIDE word. But then again - 4tH
doesn't support locals natively. So that is to be expected.
>
That is also the reason why I didn't include these findings. It would be
dishonest to compare a high level implementation where others offer a
implementation using primitives.
>
For instance, I'm sure you understand that this benchmark will come out
quite differently if I run it in 4tH.
>
As I said - you can convenience your way out of everything. And no
matter how fast your Forth, in the end raw assembly will beat
everything, including C.
>
So next time you want to make a point, yes, your native regular
expression engine *WILL* probably beat even the neatest and most
cleverly designed high level Forth matching routine.
>
I see that the proposed method is slower than the others
>
Any explainations?
>
Yeah, I understand why you like locals, because your stack juggling
skills need some polishing. But I got a video on that:
https://youtu.be/gfE8arB3uWk
>
First the preliminaries:
>
: ;then postpone exit postpone then ; immediate
: >zero dup xor ;
: spin swap rot ;
>
These are 4tH-ese, but I'm attached to them. ;-)
( n1 n2 n3 n4 -- n5)
: calc - >r - 100 r> spin */ ;
>
: tri_mf4
>r rot r> swap >r spin ( c b a R: x )
dup r@ >= if drop drop >zero rdrop ;then
over r@ >= over r@ < and if dup r> swap calc ;then drop
over r@ >= over r@ < and if over r> calc ;then
rdrop drop >zero
;
>
If you need more speed, inline CALC.
BTW, replace "RDROP" with "R> DROP" if you need to.
>
Hans Bezemer
I didn't do this comparison for anything but just to test the
possibility to integrate it (use it) in my forth programs which need
speed (fuzzy logic, neural networks).
I'm not arguing anything about forth or 4th, I'm just a user.
Thanks
--