2022-11-26 00:14:31 one thing I wonder about a bit is a multi-machine forth. 2022-11-26 00:15:19 forth system shared over a network. dictionary is shared. 2022-11-26 00:15:25 two REPLs linked up. 2022-11-26 00:53:37 decay: and a stack shared too? 2022-11-26 00:53:42 this would be a problem 2022-11-26 00:53:53 no. 2022-11-26 00:54:09 different stacks on different machines. 2022-11-26 00:54:24 but would be a multiuser forth, won't? 2022-11-26 00:54:32 like it would be kind of a forth server 2022-11-26 00:55:01 every user with his own stack, but the same dictionary 2022-11-26 00:55:04 users can communicate via dictionary modification. 2022-11-26 00:55:06 yep. 2022-11-26 00:55:16 wonder if would be great or a mess 2022-11-26 00:55:19 or both 2022-11-26 00:55:54 : msg " your code sucks" ; 2022-11-26 00:56:10 then the other user types 'msg' to see what his friend told him 2022-11-26 00:59:05 I think I just need to maintain a list of stacks and use sockets and it's done 2022-11-26 00:59:43 but could be greater if only the dictionary is shared/sync and the cpu comes from the user machine 2022-11-26 01:00:49 haha the dictionary could be shared with JSON.parse/stringify 2022-11-26 01:01:43 another thing I also love from js 2022-11-26 01:02:00 json parse and json stringify, the dom and the canvas 2022-11-26 01:02:36 sad that it can't handle recursive references 2022-11-26 01:39:46 I have a bug related with the stack 2022-11-26 01:40:16 I sometimes execute code and want to get whatever the code returns, no matter how many values 2022-11-26 01:40:54 I was getting the size of the stack before executing that code and then later, to see how many new elements were and take them 2022-11-26 01:41:17 but this is broken when a word consumes the same or more number of elements than it returns 2022-11-26 01:41:45 idk how to solve it without touching the internal functions that put and get elements from the stack 2022-11-26 01:44:53 I'll overwrite those functions in a temporary way, then reset them once I got the number of new elements xD 2022-11-26 05:50:49 https://gist.github.com/neuro-sys/4a6f96e3b14f626e7d7e7824777d43e9#file-opengl-triangle-fs-L13-L25 2022-11-26 05:51:24 Pretty trivial but, I added multi line string compiling words for my needs, S""" and """S. 2022-11-26 06:28:18 neuro_sys__: Nice 2022-11-26 09:22:49 Hmm just noticed in gforth you can define a string as "foobar" (without s"). Not sure where it's defined, but it must be in the outer interpreter I suppose, given it's not space delimited. 2022-11-26 09:25:24 neuro_sys__: Yeah it's just a 'literal' 2022-11-26 09:25:34 And it probably just mallocs the string 2022-11-26 09:30:04 https://thrig.me/tmp/there-is-no-string.txt 2022-11-26 09:30:40 It's in the latest version I compiled from the git (0.7.9) 2022-11-26 09:30:51 0.7.3 peasants represent 2022-11-26 09:31:30 gforth didn't really want to compile for me last I tried 2022-11-26 09:33:15 I find I need 0.7.3 installed to build the git version 2022-11-26 09:34:12 gcc started eating infinite memory (until the OS killed it) and clang bailed out with a wacky error message. I'll let someone smarter than me port it 2022-11-26 09:55:30 It seems like it's achieved by rec-string, but not sure. 2022-11-26 09:58:22 https://gforth.org/manual/Recognizers.html 2022-11-26 10:50:46 thrig: What variety of BSD do you smoke? 2022-11-26 10:51:18 OpenBSD 2022-11-26 11:40:44 Dragonfly BSD? 2022-11-26 13:21:56 Did anyone try a SQL eDSL in Forth? 2022-11-26 16:54:38 Forth can't open overlapping vocabularies? 2022-11-26 16:54:53 Like having + mean string concat in a certain code section 2022-11-26 16:56:06 dictionaries 2022-11-26 16:59:18 olle: don't see why it shouldn't 2022-11-26 16:59:42 it ought to find the "first" definition of + and if that's in your string vocabulary it'll see that before + in the Forth vocabulary 2022-11-26 17:01:07 gordonjcp: got it, thanks :) 2022-11-26 17:03:07 olle: Yeah, Forth doesn't have a way of calling out which word you want when two have the same name. Your only way of controlling that is by what order you put the vocabularies in your search order. 2022-11-26 17:03:31 KipIngram: OK, but I can open it and then close the dict? 2022-11-26 17:03:39 However, just executing a vocabulary name will put it first in your order, so you could say something like 2022-11-26 17:03:46 2022-11-26 17:04:00 and be guaranteed that you get from . 2022-11-26 17:04:19 Problem is, that's a permanent change until you undo it - it's now first in your order for everything. 2022-11-26 17:04:29 Ja, but how do I undo it? 2022-11-26 17:04:31 You can't override that sequence for a single word. 2022-11-26 17:04:40 Rebuild the search order back the other way. 2022-11-26 17:04:48 Crap 2022-11-26 17:04:50 crc has some nice ideas about doing that. 2022-11-26 17:05:03 He has a way of "snapshotting" and latER "restoring" the order. 2022-11-26 17:05:16 That search order can be placed on return stack, I guess? Or any stack 2022-11-26 17:05:23 so, 2022-11-26 17:05:31 That would leave you back where you started. 2022-11-26 17:05:35 Exactly 2022-11-26 17:05:42 Wonder if gforth has something like that 2022-11-26 17:05:53 I'm not sure how he implements it, but yeah - he's achieving something of that sort. 2022-11-26 17:06:05 embed talks about changing the dictionary used 2022-11-26 17:07:28 https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Word-Lists.html#Word-Lists 2022-11-26 17:11:48 http://www.complang.tuwien.ac.at/anton/euroforth/ef13/papers/nelson.pdf Forth Query Language (FQL) 2022-11-26 17:11:51 Neat 2022-11-26 17:21:37 I guess you could make an alias to the word you're overwriting 2022-11-26 17:22:57 Shouldn't there be an eDSL to deal with strings in general in Forth...? 2022-11-26 17:23:22 Ah maybe not 2022-11-26 17:24:42 "The word SQL¦ starts to create an SQL query, until the next ¦ is encountered, 2022-11-26 17:24:42 when we switch back to Forth. We then stay in Forth until another ¦ is 2022-11-26 17:24:43 leaving a pointer to the resulting array" 2022-11-26 17:24:45 Pretty cool 2022-11-26 17:24:49 Sorry for the faulty paste :( 2022-11-26 17:25:36 But basically just a template engine, I guess 2022-11-26 17:26:15 Hi ALl, forth newbie warning :-) : Can anyone tell me what the dashes in a word definition mean ( -- ). WEb search FAR from helpful. TIA. 2022-11-26 17:26:56 No stack change for that word, ms_spock 2022-11-26 17:27:07 ( here be the stack going into the word -- here be the stack after the word is done ) 2022-11-26 17:27:30 It's how words are documented 2022-11-26 17:27:35 Since Forth has no named parameters 2022-11-26 17:29:25 tHANKS, BUT STILL CONFUSED :-( 2022-11-26 17:29:34 Damn caps lock... 2022-11-26 17:29:59 Confused about what? 2022-11-26 17:30:30 Sigh, I.m not sure, I guess I should look for something else with the dashes in it. 2022-11-26 17:30:48 : multiply ( n n -- n ) * ; 2022-11-26 17:32:09 two numbers are expected to be on the stack and the result leaves one number on the stack when donw? 2022-11-26 17:32:12 down 2022-11-26 17:32:16 done 2022-11-26 17:32:59 y 2022-11-26 17:33:10 THANK YOU!!!! 2022-11-26 17:33:31 Having fun with this :-)! 2022-11-26 17:35:09 +1 2022-11-26 17:40:52 :1: Undefined word 2022-11-26 17:40:52 >>>: $@len ( addr -- u )  @ @ ;<<< 2022-11-26 17:40:56 Which word is undefined here? 2022-11-26 17:41:25 Maybe missing space or something 2022-11-26 17:41:34 Works when I write it manually instead of copy-paste from page 2022-11-26 17:54:55 It's not a common practice to namespace words in vocs? 2022-11-26 17:55:13 I see str= and str<, which could have been = and < in a string voc instead, potentially 2022-11-26 18:29:38 Hmmm. 2022-11-26 18:30:11 I'm assuming the >>> and <<< are framing added by the system; the code is just : $@len ( addr -- u ) @ @ ; 2022-11-26 18:30:12 right? 2022-11-26 18:30:24 I don't see anything wrong with that. 2022-11-26 18:30:38 you would need to box stack items with string(...) or uint(...) for a generic < to know what to do with "something" on the stack 2022-11-26 18:34:23 Yeah, Forth doesn't recognize types. str= is an entirely, completely different word from =, and the compiler has no idea that they are even related conceptually. 2022-11-26 18:35:01 It blindly matches strings parsed from the input with strings found in the dictionary. 2022-11-26 18:35:21 It either matches or it doesn't - there isn't any concept of "partial match." 2022-11-26 19:58:32 Back in the really early days, in a book he wrote, Chuck talked about the possibility of matching input substrings. If you searched the dictionary for a whole string and didn't find it, before going straight for a number conversion you'd search again after dropping the last character. And so on. It would be a "greedy match," finding the longest dictionary string that matched a prefix of the input word. 2022-11-26 19:58:34 That would be the "found word," and the part you had to lop off to get there would be treated as a parameter in some fashion. 2022-11-26 19:58:51 That never really went anywhere - my impression was that he later decided it wasn't particularly useful. 2022-11-26 20:00:57 But a mechanism like that would let you implement the sort of thing you were wondering about - str= could just match str= if it was in the dictionary, but also could match a "class" of words str and the = would be a parameter telling you what function to run from the class. 2022-11-26 20:01:36 I'm not sure it buys much - you still had to write all of those different functionalities - it's just a different way to organize getting to them. 2022-11-26 20:02:24 seems like a good way to do "Did you mean?" like gcc has 2022-11-26 20:03:41 which sometimes can go woefully wrong if automatic 2022-11-26 20:03:47 The dnf package manager does a nice-ish job of that too. If you get close to the right package name, it'll usually tell you what you really wanted. 2022-11-26 20:06:11 So, if you wanted something fancier, one way of going would be to have an "object stack" instead of just a stack of cells. The object reference you put on the stack would of course get you to its data, but it could also let you find an "object specific vocabularly." That way just putting the object on the stack would give you access to words specific to that object. 2022-11-26 20:06:45 Each object on the stack would have one of those, so you might find value in searching the top several; I haven't really given it much thought. 2022-11-26 20:07:28 I may try that out when I get ready to do that fancy Octave-like thing. 2022-11-26 20:08:07 I'd only previously really thought about it specifying where (in a heap structure) to find the object data, but it could also have namespace effects. 2022-11-26 20:09:01 I'd thought about handlng that the other way I mentioned - you search for a dictionary entry that had input requirements matching the current stack. 2022-11-26 20:09:19 That should rule out the possibility of stack underflow completely - you'd never find a word that would underflow the stack. 2022-11-26 20:09:41 For example, if the stack was empty, you wouldn't even find DROP in the dictionary. 2022-11-26 20:10:59 We've talked about the problem that comes up - the compiler would have to track stack changes through a definition, and those pesky "multiple paths with different effect" come in. 2022-11-26 20:11:42 Hey, maybe that becomes something you have to account for. if there's a spot in your code that could have different stack states depending on how you go there, you'd have to provide code for dealing with both of them. 2022-11-26 20:11:48 Some sort of "resolution." 2022-11-26 20:15:32 isnt that just usual dataflow analysis? 2022-11-26 20:16:02 Probably. :-) It just came to mind - there may well be a formal idea behind I never got exposed to. 2022-11-26 20:17:02 I'm reading now: https://en.wikipedia.org/wiki/Data-flow_analysis 2022-11-26 20:17:40 Yeah, it certainly looks like it's in the right neighborhood. 2022-11-26 20:18:55 Looks like a compiler could pretty easily run that process on a section of code, and could point out exactly what uncovered possibilities there might be. 2022-11-26 20:33:37 In the older Forth systems where FIND produced several items on success but only one (a false flag) on failure, that was how we had to write our code. It worked out, because we used the results in different ways depending on which one we got. It worked out in the end, but only because we were aware of it and provided follow-up code that corrected the situation. 2022-11-26 20:34:53 So divergent results can feed into a point, but only if we then use another conditional to split back out to divergent paths to deal with the various possibilities. 2022-11-26 20:36:06 Seems like surely having the compiler able to do that would be useful in detecting / chasing down stack imbalance bugs.