2022-05-07 03:17:03 Forth's parsing requires execution and that's what makes it so easy, although I admit usually that makes it more complicated 2022-05-07 05:25:58 How so? You don't execute a definition when you first compile it. I think I must be on the wrong wavelength - you must be looking at it in some different way from me. 2022-05-07 05:27:07 I must be thinking of "execute" and "parse" in a way different from you. 2022-05-07 06:45:30 Wrote a handy word last night. : sp@. ( n --) ; 2022-05-07 06:46:10 It saves the cursor, goes to line n, column 1, prints the stack pointer, and restores the cursor. Good for chasing stack imbalances to ground. 2022-05-07 06:46:39 I have to be particuarly careful about those, because the { ... } stack frame mechanism can hide them. 2022-05-07 06:47:16 By definition code inside { } can't imbalance the stack outside, so even if it's got problems the { } can hide them. 2022-05-07 06:47:53 So I need to specifically check that anytime I use a frame. 2022-05-07 10:27:21 xd I made another aberration 2022-05-07 10:27:35 but this time seems to be useful enough to do some stuff 2022-05-07 10:27:46 it can have nested loops, ifs, etc 2022-05-07 10:28:09 but does not even have a parser, and words aren't able to get words from the TIB 2022-05-07 10:28:20 and there's no return stack or alike 2022-05-07 10:28:51 the parser is really a regex converting the code to an array and this is the "ast" 2022-05-07 10:29:22 a regex? now you have two problems 2022-05-07 10:30:09 it's a dirty trick, but caring about the parser and making the words able to handle the code input was stopping me a lot because I have to care if we are in a repl or reading a file, etc 2022-05-07 10:30:42 I could make words read from this ast, it's just an array, but for now meh 2022-05-07 10:31:23 it has macros 2022-05-07 10:31:39 What's usually done is that the interpreter / compiler reads words from "some buffer" until it reaches the end of it. That buffer might be the tib, but it also might be a disk buffer with a block of source loaded into it. 2022-05-07 10:31:55 :if-else : swap rot :swap if drop macro ; 2022-05-07 10:32:20 In old traditional systems the variable BLK will be set to 0 to cause it to use the tib - otherwise it uses "BLK @ BLOCK" result, which is the address of a disk buffer. 2022-05-07 10:32:35 if is a macro, if-else is not, but the word macro triggers the effect of a macro 2022-05-07 10:32:59 the interpreter when finds a macro executes it and then takes the code from the stack and evaluates that 2022-05-07 10:33:24 macro is an empty word, but is a macro so triggers the interpret to execute an empty word and look at the stack 2022-05-07 10:33:40 You can nest that process - if a disk buffer of source LOADs another block, then the current BLK and >IN values are saved on the return stack - you go load that new block - and then restore BLK and >IN to pick up where you left off. 2022-05-07 10:33:51 they can build lists and push them to the stack 2022-05-07 10:34:05 so a macro just needs to return a list of words and that would be executed 2022-05-07 10:34:55 the if-else just uses if and if it's true swaps the stack then drops an item of the stack 2022-05-07 10:35:12 then calls macro to trigger the interpreter what's on the stack 2022-05-07 10:35:46 1 ("is true" .) ("is false" .) if-else 2022-05-07 10:36:42 lists aren't executed, just pushed on the stack 2022-05-07 10:37:15 yet I could make words read from the tib (or the ast) 2022-05-07 10:37:37 I prefer the forth if after all 2022-05-07 10:37:51 but I like my case 2022-05-07 10:38:21 1 ((1 "is one") ("meh" "is meh") (default "idk what is it")) case 2022-05-07 10:39:27 I need a real parser and I wonder about making words read the tib/ast 2022-05-07 10:40:13 but I have macros, I think I don't really need a return stack 2022-05-07 10:41:14 https://termbin.com/g1i2 this is the language 2022-05-07 10:41:36 https://termbin.com/xs17t and an example usage 2022-05-07 10:42:03 althought : is => in this example (I've changed again to : now) 2022-05-07 10:43:15 :word is like "word" 2022-05-07 10:43:42 as words can be pushed as strings on the stack I can use that 2022-05-07 10:44:46 it clearly needs a rewrite from scratch again, but I think it's in some sort of usable state 2022-05-07 10:47:00 a word can read the ast by triggering the compile mode, the interpreter just pushes words to an array, so an immediate word could check the stuff of this array and use it 2022-05-07 14:17:40 KipIngram: Parsing in forth involves parsing 'words'... but those 'words' are sometimes immediate, and sometimes you're interpreting, so you also execute 2022-05-07 14:17:55 And the execution often invokes sub-parsing 2022-05-07 14:18:22 So that's what I mean by the 'parsing' in forth requires 'execution'. More formally, Forth does not have a context-free grammar 2022-05-07 14:19:01 It's why, for instance, you can't write 100% accurate syntax highlighting for Forth without actually executing the code 2022-05-07 14:19:12 And that's how crc does it for his website I think 2022-05-07 14:23:02 Ok, that's fair - you can't *guarantee* you won't execute anything. Well, you can, if you know your words. Just don't use them. But at least that calibrates me. 2022-05-07 14:23:13 Say, I'm about to drive to Austin, but I have a queston before I go. 2022-05-07 14:24:00 A day or two ago, I wrote a word to obtain the cursor position. Via ansi. This involves outputing a particular string, to which the KEYBOARD responds with [;R 2022-05-07 14:24:25 I wrote code to parse that, and it works fine. The ; terminates building the first number, and the R the second. 2022-05-07 14:25:06 But, I call this at the beginning of EXPECT to get my cursor location - this is how I eliminated the need for any "leftward" motion. I just go all the way left, with "goto row, col," and then work right. 2022-05-07 14:25:09 Great - works. 2022-05-07 14:25:12 But... 2022-05-07 14:25:42 If I just hold down the Enter key, and let the keyboard spew newlines at the system, at random intervals it fouls up - the R somehow makes it through into the input stream. 2022-05-07 14:26:01 If I pause even the slightest bit between enters, it doesn't happen - ever. 2022-05-07 14:26:17 And I am using blocking keyboard I/O, so I really don't see how this can happen. 2022-05-07 14:26:35 But... I know sometimes it's wise to "flush" things - some of you guys probably know more than I do about that. 2022-05-07 14:26:59 Should I flush stdout after I send that string that triggers the row//col input? Or something like that? 2022-05-07 14:27:01 Any thoughts? 2022-05-07 14:27:29 If I don't respond shortly I've hit the road, but I'll definitely check in tonight. 2022-05-07 14:31:18 Yes basically 2022-05-07 14:31:26 I'm surprised you haven't already had issues with this 2022-05-07 14:34:33 Yeah - it hasn't shown any sign of needing to be flushed - I emit a character, it's on the screen, instantly. 2022-05-07 14:34:44 This is the first misbehavior I've observed. 2022-05-07 14:35:18 I wrote a cheap and dirty "modulo scroller" to replace the need to determine the correct row. No good long term, but it does "work" after a fashion - scrolls me down down down and then resets to the top. 2022-05-07 14:35:34 With THAT running I can hold enter down all day and it just cycles - no glitches whatsoever. 2022-05-07 14:35:48 So it's clearly the cursor position read that's the source of hte trouble. 2022-05-07 14:36:05 Plus I can see that R in the erroneous "input." 2022-05-07 14:36:37 That number building word eats characters until it gets a non-digit, so something extra is coming in that terminates it - otherwise it would eat the R. 2022-05-07 14:36:59 Or maybe a digit is coming in tainted. 2022-05-07 14:37:06 KipIngram: Basically you are sending output and hoping to receive relevant input... that needs to be synchronised, surely? 2022-05-07 14:37:16 Input vs Output is not actually synchronised by default 2022-05-07 14:37:19 So you need to flush 2022-05-07 14:37:29 Yes, but this is behaving like it's getting EXTRA input. 2022-05-07 14:37:31 So flush after writing the command, before reading 2022-05-07 14:37:36 It's not like I'm waiting and the input never comes. 2022-05-07 14:37:47 Which is what I would think implied the need for something like a flush. 2022-05-07 14:37:49 Yeah race conditions are hard to diagnose 2022-05-07 14:37:56 Try adding the flush and see if it fixes it 2022-05-07 14:37:57 What's it racing WITH? 2022-05-07 14:38:03 Other input 2022-05-07 14:38:08 Other output 2022-05-07 14:38:10 rather 2022-05-07 14:38:13 Ok - that makes sense. 2022-05-07 14:38:38 Maybe one of my ENTERS is getting ahead of the R. 2022-05-07 14:38:59 Sure - that makes total sense. 2022-05-07 14:39:07 The software is asynchronous with ME. 2022-05-07 14:39:13 I don't see how flushing will help that. 2022-05-07 14:39:27 I'm hogging the input - and it's trying to squeeze an input in. 2022-05-07 14:39:36 Sooner or later they're going to go wrong. 2022-05-07 14:40:10 It's not my program READING input that's causing the race - it's just me sending it into the OS. 2022-05-07 14:40:39 It's really a crap way to get the cursor location. 2022-05-07 14:40:59 Maybe there are other ways - I should dig around. 2022-05-07 14:41:07 ya put the tty in 'raw' mode? 2022-05-07 14:41:11 Yeah. 2022-05-07 14:41:23 I don't like it - the user should OWN the input stream. 2022-05-07 14:41:31 Not raw mode - that's fine. 2022-05-07 14:41:39 I don't like this reading cursor position from the input. 2022-05-07 14:42:06 Anyway, I'm no longer baffled. Of course it fails eventually. How could it not? 2022-05-07 14:42:12 it is a VideoTerminal hack so to speak 2022-05-07 14:42:37 Yeah. That was the only way the terminal had to send info to the host. 2022-05-07 14:42:47 They had no choice back then. 2022-05-07 14:42:55 Surely there are other ways for me to do it. 2022-05-07 14:43:14 Hopefully with a syscall - I don't want to link in some damn library. 2022-05-07 14:43:15 ioctl overused syscall I gather 2022-05-07 14:43:47 I think the right way is with the ANSI escape 2022-05-07 14:43:50 as you are doing 2022-05-07 14:44:02 Try the flush 2022-05-07 14:44:12 Works for toilets too 2022-05-07 14:44:29 lmao... 2022-05-07 14:44:40 Yah - have that one down. Took a while, but I've got it... 2022-05-07 14:44:46 I'll try it. 2022-05-07 14:45:15 I'm going to be a little surprised if it works, but... I don't know this corner of the business that well, so we'll see. 2022-05-07 14:45:44 When I was growing up I built the hardware - if I needed a channel I put one in. :-) 2022-05-07 14:46:00 fun thing I came across: you can set it up so you can ssh over a serial port. 2022-05-07 14:46:23 Oh yeah. I've actually done that. Some years back. 2022-05-07 14:48:16 veltas: Reason I'm going to be surprised - I'm sitting here holding down that key. The OS is buffering that until someone asks for it. I can't guarantee that it's going to be my own call to KEY that asks for it - it might well be that cursor output function. 2022-05-07 14:48:20 what irritated me when I came across the question and the correct answer is the tendency for many people misunderstanding the question of "I am trying to do x, can I and how?" and answer with "you really should be doing y instead" 2022-05-07 14:48:44 Yeah, I hate that. 2022-05-07 14:48:49 That's not an answer. 2022-05-07 14:49:11 At least not to the question asked. 2022-05-07 14:49:39 Or worse - they just say "you shouldn't do that" without offering any alternative. 2022-05-07 14:49:51 the good answer started "I have no idea why you are doing this but try this:" 2022-05-07 14:52:04 Yeah often they go that way 2022-05-07 14:52:11 turned out that the guy was debugging why the only eth interface on that machine was on the fritz 2022-05-07 14:52:25 It's especially annoying when you have a legit reason 2022-05-07 14:52:44 Sometimes it's so fuckin broad like "how do I do this in C" "you really should be using C++" 2022-05-07 14:53:36 "how do I write this in assembly" "you shouldn't be writing assembly" 2022-05-07 14:54:24 yeah such a non-answer is not taking into the account that a) there might not be a c++ compiler for that architecture 2022-05-07 14:55:09 b) you are perhaps back porting a feature or fix into a older c only code base 2022-05-07 14:56:13 c) you might be barred from using c++ due to various factors 2022-05-07 14:59:53 or d) you are just curious 2022-05-07 15:01:54 one thing I have noticed that these kind of non-answers are ?earmarks/hallmar/indication? of a busy-body mindset 2022-05-07 15:04:02 Honestly I shouldn't even need to justify not using one language over the other 2022-05-07 15:04:16 I don't mind "helpfully I will suggest you don't do it this way, but also here is the answer" 2022-05-07 15:04:23 Like sometimes people do need to be nudged 2022-05-07 15:04:30 But there is always a valid reason for something 2022-05-07 15:08:29 if you heard those guys it's likely you'd never try forth 2022-05-07 15:09:09 heard? or heed? 2022-05-07 15:09:20 you would end only doing what is commonly accepted 2022-05-07 15:09:44 Zarutian_HTC: I suppose heed, my english sucks like my code does 2022-05-07 15:09:51 :D 2022-05-07 15:10:30 but I think "if you'd hear" was what I wanted 2022-05-07 15:10:55 vms14: you nailed it with: you would end only doing what is commonly accepted 2022-05-07 15:11:31 which is sad if you look at what is commonly accepted and what isn't 2022-05-07 15:14:21 yebb, I usually look beyond 'what is commonly accepted' because that is often subpar to requirements 2022-05-07 18:17:46 Who's seen this? https://github.com/pzembrod/cc64 2022-05-07 18:41:16 veltas: I think I saw it some time ago while looking for forth compilers and transpilers 2022-05-07 18:41:34 there is more than one compiler to C written in forth it seems 2022-05-07 18:45:18 Kind of interesting, love seeing Forth used for stuff like this 2022-05-07 18:45:53 veltas: https://bellard.org/tcc/ 2022-05-07 18:47:05 What about it? 2022-05-07 18:47:18 sorry bad link 2022-05-07 18:47:38 https://groups.google.com/g/comp.lang.forth/c/lBYFfVJ1qhc/m/BxvaTHCX_JgJ 2022-05-07 18:49:36 Interesting 2022-05-07 18:50:19 when I saw forth I've searched a bit for forth implementations 2022-05-07 18:50:34 it seems forth has been implemented even more times than lisp 2022-05-07 18:50:54 and there are some transpilers and alike, mostly to js 2022-05-07 18:51:12 which remembers I want a forth for the browser 2022-05-07 18:51:52 Unfortunately I cannot recommend a web forth 2022-05-07 18:51:58 I've also searched for "why forth" posts, but didn't find interesting arguments 2022-05-07 18:52:02 why veltas? 2022-05-07 18:52:17 Because I am not informed on web forths 2022-05-07 18:52:24 you mean recommend an existing one or not recommend using forth for the web 2022-05-07 18:52:29 I am ignorant about web forths 2022-05-07 18:52:33 ah, don't worry I won't use them 2022-05-07 18:52:50 I'll make my own abomination and laugh when everything burns 2022-05-07 18:52:57 Okay, good luck 2022-05-07 18:53:26 Forth has many implementations because it is a simple model 2022-05-07 18:53:54 yes but it's not so easy to implement as initially seems, at least if you want to make a real forth 2022-05-07 18:54:19 And I believe: people that write forths learn forth better 2022-05-07 18:54:26 it seems the best way is to do it in assembly and if you use another language you're going to face a lot of troubles you won't find with asm 2022-05-07 18:54:33 Although I do not believe it is required to write a forth 2022-05-07 18:54:52 I can't call my toy language a 'forth' 2022-05-07 18:55:03 Yes, writing forth inside another language has issues 2022-05-07 18:55:05 vms14: maybe i should write a 'why forth' 2022-05-07 18:55:06 just a stack based rpn toy lang 2022-05-07 18:55:12 eris[m]: I'd like to read it 2022-05-07 18:55:29 ive written some stuff about forth but not a lot 2022-05-07 18:55:59 the most of "why forth" seems to revolve around "I have interactivity in microcontrollers" 2022-05-07 18:56:16 Starting Forth 2nd edition has some good stuff on "why forth" in intro part aimed at professionals 2022-05-07 18:56:28 but zero arguments about general programming, bottom up, etc 2022-05-07 18:56:49 I still write programs top-down in Forth, top-down is the way to go 2022-05-07 18:57:14 I always read from forthwrights "design top down, code bottom up" 2022-05-07 18:57:44 Don't believe their lies 2022-05-07 18:57:48 xd 2022-05-07 18:58:25 Write top-down code, writing top-down code *is* design. And when you get to bottom start 'playing' with that bottom code in the interpreter 2022-05-07 18:58:30 And work way back up to top 2022-05-07 18:58:42 And you'll have a working, well-designed, bug-free program 2022-05-07 18:58:49 Well bug-sparse anyway 2022-05-07 18:59:22 That's how I work, I can only testify to what I do myself 2022-05-07 18:59:44 And it's how I work in other languages as well, it's just easier to do the 'play' part in Gorth 2022-05-07 18:59:47 Forth* 2022-05-07 18:59:54 Gorth sounds horrific 2022-05-07 19:01:02 hahaha gay forth 2022-05-07 19:01:10 I always think that 2022-05-07 19:01:15 i always design my programs before i write them 2022-05-07 19:01:31 its a helpful strategy that top down doesnt really cover 2022-05-07 19:01:41 top down you already start to make assumptions 2022-05-07 19:02:48 from what I think I understand, bottom up is after all to just go extending the language until you have a bigger language, then you end with a small program using this language 2022-05-07 19:03:07 I do 'design first' in a sense, bad assumptions can be made either on paper or while coding 2022-05-07 19:03:14 So, no 2022-05-07 19:03:53 I think forth is really well suited to this, and at the end aren't forth programs really a dsl + a small language? 2022-05-07 19:04:24 If you think hard and avoid making assumptions with top down, and do the top down, that *is* design. But instead of a design document you end up with code 2022-05-07 19:04:27 And I'd rather write code 2022-05-07 19:04:34 the fact a colon definition is not expensive as a function call let's you define a lot of words you'd never define in other languages 2022-05-07 19:04:53 It's the same work, if you do it right, but with a more useful result 2022-05-07 19:05:13 so you go extending the language bit a bit until finally it understands the problem you want to solve 2022-05-07 19:05:24 vms14: Chuck Moore used to describe Forth that way. I think it's not how people tend to write it 2022-05-07 19:05:26 I think it's just this what I really like from forth 2022-05-07 19:05:27 But you can do that 2022-05-07 19:05:44 The most important thing is to use it 2022-05-07 19:05:54 Then you have a real opinion! 2022-05-07 19:07:02 i dont do a design document 2022-05-07 19:07:08 i just have a whiteboard 2022-05-07 19:07:28 thats what i mean by planning and design 2022-05-07 19:07:32 I never design from start, I know it helps a lot, but I never do 2022-05-07 19:07:47 I usually have some ideas and try them until the stuff gets a shape 2022-05-07 19:08:02 eris[m]: Okay then you end up with a whiteboard, or a piece of paper, or a word document. Whatever. I just prefer ending up with code, even if it's not right. 2022-05-07 19:08:15 then I rewrite it from scratch or let it as a bunch of patches and tests 2022-05-07 19:08:47 thats fair 2022-05-07 19:08:56 idk how many forth like implementations I have just because of that 2022-05-07 19:10:08 the thing avout the whiteboard is it carries more info than just the program; its my notes, a way to iterste on thought processes 2022-05-07 19:10:11 even if they arent directly represented as code 2022-05-07 19:12:03 That's fair 2022-05-07 19:12:41 a big program i had sitting around (in another language) was a KSQL parser 2022-05-07 19:12:59 eris[m]: I want to make a program to manage projects and is largely because I need some way to add info and thoughts about some project 2022-05-07 19:13:20 i'd draw out the ways to extract the ksql statement into its parts visually on the board 2022-05-07 19:13:25 but also should be able to manage other aspects of a project, like the files it uses, etc 2022-05-07 19:13:31 and then from there i eventually arrived on a solution 2022-05-07 19:13:48 I think you do fine 2022-05-07 19:13:59 I usually start from a repl and try stuff 2022-05-07 19:14:21 but a bit of thought is usually better 2022-05-07 19:14:24 i like to shy away from that kind of thing; i believe it's called the management problem 2022-05-07 19:14:25 oh, i use a repl too dont get me wrong 2022-05-07 19:14:41 but this is when i couldn't even think of the shape of it 2022-05-07 19:15:53 vms14: The "start from a repl and try stuff" is great .. when you're not that far from code 2022-05-07 19:16:19 But when you have a hard problem you need design or to write top-down. Sometimes you can do a little from repl first but not the whole thing 2022-05-07 19:16:27 hmm, its not called that 2022-05-07 19:17:07 So I'm saying don't take what Forth people say as gospel, not Chuck or anyone 2022-05-07 19:17:23 well you have to think a bit, but I guess when you have a pen and a paper you can achieve more 2022-05-07 19:17:30 The proof is in the pudding 2022-05-07 19:17:53 Demonstrate these ideas for yourself, that's how you know 2022-05-07 19:17:55 i do enjoy a good bit of pen and paper 2022-05-07 19:17:58 veltas: I usually try to check what people say by myself 2022-05-07 19:18:06 With a real problem, too 2022-05-07 19:18:10 this is why I tried lisp 2022-05-07 19:18:33 and fell in love with lisp until I discovered forth 2022-05-07 19:19:07 the thing I like the most from programming is metaprogramming 2022-05-07 19:19:26 this is why I loved lisp, but forth I think has even more power 2022-05-07 19:20:21 at least the thought about me being able to implement forth (even if it's in a bad way) wins any battle with other languages 2022-05-07 19:20:50 I value a lot the fact you can have a language written by yourself that even works 2022-05-07 19:21:05 I think nothing can beat this 2022-05-07 19:21:06 Yeah there *is* something special about that 2022-05-07 19:21:22 It's actually important/useful, in my opinion 2022-05-07 19:21:37 it's a huge feature for me 2022-05-07 19:22:08 the fact I can add it whatever I want and even implement it on top of the other languages/frameworks and steal libraries or concepts 2022-05-07 19:22:38 for example you can make forth in java or kotlin and make android applications with that 2022-05-07 19:23:07 it also means you only have to master forth and implement in the language/platform you want 2022-05-07 19:24:30 I suppose all this stuff is what creates my obsession with forth 2022-05-07 19:24:52 forth is the true universal programming language 2022-05-07 19:25:08 but I think forth can be my main language, specially when I can put it wherever I want 2022-05-07 19:30:59 forth is home 2022-05-07 19:31:20 I want Forth as everything, OS, programs, libraries, the web, ..... 2022-05-07 19:31:57 But is that a good idea? Dunno. But I hope people keep writing Forth stuff and we'll find out more 2022-05-07 19:32:05 Nighty night 2022-05-07 19:35:43 if you write an usable forth OS, it's likely fortwrights will at least take a look 2022-05-07 19:36:12 won't compete with other systems, but maybe you get some users 2022-05-07 19:37:23 gn btw 2022-05-07 21:08:20 There's already OpenBIOS in Forth to build upon, right? 2022-05-07 21:12:29 OpenBIOS v1.1 released (2013-05-04) 2022-05-07 21:13:18 looks like an abandoned project if you look at https://openfirmware.info/Welcome_to_OpenBIOS 2022-05-07 21:14:25 Still might provide a head start. 2022-05-07 23:34:27 I'm adding curses to that forth, I like it somehow 2022-05-07 23:34:53 initscr start-color red yellow 1 init-pair 1 color-pair attron "oh" 10 10 addstr refresh getchinitscr start-color red yellow 1 init-pair 1 color-pair attron "oh" 10 10 addstr refresh getch 2022-05-07 23:35:15 fck it's doubled 2022-05-07 23:36:05 I'm realizing that I need vocabularies/namespaces after all 2022-05-07 23:36:26 I have variables, but anyways