2025-08-27 02:39:28 Almost done a general fixed point library :o 2025-08-27 02:40:02 All that's really left is implementing CORDIC for sin/cos 2025-08-27 02:40:24 How do I stop the bot 2025-08-27 02:46:51 type QUIT 2025-08-27 02:48:16 QUIT 2025-08-27 02:48:24 Testing testing 2025-08-27 02:48:28 Nope, that didnt work 2025-08-27 02:48:40 Nothing's working 2025-08-27 02:49:55 Looks like a bug. I'll check it out later. I'll shut the bot down for now 2025-08-27 02:53:26 Thank you <3 2025-08-27 02:53:45 It would be nice if it were opt-in also 2025-08-27 02:54:18 lf94: congrats! 2025-08-27 02:54:32 I still don't understand CORDIC properly 2025-08-27 02:54:52 I mean, it's not much of an accomplishment @ general fixed-point lib, but it's cute at 26 lines! 2025-08-27 02:55:01 I'm sure everyone's done this in forth at some point 2025-08-27 02:55:28 CORDIC doesn't seem too complicated. The core idea is you get "closer and closer" to the real answer 2025-08-27 02:55:58 My concern is if this is fast enough for my needs 2025-08-27 02:56:18 I'm probably going to do a LUT but we'll see 2025-08-27 03:55:54 lf94: Did you have any interaction with the bot before typing "Almost done <...>"? 2025-08-27 03:56:04 Maybe months ago 2025-08-27 03:56:06 lol 2025-08-27 03:56:55 Hm. I cannot reprodue the bug. It should not react to channel messages without : prefix - and it does not when I test it 2025-08-27 03:57:58 I could have interacted with it months ago 2025-08-27 03:58:01 It's a real possibility 2025-08-27 03:58:08 quit didn't work though 2025-08-27 03:59:04 Nope, I've modified and started it just today. You must've interacted with cleobuline's original bot :) 2025-08-27 03:59:24 Ah maybe 2025-08-27 05:37:49 :0 2025-08-27 05:37:55 i'm playing with sockets 2025-08-27 05:38:11 i know gforth has some socket thingy already though 2025-08-27 05:38:50 i have this c header file 2025-08-27 05:38:54 https://termbin.com/eh80 2025-08-27 05:39:04 which i have stolen from a random socket c example xd 2025-08-27 05:40:57 then is just to bind that in gforth: c-function socket make_inet_socket a n -- n c-function write-line write_line a n n -- n 2025-08-27 05:41:24 although it's not really write-line, but write 2025-08-27 05:42:21 s\" 127.0.0.1\0" drop 3000 socket constant sock s" oh..." sock write-line 2025-08-27 05:42:57 although maybe i should change the socket function to accept the str + count so i can just use s" instead of s\" + drop 2025-08-27 05:44:00 i was wondering if i could play with the irc protocol in forth 2025-08-27 05:45:21 what would be cooler is xlib 2025-08-27 07:32:50 re CORDIC, I got slightly inaccurate results by calculating the K value for the max number of digits I wanted then truncating for less digits 2025-08-27 07:33:18 IIRC, it's not that simple 2025-08-27 14:02:25 What about an `if` word that reads buffer until `then`, runs it, checks stack for `true`, and then runs stream from `then` to `end` if it exists. 2025-08-27 14:02:40 Maybe frowned upon that a word reads the stream like that. 2025-08-27 14:06:05 sure, I guess you could do it, you could even manage to have the compiled version of it, but that would mean that your "if" can only be fed from "local" code. That's not very composable. For example, you can't do ": foo if bar then ;" anymore 2025-08-27 14:06:41 Hm 2025-08-27 14:07:00 depending on what "bar" is? 2025-08-27 14:07:28 I actually have a two-pass system, so `if` gets parsed to Word(if) before run. 2025-08-27 14:07:57 But yea you can't "cut" `then` without an `end` 2025-08-27 14:10:25 ... so "if" gets compiled in a "traditional" manner if no "end" is encountered down the stream? That sounds like a good bug inducer 2025-08-27 14:11:10 Well your example had no `end` or `endif` 2025-08-27 14:11:31 But there's no syntax check, so I guess it would just be buggy or weird. Will have to try a bit more. 2025-08-27 14:11:40 I was giving an example of "traditional" Forth code, in which there is no "end" 2025-08-27 14:11:46 Oh 2025-08-27 14:11:54 and in which the "condition" comes from the parameter stack 2025-08-27 14:11:59 True 2025-08-27 14:12:35 Since `if` would run stream between `if` and `then`, I guess you could do a void word to just check the already existing stack entry. 2025-08-27 14:12:55 Like `if dup then . endif` 2025-08-27 14:13:47 that could work, yes 2025-08-27 14:15:10 +1 2025-08-27 14:17:48 but hey, wait, isn't your proposal just syntactic sugar? If you make "if" into a noop, give "then" the meaning of traditional "if" and give "endif" the meaning of traditional then, you end up with pretty much what you want, without having to resort to stream peeking, right? 2025-08-27 14:26:28 That is an interesting point. 2025-08-27 14:28:17 Lemme write that down. 2025-08-27 14:28:52 Funny that `if` would be noop. 2025-08-27 14:29:41 Isn't original `if` stream peeking tho? How would it know which chunk to run? 2025-08-27 14:31:19 it doesn't. It "knows" because it has a ( f -- ) signature on the stack. Even if you implemented your stream peeking thing, it would require the "peeked" code to have a ( -- f ) signature, or else break the stack. In the end, it makes no difference 2025-08-27 14:36:07 what you *could* do if you implemented your stream peeking thing is have "if" be the starting point of stack signature check. If PS doesn't grow by exactly one, you could abort with "bad condition signature". It would be a fancy seatbelt 2025-08-27 14:37:07 (but then again, no stream peeking required, just do like I described above, but "if", instead of being a noop, is a PS level marker) 2025-08-27 14:45:41 Hm 2025-08-27 14:56:28 In my design for a "next-gen Forth" I considered making 'end' take an xt on stack, so it can finish literally any construct 2025-08-27 14:57:08 Because having a million 'end' words is a bit redundant 2025-08-27 14:57:37 And likewise there should probably be some tracking of syntax depth so you don't have an unbalanced word 2025-08-27 14:57:58 I achieve in zenv with a variable to remember initial stack depth at : 2025-08-27 15:01:08 If you use `end` instead of {}, you might end up with a million 2025-08-27 15:06:37 Well end or } 2025-08-27 15:07:06 Up to you, I thought something that looks a little like Lua suited Forth better but I know some people prefer symbolic syntax more 2025-08-27 15:10:59 Oh you mean like endif, endloop, etc? 2025-08-27 15:11:19 Yes, agree otherwise, Lua-like Forth-like :) 2025-08-27 16:20:59 veltas: sounds nice 2025-08-27 16:21:17 veltas: 'end' could be anything right? 2025-08-27 16:29:11 Yeah 2025-08-27 17:19:54 veltas: IRC is much simpler than the X-Windows protocol 2025-08-27 17:21:56 veltas: hmm, so you'd have if{ do{ begin{ }else{ and a single } to finish them all? 2025-08-27 22:14:10 xentrac: Re IRC / X wrong person 2025-08-27 22:14:40 I'd do e.g. if ... then ... end 2025-08-27 22:15:04 I don't think {} look good for forthy langs but that's my very subjective opinion 2025-08-27 22:15:59 if .. then .. elseif .. then .. else .. end probably 2025-08-27 22:16:26 Like Lua really, I think it's a nicer wordy language 2025-08-27 22:21:24 forthBot: 2 2 * . 2025-08-27 22:21:25 4 2025-08-27 22:21:31 xentrac: Here's some doodle I found https://termbin.com/7e2x 2025-08-27 22:23:08 The parens are just the braces concept I wrote that checks the result is exactly 1 deeper than start of parens, or does nothing if it's a 'release build' 2025-08-27 22:31:20 I think really I'd rather write C than that language though 2025-08-27 22:32:19 I still haven't tried out the COMFY-65 control structures in a Forth yet 2025-08-27 22:33:02 I think shortcut booleans and multiple exits from a loop will pay off bigtime 2025-08-27 22:33:21 that doodle does indeed look very much like Lua 2025-08-27 22:34:11 are the parens here intended to be the operand-stack-checking thing you posted previously? 2025-08-27 22:34:17 Yep 2025-08-27 22:34:26 https://veltas.co.uk/blog/forth-expr.htm 2025-08-27 22:34:34 in November 2025-08-27 22:35:22 You could achieve my doodle in a standard forth probably 2025-08-27 22:35:25 yeah 2025-08-27 22:35:26 Or most standard forths 2025-08-27 22:35:35 why only most? 2025-08-27 22:37:15 I just hesitate to say it's achievable in all, but maybe it is 2025-08-27 22:37:38 oh olle left, i was reading the irc logs and he was talking about an if word 2025-08-27 22:37:38 Sorry sort of in two conversations right now 2025-08-27 22:37:41 last night thinking about multiple return values and compilers I realized something interesting. Forth having two stacks allows the return of variable-sized data structures in the same way as Ada's secondary stack: https://docs.adacore.com/gnat_ugx-docs/html/gnat_ugx/gnat_ugx/the_stacks.html 2025-08-27 22:38:15 mine is like: if 1 then "is true" else "is false" endif 2025-08-27 22:38:17 which is difficult to achieve with a single framed stack like C implementations normally use 2025-08-27 22:38:20 if you just put if then ... endif the test is taken from the stack 2025-08-27 22:38:25 right 2025-08-27 22:38:55 the problem is that if i add some sort of macros that evaluate a list, that if will not work 2025-08-27 22:39:23 I was thinking about the fairly common case where you want to return a success/failure flag and also some meaningful value, which is easy in Forth and troublesome in most languages 2025-08-27 22:39:26 well i can "compile" it, but i won't be able to dynamically generate it's body 2025-08-27 22:40:03 in Lua you can do it but it's a little bit difficult to write higher-order functions that deal with multiple return values 2025-08-27 22:42:32 Also not very efficient in the Lua VM 2025-08-27 22:43:34 Lists of stuff aren't as efficient as tables, better to just use tables if you've got more than a normal amount of parameters/returns 2025-08-27 22:45:24 hmm, how do you disassemble the bytecode for a function in LuaJIT? 2025-08-27 22:46:38 one byte at a time /rimshot 2025-08-27 22:48:32 require("jit.util").funcinfo(function_name).bytecode 2025-08-27 22:48:38 according to Mr GPT 2025-08-27 22:49:43 that's nil 2025-08-27 22:49:56 but funcinfo is at least a function... 2025-08-27 22:51:21 for k in pairs(funcinfores) ... 2025-08-27 22:51:23 https://wiki.facepunch.com/gmod/jit.util.funcinfo doesn't look promising 2025-08-27 22:51:56 Also said command line -jdump=bc 2025-08-27 22:52:04 for lua bytecode 2025-08-27 22:52:33 oh, I think that does work 2025-08-27 22:52:44 funcbc maybe 2025-08-27 22:53:16 hmm, maybe not