2025-01-27 00:53:50 how do I avoid the return stack? 2025-01-27 00:53:52 : point >r >r display win gc r> r> draw.point ; 2025-01-27 00:54:15 rot 2025-01-27 00:56:27 2swap 2025-01-27 00:56:39 : point 2swap display win gc draw.point ; 2025-01-27 00:56:54 unless gc leaves something on the stack 2025-01-27 00:57:22 but the real answer is probably 2025-01-27 00:57:42 value x value y : point to y to x display win gc x y draw.point ; 2025-01-27 00:58:19 variable x variable y : point y ! x ! display win gc x @ y @ draw.point ; \ alternatively if you prefer variable 2025-01-27 00:58:27 disagree 2025-01-27 00:58:35 yeah I wanted to avoid both variables and the return stack 2025-01-27 00:58:42 but instead juggle them 2025-01-27 00:58:49 the thing is I have 4 5 1 2 3 2025-01-27 00:59:00 and I have to reorder them to 1 2 3 4 5 2025-01-27 00:59:03 well, it's possible to do that, but I think it's usually a bad idea 2025-01-27 00:59:10 the good thing is I can push 1 2 3 whenever I want 2025-01-27 00:59:19 what is the stack picture of this word? how many args does "display win gc" take? 2025-01-27 00:59:27 but 4 5 are already on the stack 2025-01-27 00:59:36 they are constants 2025-01-27 00:59:46 https://termbin.com/45qx 2025-01-27 00:59:52 is the same code I posted ago 2025-01-27 00:59:59 the same link actually xd 2025-01-27 01:00:31 oh, i completely misunderstood then. what's wrong with what you have? 2025-01-27 01:00:56 I think I should not resolve to the return stack without thinking twice 2025-01-27 01:01:14 *resort 2025-01-27 01:01:16 maybe draw.point's input order should change 2025-01-27 01:01:20 xentrac ty 2025-01-27 01:01:24 np 2025-01-27 01:01:47 draw.point is a binding to the XDrawPoint c function from xlib 2025-01-27 01:01:53 makes sense 2025-01-27 01:01:58 they tend to require lots of arguments 2025-01-27 01:02:23 my experience with XDrawPoint btw is that it's usually better to not use it 2025-01-27 01:02:34 because it's just ridiculously slow 2025-01-27 01:02:45 it was a test to see if I was making the bindings right 2025-01-27 01:02:57 the simplest think was to draw a point 2025-01-27 01:03:00 thing 2025-01-27 01:03:01 lol 2025-01-27 01:03:21 yeah 2025-01-27 01:03:52 I did a thing last millennium drawing 3-D IFS fractals with XDrawPoint and later I realized that if I'd just been drawing to a shared memory buffer I would have been much happier 2025-01-27 01:03:58 so do you think using r> in this case is justified? 2025-01-27 01:04:06 sure 2025-01-27 01:04:16 though I'd probably use variables instead ;) 2025-01-27 01:04:33 does it have to take args in that order, though? imo things tend to flow more smoothly when inputs that tend to be constants or near constant are more to the right, and args that are usually passed from several callers higher are on the left 2025-01-27 01:04:47 makes for more seamless composotion 2025-01-27 01:04:52 true 2025-01-27 01:04:59 I can add a c function as wrapper and bind to it 2025-01-27 01:05:13 but they will assume the display and gc and etc 2025-01-27 01:05:53 OTOH if you're building a binding to an existing Xlib API it might be easier to follow if you use the argument order of the Xlib function 2025-01-27 01:06:06 now I understand what display win gc does 2025-01-27 01:06:29 why don't you put those three things in variables or values instead of passing them explicitly? 2025-01-27 01:06:41 they are constants 2025-01-27 01:06:52 well, sort of 2025-01-27 01:06:58 you could conceivably have more than one GC 2025-01-27 01:07:03 or even more than one window 2025-01-27 01:07:15 i guess gc is graphics context. my original assumption was "garbage collect" which is why i thought it was a sentence that consumed something 2025-01-27 01:07:41 : point >r >r display win gc r> r> draw.point ; 2025-01-27 01:07:44 yeah. I have no such excuse 2025-01-27 01:07:47 display win gc are constants 2025-01-27 01:07:55 so I can just x y point 2025-01-27 01:08:00 right 2025-01-27 01:08:10 seems reasonable enough to me 2025-01-27 01:08:32 you're basically already doing what I foolishly suggested you should start doing even though you'd already shown me the code that did it 2025-01-27 01:09:16 I guess is my fault to not put stack notations 2025-01-27 01:09:18 xD 2025-01-27 01:09:51 nah, it's fine 2025-01-27 01:10:02 I'd call draw.point XDrawPoint though 2025-01-27 01:10:52 if I expect someone to use those bindings I should 2025-01-27 01:10:52 I wonder if someone will actually want them if I keep adding bindings 2025-01-27 01:11:04 there are a lot of xlib functions and I have to add wrappers I guess 2025-01-27 01:11:16 if you're looking for wide adoption, Forth is probably the wrong language 2025-01-27 01:11:38 actually the goal is to have fun with forth to learn it 2025-01-27 01:11:44 :-) 2025-01-27 01:11:57 but if someone else can benefit from those bindings it's cool 2025-01-27 01:12:18 at the end I just make them for myself this is why they have those weird names 2025-01-27 01:12:22 Sometimes I wish for stack juggling words like j45123 to get 1 2 3 4 5 2025-01-27 01:12:39 it would be easy to make all permutations 2025-01-27 01:14:58 in the example, if 4 5 are already there, you can do 1 -rot 2 -rot 3 -rot to get 1 2 3 4 5 2025-01-27 01:14:59 pretty sure crc has tjat 2025-01-27 01:15:21 actually seems I can 4 5 1 2 3 4 roll 4 roll 2025-01-27 01:15:23 he calls it reorder or shuffle i think, idr which 2025-01-27 01:15:39 but I wonder if >r is better 2025-01-27 01:15:43 as in '45123 reorder 2025-01-27 01:16:11 vms14: imo the return stack is there for you to use it 2025-01-27 01:16:49 yeah my fear is that I will likely to abuse it because I'm lazy and do not want to mess with the stack 2025-01-27 01:17:07 when I should getting familiar with it instead 2025-01-27 01:17:30 just ask me for permission before you use it. in this case, i'll allow it. 2025-01-27 01:17:35 :D 2025-01-27 01:17:37 ok 2025-01-27 01:25:17 >r >r r> r> is definitely better than 4 roll 4 roll 2025-01-27 01:25:59 I was thinking about it, and how every element might need to be updated in a new position 2025-01-27 02:01:43 Yes, I have a reorder word: https://konilo.org/manual/glossary_1054903512.html 2025-01-27 02:31:39 xentrac: >r >r r> r> and 4 roll 4 roll don't do the same thing. 2025-01-27 02:31:51 But yeah - roll sucks. 2025-01-27 02:55:14 4 5 >r >r 1 2 3 r> r> does do the same as 4 5 1 2 3 4 roll 4 roll, doesn't it? 2025-01-27 02:55:54 Oh, I see. I misunderstood - I thought the numbers were all already on the stack. 2025-01-27 03:00:22 I agree with zelgomer, if using the return stack makes the code clearer then why not use it - it's similar to pushing registers to the stack in assembler when you run out of registers 2025-01-27 03:02:10 Yeah, I feel the same. 2025-01-27 09:43:54 thrig: Whether C or assembly doesn't matter much, but if you parse C headers or have to enter that info manually makes a huge difference sometimes 2025-01-27 09:44:17 I mean there are short/sweet C headers that aren't effort 2025-01-27 09:44:40 But a lot of stuff I'm interested in like OpenGL, SDL, etc are more effort 2025-01-27 09:45:03 Of course the right way to do those manually is just as and when definitions are needed