2022-06-20 02:32:26 as established, it runs on uxn/varvara, a virtual machine 2022-06-20 02:43:10 Zarutian_HTC: when was this written? 2022-06-20 04:35:27 do Templates exist in forth ? 2022-06-20 04:36:38 I guess not because in C its written from the compiler 2022-06-20 04:37:44 I m looking to build a Template T that acts object's style 2022-06-20 04:41:35 templates are generic programming 2022-06-20 04:41:42 as in, programming that works independent of data type 2022-06-20 04:42:12 why do you need templates? 2022-06-20 04:50:00 I would like to have a definition of generic 2022-06-20 04:51:19 so one can use "template" T < > with any word but with a common set of "commands" 2022-06-20 04:52:23 one must just type myB USE T ... or myB RES T 2022-06-20 04:53:11 but one can also define myA with the same Template and do myA USE T similary 2022-06-20 04:57:17 < myA myB > COMPARE T 2022-06-20 05:10:15 how are builds and does not generic? 2022-06-20 05:10:57 sounds like you're approaching forth wrong, if im being honest 2022-06-20 05:11:08 what are you actually trying to do? 2022-06-20 05:16:17 a super- : T that acts like an object 2022-06-20 05:16:48 with generic commands myObjectB USE T 2022-06-20 05:17:38 but why do you want objects 2022-06-20 05:17:47 (would execute the definition of DOES) 2022-06-20 05:21:18 for re-useable 2022-06-20 05:23:31 Instead of rewritting CReate stuff 3 times, one could just instantiate a single BUILDS DOES template and reuse the set of commands 2022-06-20 05:25:04 I ve 2 similar objects that needs the same extention of the a RESET definition so its needs to be rewritten for each Build 2022-06-20 05:25:18 but why are you using so many builds and does 2022-06-20 05:25:28 you're writing OO code in a non OO language 2022-06-20 05:29:28 Yeah you prbly right, I'll extend the forth language, well see 2022-06-20 05:35:46 why? 2022-06-20 05:36:07 whats wrong with doing things the forth way? 2022-06-20 07:59:57 ok. 2022-06-20 08:00:07 I reask my question 2022-06-20 08:02:04 Templates-like 2022-06-20 08:02:29 that acts like objects 2022-06-20 08:03:17 with a default method USE that executes 2022-06-20 08:03:45 why are you trying to do OO in forth? 2022-06-20 08:04:15 lopata: Can you give a more fleshed out demo of what this would look like in pastebin or something? 2022-06-20 08:04:34 Probably what you're asking can be done with IMMEDIATE words and POSTPONE or something 2022-06-20 08:05:04 yea ^ 2022-06-20 08:05:36 OO is needed for re-using a definition with specific Method for 2 differents "objects" 2022-06-20 08:06:35 So one coult write ObjA USE T ... would executes the Obja T based class template 2022-06-20 08:07:10 Can you explain how this is different from DOES> ? 2022-06-20 08:08:28 but why do you need objects is what im saying 2022-06-20 08:10:02 USE would be similar to Does> but it would have other methods such as RES or COMPARE 2022-06-20 08:10:14 Some people like them, multiple major Forth implementations come with OOP libraries, I'm not going to judge 2022-06-20 08:10:27 lopata: So instead of DOES> which gives you just the one method, you want more than one method? 2022-06-20 08:10:44 so one could compare vector objects with User implemented COMPARE methdo 2022-06-20 08:11:04 but like 2022-06-20 08:11:19 you could just write a compare method for vectors yourself 2022-06-20 08:11:23 without the overhead 2022-06-20 08:11:26 ie : objA USE T objB RES T < objA objB > Compare T 2022-06-20 08:13:33 yeah but it would be simpler to have a specific "class" T that can be used Postfix to agree to its methods 2022-06-20 08:15:01 one makes a definition 2022-06-20 08:15:04 would it? 2022-06-20 08:15:20 Template myT 2022-06-20 08:15:33 myT USE DOES> ... 2022-06-20 08:15:38 or are you trying to save yourself typing two characters at the cost of an entire object system 2022-06-20 08:16:45 myT RES DOES> .... 2022-06-20 08:16:57 < myT obj1 > 2022-06-20 08:17:03 I still don't understand specifically what you're asking for 2022-06-20 08:17:04 obj1 USE myT 2022-06-20 08:17:36 Please give a full example using this, without stuff , and link to it on pastebin or something 2022-06-20 08:17:44 the ability to define multiple DOES methods for a single object 2022-06-20 08:18:08 I'm not going to guess and write code for something you don't want 2022-06-20 08:18:59 Maybe have a look at https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Basic-OOF-Usage.html#Basic-OOF-Usage 2022-06-20 08:19:03 not asking for code, just want some thought about iut 2022-06-20 08:19:44 For me code is the thinking 2022-06-20 08:20:09 9 times out of 10 anyway 2022-06-20 08:26:18 it's sort of that in the link but with DOES> methods 2022-06-20 08:26:54 an unspecified Type object could be declared and use one class or another USE method 2022-06-20 08:27:21 undtermined Obj 2022-06-20 08:29:28 is it a plane is it a bird is it superMan ? 2022-06-20 08:30:05 FlyTrajectory USE PLANE 2022-06-20 08:33:01 but then it could be reused : Flight USE FlyTrajectory USE PLANE 2022-06-20 08:54:50 well that's it! a DOES> method redefinition at no cost 2022-06-20 10:52:02 Different categories of words in Forth are differentiated by having different code that is triggered when you execute them. Basically that code is passed a parameter - the "parameter field address" of the specific individual word that was run that led to that code being executed. The code is the same for all members of that category, but each has its own PFA. So : definitions have a particular bit of 2022-06-20 10:52:04 "handling" code, variables have something different, constants something else, etc. 2022-06-20 10:52:26 BUILD/DOES> allows you to create a word in which you specify that "handling functionality" using Forth instead of using machine code. 2022-06-20 10:53:03 And I've found that it usually involves "hacking" the core design very slightly - especially in direct threaded systems. It's somewhat easier to put together in indirect threading. 2022-06-20 10:53:27 But that's how I think of the difference: machine code being triggered vs. Forth code being triggered. 2022-06-20 10:54:23 Nothing stops you from writing DOES> code that uses additional stack parameters - you could have a parameter specify an item from a list of possible functions. 2022-06-20 10:55:01 And then use some kind of conditiona structure / switch functionality to let that parameter select the actual code to execute. 2022-06-20 10:55:29 That said, I've really never had a need to do anythiing like that - there's almost always a simpler way to do whatever it is I'm trying to do. 2022-06-20 10:55:44 It's awfully rare for me to use BUILD/DOES>. 2022-06-20 10:55:45 something like CASE or some such 2022-06-20 10:55:49 Right. 2022-06-20 10:56:18 The parameter field address gets put on the stack automatically when you execute the word. 2022-06-20 10:56:35 So variables don't need to "do" anything extra - that address is precisely the result they want to return. 2022-06-20 10:56:38 I did not see in eForth which I am most familiar with 2022-06-20 10:56:55 Early on it was called CREATE/DOES> 2022-06-20 10:57:34 i think both were omitted from eForth for some reason or other 2022-06-20 10:57:57 What kind of threading is eForth? 2022-06-20 10:58:16 indirect iirc 2022-06-20 10:58:30 nl 2022-06-20 10:58:34 no 2022-06-20 10:58:49 I've never written a "seriously complete" code threaded Forth, but I have done both direct and indirect, and I found BUILD/DOES> to be a pain in the ass in the direct threaded system. Felt very klunky and hacky. 2022-06-20 10:59:06 the x86 version uses jsr docolon in colon words 2022-06-20 10:59:45 followed by the colon definition list of words 2022-06-20 11:00:55 I take that both are immediate words, no? 2022-06-20 11:02:27 I've thought a LITTLE about OO in Forth, and it seemed to me that for part of it you'd like to be able to use ANY defining word as the "starting point, so that you could make "modifications" of other things. But I never saw any really clean way of doing that. Even that first step of BUILD/DOES> is slightly cumbersome, and it just gets worse. Plus you'd lose performance with each additional level. 2022-06-20 11:02:48 Something like 2022-06-20 11:02:59 : foo build ... does> ... ; 2022-06-20 11:03:02 And then 2022-06-20 11:03:10 : bar foo ... does> ... ; 2022-06-20 11:03:22 : bam bar ... does ... ; 2022-06-20 11:03:42 And you'd somehow want that to behave sensibly, and I never saw any clean way of putting it all together. 2022-06-20 11:03:44 I see, I think you have fallen into the inheritence trap of OO 2022-06-20 11:03:53 Yes, exactly. 2022-06-20 11:04:05 That was the part of it I was trying to suss out, and largely failed. 2022-06-20 11:04:28 I dispense with that completely 2022-06-20 11:04:37 Sounds wise. :-) 2022-06-20 11:04:56 I rather use composition than inheritence 2022-06-20 11:04:58 I lost interest in it when it proved to be so "un-graceful." 2022-06-20 11:05:17 doing most parts of OO in general feels like a mistake esp in forth 2022-06-20 11:05:22 I just decided it wasn't something Forth was oriented toward. 2022-06-20 11:06:09 I agree with that. I eventually decided it just wasn't a path to pursue. 2022-06-20 11:06:28 It's not like I really "knew what I was doing" in the general OO arena anyway. 2022-06-20 11:06:30 in the object system I described here some weeks ago, an object is made up of four things: the header, the xt, the refs part, and the data part 2022-06-20 11:07:33 the xt just points to the method invocation handler code for that kind of object 2022-06-20 11:08:05 The BUILD parts - those stacked together fairly well. Simple to have that first word allocate what it allocates, and then allocate some more. 2022-06-20 11:08:16 It's the DOES> chaining that doesn't work out nicely. 2022-06-20 11:08:25 which is a bit like how DOES> defined code gets control 2022-06-20 11:15:45 hmm : compile EXIT HERE @ SWAP ! ; immediate : (BUILDS) CREATE R> dup cell+ >R @ , ; \ i think 2022-06-20 11:17:03 though it leaves the address of the built word on the return stack and not on the data stack 2022-06-20 11:19:27 btw this assumes an canonical dual stack machine arch from Koopmans book 2022-06-20 11:20:02 but should work on eForth x86 too I think 2022-06-20 11:22:19 : DOES> compile EXIT HERE @ SWAP ! compile R> ; immediate \ should fix that 2022-06-20 11:25:03 for my object system I am thinking of : s/thinking of/thinking of using/ 2022-06-20 11:30:25 oprah'ed a whole word there 2022-06-20 11:32:13 due to garbage collection objptr should only be saved in objects' refs part or the obj_root variable and no where else 2022-06-20 11:33:26 gc is btw ever only called explictly and not triggered by memory pressure 2022-06-20 11:34:31 in an event loop system it is good idea to call gc at the end of an event loop turn (or at every x such) 2022-06-20 12:44:38 hi, I was just curious if there where any 2022-06-20 12:44:43 Forth programmers here 2022-06-20 12:44:49 who are Factor programmers also 2022-06-20 16:05:33 lispmacs[work]: Do you program in it or after support? 2022-06-20 16:08:14 I haven't tried Factor yet, just curious about it 2022-06-20 16:08:55 and what Forth users think of it 2022-06-20 16:11:49 Fair enough 2022-06-20 16:11:57 Can't say I've tried it