IRC Log - 2025-05-19 - ##forth

Channel: ##forth
Total messages: 263
Time range: 00:02:29 - 23:58:33
Most active: anthk_ (92), vms14 (58), veltas (50)
00:02:29 ##forth <veltas> What are you trying to do?
00:03:01 ##forth <veltas> Multiply 32-bit numbers?
00:04:35 ##forth <veltas> You can define M*/ using M* and M/ although I don't fancy trying right now, I did do it once
00:04:41 ##forth <veltas> I think it might be defined that way in gforth
00:06:42 ##forth <anthk_> https://termbin.com/wnzh
00:06:57 ##forth <anthk_> m*/ operated with doubles right?
00:10:52 ##forth <anthk_> under pforth
00:10:52 ##forth <anthk_> 65536. 2 1 m*/ d. 131072 ok
00:11:18 ##forth <veltas> Looks like gforth doesn't have D*
00:12:01 ##forth <anthk_> also just in case
00:12:03 ##forth <anthk_> 4294967295. 2 1 m*/ d. 8589934590 ok
00:12:28 ##forth <anthk_> no m*/ at eforth :|
00:12:45 ##forth <anthk_> pforth runs under 32 bit
00:12:59 ##forth <anthk_> -1 u. 4294967295 ok
00:14:13 ##forth <veltas> If you see the link I posted it has a definition of M*/ which you should have most or all of the words in eforth for
00:14:33 ##forth <cleobuli_> bonsoir
00:16:07 ##forth <anthk_> another non-gforth source?
00:16:56 ##forth <veltas> Sorry?
00:17:21 ##forth <cleobuline> me too
00:20:09 ##forth <anthk_> heh https://www.forth.org/fd/FD-V07N5.pdf
00:23:11 ##forth <cleobuline> forthBot: 1 127 << .
00:23:11 ##forth <forthBot> 170141183460469231731687303715884105728
00:24:11 ##forth <anthk_> forthBot: SEE <<
00:24:12 ##forth <forthBot> : << << ;
00:24:23 ##forth <cleobuline> haha
00:26:15 ##forth <anthk_> forthBot needs no floats then
00:28:04 ##forth <cleobuline> forthBot: 170141183460469231731687303715884105728 NUM-TO-BIN CR
00:28:05 ##forth <forthBot> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00:28:22 ##forth <cleobuline> :)
00:29:06 ##forth <anthk_> cleobuline: https://en.wikipedia.org/wiki/Schizophrenic_number
00:29:44 ##forth <anthk_> I did that once in lisp but I woudn't be able to do yet in forth
00:29:55 ##forth <veltas> anthk_: I found this in my files https://termbin.com/3o2q
00:30:55 ##forth <veltas> If you want a non-gforth implementation
00:31:47 ##forth <cleobuline> :-)
00:32:04 ##forth <cleobuline> i will try
00:32:50 ##forth <anthk_> uhm
00:32:50 ##forth <anthk_> 65536. pi* d.
00:32:51 ##forth <anthk_> 205887 ok
00:33:48 ##forth <anthk_> : pi* 355 113 m*/ ( n -- n * pi ) ;
00:33:56 ##forth <vms14> I have to practice more with forth and then find a forth junior job
00:34:24 ##forth <veltas> I'd be amazed if anyone found any Forth jobs out there
00:34:38 ##forth <vms14> stop destroying my dreams
00:34:58 ##forth <anthk_> soon we will need Forth back
00:35:14 ##forth <anthk_> small computers, EMP/low power resistant
00:35:14 ##forth <veltas> Well if you have a job where any language will do, and nobody will review/maintain your code apart from you, you can use Forth
00:35:16 ##forth <vms14> you mean collapseOS?
00:35:20 ##forth <veltas> Or use Forth on throwaway stuff
00:35:38 ##forth <anthk_> not so bad, but we had a blackout in Spain a few weeks ago
00:35:46 ##forth <veltas> I used Forth at work to do a simple job in a script that nobody else will ever see
00:35:57 ##forth <vms14> I'm spanish too lol
00:36:01 ##forth <anthk_> FM radio worked, but computers had to be either 5V phones, or stuff like hospitals and cell towers with generators
00:36:02 ##forth <vms14> from bcn
00:36:16 ##forth <anthk_> vms14: just run whois
00:36:28 ##forth <anthk_> ah, not from the unix server I'm ssh at
00:36:28 ##forth <anthk_> :|
00:36:33 ##forth <anthk_> well, basque countr
00:37:38 ##forth <anthk_> in the blackout gopher and gemini protocols worked. TLS is complex, but gopher and IRC, once you have sockets supports, it's a dumb exercise
00:38:04 ##forth <anthk_> gforth has sockets, but I think pforth doesn't have them
00:38:14 ##forth <anthk_> (networking ones, not local unix)
00:38:49 ##forth <veltas> pi* is a cool definition
00:38:53 ##forth <veltas> I like that
00:38:56 ##forth <anthk_> veltas: I'm lazy
00:39:18 ##forth <anthk_> I came from Unix philosophy, keep it simple, stupoid;
00:39:35 ##forth <veltas> You could also define PI as a fraction e.g. 355 113 2CONSTANT PI 65536. PI M*/ D.
00:40:23 ##forth <veltas> Forth is definitely part of the 'keep it simple' ecosystem
00:42:07 ##forth <thrig> some have done complicated things on top of unix
00:44:24 ##forth <veltas> The stuff that I consider 'UNIX' is very very dead, and for good reasons
00:47:23 ##forth <veltas> One of the most 'alive' things about UNIX is C
00:58:54 ##forth <vms14> there is a way to avoid pick?
00:58:57 ##forth <vms14> : l ( a b c -- a a b c ) 2 pick -rot ;
00:59:08 ##forth <vms14> I'm making the exercises of the book
00:59:40 ##forth <vms14> it says you should use as few words as possible
01:05:54 ##forth <vms14> oh the site gedamo gave me gives solutions
01:06:09 ##forth <vms14> rot dup 2swap
01:06:19 ##forth <vms14> never thought of 2swap
01:09:29 ##forth <vms14> that tool is kind of amazing
01:09:50 ##forth <vms14> it can give you several different solutions, I wonder how it is implemented
01:16:08 ##forth <vms14> the last one was cool
01:16:11 ##forth <vms14> : n ( a b c -- a a b b c c ) rot dup 2swap 2dup rot ;
01:16:28 ##forth <vms14> I should actually practice more like that
01:17:01 ##forth <vms14> https://paste.c-net.org/StripesPlanner
01:18:06 ##forth <vms14> and that site is giving me the same answer for the n so I did it right
01:18:19 ##forth <vms14> although I would never thought of swap2 if it weren't for that site
01:18:25 ##forth <vms14> 2swap*
01:19:04 ##forth <anthk_> pforth can show the builtings of some operations
01:19:09 ##forth <anthk_> with help and see
01:19:40 ##forth <anthk_> with
01:19:41 ##forth <anthk_> S" HELP" ENVIRONMENT?
01:20:02 ##forth <anthk_> from 'help nip;
01:20:03 ##forth <anthk_> '
01:20:03 ##forth <anthk_> * drop the value under the top of stack, inverse of => TUCK
01:20:04 ##forth <anthk_> simulate: : NIP SWAP DROP ;
01:22:13 ##forth <vms14> the exercises were cool
01:23:20 ##forth <vms14> I guess I should try more of the style of the last one
01:23:58 ##forth <vms14> the book says you cannot master forth without mastering the stack, which I believe to be true
01:51:13 ##forth <anthk_> this forth might be closer to forth79 https://github.com/howerj/libforth
02:24:11 ##forth <forthBot> Environment for anthk_ inactive, freeing...
02:28:05 ##forth <forthBot> Environment for cleobuline inactive, freeing...
12:39:46 ##forth <vms14> anthk_ that libforth seems cool
12:40:00 ##forth <vms14> it has a lot of comments explaining everything
13:35:01 ##forth <xentrac> vms14: I'd suggest F83 and GForth as exemplary
13:36:58 ##forth <xentrac> vms14: you can create code words in assembly in the repl in DEBUG.COM
13:37:55 ##forth <xentrac> also it turns out that a lot of old operating systems had this functionality
13:38:17 ##forth <xentrac> RT-11, the DEC 10/50 monitor, ITS, TENEX
13:39:12 ##forth <xentrac> most of the time it doesn't mean the REPL is about to crash, and crashes aren't scary, just annoying
13:40:08 ##forth <xentrac> veltas: generally the difference between 0/1 and -1/0 is just an inc or dec
13:43:21 ##forth <xentrac> I assume the reason for using -1 for true was so that you don't need separate bitwise and Boolean not
13:45:28 ##forth <xentrac> 21:37 < veltas> Very few embedded controllers are as simple to control GPIO as setting some addresses to 1 or 0, or -1 and 0.
13:46:35 ##forth <xentrac> well, STM32's "bit banding" gives you an area of the memory map where each byte is a hardware alias for a single bit
13:46:45 ##forth <xentrac> and I think it covers the GPIO space
13:47:36 ##forth <xentrac> so you ought to be able to on and off GPIO bits there? I forget if other ARM microcontrollers (other than the abundant STM32 clones) support bit-banding
13:49:15 ##forth <xentrac> you could make things like led on work polymorphically with double dispatch: : on 1 swap execute ; : off 0 swap execute ;
14:03:57 ##forth <xentrac> sorry, bit-banding maps each bit to a *word*: https://developer.arm.com/documentation/100166/0001/Programmers-Model/Bit-banding/About-bit-banding
14:04:09 ##forth <xentrac> and it's not STM32-specific
14:11:25 ##forth <vms14> https://github.com/ForthHub/F83
14:12:03 ##forth <xentrac> yeah, that F83
14:22:40 ##forth <anthk_> vms14: no doubles on libforth I guess
14:26:03 ##forth <vms14> you could add them I guess
14:26:16 ##forth <vms14> I would like a forth implementation that I could mess with
14:26:27 ##forth <vms14> but I guess the best option is to make your own
14:27:00 ##forth <xentrac> I think the best option is GForth
14:27:01 ##forth <vms14> I want to play with xlib in forth
14:27:19 ##forth <xentrac> I haven't tried doing xlib in it tho
14:27:24 ##forth <vms14> xentrac I do not know how to add -I flags and the others, only the -l with add-lib
14:27:26 ##forth <xentrac> maybe that would change my mind
14:28:01 ##forth <vms14> an option could be making some object file or alike, but it's sad
14:28:52 ##forth <vms14> I added curses bindings, but making some simple wm in forth or just creating windows should be fun
14:29:14 ##forth <vms14> https://paste.c-net.org/ShamefulSquirm
14:29:21 ##forth <vms14> those are the curses bindings
14:29:36 ##forth <anthk_> vms14: -I /usr/include or -I /usr/local/include or -I /usr/X11R6/include
14:29:49 ##forth <vms14> I know
14:30:00 ##forth <vms14> now how do I add those flags in gforth's c bindings
14:30:54 ##forth <vms14> it uses libtool to create them
14:30:54 ##forth <vms14> so maybe I could learn how libtool works and add them
14:31:04 ##forth <vms14> but it's weird that it only provides add-lib for the -l flags
14:31:41 ##forth <anthk_> on eforth, the words from yesterday didn't fully work
14:41:06 ##forth <vms14> I see a wm in forth :0
14:41:15 ##forth <xentrac> veltas: yeah, that'll be awesome!
14:42:40 ##forth <xentrac> I mean vms14!
14:44:41 ##forth <vms14> but it's in a forth called fox
14:44:49 ##forth <vms14> there is also bigforth + minos
14:45:11 ##forth <vms14> https://bernd-paysan.de/bigforth.html
14:49:15 ##forth <vms14> this is a bit interesting I guess
14:49:23 ##forth <vms14> it uses a server and runs in gforth
14:52:24 ##forth <xentrac> I like Bigforth but I think he may have stopped working on it
14:55:21 ##forth <anthk_> bigforth was created by some Enlightenment user maybe
14:55:22 ##forth <vms14> I just wanted to have fun while learning forth :/
14:56:17 ##forth <vms14> if I try to make my own will be in perl or js which do not have memory and then I will refuse to fake it with arrays
14:56:33 ##forth <anthk_> vms14: use eforth and muxleq
14:56:39 ##forth <vms14> but if I refuse then I will just create a different thing
14:57:07 ##forth <vms14> I was taking a look at it
14:57:08 ##forth <vms14> https://github.com/chochain/eforth
15:01:07 ##forth <anthk_> vms14: that's the one for arduino
15:01:18 ##forth <anthk_> the one for muxleq it's https://github.com/howerj/muxleq
15:02:19 ##forth <anthk_> after compiling muxleq, edit muxleq.fth and enable floats at constant opt.float
15:02:24 ##forth <anthk_> set it to 1 at the file
15:02:47 ##forth <anthk_> among the 1 constant opt.better-see and opt.control contants
15:03:03 ##forth <anthk_> then to create a new subleq image: ./muxleq ./muxleq.dec < muxleq.fth > new.dec
15:03:27 ##forth <anthk_> I miss m*/ but I might implement it *correctly* one day
15:06:22 ##forth <veltas> Did you try my M*/ ?
15:06:32 ##forth <veltas> Or gforth's?
15:09:28 ##forth <anthk_> yes, but didn't fully work I think
15:09:37 ##forth <anthk_> does it work well with doubles?
15:10:02 ##forth <anthk_> I need to check that m*/ again
15:27:24 ##forth <veltas> Which one?
15:27:57 ##forth <veltas> I don't know 100% if my one works, but I think gforth's should
15:28:10 ##forth <veltas> If you have a case that fails on mine tell me and I don't mind looking into it
15:28:32 ##forth <veltas> Bear in mind M*/ in standard doesn't support negative denominators
15:49:34 ##forth <anthk_> ah, TIL
15:50:52 ##forth <anthk_> not an issue by design
15:51:56 ##forth <anthk_> eforth under subleq/muxleq it's nice once you add some missing stuff
16:02:50 ##forth <anthk_> not much, I just miss m*/
16:04:22 ##forth <anthk_> well, on pforth -200000. 2 1 m*/ d. -400000 ok
16:04:57 ##forth <anthk_> and not an issue for the denominator, I would reverse the parts
16:05:01 ##forth <anthk_> by negating both
16:07:46 ##forth <anthk_> uhm it has */mod
16:11:39 ##forth <anthk_> so
16:11:46 ##forth <anthk_> : */ */mod nip ;
16:12:58 ##forth <anthk_> no doubles but */ was missing
16:13:44 ##forth <anthk_> and I have no d* d/ neither, but if m*/ supported doubles it would be the best thing ever
20:31:45 ##forth <anthk_> is this https://termbin.com/ajht a right approach?
22:31:58 ##forth <veltas> xentrac: I wouldn't claim that -1 as true is expensive, just more expensive than 1, and I've not profiled this exhaustively but it just seems to be so from writing e.g. x86 and Z80 Forth kernels
22:32:41 ##forth <veltas> I wouldn't be surprised if it's just a larger binary and no impact on performance in latest CPUs, and we're talking about optimising something that's sort of inherently slow now anyway ... the Forth stack model
22:33:16 ##forth <veltas> Not slow but just not the best way to talk about a CPU with a decent number of registers
22:40:55 ##forth <anthk_> well on eforth: 50000. pi* d.
22:40:55 ##forth <anthk_> 157079 ok
22:41:17 ##forth <anthk_> that with the code from https://termbin.com/ajht
22:42:12 ##forth <anthk_> it should be um*/ and maybe ud* ud/ by definition
22:43:19 ##forth <anthk_> on pfrth
22:43:23 ##forth <anthk_> pforth
22:43:24 ##forth <anthk_> -100.000 50 100 m*/ d. -50000 ok
22:43:37 ##forth <veltas> um/mod can do arbitrary length division
22:43:40 ##forth <anthk_> on eforth, totally mangled
22:43:53 ##forth <anthk_> mmm true, and nip
22:43:55 ##forth <anthk_> or swap drop
22:44:05 ##forth <veltas> And D-
22:44:16 ##forth <veltas> And um* can do arbitrary length multiplication etc
22:44:48 ##forth <veltas> I find it interesting that in Forth these sorts of things are exposed, most languages have no way to do this
22:45:17 ##forth <veltas> But it's standard on pretty much all arch's now to provide mixed precision mul/div
22:46:32 ##forth <veltas> d*'s stack comment is wrong
22:46:56 ##forth <veltas> That would be ( d n -- d*n )
22:47:12 ##forth <anthk_> yes, I realized
22:51:22 ##forth <anthk_> I have um/
22:54:37 ##forth <xentrac> veltas: yeah, the extra dec is definitely nonzeo expense
22:55:35 ##forth <xentrac> wrt the Forth stack model, I think it's inherently slower for straight-line code but inherently faster for subroutine call and return
22:55:44 ##forth <veltas> True
22:56:17 ##forth <xentrac> (on a machine with a decent number of registers, at least)
23:02:24 ##forth <veltas> This is one of the reasons I came back to Forth, was optimising my assembly code for size
23:02:42 ##forth <xentrac> yeah, it's also good for size
23:02:48 ##forth <veltas> And it occurred to me that the most efficient way to pass things around was to leave them on the stack
23:03:02 ##forth <veltas> Even though that's not actually a common style for Forth
23:03:28 ##forth <xentrac> isn't it?
23:03:41 ##forth <veltas> I mean specifically to leave stuff on stack after processing it
23:03:58 ##forth <xentrac> oh, I see
23:04:03 ##forth <xentrac> you're right
23:04:12 ##forth <veltas> It's less conventional to do that, although there's plenty of exceptions. Some dialects do this a lot though.
23:04:38 ##forth <veltas> It's faster and less memory to leave stuff on stack, but the rules quickly become convoluted
23:05:06 ##forth <veltas> smaller program size I mean
23:05:08 ##forth <xentrac> so for example * + would leave the product and sum of the same two values on the stack?
23:05:25 ##forth <veltas> Could do
23:05:53 ##forth <veltas> Or in the 'accumulator'
23:06:04 ##forth <veltas> That's what an accumulator is for, after all
23:06:18 ##forth <veltas> Lots of ways to skin a cat
23:07:08 ##forth <xentrac> it accumulates cat skins
23:09:07 ##forth <cleobuli_> forthBot: LOAD "ini.fth"
23:09:08 ##forth <forthBot> Fichier chargé
23:09:13 ##forth <cleobuli_> forthBot: CAT
23:09:13 ##forth <forthBot> /_/
23:09:14 ##forth <forthBot> ( o.o )
23:09:14 ##forth <forthBot> > ^ <
23:10:21 ##forth <vms14> forthBot: :D
23:10:51 ##forth <forthBot> Unknown word: :D
23:10:51 ##forth <forthBot> Unknown word: "test.fth"
23:10:58 ##forth <vms14> oh case sensitive
23:11:01 ##forth <veltas> skin concatenation
23:12:10 ##forth <veltas> Sorry vms14, it's 6-bit ASCII o' clock
23:17:44 ##forth <anthk_> 200.000 2 1 m*/ d.
23:17:45 ##forth <anthk_> 400000 ok
23:18:26 ##forth <anthk_> unsigned stuff works, not with neg values
23:18:44 ##forth <anthk_> at least under eforth
23:18:46 ##forth <anthk_> pforth works
23:24:53 ##forth <cleobuli_> vms14: all words in forthBot are capitalized
23:25:35 ##forth <cleobuli_> forthBot: LOAD "ini.fth"
23:25:35 ##forth <forthBot> Fichier chargé
23:25:43 ##forth <cleobuli_> forthBot: :D
23:25:53 ##forth <cleobuli_> forthBot: CR
23:25:53 ##forth <forthBot> :D
23:26:04 ##forth <cleobuli_> forthBot: :D CR
23:26:04 ##forth <forthBot> :D
23:27:49 ##forth <cleobuli_> forthBot: CREDIT
23:27:49 ##forth <forthBot> Brought to you by Cleobuline https://github.com/cleobuline/forth-bot-gmp-irc-threaded-multi-users/tree/main Site https://labynet.fr
23:28:17 ##forth <anthk_> well, pforth works great
23:28:18 ##forth <anthk_> 100.000 pi* pi/ d. 100000 ok
23:28:57 ##forth <anthk_> : pi* 355 113 */ ;
23:29:04 ##forth <anthk_> : pi/ 113 355 */ ;
23:29:58 ##forth <anthk_> I'll keep eforth for niche stuff
23:30:01 ##forth <anthk_> under subleq
23:58:33 ##forth <MrMobius> You might get -1 for free the same as 1 if you have a constant generator register