2024-10-08 03:16:06 i think you could do link time execution in c 2024-10-08 03:17:37 at that point it has all of the object files in memory, it should be able to evaluate anything and use the result to initialize stuff 2024-10-08 04:21:14 they might be object files for a different architecture, but sure, that's certainly a thing you could add 2024-10-08 04:43:01 sure, it would have to be 2024-10-08 04:43:14 something approaching emulation 2024-10-08 04:43:23 hit the enter key too soon 2024-10-08 15:10:53 I was looking the code of the snake and I do not understand why it works 2024-10-08 15:10:53 [char] w down direction <> and of up to direction endof 2024-10-08 15:11:02 this is inside a case 2024-10-08 15:11:49 it was first [char] w of ... endof. which I understand it works 2024-10-08 15:12:28 but then I added direction <> and it works comparing both the character to w and checking if the direction is not down 2024-10-08 15:13:09 the code is in read-char https://termbin.com/syl0 2024-10-08 15:14:35 read-key * 2024-10-08 15:21:46 it checks if char is w and ignores it if it's going down,. it works but for some reason I assumed [char] w will return me the comparison of the key and I just use and with this. but case should not return that comparison value 2024-10-08 15:24:46 is case really comparing key [char] w = and giving that result on the stack? 2024-10-08 15:28:25 iirc case is just a shorthand for if ... else ... if ... else ... if ... else ... then then then 2024-10-08 15:29:16 yeah but there is no = and seems to be applied correctly 2024-10-08 15:29:37 [char] w down direction <> and of 2024-10-08 15:31:19 read-key case [char] w down direction <> and of up to direction endof ... 2024-10-08 15:32:48 "down direction <>" will net you either -1 or 0. then that is anded with 0x77 2024-10-08 15:33:10 so if direction is already down, then you have "0 of ..." 2024-10-08 15:33:21 if direction is not already down, then you have "[char] w of ..." 2024-10-08 15:33:52 oh 2024-10-08 15:34:22 so is smart code without me even realizing 2024-10-08 15:34:40 well that depends on whether it's what you wanted :) 2024-10-08 15:34:47 it works xd 2024-10-08 15:35:03 ty, I did not understand what was happening 2024-10-08 15:35:50 initially it was only [char] w, but then I added the option to ignore going back, and assumed for some reason I would get that comparison on the stack 2024-10-08 15:38:08 you did, you git it here: "down direction <>" and then you anded the result with [char] w 2024-10-08 15:40:06 yeah but I was expecting a implicit [char] w = was happening so I just thought I would have a flag on the stack and I would and that, but in the end it turns out that I and the [char] w with a 1 leaving all the flags that are true in [char] w, essentially returning that character if the other condition is true 2024-10-08 15:40:30 with a -1* 2024-10-08 15:40:42 so it was just a coincidence that works 2024-10-08 15:40:50 funny 2024-10-08 15:42:02 and it's a cool trick I learn while using it by accident 2024-10-08 15:50:53 it does mean the case can be hit by mistake if the input to the case can ever be 0 2024-10-08 15:52:44 if your snake is traveling down and you enter ctrl-2, does the snake reverse direction? 2024-10-08 15:55:44 in my fake computer it does not seem to do 2024-10-08 15:56:09 but I wonder if I ever achieve to send the ctrl-2 to termux with that phone keyboard so I cannot test it 2024-10-08 15:57:20 it should work at least in debian with libtool-bin and gforth 2024-10-08 15:57:59 gforth this file https://termbin.com/syl0 2024-10-08 15:59:09 i guess i could actually install and try gforth one of these days 2024-10-08 15:59:34 it's funny because it's some sort of unfinished, I wanted to add timed actions using the last time executed and current time, but I'm just using the timeout of curses xD 2024-10-08 15:59:43 which means that if you press a key the snake runs 2024-10-08 16:00:15 gforth is cool to play with forth and some c libraries 2024-10-08 16:00:28 the ffi is the easiest I ever seen 2024-10-08 16:00:44 has limitations but you can always write c code, even from forth 2024-10-08 16:01:14 \c int get_y(){ int x,y; getmaxyx(stdscr,y,x); return y; } 2024-10-08 16:04:58 just a suggestion: instead of defining left, right, up, down as numbers, you could do ... ' 1- constant up ' 1+ constant down :noname ( x y -- x' y) swap 1+ swap ; constant right :noname ( x y -- x' y) swap 1- swap ; constant left 2024-10-08 16:05:22 then your move-segment doesn't need a case statement, it just becomes direction execute 2024-10-08 16:05:38 it's a cool idea 2024-10-08 16:05:59 they could even be just colon definitions 2024-10-08 16:06:45 well you want to dispatch to them somehow 2024-10-08 16:08:42 I like them because they are general since use the stack, I could use it to move any object that has x and y 2024-10-08 16:09:40 it shows me how I have to get used to the stack, I liked how I push a segment on the stack which is just two numbers, then play with those numbers and create another segment from that 2024-10-08 16:09:51 which actually brings me to another suggestion: you could encode the position in a single number and avoid some of the shuffling you have to do to access x :) 2024-10-08 16:11:06 using bits instead of bytes 2024-10-08 16:11:27 e.g., hex : left 1- ; : right 1+ ; : up 10000 - ; : down 10000 + ; 2024-10-08 16:12:02 I have to get to that level yet 2024-10-08 16:12:12 might make your bounds checking worse, though. not sure at first glance. 2024-10-08 16:13:09 I never played with bits actually 2024-10-08 16:13:19 could also just treat it as a double precision number. e.g., : left -1 0 d+ ; 2024-10-08 16:13:26 in my life everything was at least a byte 2024-10-08 16:13:39 they're actually cells 2024-10-08 16:14:08 everything is made of cells, that's what lispers say too 2024-10-08 16:14:21 cells withing cells within one stem 2024-10-08 16:29:04 btw there is no condition to check if the snake grows more than the limit 2024-10-08 16:29:32 I was supposed to make it win or something, but meh 2024-10-08 16:29:43 a segfault is your prize 2024-10-08 16:45:48 my favorite! 2024-10-08 16:57:18 ha 2024-10-08 17:38:47 I want to try waforth 2024-10-08 17:39:12 it's what I wanted, a forth to make web applications