2022-03-26 05:47:21 KipIngram: Yeah I don't like command history that changes old commands when you select them and edit them 2022-03-26 05:47:33 Too 1984 for my taste 2022-03-26 05:47:44 rewriting history and all that :P 2022-03-26 05:48:23 Truly KipIngram I think that your frame thing is the most elegant pseudo-locals thing I've seen 2022-03-26 05:49:09 I had previously done something like this where I moved stuff to return stack and used words that got the 1st, 2nd, 3rd etc cell in return stack 2022-03-26 05:49:19 But it just wasn't as neat, it used more words 2022-03-26 05:49:45 I don't know if I'd dedicate a register for this purpose, but certainly I think it's worthy of a user variable 2022-03-26 06:08:18 Hello, I learnt about forth about 6 months ago and I really like it and its philosophy, I've read starting forth and a lot of pieces written by Chuck and Jeff Fox, now I am gonna start reading thinking forth. I also used Mecrisp a bit which is amazing for embeded, but right now I wanted to do some more "general purpose programming" in forth, aka I want to write a piece of software that queries a rest api 2022-03-26 06:08:24 and then display some info based on that, what implementation should I look at? I've been currently looking at retro, pforth, ff and uxn. 2022-03-26 06:10:33 Oh and I want to do this on 9front (Plan 9), on which I managed to make pforth run and I know uxn and ff can be made to run there. As for retro, I just felt that with the literate programming style it wouldn't be too much of a hassle to understand what is going on and to port it eventually. 2022-03-26 06:13:54 I've also read jonesforth assembly part, so I am not too scared of assembly either. I am seeking guidance here mostly because I lack pratical experience undertaking a somewhat bigger forth project and especially in a more software way (as opposed to hardware project) 2022-03-26 06:30:43 Funny, there's someone else here using 9front or similar to do forth 2022-03-26 06:30:50 I wonder if there's some kind of reason for this pattern lol 2022-03-26 06:31:42 The maintainer of retro is in this channel, I don't know about the other ones. gforth is certainly capable of implementing a rest API 2022-03-26 06:32:06 If you want more standard forth then go for gforth (get a latest snapshot, last 'release' is ancient now) 2022-03-26 06:32:39 Otherwise if you like retro then that's got a history of being used for real computing work, it's tried and true 2022-03-26 06:32:59 There is a #retro channel on libera.chat 2022-03-26 06:33:47 I don't think the specific forth matters too much, you just want something that is capable of calling C functions or at the very least doing system calls 2022-03-26 06:33:55 Pretty much all good desktop forths allow this 2022-03-26 06:35:34 Oh!? On the 9front irc chat there is a joe7, I wonder if it is joe9 here who is using 9front. Otherwise I know the uxn author is using 9front as well. Maybe there is some kind of pattern, in french we use to say "Les grands hommes se retouvent" although I don't like to consider myself above anybody else ^^' 2022-03-26 06:35:45 At the very least a standard forth could at least communicate with a pipe via file I/O and get another program to do the platform-specific I/O stuff 2022-03-26 06:37:00 I don't speak French, is that something like "great minds think alike"? 2022-03-26 06:37:46 Certainly in English "great minds think alike" is not actually an arrogant phrase, it is not too serious 2022-03-26 06:38:03 Yeah retro appealed to me for that reason, it seemed quite "practical" and has been around for 10 years or so from what I read, the only thing is that I would need to port it so I would like to here more from the maintainer if it's worth the effort :) 2022-03-26 06:38:51 Yeah it's similar to "great minds think alike"! But it could be seen as arogant since I describe myself within that lot 2022-03-26 06:40:14 And unfortunately the g-word is forbidden on 9, apparently it would be a nightmare to port anything dependant on glibc on 9front... So I am gonna have to pass on gforth for this project 2022-03-26 06:44:24 And yeah you're right, the pipe file is exactly what I had in mind, especially on 9 where "everything is a file" 2022-03-26 06:45:33 Thanks for those pointers already veltas 2022-03-26 06:46:55 I'm sure someone can chime in with a simpler forth that might work on 9front 2022-03-26 06:47:01 If pforth works then that's fine 2022-03-26 06:48:37 I know retro is good because crc actually uses it for so much, "the proof is in the pudding" as we would say in England 2022-03-26 06:49:40 Yeah pforth looks good, the only issue I was having with it, is the trouble to add 'C' words to do syscalls and the like. Although it's optional, my initial idea to use forth it to master and understand the whole system I am using. So it bothers me a bit to be limited in that way. 2022-03-26 06:52:02 Hahaha love the saying, but yeah for some reasons I ended up looking at retro quite a lot, I am also very intrigued by uxn which is not a standard forth, but close enough and keeps the idea of simplicity core to the project. 2022-03-26 06:53:18 I just feel like I want to dive into an implementation and stick a bit more with it, as my study of forth so far has been very theoritical 2022-03-26 06:53:56 Is there a generic syscall interface in 9front? Because then you only need one syscall op added in C and you can specialise the syscalls in forth 2022-03-26 06:56:21 In Linux there's a function called 'syscall' that invokes any syscall from C 2022-03-26 06:57:43 There is an "exec" function, which given an executable name, executes it. I wanted to try adding that which would give me a lot of flexibility already. 2022-03-26 06:58:40 You could probably write something like syscall in assembly but it would not be trivial 2022-03-26 06:59:50 Anyway I think given that you're on such an exotic OS, using a FORTH defined in C is not such a bad idea. C for highly portable desktop FORTHs is probably reasonable 2022-03-26 07:00:45 Yeah, I guess that's why pforth was easy to compile and get working there. 2022-03-26 07:00:56 You're right that you should dive into FORTH and actually write some programs with it, it's always important to do that to learn something, especially with FORTH 2022-03-26 07:01:08 Because FORTH is so different, you can't learn it by reading about it 2022-03-26 07:05:53 True, hence my looking for a nice implementation which I can dissect and use to my content. I tried using colorforth a bit and I absolutely loved it. I just think that right now I need to do some "real" work with forth, if you have some time to tell me why it's a good or bad idea to use retro for such a project and to actually port it to 9front, it would be my pleasure crc 2022-03-26 08:19:00 veltas: I think using a register for { ... } is purely optional; I did it purely for performance reasons. If I weren't using a register, I don't think I'd use a user variable either, though - I'd just push the new frame ppointer value to the return stack, and use it from there, and pop it when done. 2022-03-26 08:19:34 That would add one additional RAM reference to each of the s words. 2022-03-26 08:20:10 And that's not a bad idea at all - if I ever got hurting for a register it would be easy to change to that approach. 2022-03-26 08:21:17 In either implementation { and } are not usable from interpreter mode, because they adjust the return stack. 2022-03-26 08:23:09 Oh, and by the way, it actually is possible to use return stack modifyng words from interpreted mode if you go to the trouble - you have to have different versions of those words that get called if you're interpreting. They have to move a couple of values out of the way first. Pop a couple of return stack values into registers, do the adjustment, and push those other values back. 2022-03-26 08:23:24 How many depends on how you've written your INTERPRET word. 2022-03-26 08:23:48 I did that in a system 2-3 implementations back. 2022-03-26 08:24:30 It's debatable whether it's worth it - it complicates the interpreter a bit. But "it works." 2022-03-26 08:30:24 The upside is that compiled functionality of those words is unchanged and unafected - it's all a compile time decision process. 2022-03-26 08:30:57 One might decide that it's worth it in order to be able to walk through definitions that adjust the return stack manually for debugging purposes. 2022-03-26 08:32:26 Combining that idea with what I noted a couple of nights ago - that you can adjust >in to jump around in an interpreted input line - you might be able to extend the idea and get looping processes to work when interpreting as well. An interpret time word could save the value of >in to the stack; the loop back word could pop that to reset >in. 2022-03-26 08:35:16 I've already made one extension to my compiler, triggered by a bit in a word's header, for words that reequire the compilation of an offset after the compiled word cfa. That idea could be used for indicating a "return stack modifying word" as well, at the cost of an additional header bit. 2022-03-26 08:36:20 The general idea would be "if that bit is set, then: if compiling, compile, if interpreting then , execute, " 2022-03-26 08:37:18 In my case the only place I ever loop back to is "beginning of definition" - the interpreter equivalent might be "reset >in to beginning of line." 2022-03-26 08:37:39 With that little extension I could make every word in my dictionary usable in interpreter. 2022-03-26 08:39:21 Ok, one part of what I just said isn't right - it wouldn't be as simple as , execute, for EVERY word. But there would be some sort of interpret mode action that would work for every word. 2022-03-26 08:42:28 Maybe the way to do this is to allow an optional second definition for such words - you'd arrange it so the first one found in a dictionary search was the "interpret mode" version, but that one would have an extra bit set in the header so that it would be rejected, and the search continued, if the search occurred during compile mode. 2022-03-26 08:43:12 So in find, you'd match the word, but if and then that match would be passed over and you'd continue searching, in which case you'd find the original first definition of the word. 2022-03-26 08:43:14 so 2022-03-26 08:43:23 : foo ...definition... ; 2022-03-26 08:43:38 : foo ...interpret behavior... ; INTERPRETED 2022-03-26 08:44:50 So, if STATE=1, FIND requires that bit to be clear to match. 2022-03-26 08:45:52 In my system, 2022-03-26 08:46:22 : me compile jump to start of word ; <- this is my "now" def 2022-03-26 08:46:39 : me 0 >in ! ; INTERPRETED 2022-03-26 08:47:45 But I have a *lot* of conditional me words - each one would need an interpreted version in such a system, so that's a bit of a painful approach for me. 2022-03-26 08:48:11 But it does seem like a fairly powerful general idea. 2022-03-26 08:49:20 I was hoping that one could just use the compile definition to get a general solution, without having to manually specify the action in each case, but I think that can't be done - the words that would be involved are just "different enough from each other" that it's not that simple. 2022-03-26 08:49:55 nature: you seem to be thinking very carefully about what you're doing - I look forward to seeing what you wind up doing. Welcome to the channel! 2022-03-26 09:27:56 KipIngram: Thanks, yeah I do, when I realized that this is a good way to approach forth programming I was pleasantly surprised since my personality matches that. 2022-03-26 09:30:27 I always feel bad in this industry where being careful, thinking a lot first and actually trying to do things the right way is usually considered a bad thing... 2022-03-26 10:27:43 Amen, brother. Totally agree. I firmly believe that 80% of having a project "go well" happens in that early thought process. By the time you actually start writing code and designing circuits, the architecture should be tight as a drum. 2022-03-26 10:28:26 You'll enjoy Thinking Forth. That other school of thought is personified in the character "Wiggins." 2022-03-26 10:29:25 In one little cartoon, Wiggins is the apple of his managers eye because he quickly produces extremely large volumes of code. 2022-03-26 11:01:15 KipIngram: I don't think allowing return stack modification in interpreter mode has a reasonable benefit 2022-03-26 11:15:21 I do think it's fairly limited - yeah. 2022-03-26 11:15:36 It's easy enough to do - if it were valuable it would likely be common. 2022-03-26 11:39:57 Plus it's a "ground floor modification," and I'm very hesitant about those. I did make one, but it had a quite large payoff. I don't want to get carried away - whenever I've done so in the past I wind up deciding later it was a mistake. 2022-03-26 11:59:51 I do expect to write alternative interpreters for various purposes in the future. But I regard those sort of as "applications," to be hauled out and run when particular needs arise. 2022-03-26 12:43:26 for quotations, do you write the definition to some place temporary then leave a pointer to that on the stack? 2022-03-26 12:43:52 assuming interpret mode 2022-03-26 14:29:23 I have different words for quotations-in-interpret-mode 2022-03-26 14:30:27 : ]{ 0 0 CREATE-WITH-NAME LATEST ; 2022-03-26 14:30:44 : }[ POSTPONE ; ; IMMEDIATE 2022-03-26 18:07:55 I don't have string literals yet. But at the moment I'm planning on inserting them into buffers dynamically allocated using that ropes stuff. 2022-03-26 18:09:08 Well, ones encountered in interpret mode, at least. I guess compiled ones will probably go into the code stream the way ." does it. 2022-03-26 19:09:11 String literals seem like more pain than benefit to me 2022-03-26 19:14:21 Well, I've done a lot of text file parsing over the years. Taking output from one program and slicing and dicing it so that it can be consumed by some other program. That sort of work comes up enough for me to want to be able to do it in my Forth as easily as I can do it in Python. It doesn't necessarily use a lot of string *literals*, but it uses a lot of strings and requires a lot of manipulation of 2022-03-26 19:14:24 them. 2022-03-26 19:16:49 It's the sort of thing that perhaps not everyone needs to do, but if you do need to do it then certain simple tools become extremely useful. 2022-03-26 19:17:03 Python's basic string handling operations work really well for this kind of thing. 2022-03-26 19:38:33 how does python handle it? 2022-03-26 19:39:11 I've been learning lua and I'm suprised that even with a crappy pattern matcher, you can do a lot. 2022-03-26 19:43:25 Well, I use mostly just the simple stuff in Python - mostly it's just that it makes it so convenient. You can get a lot of mileage of of .split(''), which gives you back an array of strings - the orignal string split into pieces. Then maybe you split one of the entries in that array on something else, etc. You can just take a long string and bust it up and snip out what you want 2022-03-26 19:43:28 without any trouble at all. 2022-03-26 19:43:45 It also has an ability to do stuff with them involving regexes, but I've not used that very heavily. 2022-03-26 19:44:11 So what it's giving you that's most helpful is just a convenient way of keeping up with and accessing the substrings - substrings of substrings, etc. 2022-03-26 19:44:35 You don't have to think at all about "building" that array of substrings, the way you'd need to in C. 2022-03-26 19:44:55 So it's not so much "Python" that's doing it as Python's excellent array of packages for various things. 2022-03-26 19:45:10 And it's nice handling of dynamically allocated stuff. 2022-03-26 19:45:40 ah, lua doesn't even have a .split you have to make it 2022-03-26 19:45:50 It just "handles" all the memory management and so on. 2022-03-26 19:46:23 i find k is great for this sort of thing 2022-03-26 19:46:27 And putting substrings back together into new strings is equally easy - concatenation is just what the + operator does to strings. 2022-03-26 19:46:48 I don't know it, but I have no doubt Python isn't the only one. 2022-03-26 19:46:55 though its not hard. but you do have to loop 2022-03-26 19:47:18 Yeah - Python just takes care of all of that under the hood. "Convenience." 2022-03-26 19:47:26 I don't particularly like that 2022-03-26 19:47:32 It's sort of my "go to language" these days for "quick one off utilities." 2022-03-26 19:47:48 awk just uses the space separator to concatenate 2022-03-26 19:47:54 much better way to handle it 2022-03-26 19:48:10 assume you're concatenating everything unless there is an operator 2022-03-26 19:48:14 to me that seems about the same as +. Just a different character. 2022-03-26 19:48:28 That makes good sense. 2022-03-26 19:48:30 x y z vs x + y + z 2022-03-26 19:48:36 Has an intuition to it. 2022-03-26 19:48:40 yeah 2022-03-26 19:48:59 its the most apl like language I know 2022-03-26 19:49:14 eris[m]: how does K do it? 2022-03-26 19:49:16 I heard so much about apl over the years, but never worked with it. 2022-03-26 19:49:28 I heard a lot of bragging about how terse apl code could be. 2022-03-26 19:50:23 Anyway, I don't have any particular "reverence" for Python - I've just found it to be decently utilitarian. I've been able to get stuff done with it. 2022-03-26 19:51:04 It has some subtle aspects you have to get clear on when it comes to messing around with lists in any way that's not really basic. 2022-03-26 19:51:17 Mostly related to when you do and don't get a "copy" of a list. 2022-03-26 19:51:33 Sometimes early on when I thought I'd have a copy I was actually just copying a pointer to a list. 2022-03-26 19:51:49 so changing the copy changed the original too, and I didn't get the result I expected. 2022-03-26 19:52:00 Once I caught on to that, it was fine, but it took me a little while.