2023-09-19 00:10:35 The rational numbers implicit in Wildberger's preferred approach don't naturally have the range that floating point numbers have, but Chuck's already taught us that scaled integers can handle the normal jobs of floating point, so maybe that comes into play here as well. 2023-09-19 00:13:16 Also, I want to be able to do geometric algebra style calculations. That means that "multivectors" can have components of mixed dimensionality - for example, the geometric product of two vectors has a scalar part and a bivector part. I want to be able to work conveniently with such multivectors. 2023-09-19 00:14:31 That's basically what a complex number is - it's an entity with a scalar part and a bivector part in two dimensions. The scalar is the "real" part and the bivector part is the imaginary part. In 2D there's only one unit bivector, so a single number can represent that. 2023-09-19 00:15:07 There is no vector part; if you start out with just scalars and bivectors you can't produce a vector with any arithmetic operation, so they just don't appear in your calculations. 2023-09-19 00:15:29 Formally they say that "complex arithmetic is the 'even order sub-algebra' of 2D geometric algebra." 2023-09-19 04:29:01 problem: Forth operates on what is in the stack, so `1.0 3.0 to-polar` will convert that cartesian points to polar coordinates, but what about in the stack i have more points? to i have specify a to-polar-n function which i tell it how many points it must translate, or there is some more general approach to this? 2023-09-19 05:30:25 rendar: Maybe something like 1E >POLAR 3E >POLAR 4E >POLAR 2023-09-19 05:30:31 I.e. have it do one at a time 2023-09-19 05:30:37 and just call it for each thing on stack 2023-09-19 05:31:20 Or have an array ... CREATE COORDS 1E F, 3E F, 4E F, COORDS 3 >POLAR 2023-09-19 05:31:43 what is 1E 2E.. ? 2023-09-19 05:31:48 Floating point numbers 2023-09-19 05:32:07 Fixed point is fine as well, I just wrote floating point in case you don't realise 1.0 is 10 0 2023-09-19 05:34:38 i have a word "to-polar" which pops out from the stack x and y coord, convert, then pushes them again into the stack, what about having multiple points? it will pop only 2 floats (1 point) unless i create >polar-n which pops the first element from the stack which is an integer telling how many points we have 2023-09-19 05:39:12 What forth are you using? 2023-09-19 05:41:06 rendar: you could stash them on the return stack? >r and r> 2023-09-19 06:15:09 veltas, my implementation 2023-09-19 06:15:36 dave0, hmm i don't have these words implemented yet, can you give me a list of all these particular words? 2023-09-19 06:16:35 rendar: So assuming those are actually floats I would do 1.0 >POLAR 3.0 >POLAR 4.0 >POLAR 2023-09-19 06:17:00 My point is you don't usually need a "N things on stack" word 2023-09-19 06:17:13 Words should usually operate on some tiny quantity 2023-09-19 06:17:30 veltas, what? >POLAR conversion takes 2 parameters not 1, plus i have (x,y) on the stack (2 floats) as a *result* of another function 2023-09-19 06:17:35 In fact, instead of >POLAR I'd probably call it POLAR 2023-09-19 06:17:56 Then: 1.0 3.0 POLAR 4.0 5.0 POLAR 2023-09-19 06:18:23 but i have another function which results in N points on the stack, so i have: 1.0 3.0 4.0 5.0 2 2023-09-19 06:18:26 on the stack 2023-09-19 06:18:40 So I'm saying "don't do this" 2023-09-19 06:18:41 if i have polar-n it pops 2, then it knows it has 2 points 2023-09-19 06:18:48 why not? 2023-09-19 06:18:58 Is your question "should I" or "how do I" because it wasn't clear to me 2023-09-19 06:19:24 I don't really know why you're asking how to do something in your own forth, that's the especially confusing part of this question 2023-09-19 06:19:57 my question is: if i can do that with polar-n, its not convenient to have all-other-words[-n] implemented, there is a general way to do this? e.g. [2 points..] and then `polar 2 repeat` 2023-09-19 06:20:18 Yeah if you define a word to do that generally 2023-09-19 06:20:21 In your own forth.... 2023-09-19 06:20:34 in normal forth there isn't anything like that? 2023-09-19 06:20:45 As dave0 said you can use >R R> R@ etc 2023-09-19 06:21:08 ok i'm not familiar with these words, because i'm pretty new to Forth, where I can learn more about those? 2023-09-19 06:21:22 Or PICK and ROLL 2023-09-19 06:21:38 >R R> are in Starting Forth and probably any Forth tutorial 2023-09-19 06:21:58 R@ was called I in Starting FORTH, but it just gets the top return stack item, so I can explain that here 2023-09-19 06:22:22 https://forth.sourceforge.net/standard/dpans/dpansf.htm 2023-09-19 06:22:25 PICK and ROLL you can probably google, they are in newer standards (ANS and later) and get the nth item from stack, or 'rotate' n items on stack 2023-09-19 06:22:39 GeDaMo: I'd direct to standard but it's not a tutorial 2023-09-19 06:22:57 It isn't easy to read 2023-09-19 06:23:19 But you're going to get the standard advice here to not do this 2023-09-19 06:23:54 It sounds like you're going for some kind of generality that doesn't fit well with Forth 2023-09-19 06:24:29 And I will give advice that writing a Forth is not a good way to learn the basics of writing Forth programs 2023-09-19 06:25:19 rendar: if it's a list of points, you could use a variable, or create an array 2023-09-19 06:25:33 rendar: just give a len to iterate 2023-09-19 06:25:46 like how many pairs of points you return 2023-09-19 06:25:59 then just execute polar that many times 2023-09-19 06:26:12 oh, but you have to swap and alike 2023-09-19 06:26:29 i have iterators for that 2023-09-19 06:26:51 for example that would be with dopairs 2023-09-19 06:26:52 An array is better for a list of points where they all need to be held at once in memory 2023-09-19 06:27:08 yes 2023-09-19 06:27:33 it's better to use memory than the stack i suppose 2023-09-19 06:27:59 For a list of points ... on a conventional forth system 2023-09-19 06:28:01 you just give polar the direction 2023-09-19 06:28:49 dopairs takes a list of elements and pushes two, then executes the code you have 2023-09-19 06:29:19 so it would be like: points-list 'polar do.pairs 2023-09-19 06:29:47 But bear in mind vms14 is not describing a forth system 2023-09-19 06:29:53 every time will push two elements of the points list and execute polar 2023-09-19 06:30:10 yeah, but you can apply almost every idea 2023-09-19 06:30:21 it's an iterator 2023-09-19 06:30:46 I'm just saying because I can't see how what you're writing isn't confusing here 2023-09-19 06:30:47 the cool thing of making your own lang is mainly that 2023-09-19 06:31:39 how would it be an iterator like that in forth? 2023-09-19 06:32:02 you can give the execution token of a word as far as i know 2023-09-19 06:32:14 Yeah, with ' (tick) 2023-09-19 06:32:57 Except in 'standard' forths you couldn't write tick as a prefix in the word, it would need to be separated with a space 2023-09-19 06:34:57 well my Forth implementation doesn't have a return stack, so R> and :O 2023-09-19 06:35:15 how dare you rendar 2023-09-19 06:35:20 lol 2023-09-19 06:35:36 i don't have a return stack either :/ 2023-09-19 06:35:53 but mine is not a forth 2023-09-19 06:36:01 just a concat lang 2023-09-19 06:36:19 what lang is that? 2023-09-19 06:36:47 a toy rpn lang which resembles more to lisp than to forth 2023-09-19 06:37:03 wow, very interesting, lisp with a stack? 2023-09-19 06:37:06 it's a reversed lisp :D 2023-09-19 06:37:21 no, it has a stack and colon words 2023-09-19 06:37:45 but also lexical scope, closures, lists as code, quote, quasiquote, etc 2023-09-19 06:38:09 the dictionary does not exist, it's an environment 2023-09-19 06:38:33 and every time i rewrite the lang gets closer to a lisp, even being rpn 2023-09-19 06:41:48 a colon word is just a list and an environment 2023-09-19 06:42:01 which in some way is the same as a lambda 2023-09-19 06:42:41 oh, like ((1 2 +) (3 4 +) +) ? 2023-09-19 06:43:25 no, internally, it's rpn but there's almost no difference between 2023-09-19 06:43:37 what you mean with rpn? 2023-09-19 06:43:46 : oh 1 2 3 ; oh and (1 2 3) eval 2023-09-19 06:43:58 reverse polish notation 2023-09-19 06:44:02 i see 2023-09-19 06:44:15 the only difference is the colon word has an environment 2023-09-19 06:44:33 and can have inner words only available in its scope 2023-09-19 06:44:54 : oh : meh 1 2 3 ; meh ; 2023-09-19 06:45:27 meh does not exist outside and can only be found by oh or sibling words 2023-09-19 06:45:39 or children of meh 2023-09-19 06:45:51 rendar: If you've got no return stack then how do words return? Or do all words get inlined? 2023-09-19 06:46:37 basically all words are just entries into an hash table String->FnPointer 2023-09-19 06:46:44 they just modify the stack 2023-09-19 06:47:04 they are not compiled in machine assembler 2023-09-19 06:47:40 or, in a larger view, they are, because FnPointer points to some compiled function 2023-09-19 06:47:40 its a bytecode interpreter? 2023-09-19 06:47:50 vms14, we can call like that, yeah 2023-09-19 06:51:55 What is this VM for? 2023-09-19 06:52:22 Is it going to be some kind of RPN calculator? 2023-09-19 06:53:42 yeah 2023-09-19 06:53:45 exactly 2023-09-19 06:53:52 some toy project i'm writing in Rust 2023-09-19 06:53:58 :O 2023-09-19 06:54:16 a forsth 2023-09-19 06:54:19 So it's not really comparable to Forth because Forth is a programming environment, it's also a desk calculator but it's not really aimed at that 2023-09-19 06:55:16 veltas, well, my one is not only a calculator 2023-09-19 06:55:21 what defines a forth? 2023-09-19 06:55:23 it aims to be programmable and a language too 2023-09-19 06:56:35 vms14: Well I don't know how rigid it is but the topic for this channel suggests two stacks 2023-09-19 06:56:54 rendar: How are you going to allow nested words, or are you not? 2023-09-19 06:56:57 If there's no return stack 2023-09-19 06:57:15 Forgive me, I didn't understand how that was overcome with your response earlier 2023-09-19 06:57:20 veltas, you mean `: foo bar ;` ? 2023-09-19 06:57:23 Yeah 2023-09-19 06:57:34 Although that technically wouldn't need a return stack 2023-09-19 06:57:53 i need a return stack, or a loop or branch data structure 2023-09-19 06:57:58 Because it only calls bar so you could just jump to bar 2023-09-19 06:58:29 simple: "foo" will point to a chunk which contains Word("bar") which in turn will point to another Chunk.. and so on, until you get a builtin word which in turn will execute some FnPointer 2023-09-19 07:00:19 rendar: so your program reads a list of key indices for a hash with code as values? 2023-09-19 07:00:48 it just iterates the list and executes the code 2023-09-19 07:00:51 not code, pointer to code, or integers indexes to a jump table 2023-09-19 07:01:08 that's for the builtin words 2023-09-19 07:01:32 the user defined words are just vector of atoms (e.g. "2.0") and other words 2023-09-19 07:01:36 rendar: That's how it executes, but how will those chunks 'return'? 2023-09-19 07:01:46 veltas, by modifying the stack 2023-09-19 07:01:53 :O 2023-09-19 07:02:02 So shared data and return stack? 2023-09-19 07:02:08 they return the next word to execute? 2023-09-19 07:02:18 vms14, what? no 2023-09-19 07:02:39 then how modifying the data stack lets your words return 2023-09-19 07:02:43 veltas, no, they read data from the stack (pop), then push back data into the same stack (push) 2023-09-19 07:02:47 we don't mean return values 2023-09-19 07:02:48 only 1 stack, not 2 2023-09-19 07:03:05 but return to the execution of the next word 2023-09-19 07:04:03 look: "1.0 2.0 cos" -> x = stack.pop(); y = stack.pop(); result = hashtable["cos"](x,y); stack.push(result); 2023-09-19 07:04:42 look: "1.0 2.0 cos exp" -> x = stack.pop(); y = stack.pop(); result = hashtable["cos"](x,y); stack.push(result); x = stack.pop(); result = hashtable["exp"] stack.push(result); 2023-09-19 07:05:20 and a colon word is a list of integers that are indices to a jump table, which holds the definitions of builtins 2023-09-19 07:05:43 to execute a colon word you just iterate it? 2023-09-19 07:06:23 `: hello 2.0 *;` is hashtable["hello"] -> Vector[ Atom(2.0), Word("*") ] 2023-09-19 07:06:54 it's mostly how my colon words are 2023-09-19 07:07:04 except that they also have an environment 2023-09-19 07:11:46 https://pastebin.com/GNmcEbh0 2023-09-19 07:12:13 rendar: Are nested words executed in a recursive way? 2023-09-19 07:13:05 yeah how do you approach recursion? 2023-09-19 07:13:09 veltas, what you mean exactly? if i support recursion? e.g. : foo ... foo ... ; ? 2023-09-19 07:13:37 i want a return stack mainly because of tco 2023-09-19 07:13:49 for now, i don't have recursion yet 2023-09-19 07:14:01 mine blows the stack 2023-09-19 07:14:05 but i don't know if i will support it 2023-09-19 07:14:09 i have dirty workarounds 2023-09-19 07:15:31 the difference is your words are "compiled" 2023-09-19 07:15:57 and you need the definition of a word before using it in another 2023-09-19 07:16:29 my words are just lists of code to execute 2023-09-19 07:17:06 rendar: My question is really ... is any of your rust code that does the execution 'recursive', i.e. a function directly or indirectly can call itself while executing the program 2023-09-19 07:17:06 yeah 2023-09-19 07:17:07 that's why (1 2 3) eval and : oh 1 2 3 : oh are mostly the same, except for an environment 2023-09-19 07:17:19 veltas, for now, no 2023-09-19 07:17:30 i didn't implement that 2023-09-19 07:17:58 So your words can't call other words 2023-09-19 07:18:07 other words, yes 2023-09-19 07:18:13 themselves no 2023-09-19 07:18:14 But can't return from them? 2023-09-19 07:19:00 if i have `: hello cos ;` the word "hello" can call the word "cos" 2023-09-19 07:19:06 `: hello hello ;` is blocked 2023-09-19 07:19:19 And if you can return from them... how do you keep track of what executes after the word that was called has finished 2023-09-19 07:19:30 i.e. how do you return from the word 2023-09-19 07:19:54 veltas, i shown you: "1.0 2.0 cos exp" -> x = stack.pop(); y = stack.pop(); result = hashtable["cos"](x,y); stack.push(result); x = stack.pop(); result = hashtable["exp"] stack.push(result); 2023-09-19 07:20:23 the interpreter first sees "cos" then execute it, then sees "exp" then executes it with whatever there is on the stack 2023-09-19 07:21:13 tell him how a colon word is executed 2023-09-19 07:21:18 ^ 2023-09-19 07:21:18 it's a vector 2023-09-19 07:21:23 so you iterate 2023-09-19 07:21:37 What if there's a word inside a word.................... 2023-09-19 07:21:50 pin-the-tail-on-the-return-stack is getting a bit old 2023-09-19 07:22:18 well, let me rephrase that: "1.0 2.0 cos exp" -> stack.push(1.0) stack.push(2.0) hashtable["cos"](); hashtable["exp"](); then those fn ptrs: cos() { x = stack.pop(); y = stack.pop() result = math.cos(x,y); stack.push(result); } 2023-09-19 07:22:54 a colon word, change the parser state 2023-09-19 07:22:56 for example this is how i execute a colon word 2023-09-19 07:22:58 with_environment { interpret_list($word->{content}) } $word->\ 2023-09-19 07:22:58 {environment}; 2023-09-19 07:23:11 fuck emacs 2023-09-19 07:23:26 my colon word is a "special word" which starts with special character # 2023-09-19 07:23:34 so, in reality i have #: hello cos #; 2023-09-19 07:23:57 words which starts with #, changes the parser (or reader) state 2023-09-19 07:24:25 instead of reading stuff to put them into the stack, it will read stuff to put it into a new chunk which name is the first word 2023-09-19 07:24:41 and #; will change the state again to return the reader to put stuff into the stack 2023-09-19 07:24:53 : meh 1 2 3 : : oh meh 4 5 6 ; 2023-09-19 07:25:02 ah 2023-09-19 07:25:19 the secon colon is a semicolon 2023-09-19 07:25:25 yeah 2023-09-19 07:25:37 then suppose you execute oh 2023-09-19 07:25:44 which executes meh 2023-09-19 07:25:55 yeah 2023-09-19 07:25:59 but then has to execute 1 2 3 2023-09-19 07:26:05 no 2023-09-19 07:26:10 it won't execute 1 2 3 2023-09-19 07:26:14 those are atoms 2023-09-19 07:26:19 it will push 1 2 3 on the stack 2023-09-19 07:26:38 then how it comes back to the remaining code of oh 2023-09-19 07:26:42 if you call oh you end up with 1 2 3 4 5 6 on the stack 2023-09-19 07:26:43 which is 4 5 6 2023-09-19 07:27:06 it doesn't, it hasn't to "return back", it will read the next instructions 2023-09-19 07:29:21 when it reads oh, it starts a loop reading all in the chunk: basically it reads first "meh", then it executes that because its a word, by hashtable["meh"](), then it continues reading, and pushed 4, 5, 6 2023-09-19 07:29:29 pushes* 2023-09-19 07:29:56 that's what veltas wanted to know i guess 2023-09-19 07:30:05 well 2023-09-19 07:30:16 but already knew it since i saw a vector xd 2023-09-19 07:30:25 consider that for user defined words, there is a special function to execute that, which is different that builtin ones 2023-09-19 07:30:30 you just iterate it 2023-09-19 07:30:41 you use the return stack of your host lang 2023-09-19 07:30:46 like me 2023-09-19 07:30:50 vms14, indeed! basically.. 2023-09-19 07:30:59 that's why he asks you about recursion 2023-09-19 07:31:02 yeah 2023-09-19 07:31:16 because you are likely to have recursion trough rust 2023-09-19 07:32:01 the thing is you cannot reference a word that is not already defined 2023-09-19 07:32:06 at least not yet 2023-09-19 07:32:42 that's why in forth sometimes exists the word recursion 2023-09-19 07:32:43 well, basically you iterate over a chunk, which in turn will call a bultin word (which is a jump table basically) or another user defined word, so another chunk 2023-09-19 07:32:54 which makes the current word recurse 2023-09-19 07:33:02 ah it's named recurse 2023-09-19 07:33:26 http://www.forth.org/forth_intro/recurse.htm 2023-09-19 07:33:40 you can even have linear algorithms to do this recursive calling 2023-09-19 07:33:47 e.g. with a return stack! lol 2023-09-19 07:35:23 i was thinking that i could turn recursion into a loop and save the remainder of execution 2023-09-19 07:35:44 once the loop ends, just execute the remainder 2023-09-19 07:36:26 it should allow me to use recursion with the same optimization as tco, but without having to be tail call 2023-09-19 07:36:38 but i need a return stack :/ 2023-09-19 07:38:03 well, isn't that what tco does basically? transforming recursion into an iterative loop? 2023-09-19 07:39:30 This is why I asked because quite often, as in your case, when people say they don't have a return stack... they actually do have a return stack 2023-09-19 07:40:01 Whether it's the stack of a language they implemented it in, or somehow else 2023-09-19 07:40:09 Rarely it's inlined, which is what vms14 did originally I think? 2023-09-19 07:40:36 Where there's a return stack still, but it doesn't exist at runtime 2023-09-19 07:40:56 But that generates explosive code output 2023-09-19 07:44:52 originally? i remember the first time i had an @execution stack, which was a weird return stack 2023-09-19 07:45:03 i pushed code to that stack 2023-09-19 07:45:10 As far as I'm concerned the 'stack' in Forth should be thought about the same way as the 'registers' in machine code. It's convenient, temporary, small. 2023-09-19 07:45:14 a loop multiplied the code xd 2023-09-19 07:46:18 It's more like registers plus register saving because you can certainly use a deep stack, but each word should only worry about a small number of things at once 2023-09-19 07:48:09 ah when tried to optimize recursion i turned them to a loop 2023-09-19 07:48:45 a loop like while(flag){flag=0;execute_code()} 2023-09-19 07:49:26 if the code executed executes the word 'recurse' then flag=1 so the loop repeats 2023-09-19 07:49:28 xD 2023-09-19 07:50:00 the sad part is you have to stop the remainder or be tail call 2023-09-19 09:38:55 I actually get physical pain in my head when people describe what someone else did in a daily scrum 2023-09-19 10:24:52 I often wind up rolling my eyes over the whole "ceremony" around all that stufF (agile, scrum, etc. etc.) 2023-09-19 10:25:54 When the terms get used as if just saying the magic words is going to produce some kind of desired outcome. 2023-09-19 10:26:18 No but I really just don't need people saying what I did right before I'm meant to say what I did 2023-09-19 10:26:29 And I sort of sympathise when it happens to other people as well 2023-09-19 10:27:00 Oh, I see what you're talking about. Yeah - everyone's got to say something; don't undermine the guy that goes after you. 2023-09-19 10:27:53 But in a sense it does get at the "ceremony" aspect - just tha tprocess of everyone having to say something because... that's how it's done. 2023-09-19 10:28:22 Maybe I go to scrum and everything's fine and I don't HAVE anything I need to say. 2023-09-19 10:28:43 The second we worry about stuff like this it's deviated from the point of the daily scrum, which is to make sure everyone knows what's happening and what the blockers are 2023-09-19 10:28:48 and maybe plan and resolve issues 2023-09-19 10:28:55 Right. 2023-09-19 10:29:06 If it becomes show-and-tell for 15 minutes it's a pointless ritual 2023-09-19 10:29:27 And also, I've wondered why, if someone is stuck and needed help, they didn't go find that help on their own before scrum. 2023-09-19 10:29:42 The only thing worse than a pointless ritual is a pointless ritual where someone's drunk my shot of tequila already 2023-09-19 10:29:51 lmao 2023-09-19 10:29:53 I hear you. 2023-09-19 10:30:25 Quite often a day is about the right granularity to make a decision to throw your hands up and ask for help 2023-09-19 10:30:52 Like "I spent all afternoon banging my head and didn't happen to make progress so can someone help" 2023-09-19 10:31:00 Is better than immediately asking for help whenever you get stuck 2023-09-19 10:31:09 It depends how likely progress is though 2023-09-19 10:31:55 And often there's work to keep busy with even if you're blocked right now on one thing 2023-09-19 10:35:30 Yeah, I think it depends on the situation, and the more experience you have the better you can gauge whether it's likely you're going to resolve something on your own. 2023-09-19 10:35:54 If I can make a three hour issue go away in five minutes by asking the guy next door, that seems like the thing to do. 2023-09-19 10:42:53 On the other hand, if I'm going to need that other person for two hours then it would have been better for me to take three to solve it on my own. 2023-09-19 10:43:43 When I first joined Texas Memory Systems, it was still privately owned, and the little guy that owned the place was a real piece of work. He had an obsession over "today." What are you going to get done TODAY? Constantly. 2023-09-19 10:43:55 You know, you don't always reach a demonstrable milestone every day. 2023-09-19 10:44:38 I thought I'd been "aggressive" in earlier years when I was in leadership positions, but I was nothing compared to him. 2023-09-19 10:45:53 And he was a near total micromanager. He had some really top drawer guys around, but he wouldn't "turn them loose." I used to describe it by saying that it was like he owned a fine thoroughbred racehourse, but insisted on talking along beside it telling it where to put its fee. 2023-09-19 10:45:56 feet 2023-09-19 10:46:07 walking 2023-09-19 10:46:47 That said, he's now the richest man I've ever known personally and I'm... not. :-| 2023-09-19 10:46:54 i don't ask for errors in my code without trying to solve them by myself first 2023-09-19 10:47:08 but i do ask for errors on my design at any time 2023-09-19 10:47:20 Well, 99% of the time you're the person that can solve them the fastest. 2023-09-19 10:47:50 Usually errors are... errors. You just typed something wrong or goofed in some small way - most of the time it's not the case that you don't understand what you're doing. 2023-09-19 10:47:59 almost every idea i have i expose it to others and receive a lot of useful feedback 2023-09-19 10:48:34 That's an interesting way of putting it, I suppose I do the same thing 2023-09-19 10:48:37 but i understand veltas talks about lazyness 2023-09-19 10:48:56 my case is about stealing knowledge :D 2023-09-19 10:49:04 Also just because you gain an hour doesn't mean it's right to make an engineer lose an hour 2023-09-19 10:49:14 Because it make take them an hour to get back in the zone 2023-09-19 10:49:27 well, i learn, i get the idea clearer just by exposing it, sometimes i get feedback or other ways to do a thing 2023-09-19 10:50:35 veltas: haha my main goal of getting a programming job is to annoy the others with more experience with questions 2023-09-19 10:51:13 brb 2023-09-19 11:00:37 vms14: I'm usually happy to help less experienced people, but it does "depend" - I really want to feel like it was "worthwhile" help. That is, I don't mind investing some time if I can feel like I really advanced the other person's ability in some worthwhile way. If it's "one lame question after another," then yes - that can get annoying. 2023-09-19 11:01:49 I have the same reaction "helping my kids with homework." I don't really have any interest in just "giving them answers." I'm happy to *teach* them, though. Kind of a "teaching to fish" vs. "giving fish" type of thing. 2023-09-19 11:06:59 Of course 2023-09-19 13:38:39 KipIngram: would a interpreter with different states help somehow with event systems? 2023-09-19 13:39:12 i have that thingy of a hash table with lists of handlers 2023-09-19 13:39:31 for some reason if i want to think on improving that states come to mind 2023-09-19 13:40:18 or better said, how can i improve that hash table thing 2023-09-19 13:40:57 i suppose types can also do something there 2023-09-19 13:41:16 there's publishers and subscribers, channels, broadcast 2023-09-19 13:41:26 at the end i have all that with the hash table xd 2023-09-19 13:47:28 I don't immediately see how. I'm pretty simple-minded about such things, though; to me an "event system" is just a loop that repetitively checks to see if various things have happened and if they have calls some suitable code. 2023-09-19 13:48:04 Such a thing is for situations where you don't know exactly when the things are going to happen, or in what sequence, etc. 2023-09-19 13:48:37 It's just a way to respond to "random sequencing" from the world. 2023-09-19 13:48:55 On the other hand, compiling is a response to carefully planned input sequence. 2023-09-19 13:49:04 So I don't really see what the two have to do with each other. 2023-09-19 13:55:10 KipIngram: what if you are multitasking? 2023-09-19 13:55:57 you would have a way to share data or something 2023-09-19 13:56:12 my interest in events is due to async code and alike 2023-09-19 13:56:31 it seems to help a bit 2023-09-19 13:56:31 Do you mean multi-user / multi-session, or just multi-thread? 2023-09-19 13:57:13 A thread could use an event type system to respond to "events" created by other threads. 2023-09-19 13:57:29 in that case I'd see it as monitoring a set of signal pipes. 2023-09-19 13:57:57 This makes me think of digital circuit simulation. 2023-09-19 13:58:08 it's kind of similar to a signal handler 2023-09-19 13:58:19 what i have 2023-09-19 13:58:22 You've got a collection of components. When a component has an input change, then its output will change some time later - the propagation time for the component. 2023-09-19 13:58:36 The circuit netlist tells you how outputs are connected to the inputs of other components. 2023-09-19 13:58:54 So, you change an input, and then your code has to ripple that change through the circuit, until things stop changing. 2023-09-19 13:59:28 You can do this with a single event queue - whenever you find out when an output is going to change, you stick that item into the queue, keeping the queue in time order all the time. 2023-09-19 13:59:42 you observe the input changes 2023-09-19 13:59:53 Then the simulation just pops the next output change off of the queue, advances the clock to that time, and uses the netlist to figure out what further changes to put in the queue. 2023-09-19 14:00:01 Then you just go go go, until the queue becomes empty. 2023-09-19 14:00:10 That's a stable circuit configuration. 2023-09-19 14:00:31 If you include "don't know" in your set of logic values, along with 0 and 1, you can detect timing hazards with this. 2023-09-19 14:00:55 The idea there is that if your output is going to change from 0 to 1, you post to events - first a 0 to X event and then a little later an X to 1 event. 2023-09-19 14:01:14 If you've properly met all your timing requirements, no component will ever actually USE an X input. 2023-09-19 14:01:45 Because a component will see an input become X, but it'll say "that's not my clock input, so I don't do anything yet." 2023-09-19 14:01:56 Hopefully by the time its clock arrives, that input has left the X state. 2023-09-19 14:02:13 It's a nice little playground. 2023-09-19 14:02:18 the hash table i have is because i tried to simplify the event system 2023-09-19 14:02:25 and it reduced to a hash table 2023-09-19 14:02:40 I'm not sure I follow you well enough to see the connection. 2023-09-19 14:02:42 a hash table with lists as values 2023-09-19 14:02:47 and event names as keys 2023-09-19 14:03:24 i mean the philosophy of chuck seems to work 2023-09-19 14:04:25 because with this hash table it seems i can cover all the event system needs, and i would have found a more complicated way to achieve the same 2023-09-19 14:04:36 i assume it can even be more simplified 2023-09-19 14:04:53 Well, an event system really calls for a queue. But I suppose you could build a queue onto a hash table. 2023-09-19 14:05:13 Have you boiled this down to is most simplified requirements? You shouldn't really need to consider how you're implementing your queue. 2023-09-19 14:05:16 It's just a queue. 2023-09-19 14:05:32 there is no queue 2023-09-19 14:05:38 Hash tables are rather fundamentally "unordered." 2023-09-19 14:05:40 and no event loop 2023-09-19 14:05:52 Then how do you have an "event system"? 2023-09-19 14:05:57 If you don't have an event system? 2023-09-19 14:06:13 you cant receive an event if you did not register before the event was triggered 2023-09-19 14:06:21 because the event was never sent 2023-09-19 14:06:22 I think you just haven't described what you're doing clearly enough for me to follow. 2023-09-19 14:06:34 sorry 2023-09-19 14:06:45 i have a hash table named %event 2023-09-19 14:06:53 Ok. 2023-09-19 14:07:08 when i say: (some code) 'somename watch 2023-09-19 14:07:37 i push (some code) into $event{somename} 2023-09-19 14:07:59 Ok. So you've set a named item to some code. 2023-09-19 14:08:00 it's a list so i can push more handlers 2023-09-19 14:08:13 ' 2023-09-19 14:08:20 That seems like you're just naming that code. 2023-09-19 14:08:36 when i say: 'somename event 2023-09-19 14:08:41 Not too different : somename ...code.... ; 2023-09-19 14:09:07 i iterate all the handlers registered in $event{somename} and execute them 2023-09-19 14:09:23 Ok, so you can have more than one bit of code attached to a name? 2023-09-19 14:09:24 there's also another word to give arguments to them 2023-09-19 14:09:36 yes, they are a list, handlers get pushed to that list 2023-09-19 14:09:52 Ok. So you have named lists, and the list items are code. 2023-09-19 14:09:55 (1 2 3) 'somename event* 2023-09-19 14:10:15 I think the fact that you're using a hash table is fairly irrelevant. 2023-09-19 14:10:22 At least given how you've described it so far. 2023-09-19 14:10:26 now for all handlers registered to somename it will push 1 2 3 and execute every handler 2023-09-19 14:10:46 also the handlers can remove themselves or other handlers 2023-09-19 14:11:03 i think this covers everything i could take from an event system 2023-09-19 14:11:13 and look that there is no queue or loop 2023-09-19 14:11:24 it's just code attached 2023-09-19 14:12:09 a subscriber is (code) eventname watch 2023-09-19 14:12:22 or the name of a word to execute instead of a list of code 2023-09-19 14:12:51 to broadcast is just to use the event* word that pushes arguments 2023-09-19 14:13:01 I don't think it looks like an "event" system. It's just a command dispatch system. 2023-09-19 14:13:27 Like I said earlier, when I think of "events" I think of an unknown sequence of inputs from some outside source. 2023-09-19 14:13:28 but what does an event system that it's not covered there? 2023-09-19 14:13:58 Normally you'd have one specific bit of code that responded to a given events. 2023-09-19 14:14:00 event 2023-09-19 14:14:37 And when an event happens, you usually will want some particular "handler" to handle it - not a whole slew of them. 2023-09-19 14:14:59 it depends on you 2023-09-19 14:15:09 if you only want one, you only register one 2023-09-19 14:15:12 On the other hand, there are situations where you might like to be able to have a whole bunch of threads waiting for a "go" signal, and you'd like to be able to kick them all off at once. 2023-09-19 14:15:32 What are some examples of the things you're calling "events"? 2023-09-19 14:16:00 say i read from a nonblocking socket in a loop 2023-09-19 14:16:46 i can register a handler for a 'key event 2023-09-19 14:17:01 and every time i read a key i just sent the event 2023-09-19 14:17:05 And you want multiple bits of code responding to that key? 2023-09-19 14:17:08 it will execute 2023-09-19 14:17:21 i can do what i prefer 2023-09-19 14:17:43 for example i could make every key the name of an event 2023-09-19 14:17:50 and register an event for every key 2023-09-19 14:18:22 or better just register a 'key event handler that receives the key when called 2023-09-19 14:18:23 Maybe I'm just being dense here, but I'm just not seeing the "killer app" situation for this. 2023-09-19 14:18:53 Are you trying to orchestrate cooperating threads, or deal with input from a flock of input devices, or what exactly? 2023-09-19 14:20:27 i''ll implement it 2023-09-19 14:21:55 Note that I'm not saying it won't do what you think it will do - I just don't get what's to be "done" with it. 2023-09-19 14:28:11 https://imgur.com/a/GzlVKLA 2023-09-19 14:28:56 now i have to make event* 2023-09-19 14:29:59 https://imgur.com/a/cGqjtdR 2023-09-19 14:30:10 this is the implementation in perl xd 2023-09-19 14:30:22 %event is a global hash table 2023-09-19 14:35:44 https://pastebin.com/xJk8jkdH 2023-09-19 14:35:53 sorry about the images 2023-09-19 14:37:25 i dont have newlines yet 2023-09-19 14:39:03 for me it looks like i can achieve the same stuff i could achieve with some event system 2023-09-19 14:39:12 without the need of a loop or a queue